Bay 12 Games Forum

Please login or register.

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

Author Topic: DFusion - a lua based plugin system (integrated into DFHack)  (Read 151828 times)

darius

  • Bay Watcher
  • ^^
    • View Profile
DFusion - a lua based plugin system (integrated into DFHack)
« on: November 03, 2010, 10:44:00 am »

This is a hijacked thread to dfusion integrated into DFhack.

A wip wiki: here
Repository: here
Download here: DFhack, built by peterix including stonesense and other neat things

« Last Edit: January 07, 2012, 05:17:16 pm by darius »
Logged

darius

  • Bay Watcher
  • ^^
    • View Profile
Re: DFusion - a lua based plugin system v1
« Reply #1 on: November 04, 2010, 10:50:50 am »

Lua syntax:
Spoiler (click to show/hide)
Script example:
Spoiler (click to show/hide)
Guide for friendship plugin by Hugo_The_Dwarf here
« Last Edit: November 24, 2010, 07:14:44 am by darius »
Logged

Hugo_The_Dwarf

  • Bay Watcher
  • Modding Mentor
    • View Profile
    • Regeneration: Forced Evolution
Re: DFusion - a lua based plugin system v1
« Reply #2 on: November 04, 2010, 10:57:53 am »

I'd like to ask how to use this? any special things I need on my PC? (.NET, Java...)
Logged

darius

  • Bay Watcher
  • ^^
    • View Profile
Re: DFusion - a lua based plugin system v1
« Reply #3 on: November 04, 2010, 10:59:04 am »

Should work right of the box, if not please tell me. now should work right out of the box! why no one told me that it says DLL missing :/
Edit: found a little bug - first entry in friendship is not parsed... so dwarves suddenly turn into "tame" :D
« Last Edit: November 04, 2010, 07:00:17 pm by darius »
Logged

Hugo_The_Dwarf

  • Bay Watcher
  • Modding Mentor
    • View Profile
    • Regeneration: Forced Evolution
Re: DFusion - a lua based plugin system v1.2
« Reply #4 on: November 05, 2010, 08:06:20 am »

so sorry that I didn't just say the .dll file was missing, funny too cuz im a pc tech haha, so I believe that out of the box means you do'nt need "FE" just this? right on, I shall begin testing

EDIT: after reading the change log I'll get "FE" just in case
Logged

Askot Bokbondeler

  • Bay Watcher
  • please line up orderly
    • View Profile
Re: DFusion - a lua based plugin system v1.2
« Reply #5 on: November 05, 2010, 08:23:48 am »

followin

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: DFusion - a lua based plugin system v1.2
« Reply #6 on: November 07, 2010, 01:24:33 am »

going to use this post as means of dumping my add-ons so people don't have to surf this thread for all of them.
installing new is as simple open up notepad and copy paste the code in then save the file as plugin.lua then make a folder called Rum_tools and place the file in there.
next you need to do is place the folder rum_tools in the plugin folder of Dfhack.

Code: [Select]
rum_tools={} --> first lets make a menu table
rum_tools.menu=MakeMenu()
function rum_tools.changeadv() -- this function will do almost all the work
myoff=offsets.getEx("AdvCreatureVec") -- first find out where "Adventurer creature vector" is
vector=engine.peek(myoff,ptr_vector) -- +16 is a little fix...
indx=GetCreatureAtPos(getxyz()) -- a little helper, gets index in the vector with current id. And getxyz() is a function that gets x y and z of that "X" pointer. These functions are in common.lua
print("Swaping, press enter when done.")
-- next three lines is a common switch two things pattern
tval=vector:getval(0) -- get offset of player
vector:setval(0,vector:getval(indx)) -- set first offset to be the target's
vector:setval(indx,tval) -- set targets offset to the players
r=io.stdin:read() -- pause
-- again switch them around
tval=vector:getval(0)
vector:setval(0,vector:getval(indx))
vector:setval(indx,tval)
end
function rum_tools.MakeFollow()
--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())

print(string.format("current creature:%x",vector:getval(indx)))
trgid=engine.peek(vector:getval(0),ptr_Creature.ID) --get players ID
lfollow=engine.peek(vector:getval(indx),ptr_Creature.followID) -- get target creatures "now following ID"
if lfollow ~=0xFFFFFFFF then --if its set
print("Already following, unfollow? y/N") -- ask confirmation
r=io.stdin:read()
if r== "y" then
engine.poke(vector:getval(indx),ptr_Creature.followID,0)
end
else
engine.poke(vector:getval(indx),ptr_Creature.followID,trgid) -- if not just write the players ID.
end
end
function rum_tools.racechange()
--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())
RaceTable=RaceTable or BuildNameTable() --slow.If loaded don't load again
print("Enter race name ALL CAPS!:")
repeat
entry=io.stdin:read() --get entry
id=RaceTable[entry] -- find race id
until id~=nil -- if not found repeat
engine.poke(vector:getval(indx),ptr_Creature.race,id)
end
function rum_tools.makeghost()
--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:flip(76) -- 76 is ghostliness flag.
--flg:set(1,0) -- alive
--flg:set(13,1) -- skeleton

engine.poke(vector:getval(indx),ptr_Creature.flags,flg) --save flags
end
function rum_tools.maketest()
--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)))
test=engine.peek(vector:getval(indx),ptr_Creature.wutlvl) --get random hex memory between bleed and blood
--flg:flip(76) -- 76 is ghostliness flag.
--flg:set(1,0) -- alive
--flg:set(13,1) -- skeleton

engine.poke(vector:getval(indx),ptr_Creature.wutlvl,-1) --testing for anything to happen
end
function rum_tools.getitems()
--first three lines same as before (because we will need an offset of creature at location x,y,z)
x,y,z=getxyz()
vector=engine.peek(myoff+16,ptr_vector)
indx=GetCreatureAtPos(getxyz())
indx=0
flg=engine.peek(vector:getval(indx),ptr_Creature.flags) --get flags
flg:flip(76) -- 76 is ghostliness flag.
--flg:set(1,0) -- alive
--flg:set(13,1) -- skeleton
engine.poke(vector:getval(indx),ptr_Creature.flags,flg) --save flags
end
function rum_tools.hostilate()
vector=engine.peek(offsets.getEx("AdvCreatureVec"),ptr_vector)
id=GetCreatureAtPos(getxyz())
print(string.format("Vec:%d cr:%d",vector:size(),id))
off=vector:getval(id)
crciv=engine.peek(vector:getval(id),ptr_Creature.civ)
curciv=engine.peek(vector:getval(0),ptr_Creature.civ)

if curciv==crciv then
print("Friendly-making enemy")
engine.poke(off,ptr_Creature.civ,-1)
flg=engine.peek(off,ptr_Creature.flags)
flg:set(17,true)
engine.poke(off,ptr_Creature.flags,flg)
else
print("Enemy- making friendly")
engine.poke(off,ptr_Creature.civ,curciv)
flg=engine.peek(off,ptr_Creature.flags)
flg:set(17,false)
flg:set(19,false)
engine.poke(off,ptr_Creature.flags,flg)
end
end
function rum_tools.nociv() --removes Civ number will become hostile
vector=engine.peek(offsets.getEx("AdvCreatureVec"),ptr_vector)
id=GetCreatureAtPos(getxyz())
print(string.format("Vec:%d cr:%d",vector:size(),id))
off=vector:getval(id)
crciv=engine.peek(vector:getval(id),ptr_Creature.civ)
engine.poke(off,ptr_Creature.civ,-1)
--[[curciv=engine.peek(vector:getval(0),ptr_Creature.civ)

if curciv==crciv then
print("Friendly-making enemy")
engine.poke(off,ptr_Creature.civ,-1)
flg=engine.peek(off,ptr_Creature.flags)
flg:set(17,true)
engine.poke(off,ptr_Creature.flags,flg)
else
print("Enemy- making friendly")
engine.poke(off,ptr_Creature.civ,curciv)
flg=engine.peek(off,ptr_Creature.flags)
flg:set(17,false)
flg:set(19,false)
engine.poke(off,ptr_Creature.flags,flg)
end]]--
end
function rum_tools.tamingcompanions() --woop wopp does not work
vector=engine.peek(offsets.getEx("AdvCreatureVec"),ptr_vector)
id=GetCreatureAtPos(getxyz())
print(string.format("Vec:%d cr:%d",vector:size(),id))
off=vector:getval(id)
crciv=engine.peek(vector:getval(id),ptr_Creature.civ)
curciv=engine.peek(vector:getval(0),ptr_Creature.civ)

if curciv==crciv then
print("Friendly-making friendly")
engine.poke(off,ptr_Creature.civ,crciv)
flg=engine.peek(off,ptr_Creature.flags)
flg:set(17,0)
flg:set(19,0)
engine.poke(off,ptr_Creature.flags,flg)
else
print("Enemy- making friendly")
engine.poke(0,ptr_Creature.civ,crciv)
flg=engine.peek(off,ptr_Creature.flags)
flg:set(17,0)
flg:set(19,0)
engine.poke(off,ptr_Creature.flags,flg)
end
end
function rum_tools.getlegendsid(croff)
local vec=engine.peek(croff,ptr_Creature.legends)
if vec:size()~=0 then
return engine.peekd(vec:getval(0)+4)
else
return 0
end
end
function rum_tools.follow2()
myoff=offsets.getEx("AdvCreatureVec")
leg=offsets.getEx("Legends")
vector=engine.peek(myoff,ptr_vector)
legvec=engine.peek(leg,ptr_vector)
indx=GetCreatureAtPos(getxyz())
print(string.format("current creature:%x",vector:getval(indx)))
trgid=engine.peek(vector:getval(0),ptr_Creature.ID) --get players ID
--[[playerlegid=engine.peek(vector:getval(0),ptr_Creature.legends)
playerlegid=engine.peekd(playerlegid:getval(0)+4)
lfollow=engine.peek(vector:getval(indx),ptr_Creature.followID) -- get target creatures "now following ID"
trglegid=engine.peek(vector:getval(indx),ptr_Creature.legends)
trglegid=engine.peekd(trglegid:getval(0)+4)--]]
playerlegid=rum_tools.getlegendsid(vector:getval(0))
trglegid=rum_tools.getlegendsid(vector:getval(indx))
print(string.format("Player legends id:%d and offset:%x",playerlegid,legvec:getval(playerlegid)))
print(string.format("Target legends id:%d and offset:%x",trglegid,legvec:getval(trglegid)))

if lfollow ~=0xFFFFFFFF then --if its set
print("Already following, unfollow? y/N") -- ask confirmation
r=io.stdin:read()
if r== "y" then
engine.poke(vector:getval(indx),ptr_Creature.followID,-1)
engine.poke(legvec:getval(trglegid),ptr_legends2.follow,-1)
end
else
engine.poke(vector:getval(indx),ptr_Creature.followID,trgid) -- if not just write the players ID.
engine.poke(legvec:getval(trglegid),ptr_legends2.follow,playerlegid)
end
end
function rum_tools.changeadv2()
myoff=offsets.getEx("AdvCreatureVec")
vector=engine.peek(myoff,ptr_vector)
indx=GetCreatureAtPos(getxyz())
print("Swaping")

tval=vector:getval(0)
vector:setval(0,vector:getval(indx))
vector:setval(indx,tval)
local legid=rum_tools.getlegendsid(vector:getval(0))
print("Legends id found:"..legid)
if legid~=0 then
engine.poked(offsets.getEx("PlayerLegend"),legid)
else
print("Warning target does not have a valid legends id!")
end
end
function rum_tools.changeflag() --by rumrusher
   myoff=offsets.getEx("AdvCreatureVec")
   vector=engine.peek(myoff,ptr_vector)
   indx=GetCreatureAtPos(getxyz())
   flg=engine.peek(vector:getval(indx),ptr_Creature.flags)
   print("Type flags number to flip:")
   entry=io.stdin:read()
   print("Was:"..flg:get(entry))
   flg:flip(entry)
   print("Now:"..flg:get(entry))
   engine.poke(vector:getval(indx),ptr_Creature.flags,flg)
end
function rum_tools.wagonmode() --by rumrusher
   --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(1,false)
   flg:set(74,false)
   engine.poke(vector:getval(indx),ptr_Creature.flags,flg)
   print("To stay normal press y, else hit Enter turn Wagon mode on.")
   r=io.stdin:read() -- repeat for it too work... also creature will be dead.
   if r== "y" then
      flg=engine.peek(vector:getval(indx),ptr_Creature.flags)
      flg:set(1,false)
      engine.poke(vector:getval(indx),ptr_Creature.flags,flg)
   else
      flg=engine.peek(vector:getval(indx),ptr_Creature.flags)
      flg:set(1,false)
      flg:flip(74)
      engine.poke(vector:getval(indx),ptr_Creature.flags,flg)
   end
end
continue on the other post
Spoiler: "old post" (click to show/hide)
« Last Edit: May 04, 2011, 11:52:17 am by Rumrusher »
Logged
I thought I would I had never hear my daughter's escapades from some boy...
DAMN YOU RUMRUSHER!!!!!!!!
"body swapping and YOU!"
Adventure in baby making!Adv Homes

darius

  • Bay Watcher
  • ^^
    • View Profile
Re: DFusion - a lua based plugin system v1.2
« Reply #7 on: November 07, 2010, 06:46:13 am »

race changer!?
does this mean we can change the race of any selected the creature
or change the civ controller?

some how it doesn't work with .10. even when I try the -f
change race - changes the controling race, not race of one creature. As for version, try running df in arena mode and then use the "-f" if it still does not work i suspect that .10 could be too old although i tried to make algorithms universal.
Logged

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: DFusion - a lua based plugin system v1.2
« Reply #8 on: November 07, 2010, 08:59:28 am »

