Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2 3 ... 8

Author Topic: [DFHack] modtools/create-unit (version 0.4) (beta)  (Read 30828 times)

expwnent

  • Bay Watcher
    • View Profile
[DFHack] modtools/create-unit (version 0.4) (beta)
« on: July 22, 2015, 09:34:37 am »

This is a beta version. Use at your own risk.

https://github.com/expwnent/dfhack/blob/create-unit/scripts/teleport.lua
https://github.com/expwnent/dfhack/blob/create-unit/scripts/modtools/create-item.lua
https://github.com/expwnent/dfhack/blob/create-unit/scripts/modtools/create-unit.lua
https://github.com/expwnent/dfhack/blob/create-unit/scripts/modtools/equip-item.lua

Install teleport to hack/scripts and install the rest to hack/scripts/modtools. Overwrite old versions with the new ones.

Please test thoroughly and post results here.

Notes:

1. Created units are naked. I will make a separate script for managing equipment later. Currently implemented. See modtools/equip-item.lua.

2. If you try to make a tame hydra in vanilla you're going to have "fun". Tame dogs seem to work fine. I'm not sure whether you're supposed to add tame animals to your civ / group or not. Test it and let me know so I can document it. If you use -flagClear [ resident ] then it should work on megabeasts.

3. Invaders probably won't work properly because that requires creating a new invasion id and a few other things. I'll make a separate script for managing custom invasions later.

4. Once this script has been beta tested I will do my best to maintain backwards compatibility, but I make no promises until then.

5. I wasn't sure what unit flags to set for different circumstances so I let the user manually specify the flags. See here for the flags you can set. You can also clear flags if DF automatically sets them and you don't want it to.

6. Units are not named (in any useful way) by this script. Sometimes they're named something like "Dwarf -13568432", which doesn't seem to cause any other problems but it is strange and I'm not sure why it happens. As of version 0.2, use the "-name" argument to give the unit a random civilization-appropriate name. Use "-name MOUNTAIN" for dwarf names, "-name EVIL" for goblin names, etc.

7. Units may be placed in surprising places. Use the loo(k) mode to control it manually for now. You can specify location with the "-location" argument.

Examples:

Code: [Select]
modtools/create-unit -race DWARF -caste MALE -civ_id \\LOCAL -group_id \\LOCAL
modtools/create-unit -race DWARF -caste FEMALE -civ_id \\LOCAL -group_id \\LOCAL
modtools/create-unit -race HYDRA -caste FEMALE
modtools/create-unit -race DOG caste FEMALE -civ_id \\LOCAL -group-id \\LOCAL -domesticate
modtools/create-unit -race DWARF -caste MALE -civ_id \\LOCAL -group_id \\LOCAL -flagSet [ had_mood vision_good compute_health ]
modtools/create-unit -race DWARF -caste MALE -civ_id \\LOCAL -group_id \\LOCAL -name
« Last Edit: July 27, 2015, 08:05:23 am by expwnent »
Logged

Roses

  • Bay Watcher
    • View Profile
Re: [DFHack] modtools/create-unit (version 0.1) (beta)
« Reply #1 on: July 22, 2015, 10:18:16 am »

Awesome! I will definitely test this out.
Logged

expwnent

  • Bay Watcher
    • View Profile
Re: [DFHack] modtools/create-unit (version 0.1) (beta)
« Reply #2 on: July 22, 2015, 10:19:03 am »

Thanks!

PS: It should also be compatible with script_environment if you want to try more advanced features.
Logged

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: [DFHack] modtools/create-unit (version 0.1) (beta)
« Reply #3 on: July 22, 2015, 10:21:38 am »

ptw

