A_FanBubbleSpawn

From SRB2 Wiki
Jump to: navigation, search

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 MF_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
BUBPA0.png
(prandom & 0x7) == 0x7 **** *111 All results with lowest 3 bits set:

7, 15, 23, 31,
39, 47, 55, 63,
71, 79, 87, 95,
103, 111, 119, 127,
135, 143, 151, 159,
167, 175, 183, 191,
199, 207, 215, 223,
231, 239, 247, 255

32/256 (1/8), or 12.5%
MT_MEDIUMBUBBLE
BUBOA0.png
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,
244, 245, 246, 247,
248, 249, 250, 251,
252, 253, 254, 255

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%

  Actions – Spawners [view]
A_BubbleSpawnA_FanBubbleSpawnA_GhostMeA_ParticleSpawnA_RockSpawnA_SmokeTrailerA_SpawnFreshCopyA_SpawnObjectAbsoluteA_SpawnObjectRelative