mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-14 00:20:38 +00:00
- Added WRF_DISABLESWITCH flag for A_WeaponReady to indicate that any attempts to switch the weapon
should be discarded. SVN r4062 (trunk)
This commit is contained in:
parent
f0bc2fdc53
commit
87b8b6201c
3 changed files with 47 additions and 18 deletions
|
@ -212,6 +212,7 @@ enum
|
||||||
WF_WEAPONBOBBING = 1 << 1, // [HW] Bob weapon while the player is moving
|
WF_WEAPONBOBBING = 1 << 1, // [HW] Bob weapon while the player is moving
|
||||||
WF_WEAPONREADYALT = 1 << 2, // Weapon can fire its secondary attack
|
WF_WEAPONREADYALT = 1 << 2, // Weapon can fire its secondary attack
|
||||||
WF_WEAPONSWITCHOK = 1 << 3, // It is okay to switch away from this weapon
|
WF_WEAPONSWITCHOK = 1 << 3, // It is okay to switch away from this weapon
|
||||||
|
WF_DISABLESWITCH = 1 << 4, // Disable weapon switching completely
|
||||||
WF_WEAPONRELOADOK = 1 << 5, // [XA] Okay to reload this weapon.
|
WF_WEAPONRELOADOK = 1 << 5, // [XA] Okay to reload this weapon.
|
||||||
WF_WEAPONZOOMOK = 1 << 6, // [XA] Okay to use weapon zoom function.
|
WF_WEAPONZOOMOK = 1 << 6, // [XA] Okay to use weapon zoom function.
|
||||||
};
|
};
|
||||||
|
|
|
@ -352,6 +352,12 @@ void P_ZoomWeapon (player_t *player, FState *state)
|
||||||
|
|
||||||
void P_DropWeapon (player_t *player)
|
void P_DropWeapon (player_t *player)
|
||||||
{
|
{
|
||||||
|
if (player == NULL)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Since the weapon is dropping, stop blocking switching.
|
||||||
|
player->WeaponState &= ~WF_DISABLESWITCH;
|
||||||
if (player->ReadyWeapon != NULL)
|
if (player->ReadyWeapon != NULL)
|
||||||
{
|
{
|
||||||
P_SetPsprite (player, ps_weapon, player->ReadyWeapon->GetDownState());
|
P_SetPsprite (player, ps_weapon, player->ReadyWeapon->GetDownState());
|
||||||
|
@ -471,7 +477,7 @@ void P_BobWeapon (player_t *player, pspdef_t *psp, fixed_t *x, fixed_t *y)
|
||||||
//
|
//
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
void DoReadyWeaponToSwitch (AActor * self)
|
void DoReadyWeaponToSwitch (AActor *self)
|
||||||
{
|
{
|
||||||
// Prepare for switching action.
|
// Prepare for switching action.
|
||||||
player_t *player;
|
player_t *player;
|
||||||
|
@ -479,7 +485,24 @@ void DoReadyWeaponToSwitch (AActor * self)
|
||||||
player->WeaponState |= WF_WEAPONSWITCHOK;
|
player->WeaponState |= WF_WEAPONSWITCHOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoReadyWeaponToFire (AActor * self, bool prim, bool alt)
|
void DoReadyWeaponDisableSwitch (AActor *self, INTBOOL disable)
|
||||||
|
{
|
||||||
|
// Discard all switch attempts?
|
||||||
|
player_t *player;
|
||||||
|
if (self && (player = self->player))
|
||||||
|
{
|
||||||
|
if (disable)
|
||||||
|
{
|
||||||
|
player->WeaponState |= WF_DISABLESWITCH;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player->WeaponState &= ~WF_DISABLESWITCH;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DoReadyWeaponToFire (AActor *self, bool prim, bool alt)
|
||||||
{
|
{
|
||||||
player_t *player;
|
player_t *player;
|
||||||
AWeapon *weapon;
|
AWeapon *weapon;
|
||||||
|
@ -510,7 +533,7 @@ void DoReadyWeaponToFire (AActor * self, bool prim, bool alt)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoReadyWeaponToBob (AActor * self)
|
void DoReadyWeaponToBob (AActor *self)
|
||||||
{
|
{
|
||||||
if (self && self->player && self->player->ReadyWeapon)
|
if (self && self->player && self->player->ReadyWeapon)
|
||||||
{
|
{
|
||||||
|
@ -521,7 +544,7 @@ void DoReadyWeaponToBob (AActor * self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoReadyWeaponToReload (AActor * self)
|
void DoReadyWeaponToReload (AActor *self)
|
||||||
{
|
{
|
||||||
// Prepare for reload action.
|
// Prepare for reload action.
|
||||||
player_t *player;
|
player_t *player;
|
||||||
|
@ -530,7 +553,7 @@ void DoReadyWeaponToReload (AActor * self)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoReadyWeaponToZoom (AActor * self)
|
void DoReadyWeaponToZoom (AActor *self)
|
||||||
{
|
{
|
||||||
// Prepare for reload action.
|
// Prepare for reload action.
|
||||||
player_t *player;
|
player_t *player;
|
||||||
|
@ -540,7 +563,7 @@ void DoReadyWeaponToZoom (AActor * self)
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function replaces calls to A_WeaponReady in other codepointers.
|
// This function replaces calls to A_WeaponReady in other codepointers.
|
||||||
void DoReadyWeapon(AActor * self)
|
void DoReadyWeapon(AActor *self)
|
||||||
{
|
{
|
||||||
DoReadyWeaponToBob(self);
|
DoReadyWeaponToBob(self);
|
||||||
DoReadyWeaponToFire(self);
|
DoReadyWeaponToFire(self);
|
||||||
|
@ -558,6 +581,7 @@ enum EWRF_Options
|
||||||
WRF_NoFire = WRF_NoPrimary + WRF_NoSecondary,
|
WRF_NoFire = WRF_NoPrimary + WRF_NoSecondary,
|
||||||
WRF_AllowReload = 16,
|
WRF_AllowReload = 16,
|
||||||
WRF_AllowZoom = 32,
|
WRF_AllowZoom = 32,
|
||||||
|
WRF_DisableSwitch = 64,
|
||||||
};
|
};
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION_PARAMS(AInventory, A_WeaponReady)
|
DEFINE_ACTION_FUNCTION_PARAMS(AInventory, A_WeaponReady)
|
||||||
|
@ -570,6 +594,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AInventory, A_WeaponReady)
|
||||||
if (!(paramflags & WRF_NoBob)) DoReadyWeaponToBob(self);
|
if (!(paramflags & WRF_NoBob)) DoReadyWeaponToBob(self);
|
||||||
if ((paramflags & WRF_AllowReload)) DoReadyWeaponToReload(self);
|
if ((paramflags & WRF_AllowReload)) DoReadyWeaponToReload(self);
|
||||||
if ((paramflags & WRF_AllowZoom)) DoReadyWeaponToZoom(self);
|
if ((paramflags & WRF_AllowZoom)) DoReadyWeaponToZoom(self);
|
||||||
|
|
||||||
|
DoReadyWeaponDisableSwitch(self, paramflags & WRF_DisableSwitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -625,22 +651,23 @@ void P_CheckWeaponFire (player_t *player)
|
||||||
|
|
||||||
void P_CheckWeaponSwitch (player_t *player)
|
void P_CheckWeaponSwitch (player_t *player)
|
||||||
{
|
{
|
||||||
AWeapon *weapon;
|
if (player == NULL)
|
||||||
|
|
||||||
if (!player || !(weapon = player->ReadyWeapon))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Put the weapon away if the player has a pending weapon or has died.
|
|
||||||
if ((player->morphTics == 0 && player->PendingWeapon != WP_NOCHANGE) || player->health <= 0)
|
|
||||||
{
|
{
|
||||||
P_DropWeapon(player);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (player->morphTics != 0)
|
if ((player->WeaponState & WF_DISABLESWITCH) || // Weapon changing has been disabled.
|
||||||
{
|
player->morphTics != 0) // Morphed classes cannot change weapons.
|
||||||
// morphed classes cannot change weapons so don't even try again.
|
{ // ...so throw away any pending weapon requests.
|
||||||
player->PendingWeapon = WP_NOCHANGE;
|
player->PendingWeapon = WP_NOCHANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Put the weapon away if the player has a pending weapon or has died, and
|
||||||
|
// we're at a place in the state sequence where dropping the weapon is okay.
|
||||||
|
if ((player->PendingWeapon != WP_NOCHANGE || player->health <= 0) &&
|
||||||
|
player->WeaponState & WF_WEAPONSWITCHOK)
|
||||||
|
{
|
||||||
|
P_DropWeapon(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
|
@ -92,12 +92,13 @@ const int CVF_REPLACE = 2;
|
||||||
|
|
||||||
// Flags for A_WeaponReady
|
// Flags for A_WeaponReady
|
||||||
const int WRF_NOBOB = 1;
|
const int WRF_NOBOB = 1;
|
||||||
const int WRF_NOFIRE = 12;
|
|
||||||
const int WRF_NOSWITCH = 2;
|
const int WRF_NOSWITCH = 2;
|
||||||
const int WRF_NOPRIMARY = 4;
|
const int WRF_NOPRIMARY = 4;
|
||||||
const int WRF_NOSECONDARY = 8;
|
const int WRF_NOSECONDARY = 8;
|
||||||
|
const int WRF_NOFIRE = WRF_NOPRIMARY | WRF_NOSECONDARY;
|
||||||
const int WRF_ALLOWRELOAD = 16;
|
const int WRF_ALLOWRELOAD = 16;
|
||||||
const int WRF_ALLOWZOOM = 32;
|
const int WRF_ALLOWZOOM = 32;
|
||||||
|
const int WRF_DISABLESWITCH = 64;
|
||||||
|
|
||||||
// Morph constants
|
// Morph constants
|
||||||
const int MRF_ADDSTAMINA = 1;
|
const int MRF_ADDSTAMINA = 1;
|
||||||
|
|
Loading…
Reference in a new issue