Code: [Select]
function rum_tools.ressurect()
    --repeat
myoff=offsets.getEx("AdvCreatureVec")
vector=engine.peek(myoff,ptr_vector)
indx=0 --GetCreatureAtPos(getxyz())
if indx<0 then return end
--print(string.format("%x",vector:getval(indx)))
v2=engine.peek(vector:getval(indx),ptr_Creature.hurt1)
for i=0,v2:size()-1 do
v2:setval(i,0)
end
v2=engine.peek(vector:getval(indx),ptr_Creature.hurt2)
v2.type=DWORD
for i=0,v2:size()-1 do
v2:setval(i,0)
end
engine.poke(vector:getval(indx),ptr_Creature.bloodlvl,60000) --give blood
engine.poke(vector:getval(indx),ptr_Creature.bleedlvl,0) --stop some bleeding...
local flg=engine.peek(vector:getval(indx),ptr_Creature.flags)
    flg:set(1,false) --ALIVE
    flg:set(39,false) -- leave body yet again
    flg:set(37,false)
    flg:set(57,true)
    flg:set(60,true) -- something todo with wounds- lets you walk again.
    engine.poke(vector:getval(indx),ptr_Creature.flags,flg)
    --until r==7
end
function rum_tools.Hurt() --instant hurt of a body part
    --repeat
myoff=offsets.getEx("AdvCreatureVec")
vector=engine.peek(myoff,ptr_vector)
indx=GetCreatureAtPos(getxyz())
if indx<0 then return end
--print(string.format("%x",vector:getval(indx)))
v2=engine.peek(vector:getval(indx),ptr_Creature.hurt1)
for i=0,v2:size()-1 do
v2:setval(i,7)
end
v2=engine.peek(vector:getval(indx),ptr_Creature.hurt2)
v2.type=DWORD
for i=0,v2:size()-1 do
v2:setval(i,8)
end
engine.poke(vector:getval(indx),ptr_Creature.bloodlvl,60000) --give blood
engine.poke(vector:getval(indx),ptr_Creature.bleedlvl,1) --stop some bleeding...
local flg=engine.peek(vector:getval(indx),ptr_Creature.flags)
    flg:set(1,false) --ALIVE
    flg:set(39,false) -- leave body yet again
    flg:set(37,false) -- something todo with wounds- lets you walk again.
    engine.poke(vector:getval(indx),ptr_Creature.flags,flg)
    --until r==7
end

function rum_tools.Hurtselected() --found out that this does not really hurt creature but will give the user ability to disarm them if you remove(15) a limb from their bodies this will cause their clothes to fall off so find the hand and poof away gear.
    --repeat
myoff=offsets.getEx("AdvCreatureVec")
vector=engine.peek(myoff,ptr_vector)
indx=GetCreatureAtPos(getxyz())
if indx<0 then return end
--print(string.format("%x",vector:getval(indx)))
v2=engine.peek(vector:getval(indx),ptr_Creature.hurt1)
v3=engine.peek(vector:getval(indx),ptr_Creature.hurt2)
v3.type=DWORD
print("select body part 0=upperbody,1=lowerbody,2=head,3=right front leg,4=left front leg,5=")
r=io.stdin:read()
t=r*4
print("select infliction")
d=io.stdin:read()
v2:setval(t,d)
v3:setval(r,d) --remove zero-th limb or something... same with hurt2
end
function rum_tools.ressurectall()
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,0)
end
v2=engine.peek(v,ptr_Creature.hurt2)
v2.type=DWORD
for i=0,v2:size()-1 do
v2:setval(i,0)
end
engine.poke(v,ptr_Creature.bloodlvl,60000) --give blood
engine.poke(v,ptr_Creature.bleedlvl,0) --stop some bleeding...
local flags=engine.peek(v,ptr_Creature.flags)
flags:set(1,false) -- alive!
flags:set(39,false) -- leave body yet again
flags:set(37,false) -- something todo with wounds- lets you walk again.
engine.poke(v,ptr_Creature.flags,flags)
end
end
function rum_tools.ressurectcomp() --heal all your friends for a small chance to die again
local trgs=selectcomp()
for k,v in pairs(trgs) do
--indx=GetCreatureAtPos(v)
--indx=engine.peek(v,ptr_creature.ID)
print("Companion:"..k)
v2=engine.peek(v,ptr_Creature.hurt1)
for i=0,v2:size()-1 do
v2:setval(i,0)
end
v2=engine.peek(v,ptr_Creature.hurt2)
v2.type=DWORD
for i=0,v2:size()-1 do
v2:setval(i,0)
end
engine.poke(v,ptr_Creature.bloodlvl,60000) --give blood
engine.poke(v,ptr_Creature.bleedlvl,0) --stop some bleeding...
local flags=engine.peek(v,ptr_Creature.flags)
flags:set(1,false) -- alive!
flags:set(39,false) -- leave body yet again
flags:set(37,false) -- something todo with wounds- lets you walk again.
engine.poke(v,ptr_Creature.flags,flags)
end
end
function rum_tools.fortcomps() --removes the is resident tag off companions
local trgs=selectcomp()
for k,v in pairs(trgs) do
--indx=GetCreatureAtPos(v)
--indx=engine.peek(v,ptr_creature.ID)
print("Companion:"..k)
--[[v2=engine.peek(v,ptr_Creature.hurt1)
for i=0,v2:size()-1 do
v2:setval(i,0)
end
v2=engine.peek(v,ptr_Creature.hurt2)
v2.type=DWORD
for i=0,v2:size()-1 do
v2:setval(i,0)
end
engine.poke(v,ptr_Creature.bloodlvl,60000) --give blood
engine.poke(v,ptr_Creature.bleedlvl,0)]]-- --stop some bleeding...
local flags=engine.peek(v,ptr_Creature.flags)
flags:set(1,false) -- alive!
flags:set(51,false) -- leave body yet again
flags:set(47,false) -- something todo with wounds- lets you walk again.
engine.poke(v,ptr_Creature.flags,flags)
end
end
function rum_tools.Zombieressurectandcontrol() -- BE THE NECROMANCER... end up watching a bunch of zombie fight each other like savages and not get any raiding done use a teleport or carry command to order them around.
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,0)
end
v2=engine.peek(v,ptr_Creature.hurt2)
v2.type=DWORD
for i=0,v2:size()-1 do
v2:setval(i,0)
end
--engine.poke(creatureptr,ptr_Creature.legends,-1)
myoff=offsets.getEx("AdvCreatureVec")
vector=engine.peek(myoff+16,ptr_vector)
local trgs=selectall()
for k,v in pairs(trgs) do
trgid=engine.peek(vector:getval(0),ptr_Creature.ID) --get players ID
engine.peek(v,ptr_Creature.followID) -- get target creatures "now following ID"
engine.poke(v,ptr_Creature.followID,trgid) -- if not just write the players ID.
end
engine.poke(v,ptr_Creature.bloodlvl,60000) --give blood
engine.poke(v,ptr_Creature.bleedlvl,0) --stop some bleeding...
local flags=engine.peek(v,ptr_Creature.flags)
flags:set(1,false) -- alive!
flags:set(12,true) --zombie
engine.poke(v,ptr_Creature.flags,flags)
end
end

function rum_tools.Zombieressurect() -- turn dead into undead and undead into dead for good.
repeat
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,false) -- alive!
flags:set(12,true) --zombie
flags:set(17,true)
flags:set(19,true)
engine.poke(v,ptr_Creature.flags,flags)
--engine.poke(v,ptr_Creature.legends,-1)
end
until r==7
end

function rum_tools.lycanressurect() -- turns any one hurt a curtain way into a different race but be warn hitting them will cause the game to crash.
--repeat
local trgs=selectwolf()
for k,v in pairs(trgs) do
--indx=GetCreatureAtPos(v)
--indx=engine.peek(v,ptr_creature.ID)
engine.poke(v,ptr_Creature.race,151)
print("Werewolf:"..k)
v2=engine.peek(v,ptr_Creature.hurt1)
for i=0,v2:size()-1 do
v2:setval(i,0)
end
v2=engine.peek(v,ptr_Creature.hurt2)
v2.type=DWORD
for i=0,v2:size()-1 do
v2:setval(i,0)
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,false) -- alive!
flags:set(12,false) --zombie
flags:set(17,true)
flags:set(19,true)
engine.poke(v,ptr_Creature.flags,flags)
end
--until r==7
end

function rum_tools.ghostin() --necromancer controls of turning zombies into ghosts for easier manipulation of the dead
local trgs=selectskeleton()
for k,v in pairs(trgs) do
print("Zombie:"..k)
local flags=engine.peek(v,ptr_Creature.flags)
flags:set(1,false) -- alive!
flags:flip(76) --passive ghost following
engine.poke(v,ptr_Creature.flags,flags)
end
end
function rum_tools.skeltozombie() --add the rot to the pile of bones
local trgs=selectskeleton()
for k,v in pairs(trgs) do
print("Zombie:"..k)
local flags=engine.peek(v,ptr_Creature.flags)
flags:set(1,false) -- alive!
flags:set(12,true) --zombie
flags:set(13,false) --no skel
engine.poke(v,ptr_Creature.flags,flags)
end
end


function rum_tools.nosneak() --unreveal a hidden companion attack or an siege.
local trgs=selectalive()
for k,v in pairs(trgs) do
print("hidden:"..k)
local flags=engine.peek(v,ptr_Creature.flags)
flags:set(1,false) -- alive!
flags:set(18,false) --unreveal ambushers
engine.poke(v,ptr_Creature.flags,flags)
end
end
function rum_tools.compsneak()  -- stealth tactics for against archers
local trgs=selectcomp()
for k,v in pairs(trgs) do
print("hidden:"..k)
local flags=engine.peek(v,ptr_Creature.flags)
--flags:set(1,false) -- alive!
flags:set(18,true) --ambushers
engine.poke(v,ptr_Creature.flags,flags)
end
end
function rum_tools.zombietoskel() -- strip the rotten meat from the bones.
local trgs=selectzombie()
for k,v in pairs(trgs) do
print("Skeleton:"..k)
local flags=engine.peek(v,ptr_Creature.flags)
flags:set(1,false) -- alive!
flags:set(13,true)
flags:set(12,false) --no zombie
engine.poke(v,ptr_Creature.flags,flags)
end
end
function selectalive()
  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)==false then  --if dead ...
        table.insert(retvec,off)--... add it to return vector
     end
  end
  return retvec --return the "return vector" :)
end
function rum_tools.ControlZombie() -- get temp control over the dead will revert if you travel
--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)
local trgs=selectzombie()
for k,v in pairs(trgs) do
trgid=engine.peek(vector:getval(0),ptr_Creature.ID) --get players ID
engine.poke(v,ptr_Creature.civ,-1)
engine.peek(v,ptr_Creature.followID) -- get target creatures "now following ID"
engine.poke(v,ptr_Creature.followID,trgid) -- if not just write the players ID.
end
end
function selectskeleton()
  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(13)==true then  --if undead in anyway...
        table.insert(retvec,off)--... add it to return vector
     end
  end
  return retvec --return the "return vector" :)
end

function selectzombie()
  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(12)==true then  --if undead in anyway...
        table.insert(retvec,off)--... add it to return vector
     end
  end
  return retvec --return the "return vector" :)
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 selectcomp()
  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)
     lfollow=engine.peek(off,ptr_Creature.followID) -- get target creatures "now following ID"
     if lfollow ~=0xFFFFFFFF then --if its set
        table.insert(retvec,off)--... add it to return vector
     end
  end
  return retvec --return the "return vector" :)
end
function rum_tools.butcher() --flips slaughter flag on a creature causes any member of the fort to drag the poor sucker to the butcher shop and kill them for meat. yum
--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:flip(49) -- 76 is ghostliness flag.
--flg:set(1,0) -- alive
--flg:set(13,1) -- skeleton

engine.poke(vector:getval(indx),ptr_Creature.flags,flg) --save flags
end

function rum_tools.butcherdead() --search for dead creatures and flip on the butcher tag so that you can still serve a dead dwarf to feed millions.
local trgs=selectall()
for k,v in pairs(trgs) do
print("kattle:"..k)
local flags=engine.peek(v,ptr_Creature.flags)
flags:set(49,true) -- butch!
--flags:set(13,true)
--flags:set(12,false) no zombie
engine.poke(v,ptr_Creature.flags,flags)
end
end
function rum_tools.fortdy() --use the pointer on the creature flip off the is resident flag.
--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(51,false) -- 76 is ghostliness flag.
--flg:set(1,0) -- alive
--flg:set(13,1) -- skeleton

engine.poke(vector:getval(indx),ptr_Creature.flags,flg) --save flags
end
function selectindcomp(names) -- this function will allow you to change to a companion for a small period does not work
myoff=offsets.getEx("AdvCreatureVec") -- first find out where "Adventurer creature vector" is
vector=engine.peek(myoff,ptr_vector) -- +16 is a little fix...
--indx=GetCreatureAtPos(getxyz()) -- a little helper, gets index in the vector with current id. And getxyz() is a function that gets x y and z of that "X" pointer. These functions are in common.lua
local trgs=selectcomp()
for k,v in pairs(trgs) do
tnames={}
rnames={}
local name=engine.peek(v,ptt_dfstring):getval()
local lid= tools.getlegendsid(v)
if lid ~=0 then
print(i..")*Creature Name:"..name.." race="..engine.peekw(v+ptr_Creature.race.off).." legendid="..lid)
else
print(i..") Creature Name:"..name.." race="..engine.peekw(v+ptr_Creature.race.off))
end
if name ~="" and name~=nil then
tnames[v]=name
rnames[name]=v
end
end
print("=====================================")
print("type in name or number:")
r=io.stdin:read()
if tonumber(r) ==nil then
indx=rnames[r]
if indx==nil then return end
else
r=tonumber(r)
if r<vector:size() then indx=r else return end
end
return indx
end

