From 03c7b10fd66769f747a2ed4458069674621a471f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 15 Jan 2017 18:46:40 +0100 Subject: [PATCH] - fully scriptified HealthPickup. --- src/b_think.cpp | 1 - src/d_dehacked.cpp | 1 - src/dobjtype.cpp | 1 - src/g_inventory/a_health.cpp | 63 ---------------------- src/g_inventory/a_health.h | 14 ----- src/namedef.h | 2 + src/p_actionfunctions.cpp | 1 - src/p_interaction.cpp | 12 ++--- src/p_mobj.cpp | 1 - src/scripting/thingdef_properties.cpp | 10 ---- wadsrc/static/zscript/inventory/health.txt | 6 ++- 11 files changed, 12 insertions(+), 100 deletions(-) delete mode 100644 src/g_inventory/a_health.cpp delete mode 100644 src/g_inventory/a_health.h diff --git a/src/b_think.cpp b/src/b_think.cpp index fa6938571..1501a03ac 100644 --- a/src/b_think.cpp +++ b/src/b_think.cpp @@ -22,7 +22,6 @@ #include "d_player.h" #include "vectors.h" #include "a_ammo.h" -#include "a_health.h" static FRandom pr_botmove ("BotMove"); diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index aea955b8a..7b43de020 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -76,7 +76,6 @@ #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 diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index d289847e1..6e42e2919 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -51,7 +51,6 @@ #include "doomerrors.h" #include "fragglescript/t_fs.h" #include "a_keys.h" -#include "a_health.h" // MACROS ------------------------------------------------------------------ diff --git a/src/g_inventory/a_health.cpp b/src/g_inventory/a_health.cpp deleted file mode 100644 index 005e0f399..000000000 --- a/src/g_inventory/a_health.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* -** 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" -#include "p_local.h" - -//=========================================================================== -// -// Classes -// -//=========================================================================== - -IMPLEMENT_CLASS(AHealthPickup, false, false) -DEFINE_FIELD(AHealthPickup, autousemode) - -//=========================================================================== -// -// AHealthPickup :: Serialize -// -//=========================================================================== - -void AHealthPickup::Serialize(FSerializer &arc) -{ - Super::Serialize(arc); - auto def = (AHealthPickup*)GetDefault(); - arc("autousemode", autousemode, def->autousemode); -} - diff --git a/src/g_inventory/a_health.h b/src/g_inventory/a_health.h deleted file mode 100644 index c44d13659..000000000 --- a/src/g_inventory/a_health.h +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include "a_pickups.h" - -// 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) override; -}; - diff --git a/src/namedef.h b/src/namedef.h index 61430219b..dc52d27f1 100644 --- a/src/namedef.h +++ b/src/namedef.h @@ -168,6 +168,8 @@ xx(Mauler) xx(BackpackItem) xx(PuzzleItem) xx(PuzzleItemNumber) +xx(HealthPickup) +xx(autousemode) xx(AcolyteBlue) xx(SpectralLightningV1) diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index 5d4e83f73..3c7eeca07 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -79,7 +79,6 @@ #include "thingdef.h" #include "math/cmath.h" #include "a_armor.h" -#include "a_health.h" #include "g_levellocals.h" AActor *SingleActorFromTID(int tid, AActor *defactor); diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index 43cafeebc..f61e77630 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -59,7 +59,6 @@ #include "d_netinf.h" #include "a_morph.h" #include "virtual.h" -#include "a_health.h" #include "g_levellocals.h" static FRandom pr_obituary ("Obituary"); @@ -840,11 +839,12 @@ void P_AutoUseHealth(player_t *player, int saveHealth) TArray NormalHealthItems; TArray LargeHealthItems; + auto hptype = PClass::FindActor(NAME_HealthPickup); for(AInventory *inv = player->mo->Inventory; inv != NULL; inv = inv->Inventory) { - if (inv->Amount > 0 && inv->IsKindOf(RUNTIME_CLASS(AHealthPickup))) + if (inv->Amount > 0 && inv->IsKindOf(hptype)) { - int mode = static_cast(inv)->autousemode; + int mode = inv->IntVar(NAME_autousemode); if (mode == 1) NormalHealthItems.Push(inv); else if (mode == 2) LargeHealthItems.Push(inv); @@ -884,12 +884,12 @@ void P_AutoUseStrifeHealth (player_t *player) { TArray Items; + auto hptype = PClass::FindActor(NAME_HealthPickup); for(AInventory *inv = player->mo->Inventory; inv != NULL; inv = inv->Inventory) { - if (inv->Amount > 0 && inv->IsKindOf(RUNTIME_CLASS(AHealthPickup))) + if (inv->Amount > 0 && inv->IsKindOf(hptype)) { - int mode = static_cast(inv)->autousemode; - + int mode = inv->IntVar(NAME_autousemode); if (mode == 3) Items.Push(inv); } } diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 21b2d8563..fc382a988 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -71,7 +71,6 @@ #include "virtual.h" #include "a_armor.h" #include "a_ammo.h" -#include "a_health.h" #include "g_levellocals.h" #include "a_morph.h" diff --git a/src/scripting/thingdef_properties.cpp b/src/scripting/thingdef_properties.cpp index 6d6c166a4..db24349cb 100644 --- a/src/scripting/thingdef_properties.cpp +++ b/src/scripting/thingdef_properties.cpp @@ -71,7 +71,6 @@ #include "a_weaponpiece.h" #include "vmbuilder.h" #include "a_ammo.h" -#include "a_health.h" #include "a_keys.h" #include "g_levellocals.h" @@ -1969,15 +1968,6 @@ DEFINE_CLASS_PROPERTY(givequest, I, Inventory) static_cast(info)->GiveQuest = i; } -//========================================================================== -// -//========================================================================== -DEFINE_CLASS_PROPERTY(autouse, I, HealthPickup) -{ - PROP_INT_PARM(i, 0); - defaults->autousemode = i; -} - //========================================================================== // //========================================================================== diff --git a/wadsrc/static/zscript/inventory/health.txt b/wadsrc/static/zscript/inventory/health.txt index 81ffeb164..88bf6b133 100644 --- a/wadsrc/static/zscript/inventory/health.txt +++ b/wadsrc/static/zscript/inventory/health.txt @@ -89,9 +89,11 @@ class Health : Inventory } -class HealthPickup : Inventory native +class HealthPickup : Inventory { - native int autousemode; + int autousemode; + + property AutoUse: autousemode; Default {