AInventory *AInventory::CreateTossable () { AInventory *copy; // If this actor lacks a SpawnState, don't drop it. (e.g. A base weapon // like the fist can't be dropped because you'll never see it.) if (SpawnState == ::GetDefault<AActor>()->SpawnState || SpawnState == NULL) { return NULL; } if ((ItemFlags & (IF_UNDROPPABLE|IF_UNTOSSABLE)) || Owner == NULL || Amount <= 0) { return NULL; } if (Amount == 1 && !(ItemFlags & IF_KEEPDEPLETED)) { BecomePickup (); DropTime = 30; flags &= ~(MF_SPECIAL|MF_SOLID); return this; } copy = static_cast<AInventory *>(Spawn (GetClass(), Owner->Pos(), NO_REPLACE)); if (copy != NULL) { copy->MaxAmount = MaxAmount; copy->Amount = 1; copy->DropTime = 30; copy->flags &= ~(MF_SPECIAL|MF_SOLID); Amount--; } return copy; }
AInventory *ACoin::CreateTossable () { ACoin *tossed; if ((ItemFlags & IF_UNDROPPABLE) || Owner == NULL || Amount <= 0) { return NULL; } if (Amount >= 50) { Amount -= 50; tossed = static_cast<ACoin*>(Spawn("Gold50", Owner->Pos(), NO_REPLACE)); } else if (Amount >= 25) { Amount -= 25; tossed = static_cast<ACoin*>(Spawn("Gold25", Owner->Pos(), NO_REPLACE)); } else if (Amount >= 10) { Amount -= 10; tossed = static_cast<ACoin*>(Spawn("Gold10", Owner->Pos(), NO_REPLACE)); } else if (Amount > 1 || (ItemFlags & IF_KEEPDEPLETED)) { Amount -= 1; tossed = static_cast<ACoin*>(Spawn("Coin", Owner->Pos(), NO_REPLACE)); } else // Amount == 1 && !(ItemFlags & IF_KEEPDEPLETED) { BecomePickup (); tossed = this; } tossed->flags &= ~(MF_SPECIAL|MF_SOLID); tossed->DropTime = 30; if (tossed != this && Amount <= 0) { Destroy (); } return tossed; }
AInventory *ACoin::CreateTossable () { ACoin *tossed; if ((ItemFlags & IF_UNDROPPABLE) || Owner == NULL || Amount <= 0) { return NULL; } if (Amount >= 50) { Amount -= 50; tossed = Spawn<AGold50> (Owner->x, Owner->y, Owner->z, NO_REPLACE); } else if (Amount >= 25) { Amount -= 25; tossed = Spawn<AGold25> (Owner->x, Owner->y, Owner->z, NO_REPLACE); } else if (Amount >= 10) { Amount -= 10; tossed = Spawn<AGold10> (Owner->x, Owner->y, Owner->z, NO_REPLACE); } else if (Amount > 1) { Amount -= 1; tossed = Spawn<ACoin> (Owner->x, Owner->y, Owner->z, NO_REPLACE); } else { BecomePickup (); tossed = this; } tossed->flags &= ~(MF_SPECIAL|MF_SOLID); tossed->DropTime = 30; if (tossed != this && Amount <= 0) { Destroy (); } return tossed; }