Some of my scripts, including some jojo stand scripts.
I'm pretty new to this whole Scripting business so expect some errors and glitches.
Instructions should be included in the scripts themselves.
Utility scripts:swapsoul - Swaps body and soul of adventurer to selected unit. Comes with DOOM mode, when activated it makes every friendly npc crazed after your blood.
summonUnits - Teleports all units to the cursor. Ability to unsummon to previous positions included.
Jojo core scripts:Stands - controller script for all other stand scripts. Required for stands.
Put these in dfhack.init: #first ability
keybinding add Shift-B "stands -special1"
#second ability
keybinding add Shift-N "stands -special2"
Make a file in df directory named "onMapLoad.init" and put this line in there:time - does stuff. required for stands
standinit - does stuff. Requires for stands.
Jojo scripts:TheHand - imitates the abilities of it's counterpart from the series, punchy ghost not included.
Can teleport player, teleport enemies toward player; can erase items, enemies and items.
[Made in Heaven] scripts: note: WILL kill anything not immortal. Immortality recommended. heaventime - wrapper for [Made in Heaven], instructions included
accel - first stage of [Made in Heaven], accelerates time. Required for heaven.
deccel - second and final stage of [Made in Heaven], deccelerates time. Required for heaven.
soulswap:
--swaps current adventurer's soul with selected unit's soul then body swaps.
--aggronow makes every npc aggresive towards player, fun fun fun
--aggro carries over aggro from one body to the other for more fun fun fun
--probably my most stable script yet
--doesn't work on soul less units
swap = reqscript 'bodyswap'
local utils = require('utils')
local validArgs = utils.invert({
'aggro',
'aggronow',
'help'
})
local args = utils.processArgs({...}, validArgs)
if ( args.help ) then
print("swaps soul of player to unit and the unit's soul to player.")
print("syntax: ( soul ) default mode. ( soul -aggronow ) enables DOOM mode")
print(" ( soul -aggro ) if DOOM mode is enabled, it carries over to the new body.")
end
if df.global.gamemode == df.game_mode.ADVENTURE and not args.aggronow then
giver = dfhack.gui.getSelectedUnit().status.current_soul
--giverstrength = dfhack.gui.getSelectedUnit().body.physical_attrs.STRENGTH.value
--giveragility = dfhack.gui.getSelectedUnit().body.physical_attrs.AGILITY.value
--givertoughness = dfhack.gui.getSelectedUnit().body.physical_attrs.TOUGHNESS.value
--giverendurance = dfhack.gui.getSelectedUnit().body.physical_attrs.ENDURANCE.value
--giverrecuperation = dfhack.gui.getSelectedUnit().body.physical_attrs.RECUPERATION.value
taker = df.global.world.units.active[0].status.current_soul
--takerstrength = df.global.world.units.active[0].body.physical_attrs.STRENGTH.value
--takeragility = df.global.world.units.active[0].body.physical_attrs.AGILITY.value
--takertoughness = df.global.world.units.active[0].body.physical_attrs.TOUGHNESS.value
--takerendurance = df.global.world.units.active[0].body.physical_attrs.ENDURANCE.value
--takerrecuperation = df.global.world.units.active[0].body.physical_attrs.RECUPERATION.value
if df.global.world.units.active[0].enemy.caste_flags.OPPOSED_TO_LIFE == true or args.aggro then
df.global.world.units.active[0].enemy.caste_flags.OPPOSED_TO_LIFE = false
dfhack.gui.getSelectedUnit().enemy.caste_flags.OPPOSED_TO_LIFE = true
end
df.global.world.units.active[0].status.current_soul = giver
df.global.world.units.active[0].status.souls[0] = giver
--df.global.world.units.active[0].body.physical_attrs.AGILITY.value = giveragility
--df.global.world.units.active[0].body.physical_attrs.TOUGHNESS.value = givertoughness
--df.global.world.units.active[0].body.physical_attrs.STRENGTH.value = giverstrength
--df.global.world.units.active[0].body.physical_attrs.ENDURANCE.value = giverendurance
--df.global.world.units.active[0].body.physical_attrs.RECUPERATION.value = giverrecuperation
dfhack.gui.getSelectedUnit().status.current_soul = taker
dfhack.gui.getSelectedUnit().status.souls[0] = taker
--dfhack.gui.getSelectedUnit().body.physical_attrs.STRENGTH.value = takerstrength
--dfhack.gui.getSelectedUnit().body.physical_attrs.AGILITY.value = takeragility
--dfhack.gui.getSelectedUnit().body.physical_attrs.TOUGHNESS.value = takertoughness
--dfhack.gui.getSelectedUnit().body.physical_attrs.ENDURANCE.value = takerendurance
--dfhack.gui.getSelectedUnit().body.physical_attrs.RECUPERATION.value = takerrecuperation
swap.swapAdvUnit(dfhack.gui.getSelectedUnit())
elseif args.aggronow then
df.global.world.units.active[0].enemy.caste_flags.OPPOSED_TO_LIFE = true
else
print("Needo be adventuras mode, eddyboy!")
end
summonunits:
x = df.global.cursor.x
y = df.global.cursor.y
local heal = reqscript("full-heal")
yoff = 0
xoff = 0
if count == nil or allx == nil or ally == nil or allz == nil then
count = 0
allx = {}
ally = {}
allz = {}
end
local utils = require('utils')
local validArgs = utils.invert({
'summon',
'unsummon',
'help'
})
local args = utils.processArgs({...}, validArgs)
function summon()
for _, item in ipairs(df.global.world.units.active) do
if ( not (item == df.global.world.units.active[0]) and not item.flags1.inactive) then
if ( count % 10 == 0 ) then
yoff = yoff + 1
xoff = 0
end
--heal.heal(item,true,true)
item.pos.x = x + xoff
item.pos.y = y + yoff
item.pos.z = df.global.cursor.z
count = count + 1
xoff = xoff + 1
end
df.global.world.units.active[0].healing_rate[11] = 1
end
end
if ( args.help ) then
print("summons units from entire map, can also unsummon them to their previous position")
print("syntax:( summonUnits -summon ; summonUnits -unsummon )")
end
if ( args.summon ) then
for _, item in ipairs(df.global.world.units.active) do
if ( item ~= df.global.world.units.active[0]) then
count = count + 1
allx[_] = item.pos.x
ally[_] = item.pos.y
allz[_] = item.pos.z
end
end
summon()
end
if ( args.unsummon and count ~= 0 ) then
df.global.world.units.active[0].healing_rate[11] = 1
for _, item in ipairs(df.global.world.units.active) do
if ( item ~= df.global.world.units.active[0] ) then
item.pos.x = allx[_]
item.pos.y = ally[_]
item.pos.z = allz[_]
end
end
if ( count > 1000 ) then
count = 0
end
end
Stands:
local ZaHando = reqscript("TheHand")
local KiraQueen = reqscript("KillerQueen")
local utils = require 'utils'
local validArgs = utils.invert({
'special1',
'special2',
'help'
})
--for killer queen, change "Zahando" to "KiraQueen" in ZaHando.firstAbility() and ZaHando.secondAbility()
--see script for instructions
local args = utils.processArgs({...}, validArg
--if args.attack thens)
--ZaHando.attack()
if args.special1 then
ZaHando.firstAbility()
elseif args.special2 then
ZaHando.secondAbility()
elseif args.help then
print("controller for various stand scripts, by itself it doesn't do anything.")
else
print("saysomething:)")
end
time
--df.global.world.units.active[0].healing_rate[0]
--time passed
--df.global.cur_year_tick_advmode
--current time
--@ module = true
if (timeBet == nil) then
timeBet = 0
end
if (df.global.world.units.active[0].healing_rate[2] == 0 or
df.global.world.units.active[0].healing_rate[2] == null
or df.global.world.units.active[0].healing_rate[2] == 100 or
df.global.world.units.active[0].healing_rate[2] == 1000)
then df.global.world.units.active[0].healing_rate[2] = 1
end
--charge
pop = 100
limit = 9
if df.global.world.units.active[0].healing_rate[10] ~= 0 then
df.global.world.units.active[0].healing_rate[10] = 0
end
if (df.global.world.units.active[0].healing_rate[2] > limit) then
df.global.world.units.active[0].healing_rate[2] = limit
end
function countTime()
if ( df.global.world.units.active[0].healing_rate[0] == 100 or df.global.world.units.active[0].healing_rate[0] == 1000 ) then
timeBet = 0
end
timeBet = timeBet + 101
if ( timeBet >= pop) then
-- Timebet = Timebet + 2000
timeBet = 0
-- if charge =< 3 then
if ( df.global.world.units.active[0].healing_rate[2] < limit) then
-- charge = charge + 1
df.global.world.units.active[0].healing_rate[2] = df.global.world.units.active[0].healing_rate[2] + 1
-- print(charge)
print("you got " .. df.global.world.units.active[0].healing_rate[2]-1 .. " charges!")
end
end
-- if ( timebet >= globaltime ) then
-- timebet = globaltime
df.global.world.units.active[0].healing_rate[0] = timeBet
end
countTime()
standinit:
if ( df.global.gamemode == 1 ) then
command = " repeat -name standtime -time 50 -timeUnits ticks -command [ time ] "
dfhack.run_command(command)
end
TheHand:
--The hand from jojo's bizzare adventure.
--Primary ability: Erase space, allows teleportation to a tile within 15 blocks away from the player.
--Alt primary: if a unit is selected, it teleports the unit towards the player. Also stuns them.
--Secondary Ability: Erase creature, erases people and monsters. Unit must be unconsciouss or winded.
--Alt secondary ability: Item erasure, if an tile is selected any item on it is erased.
--Cooldown, lasts a few adventure mode turns. Disables ability to erase space, creatures. Items can still be deleted.
--Time.lua must be active, but if dfhack.init is correctly set, it should be.
--i know it's needlessly complicated, especially the range checks.
--@ module = true
id1 = df.global.world.units.active[0].id
-- DO NOT RESEARCH FURTHER
function attack()
command = "projectile -type shooting -unitSource 488 -locationTarget [ 1 2 3 ] -item WEAPON:ITEM_WEAPON_DAGGER_LARGE -material INORGANIC:IRON -number 1 "
dfhack.run_command(command)
end
function firstAbility() -- teleportation
if ( not dfhack.gui.getSelectedUnit(true) ) then
if (df.global.world.units.active[0].healing_rate[2] > 1 and df.global.ui_advmode.menu == df.ui_advmode_menu.Look and df.global.world.units.active[0].healing_rate[10] == 0 ) then
local tempx = df.global.world.units.active[0].pos.x
local tempy = df.global.world.units.active[0].pos.y
if (math.abs(df.global.world.units.active[0].pos.x - df.global.cursor.x) < 15) then
df.global.world.units.active[0].pos.x = df.global.cursor.x
end
if (math.abs(df.global.world.units.active[0].pos.y - df.global.cursor.y) < 15) then
df.global.world.units.active[0].pos.y = df.global.cursor.y
end
if ( tempx ~= df.global.world.units.active[0].pos.x or tempy ~= df.global.world.units.active[0].pos.y ) then
print("WOOOOSH!")
print(df.global.world.units.active[0].healing_rate[2] - 2)
df.global.world.units.active[0].healing_rate[2] = df.global.world.units.active[0].healing_rate[2] - 1
df.global.world.units.active[0].healing_rate[10] = 1
--healing_rate[10] acts as a cooldown, it is turned to 0 in time.lua
end
end
elseif (df.global.world.units.active[0].healing_rate[2] > 1 and df.global.world.units.active[0].healing_rate[10] == 0 and dfhack.gui.getSelectedUnit(true) ) then
--for later check
local tempx = dfhack.gui.getSelectedUnit().pos.x
local tempy = dfhack.gui.getSelectedUnit().pos.y
--enemy teleportation
if (math.abs(df.global.world.units.active[0].pos.x - dfhack.gui.getSelectedUnit().pos.y) < 15) and (math.abs(df.global.world.units.active[0].pos.y - dfhack.gui.getSelectedUnit().pos.y) < 15) then
if (dfhack.gui.getSelectedUnit().pos.x > df.global.world.units.active[0].pos.x) then
dfhack.gui.getSelectedUnit().pos.x = df.global.world.units.active[0].pos.x + 1
end
if (dfhack.gui.getSelectedUnit().pos.x < df.global.world.units.active[0].pos.x) then
dfhack.gui.getSelectedUnit().pos.x = df.global.world.units.active[0].pos.x - 1
end
--y teleportation
if (dfhack.gui.getSelectedUnit().pos.y > df.global.world.units.active[0].pos.y) then
dfhack.gui.getSelectedUnit().pos.y = df.global.world.units.active[0].pos.y + 1
end
if (dfhack.gui.getSelectedUnit().pos.y < df.global.world.units.active[0].pos.y) then
dfhack.gui.getSelectedUnit().pos.y = df.global.world.units.active[0].pos.y - 1
end
--to see if the charge should be taken
end
if (tempx ~= dfhack.gui.getSelectedUnit().pos.x or tempy ~= dfhack.gui.getSelectedUnit().pos.y) then
print("WOOOOSH!")
print(df.global.world.units.active[0].healing_rate[2] - 2)
dfhack.gui.getSelectedUnit().counters.stunned = 10
df.global.world.units.active[0].healing_rate[2] = df.global.world.units.active[0].healing_rate[2] - 1
df.global.world.units.active[0].healing_rate[10] = 1
end
end
if (df.global.ui_advmode.menu ~= df.ui_advmode_menu.Look) then
print("You have to use the cursor!")
end
if ( df.global.world.units.active[0].healing_rate[2] <= 0 ) then
print("No charges!")
end
end
--stolen from full-heal
function addErasureEvent(histFigID)
local event = df.history_event_hist_figure_diedst:new()
event.victim_hf = histFigID
event.slayer_hf = df.global.world.units.active[0].hist_figure_id
event.year = df.global.cur_year
event.seconds = df.global.cur_year_tick
event.id = df.global.hist_event_next_id
event.slayer_race = df.global.world.units.active[0].race
event.slayer_caste = df.global.world.units.active[0].caste
event.death_cause = 22
df.global.world.history.events:insert('#', event)
df.global.hist_event_next_id = df.global.hist_event_next_id + 1
end
function secondAbility()
-- it just works? position and range checks
if (df.global.cursor.x < df.global.world.units.active[0].pos.x) then
if (df.global.world.units.active[0].pos.x - df.global.cursor.x) < 2 then
switch1 = true
end
end
if (df.global.cursor.x > df.global.world.units.active[0].pos.x) then
if (df.global.cursor.x - df.global.world.units.active[0].pos.x) < 2 then
switch1 = true
end
end
if (df.global.cursor.y < df.global.world.units.active[0].pos.y) then
if (df.global.world.units.active[0].pos.y - df.global.cursor.y) < 2 then
switch2 = true
end
end
if (df.global.cursor.y > df.global.world.units.active[0].pos.y) then
if (df.global.cursor.y - df.global.world.units.active[0].pos.y) < 2 then
switch2 = true
end
end
if df.global.cursor.x ~= -30000 then
tempx = df.global.cursor.x
tempy = df.global.cursor.y
tempz = df.global.cursor.z
--floor item erasure
for i, v in ipairs(df.global.world.items.other.IN_PLAY) do
if (v.pos.x == tempx and v.pos.y == tempy and v.pos.z == tempz and switch1 == true and switch2 == true) then
v.pos.x = -30000
v.pos.y = -30000
v.pos.z = -30000
end
end
--Creature erasure, limits on this one for balance
for i, v in ipairs(df.global.world.units.active) do
if (v.pos.x == tempx and v.pos.y == tempy and v.pos.z == tempz and df.global.world.units.active[0] ~= v and switch1 == true and switch2 == true
and ( df.global.world.units.active[0].healing_rate[2] - 3 ) >= 1 ) then
if (v.counters.unconscious > 0 or v.counters.suffocation > 49) then
v.pos.x = -30000
v.pos.y = -30000
v.pos.z = -30000
v.idle_area.x = -30000
v.idle_area.y = -30000
v.idle_area.z = -30000
v.flags1.inactive = true
v.flags1.move_state = false
v.flags1.can_swap = false
v.flags1.check_flows = false
v.flags2.killed = true
print("WOOOOSH!")
print(df.global.world.units.active[0].healing_rate[2] - 3)
df.global.world.units.active[0].healing_rate[2] = df.global.world.units.active[0].healing_rate[2] - 2
if ( v.hist_figure_id ~= -1 ) then
addErasureEvent(v.hist_figure_id,v.race,v.caste)
end
df.global.world.units.active[0].healing_rate[10] = 1
else
print("To erase a man, he needs to be short of breath or uncoscious.")
end
end
end
end
end
--function canItReach(item1x,item1y,item1z,item2x,item2y,item2z,distance,dimension)
-- if (item1x < item1x) then
-- if (item2x - item1x < distance) then
-- switch1 = true
-- end
-- end
-- if (item1x > item2x) then
-- if (item1x - item2x < distance) then
-- switch1 = true
-- end
-- end
-- if (item1y < item2x) then
-- if (item2x - item1y < distance) then
-- switch2 = true
-- end
-- end
-- if (item1y > item2x) then
-- if (item1y - item2x < distance) then
-- switch2 = true
-- end
-- end
-- if (item1z < item2z) then
-- if(item2z - item1z < distance) then
-- switch3 = true
-- end
-- end
-- if (item1z > item2z) then
-- if(item1z - item2z < distance) then
-- switch3 = true
-- end
-- end
-- if (dimension == "2d" and switch1 == true and switch2 == true) then
-- return true
-- elseif (dimension == "3d" and switch1 == true and switch2 == true and switch3 == true) then
-- return true
-- end
--end
heaventime:
local utils = require('utils')
local accel = reqscript("accel")
local validArgs = utils.invert({
'year',
'heaven',
'cancel',
'help',
'deccel'
})
--@ module = true
local args = utils.processArgs({...}, validArgs)
lastTime = df.global.cur_year
if(args.help) then
print("Accelerates time until it turns to YEAR.")
print("Syntax:( heaventime -heaven -year 5000 ) accelerates time to year 5000. ")
print("( heaventime -cancel ) cancels the event. ")
end
if (args.year) then
futureYear = tonumber(args.year)
end
print(futureYear)
if (args.heaven) then
command = "repeat -name maiden -time 10 -timeUnits ticks -command [ accel ] "
dfhack.run_command(command)
end
if (args.cancel) then
accel.cancelHeaven()
local command = "repeat -cancel maiden"
dfhack.run_command(command)
local command = "repeat -cancel maiden1"
dfhack.run_command(command)
end
accel:
local heaven = reqscript("heaventime")
--@ module = true
if (now == nil or Then == nil) then
now = heaven.lastTime
Then = heaven.futureYear
end
function cancelHeaven()
time0 = nil
now = nil
df.global.cur_season_tick = 0
local command = "repeat -cancel maiden"
dfhack.run_command(command)
end
function degradeItems()
for _,item in ipairs(df.global.world.items.other.ANY_CAN_ROT) do
item.wear_timer = item.wear_timer + 16064000
end
end
if ( time0 == nil) then
time0 = df.global.cur_season_tick
time1 = df.global.cur_season_tick + 100
time2 = df.global.cur_season_tick + 500
time3 = df.global.cur_season_tick + 2000
time4 = df.global.cur_season_tick + 8000
time5 = df.global.cur_season_tick + 20000
time6 = df.global.cur_season_tick + 500000
time7 = df.global.cur_season_tick + 800000
time8 = df.global.cur_season_tick + 1200000
time9 = df.global.cur_season_tick + 1500000
time9 = df.global.cur_season_tick + 15000000
end
timeforheaven = 999999999
--stop laughing
if ( now + 20 <= timeforheaven and df.global.cur_season_tick < time1 ) then
df.global.cur_season_tick = df.global.cur_season_tick + 5
print("1")
end
if ( now + 20 <= timeforheaven and df.global.cur_season_tick <= time2 and df.global.cur_season_tick >= time1 ) then
df.global.cur_season_tick = df.global.cur_season_tick + 25
print("2")
end
if ( now + 20 <= timeforheaven and df.global.cur_season_tick <= time3 and df.global.cur_season_tick >= time2 ) then
df.global.cur_season_tick = df.global.cur_season_tick + 110
print("3")
end
if ( now + 20 <= timeforheaven and df.global.cur_season_tick <= time4 and df.global.cur_season_tick >= time3 ) then
df.global.cur_season_tick = df.global.cur_season_tick + 650
print("4")
end
if ( now + 20 <= timeforheaven and df.global.cur_season_tick <= time5 and df.global.cur_season_tick >= time4 ) then
df.global.cur_season_tick = df.global.cur_season_tick + 8000
print("5")
end
if ( now + 20 <= timeforheaven and df.global.cur_season_tick <= time6 and df.global.cur_season_tick >= time5 ) then
df.global.cur_season_tick = df.global.cur_season_tick + 40000
df.global.cur_year = df.global.cur_year + 1
print("6")
end
if ( now + 20 <= timeforheaven and df.global.cur_season_tick <= time7 and df.global.cur_season_tick >= time6 ) then
df.global.cur_season_tick = df.global.cur_season_tick + 40000
df.global.cur_year = df.global.cur_year + 10
print("7")
end
if ( now + 20 <= timeforheaven and df.global.cur_season_tick <= time8 and df.global.cur_season_tick >= time7 ) then
df.global.cur_season_tick = df.global.cur_season_tick + 403200
df.global.cur_year = df.global.cur_year + 100
print("8")
end
if ( now + 20 <= timeforheaven and df.global.cur_season_tick <= time9 and df.global.cur_season_tick >= time8 ) then
df.global.cur_season_tick = df.global.cur_season_tick + 403200
df.global.cur_year = df.global.cur_year + 1000
print("9")
end
if ( df.global.cur_season_tick > time9 or df.global.cur_season_tick > timeforheaven ) then
deccel()
end
function deccel()
cancelHeaven()
df.global.cur_year = 0
local command = "repeat -name maiden1 -time 10 -timeUnits ticks -command [ deccel ]"
dfhack.run_command(command)
end
function deccelDebug()
cancelHeaven()
heaven.futureYear = 500
df.global.cur_year = 0
local command = "repeat -name maiden1 -time 10 -timeUnits ticks -command [ deccel ]"
dfhack.run_command(command)
end
if ( time0 ~= nil) then
print("time0 " .. time0)
end
deccel:
local heaven = reqscript("heaventime")
local heal = reqscript("full-heal")
--@ module = true
Then = heaven.futureYear
print(Then)
function historyCheck()
for _,unit in ipairs(df.global.world.nemesis.all) do
if ( unit.figure.born_year > df.global.cur_year and unit.figure.unit_id ~= df.global.world.units.active[0].id and unit.unit ~= nil and unit.unit.enemy.caste_flags.CAN_LEARN == false and unit.unit.enemy.caste_flags.CAN_SPEAK == false ) then
print("killed" .. _)
unit.unit.flags2.killed = true
unit.unit.flags3.ghostly = true
unit.unit.flags1.inactive = true
for _,unit in ipairs(df.global.world.units.active) do
if ( unit.birth_year > df.global.cur_year and unit.id ~= df.global.world.units.active[0].id) then
print("killed " .. _)
unit.flags2.killed = true
unit.flags3.ghostly = true
unit.flags1.inactive = true
end
end
end
end
end
function degradeItems()
for _,item in ipairs(df.global.world.items.other.ANY_CAN_ROT) do
item.wear_timer = item.wear_timer + 16064000
end
end
function cancelHeaven()
time0 = nil
now = nil
df.global.cur_season_tick = 0
local command = "repeat -cancel maiden"
dfhack.run_command(command)
end
if (df.global.cur_year <= 0) then
df.global.cur_year = 1
end
if ( df.global.cur_year < math.floor((Then/2))) then
df.global.cur_season_tick = df.global.cur_season_tick + 403200
df.global.cur_year = df.global.cur_year + math.floor((Then*5/100))
end
if ( df.global.cur_year >= math.floor((Then/2))) then
df.global.cur_season_tick = df.global.cur_season_tick + 3632
if ( math.floor((Then*20/100)) > 1 ) then
df.global.cur_year = df.global.cur_year + math.floor((Then*2/100))
else
df.global.cur_year = df.global.cur_year + 1
end
end
if ( df.global.cur_year >= Then ) then
df.global.cur_year = Then
--historyCheck()
degradeItems()
local command = "repeat -cancel maiden1"
dfhack.run_command(command)
end