Looks fairly straightforward:
Code:
set event_freq := Sys_Game_Settings_Get_External_Events_Frequency()
set lng_Event_Severity := Sys_Game_Settings_Get_External_Events_Severity()
set chance := Sys_Get_Random_Long(1, 100)
case event_freq
EVENT_FREQUENCY_NONE:
set event_happened := FALSE
EVENT_FREQUENCY_LOW:
if (chance <= 5) then
set event_happened := TRUE
endif
EVENT_FREQUENCY_MEDIUM:
if (chance <= 10) then
set event_happened := TRUE
endif
EVENT_FREQUENCY_HIGH:
if (chance <= 25) then
set event_happened := TRUE
endif
endcase
A number between 1 and 100 is generated, then you go into this case statement based on the frequency used in game setup. In the particular frequency that the game is using, you compare your random number to some chance threshold to see if an event occurs. On low frequency, you have a 5% chance each turn. On high, you have a 25% chance. Set "chance <= 25" line to "chance <= 100" if you want 1 event per turn with high frequency game setting.