- floatified and consolidated throwPower handling.

This commit is contained in:
Christoph Oelckers 2022-09-29 13:17:27 +02:00
parent a87c4809f5
commit 5ab75f45e9
4 changed files with 31 additions and 14 deletions

View file

@ -135,7 +135,7 @@ struct PLAYER
int qavTimer;
int fuseTime;
int throwTime;
int throwPower;
double throwPower;
DVector3 aim; // world
DVector3 relAim; // relative
DVector3 flt_aim() const { return aim; }

View file

@ -139,6 +139,23 @@ enum
nClientAltFireNapalm,
};
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
double getThrowPower(PLAYER* pPlayer)
{
return pPlayer->throwPower * 23.46666 + 6.4;
}
void setThrowPower(PLAYER* pPlayer)
{
pPlayer->throwPower = min((PlayClock - pPlayer->throwTime) / 240., 1.);
}
//---------------------------------------------------------------------------
//
//
@ -1179,7 +1196,7 @@ void FireSpray(int, PLAYER* pPlayer)
void ThrowCan(int, PLAYER* pPlayer)
{
sfxKill3DSound(pPlayer->actor, -1, 441);
double nSpeed = FixedToFloat(MulScale(pPlayer->throwPower, 0x177777, 16) + 0x66666); // deal with this later.
double nSpeed = getThrowPower(pPlayer);
sfxPlay3DSound(pPlayer->actor, 455, 1, 0);
auto spawned = playerFireThing(pPlayer, 0, -9460 / 65536., kThingArmedSpray, nSpeed);
if (spawned)
@ -1239,7 +1256,7 @@ void ExplodeCan(int, PLAYER* pPlayer)
void ThrowBundle(int, PLAYER* pPlayer)
{
sfxKill3DSound(pPlayer->actor, 16, -1);
double nSpeed = FixedToFloat(MulScale(pPlayer->throwPower, 0x177777, 16) + 0x66666); // deal with this later.
double nSpeed = getThrowPower(pPlayer);
sfxPlay3DSound(pPlayer->actor, 455, 1, 0);
auto spawned = playerFireThing(pPlayer, 0, -9460 / 65536., kThingArmedTNTBundle, nSpeed);
if (spawned)
@ -1298,7 +1315,7 @@ void ExplodeBundle(int, PLAYER* pPlayer)
void ThrowProx(int, PLAYER* pPlayer)
{
double nSpeed = FixedToFloat(MulScale(pPlayer->throwPower, 0x177777, 16) + 0x66666); // deal with this later.
double nSpeed = getThrowPower(pPlayer);
sfxPlay3DSound(pPlayer->actor, 455, 1, 0);
auto spawned = playerFireThing(pPlayer, 0, -9460 / 65536., kThingArmedProxBomb, nSpeed);
if (spawned)
@ -1333,7 +1350,7 @@ void DropProx(int, PLAYER* pPlayer)
void ThrowRemote(int, PLAYER* pPlayer)
{
double nSpeed = FixedToFloat(MulScale(pPlayer->throwPower, 0x177777, 16) + 0x66666); // deal with this later.
double nSpeed = getThrowPower(pPlayer);
sfxPlay3DSound(pPlayer->actor, 455, 1, 0);
auto spawned = playerFireThing(pPlayer, 0, -9460 / 65536., kThingArmedRemoteBomb, nSpeed);
if (spawned)
@ -2170,7 +2187,7 @@ int processSprayCan(PLAYER* pPlayer)
return 1;
case 7:
{
pPlayer->throwPower = ClipHigh(DivScale(PlayClock - pPlayer->throwTime, 240, 16), 65536);
setThrowPower(pPlayer);
if (!(pPlayer->input.actions & SB_FIRE))
{
if (!pPlayer->fuseTime)
@ -2214,7 +2231,7 @@ static bool processTNT(PLAYER* pPlayer)
return 1;
case 6:
{
pPlayer->throwPower = ClipHigh(DivScale(PlayClock - pPlayer->throwTime, 240, 16), 65536);
setThrowPower(pPlayer);
if (!(pPlayer->input.actions & SB_FIRE))
{
if (!pPlayer->fuseTime)
@ -2239,7 +2256,7 @@ static bool processProxy(PLAYER* pPlayer)
switch (pPlayer->weaponState)
{
case 9:
pPlayer->throwPower = ClipHigh(DivScale(PlayClock - pPlayer->throwTime, 240, 16), 65536);
setThrowPower(pPlayer);
pPlayer->weaponTimer = 0;
pPlayer->qavTimer = 0;
if (!(pPlayer->input.actions & SB_FIRE))
@ -2263,7 +2280,7 @@ static bool processRemote(PLAYER* pPlayer)
switch (pPlayer->weaponState)
{
case 13:
pPlayer->throwPower = ClipHigh(DivScale(PlayClock - pPlayer->throwTime, 240, 16), 65536);
setThrowPower(pPlayer);
if (!(pPlayer->input.actions & SB_FIRE))
{
pPlayer->weaponState = 11;

View file

@ -94,7 +94,7 @@ struct BloodPlayer native
native bool qavLoop;
native int fuseTime;
native int throwTime;
native int throwPower;
native double throwPower;
//native Aim aim; // world
//native int aimTarget; // aim target sprite
native int aimTargetsCount;

View file

@ -117,7 +117,7 @@ class BloodStatusBar : RazeStatusBar
//
//---------------------------------------------------------------------------
void TileHGauge(String nTile, double x, double y, int nMult, int nDiv, double sc = 1)
void TileHGauge(String nTile, double x, double y, double nMult, double nDiv, double sc = 1)
{
int w = texWidth(nTile);
double bx = w * sc * nMult / nDiv + x;
@ -555,7 +555,7 @@ class BloodStatusBar : RazeStatusBar
DrawImage("BlinkIcon", (201.5, 185.5), DI_ITEM_RELCENTER, col:Raze.shadeToLight(pPlayer.isRunning || cl_bloodvanillarun ? 16 : 40));
if (pPlayer.throwPower)
{
TileHGauge("ThrowGauge", 124, 175.5, pPlayer.throwPower, 65536);
TileHGauge("ThrowGauge", 124, 175.5, pPlayer.throwPower, 1);
}
drawInventory(pPlayer, 166, 200 - th);
// Depending on the scale we can lower the stats display. This needs some tweaking but this catches the important default case already.
@ -695,7 +695,7 @@ class BloodStatusBar : RazeStatusBar
BeginStatusBar(false, 320, 200, 28);
if (pPlayer.throwPower)
TileHGauge("ThrowGauge", 124, 175, pPlayer.throwPower, 65536);
TileHGauge("ThrowGauge", 124, 175, pPlayer.throwPower, 1);
else
drawInventory(pPlayer, 166, 200 - texHeight("FULLHUD") / 2 - 30);
return 28;
@ -732,7 +732,7 @@ class BloodStatusBar : RazeStatusBar
{
BeginStatusBar(false, 320, 200, 28);
if (pPlayer.throwPower)
TileHGauge("ThrowGauge", 124, 175, pPlayer.throwPower, 65536);
TileHGauge("ThrowGauge", 124, 175, pPlayer.throwPower, 1);
else if (hud_size > Hud_StbarOverlay)
drawInventory(pPlayer, 166, 200 - texHeight("FullHUD") / 2);
}