From b0f3121bec0e9b265b11f002f93a18f8ffa829d2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 30 Nov 2016 13:36:13 +0100 Subject: [PATCH] - 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. --- src/CMakeLists.txt | 1 + src/b_think.cpp | 1 + src/d_dehacked.cpp | 1 + src/d_net.cpp | 1 + src/dobjtype.cpp | 2 + src/g_inventory/a_artifacts.cpp | 2 + src/g_inventory/a_health.cpp | 301 ++++++++++ src/g_inventory/a_health.h | 42 ++ src/g_inventory/a_keys.h | 24 + src/g_inventory/a_pickups.cpp | 311 ---------- src/g_inventory/a_pickups.h | 78 --- src/g_inventory/a_puzzleitems.cpp | 1 + src/p_actionfunctions.cpp | 1 + src/p_interaction.cpp | 1 + src/p_mobj.cpp | 1 + src/scripting/codegeneration/codegen.cpp | 16 +- src/scripting/codegeneration/codegen.h | 4 + src/scripting/thingdef_properties.cpp | 2 + wadsrc/static/zscript.txt | 6 +- wadsrc/static/zscript/shared/armor.txt | 72 +++ wadsrc/static/zscript/shared/inv_misc.txt | 87 +++ wadsrc/static/zscript/shared/inventory.txt | 560 +----------------- .../shared/{pickups.txt => itemeffects.txt} | 0 wadsrc/static/zscript/shared/powerups.txt | 282 +++++++++ wadsrc/static/zscript/shared/weapons.txt | 144 +++++ 25 files changed, 982 insertions(+), 959 deletions(-) create mode 100644 src/g_inventory/a_health.cpp create mode 100644 src/g_inventory/a_health.h create mode 100644 wadsrc/static/zscript/shared/armor.txt create mode 100644 wadsrc/static/zscript/shared/inv_misc.txt rename wadsrc/static/zscript/shared/{pickups.txt => itemeffects.txt} (100%) create mode 100644 wadsrc/static/zscript/shared/powerups.txt create mode 100644 wadsrc/static/zscript/shared/weapons.txt diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1265544963..83dad3b9d1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 diff --git a/src/b_think.cpp b/src/b_think.cpp index 7dd196622b..e41433fa30 100644 --- a/src/b_think.cpp +++ b/src/b_think.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"); diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index 62daefcaa9..c0ea00f5e3 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -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 diff --git a/src/d_net.cpp b/src/d_net.cpp index 2611338679..4bda255103 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -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) diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index 7377af56b7..dba5544982 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -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 ------------------------------------------------------------------ diff --git a/src/g_inventory/a_artifacts.cpp b/src/g_inventory/a_artifacts.cpp index 5866e8b2ae..1198b91531 100644 --- a/src/g_inventory/a_artifacts.cpp +++ b/src/g_inventory/a_artifacts.cpp @@ -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) diff --git a/src/g_inventory/a_health.cpp b/src/g_inventory/a_health.cpp new file mode 100644 index 0000000000..58cd86e2a5 --- /dev/null +++ b/src/g_inventory/a_health.cpp @@ -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(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(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); +} + diff --git a/src/g_inventory/a_health.h b/src/g_inventory/a_health.h new file mode 100644 index 0000000000..a462bbfbda --- /dev/null +++ b/src/g_inventory/a_health.h @@ -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); +}; + diff --git a/src/g_inventory/a_keys.h b/src/g_inventory/a_keys.h index 8222aa6942..fd46b416c1 100644 --- a/src/g_inventory/a_keys.h +++ b/src/g_inventory/a_keys.h @@ -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 diff --git a/src/g_inventory/a_pickups.cpp b/src/g_inventory/a_pickups.cpp index 84b8b366fe..cf5dddcf3f 100644 --- a/src/g_inventory/a_pickups.cpp +++ b/src/g_inventory/a_pickups.cpp @@ -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(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(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; -} - diff --git a/src/g_inventory/a_pickups.h b/src/g_inventory/a_pickups.h index 00a8e6546d..b366a60318 100644 --- a/src/g_inventory/a_pickups.h +++ b/src/g_inventory/a_pickups.h @@ -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]; diff --git a/src/g_inventory/a_puzzleitems.cpp b/src/g_inventory/a_puzzleitems.cpp index e2a538387d..7617f63833 100644 --- a/src/g_inventory/a_puzzleitems.cpp +++ b/src/g_inventory/a_puzzleitems.cpp @@ -42,6 +42,7 @@ #include "c_console.h" #include "doomstat.h" #include "v_font.h" +#include "a_keys.h" IMPLEMENT_CLASS(PClassPuzzleItem, false, false) diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index 8981538e77..bc217f4ae5 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -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); diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index e0e3e62b9a..eae7edb00e 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -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"); diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 2d36136f34..572c7656f9 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -71,6 +71,7 @@ #include "virtual.h" #include "a_armor.h" #include "a_ammo.h" +#include "a_health.h" // MACROS ------------------------------------------------------------------ diff --git a/src/scripting/codegeneration/codegen.cpp b/src/scripting/codegeneration/codegen.cpp index 7408573a00..eaeca6e9d6 100644 --- a/src/scripting/codegeneration/codegen.cpp +++ b/src/scripting/codegeneration/codegen.cpp @@ -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(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) { diff --git a/src/scripting/codegeneration/codegen.h b/src/scripting/codegeneration/codegen.h index 5d0af0b49a..c54c8dc62a 100644 --- a/src/scripting/codegeneration/codegen.h +++ b/src/scripting/codegeneration/codegen.h @@ -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; } }; //========================================================================== diff --git a/src/scripting/thingdef_properties.cpp b/src/scripting/thingdef_properties.cpp index e87602114b..9bff91a805 100644 --- a/src/scripting/thingdef_properties.cpp +++ b/src/scripting/thingdef_properties.cpp @@ -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 OptionalClassPtrs; diff --git a/wadsrc/static/zscript.txt b/wadsrc/static/zscript.txt index 82810185a3..a2b89da013 100644 --- a/wadsrc/static/zscript.txt +++ b/wadsrc/static/zscript.txt @@ -4,6 +4,10 @@ zscript/actor.txt zscript/actor_checks.txt zscript/shared/inventory.txt +zscript/shared/inv_misc.txt +zscript/shared/weapons.txt +zscript/shared/armor.txt +zscript/shared/powerups.txt zscript/shared/player.txt zscript/shared/morph.txt zscript/shared/botstuff.txt @@ -12,7 +16,7 @@ zscript/shared/blood.txt zscript/shared/debris.txt zscript/shared/decal.txt zscript/shared/splashes.txt -zscript/shared/pickups.txt +zscript/shared/itemeffects.txt zscript/shared/fountain.txt zscript/shared/spark.txt zscript/shared/soundsequence.txt diff --git a/wadsrc/static/zscript/shared/armor.txt b/wadsrc/static/zscript/shared/armor.txt new file mode 100644 index 0000000000..3e7f57e21c --- /dev/null +++ b/wadsrc/static/zscript/shared/armor.txt @@ -0,0 +1,72 @@ +class Armor : Inventory native +{ + Default + { + Inventory.PickupSound "misc/armor_pkup"; + } +} + +class BasicArmor : Armor native +{ + + native int AbsorbCount; + native double SavePercent; + native int MaxAbsorb; + native int MaxFullAbsorb; + native int BonusCount; + native Name ArmorType; + native int ActualSaveAmount; + + Default + { + +Inventory.KEEPDEPLETED + } +} + +class BasicArmorBonus : Armor native +{ + native double SavePercent; // The default, for when you don't already have armor + native int MaxSaveAmount; + native int MaxAbsorb; + native int MaxFullAbsorb; + native int SaveAmount; + native int BonusCount; + native int BonusMax; + + Default + { + +Inventory.AUTOACTIVATE + +Inventory.ALWAYSPICKUP + Inventory.MaxAmount 0; + Armor.SavePercent 33.335; + } +} + +class BasicArmorPickup : Armor native +{ + + native double SavePercent; + native int MaxAbsorb; + native int MaxFullAbsorb; + native int SaveAmount; + + Default + { + +Inventory.AUTOACTIVATE; + Inventory.MaxAmount 0; + } +} + +class HexenArmor : Armor native +{ + + native double Slots[5]; + native double SlotsIncrement[4]; + + Default + { + +Inventory.KEEPDEPLETED + +Inventory.UNDROPPABLE + } +} + diff --git a/wadsrc/static/zscript/shared/inv_misc.txt b/wadsrc/static/zscript/shared/inv_misc.txt new file mode 100644 index 0000000000..032c9e8266 --- /dev/null +++ b/wadsrc/static/zscript/shared/inv_misc.txt @@ -0,0 +1,87 @@ +class ScoreItem : Inventory +{ + Default + { + Height 10; + +COUNTITEM + Inventory.Amount 1; + +Inventory.ALWAYSPICKUP + } + + override bool TryPickup (in out Actor toucher) + { + toucher.Score += Amount; + GoAwayAndDie(); + return true; + } +} + +class Health : Inventory native +{ + native int PrevHealth; + + Default + { + Inventory.Amount 1; + Inventory.MaxAmount 0; + Inventory.PickupSound "misc/health_pkup"; + } +} + +class HealthPickup : Inventory native +{ + native int autousemode; + + Default + { + Inventory.DefMaxAmount; + +INVENTORY.INVBAR + } +} + +class Key : Inventory native +{ + native uint8 KeyNumber; + + Default + { + +DONTGIB; // Don't disappear due to a crusher + Inventory.InterHubAmount 0; + Inventory.PickupSound "misc/k_pkup"; + } +} + +class MapRevealer : Inventory +{ + //=========================================================================== + // + // AMapRevealer :: TryPickup + // + // A MapRevealer reveals the whole map for the player who picks it up. + // The MapRevealer doesn't actually go in your inventory. Instead, it sets + // a flag on the level. + // + //=========================================================================== + + override bool TryPickup (in out Actor toucher) + { + level.allmap = true; + GoAwayAndDie (); + return true; + } +} + +class PuzzleItem : Inventory native +{ + native int PuzzleItemNumber; + + Default + { + +NOGRAVITY + +INVENTORY.INVBAR + Inventory.DefMaxAmount; + Inventory.UseSound "PuzzleSuccess"; + Inventory.PickupSound "misc/i_pkup"; + } +} + diff --git a/wadsrc/static/zscript/shared/inventory.txt b/wadsrc/static/zscript/shared/inventory.txt index 5192b4c93b..4e5c13d888 100644 --- a/wadsrc/static/zscript/shared/inventory.txt +++ b/wadsrc/static/zscript/shared/inventory.txt @@ -87,108 +87,10 @@ class StateProvider : Inventory native action native void A_ResetReloadCounter(); } -class ScoreItem : Inventory native +class DehackedPickup : Inventory native { - Default - { - Height 10; - +COUNTITEM - Inventory.Amount 1; - +Inventory.ALWAYSPICKUP - } } -class Ammo : Inventory native -{ - native int BackpackAmount; - native int BackpackMaxAmount; - - Default - { - +INVENTORY.KEEPDEPLETED - Inventory.PickupSound "misc/ammo_pkup"; - } -} - -class BackpackItem : Inventory native -{ - native bool bDepleted; -} - -class Armor : Inventory native -{ - Default - { - Inventory.PickupSound "misc/armor_pkup"; - } -} - -class BasicArmor : Armor native -{ - - native int AbsorbCount; - native double SavePercent; - native int MaxAbsorb; - native int MaxFullAbsorb; - native int BonusCount; - native Name ArmorType; - native int ActualSaveAmount; - - Default - { - +Inventory.KEEPDEPLETED - } -} - -class BasicArmorBonus : Armor native -{ - native double SavePercent; // The default, for when you don't already have armor - native int MaxSaveAmount; - native int MaxAbsorb; - native int MaxFullAbsorb; - native int SaveAmount; - native int BonusCount; - native int BonusMax; - - Default - { - +Inventory.AUTOACTIVATE - +Inventory.ALWAYSPICKUP - Inventory.MaxAmount 0; - Armor.SavePercent 33.335; - } -} - -class BasicArmorPickup : Armor native -{ - - native double SavePercent; - native int MaxAbsorb; - native int MaxFullAbsorb; - native int SaveAmount; - - Default - { - +Inventory.AUTOACTIVATE; - Inventory.MaxAmount 0; - } -} - -class HexenArmor : Armor native -{ - - native double Slots[5]; - native double SlotsIncrement[4]; - - Default - { - +Inventory.KEEPDEPLETED - +Inventory.UNDROPPABLE - } -} - -class DehackedPickup : Inventory native {} - class FakeInventory : Inventory native { native bool Respawnable; @@ -201,463 +103,3 @@ class CustomInventory : StateProvider native DefaultStateUsage SUF_ACTOR|SUF_OVERLAY|SUF_ITEM; } } - -class Health : Inventory native -{ - native int PrevHealth; - - Default - { - Inventory.Amount 1; - Inventory.MaxAmount 0; - Inventory.PickupSound "misc/health_pkup"; - } -} - -class HealthPickup : Inventory native -{ - native int autousemode; - - Default - { - Inventory.DefMaxAmount; - +INVENTORY.INVBAR - } -} - -class Key : Inventory native -{ - native uint8 KeyNumber; - - Default - { - +DONTGIB; // Don't disappear due to a crusher - Inventory.InterHubAmount 0; - Inventory.PickupSound "misc/k_pkup"; - } -} - -class PowerupGiver : Inventory native -{ - - native Class PowerupType; - native int EffectTics; // Non-0 to override the powerup's default tics - native color BlendColor; // Non-0 to override the powerup's default blend - native Name Mode; // Meaning depends on powerup - used for Invulnerability and Invisibility - native double Strength; // Meaning depends on powerup - currently used only by Invisibility - - Default - { - Inventory.DefMaxAmount; - +INVENTORY.INVBAR - +INVENTORY.FANCYPICKUPSOUND - Inventory.PickupSound "misc/p_pkup"; - } -} - -class Powerup : Inventory native -{ - native int EffectTics; - native color BlendColor; - native Name Mode; // Meaning depends on powerup - used for Invulnerability and Invisibility - native double Strength; // Meaning depends on powerup - currently used only by Invisibility -} - -class PowerInvulnerable : Powerup native -{ - Default - { - Powerup.Duration -30; - inventory.icon "SPSHLD0"; - } -} - -class PowerStrength : Powerup native -{ - Default - { - Powerup.Duration 1; - Powerup.Color "ff 00 00", 0.5; - +INVENTORY.HUBPOWER - } -} - -class PowerInvisibility : Powerup native -{ - Default - { - +SHADOW; - Powerup.Duration -60; - Powerup.Strength 80; - Powerup.Mode "Fuzzy"; - } -} - -class PowerGhost : PowerInvisibility -{ - Default - { - +GHOST; - Powerup.Duration -60; - Powerup.Strength 60; - Powerup.Mode "None"; - } -} - -class PowerShadow : PowerInvisibility -{ - Default - { - +INVENTORY.HUBPOWER - Powerup.Duration -55; - Powerup.Strength 75; - Powerup.Mode "Cumulative"; - } -} - -class PowerIronFeet : Powerup native -{ - Default - { - Powerup.Duration -60; - Powerup.Color "00 ff 00", 0.125; - } -} - -class PowerMask : PowerIronFeet native -{ - Default - { - Powerup.Duration -80; - Powerup.Color "00 00 00", 0; - +INVENTORY.HUBPOWER - Inventory.Icon "I_MASK"; - } -} - -class PowerLightAmp : Powerup native -{ - Default - { - Powerup.Duration -120; - } -} - -class PowerTorch : PowerLightAmp native {} - -class PowerFlight : Powerup native -{ - Default - { - Powerup.Duration -60; - +INVENTORY.HUBPOWER - } -} - -class PowerWeaponLevel2 : Powerup native -{ - Default - { - Powerup.Duration -40; - Inventory.Icon "SPINBK0"; - +INVENTORY.NOTELEPORTFREEZE - } -} - -class PowerSpeed : Powerup native -{ - native int SpeedFlags; - - Default - { - Powerup.Duration -45; - Speed 1.5; - Inventory.Icon "SPBOOT0"; - +INVENTORY.NOTELEPORTFREEZE - } -} - -// Player Speed Trail (used by the Speed Powerup) ---------------------------- - -class PlayerSpeedTrail : Actor -{ - Default - { - +NOBLOCKMAP - +NOGRAVITY - Alpha 0.6; - RenderStyle "Translucent"; - } - - override void Tick() - { - Alpha -= .6 / 8; - if (Alpha <= 0) - { - Destroy (); - } - } -} - -class PowerMinotaur : Powerup native -{ - Default - { - Powerup.Duration -25; - Inventory.Icon "SPMINO0"; - } -} - -class PowerTargeter : Powerup native -{ - Default - { - Powerup.Duration -160; - +INVENTORY.HUBPOWER - } - States - { - Targeter: - TRGT A -1; - Stop; - TRGT B -1; - Stop; - TRGT C -1; - Stop; - } -} - -class PowerFrightener : Powerup native -{ - Default - { - Powerup.Duration -60; - } -} - -class PowerBuddha : Powerup native -{ - Default - { - Powerup.Duration -60; - } -} - -class PowerScanner : Powerup native -{ - Default - { - Powerup.Duration -80; - +INVENTORY.HUBPOWER - } -} - -class PowerTimeFreezer : Powerup native -{ - Default - { - Powerup.Duration -12; - } -} - -class PowerDamage : Powerup native -{ - Default - { - Powerup.Duration -25; - } -} - -class PowerProtection : Powerup native -{ - Default - { - Powerup.Duration -25; - } -} - -class PowerDrain : Powerup native -{ - Default - { - Powerup.Duration -60; - } -} - -class PowerRegeneration : Powerup native -{ - Default - { - Powerup.Duration -120; - Powerup.Strength 5; - } -} - -class PowerHighJump : Powerup native {} - -class PowerDoubleFiringSpeed : Powerup native {} - -class PowerMorph : Powerup native -{ - native Class PlayerClass; - native Class MorphFlash, UnMorphFlash; - native int MorphStyle; - native PlayerInfo MorphedPlayer; - native bool bInUndoMorph; - - Default - { - Powerup.Duration -40; - } -} - -class PowerInfiniteAmmo : Powerup native -{ - Default - { - Powerup.Duration -30; - } -} - -class MapRevealer : Inventory native {} - -class PuzzleItem : Inventory native -{ - native int PuzzleItemNumber; - - Default - { - +NOGRAVITY - +INVENTORY.INVBAR - Inventory.DefMaxAmount; - Inventory.UseSound "PuzzleSuccess"; - Inventory.PickupSound "misc/i_pkup"; - } -} - -class Weapon : StateProvider native -{ - enum EFireMode - { - PrimaryFire, - AltFire, - EitherFire - }; - - native uint WeaponFlags; - native class AmmoType1, AmmoType2; // Types of ammo used by this weapon - native int AmmoGive1, AmmoGive2; // Amount of each ammo to get when picking up weapon - native int MinAmmo1, MinAmmo2; // Minimum ammo needed to switch to this weapon - native int AmmoUse1, AmmoUse2; // How much ammo to use with each shot - native int Kickback; - native float YAdjust; // For viewing the weapon fullscreen (visual only so no need to be a double) - native sound UpSound, ReadySound; // Sounds when coming up and idle - native class SisterWeaponType; // Another weapon to pick up with this one - native class ProjectileType; // Projectile used by primary attack - native class AltProjectileType; // Projectile used by alternate attack - native int SelectionOrder; // Lower-numbered weapons get picked first - native int MinSelAmmo1, MinSelAmmo2; // Ignore in BestWeapon() if inadequate ammo - native double MoveCombatDist; // Used by bots, but do they *really* need it? - native int ReloadCounter; // For A_CheckForReload - native int BobStyle; // [XA] Bobbing style. Defines type of bobbing (e.g. Normal, Alpha) (visual only so no need to be a double) - native float BobSpeed; // [XA] Bobbing speed. Defines how quickly a weapon bobs. - native float BobRangeX, BobRangeY; // [XA] Bobbing range. Defines how far a weapon bobs in either direction. - native Ammo Ammo1, Ammo2; // In-inventory instance variables - native Weapon SisterWeapon; - native float FOVScale; - native int Crosshair; // 0 to use player's crosshair - native bool GivenAsMorphWeapon; - native bool bAltFire; // Set when this weapon's alternate fire is used. - native readonly bool bDehAmmo; - - Default - { - Inventory.PickupSound "misc/w_pkup"; - Weapon.DefaultKickback; - Weapon.BobSpeed 1.0; - Weapon.BobRangeX 1.0; - Weapon.BobRangeY 1.0; - +WEAPONSPAWN - DefaultStateUsage SUF_ACTOR|SUF_OVERLAY|SUF_WEAPON; - } - States - { - LightDone: - SHTG E 0 A_Light0; - Stop; - } - - native bool CheckAmmo(int fireMode, bool autoSwitch, bool requireAmmo = false, int ammocount = -1); - native bool DepleteAmmo(bool altFire, bool checkEnough = true, int ammouse = -1); - native virtual void EndPowerup(); - - virtual State GetReadyState () - { - return FindState('Ready'); - } - - virtual State GetUpState () - { - return FindState('Select'); - } - - virtual State GetDownState () - { - return FindState('Deselect'); - } - - virtual State GetAtkState (bool hold) - { - State s = null; - if (hold) s = FindState('Hold'); - if (s == null) s = FindState('Fire'); - return s; - } - - virtual State GetAltAtkState (bool hold) - { - State s = null; - if (hold) s = FindState('AltHold'); - if (s == null) s = FindState('AltFire'); - return s; - } - - native action void A_ZoomFactor(double scale = 1, int flags = 0); - native action void A_SetCrosshair(int xhair); - const ZOOM_INSTANT = 1; - const ZOOM_NOSCALETURNING = 2; - -} - -class WeaponGiver : Weapon native -{ - - native double DropAmmoFactor; - - Default - { - Weapon.AmmoGive1 -1; - Weapon.AmmoGive2 -1; - } -} - -class WeaponHolder : Inventory native -{ - native int PieceMask; - native Class PieceWeapon; - - Default - { - +NOBLOCKMAP - +NOSECTOR - +INVENTORY.UNDROPPABLE - } -} - -class WeaponPiece : Inventory native -{ - Default - { - +WEAPONSPAWN; - } -} diff --git a/wadsrc/static/zscript/shared/pickups.txt b/wadsrc/static/zscript/shared/itemeffects.txt similarity index 100% rename from wadsrc/static/zscript/shared/pickups.txt rename to wadsrc/static/zscript/shared/itemeffects.txt diff --git a/wadsrc/static/zscript/shared/powerups.txt b/wadsrc/static/zscript/shared/powerups.txt new file mode 100644 index 0000000000..4c7a84efe6 --- /dev/null +++ b/wadsrc/static/zscript/shared/powerups.txt @@ -0,0 +1,282 @@ +class PowerupGiver : Inventory native +{ + + native Class PowerupType; + native int EffectTics; // Non-0 to override the powerup's default tics + native color BlendColor; // Non-0 to override the powerup's default blend + native Name Mode; // Meaning depends on powerup - used for Invulnerability and Invisibility + native double Strength; // Meaning depends on powerup - currently used only by Invisibility + + Default + { + Inventory.DefMaxAmount; + +INVENTORY.INVBAR + +INVENTORY.FANCYPICKUPSOUND + Inventory.PickupSound "misc/p_pkup"; + } +} + +class Powerup : Inventory native +{ + native int EffectTics; + native color BlendColor; + native Name Mode; // Meaning depends on powerup - used for Invulnerability and Invisibility + native double Strength; // Meaning depends on powerup - currently used only by Invisibility +} + +class PowerInvulnerable : Powerup native +{ + Default + { + Powerup.Duration -30; + inventory.icon "SPSHLD0"; + } +} + +class PowerStrength : Powerup native +{ + Default + { + Powerup.Duration 1; + Powerup.Color "ff 00 00", 0.5; + +INVENTORY.HUBPOWER + } +} + +class PowerInvisibility : Powerup native +{ + Default + { + +SHADOW; + Powerup.Duration -60; + Powerup.Strength 80; + Powerup.Mode "Fuzzy"; + } +} + +class PowerGhost : PowerInvisibility +{ + Default + { + +GHOST; + Powerup.Duration -60; + Powerup.Strength 60; + Powerup.Mode "None"; + } +} + +class PowerShadow : PowerInvisibility +{ + Default + { + +INVENTORY.HUBPOWER + Powerup.Duration -55; + Powerup.Strength 75; + Powerup.Mode "Cumulative"; + } +} + +class PowerIronFeet : Powerup native +{ + Default + { + Powerup.Duration -60; + Powerup.Color "00 ff 00", 0.125; + } +} + +class PowerMask : PowerIronFeet native +{ + Default + { + Powerup.Duration -80; + Powerup.Color "00 00 00", 0; + +INVENTORY.HUBPOWER + Inventory.Icon "I_MASK"; + } +} + +class PowerLightAmp : Powerup native +{ + Default + { + Powerup.Duration -120; + } +} + +class PowerTorch : PowerLightAmp native {} + +class PowerFlight : Powerup native +{ + Default + { + Powerup.Duration -60; + +INVENTORY.HUBPOWER + } +} + +class PowerWeaponLevel2 : Powerup native +{ + Default + { + Powerup.Duration -40; + Inventory.Icon "SPINBK0"; + +INVENTORY.NOTELEPORTFREEZE + } +} + +class PowerSpeed : Powerup native +{ + native int SpeedFlags; + + Default + { + Powerup.Duration -45; + Speed 1.5; + Inventory.Icon "SPBOOT0"; + +INVENTORY.NOTELEPORTFREEZE + } +} + +// Player Speed Trail (used by the Speed Powerup) ---------------------------- + +class PlayerSpeedTrail : Actor +{ + Default + { + +NOBLOCKMAP + +NOGRAVITY + Alpha 0.6; + RenderStyle "Translucent"; + } + + override void Tick() + { + Alpha -= .6 / 8; + if (Alpha <= 0) + { + Destroy (); + } + } +} + +class PowerMinotaur : Powerup native +{ + Default + { + Powerup.Duration -25; + Inventory.Icon "SPMINO0"; + } +} + +class PowerTargeter : Powerup native +{ + Default + { + Powerup.Duration -160; + +INVENTORY.HUBPOWER + } + States + { + Targeter: + TRGT A -1; + Stop; + TRGT B -1; + Stop; + TRGT C -1; + Stop; + } +} + +class PowerFrightener : Powerup native +{ + Default + { + Powerup.Duration -60; + } +} + +class PowerBuddha : Powerup native +{ + Default + { + Powerup.Duration -60; + } +} + +class PowerScanner : Powerup native +{ + Default + { + Powerup.Duration -80; + +INVENTORY.HUBPOWER + } +} + +class PowerTimeFreezer : Powerup native +{ + Default + { + Powerup.Duration -12; + } +} + +class PowerDamage : Powerup native +{ + Default + { + Powerup.Duration -25; + } +} + +class PowerProtection : Powerup native +{ + Default + { + Powerup.Duration -25; + } +} + +class PowerDrain : Powerup native +{ + Default + { + Powerup.Duration -60; + } +} + +class PowerRegeneration : Powerup native +{ + Default + { + Powerup.Duration -120; + Powerup.Strength 5; + } +} + +class PowerHighJump : Powerup native {} + +class PowerDoubleFiringSpeed : Powerup native {} + +class PowerMorph : Powerup native +{ + native Class PlayerClass; + native Class MorphFlash, UnMorphFlash; + native int MorphStyle; + native PlayerInfo MorphedPlayer; + native bool bInUndoMorph; + + Default + { + Powerup.Duration -40; + } +} + +class PowerInfiniteAmmo : Powerup native +{ + Default + { + Powerup.Duration -30; + } +} + diff --git a/wadsrc/static/zscript/shared/weapons.txt b/wadsrc/static/zscript/shared/weapons.txt new file mode 100644 index 0000000000..c3ebf299dd --- /dev/null +++ b/wadsrc/static/zscript/shared/weapons.txt @@ -0,0 +1,144 @@ +class Weapon : StateProvider native +{ + enum EFireMode + { + PrimaryFire, + AltFire, + EitherFire + }; + + native uint WeaponFlags; + native class AmmoType1, AmmoType2; // Types of ammo used by this weapon + native int AmmoGive1, AmmoGive2; // Amount of each ammo to get when picking up weapon + native int MinAmmo1, MinAmmo2; // Minimum ammo needed to switch to this weapon + native int AmmoUse1, AmmoUse2; // How much ammo to use with each shot + native int Kickback; + native float YAdjust; // For viewing the weapon fullscreen (visual only so no need to be a double) + native sound UpSound, ReadySound; // Sounds when coming up and idle + native class SisterWeaponType; // Another weapon to pick up with this one + native class ProjectileType; // Projectile used by primary attack + native class AltProjectileType; // Projectile used by alternate attack + native int SelectionOrder; // Lower-numbered weapons get picked first + native int MinSelAmmo1, MinSelAmmo2; // Ignore in BestWeapon() if inadequate ammo + native double MoveCombatDist; // Used by bots, but do they *really* need it? + native int ReloadCounter; // For A_CheckForReload + native int BobStyle; // [XA] Bobbing style. Defines type of bobbing (e.g. Normal, Alpha) (visual only so no need to be a double) + native float BobSpeed; // [XA] Bobbing speed. Defines how quickly a weapon bobs. + native float BobRangeX, BobRangeY; // [XA] Bobbing range. Defines how far a weapon bobs in either direction. + native Ammo Ammo1, Ammo2; // In-inventory instance variables + native Weapon SisterWeapon; + native float FOVScale; + native int Crosshair; // 0 to use player's crosshair + native bool GivenAsMorphWeapon; + native bool bAltFire; // Set when this weapon's alternate fire is used. + native readonly bool bDehAmmo; + + Default + { + Inventory.PickupSound "misc/w_pkup"; + Weapon.DefaultKickback; + Weapon.BobSpeed 1.0; + Weapon.BobRangeX 1.0; + Weapon.BobRangeY 1.0; + +WEAPONSPAWN + DefaultStateUsage SUF_ACTOR|SUF_OVERLAY|SUF_WEAPON; + } + States + { + LightDone: + SHTG E 0 A_Light0; + Stop; + } + + native bool CheckAmmo(int fireMode, bool autoSwitch, bool requireAmmo = false, int ammocount = -1); + native bool DepleteAmmo(bool altFire, bool checkEnough = true, int ammouse = -1); + native virtual void EndPowerup(); + + virtual State GetReadyState () + { + return FindState('Ready'); + } + + virtual State GetUpState () + { + return FindState('Select'); + } + + virtual State GetDownState () + { + return FindState('Deselect'); + } + + virtual State GetAtkState (bool hold) + { + State s = null; + if (hold) s = FindState('Hold'); + if (s == null) s = FindState('Fire'); + return s; + } + + virtual State GetAltAtkState (bool hold) + { + State s = null; + if (hold) s = FindState('AltHold'); + if (s == null) s = FindState('AltFire'); + return s; + } + + native action void A_ZoomFactor(double scale = 1, int flags = 0); + native action void A_SetCrosshair(int xhair); + const ZOOM_INSTANT = 1; + const ZOOM_NOSCALETURNING = 2; + +} + +class WeaponGiver : Weapon native +{ + + native double DropAmmoFactor; + + Default + { + Weapon.AmmoGive1 -1; + Weapon.AmmoGive2 -1; + } +} + +class WeaponHolder : Inventory native +{ + native int PieceMask; + native Class PieceWeapon; + + Default + { + +NOBLOCKMAP + +NOSECTOR + +INVENTORY.UNDROPPABLE + } +} + +class WeaponPiece : Inventory native +{ + Default + { + +WEAPONSPAWN; + } +} + +class Ammo : Inventory native +{ + native int BackpackAmount; + native int BackpackMaxAmount; + + Default + { + +INVENTORY.KEEPDEPLETED + Inventory.PickupSound "misc/ammo_pkup"; + } +} + +class BackpackItem : Inventory native +{ + native bool bDepleted; +} +