A_FanBubbleSpawn
A_FanBubbleSpawn is an action used by the Fan that, if underwater, spawns a randomly sized bubble at the actor's location. The actor randomly chooses between spawning an Object of type MT_SMALLBUBBLE
, an Object of type MT_MEDIUMBUBBLE
, or spawning nothing at all otherwise. Unlike the similar action A_BubbleSpawn
, A_FanBubbleSpawn
will never spawn MT_EXTRALARGEBUBBLE
.
If the actor is not underwater when the action is called, no bubbles will be spawned by it. To save memory, bubbles are also not spawned if there is no player nearby: Var1 determines the distance in fracunits to search for players around the actor; if the actor cannot find any players within this distance, no bubbles will be spawned. This behavior is disabled if the actor has MF2_AMBUSH
in its flags.
Bubble spawn chances
The exact chances of each type of bubble (or nothing) spawning are given below. Note that the result of a single P_RandomByte
call (a number between 0 and 255 inclusive, stored in a variable called prandom
) is used by A_FanBubbleSpawn
to determine what is spawned.
Object type | Sprite | Code condition(s) | Binary representation | P_RandomByte results
|
Chance of occurring |
---|---|---|---|---|---|
MT_SMALLBUBBLE
|
(prandom & 0x7) == 0x7
|
**** *111
|
All results with lowest 3 bits set:
7, 15, 23, 31, |
32/256 (1/8), or 12.5% | |
MT_MEDIUMBUBBLE
|
Above condition was false,(prandom & 0xF0) == 0xF0
|
1111 **** (but not **** *111 )
|
All results with highest 4 bits set (except all results for MT_SMALLBUBBLE ):
240, 241, 242, 243, |
14/256 (7/128), or ~5.47% | |
Nothing | (None) | Both conditions above were false | N/A | All results not listed above | 210/256 (105/128), or ~82.03% |
|