Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 25 26 [27] 28 29 ... 38

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

Thundercraft

  • Bay Watcher
    • View Profile
Re: DFusion - a lua based plugin system v3.8
« Reply #390 on: August 06, 2011, 08:20:49 am »

...Take the line of code where it say "makes them breathe" and "gives them sight" 
paste that in the same spot in the original adv_tool resurrect
for all I did was take the original and added some missing flags due to people tend to suffocate or come out blind when I revive them.

Those sound like very useful additions to the Ressurection plugin. Will they eventually get added to the Resurrection portion of the new DFusion DFHack plugin?
Logged

darius

  • Bay Watcher
  • ^^
    • View Profile
Re: DFusion - a lua based plugin system v3.8
« Reply #391 on: August 07, 2011, 07:24:56 am »

...Take the line of code where it say "makes them breathe" and "gives them sight" 
paste that in the same spot in the original adv_tool resurrect
for all I did was take the original and added some missing flags due to people tend to suffocate or come out blind when I revive them.

Those sound like very useful additions to the Ressurection plugin. Will they eventually get added to the Resurrection portion of the new DFusion DFHack plugin?
Added.
Logged

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: DFusion - a lua based plugin system v3.8
« Reply #392 on: August 07, 2011, 06:57:29 pm »

wait if your going to do that then add this as well.
Code: [Select]
function Adv_tools.Zombieressurect() --fix to zombism
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 Adv_tools.carryEX() --have the pointer on the creature you want to hold on to.
   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 selectdead()
  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 then  --if dead ...
        table.insert(retvec,off)--... add it to return vector
     end
  end
  return retvec --return the "return vector" :)
end

function Adv_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
func.PrintMessage3_(msg)
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 Adv_tools.compwarp() --teleport companions if you used Control Civ you might teleport your self aswell
func.PrintMessage2_(msg)
myoff=offsets.getEx("AdvCreatureVec")
vector=engine.peek(myoff,ptr_vector)
local tx,ty,tz
local trgs=selectcomp()
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 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 Adv_tools.zomwarp() --teleport zombies
func.PrintMessage2_(msg)
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

function Adv_tools.fixwarp() --fixing the large invisible blocks that slows movement
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

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 Adv_tools.ControlCiv2() --those who has the same civ number as the adventurer will become the adventurer's companion might need to run this again after you travel out for they stop being companions after you travel and need to reapply one more time.
--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 Adv_tools.Convert() --makes companions the same civ
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
Adv_tools.menu:add("?control civ?",Adv_tools.ControlCiv2)
Adv_tools.menu:add("Zombies fix",Adv_tools.Zombieressurect)
Adv_tools.menu:add("?carryex?",Adv_tools.carryEX)
Adv_tools.menu:add("arrange companions",Adv_tools.compwarp)
Adv_tools.menu:add("move zed",Adv_tools.zomwarp)
Adv_tools.menu:add("move souls",Adv_tools.deadwarp)
Adv_tools.menu:add("convert companions",Adv_tools.Convert)

note: the original headers where change from Rum_tools to Adv_tools for easier adding.
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

Kaelem Gaen

  • Bay Watcher
  • And then it appeared the most terrifying creature
    • View Profile
Re: DFusion - a lua based plugin system v3.8
« Reply #393 on: August 07, 2011, 10:16:11 pm »

So how exactly do you add a plug in to DFhack?

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: DFusion - a lua based plugin system v3.8
« Reply #394 on: August 08, 2011, 06:54:24 am »

you mean how would a LUA plugin to Dfusion work for Dfhack's list of application?
beats me, I ask that same question I hope the same as before now I get access to dump silly functions to lighting pants on fire in the DFhack Chat.
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

Deviled

  • Bay Watcher
  • Yup
    • View Profile
Re: DFusion - a lua based plugin system v3.8
« Reply #395 on: August 08, 2011, 12:35:17 pm »

When I try to use any of the adv tools it says creature not found.
Logged

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: DFusion - a lua based plugin system v3.8
« Reply #396 on: August 08, 2011, 01:21:58 pm »

