Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 [2] 3 4 ... 42

Author Topic: [DFHack] Roses' Script Collection Updated 5/4/15  (Read 119009 times)

Roses

  • Bay Watcher
    • View Profile
Re: DFHack Spells (linked to DFHack script collection)
« Reply #15 on: January 22, 2014, 02:06:37 pm »

I think I can get the teleportation buildings to work with persistent storage. This should allow for the buildings to work even if you quit DF and start back up again. It may be limited to one entry and one exit portal though... I can't think of a reliable way to link multiple portals, but I will think about it more.

I'll work on it today, should be able to come up with something.
Logged

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: DFHack Spells (linked to DFHack script collection)
« Reply #16 on: January 22, 2014, 02:16:49 pm »

One (well, two, obviously) is perfectly fine. :)
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

Roses

  • Bay Watcher
    • View Profile
Re: DFHack Spells (linked to DFHack script collection)
« Reply #17 on: January 22, 2014, 04:26:45 pm »

Got it working, you need two pieces, the first is the basic check, you need to enable this like you do with projectileExpansion and itemSyndrome (you can just put teleportbase or whatever you call it in the init file)

Code: (teleportbase.lua) [Select]
events = require "plugins.eventful"
events.enableEvent(events.eventType.BUILDING,100)

events.onBuildingCreatedDestroyed.teleport=function(building_id)
bldg = df.building.find(building_id)
if bldg then
all_bldgs = df.global.world.raws.buildings.all
btype = bldg.custom_type
if ((all_bldgs[btype].code == 'TELEPORT_1') or (all_bldgs[btype].code == 'TELEPORT_2')) then
print('placing portal')
pers,status = dfhack.persistent.get('teleport')
if all_bldgs[btype].code == 'TELEPORT_1' then
print('portal 1 placed')
if not pers then
dfhack.persistent.save({key='teleport',value='teleport',ints={bldg.centerx,bldg.centery,bldg.z,-1,-1,-1,-1}})
else
dfhack.persistent.save({key='teleport',ints={bldg.centerx,bldg.centery,bldg.z,pers.ints[4],pers.ints[5],pers.ints[6],-1}})
end
else
print('portal 2 placed')
if not pers then
dfhack.persistent.save({key='teleport',value='teleport',ints={-1,-1,-1,bldg.centerx,bldg.centery,bldg.z,-1}})
else
dfhack.persistent.save({key='teleport',ints={pers.ints[1],pers.ints[2],pers.ints[3],bldg.centerx,bldg.centery,bldg.z,-1}})
end
end
pers,status = dfhack.persistent.get('teleport')
if ((pers.ints[1] > 0) and (pers.ints[4] > 0 )) then
print('portals connected')
dfhack.persistent.save({key='teleport',ints={pers.ints[1],pers.ints[2],pers.ints[3],pers.ints[4],pers.ints[5],pers.ints[6],1}})
else
print('need another portal')
end
else
print('not a portal building')
end
end
end

then the actual teleportation reaction code

Code: (teleport.lua) [Select]
args={...}

local unit = df.unit.find(tonumber(args[1]))
local dir = tonumber(args[2])

pers,status = dfhack.persistent.get('teleport')
if pers.ints[7] == 1 then
if dir == 1 then
local unitoccupancy = dfhack.maps.getTileBlock(unit.pos).occupancy[unit.pos.x%16][unit.pos.y%16]
unit.pos.x = pers.ints[1]
unit.pos.y = pers.ints[2]
unit.pos.z = pers.ints[3]
if not unit.flags1.on_ground then unitoccupancy.unit = false else unitoccupancy.unit_grounded = false end
elseif dir == 2 then
local unitoccupancy = dfhack.maps.getTileBlock(unit.pos).occupancy[unit.pos.x%16][unit.pos.y%16]
unit.pos.x = pers.ints[4]
unit.pos.y = pers.ints[5]
unit.pos.z = pers.ints[6]
if not unit.flags1.on_ground then unitoccupancy.unit = false else unitoccupancy.unit_grounded = false end
else
print('not a valid portal imput')
end
else
print('no valid portals')
end

You will need two buildings, the first named TELEPORT_1 and the second named TELEPORT_2, once both are built you will be able to move between them using reactions. (Note those are the id names, not the displayed in game names)

