- Updated scripting branch to latest version in trunk.
SVN r4337 (scripting)
This commit is contained in:
commit
459ad5abff
282 changed files with 15968 additions and 3535 deletions
161
src/p_pspr.cpp
161
src/p_pspr.cpp
|
|
@ -95,7 +95,7 @@ void P_SetPsprite (player_t *player, int position, FState *state, bool nofunctio
|
|||
|
||||
if (position == ps_weapon && !nofunction)
|
||||
{ // A_WeaponReady will re-set these as needed
|
||||
player->cheats &= ~(CF_WEAPONREADY | CF_WEAPONREADYALT | CF_WEAPONBOBBING | CF_WEAPONSWITCHOK | CF_WEAPONRELOADOK | CF_WEAPONZOOMOK);
|
||||
player->WeaponState &= ~(WF_WEAPONREADY | WF_WEAPONREADYALT | WF_WEAPONBOBBING | WF_WEAPONSWITCHOK | WF_WEAPONRELOADOK | WF_WEAPONZOOMOK);
|
||||
}
|
||||
|
||||
psp = &player->psprites[position];
|
||||
|
|
@ -170,8 +170,11 @@ void P_BringUpWeapon (player_t *player)
|
|||
|
||||
if (player->PendingWeapon == WP_NOCHANGE)
|
||||
{
|
||||
player->psprites[ps_weapon].sy = WEAPONTOP;
|
||||
P_SetPsprite (player, ps_weapon, player->ReadyWeapon->GetReadyState());
|
||||
if (player->ReadyWeapon != NULL)
|
||||
{
|
||||
player->psprites[ps_weapon].sy = WEAPONTOP;
|
||||
P_SetPsprite (player, ps_weapon, player->ReadyWeapon->GetReadyState());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -352,6 +355,12 @@ void P_ZoomWeapon (player_t *player, FState *state)
|
|||
|
||||
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)
|
||||
{
|
||||
P_SetPsprite (player, ps_weapon, player->ReadyWeapon->GetDownState());
|
||||
|
|
@ -397,7 +406,7 @@ void P_BobWeapon (player_t *player, pspdef_t *psp, fixed_t *x, fixed_t *y)
|
|||
// [RH] Smooth transitions between bobbing and not-bobbing frames.
|
||||
// This also fixes the bug where you can "stick" a weapon off-center by
|
||||
// shooting it when it's at the peak of its swing.
|
||||
bobtarget = (player->cheats & CF_WEAPONBOBBING) ? player->bob : 0;
|
||||
bobtarget = (player->WeaponState & WF_WEAPONBOBBING) ? player->bob : 0;
|
||||
if (curbob != bobtarget)
|
||||
{
|
||||
if (abs (bobtarget - curbob) <= 1*FRACUNIT)
|
||||
|
|
@ -471,15 +480,43 @@ void P_BobWeapon (player_t *player, pspdef_t *psp, fixed_t *x, fixed_t *y)
|
|||
//
|
||||
//============================================================================
|
||||
|
||||
void DoReadyWeaponToSwitch (AActor * self)
|
||||
void DoReadyWeaponToSwitch (AActor *self, bool switchable)
|
||||
{
|
||||
// Prepare for switching action.
|
||||
player_t *player;
|
||||
if (self && (player = self->player))
|
||||
player->cheats |= CF_WEAPONSWITCHOK;
|
||||
{
|
||||
if (switchable)
|
||||
{
|
||||
player->WeaponState |= WF_WEAPONSWITCHOK | WF_REFIRESWITCHOK;
|
||||
}
|
||||
else
|
||||
{
|
||||
// WF_WEAPONSWITCHOK is automatically cleared every tic by P_SetPsprite().
|
||||
player->WeaponState &= ~WF_REFIRESWITCHOK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
player->WeaponState &= ~WF_REFIRESWITCHOK;
|
||||
}
|
||||
else
|
||||
{
|
||||
player->WeaponState &= ~WF_DISABLESWITCH;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DoReadyWeaponToFire (AActor *self, bool prim, bool alt)
|
||||
{
|
||||
player_t *player;
|
||||
AWeapon *weapon;
|
||||
|
|
@ -506,41 +543,41 @@ void DoReadyWeaponToFire (AActor * self, bool prim, bool alt)
|
|||
}
|
||||
|
||||
// Prepare for firing action.
|
||||
player->cheats |= ((prim ? CF_WEAPONREADY : 0) | (alt ? CF_WEAPONREADYALT : 0));
|
||||
player->WeaponState |= ((prim ? WF_WEAPONREADY : 0) | (alt ? WF_WEAPONREADYALT : 0));
|
||||
return;
|
||||
}
|
||||
|
||||
void DoReadyWeaponToBob (AActor * self)
|
||||
void DoReadyWeaponToBob (AActor *self)
|
||||
{
|
||||
if (self && self->player && self->player->ReadyWeapon)
|
||||
{
|
||||
// Prepare for bobbing action.
|
||||
self->player->cheats |= CF_WEAPONBOBBING;
|
||||
self->player->WeaponState |= WF_WEAPONBOBBING;
|
||||
self->player->psprites[ps_weapon].sx = 0;
|
||||
self->player->psprites[ps_weapon].sy = WEAPONTOP;
|
||||
}
|
||||
}
|
||||
|
||||
void DoReadyWeaponToReload (AActor * self)
|
||||
void DoReadyWeaponToReload (AActor *self)
|
||||
{
|
||||
// Prepare for reload action.
|
||||
player_t *player;
|
||||
if (self && (player = self->player))
|
||||
player->cheats |= CF_WEAPONRELOADOK;
|
||||
player->WeaponState |= WF_WEAPONRELOADOK;
|
||||
return;
|
||||
}
|
||||
|
||||
void DoReadyWeaponToZoom (AActor * self)
|
||||
void DoReadyWeaponToZoom (AActor *self)
|
||||
{
|
||||
// Prepare for reload action.
|
||||
player_t *player;
|
||||
if (self && (player = self->player))
|
||||
player->cheats |= CF_WEAPONZOOMOK;
|
||||
player->WeaponState |= WF_WEAPONZOOMOK;
|
||||
return;
|
||||
}
|
||||
|
||||
// This function replaces calls to A_WeaponReady in other codepointers.
|
||||
void DoReadyWeapon(AActor * self)
|
||||
void DoReadyWeapon(AActor *self)
|
||||
{
|
||||
DoReadyWeaponToBob(self);
|
||||
DoReadyWeaponToFire(self);
|
||||
|
|
@ -552,12 +589,13 @@ void DoReadyWeapon(AActor * self)
|
|||
enum EWRF_Options
|
||||
{
|
||||
WRF_NoBob = 1,
|
||||
WRF_NoFire = 12,
|
||||
WRF_NoSwitch = 2,
|
||||
WRF_NoPrimary = 4,
|
||||
WRF_NoSecondary = 8,
|
||||
WRF_NoFire = WRF_NoPrimary + WRF_NoSecondary,
|
||||
WRF_AllowReload = 16,
|
||||
WRF_AllowZoom = 32,
|
||||
WRF_DisableSwitch = 64,
|
||||
};
|
||||
|
||||
DEFINE_ACTION_FUNCTION_PARAMS(AInventory, A_WeaponReady)
|
||||
|
|
@ -565,16 +603,13 @@ DEFINE_ACTION_FUNCTION_PARAMS(AInventory, A_WeaponReady)
|
|||
PARAM_ACTION_PROLOGUE;
|
||||
PARAM_INT_OPT(flags) { flags = 0; }
|
||||
|
||||
if (!(flags & WRF_NoSwitch))
|
||||
DoReadyWeaponToSwitch(self);
|
||||
if ((flags & WRF_NoFire) != WRF_NoFire)
|
||||
DoReadyWeaponToFire(self, !(flags & WRF_NoPrimary), !(flags & WRF_NoSecondary));
|
||||
if (!(flags & WRF_NoBob))
|
||||
DoReadyWeaponToBob(self);
|
||||
if ((flags & WRF_AllowReload))
|
||||
DoReadyWeaponToReload(self);
|
||||
if ((flags & WRF_AllowZoom))
|
||||
DoReadyWeaponToZoom(self);
|
||||
DoReadyWeaponToSwitch(self, !(flags & WRF_NoSwitch));
|
||||
if ((flags & WRF_NoFire) != WRF_NoFire) DoReadyWeaponToFire(self, !(flags & WRF_NoPrimary), !(flags & WRF_NoSecondary));
|
||||
if (!(flags & WRF_NoBob)) DoReadyWeaponToBob(self);
|
||||
if ((flags & WRF_AllowReload)) DoReadyWeaponToReload(self);
|
||||
if ((flags & WRF_AllowZoom)) DoReadyWeaponToZoom(self);
|
||||
|
||||
DoReadyWeaponDisableSwitch(self, flags & WRF_DisableSwitch);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -596,7 +631,7 @@ void P_CheckWeaponFire (player_t *player)
|
|||
return;
|
||||
|
||||
// Check for fire. Some weapons do not auto fire.
|
||||
if ((player->cheats & CF_WEAPONREADY) && (player->cmd.ucmd.buttons & BT_ATTACK))
|
||||
if ((player->WeaponState & WF_WEAPONREADY) && (player->cmd.ucmd.buttons & BT_ATTACK))
|
||||
{
|
||||
if (!player->attackdown || !(weapon->WeaponFlags & WIF_NOAUTOFIRE))
|
||||
{
|
||||
|
|
@ -605,7 +640,7 @@ void P_CheckWeaponFire (player_t *player)
|
|||
return;
|
||||
}
|
||||
}
|
||||
else if ((player->cheats & CF_WEAPONREADYALT) && (player->cmd.ucmd.buttons & BT_ALTATTACK))
|
||||
else if ((player->WeaponState & WF_WEAPONREADYALT) && (player->cmd.ucmd.buttons & BT_ALTATTACK))
|
||||
{
|
||||
if (!player->attackdown || !(weapon->WeaponFlags & WIF_NOAUTOFIRE))
|
||||
{
|
||||
|
|
@ -631,22 +666,23 @@ void P_CheckWeaponFire (player_t *player)
|
|||
|
||||
void P_CheckWeaponSwitch (player_t *player)
|
||||
{
|
||||
AWeapon *weapon;
|
||||
|
||||
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)
|
||||
if (player == NULL)
|
||||
{
|
||||
P_SetPsprite (player, ps_weapon, weapon->GetDownState());
|
||||
return;
|
||||
}
|
||||
else if (player->morphTics != 0)
|
||||
{
|
||||
// morphed classes cannot change weapons so don't even try again.
|
||||
if ((player->WeaponState & WF_DISABLESWITCH) || // Weapon changing has been disabled.
|
||||
player->morphTics != 0) // Morphed classes cannot change weapons.
|
||||
{ // ...so throw away any pending weapon requests.
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
|
@ -665,7 +701,7 @@ void P_CheckWeaponReload (player_t *player)
|
|||
return;
|
||||
|
||||
// Check for reload.
|
||||
if ((player->cheats & CF_WEAPONRELOADOK) && (player->cmd.ucmd.buttons & BT_RELOAD))
|
||||
if ((player->WeaponState & WF_WEAPONRELOADOK) && (player->cmd.ucmd.buttons & BT_RELOAD))
|
||||
{
|
||||
P_ReloadWeapon (player, NULL);
|
||||
}
|
||||
|
|
@ -687,7 +723,7 @@ void P_CheckWeaponZoom (player_t *player)
|
|||
return;
|
||||
|
||||
// Check for zoom.
|
||||
if ((player->cheats & CF_WEAPONZOOMOK) && (player->cmd.ucmd.buttons & BT_ZOOM))
|
||||
if ((player->WeaponState & WF_WEAPONZOOMOK) && (player->cmd.ucmd.buttons & BT_ZOOM))
|
||||
{
|
||||
P_ZoomWeapon (player, NULL);
|
||||
}
|
||||
|
|
@ -712,21 +748,21 @@ DEFINE_ACTION_FUNCTION_PARAMS(AInventory, A_ReFire)
|
|||
void A_ReFire(AActor *self, FState *state)
|
||||
{
|
||||
player_t *player = self->player;
|
||||
bool pending;
|
||||
|
||||
if (NULL == player)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ((player->cmd.ucmd.buttons&BT_ATTACK)
|
||||
&& !player->ReadyWeapon->bAltFire
|
||||
&& player->PendingWeapon == WP_NOCHANGE && player->health)
|
||||
pending = player->PendingWeapon != WP_NOCHANGE && (player->WeaponState & WF_REFIRESWITCHOK);
|
||||
if ((player->cmd.ucmd.buttons & BT_ATTACK)
|
||||
&& !player->ReadyWeapon->bAltFire && !pending && player->health > 0)
|
||||
{
|
||||
player->refire++;
|
||||
P_FireWeapon (player, state);
|
||||
}
|
||||
else if ((player->cmd.ucmd.buttons&BT_ALTATTACK)
|
||||
&& player->ReadyWeapon->bAltFire
|
||||
&& player->PendingWeapon == WP_NOCHANGE && player->health)
|
||||
else if ((player->cmd.ucmd.buttons & BT_ALTATTACK)
|
||||
&& player->ReadyWeapon->bAltFire && !pending && player->health > 0)
|
||||
{
|
||||
player->refire++;
|
||||
P_FireWeaponAlt (player, state);
|
||||
|
|
@ -807,17 +843,11 @@ DEFINE_ACTION_FUNCTION(AInventory, A_Lower)
|
|||
if (player->playerstate == PST_DEAD)
|
||||
{ // Player is dead, so don't bring up a pending weapon
|
||||
psp->sy = WEAPONBOTTOM;
|
||||
return 0;
|
||||
}
|
||||
if (player->health <= 0)
|
||||
{ // Player is dead, so keep the weapon off screen
|
||||
|
||||
// Player is dead, so keep the weapon off screen
|
||||
P_SetPsprite (player, ps_weapon, NULL);
|
||||
return 0;
|
||||
}
|
||||
/* if (player->PendingWeapon != WP_NOCHANGE)
|
||||
{ // [RH] Make sure we're actually changing weapons.
|
||||
player->ReadyWeapon = player->PendingWeapon;
|
||||
} */
|
||||
// [RH] Clear the flash state. Only needed for Strife.
|
||||
P_SetPsprite (player, ps_flash, NULL);
|
||||
P_BringUpWeapon (player);
|
||||
|
|
@ -847,7 +877,7 @@ DEFINE_ACTION_FUNCTION(AInventory, A_Raise)
|
|||
}
|
||||
if (player->PendingWeapon != WP_NOCHANGE)
|
||||
{
|
||||
P_SetPsprite (player, ps_weapon, player->ReadyWeapon->GetDownState());
|
||||
P_DropWeapon(player);
|
||||
return 0;
|
||||
}
|
||||
psp = &player->psprites[ps_weapon];
|
||||
|
|
@ -1011,7 +1041,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AInventory, A_Light)
|
|||
|
||||
if (self->player != NULL)
|
||||
{
|
||||
self->player->extralight = clamp<int>(light, 0, 20);
|
||||
self->player->extralight = clamp<int>(light, -20, 20);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1024,7 +1054,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AInventory, A_Light)
|
|||
//
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
void P_SetupPsprites(player_t *player)
|
||||
void P_SetupPsprites(player_t *player, bool startweaponup)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
|
@ -1034,7 +1064,7 @@ void P_SetupPsprites(player_t *player)
|
|||
player->psprites[i].state = NULL;
|
||||
}
|
||||
// Spawn the ready weapon
|
||||
player->PendingWeapon = player->ReadyWeapon;
|
||||
player->PendingWeapon = !startweaponup ? player->ReadyWeapon : WP_NOCHANGE;
|
||||
P_BringUpWeapon (player);
|
||||
}
|
||||
|
||||
|
|
@ -1075,7 +1105,7 @@ void P_MovePsprites (player_t *player)
|
|||
psp->tics--;
|
||||
|
||||
// [BC] Apply double firing speed.
|
||||
if ( psp->tics && ( player->cheats & CF_DOUBLEFIRINGSPEED ))
|
||||
if ( psp->tics && (player->cheats & CF_DOUBLEFIRINGSPEED))
|
||||
psp->tics--;
|
||||
|
||||
if(!psp->tics)
|
||||
|
|
@ -1087,19 +1117,16 @@ void P_MovePsprites (player_t *player)
|
|||
}
|
||||
player->psprites[ps_flash].sx = player->psprites[ps_weapon].sx;
|
||||
player->psprites[ps_flash].sy = player->psprites[ps_weapon].sy;
|
||||
if (player->cheats & CF_WEAPONSWITCHOK)
|
||||
{
|
||||
P_CheckWeaponSwitch (player);
|
||||
}
|
||||
if (player->cheats & (CF_WEAPONREADY | CF_WEAPONREADYALT))
|
||||
P_CheckWeaponSwitch (player);
|
||||
if (player->WeaponState & (WF_WEAPONREADY | WF_WEAPONREADYALT))
|
||||
{
|
||||
P_CheckWeaponFire (player);
|
||||
}
|
||||
if (player->cheats & CF_WEAPONRELOADOK)
|
||||
if (player->WeaponState & WF_WEAPONRELOADOK)
|
||||
{
|
||||
P_CheckWeaponReload (player);
|
||||
}
|
||||
if (player->cheats & CF_WEAPONZOOMOK)
|
||||
if (player->WeaponState & WF_WEAPONZOOMOK)
|
||||
{
|
||||
P_CheckWeaponZoom (player);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue