From SRB2 Wiki
Jump to: navigation, search
Test.png This article or section is incomplete. It doesn't have all of the necessary core information on this topic. Please help the SRB2 Wiki by finishing this article.

A_Boss2Chase is an action that is used as the Egg Slimer's main thinker when not in pinch phase. When this action is used continuously, the actor will move in a circle around the nearest Axis point found in the map – the actor's target is set to the nearest axis point found, and the radius of the actor's path will be the axis point's radius. If the actor cannot find any axis point in the map, it will automatically act as if it has been defeated (calling A_BossDeath).

If the actor has the flag MF_AMBUSH set, the angular speed the actor moves arounds its target will depend on the ratio of its SpawnHealth to its current health; the lower the actor's health is, the faster the angular speed will be. If MF_AMBUSH is not set, this speed will remain the same regardless of health. The actor will also regularly spray Objects of a type determined by PainChance around itself as it moves around, playing AttackSound each time it does so.

The base angular speed of the actor is determined by actor->watertop × 0.75 – by default for Objects of type MT_EGGMOBILE2 (the Egg Slimer), actor->watertop is set to the value of the actor's Speed property when spawned in the map. Normally for other Objects this would mean the action would not be of any use, but with Lua this problem can be overcome by modifying the actor's watertop attribute manually.

Object property Use
AttackSound Goop spraying sound
SpawnHealth Used for angular speed multiplier (SpawnHealth/current health)
PainChance Object type of goop to spawn
Speed Base angular speed (for Egg Slimer)

Angular speed calculation

The following lines from A_Boss2Chase's code determine the angular speed at which the actor moves around its Axis:

		// Only speed up if you have the 'Deaf' flag.
		if (actor->flags & MF_AMBUSH)
			speedvar = actor->health;
			speedvar = actor->info->spawnhealth;

		actor->target->angle += // Don't use FixedAngleC!
			FixedAngle(FixedDiv(FixedMul(actor->watertop, (actor->info->spawnhealth*(FRACUNIT/4)*3)), speedvar*FRACUNIT));

			const angle_t fa = actor->target->angle>>ANGLETOFINESHIFT;
			const fixed_t fc = FixedMul(FINECOSINE(fa),radius);
			const fixed_t fs = FixedMul(FINESINE(fa),radius);
			actor->angle = R_PointToAngle2(actor->x, actor->y, actor->target->x + fc, actor->target->y + fs);
			actor->x = actor->target->x + fc;
			actor->y = actor->target->y + fs;

In the above code, the angle of the actor's target (the axis point) is incremented by a set amount, which subsequently determines where the actor's next X and Y coordinates will be located (determined relatively to the position of the actor's target). If A_Boss2Chase is called once every tic by the game for the actor, this can be considered the actor's angular speed.

If the MF_AMBUSH flag is active, the speedvar variable will be actor->health (the current health points the actor has); otherwise it is actor->info->spawnhealth (the health points the actor started with. This determines whether the angular speed will change with respect to the actor's health or not – the result is that without MF_AMBUSH the angular speed is calculated as if the actor always had full health compared to when MF_AMBUSH is active.

Taking any multiplication by FRACUNIT above as a multiplication of 1 for simplicity, the resulting angular speed to be in degrees/tic (assuming A_Boss2Chase is used once every tic), and the base angular speed to be (actor->watertop÷FRACUNIT)×0.75, the above code for calculating the angular speed simplifies to:

Angular speed (°/tic) = base angular speed × (spawnhealth ÷ speedvar)


For Objects of type MT_EGGMOBILE2 (the Egg Slimer), SpawnHealth is set to 8, and actor->watertop is set to the value of Speed, which in turn is 2*FRACUNIT. With these statistics in mind, the angular speed for the Egg Slimer for each health point while the MF_AMBUSH flag is active can be calculated by simplifying the above equation even further:

base angular speed = 2×0.75 → 1.5°
spawnhealth = 8
speedvar = health

The result is:

Angular speed (°/tic) = 12 ÷ health

The resulting angular speeds for each of the possible health points left the Egg Slimer may have from the above equation are tabulated below. This table considers only when the Egg Slimer's health points are between 8 and 4, as below these the boss switches to a different attack pattern.

Health points left Angular speed (°/tic)
8 1.5
7 ~1.71
6 2
5 2.4
4 3

  Actions – Boss thinkers [view]