Then all you need to do is make a reaction with [SYN_CLASS:\COMMAND][SYN_CLASS:teleport][SYN_CLASS:\UNIT_ID][SYN_CLASS:direction] where direction is either 1 or 2, 1 means you want to teleport to TELEPORT_1 and 2 means you want to teleport to TELEPORT_2 (so you should give the TELEPORT_1 building a reaction with direction 2 and the TELEPORT_2 building a reaction with direction 1.

EDIT: This hasn't been massively tested so there are probably some bugs in it, but I was able to move across the map in an instant and down several z levels without any problems (obviously your dwarfs won't use these teleports for pathing)
« Last Edit: January 22, 2014, 04:29:49 pm by Roses »
Logged

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: DFHack Spells (linked to DFHack script collection)
« Reply #18 on: January 22, 2014, 04:31:09 pm »

Does this affect the worker? Or everything in a AoE area like Boltgun described? Can it be done with interactions? For example a interaction that is triggered when fleeing, to teleport the mage back to his safe home.

So many questions. ^^ (I will try this out asap)

Mind if I post the raws, workshops, inorganics and reactions here once I am done?
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

Roses

  • Bay Watcher
    • View Profile
Re: DFHack Spells (linked to DFHack script collection)
« Reply #19 on: January 22, 2014, 04:35:22 pm »

Currently only effects the worker, will modify it before official posting to include a radius effect (although I am not sure how to properly do items, but I am sure it is similar to units).

Yes it can be used with interactions, but right now will only work if both portals are placed (i.e. if you have both portals placed you can use an interaction to teleport to either of them, but if only one is placed you can not use an interaction to teleport to just that one)

And of course feel free to post the raws here if you would like.
Logged

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: DFHack Spells (linked to DFHack script collection)
« Reply #20 on: January 22, 2014, 04:52:27 pm »

Mh.. I cant get it to work.
Edit: removed unfinished stuff.
« Last Edit: January 22, 2014, 05:37:21 pm by Meph »
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

Roses

  • Bay Watcher
    • View Profile
Re: DFHack Spells (linked to DFHack script collection)
« Reply #21 on: January 22, 2014, 04:54:08 pm »

Hmm, what errors are you getting?

Edit: When using autosyndrome you need \WORKER_ID, when using an interaction you need \UNIT_ID.
« Last Edit: January 22, 2014, 04:58:30 pm by Roses »
Logged

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: DFHack Spells (linked to DFHack script collection)
« Reply #22 on: January 22, 2014, 04:57:41 pm »

Code: [Select]
[DFHack]# teleportbase enable
placing portal
portal 1 placed
need another portal
placing portal
portal 2 placed
portals connected
...asterworkDF V4h\Dwarf Fortress\hack\scripts/teleport.lua:3: Cannot write field unit.find(): number expected.
stack traceback:
        [C]: in function 'find'
        ...asterworkDF V4h\Dwarf Fortress\hack\scripts/teleport.lua:3: in main chunk
        (...tail calls...)
[DFHack]#
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

Roses

  • Bay Watcher
    • View Profile
Re: DFHack Spells (linked to DFHack script collection)
« Reply #23 on: January 22, 2014, 04:59:09 pm »

Yeah, you need \WORKER_ID for autosyndrome, \UNIT_ID is for interactions using syndrometrigger
Logged

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: DFHack Spells (linked to DFHack script collection)
« Reply #24 on: January 22, 2014, 05:05:29 pm »

 :-[ (sorry)

Works. :)

Oh, yeah, that will go into the warlocks for sure. :)

EDIT: I think I will make it AoE by using interactions. that way you can teleport a squad that is stationed nearby.
« Last Edit: January 22, 2014, 05:12:34 pm by Meph »
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: DFHack Spells (linked to DFHack script collection)
« Reply #25 on: January 22, 2014, 05:41:06 pm »

Ok, here the finished raws.

1. You have two new buildings, the Orange Portal and the Blue Portal.
2. You have four reactions. You can teleport the worker from Blue to Orange, from Orange to Blue, or teleport all creatures in a 15 tile radius from Blue to Orange, or from Orange to Blue.

