A_SpawnItem

From ZDoom Wiki
Jump to: navigation, search

bool A_SpawnItem (string type, double distance, float zheight, bool useammo, bool translation)


Note: This function has been superseded by A_SpawnItemEx, which duplicates and extends its functionality. Use of the newer function is advised in order to maintain maximum flexibility in your code.


Spawns an item in front of the calling actor.

This function can be used with monsters, weapons and inventory items. useammo has different meanings based on the caller:

  • For weapons it specifies whether ammo is to be used (1) or not (0).
  • For monsters it specifies whether there should be a master/minion relationship. Masters/Minions never attack each other and this relationship allows the use of A_KillMaster and A_KillChildren.

The default for this parameter is 1.

If translation is 1, the spawned actor will be assigned the same translation table as the actor that called the function.

Examples

ACTOR TerranMarine : ScriptedMarine2
{
 obituary "%o was killed by a Terran Marine."
 translation "112:127=198:207"
 dropitem "Clip" 256
 dropitem "GreenMedikit" 128
 dropitem "GreenStimpack" 128
 dropitem "GreenArmor" 16
 dropitem "BlueArmor" 8
 dropitem "ArmorRed" 4
 dropitem "ArmorGray" 2
 +FRIENDLY
 activesound "starcraft/active"
 deathsound "starcraft/death"
 states
 {
 Spawn:
   PLY2 A 4 A_Look
   PLY2 B 4
   goto See
 See:
   PLY2 AABBCCDD 2 A_FastChase
   PLY2 A 0 NoiseAlert (0, 0)
   loop
 Pain:
   PLY2 G 4
   PLY2 G 4 A_Pain
   goto Spawn+3
 Missile:
   PLY2 E 8 A_FaceTarget
   PLY2 E 2 A_PlayWeaponSound ("starcraft/marinef1")
   PLY2 F 2 A_CustomBulletAttack (5.6, 0, 1, 5, "BulletPuff", 0)
   PLY2 E 2 A_FaceTarget
   PLY2 F 2 A_CustomBulletAttack (5.6, 0, 1, 5, "BulletPuff", 0)
   PLY2 E 2 A_FaceTarget
   PLY2 F 2 A_CustomBulletAttack (5.6, 0, 1, 5, "BulletPuff", 0)
   PLY2 E 10 A_CPosRefire
   goto Missile+1
 Death:
   PLY2 H 10
   PLY2 I 10 A_Scream
   PLY2 J 10 A_NoBlocking
   PLY2 KLM 10
   PLY2 N 0 A_SpawnItem("SpawnTMarine",0,0)
   PLY2 N 512
   goto DDisp
 DDisp:
   PLY2 N 4 A_FadeOut(0.05)
   loop
 XDeath:
   PLY2 O 5
   PLY2 P 5 A_XScream
   PLY2 Q 5 A_NoBlocking
   PLY2 RSTUV 5
   PLY2 W 0 A_SpawnItem("SpawnTMarine",0,0)
   PLY2 W 512
   goto XDisp
 XDisp:
   PLY2 W 4 A_FadeOut(0.05)
   loop
 Raise:
   PLY2 MLKJIH 5
   goto See
 }
}
ACTOR SpawnTMarine
{
 states
 {
 Spawn:
   ALLY A 128
   ALLY A 0 A_PlaySound("misc/teleport")
   ALLY A 0 A_SpawnItemEx("TerranMarine", 0, 0, 0, 0, 0, 0, 0, 64, 0)
   TFOG ABCDEFGHIJ 8
   Stop
 }
}