RandomFiringScriptclass | eventList.t[49], eventListItem.t[475]

Random-Firing script add-in. This is a mix-in class that you can add to the superclass list of any Script subclass to make the script execute only a given percentage of the time it's invoked. Each time doScript() is invoked on the script, we'll look at the probability settings (see the properties below) to determine whether we really want to execute the script this time; if so, we'll proceed with the scripted event, otherwise we'll just return immediately, doing nothing.

Note that this must be used in the superclass list *before* the Script subclass:

myScript: RandomFiringScript, EventList
// ...my definitions...
;

This class is especially useful for random atmospheric events, because it allows you to make the timing of scripted events random. Rather than making a scripted event happen on every single turn, you can use this to make events happen only sporadically. It can often feel too predictable and repetitious when a random background event happens on every single turn; firing events less frequently often makes them feel more realistic.

`class RandomFiringScript : object`

Superclass Tree (in declaration order)

`RandomFiringScript`
`object`

Subclass Tree

`RandomFiringScript`
`RandomEventList`
`ShuffledEventList`

Global Objects

(none)

Summary of Properties

`eventPercent eventReduceAfter eventReduceTo`

Summary of Methods

`checkEventOdds doScript underusedReadyELIidx`

Properties

`eventPercent` | `eventList.t[65]`

Percentage of the time an event occurs. By default, we execute an event 100% of the time - meaning every time that doScript() is invoked. If you set this to a lower percentage, then each time doScript() is invoked, we'll randomly decide whether or not to execute an event based on this percentage. For example, if you want an event to execute on average about a third of the time, set this to 33.

Note that this is a probabilistic frequency. Setting this to 33 does *not* mean that we'll execute exactly every third time. Rather, it means that we'll randomly execute or not on each invocation, and averaged over a large number of invocations, we'll execute about a third of the time.

`eventReduceAfter` | `eventList.t[80]`

Random atmospheric events can get repetitive after a while, so we provide an easy way to reduce the frequency of our events after a while. This way, we'll generate the events more frequently at first, but once the player has seen them enough to get the idea, we'll cut back. Sometimes, the player will spend a lot of time in one place trying to solve a puzzle, so the same set of random events can get stale. Set eventReduceAfter to the number of times you want the events to be generated at full frequency; after we've fired events that many times, we'll change eventPercent to eventReduceTo. If eventReduceAfter is nil, we won't ever change eventPercent.

`eventReduceTo` | `eventList.t[81]`

no description available

Methods

`checkEventOdds ( )` | `eventList.t[98]`

Check the event odds to see if we want to fire an event at all on this invocation.

`doScript ( )` | `eventList.t[87]`

When doScript() is invoked, check the event probabilities before proceeding.

`underusedReadyELIidx ( )` | `eventListItem.t[481]`

Return the index within our eventList of any as yet unused EventListItem that's ready to fire. This is principally for the use of our RandomEventList and ShuffledEventList subclasses.

Adv3Lite Library Reference Manual
Generated on 01/03/2024 from adv3Lite version 1.6.2