Add this to the entity file:
Code: [Select]
[PERMITTED_BUILDING:TELEPORT_1]
[PERMITTED_REACTION:ORANGE_TELEPORT]
[PERMITTED_REACTION:ORANGE_TELEPORT_SQUAD]
[PERMITTED_BUILDING:TELEPORT_2]
[PERMITTED_REACTION:BLUE_TELEPORT]
[PERMITTED_REACTION:BLUE_TELEPORT_SQUAD]

Add this to a building file:
Code: [Select]
[BUILDING_FURNACE:TELEPORT_1]
[NAME:Blue Portal]
[NAME_COLOR:7:0:1]
[BUILD_LABOR:ARCHITECT]
[BUILD_KEY:CUSTOM_B] ///
[DIM:3:3]
[WORK_LOCATION:2:2]
[BLOCK:1:0:0:0]
[BLOCK:2:0:0:0]
[BLOCK:3:0:0:0]
[TILE:0:1:32:222:32]
[TILE:0:2:32:157:32]
[TILE:0:3:187:32:32]
[COLOR:0:1:0:0:0:0:0:1:0:0:0]
[COLOR:0:2:0:0:0:3:3:1:0:0:0]
[COLOR:0:3:0:0:1:0:0:0:0:0:0]
[TILE:1:1:188:32:32]
[TILE:1:2:32:157:32]
[TILE:1:3:187:222:32]
[COLOR:1:1:0:0:1:0:0:0:0:0:0]
[COLOR:1:2:0:0:0:3:3:1:0:0:0]
[COLOR:1:3:0:0:1:0:0:1:0:0:0]
[TILE:2:1:188:32:200]
[TILE:2:2:222:157:32]
[TILE:2:3:187:32:32]
[COLOR:2:1:0:0:1:0:0:0:0:0:1]
[COLOR:2:2:0:0:1:3:3:1:0:0:0]
[COLOR:2:3:0:0:1:0:0:0:0:0:0]
[TILE:3:1:188:220:200]
[TILE:3:2:222:157:221]
[TILE:3:3:187:223:201]
[COLOR:3:1:0:0:1:0:0:1:0:0:1]
[COLOR:3:2:0:0:1:3:3:1:0:0:1]
[COLOR:3:3:0:0:1:0:0:1:0:0:1]
[BUILD_ITEM:2:BLOCKS:NONE:NONE:NONE]


[BUILDING_FURNACE:TELEPORT_2]
[NAME:Orange Portal]
[NAME_COLOR:7:0:1]
[BUILD_LABOR:ARCHITECT]
[BUILD_KEY:CUSTOM_C] ///[DIM:3:3]
[WORK_LOCATION:2:2]
[BLOCK:1:0:0:0]
[BLOCK:2:0:0:0]
[BLOCK:3:0:0:0]
[TILE:0:1:32:222:32]
[TILE:0:2:32:157:32]
[TILE:0:3:187:32:32]
[COLOR:0:1:0:0:0:0:0:1:0:0:0]
[COLOR:0:2:0:0:0:4:4:1:0:0:0]
[COLOR:0:3:0:0:1:0:0:0:0:0:0]
[TILE:1:1:188:32:32]
[TILE:1:2:32:157:32]
[TILE:1:3:187:222:32]
[COLOR:1:1:0:0:1:0:0:0:0:0:0]
[COLOR:1:2:0:0:0:4:4:1:0:0:0]
[COLOR:1:3:0:0:1:0:0:1:0:0:0]
[TILE:2:1:188:32:200]
[TILE:2:2:222:157:32]
[TILE:2:3:187:32:32]
[COLOR:2:1:0:0:1:0:0:0:0:0:1]
[COLOR:2:2:0:0:1:4:4:1:0:0:0]
[COLOR:2:3:0:0:1:0:0:0:0:0:0]
[TILE:3:1:188:220:211]
[TILE:3:2:222:157:221]
[TILE:3:3:187:223:201]
[COLOR:3:1:0:0:1:0:0:1:0:0:1]
[COLOR:3:2:0:0:1:4:4:1:0:0:1]
[COLOR:3:3:0:0:1:0:0:1:0:0:1]
[BUILD_ITEM:2:BLOCKS:NONE:NONE:NONE]