function selectwolf()
  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 v2=engine.peek(off,ptr_Creature.hurt1)
     if v2:getval(12)==15 and v2:getval(8)==0 then
     --[[local flags=engine.peek(off,ptr_Creature.flags)
     if flags:get(1)==0 then]]--  --if dead ...
        table.insert(retvec,off)--... add it to return vector
     end
  end
  return retvec --return the "return vector" :)
end
function rum_tools.change_adv2comp() --woop woop does not work
myoff=offsets.getEx("AdvCreatureVec") -- first find out where "Adventurer creature vector" is
vector=engine.peek(myoff,ptr_vector) -- +16 is a little fix...
indx=selectindcomp(names) -- a little helper, gets index in the vector with current id. And getxyz() is a function that gets x y and z of that "X" pointer. These functions are in common.lua
print("Swaping, press enter when done.")
-- next three lines is a common switch two things pattern
tval=vector:getval(0) -- get offset of player
vector:setval(0,vector:getval(indx)) -- set first offset to be the target's
vector:setval(indx,tval) -- set targets offset to the players
r=io.stdin:read() -- pause
-- again switch them around
tval=vector:getval(0)
vector:setval(0,vector:getval(indx))
vector:setval(indx,tval)
end
function rum_tools.comprace()
--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())
local trgs=selectcomp()
for k,v in pairs(trgs) do
--RaceTable=RaceTable or BuildNameTable() --slow.If loaded don't load again
--print("Enter race name ALL CAPS!:")
--repeat
entry=io.stdin:read() --get entry
--id=RaceTable[entry] -- find race id
--until id~=nil -- if not found repeat
engine.poke(v,ptr_Creature.race,entry)
end

end
function rum_tools.compraceez()
--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())
local trgs=selectcomp()
for k,v in pairs(trgs) do
RaceTable=RaceTable or BuildNameTable() --slow.If loaded don't load again
print("Enter race name ALL CAPS!:")
repeat
entry=io.stdin:read() --get entry
id=RaceTable[entry] -- find race id
until id~=nil -- if not found repeat
engine.poke(v,ptr_Creature.race,id)
end
end
function rum_tools.compiggybackride() --for people who want every one to cross the river or get every one in one spot so you can retreat/attack one person
--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())
local trgs=selectcomp()
for k,v in pairs(trgs) do
--RaceTable=RaceTable or BuildNameTable() --slow.If loaded don't load again
--print("Enter race name ALL CAPS!:")
repeat
flg=engine.peek(vector:getval(0),ptr_Creature.flags)
      flg2=engine.peek(v,ptr_Creature.flags)
      enty=engine.peek(vector:getval(0),ptr_Creature.y)
      entx=engine.peek(vector:getval(0),ptr_Creature.x)
      move=engine.peek(vector:getval(0),ptr_Creature.z)
      engine.poke(v,ptr_Creature.z,move)
      engine.poke(v,ptr_Creature.x,entx)
      engine.poke(v,ptr_Creature.y,enty)
      until flg:get(15) ==true or flg2:get(1) ==true
--entry=io.stdin:read() --get entry
--id=RaceTable[entry] -- find race id
--until id~=nil -- if not found repeat
--engine.poke(v,ptr_Creature.race,id)
end
end
function rum_tools.warptowag() --for those with wagons
--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())
local trgs=selectcomp()
for k,v in pairs(trgs) do
print("warpin' to Wagon")
local trgs=selectwagon()
for w,d in pairs(trgs) do
      wary=engine.peek(d,ptr_Creature.y)
      warx=engine.peek(d,ptr_Creature.x)
      warz=engine.peek(d,ptr_Creature.z)
      engine.poke(v,ptr_Creature.z,warz)
      engine.poke(v,ptr_Creature.x,warx)
      engine.poke(v,ptr_Creature.y,wary)
      engine.poke(vector:getval(0),ptr_Creature.y,wary)
      engine.poke(vector:getval(0),ptr_Creature.x,warx)
      engine.poke(vector:getval(0),ptr_Creature.z,warz)
end
print("WARP COMPLETE! preparing getaway.")
--[[repeat
flg=engine.peek(vector:getval(0),ptr_Creature.flags)
      flg2=engine.peek(d,ptr_Creature.flags)
      enty=engine.peek(vector:getval(0),ptr_Creature.y)
      entx=engine.peek(vector:getval(0),ptr_Creature.x)
      move=engine.peek(vector:getval(0),ptr_Creature.z)
      engine.poke(v,ptr_Creature.z,move)
      engine.poke(v,ptr_Creature.x,entx)
      engine.poke(v,ptr_Creature.y,enty)
      until flg:get(15) ==true
print("Parking.")--]]
--entry=io.stdin:read() --get entry
--id=RaceTable[entry] -- find race id
--until id~=nil -- if not found repeat
--engine.poke(v,ptr_Creature.race,id)
end
end
function selectwagon()
  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(74)==true then  --if undead in anyway...
        table.insert(retvec,off)--... add it to return vector
     end
  end
  return retvec --return the "return vector" :)
end
function rum_tools.warp() --made before darius version really primitive
   myoff=offsets.getEx("AdvCreatureVec")
   vector=engine.peek(myoff,ptr_vector)
   --indx=GetCreatureAtPos(getxyz())
   print("how high?")
   entry=io.stdin:read()
   move=engine.peek(vector:getval(0),ptr_Creature.z)+entry
   print("W and E")
   entry=io.stdin:read()
   move2=engine.peek(vector:getval(0),ptr_Creature.x)+entry
   print("N and S")
   entry=io.stdin:read()
   move3=engine.peek(vector:getval(0),ptr_Creature.y)+entry
   engine.poke(vector:getval(0),ptr_Creature.z,move)
   engine.poke(vector:getval(0),ptr_Creature.x,move2)
   engine.poke(vector:getval(0),ptr_Creature.y,move3)
end

function rum_tools.carry() --first crack at the carry command
   myoff=offsets.getEx("AdvCreatureVec")
   vector=engine.peek(myoff,ptr_vector)
   indx=GetCreatureAtPos(getxyz())
   --[[print("grab person how? N S E W")
   --repeat
   r=io.stdin:read()
   if r=="N" then
      enty=(engine.peek(vector:getval(0),ptr_Creature.y)+1)
   elseif r=="S" then
      enty=(engine.peek(vector:getval(0),ptr_Creature.y)-1)
   elseif r=="W" then
      entx=(engine.peek(vector:getval(0),ptr_Creature.x)-1)
   elseif r=="E" then
      entx=(engine.peek(vector:getval(0),ptr_Creature.x)+1)
   end]]--
   repeat
   flg=engine.peek(vector:getval(0),ptr_Creature.flags)
   flg2=engine.peek(vector:getval(indx),ptr_Creature.flags)
   --print("how high?")
   --entry=io.stdin:read()
   Crepos=engine.peek(vector:getval(0),ptr_Creature.x)-1 --+entx
   move=engine.peek(vector:getval(0),ptr_Creature.z)
   --print("W and E")
   --entry=io.stdin:read()
   --move2=engine.peek(vector:getval(0),ptr_Creature.x)
   --print("N and S")
   --entry=io.stdin:read()
   move3=engine.peek(vector:getval(0),ptr_Creature.y) --+enty
   engine.poke(vector:getval(indx),ptr_Creature.z,move)
   engine.poke(vector:getval(indx),ptr_Creature.x,Crepos)
   engine.poke(vector:getval(indx),ptr_Creature.y,move3)
   until flg:get(15) ==1 or flg2:get(1) ==1
