mirror of
https://github.com/DrBeef/Raze.git
synced 2025-01-19 15:40:58 +00:00
- SetSpriteState
This commit is contained in:
parent
7e8fc3fe65
commit
0ae664e9ca
4 changed files with 44 additions and 52 deletions
|
@ -7434,13 +7434,4 @@ void HITINFO::set(hitdata_t* hit)
|
||||||
hitz = hit->pos.z;
|
hitz = hit->pos.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char SetSpriteState(DBloodActor* actor, int nState)
|
|
||||||
{
|
|
||||||
return SetSpriteState(actor->GetIndex(), &actor->x(), nState);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
END_BLD_NS
|
END_BLD_NS
|
||||||
|
|
|
@ -1564,7 +1564,7 @@ void ProcessInput(PLAYER *pPlayer)
|
||||||
if (pXSprite->locked && pPlayer == gMe && pXSprite->lockMsg)
|
if (pXSprite->locked && pPlayer == gMe && pXSprite->lockMsg)
|
||||||
trTextOver(pXSprite->lockMsg);
|
trTextOver(pXSprite->lockMsg);
|
||||||
if (!key || pPlayer->hasKey[key])
|
if (!key || pPlayer->hasKey[key])
|
||||||
trTriggerSprite(a2, pXSprite, kCmdSpritePush);
|
trTriggerSprite(act->GetIndex(), pXSprite, kCmdSpritePush);
|
||||||
else if (pPlayer == gMe)
|
else if (pPlayer == gMe)
|
||||||
{
|
{
|
||||||
viewSetMessage(GStrings("TXTB_KEY"));
|
viewSetMessage(GStrings("TXTB_KEY"));
|
||||||
|
|
|
@ -49,15 +49,16 @@ unsigned int GetWaveValue(unsigned int nPhase, int nType)
|
||||||
return nPhase;
|
return nPhase;
|
||||||
}
|
}
|
||||||
|
|
||||||
char SetSpriteState(int nSprite, XSPRITE* pXSprite, int nState)
|
bool SetSpriteState(DBloodActor* actor, int nState)
|
||||||
{
|
{
|
||||||
auto actor = &bloodActors[nSprite];
|
auto pSprite = &actor->s();
|
||||||
|
auto pXSprite = &actor->x();
|
||||||
if ((pXSprite->busy & 0xffff) == 0 && pXSprite->state == nState)
|
if ((pXSprite->busy & 0xffff) == 0 && pXSprite->state == nState)
|
||||||
return 0;
|
return 0;
|
||||||
pXSprite->busy = IntToFixed(nState);
|
pXSprite->busy = IntToFixed(nState);
|
||||||
pXSprite->state = nState;
|
pXSprite->state = nState;
|
||||||
evKillActor(actor);
|
evKillActor(actor);
|
||||||
if ((sprite[nSprite].flags & kHitagRespawn) != 0 && sprite[nSprite].inittype >= kDudeBase && sprite[nSprite].inittype < kDudeMax)
|
if ((pSprite->flags & kHitagRespawn) != 0 && pSprite->inittype >= kDudeBase && pSprite->inittype < kDudeMax)
|
||||||
{
|
{
|
||||||
pXSprite->respawnPending = 3;
|
pXSprite->respawnPending = 3;
|
||||||
evPostActor(actor, gGameOptions.nMonsterRespawnTime, kCallbackRespawn);
|
evPostActor(actor, gGameOptions.nMonsterRespawnTime, kCallbackRespawn);
|
||||||
|
@ -75,7 +76,7 @@ char SetSpriteState(int nSprite, XSPRITE* pXSprite, int nState)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
char SetWallState(int nWall, XWALL *pXWall, int nState)
|
bool SetWallState(int nWall, XWALL *pXWall, int nState)
|
||||||
{
|
{
|
||||||
if ((pXWall->busy&0xffff) == 0 && pXWall->state == nState)
|
if ((pXWall->busy&0xffff) == 0 && pXWall->state == nState)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -94,7 +95,7 @@ char SetWallState(int nWall, XWALL *pXWall, int nState)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
char SetSectorState(int nSector, XSECTOR *pXSector, int nState)
|
bool SetSectorState(int nSector, XSECTOR *pXSector, int nState)
|
||||||
{
|
{
|
||||||
if ((pXSector->busy&0xffff) == 0 && pXSector->state == nState)
|
if ((pXSector->busy&0xffff) == 0 && pXSector->state == nState)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -300,7 +301,7 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event)
|
||||||
|
|
||||||
switch (event.cmd) {
|
switch (event.cmd) {
|
||||||
case kCmdOff:
|
case kCmdOff:
|
||||||
SetSpriteState(nSprite, pXSprite, 0);
|
SetSpriteState(actor, 0);
|
||||||
break;
|
break;
|
||||||
case kCmdSpriteProximity:
|
case kCmdSpriteProximity:
|
||||||
if (pXSprite->state) break;
|
if (pXSprite->state) break;
|
||||||
|
@ -308,7 +309,7 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event)
|
||||||
case kCmdOn:
|
case kCmdOn:
|
||||||
case kCmdSpritePush:
|
case kCmdSpritePush:
|
||||||
case kCmdSpriteTouch:
|
case kCmdSpriteTouch:
|
||||||
if (!pXSprite->state) SetSpriteState(nSprite, pXSprite, 1);
|
if (!pXSprite->state) SetSpriteState(actor, 1);
|
||||||
aiActivateDude(&bloodActors[pXSprite->reference]);
|
aiActivateDude(&bloodActors[pXSprite->reference]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -322,11 +323,11 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event)
|
||||||
if (pXSprite->health <= 0) break;
|
if (pXSprite->health <= 0) break;
|
||||||
switch (event.cmd) {
|
switch (event.cmd) {
|
||||||
case kCmdOff:
|
case kCmdOff:
|
||||||
if (!SetSpriteState(nSprite, pXSprite, 0)) break;
|
if (!SetSpriteState(actor, 0)) break;
|
||||||
seqSpawn(40, actor, -1);
|
seqSpawn(40, actor, -1);
|
||||||
break;
|
break;
|
||||||
case kCmdOn:
|
case kCmdOn:
|
||||||
if (!SetSpriteState(nSprite, pXSprite, 1)) break;
|
if (!SetSpriteState(actor, 1)) break;
|
||||||
seqSpawn(38, actor, nMGunOpenClient);
|
seqSpawn(38, actor, nMGunOpenClient);
|
||||||
if (pXSprite->data1 > 0)
|
if (pXSprite->data1 > 0)
|
||||||
pXSprite->data2 = pXSprite->data1;
|
pXSprite->data2 = pXSprite->data1;
|
||||||
|
@ -334,15 +335,15 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case kThingFallingRock:
|
case kThingFallingRock:
|
||||||
if (SetSpriteState(nSprite, pXSprite, 1))
|
if (SetSpriteState(actor, 1))
|
||||||
pSprite->flags |= 7;
|
pSprite->flags |= 7;
|
||||||
break;
|
break;
|
||||||
case kThingWallCrack:
|
case kThingWallCrack:
|
||||||
if (SetSpriteState(nSprite, pXSprite, 0))
|
if (SetSpriteState(actor, 0))
|
||||||
actPostSprite(actor, kStatFree);
|
actPostSprite(actor, kStatFree);
|
||||||
break;
|
break;
|
||||||
case kThingCrateFace:
|
case kThingCrateFace:
|
||||||
if (SetSpriteState(nSprite, pXSprite, 0))
|
if (SetSpriteState(actor, 0))
|
||||||
actPostSprite(actor, kStatFree);
|
actPostSprite(actor, kStatFree);
|
||||||
break;
|
break;
|
||||||
case kTrapZapSwitchable:
|
case kTrapZapSwitchable:
|
||||||
|
@ -367,12 +368,12 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event)
|
||||||
case kTrapFlame:
|
case kTrapFlame:
|
||||||
switch (event.cmd) {
|
switch (event.cmd) {
|
||||||
case kCmdOff:
|
case kCmdOff:
|
||||||
if (!SetSpriteState(nSprite, pXSprite, 0)) break;
|
if (!SetSpriteState(actor, 0)) break;
|
||||||
seqSpawn(40, actor, -1);
|
seqSpawn(40, actor, -1);
|
||||||
sfxKill3DSound(pSprite, 0, -1);
|
sfxKill3DSound(pSprite, 0, -1);
|
||||||
break;
|
break;
|
||||||
case kCmdOn:
|
case kCmdOn:
|
||||||
if (!SetSpriteState(nSprite, pXSprite, 1)) break;
|
if (!SetSpriteState(actor, 1)) break;
|
||||||
seqSpawn(38, actor, -1);
|
seqSpawn(38, actor, -1);
|
||||||
sfxPlay3DSound(pSprite, 441, 0, 0);
|
sfxPlay3DSound(pSprite, 441, 0, 0);
|
||||||
break;
|
break;
|
||||||
|
@ -381,14 +382,14 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event)
|
||||||
case kSwitchPadlock:
|
case kSwitchPadlock:
|
||||||
switch (event.cmd) {
|
switch (event.cmd) {
|
||||||
case kCmdOff:
|
case kCmdOff:
|
||||||
SetSpriteState(nSprite, pXSprite, 0);
|
SetSpriteState(actor, 0);
|
||||||
break;
|
break;
|
||||||
case kCmdOn:
|
case kCmdOn:
|
||||||
if (!SetSpriteState(nSprite, pXSprite, 1)) break;
|
if (!SetSpriteState(actor, 1)) break;
|
||||||
seqSpawn(37, actor, -1);
|
seqSpawn(37, actor, -1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1);
|
SetSpriteState(actor, pXSprite->state ^ 1);
|
||||||
if (pXSprite->state) seqSpawn(37, actor, -1);
|
if (pXSprite->state) seqSpawn(37, actor, -1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -396,15 +397,15 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event)
|
||||||
case kSwitchToggle:
|
case kSwitchToggle:
|
||||||
switch (event.cmd) {
|
switch (event.cmd) {
|
||||||
case kCmdOff:
|
case kCmdOff:
|
||||||
if (!SetSpriteState(nSprite, pXSprite, 0)) break;
|
if (!SetSpriteState(actor, 0)) break;
|
||||||
sfxPlay3DSound(pSprite, pXSprite->data2, 0, 0);
|
sfxPlay3DSound(pSprite, pXSprite->data2, 0, 0);
|
||||||
break;
|
break;
|
||||||
case kCmdOn:
|
case kCmdOn:
|
||||||
if (!SetSpriteState(nSprite, pXSprite, 1)) break;
|
if (!SetSpriteState(actor, 1)) break;
|
||||||
sfxPlay3DSound(pSprite, pXSprite->data1, 0, 0);
|
sfxPlay3DSound(pSprite, pXSprite->data1, 0, 0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (!SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1)) break;
|
if (!SetSpriteState(actor, pXSprite->state ^ 1)) break;
|
||||||
if (pXSprite->state) sfxPlay3DSound(pSprite, pXSprite->data1, 0, 0);
|
if (pXSprite->state) sfxPlay3DSound(pSprite, pXSprite->data1, 0, 0);
|
||||||
else sfxPlay3DSound(pSprite, pXSprite->data2, 0, 0);
|
else sfxPlay3DSound(pSprite, pXSprite->data2, 0, 0);
|
||||||
break;
|
break;
|
||||||
|
@ -413,15 +414,15 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event)
|
||||||
case kSwitchOneWay:
|
case kSwitchOneWay:
|
||||||
switch (event.cmd) {
|
switch (event.cmd) {
|
||||||
case kCmdOff:
|
case kCmdOff:
|
||||||
if (!SetSpriteState(nSprite, pXSprite, 0)) break;
|
if (!SetSpriteState(actor, 0)) break;
|
||||||
sfxPlay3DSound(pSprite, pXSprite->data2, 0, 0);
|
sfxPlay3DSound(pSprite, pXSprite->data2, 0, 0);
|
||||||
break;
|
break;
|
||||||
case kCmdOn:
|
case kCmdOn:
|
||||||
if (!SetSpriteState(nSprite, pXSprite, 1)) break;
|
if (!SetSpriteState(actor, 1)) break;
|
||||||
sfxPlay3DSound(pSprite, pXSprite->data1, 0, 0);
|
sfxPlay3DSound(pSprite, pXSprite->data1, 0, 0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (!SetSpriteState(nSprite, pXSprite, pXSprite->restState ^ 1)) break;
|
if (!SetSpriteState(actor, pXSprite->restState ^ 1)) break;
|
||||||
if (pXSprite->state) sfxPlay3DSound(pSprite, pXSprite->data1, 0, 0);
|
if (pXSprite->state) sfxPlay3DSound(pSprite, pXSprite->data1, 0, 0);
|
||||||
else sfxPlay3DSound(pSprite, pXSprite->data2, 0, 0);
|
else sfxPlay3DSound(pSprite, pXSprite->data2, 0, 0);
|
||||||
break;
|
break;
|
||||||
|
@ -447,9 +448,9 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event)
|
||||||
evSendActor(actor, pXSprite->txID, kCmdLink);
|
evSendActor(actor, pXSprite->txID, kCmdLink);
|
||||||
|
|
||||||
if (pXSprite->data1 == pXSprite->data2)
|
if (pXSprite->data1 == pXSprite->data2)
|
||||||
SetSpriteState(nSprite, pXSprite, 1);
|
SetSpriteState(actor, 1);
|
||||||
else
|
else
|
||||||
SetSpriteState(nSprite, pXSprite, 0);
|
SetSpriteState(actor, 0);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case kMarkerDudeSpawn:
|
case kMarkerDudeSpawn:
|
||||||
|
@ -481,7 +482,7 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event)
|
||||||
case kMarkerEarthQuake:
|
case kMarkerEarthQuake:
|
||||||
pXSprite->triggerOn = 0;
|
pXSprite->triggerOn = 0;
|
||||||
pXSprite->isTriggered = 1;
|
pXSprite->isTriggered = 1;
|
||||||
SetSpriteState(nSprite, pXSprite, 1);
|
SetSpriteState(actor, 1);
|
||||||
for (int p = connecthead; p >= 0; p = connectpoint2[p]) {
|
for (int p = connecthead; p >= 0; p = connectpoint2[p]) {
|
||||||
spritetype *pPlayerSprite = gPlayer[p].pSprite;
|
spritetype *pPlayerSprite = gPlayer[p].pSprite;
|
||||||
int dx = (pSprite->x - pPlayerSprite->x)>>4;
|
int dx = (pSprite->x - pPlayerSprite->x)>>4;
|
||||||
|
@ -502,7 +503,7 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event)
|
||||||
case kTrapExploder:
|
case kTrapExploder:
|
||||||
switch (event.cmd) {
|
switch (event.cmd) {
|
||||||
case kCmdOn:
|
case kCmdOn:
|
||||||
SetSpriteState(nSprite, pXSprite, 1);
|
SetSpriteState(actor, 1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
pSprite->cstat &= (unsigned short)~CSTAT_SPRITE_INVISIBLE;
|
pSprite->cstat &= (unsigned short)~CSTAT_SPRITE_INVISIBLE;
|
||||||
|
@ -552,7 +553,7 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event)
|
||||||
case kGenSound:
|
case kGenSound:
|
||||||
switch (event.cmd) {
|
switch (event.cmd) {
|
||||||
case kCmdOff:
|
case kCmdOff:
|
||||||
SetSpriteState(nSprite, pXSprite, 0);
|
SetSpriteState(actor, 0);
|
||||||
break;
|
break;
|
||||||
case kCmdRepeat:
|
case kCmdRepeat:
|
||||||
if (pSprite->type != kGenTrigger) ActivateGenerator(nSprite);
|
if (pSprite->type != kGenTrigger) ActivateGenerator(nSprite);
|
||||||
|
@ -564,7 +565,7 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event)
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (!pXSprite->state) {
|
if (!pXSprite->state) {
|
||||||
SetSpriteState(nSprite, pXSprite, 1);
|
SetSpriteState(actor, 1);
|
||||||
evPostActor(actor, 0, kCmdRepeat);
|
evPostActor(actor, 0, kCmdRepeat);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -586,15 +587,15 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event)
|
||||||
case kThingZombieHead:
|
case kThingZombieHead:
|
||||||
switch (event.cmd) {
|
switch (event.cmd) {
|
||||||
case kCmdOff:
|
case kCmdOff:
|
||||||
if (!SetSpriteState(nSprite, pXSprite, 0)) break;
|
if (!SetSpriteState(actor, 0)) break;
|
||||||
actActivateGibObject(&bloodActors[pXSprite->reference]);
|
actActivateGibObject(&bloodActors[pXSprite->reference]);
|
||||||
break;
|
break;
|
||||||
case kCmdOn:
|
case kCmdOn:
|
||||||
if (!SetSpriteState(nSprite, pXSprite, 1)) break;
|
if (!SetSpriteState(actor, 1)) break;
|
||||||
actActivateGibObject(&bloodActors[pXSprite->reference]);
|
actActivateGibObject(&bloodActors[pXSprite->reference]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (!SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1)) break;
|
if (!SetSpriteState(actor, pXSprite->state ^ 1)) break;
|
||||||
actActivateGibObject(&bloodActors[pXSprite->reference]);
|
actActivateGibObject(&bloodActors[pXSprite->reference]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -602,13 +603,13 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event)
|
||||||
default:
|
default:
|
||||||
switch (event.cmd) {
|
switch (event.cmd) {
|
||||||
case kCmdOff:
|
case kCmdOff:
|
||||||
SetSpriteState(nSprite, pXSprite, 0);
|
SetSpriteState(actor, 0);
|
||||||
break;
|
break;
|
||||||
case kCmdOn:
|
case kCmdOn:
|
||||||
SetSpriteState(nSprite, pXSprite, 1);
|
SetSpriteState(actor, 1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
SetSpriteState(nSprite, pXSprite, pXSprite->state ^ 1);
|
SetSpriteState(actor, pXSprite->state ^ 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1683,6 +1684,7 @@ void LinkSector(int nSector, XSECTOR *pXSector, EVENT event)
|
||||||
}
|
}
|
||||||
|
|
||||||
void LinkSprite(int nSprite, XSPRITE *pXSprite, EVENT event) {
|
void LinkSprite(int nSprite, XSPRITE *pXSprite, EVENT event) {
|
||||||
|
auto actor = &bloodActors[nSprite];
|
||||||
spritetype *pSprite = &sprite[nSprite];
|
spritetype *pSprite = &sprite[nSprite];
|
||||||
int nBusy = GetSourceBusy(event);
|
int nBusy = GetSourceBusy(event);
|
||||||
|
|
||||||
|
@ -1695,9 +1697,9 @@ void LinkSprite(int nSprite, XSPRITE *pXSprite, EVENT event) {
|
||||||
|
|
||||||
pXSprite->data1 = actor2 && actor2->hasX()? actor2->x().data1 : 0;
|
pXSprite->data1 = actor2 && actor2->hasX()? actor2->x().data1 : 0;
|
||||||
if (pXSprite->data1 == pXSprite->data2)
|
if (pXSprite->data1 == pXSprite->data2)
|
||||||
SetSpriteState(nSprite, pXSprite, 1);
|
SetSpriteState(actor, 1);
|
||||||
else
|
else
|
||||||
SetSpriteState(nSprite, pXSprite, 0);
|
SetSpriteState(actor, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1705,7 +1707,7 @@ void LinkSprite(int nSprite, XSPRITE *pXSprite, EVENT event) {
|
||||||
{
|
{
|
||||||
pXSprite->busy = nBusy;
|
pXSprite->busy = nBusy;
|
||||||
if ((pXSprite->busy & 0xffff) == 0)
|
if ((pXSprite->busy & 0xffff) == 0)
|
||||||
SetSpriteState(nSprite, pXSprite, FixedToInt(nBusy));
|
SetSpriteState(actor, FixedToInt(nBusy));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,10 +63,9 @@ void trMessageSprite(unsigned int nSprite, EVENT event);
|
||||||
void trProcessBusy(void);
|
void trProcessBusy(void);
|
||||||
void trInit(void);
|
void trInit(void);
|
||||||
void trTextOver(int nId);
|
void trTextOver(int nId);
|
||||||
char SetSpriteState(int nSprite, XSPRITE* pXSprite, int nState);
|
bool SetSpriteState(DBloodActor* actor, int nState);
|
||||||
char SetSpriteState(DBloodActor* actor, int nState);
|
bool SetWallState(int nWall, XWALL* pXWall, int nState);
|
||||||
char SetWallState(int nWall, XWALL* pXWall, int nState);
|
bool SetSectorState(int nSector, XSECTOR* pXSector, int nState);
|
||||||
char SetSectorState(int nSector, XSECTOR* pXSector, int nState);
|
|
||||||
void TeleFrag(int nKiller, int nSector);
|
void TeleFrag(int nKiller, int nSector);
|
||||||
void SectorStartSound(int nSector, int nState);
|
void SectorStartSound(int nSector, int nState);
|
||||||
void SectorEndSound(int nSector, int nState);
|
void SectorEndSound(int nSector, int nState);
|
||||||
|
|
Loading…
Reference in a new issue