Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 200 201 [202] 203 204 ... 360

Author Topic: DFHack 0.43.03-r1  (Read 1123569 times)

Dirst

  • Bay Watcher
  • [EASILY_DISTRA
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #3015 on: August 24, 2015, 11:06:36 am »

Anyone know what happens when you try and use the function dfhack.items.createItem() without a creator? Can't run DF right now so can't check myself. If it crashes, is there anyway to make it so that it doesn't crash?
Either it crashes or it does not work at all (i.e. emits an error message).
This is because it uses df own functions (namely reaction products IIRC) and it needs unit for it to work. You can make your own createItem for subset of items (e.g. I did one for heart tearing out script, just because these reactions do not support body parts). For a general use case it would be lot's of work...

Good to know. I suppose it would be possible to select a random creator and then set the created_by flag (or whatever it is called) to -1. I actually don't think it is a big deal as I will almost always have a creator, was just wondering what would happen if I didn't.
Are you limited to the IDs of creatures actively on the map?  Deities have historical figure IDs ;)
Logged
Just got back, updating:
(0.42 & 0.43) The Earth Strikes Back! v2.15 - Pay attention...  It's a mine!  It's-a not yours!
(0.42 & 0.43) Appearance Tweaks v1.03 - Tease those hippies about their pointy ears.
(0.42 & 0.43) Accessibility Utility v1.04 - Console tools to navigate the map

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #3016 on: August 24, 2015, 11:58:39 am »

The created_by id can be -1. It's -1 for all items that are pre-history. Df says it's "by unknown author".

lethosor

  • Bay Watcher
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #3017 on: August 24, 2015, 01:38:18 pm »

Anyone know what happens when you try and use the function dfhack.items.createItem() without a creator? Can't run DF right now so can't check myself. If it crashes, is there anyway to make it so that it doesn't crash?
Currently, passing a nil unit will crash, but that's fixed in the next release.
Logged
DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

There was a typo in the siegers' campfire code. When the fires went out, so did the game.

expwnent

  • Bay Watcher
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #3018 on: August 24, 2015, 09:14:03 pm »

Anyone know what happens when you try and use the function dfhack.items.createItem() without a creator? Can't run DF right now so can't check myself. If it crashes, is there anyway to make it so that it doesn't crash?
Currently, passing a nil unit will crash, but that's fixed in the next release.

In the current version you can still just pick anybody as the fake creator then go into the item and delete the creator by setting the id to -1.
Logged

lethosor

  • Bay Watcher
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #3019 on: August 24, 2015, 09:23:35 pm »

Exactly (actually, that fix only addresses the crash - passing a null unit from now on will produce an error instead). I think df.global.world.units.all[0] should work as a creator, although replacing "all" with "active" could avoid issues that I'm not aware of with dead/off-map units.

Edit: Creating a fake unit with df.unit:new() and setting its position to arbitrary coordinates appears to work. I don't know if any information about the creator is tracked by DF or not, though. Using an off-map unit will not work, however, as DFHack makes sure units' positions are valid, so you'd need to use world.units.active[0] otherwise (and make sure its position is valid).
« Last Edit: August 24, 2015, 09:34:32 pm by lethosor »
Logged
DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

There was a typo in the siegers' campfire code. When the fires went out, so did the game.

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #3020 on: August 25, 2015, 02:53:52 am »

Hmmm, just make sure it doesn't cross into adventurer mode, no clue what it would do with one active, hopefully it would just assign it as the creator though.
Logged

