mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-08 22:11:09 +00:00
1bd6ac028b
- 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)
178 lines
4 KiB
C++
178 lines
4 KiB
C++
#include "actor.h"
|
|
#include "gi.h"
|
|
#include "m_random.h"
|
|
#include "s_sound.h"
|
|
#include "d_player.h"
|
|
#include "a_action.h"
|
|
#include "p_local.h"
|
|
#include "p_enemy.h"
|
|
#include "a_action.h"
|
|
#include "p_pspr.h"
|
|
#include "gstrings.h"
|
|
#include "a_hexenglobal.h"
|
|
#include "sbar.h"
|
|
|
|
IMPLEMENT_POINTY_CLASS (AFourthWeaponPiece)
|
|
DECLARE_POINTER (TempFourthWeapon)
|
|
END_POINTERS
|
|
|
|
BEGIN_STATELESS_DEFAULTS (AFourthWeaponPiece, Hexen, -1, 0)
|
|
PROP_Inventory_PickupSound ("misc/w_pkup")
|
|
PROP_Inventory_PickupMessage("$TXT_WEAPONPIECE")
|
|
END_DEFAULTS
|
|
|
|
void AFourthWeaponPiece::Serialize (FArchive &arc)
|
|
{
|
|
Super::Serialize (arc);
|
|
arc << FourthWeaponClass << PieceValue << TempFourthWeapon;
|
|
}
|
|
|
|
const char *AFourthWeaponPiece::PickupMessage ()
|
|
{
|
|
if (TempFourthWeapon != NULL)
|
|
{
|
|
return TempFourthWeapon->PickupMessage ();
|
|
}
|
|
else
|
|
{
|
|
return Super::PickupMessage ();
|
|
}
|
|
}
|
|
|
|
bool AFourthWeaponPiece::MatchPlayerClass (AActor *toucher)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
void AFourthWeaponPiece::PlayPickupSound (AActor *toucher)
|
|
{
|
|
if (TempFourthWeapon != NULL)
|
|
{
|
|
// Play the build-sound full volume for all players
|
|
S_Sound (toucher, CHAN_ITEM, "WeaponBuild", 1, ATTN_SURROUND);
|
|
}
|
|
else
|
|
{
|
|
Super::PlayPickupSound (toucher);
|
|
}
|
|
}
|
|
|
|
//==========================================================================
|
|
//
|
|
// TryPickupWeaponPiece
|
|
//
|
|
//==========================================================================
|
|
|
|
bool AFourthWeaponPiece::TryPickup (AActor *toucher)
|
|
{
|
|
bool shouldStay;
|
|
bool checkAssembled;
|
|
bool gaveWeapon;
|
|
int gaveMana;
|
|
const PClass *mana1 = PClass::FindClass(NAME_Mana1);
|
|
const PClass *mana2 = PClass::FindClass(NAME_Mana2);
|
|
|
|
checkAssembled = true;
|
|
gaveWeapon = false;
|
|
gaveMana = 0;
|
|
shouldStay = PrivateShouldStay ();
|
|
if (!MatchPlayerClass (toucher))
|
|
{ // Wrong class, but try to pick up for mana
|
|
if (shouldStay)
|
|
{ // Can't pick up wrong-class weapons in coop netplay
|
|
return false;
|
|
}
|
|
checkAssembled = false;
|
|
gaveMana = toucher->GiveAmmo (mana1, 20) +
|
|
toucher->GiveAmmo (mana2, 20);
|
|
if (!gaveMana)
|
|
{ // Didn't need the mana, so don't pick it up
|
|
return false;
|
|
}
|
|
}
|
|
else if (shouldStay)
|
|
{ // Cooperative net-game
|
|
if (toucher->player->pieces & PieceValue)
|
|
{ // Already has the piece
|
|
return false;
|
|
}
|
|
toucher->GiveAmmo (mana1, 20);
|
|
toucher->GiveAmmo (mana2, 20);
|
|
}
|
|
else
|
|
{ // Deathmatch or singleplayer game
|
|
gaveMana = toucher->GiveAmmo (mana1, 20) +
|
|
toucher->GiveAmmo (mana2, 20);
|
|
if (toucher->player->pieces & PieceValue)
|
|
{ // Already has the piece, check if mana needed
|
|
if (!gaveMana)
|
|
{ // Didn't need the mana, so don't pick it up
|
|
return false;
|
|
}
|
|
checkAssembled = false;
|
|
}
|
|
}
|
|
|
|
// Check if fourth weapon assembled
|
|
if (checkAssembled)
|
|
{
|
|
toucher->player->pieces |= PieceValue;
|
|
for (int i = 0; i < 9; i += 3)
|
|
{
|
|
int mask = (WPIECE1|WPIECE2|WPIECE3) << i;
|
|
|
|
if (PieceValue & mask)
|
|
{
|
|
if (toucher->CheckLocalView (consoleplayer))
|
|
{
|
|
StatusBar->SetInteger (0, i);
|
|
}
|
|
if ((toucher->player->pieces & mask) == mask)
|
|
{
|
|
gaveWeapon = (FourthWeaponClass != NULL);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (gaveWeapon)
|
|
{
|
|
TempFourthWeapon = static_cast<AInventory *>(Spawn (FourthWeaponClass, x, y, z));
|
|
if (TempFourthWeapon != NULL)
|
|
{
|
|
gaveWeapon = TempFourthWeapon->TryPickup (toucher);
|
|
if (!gaveWeapon)
|
|
{
|
|
TempFourthWeapon->GoAwayAndDie ();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
gaveWeapon = false;
|
|
}
|
|
}
|
|
if (gaveWeapon || gaveMana || checkAssembled)
|
|
{
|
|
GoAwayAndDie ();
|
|
}
|
|
return gaveWeapon || gaveMana || checkAssembled;
|
|
}
|
|
|
|
bool AFourthWeaponPiece::ShouldStay ()
|
|
{
|
|
return PrivateShouldStay ();
|
|
}
|
|
|
|
bool AFourthWeaponPiece::PrivateShouldStay ()
|
|
{
|
|
// We want a weapon piece to behave like a weapon, so follow the exact
|
|
// same logic as weapons when deciding whether or not to stay.
|
|
if (((multiplayer &&
|
|
(!deathmatch && !alwaysapplydmflags)) || (dmflags & DF_WEAPONS_STAY)) &&
|
|
!(flags & MF_DROPPED))
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|