Add this to an inorganic file:
Code: [Select]
[INORGANIC:ORANGE_TELEPORT]
[USE_MATERIAL_TEMPLATE:STONE_VAPOR_TEMPLATE]
[STATE_NAME_ADJ:ALL:Activate the portal][MATERIAL_VALUE:0][SYNDROME]
[SYN_CLASS:\AUTO_SYNDROME]
[SYN_CLASS:\COMMAND][SYN_CLASS:teleport][SYN_CLASS:\WORKER_ID][SYN_CLASS:2]

[INORGANIC:BLUE_TELEPORT]
[USE_MATERIAL_TEMPLATE:STONE_VAPOR_TEMPLATE]
[STATE_NAME_ADJ:ALL:Activate the portal][MATERIAL_VALUE:0][SYNDROME]
[SYN_CLASS:\AUTO_SYNDROME]
[SYN_CLASS:\COMMAND][SYN_CLASS:teleport][SYN_CLASS:\WORKER_ID][SYN_CLASS:1]

[INORGANIC:ORANGE_TELEPORT_SQUAD]
[USE_MATERIAL_TEMPLATE:STONE_VAPOR_TEMPLATE]
[STATE_NAME_ADJ:ALL:Activate the portal][MATERIAL_VALUE:0][SYNDROME]
[SYN_CLASS:\AUTO_SYNDROME]
[CE_SPEED_CHANGE:SPEED_PERC:1:START:0:END:200] 
      [CE_CAN_DO_INTERACTION:PROB:100:START:0:END:200]
  [CDI:INTERACTION:TELEPORT_FROM_ORANGE_TO_BLUE]
[CDI:TARGET:A:LINE_OF_SIGHT]
[CDI:TARGET_RANGE:A:15]
[CDI:VERB:bug:teleports all nearby units to the blue portal:NA]
[CDI:TARGET_VERB:bug:is teleported to the blue portal]
[CDI:MAX_TARGET_NUMBER:A:100]
[CDI:WAIT_PERIOD:250]

[INORGANIC:BLUE_TELEPORT_SQUAD]
[USE_MATERIAL_TEMPLATE:STONE_VAPOR_TEMPLATE]
[STATE_NAME_ADJ:ALL:Activate the portal][MATERIAL_VALUE:0][SYNDROME]
[SYN_CLASS:\AUTO_SYNDROME]
[CE_SPEED_CHANGE:SPEED_PERC:1:START:0:END:200] 
      [CE_CAN_DO_INTERACTION:PROB:100:START:0:END:200]
  [CDI:INTERACTION:TELEPORT_FROM_BLUE_TO_ORANGE]
[CDI:TARGET:A:LINE_OF_SIGHT]
[CDI:TARGET_RANGE:A:15]
[CDI:VERB:bug:teleports all nearby units to the orange portal:NA]
[CDI:TARGET_VERB:bug:is teleported to the orange portal]
[CDI:MAX_TARGET_NUMBER:A:100]
[CDI:WAIT_PERIOD:250]

Add this to your reactions:
Code: [Select]
[REACTION:ORANGE_TELEPORT]
[NAME:Teleport worker to orange portal]
[BUILDING:TELEPORT_1:CUSTOM_A]
[PRODUCT:0:1:BOULDER:NONE:INORGANIC:ORANGE_TELEPORT]   
[SKILL:ALCHEMY]

[REACTION:BLUE_TELEPORT]
[NAME:Teleport worker to blue portal]
[BUILDING:TELEPORT_2:CUSTOM_A]
[PRODUCT:0:1:BOULDER:NONE:INORGANIC:BLUE_TELEPORT]   
[SKILL:ALCHEMY]

[REACTION:ORANGE_TELEPORT_SQUAD]
[NAME:Teleport nearby units to orange portal]
[BUILDING:TELEPORT_1:CUSTOM_SHIFT_A]
[PRODUCT:0:1:BOULDER:NONE:INORGANIC:ORANGE_TELEPORT_SQUAD]   
[SKILL:ALCHEMY]

[REACTION:BLUE_TELEPORT_SQUAD]
[NAME:Teleport nearby units to blue portal]
[BUILDING:TELEPORT_2:CUSTOM_SHIFT_A]
[PRODUCT:0:1:BOULDER:NONE:INORGANIC:BLUE_TELEPORT_SQUAD]   
[SKILL:ALCHEMY]

