mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-13 07:57:52 +00:00
Added GetPlayerInput(int numinput, int ptr = AAPTR_PLAYER1).
- Works exactly like the ACS version, but with pointers instead. The pointer can be anything, so long as it can be identified as a player.
This commit is contained in:
parent
6384e81d0f
commit
85a34bbb88
5 changed files with 142 additions and 25 deletions
|
@ -4190,31 +4190,6 @@ bool DLevelScript::DoCheckActorTexture(int tid, AActor *activator, int string, b
|
||||||
return tex == TexMan[secpic];
|
return tex == TexMan[secpic];
|
||||||
}
|
}
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
// These are the original inputs sent by the player.
|
|
||||||
INPUT_OLDBUTTONS,
|
|
||||||
INPUT_BUTTONS,
|
|
||||||
INPUT_PITCH,
|
|
||||||
INPUT_YAW,
|
|
||||||
INPUT_ROLL,
|
|
||||||
INPUT_FORWARDMOVE,
|
|
||||||
INPUT_SIDEMOVE,
|
|
||||||
INPUT_UPMOVE,
|
|
||||||
|
|
||||||
// These are the inputs, as modified by P_PlayerThink().
|
|
||||||
// Most of the time, these will match the original inputs, but
|
|
||||||
// they can be different if a player is frozen or using a
|
|
||||||
// chainsaw.
|
|
||||||
MODINPUT_OLDBUTTONS,
|
|
||||||
MODINPUT_BUTTONS,
|
|
||||||
MODINPUT_PITCH,
|
|
||||||
MODINPUT_YAW,
|
|
||||||
MODINPUT_ROLL,
|
|
||||||
MODINPUT_FORWARDMOVE,
|
|
||||||
MODINPUT_SIDEMOVE,
|
|
||||||
MODINPUT_UPMOVE
|
|
||||||
};
|
|
||||||
|
|
||||||
int DLevelScript::GetPlayerInput(int playernum, int inputnum)
|
int DLevelScript::GetPlayerInput(int playernum, int inputnum)
|
||||||
{
|
{
|
||||||
|
|
|
@ -162,6 +162,31 @@ void InitSpawnablesFromMapinfo();
|
||||||
int P_Thing_Warp(AActor *caller, AActor *reference, double xofs, double yofs, double zofs, DAngle angle, int flags, double heightoffset, double radiusoffset, DAngle pitch);
|
int P_Thing_Warp(AActor *caller, AActor *reference, double xofs, double yofs, double zofs, DAngle angle, int flags, double heightoffset, double radiusoffset, DAngle pitch);
|
||||||
bool P_Thing_CheckProximity(AActor *self, PClass *classname, double distance, int count, int flags, int ptr);
|
bool P_Thing_CheckProximity(AActor *self, PClass *classname, double distance, int count, int flags, int ptr);
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
// These are the original inputs sent by the player.
|
||||||
|
INPUT_OLDBUTTONS,
|
||||||
|
INPUT_BUTTONS,
|
||||||
|
INPUT_PITCH,
|
||||||
|
INPUT_YAW,
|
||||||
|
INPUT_ROLL,
|
||||||
|
INPUT_FORWARDMOVE,
|
||||||
|
INPUT_SIDEMOVE,
|
||||||
|
INPUT_UPMOVE,
|
||||||
|
|
||||||
|
// These are the inputs, as modified by P_PlayerThink().
|
||||||
|
// Most of the time, these will match the original inputs, but
|
||||||
|
// they can be different if a player is frozen or using a
|
||||||
|
// chainsaw.
|
||||||
|
MODINPUT_OLDBUTTONS,
|
||||||
|
MODINPUT_BUTTONS,
|
||||||
|
MODINPUT_PITCH,
|
||||||
|
MODINPUT_YAW,
|
||||||
|
MODINPUT_ROLL,
|
||||||
|
MODINPUT_FORWARDMOVE,
|
||||||
|
MODINPUT_SIDEMOVE,
|
||||||
|
MODINPUT_UPMOVE
|
||||||
|
};
|
||||||
enum CPXF
|
enum CPXF
|
||||||
{
|
{
|
||||||
CPXF_ANCESTOR = 1 << 0,
|
CPXF_ANCESTOR = 1 << 0,
|
||||||
|
|
|
@ -543,6 +543,63 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetCVar)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// GetPlayerInput
|
||||||
|
//
|
||||||
|
// NON-ACTION function that works like ACS's GetPlayerInput.
|
||||||
|
// Takes a pointer as anyone may or may not be a player.
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetPlayerInput)
|
||||||
|
{
|
||||||
|
if (numret > 0)
|
||||||
|
{
|
||||||
|
assert(ret != nullptr);
|
||||||
|
PARAM_SELF_PROLOGUE(AActor);
|
||||||
|
PARAM_INT (inputnum);
|
||||||
|
PARAM_INT_OPT (ptr) { ptr = AAPTR_PLAYER1; }
|
||||||
|
|
||||||
|
AActor *mobj = COPY_AAPTR(self, ptr);
|
||||||
|
|
||||||
|
//Need a player.
|
||||||
|
if (!mobj || !mobj->player)
|
||||||
|
{
|
||||||
|
ret->SetInt(0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player_t *p = mobj->player;
|
||||||
|
int renum = 0;
|
||||||
|
switch (inputnum)
|
||||||
|
{
|
||||||
|
case INPUT_OLDBUTTONS: renum = p->original_oldbuttons; break;
|
||||||
|
case INPUT_BUTTONS: renum = p->original_cmd.buttons; break;
|
||||||
|
case INPUT_PITCH: renum = p->original_cmd.pitch; break;
|
||||||
|
case INPUT_YAW: renum = p->original_cmd.yaw; break;
|
||||||
|
case INPUT_ROLL: renum = p->original_cmd.roll; break;
|
||||||
|
case INPUT_FORWARDMOVE: renum = p->original_cmd.forwardmove; break;
|
||||||
|
case INPUT_SIDEMOVE: renum = p->original_cmd.sidemove; break;
|
||||||
|
case INPUT_UPMOVE: renum = p->original_cmd.upmove; break;
|
||||||
|
|
||||||
|
case MODINPUT_OLDBUTTONS: renum = p->oldbuttons; break;
|
||||||
|
case MODINPUT_BUTTONS: renum = p->cmd.ucmd.buttons; break;
|
||||||
|
case MODINPUT_PITCH: renum = p->cmd.ucmd.pitch; break;
|
||||||
|
case MODINPUT_YAW: renum = p->cmd.ucmd.yaw; break;
|
||||||
|
case MODINPUT_ROLL: renum = p->cmd.ucmd.roll; break;
|
||||||
|
case MODINPUT_FORWARDMOVE: renum = p->cmd.ucmd.forwardmove; break;
|
||||||
|
case MODINPUT_SIDEMOVE: renum = p->cmd.ucmd.sidemove; break;
|
||||||
|
case MODINPUT_UPMOVE: renum = p->cmd.ucmd.upmove; break;
|
||||||
|
|
||||||
|
default: renum = 0; break;
|
||||||
|
}
|
||||||
|
ret->SetInt(renum);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// __decorate_internal_state__
|
// __decorate_internal_state__
|
||||||
|
|
|
@ -48,6 +48,7 @@ ACTOR Actor native //: Thinker
|
||||||
native int GetGibHealth();
|
native int GetGibHealth();
|
||||||
native float GetCrouchFactor(int ptr = AAPTR_PLAYER1);
|
native float GetCrouchFactor(int ptr = AAPTR_PLAYER1);
|
||||||
native float GetCVar(string cvar);
|
native float GetCVar(string cvar);
|
||||||
|
native int GetPlayerInput(int inputnum, int ptr = AAPTR_PLAYER1);
|
||||||
|
|
||||||
// Action functions
|
// Action functions
|
||||||
// Meh, MBF redundant functions. Only for DeHackEd support.
|
// Meh, MBF redundant functions. Only for DeHackEd support.
|
||||||
|
|
|
@ -593,3 +593,62 @@ enum
|
||||||
PSP_WEAPON = 1,
|
PSP_WEAPON = 1,
|
||||||
PSP_FLASH = 1000,
|
PSP_FLASH = 1000,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
// These are the original inputs sent by the player.
|
||||||
|
INPUT_OLDBUTTONS,
|
||||||
|
INPUT_BUTTONS,
|
||||||
|
INPUT_PITCH,
|
||||||
|
INPUT_YAW,
|
||||||
|
INPUT_ROLL,
|
||||||
|
INPUT_FORWARDMOVE,
|
||||||
|
INPUT_SIDEMOVE,
|
||||||
|
INPUT_UPMOVE,
|
||||||
|
|
||||||
|
// These are the inputs, as modified by P_PlayerThink().
|
||||||
|
// Most of the time, these will match the original inputs, but
|
||||||
|
// they can be different if a player is frozen or using a
|
||||||
|
// chainsaw.
|
||||||
|
MODINPUT_OLDBUTTONS,
|
||||||
|
MODINPUT_BUTTONS,
|
||||||
|
MODINPUT_PITCH,
|
||||||
|
MODINPUT_YAW,
|
||||||
|
MODINPUT_ROLL,
|
||||||
|
MODINPUT_FORWARDMOVE,
|
||||||
|
MODINPUT_SIDEMOVE,
|
||||||
|
MODINPUT_UPMOVE
|
||||||
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
BT_ATTACK = 1<<0, // Press "Fire".
|
||||||
|
BT_USE = 1<<1, // Use button, to open doors, activate switches.
|
||||||
|
BT_JUMP = 1<<2,
|
||||||
|
BT_CROUCH = 1<<3,
|
||||||
|
BT_TURN180 = 1<<4,
|
||||||
|
BT_ALTATTACK = 1<<5, // Press your other "Fire".
|
||||||
|
BT_RELOAD = 1<<6, // [XA] Reload key. Causes state jump in A_WeaponReady.
|
||||||
|
BT_ZOOM = 1<<7, // [XA] Zoom key. Ditto.
|
||||||
|
|
||||||
|
// The rest are all ignored by the play simulation and are for scripts.
|
||||||
|
BT_SPEED = 1<<8,
|
||||||
|
BT_STRAFE = 1<<9,
|
||||||
|
|
||||||
|
BT_MOVERIGHT = 1<<10,
|
||||||
|
BT_MOVELEFT = 1<<11,
|
||||||
|
BT_BACK = 1<<12,
|
||||||
|
BT_FORWARD = 1<<13,
|
||||||
|
BT_RIGHT = 1<<14,
|
||||||
|
BT_LEFT = 1<<15,
|
||||||
|
BT_LOOKUP = 1<<16,
|
||||||
|
BT_LOOKDOWN = 1<<17,
|
||||||
|
BT_MOVEUP = 1<<18,
|
||||||
|
BT_MOVEDOWN = 1<<19,
|
||||||
|
BT_SHOWSCORES = 1<<20,
|
||||||
|
|
||||||
|
BT_USER1 = 1<<21,
|
||||||
|
BT_USER2 = 1<<22,
|
||||||
|
BT_USER3 = 1<<23,
|
||||||
|
BT_USER4 = 1<<24,
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in a new issue