end
function rum_tools.carryEX() --better version of the said carry command to use this have the pointer on top of the creature you want to hold and insert a letter may lead to invisible blocks so user beware.
   myoff=offsets.getEx("AdvCreatureVec")
   vector=engine.peek(myoff,ptr_vector)
   indx=GetCreatureAtPos(getxyz())
   print("grab person how? N S E W")
   --repeat
   r=io.stdin:read()
   if r=="N" then
      repeat 
      flg=engine.peek(vector:getval(0),ptr_Creature.flags)
      flg2=engine.peek(vector:getval(indx),ptr_Creature.flags)
      enty=engine.peek(vector:getval(0),ptr_Creature.y)+1
      entx=engine.peek(vector:getval(0),ptr_Creature.x)
      move=engine.peek(vector:getval(0),ptr_Creature.z)
      engine.poke(vector:getval(indx),ptr_Creature.z,move)
      engine.poke(vector:getval(indx),ptr_Creature.x,entx)
      engine.poke(vector:getval(indx),ptr_Creature.y,enty)
      until flg:get(15) ==true or flg2:get(1) ==true
   elseif r=="S" then
      repeat
      flg=engine.peek(vector:getval(0),ptr_Creature.flags)
      flg2=engine.peek(vector:getval(indx),ptr_Creature.flags)
      enty=engine.peek(vector:getval(0),ptr_Creature.y)-1
      entx=engine.peek(vector:getval(0),ptr_Creature.x)
      move=engine.peek(vector:getval(0),ptr_Creature.z)
      engine.poke(vector:getval(indx),ptr_Creature.z,move)
      engine.poke(vector:getval(indx),ptr_Creature.x,entx)
      engine.poke(vector:getval(indx),ptr_Creature.y,enty)
      until flg:get(15) ==true or flg2:get(1) ==true
   elseif r=="W" then
      repeat
      flg=engine.peek(vector:getval(0),ptr_Creature.flags)
      flg2=engine.peek(vector:getval(indx),ptr_Creature.flags)
      entx=engine.peek(vector:getval(0),ptr_Creature.x)-1
      enty=engine.peek(vector:getval(0),ptr_Creature.y)
      move=engine.peek(vector:getval(0),ptr_Creature.z)
      engine.poke(vector:getval(indx),ptr_Creature.z,move)
      engine.poke(vector:getval(indx),ptr_Creature.x,entx)
      engine.poke(vector:getval(indx),ptr_Creature.y,enty)
      until flg:get(15) ==true or flg2:get(1) ==true
   elseif r=="E" then
      repeat
      flg=engine.peek(vector:getval(0),ptr_Creature.flags)
      flg2=engine.peek(vector:getval(indx),ptr_Creature.flags)
      entx=engine.peek(vector:getval(0),ptr_Creature.x)+1
      enty=engine.peek(vector:getval(0),ptr_Creature.y)
      move=engine.peek(vector:getval(0),ptr_Creature.z)
      engine.poke(vector:getval(indx),ptr_Creature.z,move)
      engine.poke(vector:getval(indx),ptr_Creature.x,entx)
      engine.poke(vector:getval(indx),ptr_Creature.y,enty)
      until flg:get(15) ==true or flg2:get(1) ==true
   end
   --[[flg=engine.peek(vector:getval(0),ptr_Creature.flags)
   flg2=engine.peek(vector:getval(indx),ptr_Creature.flags)
   --print("how high?")
   --entry=io.stdin:read()
   --Crepos=engine.peek(vector:getval(0),ptr_Creature.x)+entx
   move=engine.peek(vector:getval(0),ptr_Creature.z)
   --print("W and E")
   --entry=io.stdin:read()
   move2=engine.peek(vector:getval(0),ptr_Creature.x)
   --print("N and S")
   --entry=io.stdin:read()
   move3=engine.peek(vector:getval(0),ptr_Creature.y)
   repeat
   engine.poke(vector:getval(indx),ptr_Creature.z,move)
   engine.poke(vector:getval(indx),ptr_Creature.x,entx)
   engine.poke(vector:getval(indx),ptr_Creature.y,enty)
   until flg:get(15) ==1 or flg2:get(1) ==1]]--
end
function rum_tools.Fortilate() -- make creature same civ as the area their in great for converting adventurers to citizens of a fort.
vector=engine.peek(offsets.getEx("CreatureVec"),ptr_vector)
id=engine.peekd(offsets.getEx("CreaturePtr"))
print(string.format("Vec:%d cr:%d",vector:size(),id))
off=vector:getval(id)
crciv=engine.peek(off,ptr_Creature.civ)
curciv=engine.peekd(offsets.getEx("CurrentRace")-12)

if curciv==crciv then
print("Friendly")
--engine.poke(off,ptr_Creature.civ,curciv)
flg=engine.peek(off,ptr_Creature.flags)
flg:set(17,false)
engine.poke(off,ptr_Creature.flags,flg)
else
print("Enemy or Adventurer- making friendly")
engine.poke(off,ptr_Creature.civ,curciv)
flg=engine.peek(off,ptr_Creature.flags)
flg:set(17,false)
flg:set(19,false)
engine.poke(off,ptr_Creature.flags,flg)
end
end
function selectciv()
  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 crciv=engine.peek(off,ptr_Creature.civ)
     local curciv=engine.peek(vector:getval(0),ptr_Creature.civ)
     if curciv==crciv then
     --[[local flags=engine.peek(off,ptr_Creature.flags)
     if flags:get(1)==false then]]--  --if dead ...
        table.insert(retvec,off)--... add it to return vector
     end
  end
  return retvec --return the "return vector" :)
end
function selectciv1() -- this grabs any who is apart of the first civ aka Civ number "1"
  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 crciv=engine.peek(off,ptr_Creature.civ)
     --local curciv=engine.peek(vector:getval(0),ptr_Creature.civ)
     if crciv==1  then
     --[[local flags=engine.peek(off,ptr_Creature.flags)
     if flags:get(1)==false then]]--  --if dead ...
        table.insert(retvec,off)--... add it to return vector
     end
  end
  return retvec --return the "return vector" :)