Dirst

  • Bay Watcher
  • [EASILY_DISTRA
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #3021 on: August 31, 2015, 07:13:49 am »

Hey all, I'm trying to get spawned creatures to do something other than wander, and the logical thing seemed to be to induce them to attack the dwarf that triggered the spawn (unless mod logic says the creature should be friendly, of course).

I tried populating

critter.opponent.unit_id=15250
critter.opponent.unit_pos={118,67,178}
critter.anon_1=300


based on what I've seen hunters and prey do.  The id and position are for the miner.  But the creature still wanders off and the anon_1 was 265 the next time I checked.  It stayed at 300 for hunters and prey.  It's apparently a count-down for how long a unit stays interested in its opponent, and there must be some other attributes I'm missing to start a fight.

Has anyone scienced this out?
Logged
Just got back, updating:
(0.42 & 0.43) The Earth Strikes Back! v2.15 - Pay attention...  It's a mine!  It's-a not yours!
(0.42 & 0.43) Appearance Tweaks v1.03 - Tease those hippies about their pointy ears.
(0.42 & 0.43) Accessibility Utility v1.04 - Console tools to navigate the map

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #3022 on: August 31, 2015, 07:58:21 am »

Hey all, I'm trying to get spawned creatures to do something other than wander, and the logical thing seemed to be to induce them to attack the dwarf that triggered the spawn (unless mod logic says the creature should be friendly, of course).

I tried populating

critter.opponent.unit_id=15250
critter.opponent.unit_pos={118,67,178}
critter.anon_1=300


based on what I've seen hunters and prey do.  The id and position are for the miner.  But the creature still wanders off and the anon_1 was 265 the next time I checked.  It stayed at 300 for hunters and prey.  It's apparently a count-down for how long a unit stays interested in its opponent, and there must be some other attributes I'm missing to start a fight.

Has anyone scienced this out?
Well obvious out of the way first: have you set civ_id to -1? If so then maybe adding an attack action? Also setting the berserk mood (or that other that badgers use?) should also work.

Dirst

  • Bay Watcher
  • [EASILY_DISTRA
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #3023 on: August 31, 2015, 08:29:24 am »

Well obvious out of the way first: have you set civ_id to -1? If so then maybe adding an attack action? Also setting the berserk mood (or that other that badgers use?) should also work.
Yes, its was civ -1.  Hunter's prey that fought back didn't have an invader ID, so that can't be necessary to fight.  Hunters and prey also maintain mood -1, but it's worth checking for berserk or something.  (Edit: Some prey don't fight back and their opponent remains -1, so I know I don't need to fiddle with the triggering dwarf's mind.)

I don't know how to set an attack action, but I supposed I could watch some fights in the arena then verify with hunting.  A direct attack action ought to work: if the mod triggers the spawn then the triggering dwarf and the spawned creature will be 0 or 1 tiles apart.  The player could play with the command line and spawn a creature half a map away from the triggering dwarf, but that won't crash the game or anything.

"Missed him by that much."
« Last Edit: August 31, 2015, 08:31:15 am by Dirst »
Logged
Just got back, updating:
(0.42 & 0.43) The Earth Strikes Back! v2.15 - Pay attention...  It's a mine!  It's-a not yours!
(0.42 & 0.43) Appearance Tweaks v1.03 - Tease those hippies about their pointy ears.
(0.42 & 0.43) Accessibility Utility v1.04 - Console tools to navigate the map

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #3024 on: August 31, 2015, 10:00:33 am »

Well obvious out of the way first: have you set civ_id to -1? If so then maybe adding an attack action? Also setting the berserk mood (or that other that badgers use?) should also work.
Yes, its was civ -1.  Hunter's prey that fought back didn't have an invader ID, so that can't be necessary to fight.  Hunters and prey also maintain mood -1, but it's worth checking for berserk or something.  (Edit: Some prey don't fight back and their opponent remains -1, so I know I don't need to fiddle with the triggering dwarf's mind.)

I don't know how to set an attack action, but I supposed I could watch some fights in the arena then verify with hunting.  A direct attack action ought to work: if the mod triggers the spawn then the triggering dwarf and the spawned creature will be 0 or 1 tiles apart.  The player could play with the command line and spawn a creature half a map away from the triggering dwarf, but that won't crash the game or anything.

"Missed him by that much."
The thing about hunting is that it's a job. All the "ai" depends on creature having hunting job and then it depends on ammo/weapon. Also one of main things is that jobs for non dwarves that are your civ might work and might not.

Roses

  • Bay Watcher
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #3025 on: August 31, 2015, 11:02:02 am »

Well obvious out of the way first: have you set civ_id to -1? If so then maybe adding an attack action? Also setting the berserk mood (or that other that badgers use?) should also work.
Yes, its was civ -1.  Hunter's prey that fought back didn't have an invader ID, so that can't be necessary to fight.  Hunters and prey also maintain mood -1, but it's worth checking for berserk or something.  (Edit: Some prey don't fight back and their opponent remains -1, so I know I don't need to fiddle with the triggering dwarf's mind.)

I don't know how to set an attack action, but I supposed I could watch some fights in the arena then verify with hunting.  A direct attack action ought to work: if the mod triggers the spawn then the triggering dwarf and the spawned creature will be 0 or 1 tiles apart.  The player could play with the command line and spawn a creature half a map away from the triggering dwarf, but that won't crash the game or anything.

"Missed him by that much."

I actually have a script I am working on to add attacks. Here is the rough version

Code: (unit/attack-add.lua) [Select]
function checkbodytoken(unit,token)
 local parts = {}
 local body = unit.body.body_plan.body_parts
 for i,x in ipairs(token) do
  local a = 1
  for j,y in ipairs(body) do
   if y.token == x and not unit.body.components.body_part_status[j].missing then
    parts[a] = j
    a = a + 1
   end
  end
 end
 return parts[1]
end

validArgs = validArgs or utils.invert({
 'help',
 'defender',
 'attacker',
 'target',
 'weapon',
 'velocity',
})
local args = utils.processArgs({...}, validArgs)

if args.defender and tonumber(args.defender) then -- Check for defender declaration !REQUIRED
 defender = df.unit.find(tonumber(args.defender))
else
 print('No defender selected')
 return
end
if args.attacker and tonumber(args.attacker) then -- Check for attacker declaration !REQUIRED
 attacker = df.unit.find(tonumber(args.attacker))
else
 print('No attacker selected')
 return
end
j = 0
while j < 1 do
action = df.unit_action:new()
action.id = attacker.next_action_id
attacker.next_action_id = attacker.next_action_id + 1

action.type = 1
attack = action.data.attack
attack.target_unit_id = defender.id
attack.attack_item_id = -1
attack.target_body_part_id = checkbodytoken(defender,{args.target})
attack.attack_body_part_id = checkbodytoken(attacker,{args.weapon})
attack.unk_30 = tonumber(args.velocity)
attack.attack_id = 0
attack.flags = 0

attack.unk_28 = 100
attack.unk_2c = 100
attack.unk_38 = 100
attack.unk_3c = 100
attack.timer1 = 1
attack.timer2 = 1
for i,x in pairs(attack.unk_4) do
 attack.unk_4[i] = 0
end
attack.unk_4.wrestle_type = -1
attacker.actions:insert('#',action)
j = j + 1
end

It's still extremely rough, but it should work. Just use this syntax

Code: [Select]
unit/attack-add -target UNIT_ID -attacker UNIT_ID -target BODY_TOKEN -weapon BODY_TOKEN -velocity X
Note I haven't fully tested this yet, but in arena mode I was able to add attacks just fine.
Logged

Dirst

  • Bay Watcher
  • [EASILY_DISTRA
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #3026 on: August 31, 2015, 12:05:13 pm »

Thanks Warmist and Roses.  I'll let you know how things work when I get a chance to test it.
Logged
Just got back, updating:
(0.42 & 0.43) The Earth Strikes Back! v2.15 - Pay attention...  It's a mine!  It's-a not yours!
(0.42 & 0.43) Appearance Tweaks v1.03 - Tease those hippies about their pointy ears.
(0.42 & 0.43) Accessibility Utility v1.04 - Console tools to navigate the map

Duul

  • Bay Watcher
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #3027 on: September 01, 2015, 03:37:23 am »

I'm having a bit of trouble with the add-syndrome script in modtools. I'll admit I'm a beginner at using dfhack in this way, so if I wanted to add a syndrome to turn my adventurer into a mist thrall/husk, how would I go about doing that?

I don't really care if you just tell me how to do it or give me a direct command to put into the console but I would really appreciate some help on this one.
Logged

Blind Wolf

  • Bay Watcher
  • [EXTRAVISION]
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #3028 on: September 01, 2015, 06:04:52 am »

In Adventure mode, is there any way to add an artifact from worldgen directly into my inventory or locate the item in a site?

Alternatively, is there an easier way to add secrets to a slab than by changing the topic with gm-editor? The game is heavily modded and I've had some interesting results from testing every single value one at a time, but now that I'm in the 50's it's lost its charm.
Logged

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile
Re: DFHack 0.40.24-r3
« Reply #3029 on: September 01, 2015, 07:54:22 pm »

Hello anon >.> and you can artifake one into existence. https://github.com/maxthyme/dfstuff/blob/master/artifake.lua
Logged
Pages: 1 ... 200 201 [202] 203 204 ... 360