- Added a PickupMessage property to the internal actor parser, replaced most of the virtual PickupMessages with it and placed the code that reads the metadata into AInventory::PickupMessage. Now the PickupMessage method is truly virtual and I can do: Added a Health.LowMessage property to define double message items like Doom's medikit in DECORATE. - Since defining Mana3 as an ammo type and then overriding the TryPickup method means that this item defeats all ammo checks in the game it might as well be defined as a CustomInventory item. At least this fixes the amount given in easy and very hard skills. - Converted all ammo items to DECORATE. - Changed internal property setting of ammo types and sister weapons to use fuglyname as for DECORATE definitions. This allows to export the ammo definitions into DECORATE definitions without doing it for the weapons themselves. - Replaced obituary methods with actor properties. - Fixed: The secret map check didn't work for maps inside Zips. SVN r196 (trunk)
217 lines
4.4 KiB
C++
217 lines
4.4 KiB
C++
#include "a_pickups.h"
|
|
#include "a_strifeglobal.h"
|
|
#include "gstrings.h"
|
|
|
|
// Coin ---------------------------------------------------------------------
|
|
|
|
FState ACoin::States[] =
|
|
{
|
|
S_NORMAL (COIN, 'A', -1, NULL, NULL)
|
|
};
|
|
|
|
IMPLEMENT_ACTOR (ACoin, Strife, 93, 0)
|
|
PROP_StrifeType (168)
|
|
PROP_StrifeTeaserType (161)
|
|
PROP_StrifeTeaserType2 (165)
|
|
PROP_SpawnState (0)
|
|
PROP_Flags (MF_SPECIAL|MF_DROPPED|MF_NOTDMATCH)
|
|
PROP_Flags2 (MF2_FLOORCLIP)
|
|
PROP_Inventory_MaxAmountLong (INT_MAX)
|
|
PROP_Inventory_FlagsSet (IF_INVBAR)
|
|
PROP_Inventory_Icon ("I_COIN")
|
|
PROP_Tag ("coin")
|
|
PROP_Inventory_PickupMessage("$TXT_COIN")
|
|
END_DEFAULTS
|
|
|
|
const char *ACoin::PickupMessage ()
|
|
{
|
|
if (Amount == 1)
|
|
{
|
|
return Super::PickupMessage();
|
|
}
|
|
else
|
|
{
|
|
static char msg[64];
|
|
|
|
sprintf (msg, GStrings("TXT_XGOLD"), Amount);
|
|
return msg;
|
|
}
|
|
}
|
|
|
|
bool ACoin::HandlePickup (AInventory *item)
|
|
{
|
|
if (item->IsKindOf (RUNTIME_CLASS(ACoin)))
|
|
{
|
|
if (Amount < MaxAmount)
|
|
{
|
|
if (MaxAmount - Amount < item->Amount)
|
|
{
|
|
Amount = MaxAmount;
|
|
}
|
|
else
|
|
{
|
|
Amount += item->Amount;
|
|
}
|
|
item->ItemFlags |= IF_PICKUPGOOD;
|
|
}
|
|
return true;
|
|
}
|
|
if (Inventory != NULL)
|
|
{
|
|
return Inventory->HandlePickup (item);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
AInventory *ACoin::CreateCopy (AActor *other)
|
|
{
|
|
if (GetClass() == RUNTIME_CLASS(ACoin))
|
|
{
|
|
return Super::CreateCopy (other);
|
|
}
|
|
AInventory *copy = Spawn<ACoin> (0,0,0);
|
|
copy->Amount = Amount;
|
|
copy->BecomeItem ();
|
|
GoAwayAndDie ();
|
|
return copy;
|
|
}
|
|
|
|
// 10 Gold ------------------------------------------------------------------
|
|
|
|
class AGold10 : public ACoin
|
|
{
|
|
DECLARE_ACTOR (AGold10, ACoin)
|
|
};
|
|
|
|
FState AGold10::States[] =
|
|
{
|
|
S_NORMAL (CRED, 'A', -1, NULL, NULL)
|
|
};
|
|
|
|
IMPLEMENT_ACTOR (AGold10, Strife, 138, 0)
|
|
PROP_StrifeType (169)
|
|
PROP_StrifeTeaserType (162)
|
|
PROP_StrifeTeaserType2 (166)
|
|
PROP_SpawnState (0)
|
|
PROP_Inventory_Amount (10)
|
|
PROP_Tag ("10_gold")
|
|
END_DEFAULTS
|
|
|
|
// 25 Gold ------------------------------------------------------------------
|
|
|
|
class AGold25 : public ACoin
|
|
{
|
|
DECLARE_ACTOR (AGold25, ACoin)
|
|
};
|
|
|
|
FState AGold25::States[] =
|
|
{
|
|
S_NORMAL (SACK, 'A', -1, NULL, NULL)
|
|
};
|
|
|
|
IMPLEMENT_ACTOR (AGold25, Strife, 139, 0)
|
|
PROP_StrifeType (170)
|
|
PROP_StrifeTeaserType (163)
|
|
PROP_StrifeTeaserType2 (167)
|
|
PROP_SpawnState (0)
|
|
PROP_Inventory_Amount (25)
|
|
PROP_Tag ("25_gold")
|
|
END_DEFAULTS
|
|
|
|
// 50 Gold ------------------------------------------------------------------
|
|
|
|
class AGold50 : public ACoin
|
|
{
|
|
DECLARE_ACTOR (AGold50, ACoin)
|
|
};
|
|
|
|
FState AGold50::States[] =
|
|
{
|
|
S_NORMAL (CHST, 'A', -1, NULL, NULL)
|
|
};
|
|
|
|
IMPLEMENT_ACTOR (AGold50, Strife, 140, 0)
|
|
PROP_StrifeType (171)
|
|
PROP_StrifeTeaserType (164)
|
|
PROP_StrifeTeaserType2 (168)
|
|
PROP_SpawnState (0)
|
|
PROP_Inventory_Amount (50)
|
|
PROP_Tag ("50_gold")
|
|
END_DEFAULTS
|
|
|
|
// 300 Gold ------------------------------------------------------------------
|
|
|
|
class AGold300 : public ACoin
|
|
{
|
|
DECLARE_ACTOR (AGold300, ACoin)
|
|
public:
|
|
bool TryPickup (AActor *toucher);
|
|
};
|
|
|
|
FState AGold300::States[] =
|
|
{
|
|
S_NORMAL (TOKN, 'A', -1, NULL, NULL)
|
|
};
|
|
|
|
IMPLEMENT_ACTOR (AGold300, Strife, -1, 0)
|
|
PROP_StrifeType (172)
|
|
PROP_SpawnState (0)
|
|
PROP_Inventory_AmountWord (300)
|
|
PROP_Tag ("300_gold")
|
|
END_DEFAULTS
|
|
|
|
bool AGold300::TryPickup (AActor *toucher)
|
|
{
|
|
toucher->GiveInventoryType (QuestItemClasses[2]);
|
|
return Super::TryPickup (toucher);
|
|
}
|
|
|
|
//===========================================================================
|
|
//
|
|
// ACoin :: CreateTossable
|
|
//
|
|
// Gold drops in increments of 50 if you have that much, less if you don't.
|
|
//
|
|
//===========================================================================
|
|
|
|
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);
|
|
}
|
|
else if (Amount >= 25)
|
|
{
|
|
Amount -= 25;
|
|
tossed = Spawn<AGold25> (Owner->x, Owner->y, Owner->z);
|
|
}
|
|
else if (Amount >= 10)
|
|
{
|
|
Amount -= 10;
|
|
tossed = Spawn<AGold10> (Owner->x, Owner->y, Owner->z);
|
|
}
|
|
else if (Amount > 1)
|
|
{
|
|
Amount -= 1;
|
|
tossed = Spawn<ACoin> (Owner->x, Owner->y, Owner->z);
|
|
}
|
|
else
|
|
{
|
|
BecomePickup ();
|
|
tossed = this;
|
|
}
|
|
tossed->flags &= ~(MF_SPECIAL|MF_SOLID);
|
|
tossed->DropTime = 30;
|
|
if (tossed != this && Amount <= 0)
|
|
{
|
|
Destroy ();
|
|
}
|
|
return tossed;
|
|
}
|