- exported P_PlayerThink to ZScript.

This commit is contained in:
Christoph Oelckers 2017-04-30 20:29:39 +02:00
parent 8c992647de
commit 10deb5ce56
4 changed files with 254 additions and 76 deletions

View file

@ -1508,6 +1508,12 @@ void player_t::TickPSprites()
} }
} }
DEFINE_ACTION_FUNCTION(_PlayerInfo, TickPSprites)
{
PARAM_SELF_STRUCT_PROLOGUE(player_t);
self->TickPSprites();
return 0;
}
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// //
// //

View file

@ -3068,6 +3068,98 @@ void P_HandleMovement(player_t *player)
} }
} }
DEFINE_ACTION_FUNCTION(APlayerPawn, CheckFOV)
{
PARAM_SELF_PROLOGUE(APlayerPawn);
P_CheckFOV(self->player);
return 0;
}
DEFINE_ACTION_FUNCTION(APlayerPawn, CheckCheats)
{
PARAM_SELF_PROLOGUE(APlayerPawn);
P_CheckCheats(self->player);
return 0;
}
DEFINE_ACTION_FUNCTION(APlayerPawn, CheckFrozen)
{
PARAM_SELF_PROLOGUE(APlayerPawn);
ACTION_RETURN_BOOL(P_CheckFrozen(self->player));
}
DEFINE_ACTION_FUNCTION(APlayerPawn, CheckCrouch)
{
PARAM_SELF_PROLOGUE(APlayerPawn);
PARAM_BOOL(totally);
P_CheckCrouch(self->player, totally);
return 0;
}
DEFINE_ACTION_FUNCTION(APlayerPawn, CheckMusicChange)
{
PARAM_SELF_PROLOGUE(APlayerPawn);
P_CheckMusicChange(self->player);
return 0;
}
DEFINE_ACTION_FUNCTION(APlayerPawn, DeathThink)
{
PARAM_SELF_PROLOGUE(APlayerPawn);
P_DeathThink(self->player);
return 0;
}
DEFINE_ACTION_FUNCTION(APlayerPawn, CheckPitch)
{
PARAM_SELF_PROLOGUE(APlayerPawn);
P_CheckPitch(self->player);
return 0;
}
DEFINE_ACTION_FUNCTION(APlayerPawn, HandleMovement)
{
PARAM_SELF_PROLOGUE(APlayerPawn);
P_HandleMovement(self->player);
return 0;
}
DEFINE_ACTION_FUNCTION(APlayerPawn, CalcHeight)
{
PARAM_SELF_PROLOGUE(APlayerPawn);
P_CalcHeight(self->player);
return 0;
}
DEFINE_ACTION_FUNCTION(APlayerPawn, CheckEnvironment)
{
PARAM_SELF_PROLOGUE(APlayerPawn);
P_CheckEnvironment(self->player);
return 0;
}
DEFINE_ACTION_FUNCTION(APlayerPawn, CheckUse)
{
PARAM_SELF_PROLOGUE(APlayerPawn);
P_CheckUse(self->player);
return 0;
}
DEFINE_ACTION_FUNCTION(APlayerPawn, CheckUndoMorph)
{
PARAM_SELF_PROLOGUE(APlayerPawn);
P_CheckUndoMorph(self->player);
return 0;
}
DEFINE_ACTION_FUNCTION(APlayerPawn, CheckPoison)
{
PARAM_SELF_PROLOGUE(APlayerPawn);
P_CheckPoison(self->player);
return 0;
}
DEFINE_ACTION_FUNCTION(APlayerPawn, CheckDegeneration)
{
PARAM_SELF_PROLOGUE(APlayerPawn);
P_CheckDegeneration(self->player);
return 0;
}
DEFINE_ACTION_FUNCTION(APlayerPawn, CheckAirSupply)
{
PARAM_SELF_PROLOGUE(APlayerPawn);
P_CheckAirSupply(self->player);
return 0;
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// //
// PROC P_PlayerThink // PROC P_PlayerThink
@ -3098,75 +3190,10 @@ void P_PlayerThink (player_t *player)
// Don't interpolate the view for more than one tic // Don't interpolate the view for more than one tic
player->cheats &= ~CF_INTERPVIEW; player->cheats &= ~CF_INTERPVIEW;
P_CheckFOV(player); IFVIRTUALPTR(player->mo, APlayerPawn, PlayerThink)
if (player->inventorytics)
{ {
player->inventorytics--; VMValue param = player->mo;
} VMCall(func, &param, 1, nullptr, 0);
P_CheckCheats(player);
if (player->mo->flags & MF_JUSTATTACKED)
{ // Chainsaw/Gauntlets attack auto forward motion
cmd->ucmd.yaw = 0;
cmd->ucmd.forwardmove = 0xc800/2;
cmd->ucmd.sidemove = 0;
player->mo->flags &= ~MF_JUSTATTACKED;
}
bool totallyfrozen = P_CheckFrozen(player);
// Handle crouching
P_CheckCrouch(player, totallyfrozen);
P_CheckMusicChange(player);
if (player->playerstate == PST_DEAD)
{
P_DeathThink (player);
return;
}
if (player->jumpTics != 0)
{
player->jumpTics--;
if (player->onground && player->jumpTics < -18)
{
player->jumpTics = 0;
}
}
if (player->morphTics && !(player->cheats & CF_PREDICTING))
{
player->mo->MorphPlayerThink ();
}
P_CheckPitch(player);
P_HandleMovement(player);
P_CalcHeight (player);
if (!(player->cheats & CF_PREDICTING))
{
P_CheckEnvironment(player);
P_CheckUse(player);
P_CheckUndoMorph(player);
// Cycle psprites
player->TickPSprites();
// Other Counters
if (player->damagecount)
player->damagecount--;
if (player->bonuscount)
player->bonuscount--;
if (player->hazardcount)
{
player->hazardcount--;
if (!(level.time % player->hazardinterval) && player->hazardcount > 16*TICRATE)
P_DamageMobj (player->mo, NULL, NULL, 5, player->hazardtype);
}
P_CheckPoison(player);
P_CheckDegeneration(player);
P_CheckAirSupply(player);
} }
} }
@ -3727,12 +3754,20 @@ DEFINE_FIELD_X(PlayerInfo, player_t, ConversationNPC)
DEFINE_FIELD_X(PlayerInfo, player_t, ConversationPC) DEFINE_FIELD_X(PlayerInfo, player_t, ConversationPC)
DEFINE_FIELD_X(PlayerInfo, player_t, ConversationNPCAngle) DEFINE_FIELD_X(PlayerInfo, player_t, ConversationNPCAngle)
DEFINE_FIELD_X(PlayerInfo, player_t, ConversationFaceTalker) DEFINE_FIELD_X(PlayerInfo, player_t, ConversationFaceTalker)
DEFINE_FIELD_X(PlayerInfo, player_t, cmd) DEFINE_FIELD_NAMED_X(PlayerInfo, player_t, cmd.ucmd, cmd)
DEFINE_FIELD_X(PlayerInfo, player_t, original_cmd) DEFINE_FIELD_X(PlayerInfo, player_t, original_cmd)
DEFINE_FIELD_X(PlayerInfo, player_t, userinfo) DEFINE_FIELD_X(PlayerInfo, player_t, userinfo)
DEFINE_FIELD_X(PlayerInfo, player_t, weapons) DEFINE_FIELD_X(PlayerInfo, player_t, weapons)
DEFINE_FIELD_NAMED_X(PlayerInfo, player_t, cmd.ucmd.buttons, buttons) DEFINE_FIELD_NAMED_X(PlayerInfo, player_t, cmd.ucmd.buttons, buttons)
DEFINE_FIELD_X(UserCmd, usercmd_t, buttons)
DEFINE_FIELD_X(UserCmd, usercmd_t, pitch)
DEFINE_FIELD_X(UserCmd, usercmd_t, yaw)
DEFINE_FIELD_X(UserCmd, usercmd_t, roll)
DEFINE_FIELD_X(UserCmd, usercmd_t, forwardmove)
DEFINE_FIELD_X(UserCmd, usercmd_t, sidemove)
DEFINE_FIELD_X(UserCmd, usercmd_t, upmove)
DEFINE_FIELD(FPlayerClass, Type) DEFINE_FIELD(FPlayerClass, Type)
DEFINE_FIELD(FPlayerClass, Flags) DEFINE_FIELD(FPlayerClass, Flags)
DEFINE_FIELD(FPlayerClass, Skins) DEFINE_FIELD(FPlayerClass, Skins)

