A_SorcBallOrbit

From ZDoom Wiki
Jump to navigation Jump to search

A_SorcBallOrbit
(no parameters)

This is part of the Heresiarch's attack function. This codepointer can only work correctly if it is called by an actor of type SorcBall which has an actor of type Heresiarch in its target field. (Projectiles use this field to store not what actor they were fired at, but which actor did fire them. The calling actor's target field is supposed to be its parent actor.)

In the following, "ball" refers to the calling actor and "parent" to the calling actor's target. This codepointer makes use of several fields in the ball and its parent:

Parent fields
special1 Angle of the first ball
StopBall which type of ball to stop: SorcBall1, SorcBall2 or SorcBall3
args[0] Defense time
args[1] Number of full rotations since stopping mode
args[2] Orbit speed to reach when accelerating or decelerating
args[3] Movement mode, see below
args[4] Current ball orbit speed
Ball fields
special1 Previous angle of ball (for woosh)
special2 Countdown of rapid fire (SorcFX4)


If the ball has no parent, puts the ball in its pain state.

Otherwise, makes the calling actor orbits around its target. Depending on the value of the parent's args[3] field, several other effects might happen, see "orbit modes" below.

Orbit modes

  • 0: The ball decelerates to orbit more slowly: the parent's args[4] field is decreased if it hasn't yet reached the value of the parent's args[2] field, otherwise the parent's args[3] field is set to 5.
  • 1: The ball accelerates to orbit more quickly: the parent's args[4] field is increased if it hasn't yet reached the value of the parent's args[2] field, otherwise the parent's args[3] field is set to 5 and if the args[4] field has reached the value of 25, the balls stop their orbit, the parent's args[1] and [3] fields are set to 0 and 3 respectively, and the StopBall field is set to SorcBall2 (about 80% chance if args[0] is 0), SorcBall3 (otherwise, about 80% chance if the parent's health is reduced to half or less) or SorcBall1 the rest of the time.
  • 2: If possible, stops the rotation and sets the parent's args[3] and args[4] fields to 3 and 0 respectively. Otherwise, orbits normally. An actor of type SorcBall1 will update the parent's special1 field accordingly.
  • 3: If the parent is alive and its StopBall corresponds to the ball's type, puts the parent in its Attack1 state. Otherwise, do nothing. Further effects depends on the ball's type; see "attack modes" below.
  • 4: Do nothing — this is also the default (in)action for any value not in the 0—6 range.
  • 5: Orbits normally
  • 6: Decrements the ball's special2 field, if it becomes negative then sets the parent's args[3] field to 4 and, if alive, puts the parent in its Attack2 state.

Attack modes

  • SorcBall: Sets the parent's args[3] field to 4. As this is a base type, SorcBall does nothing else.
  • SorcBall1: Makes the parent plays the "SorcererSpellCast" sound on its voice channel. About 80% of the time, the ball's args[4] field is to 128 and its special2 field to 18; and the parent's args[3] field is set to 6.

The rest of the time, puts the parent in its Attack2 state.

  • SorcBall2: Parent plays the sound "SorcererSpellCast" and goes in its Attack2 state. A SorcFX2 is spawned at the ball's horizontal position and vertically 45 units from the parent's feet; its target field is set to the parent. The parent gains the REFLECTIVE and INVULNERABLE flags and its args[0] is set to 255.
  • SorcBall3: Parent plays the sound "SorcererSpellCast" and goes in its Attack2 state. If the parent's health has been reduced to 1/3 of its starting value, spawns two SorcFX3, otherwise spawn only one. Any spawned actor has its target field set to the parent.

This codepointer is restricted to SorcBall and actors inheriting from it.