A_SpawnItemEx

From ZDoom Wiki
Jump to: navigation, search

A_SpawnItemEx (string type [, float xoffset [, float yoffset [, float zoffset [, float xvelocity [, float yvelocity [, float zvelocity [, float angle [, int flags [, int chance ]]]]]]]])

A_SpawnItemEx (string type [, float xoffset [, float yoffset [, float zoffset [, float xvelocity [, float yvelocity [, float zvelocity [, float angle [, int flags [, int chance [, int tid ]]]]]]]]]) (New from 2.7.1)

Usage

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.

Parameters

  • 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 - the spawned actor will use the same translation as the parent.
    • SXF_ABSOLUTEPOSITION - spawn the actor at an absolute position, instead of offsetting it by the given coordinates from the calling actor's position.
    • SXF_ABSOLUTEANGLE - use the angle parameter as an absolute angle instead of a relative one to the calling actor's angle.
    • SXF_ABSOLUTEVELOCITY- the spawned actor will have its velocity set in absolute values instead of relative derived from the calling actor's velocities along the X, Y and Z axis.
    • SXF_SETMASTER - if the calling actor is a monster (in (development version 7a62459 only), however, this restriction does not apply), 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 - do not check the destination for room before spawning.
    • SXF_TELEFRAG - kills any actor that would prevent the new actor from spawning.
    • SXF_CLIENTSIDE - client-side spawning only. SkulltagIcon22.png (Skulltag only: not supported by ZDoom)
    • SXF_TRANSFERAMBUSHFLAG - if the calling actor has the AMBUSH flag set, then the spawned actor's will have it 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 master field.
    • SXF_USEBLOODCOLOR - uses the calling actor's BloodColor as the source of translation to be applied to the spawned actor. If no BloodColor is specifed, no translation is applied. If, both, this flag and SXF_TRANSFERTRANSLATION are used together in the same call, the latter takes precedence. (New from 2.7.1)
    • SXF_CLEARCALLERTID - if the actor is spawned successfully, this actor (the one that called A_SpawnItemEx) will have its TID set to 0. (New from 2.7.1)
    • SXF_MULTIPLYSPEED - multiply the spawned actor's velocity by its Speed property. (New from 2.7.1)
    • SXF_TRANSFERSCALE - transfers the current Scale factor of the spawning actor to the spawned actor. (New from 2.7.1)
    • SXF_TRANSFERSPECIAL - the calling actor transfers the special and the arguments of it to the spawning actor. (New from 2.7.1)
    • SXF_CLEARCALLERSPECIAL - if the actor is spawned successfully, the calling actor of this function will have its special and arguments removed. (New from 2.7.1)
    • SXF_TRANSFERSTENCILCOL - transfers the calling actor's StencilColor to the spawned actor. (development version cbc0b70 only)
    • SXF_TRANSFERALPHA - transfers the calling actor's alpha to the spawned actor. (development version 5c4ad9b only)
    • SXF_TRANSFERRENDERSTYLE - transfers the calling actor's render style to the spawned actor. (development version 5c4ad9b only)
    • SXF_SETTARGET - sets the calling actor to be the spawning actor's target. Can be combined with SXF_SETTRACER and SXF_SETMASTER. (development version 0735cb9 only)
    • SXF_SETTRACER - sets the calling actor to be the spawning actor's tracer. Can be combined with SXF_SETTARGET and SXF_SETMASTER. (development version 0735cb9 only)
    • SXF_NOPOINTERS - clears the spawning actor's target, master and tracer fields. This overrides SXF_TRANSFERPOINTERS, but is overridden by SXF_SETTARGET, SXF_SETMASTER and SXF_SETTRACER. (development version 68a5db3 only)
    • SXF_ORIGINATOR - Only useful for missiles. Allows said missile actors to set themselves as the master of the spawned actors, if SXF_SETMASTER is used. (development version f766a1a only)
  • chance: This is the chance (out of 255) that the actor has of not spawning. If this is 0 or omitted, the actor will always spawn. If it is 255, it will never spawn.
  • tid: The TID to assign to the spawned actor. If you wish it to share the same TID as the calling actor's, pass tid. In conjunction with SXF_CLEARCALLERTID, this can be used to transfer a TID from the original actor to the spawned actor. (New from 2.7.1)

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
	}
}