ShuffledEventListclass
eventList.t[400], eventListItem.t[362]
Shuffled event list. This is similar to a random event list, except that we fire our events in a “shuffled” order rather than an independently random order. “Shuffled order” means that we fire the events in random order, but we don’t re-fire an event until we’ve run through all of the other events. The effect is as though we were dealing from a deck of cards.
For the first time through the main list, we normally shuffle the strings immediately at startup, but this is optional. If shuffleFirst is set to nil, we will NOT shuffle the list the first time through - we’ll run through it once in the given order, then shuffle for the next time through, then shuffle again for the next, and so on. So, if you want a specific order for the first time through, just define the list in the desired order and set shuffleFirst to nil.
You can optionally specify a separate list of one-time-only sequential strings in the property firstEvents. We’ll run through these strings once. When we’ve exhausted them, we’ll switch to the main eventList list, showing it one time through in its given order, then shuffling it and running through it again, and so on. The firstEvents list is never shuffled - it’s always shown in exactly the order given.
Modified in
eventListItem.t[362]:
Mofiications to ShuffledEventList for EventListItem extension
class
ShuffledEventList
:
RandomFiringScript
EventList
Superclass Tree (in declaration order)
ShuffledEventList
RandomFiringScript
` object
[
EventList](../object/EventList.html)
[
Script](../object/Script.html)
object`
Subclass Tree
(none)
Global Objects
(none)
Summary of Properties
firstEvents
shuffledList_
shuffleFirst
suppressRepeats
Inherited from RandomFiringScript
:
eventPercent
eventReduceAfter
eventReduceTo
Inherited from EventList
:
curScriptState
eventList
eventListLen
resetEachCycle
Summary of Methods
addItem
doScript
getNextRandom
resetList
Inherited from RandomFiringScript
:
checkEventOdds
underusedReadyELIidx
Inherited from EventList
:
advanceState
construct
doScriptEvent
scriptDone
Inherited from Script
:
getScriptState
Properties
firstEvents
a list of events to go through sequentially, in the exact order specified, before firing any events from the main list
shuffledList_
our ShuffledList - we’ll initialize this on demand
shuffleFirst
Flag: shuffle the eventList list before we show it for the first time. By default, this is set to true, so that the behavior is random on each independent run of the game. However, it might be desirable in some cases to always use the original ordering of the eventList list the first time through the list. If this is set to nil, we won’t shuffle the list the first time through.
suppressRepeats
Flag: suppress repeats in the shuffle. If this is true, it prevents a given event from showing up twice in a row, which could otherwise happen right after a shuffle. This is ignored for lists with one or two events: it’s impossible to prevent repeats in a one-element list, and doing so in a two-element list would produce a predictable A-B-A-B… pattern.
You might want to set this to nil for lists of three or four elements, since such short lists can result in fairly un-random-looking sequences when repeats are suppressed, because the available number of permutations drops significantly.
Methods
addItem (item, prop)
OVERRIDDEN
apply our suppressRepeats option to the shuffled list
doScript ( )
OVERRIDDEN
process the next step of the script
getNextRandom ( )
eventList.t[490], eventListItem.t[369]
Get the next random event. We’ll pick an event from our list of events using a ShuffledIntegerList to ensure we pick each value once before re-using any values.
Modified in
eventListItem.t[369]:
For the EventListItem extenstion we modify this method so that it first
chooses any as yet unused EventListItem from our eventList that’s now
ready to fire. If none is found, we use the inherited behaviour to
select the next item indicated by our shuffledList_ .
resetList ( )
OVERRIDDEN
Reset our eventList to clear out EventListItems that are done with (isDone = true). This is not called from any library code by default, but can be called from game code if game authors are worried about an accumulation of too many spent EventListItems in any given eventList. For many games, this probably won’t be necessary.
One potentially good place to call this from as at the end of each iteration of a ShuffledEventList, when the items are about to be reshuffled in any case. You can make this happen by setting the resetOnReshuffle property to true,
Adv3Lite Library Reference Manual
Generated on 15/03/2023 from adv3Lite version 1.6.1