Beispiel #1
0
void GiveSpawner (player_t *player, const PClass *type, int amount)
{
	if (player->mo == NULL || player->health <= 0)
	{
		return;
	}

	AInventory *item = static_cast<AInventory *>
		(Spawn (type, player->mo->x, player->mo->y, player->mo->z, NO_REPLACE));
	if (item != NULL)
	{
		if (amount > 0)
		{
			if (type->IsDescendantOf (RUNTIME_CLASS(ABasicArmorPickup)))
			{
				if (static_cast<ABasicArmorPickup*>(item)->SaveAmount != 0)
				{
					static_cast<ABasicArmorPickup*>(item)->SaveAmount *= amount;
				}
				else
				{
					static_cast<ABasicArmorPickup*>(item)->SaveAmount *= amount;
				}
			}
			else if (type->IsDescendantOf (RUNTIME_CLASS(ABasicArmorBonus)))
			{
				static_cast<ABasicArmorBonus*>(item)->SaveAmount *= amount;
				// [BB]
				static_cast<ABasicArmorBonus*>(item)->BonusCount *= amount;

			}
			else
			{
				item->Amount = MIN (amount, item->MaxAmount);
			}
		}
		if(item->flags & MF_COUNTITEM) // Given items shouldn't count against the map's total,
		{								// since they aren't added to the player's total.
			level.total_items--;
			item->flags &= ~MF_COUNTITEM;
		} 
		if (!item->CallTryPickup (player->mo))
		{
			item->Destroy ();
		}
		else
		{
			// [BB] This construction is more or less a hack, but at least the give cheats are now working.
			SERVER_GiveInventoryToPlayer( player, item );
			// [BC] Play the announcer sound.
			if ( players[consoleplayer].camera == players[consoleplayer].mo && cl_announcepickups )
				ANNOUNCER_PlayEntry( cl_announcer, item->PickupAnnouncerEntry( ));
		}
	}
}