end
function rum_tools.returnfort() -- goes through all who are apart of your civ and flips off the is resident tag also has left over code form previous testing.
local trgs=selectciv()
for k,v in pairs(trgs) do
print("members:"..k)
local flags=engine.peek(v,ptr_Creature.flags)
flags:set(51,false) -- alive!
--flags:set(13,true)
--flags:set(12,false) no zombie
engine.poke(v,ptr_Creature.flags,flags)
end
local trgs=selectciv1()
for w,q in pairs(trgs) do
print("pets:"..w)
local flags=engine.peek(q,ptr_Creature.flags)
flags:set(26,true) -- alive!
--flags:set(13,true)
--flags:set(12,false) no zombie
engine.poke(q,ptr_Creature.flags,flags)
end
end

function rum_tools.ControlCiv() -- mass assemble of every one in your fort though they will be non companions if you fast travel
--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)
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
engine.peek(v,ptr_Creature.followID) -- get target creatures "now following ID"
engine.poke(v,ptr_Creature.followID,trgid) -- if not just write the players ID.
end
end

function rum_tools.ControlCiv2() -- this fixes the Fast travel issue and will make them permanently a member of your companions best for military heavy groups and armies.
--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=rum_tools.getlegendsid(vector:getval(0))
trglegid=rum_tools.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)
end
end
function selecttame()
  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(26)==true then  --if tame in anyway...
        table.insert(retvec,off)--... add it to return vector
     end
  end
  return retvec --return the "return vector" :)
end

function rum_tools.tamilate() -- this function causes any tame critter to be turn into civ one or apart of your civ number I need to change this so that it just does the latter.
vector=engine.peek(offsets.getEx("AdvCreatureVec"),ptr_vector)
--id=GetCreatureAtPos(getxyz())
local trgs=selecttame()
for k,v in pairs(trgs) do
--print(string.format("Vec:%d cr:%d",vector:size(),id))
print("tamed" ..k)
--off=vector:getval(id)
crciv=engine.peek(v,ptr_Creature.civ)
curciv=engine.peek(vector:getval(0),ptr_Creature.civ)

if curciv==crciv then
print("unlocked-making locked")
engine.poke(v,ptr_Creature.civ,1)
flg=engine.peek(v,ptr_Creature.flags)
flg:set(51,false)
flg:set(26,false)
engine.poke(v,ptr_Creature.flags,flg)
else
print("locked- making unlocked")
engine.poke(v,ptr_Creature.civ,curciv)
flg=engine.peek(v,ptr_Creature.flags)
flg:set(51,false)
flg:set(19,false)
engine.poke(v,ptr_Creature.flags,flg)
end
end
end

function rum_tools.Convert() -- for changing the civ number of the companion to match the adventurer.
myoff=offsets.getEx("AdvCreatureVec")
vector=engine.peek(myoff,ptr_vector)
--id=engine.peekd(offsets.getEx("CreaturePtr"))
--print(string.format("Vec:%d cr:%d",vector:size(),id))
local trgs=selectcomp()
for k,v in pairs(trgs) do
print("members:"..k)
off=v
crciv=engine.peek(off,ptr_Creature.civ)
curciv=engine.peek(vector:getval(0),ptr_Creature.civ)
if curciv==crciv then
print("Friendly")
--engine.poke(off,ptr_Creature.civ,curciv)
flg=engine.peek(off,ptr_Creature.flags)
flg:set(17,false)
engine.poke(off,ptr_Creature.flags,flg)
else
print("Enemy or Adventurer- making friendly")
engine.poke(off,ptr_Creature.civ,curciv)
flg=engine.peek(off,ptr_Creature.flags)
flg:set(17,false)
flg:set(19,false)
engine.poke(off,ptr_Creature.flags,flg)
end
end
end

function rum_tools.deadwarp()
myoff=offsets.getEx("AdvCreatureVec")
vector=engine.peek(myoff,ptr_vector)
local tx,ty,tz
local trgs=selectdead()
for k,v in pairs(trgs) do
tx,ty,tz=getxyz()
print("Warp to coords:"..tx.." "..ty.." "..tz)
engine.poke(v,ptr_Creature.x,tx)
engine.poke(v,ptr_Creature.y,ty)
engine.poke(v,ptr_Creature.z,tz)
end
end

function rum_tools.zomwarp()
myoff=offsets.getEx("AdvCreatureVec")
vector=engine.peek(myoff,ptr_vector)
local tx,ty,tz
local trgs=selectzombie()
for k,v in pairs(trgs) do
tx,ty,tz=getxyz()
print("Warp to coords:"..tx.." "..ty.." "..tz)
engine.poke(v,ptr_Creature.x,tx)
engine.poke(v,ptr_Creature.y,ty)
engine.poke(v,ptr_Creature.z,tz)
end
end
if not(FILE) then -- if not in script mode
rum_tools.menu:add("Toggle wutest",rum_tools.maketest)
rum_tools.menu:add("Change flag",rum_tools.changeflag)
rum_tools.menu:add("Ressurection Fix",rum_tools.ressurect)
--rum_tools.menu:add("?Toggle hostile?",rum_tools.hostilate)
rum_tools.menu:add("?control undead?",rum_tools.ControlZombie)
rum_tools.menu:add("control civ",rum_tools.ControlCiv)
rum_tools.menu:add("?control civ?",rum_tools.ControlCiv2)
rum_tools.menu:add("healer",rum_tools.ressurectcomp)
rum_tools.menu:add("Mass Ressurection",rum_tools.ressurectall)
rum_tools.menu:add("?Reveal ambush?",rum_tools.nosneak)
rum_tools.menu:add("?passive ghost time?",rum_tools.ghostin)
rum_tools.menu:add("?SkeltoZombies?",rum_tools.skeltozombie)
rum_tools.menu:add("?Zombiestoskel?",rum_tools.zombietoskel)
rum_tools.menu:add("Zombies fix",rum_tools.Zombieressurect)
rum_tools.menu:add("?necromancer?",rum_tools.Zombieressurectandcontrol)
rum_tools.menu:add("?harm?",rum_tools.Hurt)
rum_tools.menu:add("?returntofort?",rum_tools.returnfort)
rum_tools.menu:add("?carry?",rum_tools.carry)
rum_tools.menu:add("?carryex?",rum_tools.carryEX)
rum_tools.menu:add("?warp?",rum_tools.warp)
rum_tools.menu:add("?warp2wagon?",rum_tools.warptowag)
rum_tools.menu:add("?piggy backin?",rum_tools.compiggybackride)
rum_tools.menu:add("?group sneak?",rum_tools.compsneak)
rum_tools.menu:add("?bye civ?",rum_tools.nociv)
rum_tools.menu:add("change make member of civ",rum_tools.Fortilate)
rum_tools.menu:add("?make companions fortplayable?",rum_tools.fortcomps)
rum_tools.menu:add("?makefort playable?",rum_tools.fortdy)
rum_tools.menu:add("gut a friendly",rum_tools.butcher)
rum_tools.menu:add("gut a dead",rum_tools.butcherdead)
rum_tools.menu:add("?harm part?",rum_tools.Hurtselected)
rum_tools.menu:add("?werebronze?",rum_tools.lycanressurect)
rum_tools.menu:add("?Companionsracechange?",rum_tools.comprace)
rum_tools.menu:add("?Companionsracechange easier?",rum_tools.compraceez)
rum_tools.menu:add("lock up pets",rum_tools.tamilate)
rum_tools.menu:add("cleanupfloors",rum_tools.fixwarp)
rum_tools.menu:add("move zed",rum_tools.zomwarp)
rum_tools.menu:add("move souls",rum_tools.deadwarp)
rum_tools.menu:add("convert companions",rum_tools.Convert)
--rum_tools.menu:add("Swap to companion",rum_tools.change_adv2comp)
--rum_tools.menu:add("beastmaster",rum_tools.tamingcompanions)
rum_tools.menu:display()
--[[
choices={,{adv_tools.makeghost,"Toggle ghostliness"},{adv_tools.hostilate,"Toggle hostile"},{function () return end,"Quit"}} --make a table of function+string pairs
print("Select choice:")
for p,c in pairs(choices) do
print(p..")."..c[2]) -- print choices names
end
repeat
ans=tonumber(io.stdin:read())
if ans==nil or not(ans<=table.maxn(choices) and ans>0) then
print("incorrect choice")
end
until ans~=nil and (ans<=table.maxn(tdir) and ans>0)
choices[ans][1]() --run the choice
--]]
end
Spoiler: "old post" (click to show/hide)
« Last Edit: May 24, 2011, 06:23:45 am by Rumrusher »
Logged
I thought I would I had never hear my daughter's escapades from some boy...
DAMN YOU RUMRUSHER!!!!!!!!
"body swapping and YOU!"
Adventure in baby making!Adv Homes