And add this to your interactions:
Code: [Select]

[INTERACTION:TELEPORT_FROM_ORANGE_TO_BLUE]
   [I_SOURCE:CREATURE_ACTION]
   [I_TARGET:A:CREATURE]
[IT_CANNOT_TARGET_IF_ALREADY_AFFECTED]
   [IT_LOCATION:CONTEXT_CREATURE]
   [I_EFFECT:ADD_SYNDROME][IE_TARGET:A][IE_IMMEDIATE]
      [SYNDROME]
[SYN_CLASS:\COMMAND][SYN_CLASS:teleport][SYN_CLASS:\UNIT_ID][SYN_CLASS:2]
[CE_SPEED_CHANGE:SPEED_PERC:101:START:0:END:100] 

[INTERACTION:TELEPORT_FROM_BLUE_TO_ORANGE]
   [I_SOURCE:CREATURE_ACTION]
   [I_TARGET:A:CREATURE]
[IT_CANNOT_TARGET_IF_ALREADY_AFFECTED]
   [IT_LOCATION:CONTEXT_CREATURE]
   [I_EFFECT:ADD_SYNDROME][IE_TARGET:A][IE_IMMEDIATE]
      [SYNDROME]
[SYN_CLASS:\COMMAND][SYN_CLASS:teleport][SYN_CLASS:\UNIT_ID][SYN_CLASS:1]
[CE_SPEED_CHANGE:SPEED_PERC:101:START:0:END:100] 

Edit: Fixed the unit_id vs. worker_id mixup.
« Last Edit: January 22, 2014, 07:34:20 pm by Meph »
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

Roses

  • Bay Watcher
    • View Profile
Re: DFHack Spells (linked to DFHack script collection)
« Reply #26 on: January 22, 2014, 06:25:12 pm »

It should be noted that even if you deconstruct one of the portals you will still be teleported to that spot. However making another portal somewhere else should work to update the teleport location (i.e. deconstruct TELEPORT_1, TELEPORT_2 will still send you to the old location. Construct new TELEPORT_1, TELEPORT_2 will send you to the new location.
« Last Edit: January 22, 2014, 07:24:07 pm by Roses »
Logged

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: DFHack Spells (linked to DFHack script collection)
« Reply #27 on: January 22, 2014, 06:32:27 pm »

OMG, Roses. You know what?

Make an interaction with HINT:ATTACK, and teleport all these invaders directly to portal 1. Which is in a lionpit/magmalake/hfs/next to angry FB/in an airlocked room supported by one pillar.

EDIT: We have to do some teleporting invaders. :D Siege arrives, teleports into your fort.

EDIT2: Hooking up a harmless building like a forge or something to an interaction of a skulking race that only sends hidden thieves, that can actually fight well. And if you dont find them within a time limit, they spawn an army. ^^
« Last Edit: January 22, 2014, 06:35:21 pm by Meph »
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

Roses

  • Bay Watcher
    • View Profile
Re: DFHack Spells (linked to DFHack script collection)
« Reply #28 on: January 22, 2014, 07:23:50 pm »

That would be possible, you could make a race that used the portals against you and can teleport into them. Or a race that can teleport to one of your meeting rooms or a random bedroom, that could be entertaining.

And here's a new idea. With the use of persistent variables (which I used in the teleport) it would be possible to track multiple things about a given dwarf without complex syndrome class effects. There is one string and 7 integers that can be stored in a persistent variable. For example you could have each integer represent a certain level of advancement in a specified field (so integer 1 would be level in the warrior class, integer 2 would be level in the rogue class, integer 3 would be level in the mage class, etc...) then you could make scripts that only work for certain combinations of values.
Logged

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: DFHack Spells (linked to DFHack script collection)
« Reply #29 on: January 22, 2014, 07:36:03 pm »

So for example: Unit kills 50 enemies, learns new warrior ability? Unit finished praying 100 times, gets new religion-based ability?

You guys are killing me. I cant add that much stuff. ^^

EDIT: And a question: What happens if I build 10 blue portals, and 1 orange one? Will blue portal that I build last be active?
« Last Edit: January 22, 2014, 07:49:32 pm by Meph »
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::
Pages: 1 [2] 3 4 ... 42