Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: How to do a bodyswap ?  (Read 3954 times)

Bauta

  • Bay Watcher
    • View Profile
    • My Youtube
How to do a bodyswap ?
« on: March 27, 2017, 08:20:02 am »

I want to start an adventure with one of my fortressdwarfs
I retired the fortress, went there with another character, found the guy i am looking for but i dont know how to bodyswap because adv_bodyswap says its not a recognised comman  :'(
Logged
_________
>Blacki loses his right arm, Blacki loses his left arm
>Blacki: I am badly injured, this phases me not
>Blacki bites the Goblin lasher in the throat and the injured part is cloven asunder

Shonai_Dweller

  • Bay Watcher
    • View Profile
Re: How to do a bodyswap ?
« Reply #1 on: March 27, 2017, 08:28:48 am »

I want to start an adventure with one of my fortressdwarfs
I retired the fortress, went there with another character, found the guy i am looking for but i dont know how to bodyswap because adv_bodyswap says its not a recognised comman  :'(
Try the Mod forum? Dfhack forum? Someplace like that.
Logged

Lezeryn

  • Bay Watcher
    • View Profile
Re: How to do a bodyswap ?
« Reply #2 on: March 27, 2017, 10:02:24 am »

I can change to a desired character? How????
Logged

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: How to do a bodyswap ?
« Reply #3 on: March 27, 2017, 11:43:04 am »

oh boy you probably want Dfhack... or Resurrection on your adventurer next to the person you want to swap to and hope you jump into the body you wanted.
Code: [Select]
function getCreatureAtPos(x,y,z) -- gets the creature index @ x,y,z coord
--local x,y,z=getxyz() --get 'X' coords
local vector=df.global.world.units.all -- load all creatures
for i = 0, #vector-1 do -- look into all creatures offsets
local curpos=vector[i].pos --get its coordinates
local cx=curpos.x
local cy=curpos.y
local cz=curpos.z
if cx==x and cy==y and cz==z then --compare them
return vector[i] --return index
end
end
--print("Creature not found!")
return nil

end

function change_adv2(unit,nemesis)
if nemesis==nil then
nemesis=true --default value is nemesis switch too.
end
if unit==nil then
unit=getCreatureAtPos(getxyz())    --getCreatureAtPointer()--getSelectedUnit()
end
if unit==nil then
error("Invalid unit!")
end
local other=df.global.world.units.active
local unit_indx
for k,v in pairs(other) do
if v==unit then
unit_indx=k
break
end
end
if unit_indx==nil then
error("Unit not found in array?!") --should not happen
end
other[unit_indx]=other[0]
other[0]=unit
if nemesis then --basicly copied from advtools plugin...
local nem=dfhack.units.getNemesis(unit)
local other_nem=dfhack.units.getNemesis(other[unit_indx])
if other_nem then
other_nem.flags[0]=false
other_nem.flags[1]=true
end
if nem then
nem.flags[0]=true
nem.flags[2]=true
for k,v in pairs(df.global.world.nemesis.all) do
if v.id==nem.id then
df.global.ui_advmode.player_id=k
end
end
else
qerror("Current unit does not have nemesis record, further working not guaranteed")
end
end
end
here this is the remains of the bodyswap/ change adv script I use based from warmist's Dfusion copy, it works on cursor alignment so you need to be looking at your target you want to swap to.
switching back probably takes using Reveal if you happen to say swap to someone Miles away.
switching with this has the side effect of being able to play the character and any one you swap to before again if you retire them they get added to the playable adv pool.
you could swap between Fort mode and advmode through saving the game and selecting an adventurer with this though you probably have to go through loads of Gm-editor loops to get them Fort workable if they were not apart of the civ.
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

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile
Re: How to do a bodyswap ?
« Reply #4 on: March 27, 2017, 05:38:55 pm »

I wanted one of these I could hotkey actually, I remembered why I went through the hoops instead of just using the advtools or whatnot methods.
Code: (assumecontrol.lua) [Select]
local utils = require 'gui'

function assumeControl(new,old)
local actold
for i,j in ipairs(df.global.world.units.all) do
if j.id==df.global.world.units.active[0].id then
actold=j.id
break
end
end
local old
old=df.unit.find(actold)
local new
new=dfhack.gui.getSelectedUnit(true)
if new==nil then
qerror("Unable to Assume Control!")
end
local active=df.global.world.units.active
local actnew
for k,v in pairs(active) do
if v==new then
actnew=k
break
end
end
if actnew==nil then
qerror("Attempt to Assume Control has failed?")
end
active[actnew]=active[0]
active[0]=new
local target = dfhack.units.getNemesis(new)
if target then
local nwnem=dfhack.units.getNemesis(new)
local olnem=dfhack.units.getNemesis(old)
if olnem then
olnem.flags.ACTIVE_ADVENTURER=false
olnem.flags.RETIRED_ADVENTURER=true
olnem.unit.status.current_soul.personality.flags[1]=false
end
if nwem then
nwem.flags.ACTIVE_ADVENTURER=true
nwem.flags.RETIRED_ADVENTURER=false
nwnem.flags.ADVENTURER=true
nwnem.unit.status.current_soul.personality.flags[1]=true
for k,v in pairs(df.global.world.nemesis.all) do
if v.id==nwnem.id then
df.global.ui_advmode.player_id=k
end
end
end
else
qerror("Assuming Direct Control! Current target may not last long!")
end
end
assumeControl(new,old)
Logged

Bauta

  • Bay Watcher
    • View Profile
    • My Youtube
Re: How to do a bodyswap ?
« Reply #5 on: April 26, 2017, 05:58:35 am »

I tried figuring it out myself, but i simply dont know how to make the commands work in DF hack, can anyone help me ?
Logged
_________
>Blacki loses his right arm, Blacki loses his left arm
>Blacki: I am badly injured, this phases me not
>Blacki bites the Goblin lasher in the throat and the injured part is cloven asunder

Bauta

  • Bay Watcher
    • View Profile
    • My Youtube
Re: How to do a bodyswap ?
« Reply #6 on: April 29, 2017, 03:09:56 pm »

Do i need to install a different programm apart from DFHack ?
Is there an easy manual on how to use the adv tools ?
Logged
_________
>Blacki loses his right arm, Blacki loses his left arm
>Blacki: I am badly injured, this phases me not
>Blacki bites the Goblin lasher in the throat and the injured part is cloven asunder