So here's what I have for corrosion now, that I can show with out needing additional raws. stick this into Onfunction/plugin.lua file in the DFhack's dfusion section.
this is basic zombie mode at best, any one dies will come back as a zombie then if they die again they won't comeback. meaning you have to kill people twice with this installed.
function ControlCiv3()
--first three lines same as before (because we will need an offset of creature at location x,y,z)
myoff=offsets.getEx("AdvCreatureVec")
vector=engine.peek(myoff,ptr_vector)
leg=offsets.getEx("Legends")
legvec=engine.peek(leg,ptr_vector)
local trgs=selectciv()
for k,v in pairs(trgs) do
--print("members:"..k)
trgid=engine.peek(vector:getval(0),ptr_Creature.ID) --get players ID
playerlegid=getlegendsid(vector:getval(0))
trglegid=getlegendsid(v)
trgid=engine.peek(vector:getval(0),ptr_Creature.ID) --get players ID
engine.poke(v,ptr_Creature.followID,trgid) -- if not just write the players ID.
engine.poke(legvec:getval(trglegid),ptr_legends2.follow,playerlegid)
engine.poke(vector:getval(0),ptr_Creature.followID,-1)
engine.poke(legvec:getval(trglegid),ptr_legends2.follow,-1)
end
end
function ControlRace()
--first three lines same as before (because we will need an offset of creature at location x,y,z)
myoff=offsets.getEx("AdvCreatureVec")
vector=engine.peek(myoff,ptr_vector)
leg=offsets.getEx("Legends")
legvec=engine.peek(leg,ptr_vector)
local trgs=selectRace2()
for k,v in pairs(trgs) do
--print("members:"..k)
id=engine.peek(vector:getval(0),ptr_Creature.race)
id2=engine.peek(v,ptr_Creature.race)
if id==id2 then
trgid=engine.peek(vector:getval(0),ptr_Creature.ID) --get players ID
playerlegid=getlegendsid(vector:getval(0))
trglegid=getlegendsid(v)
trgid=engine.peek(vector:getval(0),ptr_Creature.ID) --get players ID
engine.poke(v,ptr_Creature.followID,trgid) -- if not just write the players ID.
engine.poke(legvec:getval(trglegid),ptr_legends2.follow,playerlegid)
engine.poke(vector:getval(0),ptr_Creature.followID,-1)
engine.poke(legvec:getval(trglegid),ptr_legends2.follow,-1)
end
end
end
function keeptrack()
local trgs=selectmat()
for k,v in pairs(trgs) do
if k=>1 then --checks if there one or more cigar
Cure()
end
end
function selectmat()
local retvec={} --return vector (or a list)
myoff=offsets.getEx("Items")
vector=engine.peek(myoff,ptr_vector)
for i=0,vector:size()-1 do --check all creatures
off=vector:getval(i)
mat=engine.peek(off,ptr_item.mat)
submat=engine.peek(off,ptr_item.submat)
submat2=engine.peek(off,ptr_item.submat2)
lid=engine.peek(off,ptr_item.legendid)
RTI=engine.peek(off,ptr_item.RTI)
itmser=ptr_item.getname(nil,RTI)
--local flags=engine.peek(off,ptr_item.flags)
if itmser=="item_plantst" and mat==(419) and submat2==(62) then --if a cigar ...
table.insert(retvec,off)--... add it to return vector
--print("drugs")
end
end
return retvec --return the "return vector" :)
end
function Cure() -- this will turn the user into a specter and cure your zombism, best use when your in a jam, to get rid of it smoke the cigar.
--first three lines same as before (because we will need an offset of creature at location x,y,z)
myoff=offsets.getEx("AdvCreatureVec")
vector=engine.peek(myoff,ptr_vector)
--indx=GetCreatureAtPos(getxyz())
indx=0
--print(string.format("%x",vector:getval(indx)))
flg=engine.peek(vector:getval(indx),ptr_Creature.flags) --get flags
flg:set(12,0) -- 76 is ghostliness flag. this turns them back to normal
flg:set(76,1) -- ghost
--flg:set(13,1) -- skeleton
engine.poke(vector:getval(indx),ptr_Creature.flags,flg) --save flags
end
function trait()
RaceTable=RaceTable or BuildNameTable() --slow.If loaded don't load again
myoff=offsets.getEx("AdvCreatureVec")
vector=engine.peek(myoff,ptr_vector)
trai=engine.peek(vector:getval(0),ptr_Creature.race)
tra2=RaceTable["HUMAN"]
tra3=RaceTable["HUMAN_ENLIGHT"]
if trai==tra2 then
ControlCiv3()
keeptrack()
end
if trai==tra3 then
--ControlCiv3()
--wepbrn2()
ControlRace()
keeptrack()
end
end
function selectall()
local retvec={} --return vector (or a list)
myoff=offsets.getEx("AdvCreatureVec")
vector=engine.peek(myoff,ptr_vector) --standart start
for i=0,vector:size()-1 do --check all creatures
local off
off=vector:getval(i)
local flags=engine.peek(off,ptr_Creature.flags)
if flags:get(1)==true and flags:get(12)==false then --if dead ...
table.insert(retvec,off)--... add it to return vector
end
end
return retvec --return the "return vector" :)
end
function Zombieressurect()
local trgs=selectall()
for k,v in pairs(trgs) do
--indx=GetCreatureAtPos(v)
--indx=engine.peek(v,ptr_creature.ID)
print("Zombie:"..k)
v2=engine.peek(v,ptr_Creature.hurt1)
for i=0,v2:size()-1 do
v2:setval(i,1)
end
v2=engine.peek(v,ptr_Creature.hurt2)
v2.type=DWORD
for i=0,v2:size()-1 do
v2:setval(i,1)
end
--engine.peek(v,ptr_Creature.civ)
--engine.poke(v,ptr_Creature.civ,-1)
engine.poke(v,ptr_Creature.bloodlvl,60000) --give blood
engine.poke(v,ptr_Creature.bleedlvl,24) --stop some bleeding...
local flags=engine.peek(v,ptr_Creature.flags)
flags:set(1,0) -- alive!
flags:set(12,1) --zombie
flags:set(17,1)
flags:set(19,1)
engine.poke(v,ptr_Creature.flags,flags)
end
end
function Mfolder()
Zombieressurect()
trait()
end
stick this in the install function section at the bottom.
onfunction.SetCallback("Move",Mfolder)
so far this would handle the the recent version of Corrosion with little fuss.