Skip to content

Commit

Permalink
+NOMORPHLIMITATIONS now also keeps player velocity and pitch
Browse files Browse the repository at this point in the history
  • Loading branch information
IgeNiaI committed Jan 29, 2023
1 parent acbac7c commit dd3a4d4
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
40 changes: 35 additions & 5 deletions src/g_shared/a_morph.cpp
Expand Up @@ -97,6 +97,13 @@ bool P_MorphPlayer (player_t *activator, player_t *p, const PClass *spawntype, i
p->PremorphWeapon = p->ReadyWeapon;
morphed->special2 = actor->flags & ~MF_JUSTHIT;
morphed->player = p;
if (morphed->PlayerFlags & PPF_NOMORPHLIMITATIONS)
{
morphed->velx = actor->velx;
morphed->vely = actor->vely;
morphed->velz = actor->velz;
morphed->pitch = actor->pitch;
}
if (actor->renderflags & RF_INVISIBLE)
{
morphed->special2 |= MF_JUSTHIT;
Expand Down Expand Up @@ -133,7 +140,10 @@ bool P_MorphPlayer (player_t *activator, player_t *p, const PClass *spawntype, i
p->MorphExitFlash = (exit_flash) ? exit_flash : RUNTIME_CLASS(ATeleportFog);
p->health = morphed->health;
p->mo = morphed;
p->velx = p->vely = 0;
if (!(morphed->PlayerFlags & PPF_NOMORPHLIMITATIONS))
{
p->velx = p->vely = 0;
}
morphed->ObtainInventory (actor);
// Remove all armor
for (item = morphed->Inventory; item != NULL; )
Expand Down Expand Up @@ -184,6 +194,11 @@ bool P_MorphPlayer (player_t *activator, player_t *p, const PClass *spawntype, i
SERVERCOMMANDS_SetThingFlags( morphed, FLAGSET_FLAGS3 );
if ( morphed->tid != 0 )
SERVERCOMMANDS_SetThingTID( morphed );
if ( morphed->PlayerFlags & PPF_NOMORPHLIMITATIONS )
{
SERVERCOMMANDS_MoveLocalPlayer( ulPlayer );
SERVERCOMMANDS_MovePlayer( ulPlayer, ulPlayer, SVCF_SKIPTHISCLIENT );
}
}

return true;
Expand Down Expand Up @@ -259,10 +274,20 @@ bool P_UndoPlayerMorph (player_t *activator, player_t *player, int unmorphflag,
mo->player = player;
mo->reactiontime = 18;
mo->flags = pmo->special2 & ~MF_JUSTHIT;
mo->velx = 0;
mo->vely = 0;
player->velx = 0;
player->vely = 0;
if (pmo->PlayerFlags & PPF_NOMORPHLIMITATIONS)
{
mo->velx = pmo->velx;
mo->vely = pmo->vely;
mo->velz = pmo->velz;
mo->pitch = pmo->pitch;
}
else
{
mo->velx = 0;
mo->vely = 0;
player->velx = 0;
player->vely = 0;
}
mo->velz = pmo->velz;
if (!(pmo->special2 & MF_JUSTHIT))
{
Expand Down Expand Up @@ -414,6 +439,11 @@ bool P_UndoPlayerMorph (player_t *activator, player_t *player, int unmorphflag,
SERVERCOMMANDS_SetThingFrame( player->mo, player->mo->state, MAXPLAYERS, 0, false );
if ( player->mo->tid != 0 )
SERVERCOMMANDS_SetThingTID( player->mo );
if ( pmo->PlayerFlags & PPF_NOMORPHLIMITATIONS )
{
SERVERCOMMANDS_MoveLocalPlayer( ULONG( player-players ) );
SERVERCOMMANDS_MovePlayer( ULONG( player-players ), ULONG( player-players ), SVCF_SKIPTHISCLIENT );
}
}
return true;
}
Expand Down
1 change: 1 addition & 0 deletions src/p_pspr.cpp
Expand Up @@ -844,6 +844,7 @@ void P_CheckWeaponSwitch (player_t *player)
if ((player->WeaponState & WF_DISABLESWITCH) || // Weapon changing has been disabled.
( player->morphTics != 0 && !( player->mo && (player->mo->PlayerFlags & PPF_NOMORPHLIMITATIONS) ) )) // Morphed classes cannot change weapons.
{ // ...so throw away any pending weapon requests.
// [geNia] unless +NOMORPHLIMITATIONS is used
player->PendingWeapon = WP_NOCHANGE;
}

Expand Down

0 comments on commit dd3a4d4

Please sign in to comment.