mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-28 06:53:58 +00:00
- added Xaser's bobbing style options submission.
SVN r3615 (trunk)
This commit is contained in:
parent
5dbf486806
commit
cbcc7443c6
5 changed files with 110 additions and 6 deletions
|
@ -262,6 +262,9 @@ public:
|
|||
int SelectionOrder; // Lower-numbered weapons get picked first
|
||||
fixed_t MoveCombatDist; // Used by bots, but do they *really* need it?
|
||||
int ReloadCounter; // For A_CheckForReload
|
||||
int BobStyle; // [XA] Bobbing style. Defines type of bobbing (e.g. Normal, Alpha)
|
||||
fixed_t BobSpeed; // [XA] Bobbing speed. Defines how quickly a weapon bobs.
|
||||
fixed_t BobRangeX, BobRangeY; // [XA] Bobbing range. Defines how far a weapon bobs in either direction.
|
||||
|
||||
// In-inventory instance variables
|
||||
TObjPtr<AAmmo> Ammo1, Ammo2;
|
||||
|
@ -304,6 +307,16 @@ public:
|
|||
bool CheckAmmo (int fireMode, bool autoSwitch, bool requireAmmo=false, int ammocount = -1);
|
||||
bool DepleteAmmo (bool altFire, bool checkEnough=true, int ammouse = -1);
|
||||
|
||||
enum
|
||||
{
|
||||
BobNormal,
|
||||
BobInverse,
|
||||
BobAlpha,
|
||||
BobInverseAlpha,
|
||||
BobSmooth,
|
||||
BobInverseSmooth
|
||||
};
|
||||
|
||||
protected:
|
||||
AAmmo *AddAmmo (AActor *other, const PClass *ammotype, int amount);
|
||||
bool AddExistingAmmo (AAmmo *ammo, int amount);
|
||||
|
|
|
@ -59,8 +59,11 @@ void AWeapon::Serialize (FArchive &arc)
|
|||
<< MoveCombatDist
|
||||
<< Ammo1 << Ammo2 << SisterWeapon << GivenAsMorphWeapon
|
||||
<< bAltFire
|
||||
<< ReloadCounter
|
||||
<< FOVScale
|
||||
<< ReloadCounter;
|
||||
if (SaveVersion >= 3615) {
|
||||
arc << BobStyle << BobSpeed << BobRangeX << BobRangeY;
|
||||
}
|
||||
arc << FOVScale
|
||||
<< Crosshair;
|
||||
}
|
||||
|
||||
|
|
|
@ -366,6 +366,8 @@ void P_DropWeapon (player_t *player)
|
|||
// tic and not just when A_WeaponReady is called. Not all weapons execute
|
||||
// A_WeaponReady every tic, and it looks bad if they don't bob smoothly.
|
||||
//
|
||||
// [XA] Added new bob styles and exposed bob properties. Thanks, Ryan Cordell!
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
void P_BobWeapon (player_t *player, pspdef_t *psp, fixed_t *x, fixed_t *y)
|
||||
|
@ -383,8 +385,14 @@ void P_BobWeapon (player_t *player, pspdef_t *psp, fixed_t *x, fixed_t *y)
|
|||
return;
|
||||
}
|
||||
|
||||
// [XA] Get the current weapon's bob properties.
|
||||
int bobstyle = weapon->BobStyle;
|
||||
int bobspeed = (weapon->BobSpeed * 128) >> 16;
|
||||
fixed_t rangex = weapon->BobRangeX;
|
||||
fixed_t rangey = weapon->BobRangeY;
|
||||
|
||||
// Bob the weapon based on movement speed.
|
||||
int angle = (128*35/TICRATE*level.time)&FINEMASK;
|
||||
int angle = (bobspeed*35/TICRATE*level.time)&FINEMASK;
|
||||
|
||||
// [RH] Smooth transitions between bobbing and not-bobbing frames.
|
||||
// This also fixes the bug where you can "stick" a weapon off-center by
|
||||
|
@ -412,8 +420,39 @@ void P_BobWeapon (player_t *player, pspdef_t *psp, fixed_t *x, fixed_t *y)
|
|||
|
||||
if (curbob != 0)
|
||||
{
|
||||
*x = FixedMul(player->bob, finecosine[angle]);
|
||||
*y = FixedMul(player->bob, finesine[angle & (FINEANGLES/2-1)]);
|
||||
fixed_t bobx = FixedMul(player->bob, rangex);
|
||||
fixed_t boby = FixedMul(player->bob, rangey);
|
||||
switch (bobstyle)
|
||||
{
|
||||
case AWeapon::BobNormal:
|
||||
*x = FixedMul(bobx, finecosine[angle]);
|
||||
*y = FixedMul(boby, finesine[angle & (FINEANGLES/2-1)]);
|
||||
break;
|
||||
|
||||
case AWeapon::BobInverse:
|
||||
*x = FixedMul(bobx, finecosine[angle]);
|
||||
*y = boby - FixedMul(boby, finesine[angle & (FINEANGLES/2-1)]);
|
||||
break;
|
||||
|
||||
case AWeapon::BobAlpha:
|
||||
*x = FixedMul(bobx, finesine[angle]);
|
||||
*y = FixedMul(boby, finesine[angle & (FINEANGLES/2-1)]);
|
||||
break;
|
||||
|
||||
case AWeapon::BobInverseAlpha:
|
||||
*x = FixedMul(bobx, finesine[angle]);
|
||||
*y = boby - FixedMul(boby, finesine[angle & (FINEANGLES/2-1)]);
|
||||
break;
|
||||
|
||||
case AWeapon::BobSmooth:
|
||||
*x = FixedMul(bobx, finecosine[angle]);
|
||||
*y = (boby - FixedMul(boby, finecosine[angle*2 & (FINEANGLES-1)])) / 2;
|
||||
break;
|
||||
|
||||
case AWeapon::BobInverseSmooth:
|
||||
*x = FixedMul(bobx, finecosine[angle]);
|
||||
*y = (FixedMul(boby, finecosine[angle*2 & (FINEANGLES-1)]) + boby) / 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1759,6 +1759,52 @@ DEFINE_CLASS_PROPERTY(yadjust, F, Weapon)
|
|||
defaults->YAdjust = i;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//==========================================================================
|
||||
DEFINE_CLASS_PROPERTY(bobstyle, S, Weapon)
|
||||
{
|
||||
static const char *names[] = { "Normal", "Inverse", "Alpha", "InverseAlpha", "Smooth", "InverseSmooth", NULL };
|
||||
static const int flags[] = { AWeapon::BobNormal,
|
||||
AWeapon::BobInverse, AWeapon::BobAlpha, AWeapon::BobInverseAlpha,
|
||||
AWeapon::BobSmooth, AWeapon::BobInverseSmooth, };
|
||||
PROP_STRING_PARM(id, 0);
|
||||
int match = MatchString(id, names);
|
||||
if (match < 0)
|
||||
{
|
||||
I_Error("Unknown bobstyle %s", id);
|
||||
match = 0;
|
||||
}
|
||||
defaults->BobStyle |= flags[match];
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//==========================================================================
|
||||
DEFINE_CLASS_PROPERTY(bobspeed, F, Weapon)
|
||||
{
|
||||
PROP_FIXED_PARM(i, 0);
|
||||
defaults->BobSpeed = i;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//==========================================================================
|
||||
DEFINE_CLASS_PROPERTY(bobrangex, F, Weapon)
|
||||
{
|
||||
PROP_FIXED_PARM(i, 0);
|
||||
defaults->BobRangeX = i;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//==========================================================================
|
||||
DEFINE_CLASS_PROPERTY(bobrangey, F, Weapon)
|
||||
{
|
||||
PROP_FIXED_PARM(i, 0);
|
||||
defaults->BobRangeY = i;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//==========================================================================
|
||||
|
|
|
@ -329,7 +329,10 @@ ACTOR PuzzleItem : Inventory native
|
|||
Actor Weapon : Inventory native
|
||||
{
|
||||
Inventory.PickupSound "misc/w_pkup"
|
||||
Weapon.DefaultKickback
|
||||
Weapon.DefaultKickback
|
||||
Weapon.BobSpeed 1.0
|
||||
Weapon.BobRangeX 1.0
|
||||
Weapon.BobRangeY 1.0
|
||||
States
|
||||
{
|
||||
LightDone:
|
||||
|
|
Loading…
Reference in a new issue