diff --git a/src/g_shared/a_artifacts.cpp b/src/g_shared/a_artifacts.cpp index 5b03d4a607..bf24c8eb85 100644 --- a/src/g_shared/a_artifacts.cpp +++ b/src/g_shared/a_artifacts.cpp @@ -1884,6 +1884,13 @@ void APowerDoubleFiringSpeed::EndEffect( ) IMPLEMENT_CLASS(APowerMorph, false, false, false, false) +DEFINE_FIELD(APowerMorph, PlayerClass) +DEFINE_FIELD(APowerMorph, MorphFlash) +DEFINE_FIELD(APowerMorph, UnMorphFlash) +DEFINE_FIELD(APowerMorph, MorphStyle) +DEFINE_FIELD(APowerMorph, MorphedPlayer) +DEFINE_FIELD(APowerMorph, bInUndoMorph) + //=========================================================================== // // APowerMorph :: Serialize @@ -1897,7 +1904,7 @@ void APowerMorph::Serialize(FSerializer &arc) ("morphstyle", MorphStyle) ("morphflash", MorphFlash) ("unmorphflash", UnMorphFlash) - ("player", Player); + ("morphedplayer", MorphedPlayer); } //=========================================================================== @@ -1917,7 +1924,7 @@ void APowerMorph::InitEffect( ) { Owner = realplayer->mo; // Replace the new owner in our owner; safe because we are not attached to anything yet ItemFlags |= IF_CREATECOPYMOVED; // Let the caller know the "real" owner has changed (to the morphed actor) - Player = realplayer; // Store the player identity (morphing clears the unmorphed actor's "player" field) + MorphedPlayer = realplayer; // Store the player identity (morphing clears the unmorphed actor's "player" field) } else // morph failed - give the caller an opportunity to fail the pickup completely { @@ -1939,19 +1946,19 @@ void APowerMorph::EndEffect( ) // Abort if owner already destroyed if (Owner == NULL) { - assert(Player == NULL); + assert(MorphedPlayer == NULL); return; } // Abort if owner already unmorphed - if (Player == NULL) + if (MorphedPlayer == NULL) { return; } // Abort if owner is dead; their Die() method will // take care of any required unmorphing on death. - if (Player->health <= 0) + if (MorphedPlayer->health <= 0) { return; } @@ -1959,26 +1966,26 @@ void APowerMorph::EndEffect( ) // Unmorph if possible if (!bInUndoMorph) { - int savedMorphTics = Player->morphTics; - P_UndoPlayerMorph (Player, Player, 0, !!(Player->MorphStyle & MORPH_UNDOALWAYS)); + int savedMorphTics = MorphedPlayer->morphTics; + P_UndoPlayerMorph (MorphedPlayer, MorphedPlayer, 0, !!(MorphedPlayer->MorphStyle & MORPH_UNDOALWAYS)); // Abort if unmorph failed; in that case, // set the usual retry timer and return. - if (Player != NULL && Player->morphTics) + if (MorphedPlayer != NULL && MorphedPlayer->morphTics) { // Transfer retry timeout // to the powerup's timer. - EffectTics = Player->morphTics; + EffectTics = MorphedPlayer->morphTics; // Reload negative morph tics; // use actual value; it may // be in use for animation. - Player->morphTics = savedMorphTics; + MorphedPlayer->morphTics = savedMorphTics; // Try again some time later return; } } // Unmorph suceeded - Player = NULL; + MorphedPlayer = NULL; } // Infinite Ammo Powerup ----------------------------------------------------- diff --git a/src/g_shared/a_artifacts.h b/src/g_shared/a_artifacts.h index bd7e86323c..d9629c1653 100644 --- a/src/g_shared/a_artifacts.h +++ b/src/g_shared/a_artifacts.h @@ -286,7 +286,7 @@ public: PClassPlayerPawn *PlayerClass; PClassActor *MorphFlash, *UnMorphFlash; int MorphStyle; - player_t *Player; + player_t *MorphedPlayer; bool bInUndoMorph; // Because P_UndoPlayerMorph() can call EndEffect recursively protected: diff --git a/src/g_shared/a_morph.cpp b/src/g_shared/a_morph.cpp index 49ea525bbf..84de5a0d6e 100644 --- a/src/g_shared/a_morph.cpp +++ b/src/g_shared/a_morph.cpp @@ -618,6 +618,13 @@ void InitAllPowerupEffects(AInventory *item) IMPLEMENT_CLASS(AMorphProjectile, false, false, false, false) +DEFINE_FIELD(AMorphProjectile, PlayerClass) +DEFINE_FIELD(AMorphProjectile, MonsterClass) +DEFINE_FIELD(AMorphProjectile, MorphFlash) +DEFINE_FIELD(AMorphProjectile, UnMorphFlash) +DEFINE_FIELD(AMorphProjectile, Duration) +DEFINE_FIELD(AMorphProjectile, MorphStyle) + int AMorphProjectile::DoSpecialDamage (AActor *target, int damage, FName damagetype) { if (target->player) @@ -652,6 +659,11 @@ IMPLEMENT_POINTERS_START(AMorphedMonster) IMPLEMENT_POINTER(UnmorphedMe) IMPLEMENT_POINTERS_END +DEFINE_FIELD(AMorphedMonster, UnmorphedMe) +DEFINE_FIELD(AMorphedMonster, UnmorphTime) +DEFINE_FIELD(AMorphedMonster, MorphStyle) +DEFINE_FIELD(AMorphedMonster, MorphExitFlash) + void AMorphedMonster::Serialize(FSerializer &arc) { Super::Serialize (arc); diff --git a/wadsrc/static/zscript/shared/inventory.txt b/wadsrc/static/zscript/shared/inventory.txt index 048590b397..12e521d53f 100644 --- a/wadsrc/static/zscript/shared/inventory.txt +++ b/wadsrc/static/zscript/shared/inventory.txt @@ -487,6 +487,12 @@ 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; diff --git a/wadsrc/static/zscript/shared/morph.txt b/wadsrc/static/zscript/shared/morph.txt index ff58d897b1..c5c2cbe0a7 100644 --- a/wadsrc/static/zscript/shared/morph.txt +++ b/wadsrc/static/zscript/shared/morph.txt @@ -1,5 +1,10 @@ class MorphProjectile : Actor native { + + native Class PlayerClass; + native Class MonsterClass, MorphFlash, UnMorphFlash; + native int Duration, MorphStyle; + Default { Damage 1; @@ -11,6 +16,10 @@ class MorphProjectile : Actor native class MorphedMonster : Actor native { + native Actor UnmorphedMe; + native int UnmorphTime, MorphStyle; + native Class MorphExitFlash; + Default { Monster;