A_SpawnObject

From DoomWiki.org

A_SpawnObject(type, angle, x_ofs, y_ofs, z_ofs, x_vel, y_vel, z_vel) is a generic actor spawn function that is part of the MBF21 specification. It has eight parameters, using the values provided in the "Args" fields as arguments.

The first argument determines the actor to be spawned by its DeHackEd thing number, while the second argument specifies the angle at which the spawnee is spawned relative to the direction the calling actor is facing (negative value = angle to the right, positive value = angle to the left). The next three arguments set the x, y, and z offsets of the spawnee relative to the calling actor, while the last three arguments set the velocity of the spawnee along the x, y, and z axes. In both cases, x implies a position along the axis the calling actor is facing (positive value = forward, negative = backward), y implies a position along the axis to the left and right of the calling actor (positive value = to the left, negative value = to the right), and z implies a position along the axis upward and downward from the calling actor (positive value = upward, negative value = downward). All arguments except the first have to be provided in fixed point, meaning the intended value has to be multiplied by 65536 (FRACUNIT).

Note that in case the spawned actor is a missile that is spawned by another missile, the target and tracer pointers will be copied over from the calling actor. Otherwise the spawned missile will set the calling actor as its target and the calling actor's target as its tracer, mirroring the behavior of a revenant's homing missile.

Example[edit]

The following is an example of how to set the A_SpawnObject code pointer in a DeHackEd file using BEX syntax:

Thing 1234 (Spawner)
ID # = 8001
Width = 1048576
Height = 1048576
Initial frame = 1234	 

Frame 1234
Next frame = 1234
Duration = 10
Args1 = 34
Args2 = 0 
Args3 = 0
Args4 = 0
Args5 = 2097152
Args6 = 1638400
Args7 = 0
Args8 = 0

[CODEPTR]
FRAME 1234 = SpawnObject

Or using DECOHack syntax:

#include <dsdhacked> 

thing 1234 "Spawner"
{
EdNum 8001

Radius 16
Height 16

states 
 {
Spawn:
 TNT1 A 10 A_SpawnObject(34, 0, 0, 0, 32.0, 25.0, 0, 0)
 loop
 }
}

The above example creates a basic spawner that shoots out a rocket at the firing height of a cyberdemon and at a rate of about three rockets per second. (Note that the speed of the rocket has to be set to 25 to match the velocity of a regular rocket, despite rockets normally having a speed of just 20, because of differences between how A_SpawnObject calculates the speed of its spawned actor compared to projectile attack functions such as A_MonsterProjectile or Doom's native A_CyberAttack.)

External links[edit]