Enemy

From SRB2 Wiki
Jump to: navigation, search
POSSA1.png FISHA0.png DETNA1.png JETBA1.png SKIMA1.png SHRPA1.png SSHLA1.png
Enemies

In SRB2, enemies (or badniks) are special Objects with artificial intelligence that appear frequently in most Single Player levels. As in most Sonic games, these are generally robots created by Dr. Eggman, the game's main villain. They will normally harm the player on direct contact, or even kill them if they have no rings. However, if the player jumps on an enemy or spins into it, the enemy is destroyed, points are awarded to the player, and an animal trapped inside the enemy will be freed. In rare cases, enemies will take multiple hits to destroy rather than one.

Players can also destroy enemies by firing projectiles at them, exploding an Armageddon Shield within range of them, or coming into direct contact with them while invincible. Enemies can also be destroyed if they are crushed by moving floors/ceilings or solid Objects, or by coming into contact with death pits; however, no points are awarded to anyone in either case. On the other hand, they are unaffected by any sectors with damaging floors/ceilings nor Instant Kill.

Enemies also have the ability to trigger linedef executors via linedef type 313, a trigger linedef specially designed to activate linedef executors once there are no more enemies in the specified area – i.e. it will not trigger until all enemies in the area have been destroyed or have left the area.

Enemies in SRB2

Regular

* SRB2 does not use these enemies in any of its levels; however, they are still available for custom maps to use.

Mario

These enemies appear exclusively in Pipe Towers Zone:

SRB1

These enemies appear exclusively in SRB1 Remake:

Note that the Turret and King Bowser are not actual enemy Objects unlike the above, and both cannot be destroyed by normal means.

Score chains

When an enemy is destroyed, 100 points are awarded to the player who did so. If the player manages to destroy multiple enemies in one move, more points are awarded per enemy. The most typical way of doing this is through bouncing off multiple enemies after a single jump, a technique known as "Crawla bouncing". The score chain is broken if the player touches the ground or is climbing a wall (except when invincibility is in effect), resetting the points awarded to 100 each.

Number of enemies Point value per enemy
1 100
2 200
3 500
4–14 1,000
15 and above 10,000

Custom enemies

It is possible to make custom enemies for SRB2 with the use of SOCs and/or Lua. To make an Object behave like and be recognised as an enemy, it needs to be given the MF_ENEMY flag. However, MF_SPECIAL and MF_SHOOTABLE are generally also needed as well; MF_SPECIAL enables the player to bounce on and be harmed by the enemy Object, and MF_SHOOTABLE allows the Object to be harmed/killed by something, whether or not it is the player. Egg Guard and Minus in particular manipulate these two flags to allow them to be untouchable temporarily.

The only Object properties that affect all enemy behavior are:

  • PainState: This is used when an enemy has been hit and still has health points left; this is generally not needed as most enemies have only 1 health point
  • DeathState: This is used when an enemy has been hit and has no health left; in general this is set to S_XPLD1 for the enemy explosion. For the enemy to be removed from the map after destruction, this should eventually lead to S_NULL

For multiple-hit enemies, a system to make them temporarily invincible for recovery may be needed to prevent multiple health points being lost from a single hit. This is not present by default however; the Crawla Commander's own recovery system is hardcoded to be used by itself only. Options to get around this can include removal of MF_SPECIAL and MF_SHOOTABLE in the pain animation for the reasons already stated above, or otherwise use of Lua if a pain animation is not wanted: for example, a combination of the Lua hooks "ShouldDamage" and "MobjDamage" (and perhaps "MobjThinker") along with a custom variable, explained here:

  • "MobjDamage", for handling what happens when the enemy is damaged; a custom variable can be set to an initial value here, to prevent further damage for a set time
  • "ShouldDamage", for deciding whether the enemy can be damaged or not; if the custom variable is not 0 yet, the enemy should not be harmed yet
  • "MobjThinker", for handling what happens otherwise every tic; the custom variable should be decreased by 1 each time here
  Object types [view]
General EnemyBossPushableSpringMonitorNiGHTS power-upProjectileAmbient sound effect
Special PlayerShieldsFreed animalsEmblemOverlay
Related links List of Object types