Hello everyone,
due my recent work on IND to develop a title based recruitment system, I thought some of you might be interested in my results
Object: Our object is to restrict the recruitment of units and bind it to a certain title of a family member or for example the title "Prince of Galiläa". Nowhere else, but at his own manor (Tiberias) the "Prince of Galiläa" should be able to recruit decent units, for example feudal spearmen. To make the story short, if the prince is at Jaffa, he won't be able to recruit any of his own men, but in Tiberias. (is it Tiberia or Tiberias?? )
How: How are we going to accomplish that? Well, we will create two hidden traits, which trigger as soon as the prince is inside the city of Tiberias or just left the city. Additional, we will run two monitors. These monitors will check if our prince is in the field or in the city and activate the recruit_pool accordingly.
What:What do we need?These files:
- campaign_script
- EDB
- export_descr_character_traits
- export_descr_ancillaries
1. Step:
To create a new anc is our first step. How to create a new anc in detail won't be explained in this tutorial. The only important thing to know is that you have to create a new Type for your anc.
My code:
I chose Type NobleTiberias. We need that later on and of course you have to add a trigger, as well. The details are up to youCode:;------------------------------------------ Ancillary titel_tiberias Type NobleTiberias Transferable 0 Image sex_yangman.tga Description titel_tiberias_desc EffectsDescription titel_tiberias_effects_desc Effect Loyalty -1
2. Step:
Now more fancy stuff. Open the export_descr_character_traits file and create two new trait entries.
Note: Define these traits as hidden, so they won't show up during the campaign. Of course it's not mandatory, but it looks better
As I already told you at the beginning, the traits serve us to check if our prince is in the field or in his city or any other city. Of course the recruit_pool should only be activated, when our prince is inside the city.
That is why we need two traits. One to represent the case that the prince is at Tiberias (AtTiberias) and the other to represent the prince while he is not at Tiberias (NotAtTiberias).
We do not need any effects, because we only use these traits to represent two situations.Code:;------------------------------------------ Trait NotAtTiberias Characters family Hidden Level StaysNotAtTiberias Description StaysNotAtTiberias EffectsDescription StaysNotAtTiberias_effects_desc Threshold 1 ;------------------------------------------ Trait AtTiberias Characters family Hidden Level StaysAtTiberias Description StaysAtTiberias_desc EffectsDescription StaysAtTiberias_effects_desc Threshold 1
3. Step:
That is the tricky part. Our triggers shall only be triggered, when either our prince is at "home" or not. After some trail and error I come up to this code, of course it is not perfect, so feel more than free to make any suggestions!
Trigger 1:
The use of the first trigger is to check if the prince is in the city at the end of his turn. To prevent that we get the wrong character or city, we set conditions, that is why we need a new type, HasAncType NobleTiberias and SettlementName Tiberias.Code:;------------------------------------------ Trigger StayedAtTiberias01 WhenToTest CharacterTurnEnd Condition IsGeneral and HasAncType NobleTiberias and EndedInSettlement and SettlementName Tiberias Affects AtTiberias 1 Chance 100 Affects NotAtTiberias -1 Chance 100
EndedInSettlement is used to check if the character has ended his turn inside a city.
In case all of our conditions are met, our prince obviously have to be inside the city of Tiberias, as a consequence:
Affects AtTiberias 1 Chance 100, our prince gets the trait, (AtTiberias). He is inside the city.
To prevent other potential problems, we create a trigger which triggers in case our prince stays in the field.
Trigger 2:
The second trigger is quite the opposite of the previous one. In case our prince is in the field he gets the trait NotAtTiberias.Code:;------------------------------------------ Trigger StayedNotAtTiberias01 WhenToTest CharacterTurnEnd Condition IsGeneral and HasAncType NobleTiberias and not EndedInSettlement Affects AtTiberias -1 Chance 100 Affects NotAtTiberias 1 Chance 100
If our prince is Not EndedInSettlement, so is he in no city at all.
Trigger 3:
This one is the exact negation of our first trigger. He checks if our prince has ended up in another city, not Tiberias.Code:;------------------------------------------ Trigger StayedNotAtTiberias03 WhenToTest CharacterTurnEnd Condition IsGeneral and HasAncType NobleTiberias and EndedInSettlement and not SettlementName Tiberias Affects AtTiberias -1 Chance 100 Affects NotAtTiberias 1 Chance 100
Trigger 4:
I have just found a way to exchange the traits, when our prince just left the city.
Code:;------------------------------------------ Trigger StayedAtTiberias02 WhenToTest CharacterSelected Condition IsGeneral and RemainingMPPercentage < 100 and HasAncType NobleTiberias and Trait AtTiberias > 0 Affects AtTiberias -1 Chance 100 Affects NotAtTiberias 1 Chance 100
In case our general has moved (Remaining MPPercentage < 100) and has the trait "AtTiberias", he is probably outside the city, so we give him the trait "NotAtTiberias". Our problem is now, when our prince returns back into the city, we have to wait until next turn.
Yet I haven't found any condition, which checks the current position of a character, if somebody have an idea, please let me know!
4. Step:
Almost done, now open your campaign_script and EDB.
First, campaign_script. Two monitors need to be scripted. These check the current position of our prince, using our previously created traits. This is the code:
At the beginning of each turn of Jerusalem, our prince will be checked if he has the trait AtTiberias. If he has the trait, he is in Tiberias and not somewhere else. As a consequence, trait NotAtTiberias < 1, means 0.Code:;Tiberias monitor_event CharacterTurnStart FactionIsLocal and FactionType jerusalem and Trait AtTiberias = 1 and Trait NotAtTiberias < 1 set_event_counter ruler_tiberias 1 if I_EventCounter ruler_tiberias > 0 and I_EventCounter pool_tiberias < 1 set_recruit_pool Tiberias_Region 4 Feudal Spearmen set_event_counter pool_tiberias 1 end_if end_monitor
Now we set up an event counter, which we need later on in the EDU. But first we have to solve a problem of the EDU file. Our problem is we can not set an initial value to the number of units available as soon as the pool is activated, like in the descr_mercenaries. To remedy this, we use the command "set_recruit_pool" and hussaaa our problem is solved
Otherwise you would have to wait the numbers of turns, which you have set up in the EDU for the respective recruit_pool. (Not exactly turn numbers, but points)
Our parameters are:
- Province: Tiberias_Region (descr_regions)
- Number of units: 4 (depends on how many units you would like to have in your recruit_pool)
- Unit: Feudal Spearmen
Well, I have included an control counter, as well, even if I am not sure if it is necessary..
Alright, next step EDB.
Chose a building where you'd like to recruit your desired unit. I chose town_watch.
Now, add a new recruit_pool for your unit.
Now we need our previously created, ruler_tiberias 1. We use it to switch the recruit_pool on and off, depending on the position of our prince.Code:recruit_pool "Feudal Spearmen" 1 0.15 4 0 requires factions { jerusalem, } and event_counter ruler_tiberias 1
One last step!
5. Step:
To prevent other generals from using this recruit_pool, we have to check once more, if you prince is inside the city. Is he not, the pool has to be deactivated.
If our prince is not inside Tiberias, this monitor sets the event counters back to their basic values. Accordingly, our recruit_pool gets deactivated, as well as, our control counter.Code:monitor_event CharacterTurnStart FactionIsLocal and FactionType jerusalem and Trait NotAtTiberias = 1 and Trait AtTiberias < 1 set_event_counter ruler_tiberias 0 set_event_counter pool_tiberias 0 end_monitor
That's it!
Note:
This is script is far from being complete, for example I haven't tested yet what happen if your adding more units than you have defined as your max value in the EDU. Also, I have no clue, if the maximal number of units, defined for your recruit pool, is correctly calculated, since you fill up the pool again and again.
Anyway, happy modding!
Best regards,
Ned