How to add a unique troop to a specific castle?

Users who are viewing this thread

Hello, I had an idea to my mod and it would be add a unique troop to a specific castle and make it so that only the owner of the castle can recruit them. For example, Ibelin castle is part of Kingdom of Jerusalem and I want to attach Ibelin Knights to be recruitable only there (they aren't part of any troop tree) and only the owner of the castle can recruit them (not the faction but only the owner himself). Like the player can only recruit them if he owns the castle. Is there an easy way to do this? Thanks in advance.
 
This is somewhat easy and also fairly complicated, it will require a lot of work on your end, unless you've seen it done in another mod already than you could ask to borrow their code.
You have to find the scripts/strings/dialogs/constants/ect for recruiting from castles and custom faction recruits and make scripts so instead of a range of villages like it is normally, only that specific location will have the troop available.

Getting NPCs to recruit the troop will be dificult because NPCs don't actually recruit troops, they just get gifted units by the system depending on how their faction is setup.

Like this is a script for recruiting custom troops from villages the player's faction owns: http://forums.taleworlds.com/index.php/topic,111689.0.html

Basically, you have to learn how troops are recruited currently, copy those scripts, make adjustments to the values to instead of looking at a range of items like castles/villages/towns and which specific faction to offer troops from, to a specific location, and a specific troop.

And then find a script that makes it so only the owner can recruit them.
 
Thanks, yeah it seems too much work for such a small feature, not sure if it's worth the work since is just more a flavour thing, well thanks!
 
There's a workaround possible if you want only the player to recruit these special troops. Two ways you can do it, one is to set up a dialogue with the castellan, or make it part of the castle menu.

If it's part of the castle menu, you add a menu that checks if this castle is Ibelin Castle, and only shows the menu if it is.
 
Yep, it's not difficult. The warband recruitment code is overly complicated and you could quite easily add you own that's not related to it.

Just add a submenu option in mnu_town that checks that $current_town is the castle you're looking for, and sends the player to another new menu which allows them to buy troops or leave the menu.

For the actual recruitment, you'll need a global variable (if it's one castle), or a party_slot (if it's more than one), which will increase by a certain amount every few days or weeks (use a simple_trigger). This value will decrease when the player recruits troops, and thus represent the number of men available.
 
It would be fairly easy to do for both ai and the player, for ai see below

Chuck this in module triggers

Code:
    (24*7, 0, 0, [],
    [
        (try_for_range, ":town", towns_begin, towns_end),
             (eq,":town",YOUR CASTLE HERE)
             (party_get_slot, ":lord_troop", ":town", slot_town_lord),
             (troop_get_slot, ":lords_party", ":lord_troop", slot_troop_leaded_party),
             (party_add_members,  ":lords_party", YOUR TROOP HERE, THE NUMBER YOU WANT TO ADD),
        (try_end),
    ]),
This will add troops to the castles owner once a week

For the player its just as easy, you would simply have a game menu option which checked the current castle was the right one and then give the option to recruit troops if the player has enough gold.

Note I havent tested any of the above so it may not work straight away but it should at least point you in the right direction
 
Grandmasters code will work but the AI ideal party size has a pruning feature which removes non-kingdom troops (iirc) so if they go above the ideal size limit the new troops will likely get taken out first. Shouldn't be too hard to make the exceptions in the kingdom recruit script. As for the player, just use game menus as stated above. You'll have to put in a check to make sure it is non-player if you add La Grandmaster's trigger, or the player will get the troops automatically (which if they're at full party size already might cause issues.)
 
Back
Top Bottom