I have recently discovered quite a problem. I designed a routine in CS which works flawlessly for the player but for AI it does not work because (according to log and testing) the CS is processed differently for AI factions.
Simplified version of what I am doing:
;;;;This is done for all factions and IDs range from 0 to 30. When settlement is captured the counter is set to the ID of faction that captured it.
monitor_event GeneralCaptureSettlement FactionType {faction}
set_counter settlement_taken {ID}
end_monitor
;;;;This monitors the change of the above counter and then it does stuff.
monitor_conditions I_CompareCounter settlement_taken < 31
;;;;Series of if checking what faction triggered the change and then do stuff to it.
if I_CompareCounter settlement_taken = {ID}
;;;;I know there is no counter = counter, this is just simplification of lengthy procedure of translating one counter into another. It works, that is not the problem.
(set_counter {settlement_ownership_counter} = settlement_taken)
end_if
end_monitor
Now this works nicely for the player but for the AI the monitor_conditions is NOT triggered right after the change of the counter for some reason.
Instead AI turn processes all GeneralCaptureSettlement events and assign correct values based on the factions but it does not trigger the monitor_conditions as well. That is wrong because I need to translate each change into another counter (for which I assumed one monitor_conditions should work). In practice when there are more than one settlement take per turn it takes the value of the last faction which took a settlement and applies it to all such events (ownership is wrong).
Example:
Faction 'england' (7) takes settlement A and the 'settlement_taken' counter is then changed to 7. It does not trigger the monitor_conditions however so the counter 'A_ownership' is not set to anything yet. In the same turn faction 'france' (8) takes settlement B and the 'settlement_taken' counter is overwritten and set to 8. Then, by the end of the turn, monitor_conditions finally triggers and set the ownership of both A and B to 8 (france) instead.
I have no idea why it is happening like this but log says it does exactly happen like this. It shows several counter changes right after each other according to settlements being sieged out in that turn but only the last one actually triggers the monitor_conditions.
Again, for player this works fine and monitor_conditions fires right after the counter changes after the settlement fell. But why it does not work the same for the AI??
My question thus is how to possibly solve this? Employ campaign_wait or something? Am I missing something? This behaviour is completely idiotic and would not make sense in any programming language I know!
Thanks in advance, this is a really hard nut to crack for me.
Addendum, here is the excerpt from the log which clearly shows that the counter did change correctly but it did not trigger the monitor_conditions:
Code:08:52:42.576 [game.script.trigger] [trace] Trigger <0052_T_Invaded_Settlement> fired 08:52:42.576 [data.transgression] [info] Applied transgression TC_INVADED_SETTLEMENT from transgressor faction 1056D1E4 against faction 1056E5F2 08:52:42.588 [game.script.exec] [trace] exec <set_counter> at line 3960 in mods/DotS/data/world/maps/campaign/imperial_campaign/campaign_script.txt 08:52:42.588 [game.script.counter] [trace] counter <settlement_taken> = 8 08:52:42.600 [game.script.trigger] [trace] Trigger <0052_T_Invaded_Settlement> fired 08:52:42.600 [data.transgression] [info] Applied transgression TC_INVADED_SETTLEMENT from transgressor faction 10549DEC against faction 1056E5F2 08:52:42.608 [game.script.exec] [trace] exec <set_counter> at line 3956 in mods/DotS/data/world/maps/campaign/imperial_campaign/campaign_script.txt 08:52:42.608 [game.script.counter] [trace] counter <settlement_taken> = 7 08:52:42.609 [game.script.trigger] [trace] Trigger <0052_T_Invaded_Settlement> fired 08:52:42.609 [data.transgression] [info] Applied transgression TC_INVADED_SETTLEMENT from transgressor faction 1056D0CE against faction 1056E5F2 08:52:42.646 [game.script.exec] [trace] exec <set_counter> at line 4000 in mods/DotS/data/world/maps/campaign/imperial_campaign/campaign_script.txt 08:52:42.647 [game.script.counter] [trace] counter <settlement_taken> = 18





Reply With Quote






