apply WeaponScaleX/Y to all PSprites on a weapon

This commit is contained in:
Xaser Acheron 2022-01-23 19:59:06 -06:00
parent 441b70022d
commit e9c86017e4
3 changed files with 25 additions and 3 deletions

View file

@ -1032,6 +1032,8 @@ xx(Crosshair)
xx(WeaponFlags)
xx(DropTime)
xx(PickupSound)
xx(WeaponScaleX)
xx(WeaponScaleY)
// PlayerPawn member fields
xx(ColorRangeStart)

View file

@ -252,6 +252,26 @@ DEFINE_ACTION_FUNCTION(_PlayerInfo, FindPSprite) // the underscore is needed to
}
//------------------------------------------------------------------------
//
//
//
//------------------------------------------------------------------------
static DPSprite *P_CreatePsprite(player_t *player, AActor *caller, int layer)
{
DPSprite *pspr = Create<DPSprite>(player, caller, layer);
// [XA] apply WeaponScaleX/WeaponScaleY properties for weapon psprites
if (caller != nullptr && caller->IsKindOf(NAME_Weapon))
{
pspr->baseScale.X = caller->FloatVar(NAME_WeaponScaleX);
pspr->baseScale.Y = caller->FloatVar(NAME_WeaponScaleY);
}
return pspr;
}
//------------------------------------------------------------------------
//
//
@ -301,7 +321,7 @@ DPSprite *player_t::GetPSprite(PSPLayers layer)
DPSprite *pspr = FindPSprite(layer);
if (pspr == nullptr)
{
pspr = Create<DPSprite>(this, newcaller, layer);
pspr = P_CreatePsprite(this, newcaller, layer);
}
else
{
@ -1112,7 +1132,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Overlay)
}
DPSprite *pspr;
pspr = Create<DPSprite>(player, stateowner, layer);
pspr = P_CreatePsprite(player, stateowner, layer);
pspr->SetState(state);
ACTION_RETURN_BOOL(true);
}

View file

@ -25,7 +25,7 @@ class Weapon : StateProvider
int BobStyle; // [XA] Bobbing style. Defines type of bobbing (e.g. Normal, Alpha) (visual only so no need to be a double)
float BobSpeed; // [XA] Bobbing speed. Defines how quickly a weapon bobs.
float BobRangeX, BobRangeY; // [XA] Bobbing range. Defines how far a weapon bobs in either direction.
float WeaponScaleX, WeaponScaleY; // [XA] Weapon scale. Defines the scale for the held weapon sprites (PSprite). Defaults to (1.0, 1.2) since that's what Doom does.
double WeaponScaleX, WeaponScaleY; // [XA] Weapon scale. Defines the scale for the held weapon sprites (PSprite). Defaults to (1.0, 1.2) since that's what Doom does.
Ammo Ammo1, Ammo2; // In-inventory instance variables
Weapon SisterWeapon;
double FOVScale;