- the remaining functions of player.cpp.

This commit is contained in:
Christoph Oelckers 2021-09-04 22:18:27 +02:00
parent fddc213fa8
commit 8f974dc1d8
3 changed files with 94 additions and 85 deletions

View file

@ -1785,17 +1785,15 @@ void playerProcess(PLAYER *pPlayer)
} }
} }
spritetype *playerFireMissile(PLAYER *pPlayer, int a2, int a3, int a4, int a5, int a6) DBloodActor* playerFireMissile(PLAYER *pPlayer, int a2, int a3, int a4, int a5, int a6)
{ {
auto misl = actFireMissile(pPlayer->actor(), a2, pPlayer->zWeapon-pPlayer->pSprite->z, a3, a4, a5, a6); return actFireMissile(pPlayer->actor(), a2, pPlayer->zWeapon-pPlayer->pSprite->z, a3, a4, a5, a6);
return misl ? &misl->s() : nullptr;
} }
spritetype * playerFireThing(PLAYER *pPlayer, int a2, int a3, int thingType, int a5) DBloodActor* playerFireThing(PLAYER *pPlayer, int a2, int a3, int thingType, int a5)
{ {
assert(thingType >= kThingBase && thingType < kThingMax); assert(thingType >= kThingBase && thingType < kThingMax);
auto misl = actFireThing(pPlayer->actor(), a2, pPlayer->zWeapon-pPlayer->pSprite->z, pPlayer->slope+a3, thingType, a5); return actFireThing(pPlayer->actor(), a2, pPlayer->zWeapon-pPlayer->pSprite->z, pPlayer->slope+a3, thingType, a5);
return misl ? &misl->s() : nullptr;
} }
void playerFrag(PLAYER *pKiller, PLAYER *pVictim) void playerFrag(PLAYER *pKiller, PLAYER *pVictim)
@ -1904,7 +1902,7 @@ int playerDamageArmor(PLAYER *pPlayer, DAMAGE_TYPE nType, int nDamage)
return nDamage; return nDamage;
} }
spritetype *flagDropped(PLAYER *pPlayer, int a2) void flagDropped(PLAYER *pPlayer, int a2)
{ {
auto playeractor = pPlayer->actor(); auto playeractor = pPlayer->actor();
DBloodActor* actor; DBloodActor* actor;
@ -1931,7 +1929,6 @@ spritetype *flagDropped(PLAYER *pPlayer, int a2)
viewSetMessage(buffer); viewSetMessage(buffer);
break; break;
} }
return pSprite;
} }
int playerDamageSprite(DBloodActor* source, PLAYER *pPlayer, DAMAGE_TYPE nDamageType, int nDamage) int playerDamageSprite(DBloodActor* source, PLAYER *pPlayer, DAMAGE_TYPE nDamageType, int nDamage)
@ -2043,7 +2040,7 @@ int playerDamageSprite(DBloodActor* source, PLAYER *pPlayer, DAMAGE_TYPE nDamage
nKneelingPlayer = nPlayerKneelClient; nKneelingPlayer = nPlayerKneelClient;
powerupActivate(pPlayer, kPwUpDeliriumShroom); powerupActivate(pPlayer, kPwUpDeliriumShroom);
pActor->SetTarget(source); pActor->SetTarget(source);
evPostActor(&bloodActors[pSprite->index], 15, kCallbackFinishHim); evPostActor(pPlayer->actor(), 15, kCallbackFinishHim);
} }
else else
{ {

View file

@ -263,11 +263,10 @@ void playerInit(int nPlayer, unsigned int a2);
void CheckPickUp(PLAYER *pPlayer); void CheckPickUp(PLAYER *pPlayer);
void ProcessInput(PLAYER *pPlayer); void ProcessInput(PLAYER *pPlayer);
void playerProcess(PLAYER *pPlayer); void playerProcess(PLAYER *pPlayer);
spritetype *playerFireMissile(PLAYER *pPlayer, int a2, int a3, int a4, int a5, int a6); DBloodActor *playerFireMissile(PLAYER *pPlayer, int a2, int a3, int a4, int a5, int a6);
spritetype *playerFireThing(PLAYER *pPlayer, int a2, int a3, int thingType, int a5); DBloodActor *playerFireThing(PLAYER *pPlayer, int a2, int a3, int thingType, int a5);
void playerFrag(PLAYER *pKiller, PLAYER *pVictim); void playerFrag(PLAYER *pKiller, PLAYER *pVictim);
int playerDamageArmor(PLAYER *pPlayer, DAMAGE_TYPE nType, int nDamage); int playerDamageArmor(PLAYER *pPlayer, DAMAGE_TYPE nType, int nDamage);
spritetype *flagDropped(PLAYER *pPlayer, int a2);
int playerDamageSprite(DBloodActor* nSource, PLAYER *pPlayer, DAMAGE_TYPE nDamageType, int nDamage); int playerDamageSprite(DBloodActor* nSource, PLAYER *pPlayer, DAMAGE_TYPE nDamageType, int nDamage);
int UseAmmo(PLAYER *pPlayer, int nAmmoType, int nDec); int UseAmmo(PLAYER *pPlayer, int nAmmoType, int nDec);
void voodooTarget(PLAYER *pPlayer); void voodooTarget(PLAYER *pPlayer);

View file

@ -1087,14 +1087,12 @@ void ThrowCan(int, PLAYER *pPlayer)
sfxKill3DSound(pPlayer->pSprite, -1, 441); sfxKill3DSound(pPlayer->pSprite, -1, 441);
int nSpeed = MulScale(pPlayer->throwPower, 0x177777, 16)+0x66666; int nSpeed = MulScale(pPlayer->throwPower, 0x177777, 16)+0x66666;
sfxPlay3DSound(pPlayer->pSprite, 455, 1, 0); sfxPlay3DSound(pPlayer->pSprite, 455, 1, 0);
spritetype *pSprite = playerFireThing(pPlayer, 0, -9460, kThingArmedSpray, nSpeed); auto spawned = playerFireThing(pPlayer, 0, -9460, kThingArmedSpray, nSpeed);
if (pSprite) if (spawned)
{ {
sfxPlay3DSound(pSprite, 441, 0, 0); sfxPlay3DSound(spawned, 441, 0, 0);
evPostActor(&bloodActors[pSprite->index], pPlayer->fuseTime, kCmdOn); evPostActor(spawned, pPlayer->fuseTime, kCmdOn);
int nXSprite = pSprite->extra; spawned->x().Impact = 1;
XSPRITE *pXSprite = &xsprite[nXSprite];
pXSprite->Impact = 1;
UseAmmo(pPlayer, 6, gAmmoItemData[0].count); UseAmmo(pPlayer, 6, gAmmoItemData[0].count);
pPlayer->throwPower = 0; pPlayer->throwPower = 0;
} }
@ -1103,10 +1101,10 @@ void ThrowCan(int, PLAYER *pPlayer)
void DropCan(int, PLAYER *pPlayer) void DropCan(int, PLAYER *pPlayer)
{ {
sfxKill3DSound(pPlayer->pSprite, -1, 441); sfxKill3DSound(pPlayer->pSprite, -1, 441);
spritetype *pSprite = playerFireThing(pPlayer, 0, 0, kThingArmedSpray, 0); auto spawned = playerFireThing(pPlayer, 0, 0, kThingArmedSpray, 0);
if (pSprite) if (spawned)
{ {
evPostActor(&bloodActors[pSprite->index], pPlayer->fuseTime, kCmdOn); evPostActor(spawned, pPlayer->fuseTime, kCmdOn);
UseAmmo(pPlayer, 6, gAmmoItemData[0].count); UseAmmo(pPlayer, 6, gAmmoItemData[0].count);
} }
} }
@ -1114,12 +1112,15 @@ void DropCan(int, PLAYER *pPlayer)
void ExplodeCan(int, PLAYER *pPlayer) void ExplodeCan(int, PLAYER *pPlayer)
{ {
sfxKill3DSound(pPlayer->pSprite, -1, 441); sfxKill3DSound(pPlayer->pSprite, -1, 441);
spritetype *pSprite = playerFireThing(pPlayer, 0, 0, kThingArmedSpray, 0); auto spawned = playerFireThing(pPlayer, 0, 0, kThingArmedSpray, 0);
evPostActor(&bloodActors[pSprite->index], 0, kCmdOn); if (spawned)
UseAmmo(pPlayer, 6, gAmmoItemData[0].count); {
StartQAV(pPlayer, kQAVCANBOOM); evPostActor(spawned, 0, kCmdOn);
pPlayer->curWeapon = kWeapNone; UseAmmo(pPlayer, 6, gAmmoItemData[0].count);
pPlayer->throwPower = 0; StartQAV(pPlayer, kQAVCANBOOM);
pPlayer->curWeapon = kWeapNone;
pPlayer->throwPower = 0;
}
} }
void ThrowBundle(int, PLAYER *pPlayer) void ThrowBundle(int, PLAYER *pPlayer)
@ -1127,72 +1128,87 @@ void ThrowBundle(int, PLAYER *pPlayer)
sfxKill3DSound(pPlayer->pSprite, 16, -1); sfxKill3DSound(pPlayer->pSprite, 16, -1);
int nSpeed = MulScale(pPlayer->throwPower, 0x177777, 16)+0x66666; int nSpeed = MulScale(pPlayer->throwPower, 0x177777, 16)+0x66666;
sfxPlay3DSound(pPlayer->pSprite, 455, 1, 0); sfxPlay3DSound(pPlayer->pSprite, 455, 1, 0);
spritetype *pSprite = playerFireThing(pPlayer, 0, -9460, kThingArmedTNTBundle, nSpeed); auto spawned = playerFireThing(pPlayer, 0, -9460, kThingArmedTNTBundle, nSpeed);
int nXSprite = pSprite->extra; if (spawned)
XSPRITE *pXSprite = &xsprite[nXSprite]; {
if (pPlayer->fuseTime < 0) if (pPlayer->fuseTime < 0)
pXSprite->Impact = 1; spawned->x().Impact = 1;
else else
evPostActor(&bloodActors[pSprite->index], pPlayer->fuseTime, kCmdOn); evPostActor(spawned, pPlayer->fuseTime, kCmdOn);
UseAmmo(pPlayer, 5, 1); UseAmmo(pPlayer, 5, 1);
pPlayer->throwPower = 0; pPlayer->throwPower = 0;
}
} }
void DropBundle(int, PLAYER *pPlayer) void DropBundle(int, PLAYER *pPlayer)
{ {
sfxKill3DSound(pPlayer->pSprite, 16, -1); sfxKill3DSound(pPlayer->pSprite, 16, -1);
spritetype *pSprite = playerFireThing(pPlayer, 0, 0, kThingArmedTNTBundle, 0); auto spawned = playerFireThing(pPlayer, 0, 0, kThingArmedTNTBundle, 0);
evPostActor(&bloodActors[pSprite->index], pPlayer->fuseTime, kCmdOn); if (spawned)
UseAmmo(pPlayer, 5, 1); {
evPostActor(spawned, pPlayer->fuseTime, kCmdOn);
UseAmmo(pPlayer, 5, 1);
}
} }
void ExplodeBundle(int, PLAYER *pPlayer) void ExplodeBundle(int, PLAYER *pPlayer)
{ {
sfxKill3DSound(pPlayer->pSprite, 16, -1); sfxKill3DSound(pPlayer->pSprite, 16, -1);
spritetype *pSprite = playerFireThing(pPlayer, 0, 0, kThingArmedTNTBundle, 0); auto spawned = playerFireThing(pPlayer, 0, 0, kThingArmedTNTBundle, 0);
evPostActor(&bloodActors[pSprite->index], 0, kCmdOn); if (spawned)
UseAmmo(pPlayer, 5, 1); {
StartQAV(pPlayer, kQAVDYNEXPLO); evPostActor(spawned, 0, kCmdOn);
pPlayer->curWeapon = kWeapNone; UseAmmo(pPlayer, 5, 1);
pPlayer->throwPower = 0; StartQAV(pPlayer, kQAVDYNEXPLO);
pPlayer->curWeapon = kWeapNone;
pPlayer->throwPower = 0;
}
} }
void ThrowProx(int, PLAYER *pPlayer) void ThrowProx(int, PLAYER *pPlayer)
{ {
int nSpeed = MulScale(pPlayer->throwPower, 0x177777, 16)+0x66666; int nSpeed = MulScale(pPlayer->throwPower, 0x177777, 16)+0x66666;
sfxPlay3DSound(pPlayer->pSprite, 455, 1, 0); sfxPlay3DSound(pPlayer->pSprite, 455, 1, 0);
spritetype *pSprite = playerFireThing(pPlayer, 0, -9460, kThingArmedProxBomb, nSpeed); auto spawned = playerFireThing(pPlayer, 0, -9460, kThingArmedProxBomb, nSpeed);
evPostActor(&bloodActors[pSprite->index], 240, kCmdOn); if (spawned)
UseAmmo(pPlayer, 10, 1); {
pPlayer->throwPower = 0; evPostActor(spawned, 240, kCmdOn);
UseAmmo(pPlayer, 10, 1);
pPlayer->throwPower = 0;
}
} }
void DropProx(int, PLAYER *pPlayer) void DropProx(int, PLAYER *pPlayer)
{ {
spritetype *pSprite = playerFireThing(pPlayer, 0, 0, kThingArmedProxBomb, 0); auto spawned = playerFireThing(pPlayer, 0, 0, kThingArmedProxBomb, 0);
evPostActor(&bloodActors[pSprite->index], 240, kCmdOn); if (spawned)
UseAmmo(pPlayer, 10, 1); {
evPostActor(spawned, 240, kCmdOn);
UseAmmo(pPlayer, 10, 1);
}
} }
void ThrowRemote(int, PLAYER *pPlayer) void ThrowRemote(int, PLAYER *pPlayer)
{ {
int nSpeed = MulScale(pPlayer->throwPower, 0x177777, 16)+0x66666; int nSpeed = MulScale(pPlayer->throwPower, 0x177777, 16)+0x66666;
sfxPlay3DSound(pPlayer->pSprite, 455, 1, 0); sfxPlay3DSound(pPlayer->pSprite, 455, 1, 0);
spritetype *pSprite = playerFireThing(pPlayer, 0, -9460, kThingArmedRemoteBomb, nSpeed); auto spawned = playerFireThing(pPlayer, 0, -9460, kThingArmedRemoteBomb, nSpeed);
int nXSprite = pSprite->extra; if (spawned)
XSPRITE *pXSprite = &xsprite[nXSprite]; {
pXSprite->rxID = 90+(pPlayer->pSprite->type-kDudePlayer1); spawned->x().rxID = 90 + (pPlayer->pSprite->type - kDudePlayer1);
UseAmmo(pPlayer, 11, 1); UseAmmo(pPlayer, 11, 1);
pPlayer->throwPower = 0; pPlayer->throwPower = 0;
}
} }
void DropRemote(int, PLAYER *pPlayer) void DropRemote(int, PLAYER *pPlayer)
{ {
spritetype *pSprite = playerFireThing(pPlayer, 0, 0, kThingArmedRemoteBomb, 0); auto spawned = playerFireThing(pPlayer, 0, 0, kThingArmedRemoteBomb, 0);
int nXSprite = pSprite->extra; if (spawned)
XSPRITE *pXSprite = &xsprite[nXSprite]; {
pXSprite->rxID = 90+(pPlayer->pSprite->type-kDudePlayer1); spawned->x().rxID = 90 + (pPlayer->pSprite->type - kDudePlayer1);
UseAmmo(pPlayer, 11, 1); UseAmmo(pPlayer, 11, 1);
}
} }
void FireRemote(int, PLAYER *pPlayer) void FireRemote(int, PLAYER *pPlayer)
@ -1576,13 +1592,11 @@ void AltFireVoodoo(int nTrigger, PLAYER *pPlayer)
void DropVoodoo(int , PLAYER *pPlayer) void DropVoodoo(int , PLAYER *pPlayer)
{ {
sfxPlay3DSound(pPlayer->pSprite, 455, 2, 0); sfxPlay3DSound(pPlayer->pSprite, 455, 2, 0);
spritetype *pSprite = playerFireThing(pPlayer, 0, -4730, kThingVoodooHead, 0xccccc); auto spawned = playerFireThing(pPlayer, 0, -4730, kThingVoodooHead, 0xccccc);
if (pSprite) if (spawned)
{ {
int nXSprite = pSprite->extra; spawned->x().data1 = pPlayer->ammoCount[9];
XSPRITE *pXSprite = &xsprite[nXSprite]; evPostActor(spawned, 90, kCallbackDropVoodoo);
pXSprite->data1 = pPlayer->ammoCount[9];
evPostActor(&bloodActors[pSprite->index], 90, kCallbackDropVoodoo);
UseAmmo(pPlayer, 6, gAmmoItemData[0].count); UseAmmo(pPlayer, 6, gAmmoItemData[0].count);
UseAmmo(pPlayer, 9, pPlayer->ammoCount[9]); UseAmmo(pPlayer, 9, pPlayer->ammoCount[9]);
pPlayer->hasWeapon[10] = 0; pPlayer->hasWeapon[10] = 0;
@ -1676,16 +1690,16 @@ void FireNapalm2(int , PLAYER *pPlayer)
void AltFireNapalm(int , PLAYER *pPlayer) void AltFireNapalm(int , PLAYER *pPlayer)
{ {
int nSpeed = MulScale(0x8000, 0x177777, 16)+0x66666; int nSpeed = MulScale(0x8000, 0x177777, 16)+0x66666;
spritetype *pMissile = playerFireThing(pPlayer, 0, -4730, kThingNapalmBall, nSpeed); auto missile = playerFireThing(pPlayer, 0, -4730, kThingNapalmBall, nSpeed);
if (pMissile) if (missile)
{ {
XSPRITE *pXSprite = &xsprite[pMissile->extra]; XSPRITE *pXSprite = &missile->x();
pXSprite->data4 = ClipHigh(pPlayer->ammoCount[4], 12); pXSprite->data4 = ClipHigh(pPlayer->ammoCount[4], 12);
UseAmmo(pPlayer, 4, pXSprite->data4); UseAmmo(pPlayer, 4, pXSprite->data4);
seqSpawn(22, 3, pMissile->extra, -1); seqSpawn(22, missile, -1);
actBurnSprite(pPlayer->actor(), &bloodActors[pMissile->index], 600); actBurnSprite(pPlayer->actor(), missile, 600);
evPostActor(&bloodActors[pMissile->index], 0, kCallbackFXFlameLick); evPostActor(missile, 0, kCallbackFXFlameLick);
sfxPlay3DSound(pMissile, 480, 2, 0); sfxPlay3DSound(missile, 480, 2, 0);
pPlayer->visibility = 30; pPlayer->visibility = 30;
pPlayer->flashEffect = 1; pPlayer->flashEffect = 1;
} }
@ -1699,13 +1713,11 @@ void FireLifeLeech(int nTrigger, PLAYER *pPlayer)
int r2 = Random2(2000); int r2 = Random2(2000);
int r3 = Random2(1000); int r3 = Random2(1000);
auto actor = pPlayer->actor(); auto actor = pPlayer->actor();
spritetype *pMissile = playerFireMissile(pPlayer, 0, pPlayer->aim.dx+r1, pPlayer->aim.dy+r2, pPlayer->aim.dz+r3, 315); auto missileActor = playerFireMissile(pPlayer, 0, pPlayer->aim.dx+r1, pPlayer->aim.dy+r2, pPlayer->aim.dz+r3, 315);
if (pMissile) if (missileActor)
{ {
auto missileActor = &bloodActors[pMissile->index];
XSPRITE *pXSprite = &xsprite[pMissile->extra];
missileActor->SetTarget(pPlayer->aimTarget); missileActor->SetTarget(pPlayer->aimTarget);
pMissile->ang = (nTrigger==2) ? 1024 : 0; missileActor->s().ang = (nTrigger==2) ? 1024 : 0;
} }
if (checkAmmo2(pPlayer, 8, 1)) if (checkAmmo2(pPlayer, 8, 1))
UseAmmo(pPlayer, 8, 1); UseAmmo(pPlayer, 8, 1);
@ -1718,11 +1730,12 @@ void AltFireLifeLeech(int , PLAYER *pPlayer)
{ {
auto actor = pPlayer->actor(); auto actor = pPlayer->actor();
sfxPlay3DSound(pPlayer->pSprite, 455, 2, 0); sfxPlay3DSound(pPlayer->pSprite, 455, 2, 0);
spritetype *pMissile = playerFireThing(pPlayer, 0, -4730, kThingDroppedLifeLeech, 0x19999); auto missile = playerFireThing(pPlayer, 0, -4730, kThingDroppedLifeLeech, 0x19999);
if (pMissile) if (missile)
{ {
auto pMissile = &missile->s();
pMissile->cstat |= 4096; pMissile->cstat |= 4096;
XSPRITE *pXSprite = &xsprite[pMissile->extra]; XSPRITE *pXSprite = &missile->x();
pXSprite->Push = 1; pXSprite->Push = 1;
pXSprite->Proximity = 1; pXSprite->Proximity = 1;
pXSprite->DudeLockout = 1; pXSprite->DudeLockout = 1;