Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 10 11 [12] 13 14 ... 38

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

darius

  • Bay Watcher
  • ^^
    • View Profile
Re: DFusion - a lua based plugin system v2.4
« Reply #165 on: January 17, 2011, 06:03:23 pm »

Could be that you are using the wrong tool. Adv-tools are for adventure mode only. AFAIR there should be same tools for fort mode but it has been some time since i touched anything related to DF/DFusion (few more weeks and i'll be done with uni ^^ (for now...) )
add this into plugins\tools\plugin.lua
Not tested for now...
Code: [Select]
function tools.racechange()

myoff=offsets.getEx("CreatureVec")
vector=engine.peek(myoff,ptr_vector)
local offset=0
tx,ty,tz=getxyz()
for i=0,vector:size() do
x=engine.peek(vector:getval(i),ptr_Creature.x)
y=engine.peek(vector:getval(i),ptr_Creature.y)
z=engine.peek(vector:getval(i),ptr_Creature.z)
if x==tx and y==ty and z==tz then
offset=vector:getval(i)
break;
end
end
if offset==0 then
print("Failed to find creature!")
return
end

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(offset,ptr_Creature.race,id)
end
tools.menu:add("Change creature race",tools.racechange)
Logged

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: DFusion - a lua based plugin system v2.4
« Reply #166 on: January 23, 2011, 04:09:25 am »

edit: Darius ADv_tools do work in fort mode.
oh I just smooth out more of the wagon mode code for adventurers.
Code: [Select]
function adv_tools.wagonmode()
--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+16,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,0)
flg:set(74,0)
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,0)
engine.poke(vector:getval(indx),ptr_Creature.flags,flg)
else
flg=engine.peek(vector:getval(indx),ptr_Creature.flags)
flg:set(1,0)
flg:flip(74)
engine.poke(vector:getval(indx),ptr_Creature.flags,flg)
end
end
sadly I wonder why does it only work when the creature is dead. guess it from the fact it only meant to be use only for caravans in fort mode and those where pulled by some type of animal, oh well makes me wonder oh well still wonder why that zombie mod doesn't work.
edit: made a easier to play with flags command for adventure mode.
Code: [Select]
function adv_tools.insertflag()
myoff=offsets.getEx("AdvCreatureVec")
vector=engine.peek(myoff+16,ptr_vector)
indx=GetCreatureAtPos(getxyz())
flg=engine.peek(vector:getval(indx),ptr_Creature.flags)
print("insert flag:")
entry=io.stdin:read()
flg:flip(entry)
engine.poke(vector:getval(indx),ptr_Creature.flags,flg)
end
« Last Edit: January 26, 2011, 04:58:05 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 v2.4
« Reply #167 on: January 26, 2011, 03:26:20 pm »

Okay i'm back. Just tried zombies and the problem is (i think) with the resurrected creatures that they have no body so next action involving body (attack defense or sth) will crash DF.

EDIT: added two plugins by rumrusher, ALSO: RESSURECTION!!!!11ONE with limb healing!!!!
« Last Edit: January 26, 2011, 06:48:11 pm by darius »
Logged

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: DFusion - a lua based plugin system v2.4
« Reply #168 on: January 26, 2011, 09:06:52 pm »

Okay i'm back. Just tried zombies and the problem is (i think) with the resurrected creatures that they have no body so next action involving body (attack defense or sth) will crash DF.

EDIT: added two plugins by rumrusher, ALSO: RESSURECTION!!!!11ONE with limb healing!!!!
also if you slap on Resurrection limb healing with Zombie you could fix that crashing issue since they revive with no limbs.
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 v2.5
« Reply #169 on: January 26, 2011, 09:33:06 pm »

Yeah had that idea after releasing... But now I just found out that i must do another homework for university :(
Logged

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: DFusion - a lua based plugin system v2.5
« Reply #170 on: January 26, 2011, 09:43:40 pm »

Yeah had that idea after releasing... But now I just found out that i must do another homework for university :(
no big though I might have to find a way to get "v" in the zombie command to fit into the "Indx" in the resurrection code and I don't think placing indx=v would work.
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 v2.5
« Reply #171 on: January 26, 2011, 09:53:01 pm »

something like this, but have not time to test:
Code: [Select]
function adv_tools.zombie()
local trgs=selectall()
for k,v in pairs(trgs) do
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 flg=engine.peek(v,ptr_Creature.flags)
local flags=engine.peek(v,ptr_Creature.flags)
    flg:set(1,0) --ALIVE
flags:set(12,1) --zombie
    flg:set(39,0) -- leave body yet again
    flg:set(37,0) -- something todo with wounds- lets you walk again.
engine.poke(v,ptr_Creature.flags,flags)
end
end
Logged

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: DFusion - a lua based plugin system v2.5
« Reply #172 on: January 26, 2011, 10:05:55 pm »

something like this, but have not time to test:
Code: [Select]
function adv_tools.zombie()
local trgs=selectall()
for k,v in pairs(trgs) do
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 flg=engine.peek(v,ptr_Creature.flags)
local flags=engine.peek(v,ptr_Creature.flags)
    flg:set(1,0) --ALIVE
flags:set(12,1) --zombie
    flg:set(39,0) -- leave body yet again
    flg:set(37,0) -- something todo with wounds- lets you walk again.
engine.poke(v,ptr_Creature.flags,flags)
end
end
oh shoot that's what I got...
Code: [Select]
function adv_tools.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,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,0) -- alive!
flags:set(12,1) --zombie
engine.poke(v,ptr_Creature.flags,flags)
end
end
it was puzzling but I figured out that the problem was the vector getting value so I remove all of it and replace it with v.
oh well still my alligators seem to be just pushing stuff around than attacking. well at least now the folks at zombie mod can have their rising dead again.
edit: I just tested your code(added the two flags from yours 37 and 39) and it seems it just kills the zombie again.
removing those two seems to fix it. 
So now in adventure mode we can walk on water, come back from the dead in less than 3 days, turn water in to wine and turn folks into wooden caravans I mean really go at carpentry oh revive millions.

edit:
here some adventurer mode only zombie codes for any one with a necro twitch
Code: [Select]
function adv_tools.Zombieressurectandcontrol()
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
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,0) -- alive!
flags:set(12,1) --zombie
engine.poke(v,ptr_Creature.flags,flags)
end
end

