TakeActorInventory
From ZDoom Wiki
void TakeActorInventory(int tid, str inventory_item, int amount);
Usage
This function will take the amount of items from the specified actor. See also: TakeInventory.
Examples
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 one.
str weapon[7] = {
"Chainsaw",
"Shotgun",
"SuperShotgun",
"Chaingun",
"RocketLauncher",
"PlasmaRifle",
"BFG9000"
};
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]))
{
count++;
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;
}
}