From ZDoom Wiki
Jump to: navigation, search

void TakeActorInventory(int tid, str inventory_item, int amount);


This function will take the amount of items from the specified actor. In the case of ammo, health and armor it will take the total number (so TakeActorInventory(3, "Shell", 5) and TakeActorInventory(3, "ShellBox", 5) will both take five shells from actors with a TID of 3).

Unlike ClearActorInventory, TakeActorInventory can remove items that are flagged as undroppable.

See the inventory page for a list of items in ZDoom.


In this example, when a player activates script 2, they will steal the most powerful weapon that can be found (in the order given in the weapon string array) from the first player that can be found with it at random. This results in the activating player gaining the weapon and the player found with said weapon losing it.

str weapon[7] = {

bool player_checked[8];

script 1 enter
    Thing_ChangeTID(0, 1000 + PlayerNumber());

script 2 (void)
    int w, p, take, count;
    for (w=6; w>=0; w--) 
        while (count < PlayerCount() && !take) 
            count = 1;
            do {
                p = random(0, 7); 
            } while (!PlayerInGame(p) || player_checked[p] || p == PlayerNumber());

            if (!CheckActorInventory(1000 + p, weapon[w])) 
                player_checked[p] = 1;
            else if(CheckActorInventory(1000 + p, weapon[w]))
                TakeActorInventory(1000 + p, weapon[w], 1);
                GiveInventory(weapon[w], 1);
                take = 1;
                w = -1;

        for (p=0; p<8; p++)
            player_checked[p] = 0;

See also