Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Minor mod: hire guard  (Read 4984 times)

Kurik Amudnil

  • Bay Watcher
    • View Profile
Minor mod: hire guard
« on: June 25, 2013, 03:43:58 pm »

I was asked if it would be possible to hire/bribe/convert caravan guards with a reaction and this is what I put together: DFFD Hire Guard.

Since units of a race other than the fort's race don't grab their own labors, I exclude guards of caravans from other races.

hack/scripts/hire-guard.lua
   *   Registers all reactions that begin with LUA_HOOK_HIRE_GUARD

hack/lua/fov.lua
   *   An include file for calculating a 2d circular shadow cast field of view around the unit performing the reaction.

hack/lua/makeown.lua
   *   An include porting a bit of tweak makeown and my fix for making those units (if they are of the same race) full fort members by creating a historical figure, a nemesis entry, and the associated events of migration as needed.

hack/raw/reaction_hire_guard.txt
   *   A sample reaction

hack/raw/building_hire_guard.txt
   *   A sample workshop to hold the reaction, nothing special

copy the reaction_hire_guard.txt and building_hire_guard.txt from hack/raw to raw/objects or create your own, then generate a new world.


Reaction Product field must exist, I suggest using quantity 0 because it doesn't need to actually produce anything. And won't produce any items if the script hooks the reaction properly.

Product dimension determines sight radius in a circle with shadow cast visibility (defaults to 10 if less than 1 or not present) .

product probability + effective skill level of the reaction skill determines chance to convert each valid in range target, limit 1. If the first found target fails, the second found target has the same chance etc. If all fail, reagents are consumed as normal (respects PRESERVE_REAGENTS if present).  Does not currently modify chance of success based on the other social skills

if no valid targets in range are found, forces PRESERVE_REAGENTS.

Announcements:

success: "{guard name} has joined our cause!" in bright green

no targets: "{Worker Name}, {Worker Profession} cancels {reaction name}: No visible targets in range." in yellow

failed: "{Reaction name} failed." in dark red


Thank you to Meph for the idea.  It gave me the opportunity to learn a bunch about plugin.eventful's api, map blocks, tiletypes, and some stuff about reactions.
« Last Edit: June 25, 2013, 06:09:22 pm by Kurik Amudnil »
Logged

Iceblaster

  • Bay Watcher
  • Now with 50% less in-jokes!
    • View Profile
Re: Minor mod: hire guard
« Reply #1 on: June 25, 2013, 04:36:45 pm »

Very interesting. This could help forts that enforce a certain rule about military training(I.E Only training from a skilled commander allowed)

Boltgun

  • Bay Watcher
  • [UTTERANCES]
    • View Profile
Re: Minor mod: hire guard
« Reply #2 on: June 26, 2013, 01:19:03 am »

I like the makeown script, may I use it in the succubi mod ?
Logged

Kurik Amudnil

  • Bay Watcher
    • View Profile
Re: Minor mod: hire guard
« Reply #3 on: June 26, 2013, 02:19:01 am »

I like the makeown script, may I use it in the succubi mod ?

Absolutely.  I made it an include (put in hack/lua) so that it would be easier for other mods / scripts to use.

However, I am of two minds on the subject of using it as hack/lua/makeown.lua or hack/lua/plugins/tweak.lua. 

hack/lua/plugins/tweak.lua would integrate with the tweak plugin (the original source of makeown) if/when it exports an api.
and have the scripts that use it require 'plugins.tweak'.  I need to talk to the dfhack folks about that, which means that I make some changes to it.







to include hack/lua/tweak.lua, use

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: Minor mod: hire guard
« Reply #4 on: June 26, 2013, 02:39:14 am »

Nice. :) I will certainly include it in MasterworkDF, for the dwarf mode embassy/tavern. Kobolds have no caravan guards, but I will let smake know that it exists, maybe he likes it for the orcs as well. :)

Some day I have to make a thread to collect all non-official dfhack scripts, post some readmes and screenshots and sort it all.

I just asked falconne about a possible info overlay for items. Similar to your unit-viewer, but for weapons, armor and such. I somehow thought of him first, but maybe you guys can talk about it. I think your code might already have the baselines worked out, it would be silly if falconne starts from scratch.
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 :::

