I am slightly puzzled if 'generate_random_counter' creates a counter which I would query with 'I_CompareCounter' or an event to be queried with 'I_EventCounter'.
My money is on the latter, but I wouldn't mind some comments.
Yes. You should use 'I_EventCounter' with ‘generate_random_counter’:
Spoiler Alert, click show to read:
generate_random_counter could be used where ever you like. The counter itself IS the event_counter. It is entirely up to you as to how its used. It is simply called in the script and set to the random value. What that random value does is then left to the rest of the script.
...longbows, in skilled hands, could reach further than trebuchets...
How does this look? I used it for percentage as well, found only later the random_percentage command\condition thing.
Code:monitor_event PreFactionTurnStart FactionIsLocal generate_random_counter 3jahre 1 36 generate_random_counter prozent 1 100 end_monitor monitor_event PreFactionTurnStart FactionIsLocal and I_EventCounter 3jahre = 36 if I_EventCounter prozent < 35 spawn_character slave, random_name, witch, age 40, x 59, y 240 spawn_character slave, random_name, witch, age 40, x 112, y 319 end_if if I_EventCounter prozent > 34 and I_CompareCounter prozent < 70 spawn_character slave, random_name, witch, age 40, x 180, y 254 spawn_character slave, random_name, witch, age 40, x 180, y 395 end_if if I_EventCounter prozent > 69 spawn_character slave, random_name, witch, age 40, x 438, y 38 spawn_character slave, random_name, witch, age 40, x 447, y 72 end_if historic_event hexerei end_monitor
Maybe something like this is better:
Code:monitor_event FactionTurnStart FactionIsLocal generate_random_counter 3jahre 1 36 if I_EventCounter 3jahre = 36 generate_random_counter prozent 1 100 if I_EventCounter prozent < 35 spawn_character slave, random_name, witch, age 40, x 59, y 240 spawn_character slave, random_name, witch, age 40, x 112, y 319 end_if if I_EventCounter prozent > 34 and I_CompareCounter prozent < 70 spawn_character slave, random_name, witch, age 40, x 180, y 254 spawn_character slave, random_name, witch, age 40, x 180, y 395 end_if if I_EventCounter prozent > 69 spawn_character slave, random_name, witch, age 40, x 438, y 38 spawn_character slave, random_name, witch, age 40, x 447, y 72 end_if historic_event hexerei end_if end_monitor
Last edited by Taiji; November 16, 2011 at 12:53 PM.
The stuff was a bit out of context, there are more random counters in the first monitor which are used by about a dozen different monitors:
Code:monitor_event PreFactionTurnStart FactionIsLocal ; Zufallsnummern benutzt generate_random_counter 1jahr 1 12 ; - 12 - 11 generate_random_counter 2jahre 1 24 ; - 24 - 23 - 22 - 21 generate_random_counter 3jahre 1 36 ; - 36 - 35 - 34 - 33 - 32 - 31 generate_random_counter 5jahre 1 60 ; - 60 - 59 generate_random_counter 6jahre 1 72 ; - 72 - 71 generate_random_counter 7jahre 1 84 ; - 84 generate_random_counter 8jahre 1 96 ; - 96 generate_random_counter prozent 1 100 end_monitorCode:declare_counter bruch monitor_event PreFactionTurnStart FactionIsLocal and I_EventCounter 6jahre = 71 historic_event deiche end_monitor
The point I make is that you've no need for a second monitor, since it only differs from the first by a condition that can be used in a if statement. If this is the same in every case, then you wind up with one monitor that contains several if statements.
Also if buildings and traits are going to be affected by these event counters then you need it to run in PreFactionTurnStart, otherwise I think you'll find FactionTurnStart more efficient.
I kept the random_counter stuff in a separate monitor to better keep track which numbers I have been using (hence the numbers on the right) - one additional monitor shouldn't hurt.
And yes, all the monitors using it for EDB and traits have PreFactionTurnStart (see post #7) - my bad I omitted the monitor that resets the 'deiche' event after a few rounds:
Code:monitor_event PreFactionTurnStart FactionIsLocal if I_EventCounter deiche = 1 inc_counter bruch 1 end_if if I_CompareCounter bruch = 5 set_event_counter deiche 0 set_counter bruch 0 end_if end_monitor