darius

  • Bay Watcher
  • ^^
    • View Profile
Re: DFusion - a lua based plugin system v1.2
« Reply #9 on: November 07, 2010, 09:31:47 am »

<..> Though I Ponder the miss chance of communicating to animals using this,<..>
what do you mean? Talking to animals?
<..> that and finally seeing if one can have babies with adventurers in 31.xx.
Should not be so hard. (If Runesmith does not give that ability i could look into it.) AFAIK: you need ability to change a few flags for the retired adventurer and maybe his civ?
Edit: one problem though: you cannot embark on any city/village in 31.16
« Last Edit: November 07, 2010, 12:43:09 pm by darius »
Logged

Kiktamo

  • Bay Watcher
    • View Profile
Re: DFusion - a lua based plugin system v1.2
« Reply #10 on: November 07, 2010, 01:34:48 pm »

True but there's an embark anywhere hex edit that can be done

http://www.bay12forums.com/smf/index.php?topic=21351.msg1655462#msg1655462
Logged

darius

  • Bay Watcher
  • ^^
    • View Profile
Re: DFusion - a lua based plugin system v1.2
« Reply #11 on: November 07, 2010, 01:55:27 pm »

Did not work (at least for me) in .16
Logged

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: DFusion - a lua based plugin system v1.2
« Reply #12 on: November 07, 2010, 02:35:48 pm »

Code: [Select]
function rum_tools.fixwarp()
local mapoffset=offsets.getEx("WorldData")--0x131C128+offsets.base()
local x=engine.peek(mapoffset+24,DWORD)
local y=engine.peek(mapoffset+28,DWORD)
local z=engine.peek(mapoffset+32,DWORD)
--vec=engine.peek(mapoffset,ptr_vector)

print("Blocks loaded:"..x.." "..y.." "..z)
print("Select type:")
print("1. All (SLOW)")
print("2. range (x0 x1 y0 y1 z0 z1)")
print("3. One block around pointer")
print("anything else- quit")
q=io.stdin:read()
n2=tonumber(q)
if n2==nil then return end
if n2>3 or n2<1 then return end
local xs,xe,ys,ye,zs,ze
if n2==1 then
xs=0
xe=x-1
ys=0
ye=y-1
zs=0
ze=z-1
elseif n2==2 then
print("enter x0:")
xs=tonumber(io.stdin:read())
print("enter x1:")
xe=tonumber(io.stdin:read())
print("enter y0:")
ys=tonumber(io.stdin:read())
print("enter y1:")
ye=tonumber(io.stdin:read())
print("enter z0:")
zs=tonumber(io.stdin:read())
print("enter z1:")
ze=tonumber(io.stdin:read())
function clamp(t,vmin,vmax)
if t> vmax then return vmax end
if t< vmin then return vmin end
return t
end
xs=clamp(xs,0,x-1)
ys=clamp(ys,0,y-1)
zs=clamp(zs,0,z-1)
xe=clamp(xe,xs,x-1)
ye=clamp(ye,ys,y-1)
ze=clamp(ze,zs,z-1)
else
xs,ys,zs=getxyz()
xs=math.floor(xs/16)
ys=math.floor(ys/16)
xe=xs
ye=ys
ze=zs
end
local xblocks=engine.peek(mapoffset,DWORD)
local flg=bit.bnot(bit.lshift(1,3))
for xx=xs,xe do
local yblocks=engine.peek(xblocks+xx*4,DWORD)
for yy=ys,ye do
local zblocks=engine.peek(yblocks+yy*4,DWORD)
for zz=zs,ze do



local myblock=engine.peek(zblocks+zz*4,DWORD)
if myblock~=0 then
for i=0,255 do
local ff=engine.peek(myblock+0x67c+i*4,DWORD)
ff=bit.band(ff,flg) --set 14 flag to 1
engine.poke(myblock+0x67c+i*4,DWORD,ff)
end
end
end
print("Blocks done:"..xx.." "..yy)
end
end
end

Spoiler: old post (click to show/hide)
« Last Edit: May 24, 2011, 06:23:59 am by Rumrusher »
Logged
I thought I would I had never hear my daughter's escapades from some boy...
DAMN YOU RUMRUSHER!!!!!!!!
"body swapping and YOU!"
Adventure in baby making!Adv Homes

darius

  • Bay Watcher
  • ^^
    • View Profile
Re: DFusion - a lua based plugin system v1.2
« Reply #13 on: November 07, 2010, 02:40:38 pm »

As for companions: sometimes they are left behind if you travel(in local mode) very fast in one direction and they are fighting or sth... don't remember but it happened to me at least twice.
Edit: yay found an how to fix embark anywhere.
Edit2: but the map gen is busted and cities are non existant (including units)
« Last Edit: November 07, 2010, 03:48:01 pm by darius »
Logged

Kiktamo

  • Bay Watcher
    • View Profile
Re: DFusion - a lua based plugin system v1.2
« Reply #14 on: November 07, 2010, 10:29:23 pm »

Yeah seems that an adventurer has to enter a town before it exists or whatever I don't know If the town continues to exist after the adventurer leaves though.
Logged
Pages: [1] 2 3 ... 38