.com.unity Forums

.com.unity Forums (http://forum.shrapnelgames.com/index.php)
-   SEV Modders Knowledge Base (http://forum.shrapnelgames.com/forumdisplay.php?f=154)
-   -   Event and Intel scripts (http://forum.shrapnelgames.com/showthread.php?t=31672)

Phoenix-D November 6th, 2006 09:11 PM

Event and Intel scripts
 
I can sort of figure out the AI scripts, but the Event script is driving me batty.

I'm trying to make a fairly simple change- I want an event to fire every turn. Any ideas on -how- to do that?

Fyron November 6th, 2006 09:19 PM

Re: Event and Intel scripts
 
Looks fairly straightforward:

<font class="small">Code:</font><hr /><pre> 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 &lt;= 5) then
set event_happened := TRUE
endif
EVENT_FREQUENCY_MEDIUM:
if (chance &lt;= 10) then
set event_happened := TRUE
endif
EVENT_FREQUENCY_HIGH:
if (chance &lt;= 25) then
set event_happened := TRUE
endif
endcase</pre><hr />

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 &lt;= 25" line to "chance &lt;= 100" if you want 1 event per turn with high frequency game setting.


All times are GMT -4. The time now is 05:39 PM.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2024, Shrapnel Games, Inc. - All Rights Reserved.