From 70f9b649aa27f1109c25175789c90b8b503b2441 Mon Sep 17 00:00:00 2001 From: Major Cooke Date: Sun, 8 Mar 2020 09:19:20 -0500 Subject: [PATCH] Changed Pre/Post(Un)Morph to take the other actor and a boolean indicating direction. - 'current' is true for the actor that is the new body, false for the old body. --- wadsrc/static/zscript/actors/morph.zs | 21 ++++++++-------- .../zscript/actors/player/player_morph.zs | 25 ++++++++++--------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/wadsrc/static/zscript/actors/morph.zs b/wadsrc/static/zscript/actors/morph.zs index 8dbfb38621..1dcfb31faf 100644 --- a/wadsrc/static/zscript/actors/morph.zs +++ b/wadsrc/static/zscript/actors/morph.zs @@ -28,12 +28,11 @@ extend class Actor return null, 0, 0; } - // [MC] Called when an actor morphs, on both the previous form (passive) and present form (!passive). - // 'cls' points to the other class they transitioned from/to. - virtual void PreMorph(Class cls) {} - virtual void PostMorph(Class cls) {} - virtual void PreUnmorph(Class cls) {} - virtual void PostUnmorph(Class cls) {} + // [MC] Called when an actor morphs, on both the previous form (!current) and present form (current). + virtual void PreMorph(Actor mo, bool current) {} + virtual void PostMorph(Actor mo, bool current) {} + virtual void PreUnmorph(Actor mo, bool current) {} + virtual void PostUnmorph(Actor mo, bool current) {} //=========================================================================== // @@ -112,9 +111,9 @@ extend class Actor let morphed = MorphedMonster(Spawn (spawntype, Pos, NO_REPLACE)); - // Use GetClass in the event someone actually allows replacements. - PreMorph(morphed.GetClass()); - morphed.PreMorph(GetClass()); + // [MC] Notify that we're just about to start the transfer. + PreMorph(morphed, false); // False: No longer the current. + morphed.PreMorph(self, true); // True: Becoming this actor. Substitute (morphed); if ((style & MRF_TRANSFERTRANSLATION) && !morphed.bDontTranslate) @@ -151,8 +150,8 @@ extend class Actor let eflash = Spawn(enter_flash ? enter_flash : (class)("TeleportFog"), Pos + (0, 0, gameinfo.TELEFOGHEIGHT), ALLOW_REPLACE); if (eflash) eflash.target = morphed; - PostMorph(morphed.GetClass()); - morphed.PostMorph(GetClass()); + PostMorph(morphed, false); + morphed.PostMorph(self, true); return true; } } diff --git a/wadsrc/static/zscript/actors/player/player_morph.zs b/wadsrc/static/zscript/actors/player/player_morph.zs index 2a4437159a..a7c1a97e5f 100644 --- a/wadsrc/static/zscript/actors/player/player_morph.zs +++ b/wadsrc/static/zscript/actors/player/player_morph.zs @@ -140,8 +140,8 @@ extend class PlayerPawn let morphed = PlayerPawn(Spawn (spawntype, Pos, NO_REPLACE)); // Use GetClass in the event someone actually allows replacements. - PreMorph(morphed.GetClass()); - morphed.PreMorph(GetClass()); + PreMorph(morphed, false); + morphed.PreMorph(self, true); EndAllPowerupEffects(); Substitute(morphed); @@ -216,8 +216,8 @@ extend class PlayerPawn morphed.ScoreIcon = ScoreIcon; // [GRB] if (eflash) eflash.target = morphed; - PostMorph(morphed.GetClass()); - morphed.PostMorph(GetClass()); + PostMorph(morphed, false); // No longer the current body + morphed.PostMorph(self, true); // This is the current body return true; } @@ -256,8 +256,9 @@ extend class PlayerPawn player.morphTics = 2*TICRATE; return false; } - PreUnmorph(altmo.GetClass()); - altmo.PreUnmorph(GetClass()); + + PreUnmorph(altmo, false); // This body's about to be left. + altmo.PreUnmorph(self, true); // This one's about to become current. // No longer using tracer as morph storage. That is what 'alternative' is for. // If the tracer has changed on the morph, change the original too. @@ -405,8 +406,8 @@ extend class PlayerPawn beastweap.Destroy (); } } - PostUnmorph(altmo.GetClass()); - altmo.PostUnmorph(GetClass()); + PostUnmorph(altmo, false); // This body is no longer current. + altmo.PostUnmorph(self, true); // altmo body is current. Destroy (); // Restore playerclass armor to its normal amount. let hxarmor = HexenArmor(altmo.FindInventory('HexenArmor')); @@ -556,8 +557,8 @@ class MorphedMonster : Actor UnmorphTime = level.time + 5*TICRATE; // Next try in 5 seconds return false; } - PreUnmorph(unmorphed.GetClass()); - unmorphed.PreUnmorph(GetClass()); + PreUnmorph(unmorphed, false); + unmorphed.PreUnmorph(self, true); unmorphed.Angle = Angle; unmorphed.target = target; unmorphed.bShadow = bShadow; @@ -577,8 +578,8 @@ class MorphedMonster : Actor unmorphed.args[4] = args[4]; unmorphed.CopyFriendliness (self, true); unmorphed.bUnmorphed = false; - PostUnmorph(unmorphed.GetClass()); - unmorphed.PostUnmorph(GetClass()); + PostUnmorph(unmorphed, false); // From is false here: Leaving the caller's body. + unmorphed.PostUnmorph(self, true); // True here: Entering this body from here. UnmorphedMe = NULL; Substitute(unmorphed); Destroy ();