When I try to use any of the adv tools it says creature not found.

More info pls (is version latest/SDL and are you in adventure mode?)

Also i found my old account pass :)

So how exactly do you add a plug in to DFhack?

Not as simple as dfusion :) but almost as simple. You need to know some C++ to do that if you are still interested- i will try to explain in more detail.

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: DFusion - a lua based plugin system v3.8
« Reply #397 on: August 08, 2011, 04:27:11 pm »

more so for Deviled have you try using the pointer on a creature who is alive?
ADv_tools greatest hurdle is just the teaching folks you need to use the pointer on top of the creature you want to affect.
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

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: DFusion - a lua based plugin system v3.8
« Reply #398 on: August 08, 2011, 06:03:26 pm »

more so for Deviled have you try using the pointer on a creature who is alive?
ADv_tools greatest hurdle is just the teaching folks you need to use the pointer on top of the creature you want to affect.
hehe tottaly forgot how it works :D

Btw linux version working but not doing anything yet :)

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: DFusion - a lua based plugin system v3.8
« Reply #399 on: August 08, 2011, 07:13:36 pm »

Well for Adventure fort news You can enlist any thing to military just not as a captain if you use the change fort race over in the Military screen and have the creature you want to apply have resident off(if there not sentient just flip them to the same race the fort runs enlist then flip back).
The other news is that if you add back the is resident flag on a military unit they will still be able to order around and have the added bonus of never need to feed them or give them a room.
Which means you can have squads of friendly minotaurs at the front gate or a group of Cave spiders appointed for archery with the Forbidden beasts.

For any home owners best pick up Runesmith and causally clean out the rising Demon population using the extinct button for these forts will accumulate demons who for some reason won't leave and will slow down the cpu. Animal men are to small an issue (and won't spill syndromes every where killing your citizens unless you got a mod that allows them to do so) and if you find any on the list better change their civ to yours and pull them out of the ground and enlist them as the military backbone of the site.

Oh and one thing INTERNS should never be place in the same group or squad as every one else in fact better keep them away from every one else or send them in first.
I learn this the hard way and now I got rotting living men who I guess caused my intern adventurer to go insane.
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

Kaelem Gaen

  • Bay Watcher
  • And then it appeared the most terrifying creature
    • View Profile
Re: DFusion - a lua based plugin system v3.8
« Reply #400 on: August 08, 2011, 09:13:37 pm »

Actually no I was asking how I use the DFusion Plugin for DF Hack, I just see CPP or something for all the files on the git, my question is how do you use DFusion AS a plugin for DFhack....

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: DFusion - a lua based plugin system v3.8
« Reply #401 on: August 08, 2011, 11:19:39 pm »

Warmist you didn't add the perma adventurer swap and perma follow for the Dfhack version of DFusion?
I guess there removed until dfhack version works properly.
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

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: DFusion - a lua based plugin system v3.8
« Reply #402 on: August 09, 2011, 05:08:35 am »

Warmist you didn't add the perma adventurer swap and perma follow for the Dfhack version of DFusion?
I guess there removed until dfhack version works properly.

Yeah could have missed them. Currently it's a bit messy, trying to port embark.

Deviled

  • Bay Watcher
  • Yup
    • View Profile
Re: DFusion - a lua based plugin system v3.8
« Reply #403 on: August 09, 2011, 05:22:38 pm »

more so for Deviled have you try using the pointer on a creature who is alive?
ADv_tools greatest hurdle is just the teaching folks you need to use the pointer on top of the creature you want to affect.

Wait what. Hold on let me try that.

Edit: yeah that was the problem
« Last Edit: August 09, 2011, 05:26:46 pm by Deviled »
Logged

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: DFusion - a lua based plugin system v3.8
« Reply #404 on: August 09, 2011, 05:29:59 pm »

Oh warmist I got a question I'm having trouble with getting a site to be change due to the dfusion doesn't recognize SCALE as a word and Dfusion can't search for sites by one word.
The issue here is from attempting to change a elven resort over to a hamlet so I can steal their princess for my fort.
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
Pages: 1 ... 25 26 [27] 28 29 ... 38