- split up zscript/shared/inventory.txt.
- moved health items to their own file. - scriptified ScoreItem and MapRevealer whose entire functionality was a small TryPickup method. - fixed: bit fields in global variables were not correctly written. This should conclude the inventory cleanup. It is now possible again to find things in there.
This commit is contained in:
parent
229c55ce61
commit
b0f3121bec
25 changed files with 982 additions and 959 deletions
|
|
@ -1110,6 +1110,7 @@ set (PCH_SOURCES
|
|||
g_inventory/a_ammo.cpp
|
||||
g_inventory/a_armor.cpp
|
||||
g_inventory/a_artifacts.cpp
|
||||
g_inventory/a_health.cpp
|
||||
g_inventory/a_keys.cpp
|
||||
g_inventory/a_pickups.cpp
|
||||
g_inventory/a_puzzleitems.cpp
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
#include "d_player.h"
|
||||
#include "vectors.h"
|
||||
#include "a_ammo.h"
|
||||
#include "a_health.h"
|
||||
|
||||
static FRandom pr_botmove ("BotMove");
|
||||
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@
|
|||
#include "vmbuilder.h"
|
||||
#include "a_armor.h"
|
||||
#include "a_ammo.h"
|
||||
#include "a_health.h"
|
||||
|
||||
// [SO] Just the way Randy said to do it :)
|
||||
// [RH] Made this CVAR_SERVERINFO
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@
|
|||
#include "p_spec.h"
|
||||
#include "hardware.h"
|
||||
#include "r_utility.h"
|
||||
#include "a_keys.h"
|
||||
#include "intermission/intermission.h"
|
||||
|
||||
EXTERN_CVAR (Int, disableautosave)
|
||||
|
|
|
|||
|
|
@ -50,6 +50,8 @@
|
|||
#include "d_player.h"
|
||||
#include "doomerrors.h"
|
||||
#include "fragglescript/t_fs.h"
|
||||
#include "a_keys.h"
|
||||
#include "a_health.h"
|
||||
|
||||
// MACROS ------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ static FRandom pr_torch ("Torch");
|
|||
#define TIMEFREEZE_TICS ( 12 * TICRATE )
|
||||
*/
|
||||
|
||||
|
||||
IMPLEMENT_CLASS(APowerup, false, false)
|
||||
|
||||
// Powerup-Giver -------------------------------------------------------------
|
||||
|
|
@ -56,6 +57,7 @@ void PClassPowerupGiver::ReplaceClassRef(PClass *oldclass, PClass *newclass)
|
|||
}
|
||||
}
|
||||
|
||||
IMPLEMENT_CLASS(APowerupGiver, false, false)
|
||||
|
||||
DEFINE_FIELD(APowerupGiver, PowerupType)
|
||||
DEFINE_FIELD(APowerupGiver, EffectTics)
|
||||
|
|
|
|||
301
src/g_inventory/a_health.cpp
Normal file
301
src/g_inventory/a_health.cpp
Normal file
|
|
@ -0,0 +1,301 @@
|
|||
/*
|
||||
** a_health.cpp
|
||||
** All health items
|
||||
**
|
||||
**---------------------------------------------------------------------------
|
||||
** Copyright 2000-2016 Randy Heit
|
||||
** Copyright 2006-2016 Cheistoph Oelckers
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions
|
||||
** are met:
|
||||
**
|
||||
** 1. Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** 2. Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** 3. The name of the author may not be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**---------------------------------------------------------------------------
|
||||
**
|
||||
*/
|
||||
|
||||
#include "d_player.h"
|
||||
#include "a_morph.h"
|
||||
#include "a_health.h"
|
||||
#include "serializer.h"
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// FUNC P_GiveBody
|
||||
//
|
||||
// Returns false if the body isn't needed at all.
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool P_GiveBody (AActor *actor, int num, int max)
|
||||
{
|
||||
if (actor->health <= 0 || (actor->player != NULL && actor->player->playerstate == PST_DEAD))
|
||||
{ // Do not heal dead things.
|
||||
return false;
|
||||
}
|
||||
|
||||
player_t *player = actor->player;
|
||||
|
||||
num = clamp(num, -65536, 65536); // prevent overflows for bad values
|
||||
if (player != NULL)
|
||||
{
|
||||
// Max is 0 by default, preserving default behavior for P_GiveBody()
|
||||
// calls while supporting AHealth.
|
||||
if (max <= 0)
|
||||
{
|
||||
max = static_cast<APlayerPawn*>(actor)->GetMaxHealth() + player->mo->stamina;
|
||||
// [MH] First step in predictable generic morph effects
|
||||
if (player->morphTics)
|
||||
{
|
||||
if (player->MorphStyle & MORPH_FULLHEALTH)
|
||||
{
|
||||
if (!(player->MorphStyle & MORPH_ADDSTAMINA))
|
||||
{
|
||||
max -= player->mo->stamina;
|
||||
}
|
||||
}
|
||||
else // old health behaviour
|
||||
{
|
||||
max = MAXMORPHHEALTH;
|
||||
if (player->MorphStyle & MORPH_ADDSTAMINA)
|
||||
{
|
||||
max += player->mo->stamina;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// [RH] For Strife: A negative body sets you up with a percentage
|
||||
// of your full health.
|
||||
if (num < 0)
|
||||
{
|
||||
num = max * -num / 100;
|
||||
if (player->health < num)
|
||||
{
|
||||
player->health = num;
|
||||
actor->health = num;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (num > 0)
|
||||
{
|
||||
if (player->health < max)
|
||||
{
|
||||
num = int(num * G_SkillProperty(SKILLP_HealthFactor));
|
||||
if (num < 1) num = 1;
|
||||
player->health += num;
|
||||
if (player->health > max)
|
||||
{
|
||||
player->health = max;
|
||||
}
|
||||
actor->health = player->health;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Parameter value for max is ignored on monsters, preserving original
|
||||
// behaviour on AHealth as well as on existing calls to P_GiveBody().
|
||||
max = actor->SpawnHealth();
|
||||
if (num < 0)
|
||||
{
|
||||
num = max * -num / 100;
|
||||
if (actor->health < num)
|
||||
{
|
||||
actor->health = num;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (actor->health < max)
|
||||
{
|
||||
actor->health += num;
|
||||
if (actor->health > max)
|
||||
{
|
||||
actor->health = max;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(AActor, GiveBody)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(AActor);
|
||||
PARAM_INT(num);
|
||||
PARAM_INT_DEF(max);
|
||||
ACTION_RETURN_BOOL(P_GiveBody(self, num, max));
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// Classes
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
IMPLEMENT_CLASS(PClassHealth, false, false)
|
||||
IMPLEMENT_CLASS(AHealth, false, false)
|
||||
DEFINE_FIELD(AHealth, PrevHealth)
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// PClassHealth Constructor
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
PClassHealth::PClassHealth()
|
||||
{
|
||||
LowHealth = 0;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// PClassHealth :: DeriveData
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
void PClassHealth::DeriveData(PClass *newclass)
|
||||
{
|
||||
assert(newclass->IsKindOf(RUNTIME_CLASS(PClassHealth)));
|
||||
Super::DeriveData(newclass);
|
||||
PClassHealth *newc = static_cast<PClassHealth *>(newclass);
|
||||
|
||||
newc->LowHealth = LowHealth;
|
||||
newc->LowHealthMessage = LowHealthMessage;
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// AHealth :: PickupMessage
|
||||
//
|
||||
//===========================================================================
|
||||
FString AHealth::PickupMessage ()
|
||||
{
|
||||
int threshold = GetClass()->LowHealth;
|
||||
|
||||
if (PrevHealth < threshold)
|
||||
{
|
||||
FString message = GetClass()->LowHealthMessage;
|
||||
|
||||
if (message.IsNotEmpty())
|
||||
{
|
||||
return message;
|
||||
}
|
||||
}
|
||||
return Super::PickupMessage();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// AHealth :: TryPickup
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
bool AHealth::TryPickup (AActor *&other)
|
||||
{
|
||||
PrevHealth = other->player != NULL ? other->player->health : other->health;
|
||||
|
||||
// P_GiveBody adds one new feature, applied only if it is possible to pick up negative health:
|
||||
// Negative values are treated as positive percentages, ie Amount -100 means 100% health, ignoring max amount.
|
||||
if (P_GiveBody(other, Amount, MaxAmount))
|
||||
{
|
||||
GoAwayAndDie();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
IMPLEMENT_CLASS(AHealthPickup, false, false)
|
||||
|
||||
DEFINE_FIELD(AHealthPickup, autousemode)
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// AHealthPickup :: CreateCopy
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
AInventory *AHealthPickup::CreateCopy (AActor *other)
|
||||
{
|
||||
AInventory *copy = Super::CreateCopy (other);
|
||||
copy->health = health;
|
||||
return copy;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// AHealthPickup :: CreateTossable
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
AInventory *AHealthPickup::CreateTossable ()
|
||||
{
|
||||
AInventory *copy = Super::CreateTossable ();
|
||||
if (copy != NULL)
|
||||
{
|
||||
copy->health = health;
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// AHealthPickup :: HandlePickup
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
bool AHealthPickup::HandlePickup (AInventory *item)
|
||||
{
|
||||
// HealthPickups that are the same type but have different health amounts
|
||||
// do not count as the same item.
|
||||
if (item->health == health)
|
||||
{
|
||||
return Super::HandlePickup (item);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// AHealthPickup :: Use
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
bool AHealthPickup::Use (bool pickup)
|
||||
{
|
||||
return P_GiveBody (Owner, health, 0);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// AHealthPickup :: Serialize
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
void AHealthPickup::Serialize(FSerializer &arc)
|
||||
{
|
||||
Super::Serialize(arc);
|
||||
auto def = (AHealthPickup*)GetDefault();
|
||||
arc("autousemode", autousemode, def->autousemode);
|
||||
}
|
||||
|
||||
42
src/g_inventory/a_health.h
Normal file
42
src/g_inventory/a_health.h
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
#pragma once
|
||||
|
||||
#include "a_pickups.h"
|
||||
|
||||
// Health is some item that gives the player health when picked up.
|
||||
class PClassHealth : public PClassInventory
|
||||
{
|
||||
DECLARE_CLASS(PClassHealth, PClassInventory)
|
||||
protected:
|
||||
public:
|
||||
PClassHealth();
|
||||
virtual void DeriveData(PClass *newclass);
|
||||
|
||||
FString LowHealthMessage;
|
||||
int LowHealth;
|
||||
};
|
||||
|
||||
class AHealth : public AInventory
|
||||
{
|
||||
DECLARE_CLASS_WITH_META(AHealth, AInventory, PClassHealth)
|
||||
|
||||
public:
|
||||
int PrevHealth;
|
||||
virtual bool TryPickup (AActor *&other);
|
||||
virtual FString PickupMessage ();
|
||||
};
|
||||
|
||||
// HealthPickup is some item that gives the player health when used.
|
||||
class AHealthPickup : public AInventory
|
||||
{
|
||||
DECLARE_CLASS (AHealthPickup, AInventory)
|
||||
public:
|
||||
int autousemode;
|
||||
|
||||
|
||||
virtual void Serialize(FSerializer &arc);
|
||||
virtual AInventory *CreateCopy (AActor *other);
|
||||
virtual AInventory *CreateTossable ();
|
||||
virtual bool HandlePickup (AInventory *item);
|
||||
virtual bool Use (bool pickup);
|
||||
};
|
||||
|
||||
|
|
@ -21,4 +21,28 @@ void P_DeinitKeyMessages ();
|
|||
int P_GetMapColorForLock (int lock);
|
||||
int P_GetMapColorForKey (AInventory *key);
|
||||
|
||||
|
||||
// PuzzleItems work in conjunction with the UsePuzzleItem special
|
||||
class PClassPuzzleItem : public PClassInventory
|
||||
{
|
||||
DECLARE_CLASS(PClassPuzzleItem, PClassInventory);
|
||||
protected:
|
||||
public:
|
||||
virtual void DeriveData(PClass *newclass);
|
||||
FString PuzzFailMessage;
|
||||
};
|
||||
|
||||
class APuzzleItem : public AInventory
|
||||
{
|
||||
DECLARE_CLASS_WITH_META(APuzzleItem, AInventory, PClassPuzzleItem)
|
||||
public:
|
||||
|
||||
bool ShouldStay ();
|
||||
bool Use (bool pickup);
|
||||
bool HandlePickup (AInventory *item);
|
||||
|
||||
int PuzzleItemNumber;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -72,114 +72,6 @@ void PClassInventory::Finalize(FStateDefinitions &statedef)
|
|||
((AActor*)Defaults)->flags |= MF_SPECIAL;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// FUNC P_GiveBody
|
||||
//
|
||||
// Returns false if the body isn't needed at all.
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
bool P_GiveBody (AActor *actor, int num, int max)
|
||||
{
|
||||
if (actor->health <= 0 || (actor->player != NULL && actor->player->playerstate == PST_DEAD))
|
||||
{ // Do not heal dead things.
|
||||
return false;
|
||||
}
|
||||
|
||||
player_t *player = actor->player;
|
||||
|
||||
num = clamp(num, -65536, 65536); // prevent overflows for bad values
|
||||
if (player != NULL)
|
||||
{
|
||||
// Max is 0 by default, preserving default behavior for P_GiveBody()
|
||||
// calls while supporting AHealth.
|
||||
if (max <= 0)
|
||||
{
|
||||
max = static_cast<APlayerPawn*>(actor)->GetMaxHealth() + player->mo->stamina;
|
||||
// [MH] First step in predictable generic morph effects
|
||||
if (player->morphTics)
|
||||
{
|
||||
if (player->MorphStyle & MORPH_FULLHEALTH)
|
||||
{
|
||||
if (!(player->MorphStyle & MORPH_ADDSTAMINA))
|
||||
{
|
||||
max -= player->mo->stamina;
|
||||
}
|
||||
}
|
||||
else // old health behaviour
|
||||
{
|
||||
max = MAXMORPHHEALTH;
|
||||
if (player->MorphStyle & MORPH_ADDSTAMINA)
|
||||
{
|
||||
max += player->mo->stamina;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// [RH] For Strife: A negative body sets you up with a percentage
|
||||
// of your full health.
|
||||
if (num < 0)
|
||||
{
|
||||
num = max * -num / 100;
|
||||
if (player->health < num)
|
||||
{
|
||||
player->health = num;
|
||||
actor->health = num;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (num > 0)
|
||||
{
|
||||
if (player->health < max)
|
||||
{
|
||||
num = int(num * G_SkillProperty(SKILLP_HealthFactor));
|
||||
if (num < 1) num = 1;
|
||||
player->health += num;
|
||||
if (player->health > max)
|
||||
{
|
||||
player->health = max;
|
||||
}
|
||||
actor->health = player->health;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Parameter value for max is ignored on monsters, preserving original
|
||||
// behaviour on AHealth as well as on existing calls to P_GiveBody().
|
||||
max = actor->SpawnHealth();
|
||||
if (num < 0)
|
||||
{
|
||||
num = max * -num / 100;
|
||||
if (actor->health < num)
|
||||
{
|
||||
actor->health = num;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (actor->health < max)
|
||||
{
|
||||
actor->health += num;
|
||||
if (actor->health > max)
|
||||
{
|
||||
actor->health = max;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(AActor, GiveBody)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(AActor);
|
||||
PARAM_INT(num);
|
||||
PARAM_INT_DEF(max);
|
||||
ACTION_RETURN_BOOL(P_GiveBody(self, num, max));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// PROC A_RestoreSpecialThing1
|
||||
|
|
@ -1379,12 +1271,6 @@ bool AInventory::DrawPowerup (int x, int y)
|
|||
return false;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
/* AArtifact implementation */
|
||||
/***************************************************************************/
|
||||
|
||||
IMPLEMENT_CLASS(APowerupGiver, false, false)
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// AInventory :: DoRespawn
|
||||
|
|
@ -1748,200 +1634,3 @@ bool ACustomInventory::TryPickup (AActor *&toucher)
|
|||
}
|
||||
return useok;
|
||||
}
|
||||
|
||||
IMPLEMENT_CLASS(PClassHealth, false, false)
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// PClassHealth Constructor
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
PClassHealth::PClassHealth()
|
||||
{
|
||||
LowHealth = 0;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// PClassHealth :: DeriveData
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
void PClassHealth::DeriveData(PClass *newclass)
|
||||
{
|
||||
assert(newclass->IsKindOf(RUNTIME_CLASS(PClassHealth)));
|
||||
Super::DeriveData(newclass);
|
||||
PClassHealth *newc = static_cast<PClassHealth *>(newclass);
|
||||
|
||||
newc->LowHealth = LowHealth;
|
||||
newc->LowHealthMessage = LowHealthMessage;
|
||||
}
|
||||
|
||||
IMPLEMENT_CLASS(AHealth, false, false)
|
||||
|
||||
DEFINE_FIELD(AHealth, PrevHealth)
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// AHealth :: PickupMessage
|
||||
//
|
||||
//===========================================================================
|
||||
FString AHealth::PickupMessage ()
|
||||
{
|
||||
int threshold = GetClass()->LowHealth;
|
||||
|
||||
if (PrevHealth < threshold)
|
||||
{
|
||||
FString message = GetClass()->LowHealthMessage;
|
||||
|
||||
if (message.IsNotEmpty())
|
||||
{
|
||||
return message;
|
||||
}
|
||||
}
|
||||
return Super::PickupMessage();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// AHealth :: TryPickup
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
bool AHealth::TryPickup (AActor *&other)
|
||||
{
|
||||
PrevHealth = other->player != NULL ? other->player->health : other->health;
|
||||
|
||||
// P_GiveBody adds one new feature, applied only if it is possible to pick up negative health:
|
||||
// Negative values are treated as positive percentages, ie Amount -100 means 100% health, ignoring max amount.
|
||||
if (P_GiveBody(other, Amount, MaxAmount))
|
||||
{
|
||||
GoAwayAndDie();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
IMPLEMENT_CLASS(AHealthPickup, false, false)
|
||||
|
||||
DEFINE_FIELD(AHealthPickup, autousemode)
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// AHealthPickup :: CreateCopy
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
AInventory *AHealthPickup::CreateCopy (AActor *other)
|
||||
{
|
||||
AInventory *copy = Super::CreateCopy (other);
|
||||
copy->health = health;
|
||||
return copy;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// AHealthPickup :: CreateTossable
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
AInventory *AHealthPickup::CreateTossable ()
|
||||
{
|
||||
AInventory *copy = Super::CreateTossable ();
|
||||
if (copy != NULL)
|
||||
{
|
||||
copy->health = health;
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// AHealthPickup :: HandlePickup
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
bool AHealthPickup::HandlePickup (AInventory *item)
|
||||
{
|
||||
// HealthPickups that are the same type but have different health amounts
|
||||
// do not count as the same item.
|
||||
if (item->health == health)
|
||||
{
|
||||
return Super::HandlePickup (item);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// AHealthPickup :: Use
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
bool AHealthPickup::Use (bool pickup)
|
||||
{
|
||||
return P_GiveBody (Owner, health);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// AHealthPickup :: Serialize
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
void AHealthPickup::Serialize(FSerializer &arc)
|
||||
{
|
||||
Super::Serialize(arc);
|
||||
auto def = (AHealthPickup*)GetDefault();
|
||||
arc("autousemode", autousemode, def->autousemode);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// ABackpack
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
IMPLEMENT_CLASS(AMapRevealer, false, false)
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// AMapRevealer :: TryPickup
|
||||
//
|
||||
// The MapRevealer doesn't actually go in your inventory. Instead, it sets
|
||||
// a flag on the level.
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
bool AMapRevealer::TryPickup (AActor *&toucher)
|
||||
{
|
||||
level.flags2 |= LEVEL2_ALLMAP;
|
||||
GoAwayAndDie ();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// AScoreItem
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
IMPLEMENT_CLASS(AScoreItem, false, false)
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// AScoreItem :: TryPickup
|
||||
//
|
||||
// Adds the value (Amount) of the item to the toucher's Score property.
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
bool AScoreItem::TryPickup (AActor *&toucher)
|
||||
{
|
||||
toucher->Score += Amount;
|
||||
GoAwayAndDie();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -169,84 +169,6 @@ public:
|
|||
bool SpecialDropAction (AActor *dropper);
|
||||
};
|
||||
|
||||
// Health is some item that gives the player health when picked up.
|
||||
class PClassHealth : public PClassInventory
|
||||
{
|
||||
DECLARE_CLASS(PClassHealth, PClassInventory)
|
||||
protected:
|
||||
public:
|
||||
PClassHealth();
|
||||
virtual void DeriveData(PClass *newclass);
|
||||
|
||||
FString LowHealthMessage;
|
||||
int LowHealth;
|
||||
};
|
||||
|
||||
class AHealth : public AInventory
|
||||
{
|
||||
DECLARE_CLASS_WITH_META(AHealth, AInventory, PClassHealth)
|
||||
|
||||
public:
|
||||
int PrevHealth;
|
||||
virtual bool TryPickup (AActor *&other);
|
||||
virtual FString PickupMessage ();
|
||||
};
|
||||
|
||||
// HealthPickup is some item that gives the player health when used.
|
||||
class AHealthPickup : public AInventory
|
||||
{
|
||||
DECLARE_CLASS (AHealthPickup, AInventory)
|
||||
public:
|
||||
int autousemode;
|
||||
|
||||
|
||||
virtual void Serialize(FSerializer &arc);
|
||||
virtual AInventory *CreateCopy (AActor *other);
|
||||
virtual AInventory *CreateTossable ();
|
||||
virtual bool HandlePickup (AInventory *item);
|
||||
virtual bool Use (bool pickup);
|
||||
};
|
||||
|
||||
// PuzzleItems work in conjunction with the UsePuzzleItem special
|
||||
class PClassPuzzleItem : public PClassInventory
|
||||
{
|
||||
DECLARE_CLASS(PClassPuzzleItem, PClassInventory);
|
||||
protected:
|
||||
public:
|
||||
virtual void DeriveData(PClass *newclass);
|
||||
FString PuzzFailMessage;
|
||||
};
|
||||
|
||||
class APuzzleItem : public AInventory
|
||||
{
|
||||
DECLARE_CLASS_WITH_META(APuzzleItem, AInventory, PClassPuzzleItem)
|
||||
public:
|
||||
|
||||
bool ShouldStay ();
|
||||
bool Use (bool pickup);
|
||||
bool HandlePickup (AInventory *item);
|
||||
|
||||
int PuzzleItemNumber;
|
||||
};
|
||||
|
||||
// A MapRevealer reveals the whole map for the player who picks it up.
|
||||
class AMapRevealer : public AInventory
|
||||
{
|
||||
DECLARE_CLASS (AMapRevealer, AInventory)
|
||||
public:
|
||||
bool TryPickup (AActor *&toucher);
|
||||
};
|
||||
|
||||
// A score item is picked up without being added to the inventory.
|
||||
// It differs from FakeInventory by doing nothing more than increasing the player's score.
|
||||
class AScoreItem : public AInventory
|
||||
{
|
||||
DECLARE_CLASS (AScoreItem, AInventory)
|
||||
|
||||
public:
|
||||
bool TryPickup(AActor *&toucher);
|
||||
};
|
||||
|
||||
extern PClassActor *QuestItemClasses[31];
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@
|
|||
#include "c_console.h"
|
||||
#include "doomstat.h"
|
||||
#include "v_font.h"
|
||||
#include "a_keys.h"
|
||||
|
||||
|
||||
IMPLEMENT_CLASS(PClassPuzzleItem, false, false)
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@
|
|||
#include "thingdef.h"
|
||||
#include "math/cmath.h"
|
||||
#include "a_armor.h"
|
||||
#include "a_health.h"
|
||||
|
||||
AActor *SingleActorFromTID(int tid, AActor *defactor);
|
||||
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@
|
|||
#include "d_netinf.h"
|
||||
#include "a_morph.h"
|
||||
#include "virtual.h"
|
||||
#include "a_health.h"
|
||||
|
||||
static FRandom pr_obituary ("Obituary");
|
||||
static FRandom pr_botrespawn ("BotRespawn");
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@
|
|||
#include "virtual.h"
|
||||
#include "a_armor.h"
|
||||
#include "a_ammo.h"
|
||||
#include "a_health.h"
|
||||
|
||||
// MACROS ------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -2248,16 +2248,7 @@ FxExpression *FxAssign::Resolve(FCompileContext &ctx)
|
|||
}
|
||||
|
||||
// Special case: Assignment to a bitfield.
|
||||
if (Base->ExprType == EFX_StructMember || Base->ExprType == EFX_ClassMember)
|
||||
{
|
||||
auto f = static_cast<FxStructMember *>(Base)->membervar;
|
||||
if (f->BitValue != -1 && !ctx.CheckReadOnly(f->Flags))
|
||||
{
|
||||
IsBitWrite = f->BitValue;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
IsBitWrite = Base->GetBitValue();
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
@ -5743,6 +5734,11 @@ FxExpression *FxMemberIdentifier::Resolve(FCompileContext& ctx)
|
|||
|
||||
SAFE_RESOLVE(Object, ctx);
|
||||
|
||||
if (Identifier == FName("allmap"))
|
||||
{
|
||||
int a = 2;
|
||||
}
|
||||
|
||||
// check for class or struct constants if the left side is a type name.
|
||||
if (Object->ValueType == TypeError)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -318,6 +318,7 @@ public:
|
|||
virtual PPrototype *ReturnProto();
|
||||
virtual VMFunction *GetDirectFunction();
|
||||
virtual bool CheckReturn() { return false; }
|
||||
virtual int GetBitValue() { return -1; }
|
||||
bool IsNumeric() const { return ValueType->isNumeric(); }
|
||||
bool IsFloat() const { return ValueType->GetRegType() == REGT_FLOAT && ValueType->GetRegCount() == 1; }
|
||||
bool IsInteger() const { return ValueType->isNumeric() && (ValueType->GetRegType() == REGT_INT); }
|
||||
|
|
@ -1266,6 +1267,7 @@ public:
|
|||
FxExpression *Resolve(FCompileContext&);
|
||||
bool RequestAddress(FCompileContext &ctx, bool *writable);
|
||||
ExpEmit Emit(VMFunctionBuilder *build);
|
||||
virtual int GetBitValue() { return membervar->BitValue; }
|
||||
};
|
||||
|
||||
class FxCVar : public FxExpression
|
||||
|
|
@ -1296,6 +1298,7 @@ public:
|
|||
FxExpression *Resolve(FCompileContext&);
|
||||
bool RequestAddress(FCompileContext &ctx, bool *writable);
|
||||
ExpEmit Emit(VMFunctionBuilder *build);
|
||||
virtual int GetBitValue() { return membervar->BitValue; }
|
||||
};
|
||||
|
||||
//==========================================================================
|
||||
|
|
@ -1349,6 +1352,7 @@ public:
|
|||
FxExpression *Resolve(FCompileContext&);
|
||||
bool RequestAddress(FCompileContext &ctx, bool *writable);
|
||||
ExpEmit Emit(VMFunctionBuilder *build);
|
||||
virtual int GetBitValue() { return membervar->BitValue; }
|
||||
};
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
|||
|
|
@ -71,6 +71,8 @@
|
|||
#include "a_weaponpiece.h"
|
||||
#include "vmbuilder.h"
|
||||
#include "a_ammo.h"
|
||||
#include "a_health.h"
|
||||
#include "a_keys.h"
|
||||
|
||||
extern TArray<PClassActor **> OptionalClassPtrs;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue