
Originally Posted by
King Siegfried
That won't work because the Constable of Jerusalem is the KoJ's final cavalry from the King's Stables. For my purposes, it needs to come from the King's Stables, and it needs to be unique. Whether or not it exists at the start of the campaign is unimportant at this point. As long as it works, I'm fine.
Now, regarding that, I decided to just go back to the Crusades campaign's script, copy it, and have the player start the campaign with the unit. And now the script isn't working, which is really upsetting me. Why would it work in Crusades and not SS? They both use Kingdoms, do they not?
Well the Crusades script first of all uses a deprecated practice of using add_events but that won't kill the script, the script should work fine. The discrepancy is likely that they have two recruit pools, one that only turns on when there isn't an existing Constable and probably functions to bump the pool up to 1. I'd still suggest doing it via script though. Try this:
Code:
; Sets recuit pool based on whether the unit existed last turn
monitor_event FactionTurnStart FactionIsLocal
and FactionType jerusalem
if I_UnitExists jerusalem Constable of Jerusalem
set_event_counter constable 1
set_event_counter constable_existed 1
end_if
if not I_UnitExists jerusalem Constable of Jerusalem
set_event_counter constable 0
; If the constable existed last turn, we let it be recruited again
if I_EventCounter constable_existed == 1
inc_recruit_pool Jerusalem_Province -2 Constable of Jerusalem
inc_recruit_pool Jerusalem_Province 1 Constable of Jerusalem
end_if
set_event_counter constable_existed 0
end_if
end_monitor
;Resets recruit pool to 0 once it has been recruited
monitor_event UnitTrained UnitType Constable of Jerusalem
and FactionType jerusalem
and FactionIsLocal
inc_recruit_pool Jerusalem_Province -2 Constable of Jerusalem
set_event_counter constable_existed 1
set_event_counter constable 1
end_monitor
;Un-comment this line if the constable exists initially
;set_event_counter constable_existed 1
And this as the recruit pools in the EDB:
Code:
recruit_pool "Constable of Jerusalem" 0 0 1 0 requires factions { jerusalem, } and event_counter constable 0
recruit_pool "Constable of Jerusalem" 0 0.1 0.99 0 requires factions { jerusalem, } and event_counter constable 1
I haven't tested it expressly. What it should do is if the unit doesn't exist, increase the recruit pool to 1 so it can be recruited. If it does exist, say that it existed so that the next turn it can pick that up. The reason for this is while a unit is being trained it won't 'exist', so if you didn't check whether it existed last turn then it'd just keep increasing it by 1 until the unit is built. The order is also very specific in the first monitor, because if you set the constable_existed counter back to 0 before the if statement it would invalidate itself. The recruit pools are setup so that while the constable exists it increases 0.1 per turn to a max of 0.99, and when it doesn't exist the max is 1 but it doesn't get any increase as that comes from the script. If you add it to the queue and then remove it, it should add the unit back into the pool automatically since it was never made, unless I'm forgetting something.