Actions are a special group of functions that determine what an Object does during a given state. They are used to control the interaction of Objects with the player and the level environment. During any state, an Object can perform one of the 184 actions coded into SRB2, although it does not need to perform one during every state. Some Objects, such as static scenery Objects, do not perform any actions at all because they do not need to interact with their environment in any way. These Objects may or may not have the
MF_NOTHINK flag set, which will prevent them from using actions at all anyway. Actions are commonly associated with SOC, but Lua allows them to be called externally to states as normal functions (see below).
The Object that performs or calls an action is called the actor. Additionally, actions can assign a target or a tracer Object to the actor as reference Objects. They are used for actions that need to be performed in relation to another Object. For example, a shooting action will fire a projectile at the target; a movement attack will make the actor move towards the target. Some actions will set these themselves if they are necessary, but they can also be set manually with the actions
Some actions allow for modifications of their behavior through two signed 32-bit integer variables, called Var1 and Var2. Their effect depends entirely on the action they are used with. These can take a large range of values, both positive and negative. For some of the more complicated actions, SRB2 divides one or both of these variables into upper 16 and lower 16 bits, essentially creating up to four distinct parameters to allow for more flexible control. In these cases, the value of the variable is calculated as the desired upper 16-bit value multiplied with 65536 (or left-shifted by 16) plus the desired lower 16-bit value – this can be written in a SOC or Lua script as VarX = (upper*65536)+lower or VarX = (upper<<16)+lower.
Normally, only a single action can be performed during one state, and their effects usually last only for the moment the state is first used. However, the action
A_DualAction allows for two actions to be executed in the same state. Actions can also be performed simultaneously by setting a state's duration to 0, causing the Object to change into the next state instantly. However, this is not possible in the
SpawnState, whose duration may never be 0. When an Object is first spawned, the
SpawnState's action is not performed unless the Object has the
MF_RUNSPAWNFUNC flag set. If the
SpawnState is called again after that, however, the action will be performed even without the flag.
- 1 Actions with Lua
- 2 List of actions
Actions with Lua
Calling an action
You can call an action by simply using the following format:
A_BunnyHop(actor, var1, var2) -- actor is a mobj_t structure, and var1 and var2 are both INT32
Overriding existing functions
You may override existing actions through this format:
function A_BunnyHop(actor, var1, var2) -- do things end
However, the function super() may be used within a function to call the original, unmodified action as shown here:
function A_BunnyHop(actor, var1, var2) super(actor, var1, var2) -- calls the original A_BunnyHop action -- do things end
Creating new actions
You may also want to create a new action, which allows it to be called in SOC and outside of the Lua script that it was defined in. This must be prefixed with A_.
function A_MyAction(actor, var1, var2) -- do things end
List of actions
Go to the respective article for each action for more details on how to use them.
- A_BubbleRise: Used to make bubbles rise.
- A_BunnyHop: Makes the actor jump hop like a bunny.
- A_CapeChase: Sets the actor's position to its target or tracer; if used repeatedly, the actor will continuously follow its target.
- A_Chase: Makes the actor move towards its target; use repeatedly for basic chasing movement. Used by several enemies, such as the Crawlas.
- A_FishJump: Makes the actor jump if on the ground or underwater. Used by the SDURF.
- A_ForceStop: Immediately stops the actor's movement.
- A_HomingChase: Makes the actor move directly towards its target or tracer; use repeatedly for the actor to continuously chase its target.
- A_InstaLoop: Makes the actor move along a 2D horizontal polygon.
- A_KnockBack: Knocks back the actor's target or tracer at its current speed.
- A_MouseThink: The thinker for mice released by enemies.
- A_MoveAbsolute: Moves the actor horizontally at an absolute speed.
- A_MoveRelative: Moves the actor horizontally while keeping its current momentum.
- A_PushAway: Pushes the actor's target or tracer away from the actor itself.
- A_ScoreRise: Used to make score logos rise.
- A_SkullAttack: The actor flies like a missile toward its target.
- A_Thrust: Thrusts the actor horizontally at its current angle.
- A_ZThrust: Thrusts the actor vertically.
- A_Custom3DRotate: Rotates the actor around its target in 3 dimensions.
- A_MaceRotate: Makes a mace or chain link spin around its target or swing from side to side.
- A_OrbitNights: Makes the Chaos Emeralds in NiGHTS Special Stages orbit around Super Sonic.
- A_RotateSpikeBall: Rotates the actor around its target or tracer.
- A_SparkFollow: Rotates the actor around its target; requires the target to be a player in Super form.
- A_UnidusBall: Thinker for Unidus's/Egg Mobile's spike balls. Rotates the actor around its target; actor can be thrown away from its target, depending on the situation.
- A_BuzzFly: Thinker for the golden and red Buzzes. Makes the actor slowly fly after the player.
- A_CrawlaCommanderThink: Thinker for the Crawla Commander.
- A_DetonChase: Thinker for the Deton. Makes the actor chase after a player; actor explodes if it comes into contact with the player.
- A_EggShield: Thinker for Egg Guard's shield. Sets the position of the actor to its target; pushes away any players touching it at the front.
- A_FaceStabChase: Modified
A_Chasefor the CastleBot FaceStabber.
- A_GuardChase: Modified
A_Chasefor the Egg Guard.
- A_HoodThink: Thinker for the Robo-Hood.
- A_JetbThink: Thinker for the Jetty-Syn Bomber.
- A_JetChase: Modified
A_Chasefor the Jetty-Syns.
- A_JetgShoot: Firing attack for the Jetty-Syn Gunner.
- A_JetgThink: Thinker for the Jetty-Syn Gunner.
- A_JetJawChomp: Attacking thinker for the Jet Jaw. Chases towards target as long as it is in view.
- A_JetJawRoam: Roaming thinker for the Jet Jaw.
- A_MinusCheck: Used to reset the Minus to digging form when it hits the floor.
- A_MinusDigging: Used by the Minus when digging in the ground.
- A_MinusPopup: Used by the Minus when popping out of the ground.
- A_PointyThink: Thinker for the Pointy.
- A_SharpChase: Thinker for the Sharp.
- A_SharpSpin: Thinker for the Sharp's spin attack.
- A_SkimChase: Modified
A_Chasefor the Skim.
- A_SnailerThink: Thinker for the Snailer.
- A_VultureCheck: Thinker for BASH's flight; if stopped, the actor is made to fall down until it reaches the ground.
- A_VultureVtol: Thinker for BASH when aiming. The actor adjusts its Z position until a suitable height to attack its target from is reached.
- A_FocusTarget: Used by the Egg Mobile's laser to move towards the target player.
- A_BrakChase: Modified
A_Chasefor Brak Eggman; movement speed and attacks depend on the actor's health.
- A_BrakFireShot: Makes the actor shoot an Object at its target, offset to match where Brak Eggman's gun is.
- A_BrakLobShot: A specialised version of
A_LobShotused by Brak Eggman; the actor lobs an Object at the floor a third of the way towards the target, assuming it will bounce the rest of the way.
- A_Boss1Chase: Basic chasing behavior and thinker used by the Egg Mobile. An attack may also be randomly selected by this action.
- A_Boss1Laser: Egg Mobile's laser attack thinker. Unlike other actions, this action will automatically call itself again repeatedly for the rest of the current state's duration.
- A_Boss1Spikeballs: Used to spawn each of the Egg Mobile's spikeballs (once per use of the action) during pinch phase.
- A_Boss2Chase: Egg Slimer's main thinker, for moving in a circle around an Axis and spraying goop around itself.
- A_Boss2Pogo: Egg Slimer's pinch phase thinker, for pogoing around spraying goop around itself.
- A_Boss2PogoSFX: Old pogoing thrust behavior used by the Egg Slimer in previous versions of SRB2.
- A_Boss2PogoTarget: New pogoing thrust behavior used by the Egg Slimer from Version 2.1 onwards.
- A_Boss2TakeDamage: Egg Slimer pain-invincibility handler; prevents the actor from being damaged again for a limited time.
- A_Boss3Path: Used by the fake Sea Egg clones to behave similarly to that of the Sea Egg itself, but taking into account where the Sea Egg itself is actually located.
- A_Boss3TakeDamage: Sea Egg pain-invincibility handler; allows it to start moving along the paths of boss waypoints again.
- A_Boss4Raise: Used by the Eggscalibur to signal when to raise the cage surrounding it.
- A_Boss4Reverse: Used by the Eggscalibur to signal when to reverse the direction its spikeball arms spin around it.
- A_Boss4SpeedUp: Used by the Eggscalibur to signal when to increase the speed its spikeball arms spin around it.
- A_Boss7Chase: Modified
A_Chasefor v2.0's Brak Eggman.
- A_Boss7FireMissiles: Fires four missiles of a set type from around the actor's middle; used by v2.0's Brak Eggman to fire grabbable missiles at the player.
- A_BossDeath: Thinker for bosses after they have been defeated.
- A_BossFireShot: A specialized firing attack that allows the Egg Mobile (in previous versions of SRB2) and the Sea Egg to fire missiles from specific positions relative to themselves.
- A_BossJetFume: Used to spawn Egg Mobile-style jet fumes, a Sea Egg-style propeller, a Metal Sonic-style jet fume, or an Eggscalibur-style jet flame.
- A_BossScream: Used to spawn explosions around the actor during a boss death animation.
- A_BossZoom: An unused action similar in function to
A_SkullAttack, but with a modifiable speed.
- A_AttractChase: Thinker for rings, CTF team rings (red and blue) and coins. If a nearby player has an Attraction Shield, the actor will be pulled towards it.
- A_OldRingExplode: Makes the actor explode like the old Explosion Ring from version 1.09.4.
- A_RingDrain: Removes a specified number of rings from the actor's target player.
- A_RingExplode: Makes the actor explode like an Explosion Ring or Grenade Ring.
- A_ThrownRing: Thinker for thrown rings.
Powers and monitors
- A_1upThinker: Changes actor's sprite to nearest player's 1-up sprite.
- A_AwardScore: Awards a set amount of points to a player.
- A_BombShield: Gives target player an Armageddon Shield.
- A_CustomPower: Gives target player a power-up.
- A_EggmanBox: Deals non-elemental damage to target player. Used by the Eggman Monitor.
- A_ExtraLife: Gives target player an extra life.
- A_ForceShield: Gives target player a Force Shield.
- A_GiveWeapon: Gives target player one or more weapon panels.
- A_GravityBox: Reverses target player's gravity for set time.
- A_Invincibility: Makes target player invincible.
- A_JumpShield: Gives target player a Whirlwind Shield.
- A_MixUp: Used as a thinker for the Teleport Monitor.
- A_MonitorPop: Used as a thinker for when a monitor is popped.
- A_PityShield: Gives target player a Pity Shield.
- A_RecyclePowers: Used as thinker for Recycler Monitor.
- A_RingBox: Gives the target player a certain amount of rings.
- A_RingShield: Gives target player an Attraction Shield.
- A_SuperSneakers: Awards target player with Super Sneakers.
- A_WaterShield: Gives target player an Elemental Shield.
- A_BubbleSpawn: Spawns randomly sized bubble if underwater; used by the Air Bubble Patch.
- A_FanBubbleSpawn: Spawns a randomly sized bubble if underwater; used by the Fan.
- A_GhostMe: Spawns an afterimage of actor's current position.
- A_ParticleSpawn: Spawns a particle at a specified interval.
- A_RockSpawn: Spawns rocks at a specified interval.
- A_SmokeTrailer: Spawns a trail of objects when used repeatedly.
- A_SpawnFreshCopy: Spawns a copy of the actor; used to respawn Brak Eggman's electric barrier.
- A_SpawnObjectAbsolute: Spawns an object at an absolute location.
- A_SpawnObjectRelative: Spawns an object relative to the actor's position.
- A_DropMine: Makes actor drop an object.
- A_FireShot: Fires an object at target.
- A_LobShot: Lobs an object at target.
- A_MissileSplit: When applied to a missile object, creates a second missile.
- A_MultiShot: Shoots multiple objects horizontally that spread evenly.
- A_NapalmScatter: Scatters a number of projectiles around in a circle; intended for use with objects that are affected by gravity.
- A_ShootBullet: Makes actor fire an object at the target.
- A_SplitShot: Shoots a missile at either side of target.
- A_SuperFireShot: Fires an object at target that will even stun Super Sonic.
- A_SuperTurretFire: Rapidly fires projectiles that will even stun Super Sonic.
- A_TrapShot: Fires a projectile in a particular direction, rather than at an object.
- A_TurretFire: Rapidly fires projectiles at target.
- A_TurretStop: Stops
- A_VileAttack: Instantly hurts the actor's target if it is in the actor's line of sight. Used as part of Brak Eggman's sniping attack.
- A_VileFire: Thinker for Brak Eggman's targeting reticule. Keeps the actor in front of its tracer, unless its target cannot see it. Optionally draws a line directly to the actor's target.
- A_VileTarget: Spawns an object directly on the actor's target, and sets this object as the actor's tracer. Used as part of Brak Eggman's sniping attack.
- A_Pain: Plays actor's
- A_PlayActiveSound: Plays actor's
- A_PlayAttackSound: Plays actor's
- A_PlaySeeSound: Plays actor's
- A_PlaySound: Plays a sound effect.
- A_Scream: Plays actor's
- A_DualAction: Performs two actions.
- A_LinedefExecute: Executes a linedef executor.
- A_RandomState: Randomly choose between two states.
- A_RandomStateRange: Chooses state from range.
- A_RemoteAction: Tells target to perform an action remotely.
- A_RemoteDamage: Damages, kills or removes the actor or its target/tracer remotely.
- A_SetTargetsTarget: Changes the actor's target to the target of its current target.
- A_SetObjectState: Sets state of target.
- A_SetObjectTypeState: Sets state of a certain type of object.
- A_ChangeAngleAbsolute: Sets actor's angle.
- A_ChangeAngleRelative: Sets actor's angle relative to its current angle.
- A_ChangeColorAbsolute: Sets actor's skin color.
- A_ChangeColorRelative: Sets actor's skin color relative to its current skin color.
- A_FindTarget: Sets actor's target.
- A_FindTracer: Sets actor's tracer.
- A_SetFuse: Set actor's fuse timer.
- A_SetObjectFlags: Modifies actor's primary Object flags.
- A_SetObjectFlags2: Modifies actor's secondary Object flags.
- A_SetRandomTics: Randomly sets duration of actor's current state.
- A_SetReactionTime: Set actor's reaction time.
- A_SetScale: Sets actor's scale.
- A_SetTics: Sets duration of actor's current state.
- A_BubbleCheck: Checks if actor is underwater; if not, actor turns invisible.
- A_CheckAmbush: Calls state if behind target.
- A_CheckHealth: Calls state depending on current health.
- A_CheckHeight: Calls state depending on height difference from target.
- A_CheckRandom: Randomly decides whether or not to call a state.
- A_CheckRange: Calls state depending on horizontal distance from target.
- A_CheckRings: Calls state depending on total rings held by all players.
- A_CheckTargetRings: Calls state depending on number of rings held by target.
- A_CheckThingCount: Calls specific state depending on number of active objects of a certain type.
- A_CheckTotalRings: Calls state if total number of rings collected is high enough.
- A_CheckTrueRange: Calls state if target is in range.
- A_ChickenCheck: Resets chicken if on the ground.
- A_Look: Looks for a player and sets them as new target.
- A_SearchForPlayers: Calls state if actor has found a player.
- A_CheckCustomValue: Calls state depending on custom value.
- A_CheckCusValMemo: Calls state depending on custom memory value.
- A_CusValAction: Remotely calls an action, but modifies vars depending on custom value.
- A_RelayCustomValue: Change custom value of target/tracer.
- A_SetCustomValue: Changes actor's custom value.
- A_UseCusValMemo: Saves or reloads actor's custom value.
- A_ArrowCheck: Switches state depending on vertical direction.
- A_CheckBuddy: Check if actor's "buddy" has at least one hit point.
- A_FaceTarget: Makes actor face target.
- A_FaceTracer: Makes actor face tracer.
- A_InfoState: Switches to an anchor state.
- A_Repeat: Repeats a state a certain number of times. Useful for looping animations.
- A_Explode: Damages objects within range of the actor.
- A_Fall: Changes actor's flags. Used by players who have died.
- A_ForceWin: If there are any living players, it makes them finish the level, as if they stepped into the exit sector.
- A_GoopSplat: Changes actor's flags. Used by the goop projectiles of Brak Eggman (Old).
- A_OverlayThink: Thinker for overlay-like objects. Moves actor to the position of its target.
- A_SetSolidSteam: Makes Gas Jets solid.
- A_SignPlayer: Changes state and skin color of the Level End Sign.
- A_SlingAppear: Used to make the Hidden Chain appear in the map.
- A_SpikeRetract: Toggles solidity of spikes.
- A_ToggleFlameJet: Turns flame jets on and off.
- A_UnsetSolidSteam: Undoes effects of
|Sonic Object Configuration||[view]|
|Unlockable content|| |
|Related links||Actions • Constants • Object creation tutorial|