From 0d6f37835fbeba30b24b5ffe3f19fbd7ff100867 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 25 Nov 2016 18:41:00 +0100 Subject: [PATCH] - completed Heretic scriptification with the two remaining artifacts. --- src/CMakeLists.txt | 5 -- src/dobject.h | 5 -- src/g_heretic/a_hereticartifacts.cpp | 63 ------------------- src/g_heretic/a_hereticmisc.cpp | 22 ------- src/g_shared/a_morph.cpp | 9 +++ src/g_shared/a_pickups.cpp | 27 +++++++- src/g_shared/a_pickups.h | 1 + src/p_mobj.cpp | 7 +-- .../zscript/heretic/hereticartifacts.txt | 37 ++++++++++- wadsrc/static/zscript/shared/inventory.txt | 3 + wadsrc/static/zscript/shared/player.txt | 2 + 11 files changed, 77 insertions(+), 104 deletions(-) delete mode 100644 src/g_heretic/a_hereticartifacts.cpp delete mode 100644 src/g_heretic/a_hereticmisc.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 434d0c5203..215e88b52d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -824,7 +824,6 @@ endif() file( GLOB HEADER_FILES ${EXTRA_HEADER_DIRS} fragglescript/*.h - g_heretic/*.h g_hexen/*.h g_raven/*.h g_shared/*.h @@ -857,7 +856,6 @@ set( NOT_COMPILED_SOURCE_FILES ${OTHER_SYSTEM_SOURCES} sc_man_scanner.h sc_man_scanner.re - g_heretic/a_hereticartifacts.cpp g_hexen/a_blastradius.cpp g_hexen/a_boostarmor.cpp g_hexen/a_clericflame.cpp @@ -1148,7 +1146,6 @@ set (PCH_SOURCES w_wad.cpp wi_stuff.cpp zstrformat.cpp - g_heretic/a_hereticmisc.cpp g_hexen/a_hexenmisc.cpp g_raven/a_artitele.cpp g_raven/a_minotaur.cpp @@ -1303,7 +1300,6 @@ endif() target_link_libraries( zdoom ${ZDOOM_LIBS} gdtoa dumb lzma ) include_directories( . - g_heretic g_hexen g_raven g_strife @@ -1436,7 +1432,6 @@ source_group("External\\Math" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/m source_group("External\\RapidJSON" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/rapidjson/.+") source_group("Externak\\SFMT" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/sfmt/.+") source_group("FraggleScript" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/fragglescript/.+") -source_group("Games\\Heretic Game" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/g_heretic/.+") source_group("Games\\Hexen Game" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/g_hexen/.+") source_group("Games\\Raven Shared" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/g_raven/.+") source_group("Games\\Strife Game" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/g_strife/.+") diff --git a/src/dobject.h b/src/dobject.h index cb1074c0c4..7d27133dc3 100644 --- a/src/dobject.h +++ b/src/dobject.h @@ -467,11 +467,6 @@ public: void SerializeUserVars(FSerializer &arc); virtual void Serialize(FSerializer &arc); - void VMSuperCall() - { - ObjectFlags |= OF_SuperCall; - } - void ClearClass() { Class = NULL; diff --git a/src/g_heretic/a_hereticartifacts.cpp b/src/g_heretic/a_hereticartifacts.cpp deleted file mode 100644 index 2fb45c1242..0000000000 --- a/src/g_heretic/a_hereticartifacts.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* -#include "info.h" -#include "a_pickups.h" -#include "a_artifacts.h" -#include "gstrings.h" -#include "p_local.h" -#include "s_sound.h" -#include "vm.h" -*/ - -// Tome of power ------------------------------------------------------------ - -class AArtiTomeOfPower : public APowerupGiver -{ - DECLARE_CLASS (AArtiTomeOfPower, APowerupGiver) -public: - bool Use (bool pickup); -}; - -IMPLEMENT_CLASS(AArtiTomeOfPower, false, false) - -bool AArtiTomeOfPower::Use (bool pickup) -{ - if (Owner->player->morphTics && (Owner->player->MorphStyle & MORPH_UNDOBYTOMEOFPOWER)) - { // Attempt to undo chicken - if (!P_UndoPlayerMorph (Owner->player, Owner->player, MORPH_UNDOBYTOMEOFPOWER)) - { // Failed - if (!(Owner->player->MorphStyle & MORPH_FAILNOTELEFRAG)) - { - P_DamageMobj (Owner, NULL, NULL, TELEFRAG_DAMAGE, NAME_Telefrag); - } - } - else - { // Succeeded - S_Sound (Owner, CHAN_VOICE, "*evillaugh", 1, ATTN_IDLE); - } - return true; - } - else - { - return Super::Use (pickup); - } -} - -// Time bomb ---------------------------------------------------------------- - -class AArtiTimeBomb : public AInventory -{ - DECLARE_CLASS (AArtiTimeBomb, AInventory) -public: - bool Use (bool pickup); -}; - -IMPLEMENT_CLASS(AArtiTimeBomb, false, false) - -bool AArtiTimeBomb::Use (bool pickup) -{ - AActor *mo = Spawn("ActivatedTimeBomb", - Owner->Vec3Angle(24., Owner->Angles.Yaw, - Owner->Floorclip), ALLOW_REPLACE); - mo->target = Owner; - return true; -} - diff --git a/src/g_heretic/a_hereticmisc.cpp b/src/g_heretic/a_hereticmisc.cpp deleted file mode 100644 index af9d10ba5b..0000000000 --- a/src/g_heretic/a_hereticmisc.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "actor.h" -#include "info.h" -#include "a_pickups.h" -#include "a_action.h" -#include "m_random.h" -#include "p_local.h" -#include "s_sound.h" -#include "gstrings.h" -#include "p_enemy.h" -#include "a_specialspot.h" -#include "g_level.h" -#include "a_sharedglobal.h" -#include "templates.h" -#include "r_data/r_translate.h" -#include "doomstat.h" -#include "d_player.h" -#include "a_morph.h" -#include "p_spec.h" -#include "serializer.h" - -// Include all the other Heretic stuff here to reduce compile time -#include "a_hereticartifacts.cpp" diff --git a/src/g_shared/a_morph.cpp b/src/g_shared/a_morph.cpp index 5514ae4137..5ab1e3eb9b 100644 --- a/src/g_shared/a_morph.cpp +++ b/src/g_shared/a_morph.cpp @@ -372,6 +372,15 @@ bool P_UndoPlayerMorph (player_t *activator, player_t *player, int unmorphflag, return true; } +DEFINE_ACTION_FUNCTION(_PlayerInfo, UndoPlayerMorph) +{ + PARAM_SELF_STRUCT_PROLOGUE(player_t); + PARAM_POINTER(player, player_t); + PARAM_INT_DEF(unmorphflag); + PARAM_BOOL_DEF(force); + ACTION_RETURN_BOOL(P_UndoPlayerMorph(self, player, unmorphflag, force)); +} + //--------------------------------------------------------------------------- // // FUNC P_MorphMonster diff --git a/src/g_shared/a_pickups.cpp b/src/g_shared/a_pickups.cpp index 16a63a2ff4..ee68a16db0 100644 --- a/src/g_shared/a_pickups.cpp +++ b/src/g_shared/a_pickups.cpp @@ -20,6 +20,7 @@ #include "d_player.h" #include "p_spec.h" #include "serializer.h" +#include "virtual.h" static FRandom pr_restore ("RestorePos"); @@ -1005,6 +1006,30 @@ bool AInventory::Use (bool pickup) return false; } +DEFINE_ACTION_FUNCTION(AInventory, Use) +{ + PARAM_SELF_PROLOGUE(AInventory); + PARAM_BOOL(pickup); + ACTION_RETURN_BOOL(self->Use(pickup)); +} + +bool AInventory::CallUse(bool pickup) +{ + IFVIRTUAL(AInventory, Use) + { + VMValue params[2] = { (DObject*)this, pickup }; + VMReturn ret; + VMFrameStack stack; + int retval; + ret.IntAt(&retval); + stack.Call(func, params, 2, &ret, 1, nullptr); + return !!retval; + + } + else return Use(pickup); +} + + //=========================================================================== // // AInventory :: Hide @@ -1494,7 +1519,7 @@ bool AInventory::TryPickup (AActor *&toucher) copy->AttachToOwner (newtoucher); if (ItemFlags & IF_AUTOACTIVATE) { - if (copy->Use (true)) + if (copy->CallUse (true)) { if (--copy->Amount <= 0) { diff --git a/src/g_shared/a_pickups.h b/src/g_shared/a_pickups.h index 0cfd04147f..f035efeea8 100644 --- a/src/g_shared/a_pickups.h +++ b/src/g_shared/a_pickups.h @@ -204,6 +204,7 @@ public: virtual void GoAwayAndDie (); virtual bool HandlePickup (AInventory *item); virtual bool Use (bool pickup); + bool CallUse(bool pickup); virtual void Travelled (); virtual void OwnerDied (); diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index f956d8911a..d845846db8 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -955,7 +955,7 @@ bool AActor::DoUseInventory (AInventory *item) { return false; } - if (!item->Use (false)) + if (!item->CallUse (false)) { return false; } @@ -974,7 +974,6 @@ DEFINE_ACTION_FUNCTION(AActor, UseInventory) { PARAM_SELF_PROLOGUE(AActor); PARAM_OBJECT(item, AInventory); - self->VMSuperCall(); ACTION_RETURN_BOOL(self->DoUseInventory(item)); } @@ -4149,7 +4148,6 @@ void AActor::Tick () DEFINE_ACTION_FUNCTION(AActor, Tick) { PARAM_SELF_PROLOGUE(AActor); - self->VMSuperCall(); self->Tick(); return 0; } @@ -4708,7 +4706,6 @@ DEFINE_ACTION_FUNCTION(AActor, Activate) { PARAM_SELF_PROLOGUE(AActor); PARAM_OBJECT(activator, AActor); - self->VMSuperCall(); self->Activate(activator); return 0; } @@ -4756,7 +4753,6 @@ DEFINE_ACTION_FUNCTION(AActor, Deactivate) { PARAM_SELF_PROLOGUE(AActor); PARAM_OBJECT(activator, AActor); - self->VMSuperCall(); self->Deactivate(activator); return 0; } @@ -6797,7 +6793,6 @@ DEFINE_ACTION_FUNCTION(AActor, DoSpecialDamage) PARAM_OBJECT(target, AActor); PARAM_INT(damage); PARAM_NAME(damagetype); - self->VMSuperCall(); ACTION_RETURN_INT(self->DoSpecialDamage(target, damage, damagetype)); } diff --git a/wadsrc/static/zscript/heretic/hereticartifacts.txt b/wadsrc/static/zscript/heretic/hereticartifacts.txt index 50a25008a3..3ef265735a 100644 --- a/wadsrc/static/zscript/heretic/hereticartifacts.txt +++ b/wadsrc/static/zscript/heretic/hereticartifacts.txt @@ -47,7 +47,7 @@ Class ArtiInvisibility : PowerupGiver // Tome of power ------------------------------------------------------------ -Class ArtiTomeOfPower : PowerupGiver native +Class ArtiTomeOfPower : PowerupGiver { Default { @@ -65,6 +65,31 @@ Class ArtiTomeOfPower : PowerupGiver native PWBK A 350; Loop; } + + bool Use (bool pickup) + { + Playerinfo p = Owner.player; + if (p && p.morphTics && (p.MorphStyle & MRF_UNDOBYTOMEOFPOWER)) + { // Attempt to undo chicken + if (!p.UndoPlayerMorph (p, MRF_UNDOBYTOMEOFPOWER)) + { // Failed + if (!(p.MorphStyle & MRF_FAILNOTELEFRAG)) + { + Owner.DamageMobj (null, null, TELEFRAG_DAMAGE, 'Telefrag'); + } + } + else + { // Succeeded + Owner.A_PlaySound ("*evillaugh", CHAN_VOICE); + } + return true; + } + else + { + return Super.Use (pickup); + } + } + } @@ -99,7 +124,7 @@ Class ActivatedTimeBomb : Actor } -Class ArtiTimeBomb : Inventory native +Class ArtiTimeBomb : Inventory { Default { @@ -120,4 +145,12 @@ Class ArtiTimeBomb : Inventory native FBMB E 350; Loop; } + + override bool Use (bool pickup) + { + Actor mo = Spawn("ActivatedTimeBomb", Owner.Vec3Angle(24., Owner.angle, - Owner.Floorclip), ALLOW_REPLACE); + mo.target = Owner; + return true; + } + } diff --git a/wadsrc/static/zscript/shared/inventory.txt b/wadsrc/static/zscript/shared/inventory.txt index 52a346ce15..c2c99453fa 100644 --- a/wadsrc/static/zscript/shared/inventory.txt +++ b/wadsrc/static/zscript/shared/inventory.txt @@ -25,6 +25,9 @@ class Inventory : Actor native Inventory.PickupMessage "$TXT_DEFAULTPICKUPMSG"; } + virtual native bool Use (bool pickup); + + // These are regular functions for the item itself. private native void A_RestoreSpecialDoomThing(); private native void A_RestoreSpecialThing1(); diff --git a/wadsrc/static/zscript/shared/player.txt b/wadsrc/static/zscript/shared/player.txt index ed95354f89..e76e637fe5 100644 --- a/wadsrc/static/zscript/shared/player.txt +++ b/wadsrc/static/zscript/shared/player.txt @@ -213,8 +213,10 @@ FWeaponSlots weapons; */ + native bool UndoPlayerMorph(playerinfo player, int unmorphflag = 0, bool force = false); native void SetPsprite(int id, State stat, bool pending = false); native void SetSafeFlash(Weapon weap, State flashstate, int index); native PSprite GetPSprite(int id); native PSprite FindPSprite(int id); + }