oh yeah what I did to get fights to start in the old versions was getting both attacker and defender to target each other.
which usually cause them to continue on now that they took some damage.
usually when you set it to 1 person there's a chance the character cancels the attack because why provoke an attack on someone you know isn't aiming to hurt you.
but getting this to work for companions or optimize it for say adventure mode tomfoolery was a pain.
Target={}
function getxyz() -- this will return pointers x,y and z coordinates.
local x=df.global.cursor.x
local y=df.global.cursor.y
local z=df.global.cursor.z
return x,y,z -- return the coords
end
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
if unit==nil then
adv=df.global.world.units.active[0]
for k,v in pairs(df.global.world.units.active) do
if v.relations.group_leader_id==adv.id then
if v== nil then
error("Invalid creature")
end
--entry=dfhack.lineedit()
targ=getCreatureAtPos(getxyz())
v.opponent.unit_id=targ.id
v.opponent.unit_pos.x=getxyz()
v.opponent.unit_pos.y=getxyz()
v.opponent.unit_pos.z=getxyz()
targ.job.hunt_target=v
end
end
end
this was kinda the jist of it but the bottom part is the stuff you want to poke around the opponent unit_position and unit_id get both of those working and you got a fight.