IntroductionThe base script used in the example is from GED's resource which can be found here. TPY scripts typically use the FactionIsLocal condition to trigger the script at PreFactionTurnStart. Which is a problem in a hotseat as there a multiple local factions. While the idea of using an AI faction instead has seemingly merit it will not work as intended: the game always processes local factions before AI factions which means changes will happen after the players turn. The solution to this is to use event counters to restrict the number of times this script will fire per turn. Please note that event counters do not need to be declared as they exist with a zero value, even before you have thought of them The script will, for obvious reasons, work just fine for single player games as well. Script StuffThe changes in the script have been highlighted and commented Code: ; === 12 Turns per year === ; the HotseatTPYcheck counter prevents multiple execution during hotseat play declare_counter month declare_counter winter_severity set_counter winter_severity 1 ; 1 = normal winter, 2 = severe winter, 3 = mild winter set_counter month 1 ; set to January monitor_event PreFactionTurnStart FactionIsLocal ; set the season for each month if I_EventCounter HotseatTPYcheck == 0 ; will trigger only once per turn in hotseat if I_CompareCounter month == 1 ;January and I_CompareCounter winter_severity == 1 ; normal winter console_command season winter end_if if I_CompareCounter month == 1 ;January and I_CompareCounter winter_severity == 2 ; severe winter console_command season winter end_if if I_CompareCounter month == 1 ;January and I_CompareCounter winter_severity == 3 ; mild winter console_command season summer end_if if I_CompareCounter month == 2 ;February and I_CompareCounter winter_severity == 1 ; normal winter console_command season winter set_event_counter summer_winter 1 ; next turn will be summer end_if if I_CompareCounter month == 2 ;February and I_CompareCounter winter_severity == 2 ; severe winter console_command season winter end_if if I_CompareCounter month == 2 ;February and I_CompareCounter winter_severity == 3 ; mild winter console_command season summer end_if if I_CompareCounter month == 3 ;March and I_CompareCounter winter_severity == 1 ; normal winter console_command season summer end_if if I_CompareCounter month == 3 ;March and I_CompareCounter winter_severity == 2 ;severe winter console_command season winter end_if if I_CompareCounter month == 3 ;March and I_CompareCounter winter_severity == 3 ; mild winter console_command season summer end_if if I_CompareCounter month == 4 ;April and I_CompareCounter winter_severity == 1 ; normal winter console_command season summer end_if if I_CompareCounter month == 4 ;April and I_CompareCounter winter_severity == 2 ; severe winter console_command season winter set_event_counter summer_winter 1 ; next turn will be summer end_if if I_CompareCounter month == 4 ;April and I_CompareCounter winter_severity == 3 ; mild winter console_command season summer end_if if I_CompareCounter month == 5 ;May console_command season summer end_if if I_CompareCounter month == 6 ;June console_command season summer end_if if I_CompareCounter month == 7 ;July console_command season summer end_if if I_CompareCounter month == 8 ;August console_command season summer end_if if I_CompareCounter month == 8 ;August and I_CompareCounter winter_severity == 2 ; severe winter set_event_counter summer_winter 2 ; next turn will be winter end_if if I_CompareCounter month == 9 ;September and I_CompareCounter winter_severity == 1 ; normal winter console_command season summer set_event_counter summer_winter 2 ; next turn will be winter end_if if I_CompareCounter month == 9 ;September and I_CompareCounter winter_severity == 2 ; severe winter console_command season winter campaign_wait 1 historic_event severe_winter end_if if I_CompareCounter month == 9 ;September and I_CompareCounter winter_severity == 3 ; mild winter console_command season summer end_if if I_CompareCounter month == 10 ;October and I_CompareCounter winter_severity == 1 ; normal winter console_command season winter end_if if I_CompareCounter month == 10 ;October and I_CompareCounter winter_severity == 2 ; severe winter console_command season winter end_if if I_CompareCounter month == 10 ;October and I_CompareCounter winter_severity == 3 ; mild winter console_command season summer campaign_wait 1 historic_event mild_winter end_if if I_CompareCounter month == 11 ;November and I_CompareCounter winter_severity == 1 ; normal winter console_command season winter end_if if I_CompareCounter month == 11; November and I_CompareCounter winter_severity == 2 ; severe winter console_command season winter end_if if I_CompareCounter month == 11 ;November and I_CompareCounter winter_severity == 3 ; mild winter console_command season summer set_event_counter summer_winter 2 ; next turn will be winter end_if if I_CompareCounter month == 12 ;December console_command season winter end_if if I_CompareCounter month == 12 ;December and I_CompareCounter winter_severity == 3 ; mild winter set_event_counter summer_winter 1 ; next turn will be summer end_if inc_counter month 1 ; advance the month if I_CompareCounter month == 13 ; start a new year set_counter month 1 end_if set_event_counter HotseatTPYcheck 1 ; prevents executing more then once per turn end_if end_monitor monitor_event FactionTurnEnd FactionType slave ; allows game to advance age and I_CompareCounter month < 12 console_command season summer set_event_counter HotseatTPYcheck 0 ; resets counter for the next turn end_monitor monitor_event FactionTurnEnd FactionType slave ; randomized winter and I_CompareCounter month == 6 generate_random_counter random_winter 1 10 set_event_counter HotseatTPYcheck 0 ; resets counter for the next turn if I_EventCounter random_winter >= 1 and I_EventCounter random_winter <= 8 set_counter winter_severity 1 ; 80 percent chance of regular winter end_if if I_EventCounter random_winter == 9 set_counter winter_severity 2 ; 10 percent chance of severe winter end_if if I_EventCounter random_winter == 10 set_counter winter_severity 3 ; 10 percent chance of mild winter end_if end_monitor
; === 12 Turns per year === ; the HotseatTPYcheck counter prevents multiple execution during hotseat play declare_counter month declare_counter winter_severity set_counter winter_severity 1 ; 1 = normal winter, 2 = severe winter, 3 = mild winter set_counter month 1 ; set to January monitor_event PreFactionTurnStart FactionIsLocal ; set the season for each month if I_EventCounter HotseatTPYcheck == 0 ; will trigger only once per turn in hotseat if I_CompareCounter month == 1 ;January and I_CompareCounter winter_severity == 1 ; normal winter console_command season winter end_if if I_CompareCounter month == 1 ;January and I_CompareCounter winter_severity == 2 ; severe winter console_command season winter end_if if I_CompareCounter month == 1 ;January and I_CompareCounter winter_severity == 3 ; mild winter console_command season summer end_if if I_CompareCounter month == 2 ;February and I_CompareCounter winter_severity == 1 ; normal winter console_command season winter set_event_counter summer_winter 1 ; next turn will be summer end_if if I_CompareCounter month == 2 ;February and I_CompareCounter winter_severity == 2 ; severe winter console_command season winter end_if if I_CompareCounter month == 2 ;February and I_CompareCounter winter_severity == 3 ; mild winter console_command season summer end_if if I_CompareCounter month == 3 ;March and I_CompareCounter winter_severity == 1 ; normal winter console_command season summer end_if if I_CompareCounter month == 3 ;March and I_CompareCounter winter_severity == 2 ;severe winter console_command season winter end_if if I_CompareCounter month == 3 ;March and I_CompareCounter winter_severity == 3 ; mild winter console_command season summer end_if if I_CompareCounter month == 4 ;April and I_CompareCounter winter_severity == 1 ; normal winter console_command season summer end_if if I_CompareCounter month == 4 ;April and I_CompareCounter winter_severity == 2 ; severe winter console_command season winter set_event_counter summer_winter 1 ; next turn will be summer end_if if I_CompareCounter month == 4 ;April and I_CompareCounter winter_severity == 3 ; mild winter console_command season summer end_if if I_CompareCounter month == 5 ;May console_command season summer end_if if I_CompareCounter month == 6 ;June console_command season summer end_if if I_CompareCounter month == 7 ;July console_command season summer end_if if I_CompareCounter month == 8 ;August console_command season summer end_if if I_CompareCounter month == 8 ;August and I_CompareCounter winter_severity == 2 ; severe winter set_event_counter summer_winter 2 ; next turn will be winter end_if if I_CompareCounter month == 9 ;September and I_CompareCounter winter_severity == 1 ; normal winter console_command season summer set_event_counter summer_winter 2 ; next turn will be winter end_if if I_CompareCounter month == 9 ;September and I_CompareCounter winter_severity == 2 ; severe winter console_command season winter campaign_wait 1 historic_event severe_winter end_if if I_CompareCounter month == 9 ;September and I_CompareCounter winter_severity == 3 ; mild winter console_command season summer end_if if I_CompareCounter month == 10 ;October and I_CompareCounter winter_severity == 1 ; normal winter console_command season winter end_if if I_CompareCounter month == 10 ;October and I_CompareCounter winter_severity == 2 ; severe winter console_command season winter end_if if I_CompareCounter month == 10 ;October and I_CompareCounter winter_severity == 3 ; mild winter console_command season summer campaign_wait 1 historic_event mild_winter end_if if I_CompareCounter month == 11 ;November and I_CompareCounter winter_severity == 1 ; normal winter console_command season winter end_if if I_CompareCounter month == 11; November and I_CompareCounter winter_severity == 2 ; severe winter console_command season winter end_if if I_CompareCounter month == 11 ;November and I_CompareCounter winter_severity == 3 ; mild winter console_command season summer set_event_counter summer_winter 2 ; next turn will be winter end_if if I_CompareCounter month == 12 ;December console_command season winter end_if if I_CompareCounter month == 12 ;December and I_CompareCounter winter_severity == 3 ; mild winter set_event_counter summer_winter 1 ; next turn will be summer end_if inc_counter month 1 ; advance the month if I_CompareCounter month == 13 ; start a new year set_counter month 1 end_if set_event_counter HotseatTPYcheck 1 ; prevents executing more then once per turn end_if end_monitor monitor_event FactionTurnEnd FactionType slave ; allows game to advance age and I_CompareCounter month < 12 console_command season summer set_event_counter HotseatTPYcheck 0 ; resets counter for the next turn end_monitor monitor_event FactionTurnEnd FactionType slave ; randomized winter and I_CompareCounter month == 6 generate_random_counter random_winter 1 10 set_event_counter HotseatTPYcheck 0 ; resets counter for the next turn if I_EventCounter random_winter >= 1 and I_EventCounter random_winter <= 8 set_counter winter_severity 1 ; 80 percent chance of regular winter end_if if I_EventCounter random_winter == 9 set_counter winter_severity 2 ; 10 percent chance of severe winter end_if if I_EventCounter random_winter == 10 set_counter winter_severity 3 ; 10 percent chance of mild winter end_if end_monitor
Last edited by Gigantus; September 03, 2024 at 11:04 PM.
View Tag Cloud
Forum Rules