View file

@ -1,3 +1,15 @@
struct UserCmd native
{
native uint buttons;
native int16 pitch; // up/down
native int16 yaw; // left/right
native int16 roll; // "tilt"
native int16 forwardmove;
native int16 sidemove;
native int16 upmove;
}
class PlayerPawn : Actor native class PlayerPawn : Actor native
{ {
@ -94,6 +106,12 @@ class PlayerPawn : Actor native
Obituary "$OB_MPDEFAULT"; Obituary "$OB_MPDEFAULT";
} }
//----------------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------------
virtual void PlayIdle () virtual void PlayIdle ()
{ {
if (InStateSequence(CurState, SeeState)) if (InStateSequence(CurState, SeeState))
@ -120,6 +138,12 @@ class PlayerPawn : Actor native
{ {
} }
//----------------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------------
virtual void OnRespawn() virtual void OnRespawn()
{ {
if (sv_respawnprotect && (multiplayer || alwaysapplydmflags)) if (sv_respawnprotect && (multiplayer || alwaysapplydmflags))
@ -132,6 +156,12 @@ class PlayerPawn : Actor native
} }
} }
//----------------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------------
override String GetObituary(Actor victim, Actor inflictor, Name mod, bool playerattack) override String GetObituary(Actor victim, Actor inflictor, Name mod, bool playerattack)
{ {
if (victim.player != player && victim.IsTeammate(self)) if (victim.player != player && victim.IsTeammate(self))
@ -162,7 +192,12 @@ class PlayerPawn : Actor native
} }
} }
//----------------------------------------------------------------------------
//
// This is for SBARINFO. // This is for SBARINFO.
//
//----------------------------------------------------------------------------
clearscope int, int GetEffectTicsForItem(class<Inventory> item) const clearscope int, int GetEffectTicsForItem(class<Inventory> item) const
{ {
let pg = (class<PowerupGiver>)(item); let pg = (class<PowerupGiver>)(item);
@ -180,6 +215,110 @@ class PlayerPawn : Actor native
return -1, -1; return -1, -1;
} }
//----------------------------------------------------------------------------
//
// PROC P_PlayerThink
//
//----------------------------------------------------------------------------
native void CheckFOV();
native void CheckCheats();
native bool CheckFrozen();
native void CheckCrouch(bool totallyfrozen);
native void CheckMusicChange();
native void DeathThink ();
native void CheckPitch();
native void HandleMovement();
native void CalcHeight ();
native void CheckEnvironment();
native void CheckUse();
native void CheckUndoMorph();
// Cycle psprites
native void CheckPoison();
native void CheckDegeneration();
native void CheckAirSupply();
virtual void PlayerThink()
{
let player = self.player;
UserCmd cmd = player.cmd;
CheckFOV();
if (player.inventorytics)
{
player.inventorytics--;
}
CheckCheats();
if (bJustAttacked)
{ // Chainsaw/Gauntlets attack auto forward motion
cmd.yaw = 0;
cmd.forwardmove = 0xc800/2;
cmd.sidemove = 0;
bJustAttacked = false;
}
bool totallyfrozen = CheckFrozen();
// Handle crouching
CheckCrouch(totallyfrozen);
CheckMusicChange();
if (player.playerstate == PST_DEAD)
{
DeathThink ();
return;
}
if (player.jumpTics != 0)
{
player.jumpTics--;
if (player.onground && player.jumpTics < -18)
{
player.jumpTics = 0;
}
}
if (player.morphTics && !(player.cheats & CF_PREDICTING))
{
MorphPlayerThink ();
}
CheckPitch();
HandleMovement();
CalcHeight ();
if (!(player.cheats & CF_PREDICTING))
{
CheckEnvironment();
CheckUse();
CheckUndoMorph();
// Cycle psprites
player.TickPSprites();
// Other Counters
if (player.damagecount) player.damagecount--;
if (player.bonuscount) player.bonuscount--;
if (player.hazardcount)
{
player.hazardcount--;
if (!(level.time % player.hazardinterval) && player.hazardcount > 16*TICRATE)
DamageMobj (NULL, NULL, 5, player.hazardtype);
}
CheckPoison();
CheckDegeneration();
CheckAirSupply();
}
}
//----------------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------------
native clearscope int GetMaxHealth(bool withupgrades = false) const; native clearscope int GetMaxHealth(bool withupgrades = false) const;
native bool ResetAirSupply (bool playgasp = false); native bool ResetAirSupply (bool playgasp = false);
native void CheckWeaponSwitch(class<Inventory> item); native void CheckWeaponSwitch(class<Inventory> item);
@ -341,12 +480,9 @@ struct PlayerInfo native play // this is what internally is known as player_t
native double ConversationNPCAngle; native double ConversationNPCAngle;
native bool ConversationFaceTalker; native bool ConversationFaceTalker;
native @WeaponSlots weapons; native @WeaponSlots weapons;
native @UserCmd cmd;
native readonly @UserCmd original_cmd;
/* these are not doable yet
ticcmd_t cmd;
usercmd_t original_cmd;
*/
native bool MorphPlayer(playerinfo p, Class<PlayerPawn> spawntype, int duration, int style, Class<Actor> enter_flash = null, Class<Actor> exit_flash = null); native bool MorphPlayer(playerinfo p, Class<PlayerPawn> spawntype, int duration, int style, Class<Actor> enter_flash = null, Class<Actor> exit_flash = null);
native bool UndoPlayerMorph(playerinfo player, int unmorphflag = 0, bool force = false); native bool UndoPlayerMorph(playerinfo player, int unmorphflag = 0, bool force = false);
@ -375,6 +511,7 @@ usercmd_t original_cmd;
native bool GetNoAutostartMap() const; native bool GetNoAutostartMap() const;
native void SetFOV(float fov); native void SetFOV(float fov);
native clearscope bool HasWeaponsInSlot(int slot) const; native clearscope bool HasWeaponsInSlot(int slot) const;
native void TickPSprites();
clearscope int fragSum () const clearscope int fragSum () const
{ {

View file

@ -592,8 +592,8 @@ class StatusScreen abstract play version("2.5")
PlayerInfo player = players[i]; PlayerInfo player = players[i];
if (playeringame[i]) if (playeringame[i])
{ {
if ((player.buttons ^ player.oldbuttons) && if ((player.cmd.buttons ^ player.oldbuttons) &&
((player.buttons & player.oldbuttons) == player.oldbuttons) && player.Bot == NULL) ((player.cmd.buttons & player.oldbuttons) == player.oldbuttons) && player.Bot == NULL)
{ {
acceleratestage = 1; acceleratestage = 1;
playerready[i] = true; playerready[i] = true;