(Quick work, I'm impressed)
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

Roses

  • Bay Watcher
    • View Profile
Re: [DFHack] modtools/create-unit (version 0.1) (beta)
« Reply #4 on: July 22, 2015, 10:57:08 am »

Thanks!

PS: It should also be compatible with script_environment if you want to try more advanced features.

Ooh, good call. Can definitely think of some fun things that could be done. Here are a couple questions to start;

  • Are creatures that are created properly randomized? For instance if I make 2 dwarf males, will they have different attributes/appearance/traits/etc... ?
  • Is name generation something you plan on adding to the script?
  • For spawning domesticated animals, have you thought about adding trained values and/or pet status? (Which could both be done in a seperate script quite easily, but don't want to write something up if you were planning on adding it as a functionality)
  • Do you have plans of allowing a location to be specified?
Logged

expwnent

  • Bay Watcher
    • View Profile
Re: [DFHack] modtools/create-unit (version 0.1) (beta)
« Reply #5 on: July 22, 2015, 11:12:10 am »

I plan on doing all of that. Randomization should already be in, but I didn't check.
Logged

lethosor

  • Bay Watcher
    • View Profile
Re: [DFHack] modtools/create-unit (version 0.1) (beta)
« Reply #6 on: July 22, 2015, 11:51:20 am »

It would be nice to have a user-friendly wrapper like the old spawn-unit script (e.g. treating the first two script arguments as race and caste, and possibly passing the rest directly to modtools/create-unit).
The weird numbers in unit names are probably due to the value(s) used in unit names in arena mode not being initialized.
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.

Vattic

  • Bay Watcher
  • bibo ergo sum
    • View Profile
Re: [DFHack] modtools/create-unit (version 0.1) (beta)
« Reply #7 on: July 22, 2015, 02:35:01 pm »

PTW.

Look forward to seeing where this goes.
Logged
6 out of 7 dwarves aren't Happy.
How To Generate Small Islands

expwnent

  • Bay Watcher
    • View Profile
Re: [DFHack] modtools/create-unit (version 0.1) (beta)
« Reply #8 on: July 22, 2015, 03:36:45 pm »

I can't upload it at the moment, but I implemented random appropriate naming. Next up is equipment management, followed by invasion management.
Logged

Dirst

  • Bay Watcher
  • [EASILY_DISTRA
    • View Profile
Re: [DFHack] modtools/create-unit (version 0.1) (beta)
« Reply #9 on: July 22, 2015, 03:53:03 pm »

Nice work.  I can't test this at the moment, but I have two questions based on what I see in the code:

1. Wouldn't \\LOCAL be passed to the script as \LOCAL?  Never mind.  The \\LOCAL in the code is passed to Lua as \LOCAL, just like the \\LOCAL from the command is.  It will work fine as written.

2. I assume the arena-mode stuff handles the unit's birth year and such... but what if we want to control that?  For my purposes (and Taldarus in the other thread) the age ought to be exactly zero.  Can we safely overwrite the birth_year and such inside arena mode?  An -age parameter would make this script more useful, even if it has to be restricted to adult ages.
« Last Edit: July 22, 2015, 03:57:35 pm 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

lethosor

  • Bay Watcher
    • View Profile
Re: [DFHack] modtools/create-unit (version 0.1) (beta)
« Reply #10 on: July 22, 2015, 04:19:09 pm »

I'm a little confused about what you're saying about backslashes, unless you mean that the commands expwnent listed should be passed as strings to dfhack.run_command or dfhack.run_script:
Code: [Select]
[DFHack]# devel/print-args \LOCAL
\LOCAL
[DFHack]# devel/print-args \\LOCAL
\\LOCAL
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] modtools/create-unit (version 0.1) (beta)
« Reply #11 on: July 22, 2015, 04:24:40 pm »

Dirst: that's quite reasonable. I'll have to be careful it computes size correctly for different ages because that's important for combat. I probably won't bother making things like hair length be age appropriate unless someone really wants it.
Logged

expwnent

  • Bay Watcher
    • View Profile
Re: [DFHack] modtools/create-unit (version 0.1) (beta)
« Reply #12 on: July 22, 2015, 04:28:07 pm »

I'm a little confused about what you're saying about backslashes, unless you mean that the commands expwnent listed should be passed as strings to dfhack.run_command or dfhack.run_script:
Code: [Select]
[DFHack]# devel/print-args \LOCAL
\LOCAL
[DFHack]# devel/print-args \\LOCAL
\\LOCAL

Keep in mind that the arguments get passed through processArgs, which will eat one of the backslashes. This is necessary, otherwise it would be impossible to pass negative numbers as values to named arguments.
« Last Edit: July 22, 2015, 04:51:43 pm by expwnent »
Logged

expwnent

  • Bay Watcher
    • View Profile
Re: [DFHack] modtools/create-unit (version 0.1) (beta)
« Reply #14 on: July 22, 2015, 05:22:55 pm »

What is the extra viewscreen_dwarfmodest for?

That makes it so that it works even if the current viewscreen is something else.
Logged
Pages: [1] 2 3 ... 8