smakemupagus

  • Bay Watcher
  • [CANOPENDOORS]
    • View Profile
Re: Minor mod: hire guard
« Reply #5 on: June 26, 2013, 12:43:30 pm »

Very cool!  Thanks Kurik :D

I see that it calls a dfhack conditional "dfhack.units.isDwarf(u)".

>> dfhack.units.isDwarf(unit)
>> The unit is of the correct race of the fortress.

It sounds like despite the name, it doesn't actually looks for Dwarfs specifically, and should work too without tweaks for my non-Dwarven citizens.  Am I understanding that right?

I will try it out and let you know how it works :)

« Last Edit: June 26, 2013, 12:55:44 pm by smakemupagus »
Logged

Kurik Amudnil

  • Bay Watcher
    • View Profile
Re: Minor mod: hire guard
« Reply #6 on: June 26, 2013, 01:17:10 pm »

correct, dfhack.isDwarf(unit) == is fort race or unit.race == df.global.ui.race_id == df.global.ui.main.fortress_entity.race
« Last Edit: June 26, 2013, 03:13:21 pm by Kurik Amudnil »
Logged

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: Minor mod: hire guard
« Reply #7 on: June 28, 2013, 12:25:00 am »

I just wanted to add a bit of information:

The included raw uses SKILL:TANNER, because tanner skill has been replaced by diplomacy/ambassador in MasterworkDF. I also added this reaction to my embassy. :)

And I reduced the price to 5000 gold coins. 10000 does not feel too much, but the hauling time is rather long. 20 stacks worth of money...
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 :::

Kurik Amudnil

  • Bay Watcher
    • View Profile
Re: Minor mod: hire guard
« Reply #8 on: June 28, 2013, 01:21:31 am »

I have noticed that by hooking the reaction complete event, there is no experience gain for completing the job/reaction.  I could use some more info in how experience gain rates from the raws affect how much experience should be gained by successfully completing a reaction with that skill.  I don't expect hire guard to happen very often but I think it should give some experience.  It might also be nice to include some of the social skills like persuade, and attribute linguistic ability.

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: Minor mod: hire guard
« Reply #9 on: June 28, 2013, 01:38:23 am »

Reactions usually only raise skills with a labor attached to them, because the social skills cant be controlled ingame. If you make a reaction use... lets say coordination, then ANY dwarf that is idle might take it up. It makes at quite hard to control your dwarves that way.

Making one item, with a 100% skill learn rate gives 30xp in vanilla DF. I offer an optional setting with 50% skill lean rate, of course that would make it 15xp. The skill rate is linked to the amount of items that are created. 10 items? 300xp. 5000 items? Legendary skill, there you go. ;)

I also run the reaction without a valid target nearby, and the gold disappeared. Your readme indicates that it should be preserved, but it is not.
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 :::

Kurik Amudnil

  • Bay Watcher
    • View Profile
Re: Minor mod: hire guard
« Reply #10 on: June 28, 2013, 03:24:05 am »

If you got the announcement "... No visible targets in range." then it should have preserved the coins.  If you got the announcement "... failed." then it found a valid target and failed, consuming the reagents.  My quick test shows it to be working as intended so we may need more testing on that, please double check which announcement you received and do some more tests.

I think I might want to change the "...no targets" announcement because it is too long and has to word wrap.

As for the skills, I am not referring to changing the skill on the reaction but incorporating more than the reaction skill in the script's processing of the probability and experience improvements so that yes it uses and improves the diplomacy skill, but also uses/improves persuasion, linguistic ability, and any other skill or attribute that is related to the task.

Edit:  I haven't looked at newly arrived migrants to see what their flags are, is it possible you had some new migrants passing by when the reaction completed?  If so then maybe I need to add to the selection criteria.
« Last Edit: June 28, 2013, 03:38:55 am by Kurik Amudnil »
Logged

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: Minor mod: hire guard
« Reply #11 on: June 28, 2013, 04:16:21 am »

"... No visible targets in range." => "... no guard in range."

I will do more tests, but I run it with the original 7 and no caravan on the map.
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 :::