function adv_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,0) -- alive!
flags:set(39,0) -- leave body yet again
flags:set(37,0) -- something todo with wounds- lets you walk again.
engine.poke(v,ptr_Creature.flags,flags)
end
end

function adv_tools.ControlZombie()
--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+16,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.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 selectalive()
  local retvec={} --return vector (or a list)
  myoff=offsets.getEx("AdvCreatureVec")
  vector=engine.peek(myoff+16,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)==0 then  --if dead ...
        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+16,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)==1 then  --if dead ...
        table.insert(retvec,off)--... add it to return vector
     end
  end
  return retvec --return the "return vector" :)
end
I was going to add in a perma zombie res control but then it was to much code to cut and paste into right... that and having horrible zombies who will attack you unless you're a ghost isn't what I had in mind. oh well with this it would make the process of making them follow much easier.
wait danging now I need to test if I can add a "non hostile to other companions" code.
hmm maybe later when I can build up over 100 zombie minions.
« Last Edit: January 28, 2011, 02:01:38 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

Dragonchampion

  • Bay Watcher
    • View Profile
Re: DFusion - a lua based plugin system v2.5
« Reply #173 on: February 07, 2011, 12:56:00 am »

Sorry for the noobishness, but is there any way to get this to work with Dwarf Therapist? It will not see any races but dwarves.  :'(
Logged

darius

  • Bay Watcher
  • ^^
    • View Profile
Re: DFusion - a lua based plugin system v2.5
« Reply #174 on: February 07, 2011, 11:52:18 am »

not without manually editing dwarf therapist's source code. Maybe somebody could do that from DT thread? (atleast remove the check altogether)
Logged

Deon

  • Bay Watcher
  • 💀 💀 💀 💀 💀
    • View Profile
Re: DFusion - a lua based plugin system v2.5
« Reply #175 on: February 07, 2011, 12:11:24 pm »

Hey, did YOU make that awesome tool which allowed magical gem? If so, is there any chance to get it for the current version? :)
Logged
▬(ஜ۩۞۩ஜ)▬
✫ DF Wanderer ✫ - the adventure mode crafting and tweaks
✫ Cartographer's Lounge ✫ - a custom worldgen repository

darius

  • Bay Watcher
  • ^^
    • View Profile
Re: DFusion - a lua based plugin system v2.5
« Reply #176 on: February 07, 2011, 12:43:43 pm »

You mean that enchanting with detailing mod for old DF? Unfortunately not yet. Don't have the patients to find all the offsets (and calling conventions) for functions just to find them different next version (and new DF is really not far away). Maybe i'll make some automated tool later.
Logged

Deon

  • Bay Watcher
  • 💀 💀 💀 💀 💀
    • View Profile
Re: DFusion - a lua based plugin system v2.5
« Reply #177 on: February 07, 2011, 12:57:02 pm »

Yeah, if you ever make it again, it would be grand :). I miss firebreathing statues.
Logged
▬(ஜ۩۞۩ஜ)▬
✫ DF Wanderer ✫ - the adventure mode crafting and tweaks
✫ Cartographer's Lounge ✫ - a custom worldgen repository

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: DFusion - a lua based plugin system v2.5
« Reply #178 on: February 07, 2011, 02:43:08 pm »

Yeah, if you ever make it again, it would be grand :). I miss firebreathing statues.
I missed making fire breathing weapons for adventure mode. man those where the days in fact I think making spells was the thing that cause me to stumble into adventurer breeding.
oh well now this makes me want to crack open Spellcraft.exe see how it ticks and use that as a starting point once I go search for those offsets.

Sadly I don't know how to crack open my old Spellcraft nor know how to search for offsets(I think someone posted a guide on how.).
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

Alkhemia

  • Bay Watcher
  • aka Deep Sea Diver Man
    • View Profile
Re: DFusion - a lua based plugin system v2.5
« Reply #179 on: February 07, 2011, 03:02:55 pm »

lol I was changing adventures and i set the cursor in the wrong spot now I'm in HFS and a Clown  :o
 Edit: every time i sleep and travel i end up as a diffrent creature now i'm a plump helmet man...
« Last Edit: February 07, 2011, 03:08:12 pm by Alkhemia »
Logged
"Hiken: Tsubame-Gaeshi" -Sasaki Kojirou (Grand Order}

"Please touch me. Without lying, wherever you want to touch. That is my wish." - Kiyohime (Grand Order)

"Tyranny, violation, genocide. Those are the things that I detest above all else." - Amakusa Shirou Tokisada (Grand Order)
Pages: 1 ... 10 11 [12] 13 14 ... 38