A_SpawnItemEx
A_SpawnItemEx (string type, float xoffset, float yoffset, float zoffset, float xvelocity, float yvelocity, float zvelocity, float angle, int flags, int chance)
Spawns an item at the specified offset away from the calling actor, facing the given angle, and with the indicated velocity.
This function can be used with monsters, weapons and inventory items.
- type: The name of the actor to spawn.
- x-/y-/zoffset: The offset from the calling actor at which to spawn the new actor. If Absolute Position is set (see flags), this is in absolute map coordinates, otherwise it is based on the calling actor's facing.
- x-/y-/zvelocity: The initial velocity to give to the spawned actor, useful for projectiles. If Absolute Momentum is set (see flags), this is the absolute velocity that will be given, otherwise it is relative to the calling actor's facing.
- angle: The angle the new actor will face. If Absolute Angle is set, this exact angle will be used. Otherwise, this defines the offset from the calling actor's current angle to use.
- flags: The following flags can be combined by using the | character between the constant names:
- SXF_TRANSFERTRANSLATION — Transfer Translation: The spawned actor will use the same translation as the parent.
- SXF_ABSOLUTEPOSITION — Absolute Position: Spawn the actor at an absolute position.
- SXF_ABSOLUTEANGLE — Absolute Angle: Use angle as an absolute angle, and ignore the parent's angle.
- SXF_ABSOLUTEMOMENTUM — Absolute Momentum: Use an absolute velocity.
- SXF_SETMASTER — Set Master: If the calling actor is a monster, this places the new actor in a master/minion relationship with the parent. Master/minions will not attack each other and this allows for the use of A_KillMaster and/or A_KillChildren.
- SXF_NOCHECKPOSITION — No Check Position: Do not check the destination for room before spawning.
- SXF_TELEFRAG — Telefrag: Kills any actor that would prevent the new actor from spawning.
- SXF_CLIENTSIDE — Client-side spawning only.
(Skulltag only: not supported by ZDoom)
- SXF_TRANSFERAMBUSHFLAG — Transfer AMBUSH Flag: If the spawning actor's AMBUSH flag is set, then the spawned actor's will be set as well.
- SXF_TRANSFERPITCH — Transfers the calling actor's pitch to the spawned actor. Note that this has no effect on the spawned actor's velocities. If you want the calling actor's pitch to be taken into account for the spawned actor's trajectory, use a formula such as this one: A_SpawnItemEx (<type>,cos(-pitch)*<Dist. from spawner>,<yoffset>,<zoffset>+(sin(-pitch)*<Dist. from spawner>),cos(-pitch)*<Projectile speed>,0,sin(-pitch)*<Projectile speed>,<angle>,<flags>,<chance>)
- SXF_TRANSFERPOINTERS — Transfers the calling actor's master, target, and tracer fields to the spawned actor. Note that SXF_SETMASTER has the last word for the the master field.
- chance: This is the chance (out of 256) that the actor has of not spawning. If this is 0 or omitted, the actor will always spawn. If it is 256, it will never spawn.
Examples
The following actor is a variant of the Heretic explosive pod that leaves a poison cloud behind it as well. It uses A_SpawnItemEx so as to make use of the SXF_TRANSFERPOINTERS flag. This way, the monster or player responsible for blowing up the pod will be known as the source of damage created by the poison cloud. This makes sure that deathmatch frags are credited to the proper player, and allows barrel-based infighting to happen. The zoffset is set to 28 so as to mimick closely the A_PoisonBagInit function which isn't accessible to pod actors.
ACTOR PoisonPod : Pod 20020 { DeathSound "PoisonPod/Puff" States { Death: PPOD C 5 BRIGHT A_RemovePod PPOD D 5 BRIGHT A_Scream PPOD E 5 BRIGHT A_Explode PPOD A 0 A_SpawnItemEx("PoisonCloud", 0, 0, 28, 0, 0, 0, 0, SXF_TRANSFERPOINTERS) PPOD F 10 BRIGHT Stop } }