From ZDoom Wiki
Jump to: navigation, search

bool A_GiveToTarget (string type [, int count [, pointer giveto]])


Tries to add count items of type type to the calling actor's current target's inventory. This function will not add more items than can be carried. Note that when an actor dies its target is automatically set to the killer. Projectiles also target the actor which shot them when they are fired.

If type is an item derived from Health, then the amount received is the result of multiplying count by the item's amount, e.g. if type is Medikit and count is 2, then the amount of health received would be 50 points, not 2.


  • type: the item to give. This should be a valid inventory item.
  • count: the number of samples of this item to give. Default is 0, which is interpreted as 1.
  • giveto: the actor to give the item to, with the calling actor's target being the context, here, as opposed to the caller itself. This is an actor pointer selector. Default is AAPTR_DEFAULT, which corresponds to the calling actor's target.

Return value

The function returns true if the item is successfully received, otherwise it returns false.


This function can be used to reward players with items for killing certain monsters.

  CYBR H 10 A_GiveToTarget("Credits", 1000)
  CYBR I 10 A_Scream
  CYBR M 10 A_NoBlocking
  CYBR NO 10
  CYBR P 30
  CYBR P -1 A_BossDeath

If this imp dies, it gives a partial invisibility sphere to its target's (killer's) master.

ACTOR BlurSphereDoomImp : DoomImp
        TROO A 0 A_GiveToTarget("BlurSphere", 1, AAPTR_MASTER)
        Goto Super::Death

        TROO A 0 A_GiveToTarget("BlurSphere", 1, AAPTR_MASTER)
        Goto Super::XDeath