mirror of
https://github.com/ZDoom/Raze.git
synced 2025-01-18 14:41:55 +00:00
- quake.cpp plus SP_TAG13/14 cleanup
This commit is contained in:
parent
9aaaadefc3
commit
49cc2b3cad
6 changed files with 41 additions and 66 deletions
|
@ -2115,9 +2115,6 @@ inline uint8_t& SP_TAG9(spritetype* s) { return MSB_VAR(s->owner); }
|
|||
inline uint8_t& SP_TAG10(spritetype* s) { return LSB_VAR(s->owner); }
|
||||
inline int8_t& SP_TAG11(spritetype* s) { return s->shade; }
|
||||
inline uint8_t& SP_TAG12(spritetype* s) { return s->pal; }
|
||||
inline int16_t SP_TAG13(spritetype* s) { return int16_t(s->xoffset + (s->yoffset << 8)); }
|
||||
inline int16_t SP_TAG14(spritetype* s) { return int16_t(s->xrepeat + (s->yrepeat << 8)); }
|
||||
inline void SET_SP_TAG13(spritetype* s, int val) { s->xoffset = uint8_t(val); s->yoffset = uint8_t(val >> 8); }
|
||||
|
||||
inline void SET_BOOL1(DSWActor* sp) { sp->spr.extra |= SPRX_BOOL1; }
|
||||
inline void SET_BOOL2(DSWActor* sp) { sp->spr.extra |= SPRX_BOOL2; }
|
||||
|
@ -2169,7 +2166,6 @@ inline uint8_t& SP_TAG10(DSWActor* actor) { return LSB_VAR(actor->spr.owner); }
|
|||
inline int8_t& SP_TAG11(DSWActor* actor) { return actor->spr.shade; }
|
||||
inline uint8_t& SP_TAG12(DSWActor* actor) { return actor->spr.pal; }
|
||||
inline int16_t SP_TAG13(DSWActor* actor) { return int16_t(actor->spr.xoffset + (actor->spr.yoffset << 8)); }
|
||||
inline int16_t SP_TAG14(DSWActor* actor) { return int16_t(actor->spr.xrepeat + (actor->spr.yrepeat << 8)); }
|
||||
inline void SET_SP_TAG13(DSWActor* actor, int val) { actor->spr.xoffset = uint8_t(val); actor->spr.yoffset = uint8_t(val >> 8); }
|
||||
|
||||
// actual Z for TOS and BOS - handles both WYSIWYG and old style
|
||||
|
|
|
@ -39,34 +39,31 @@ BEGIN_SW_NS
|
|||
|
||||
inline int16_t& QUAKE_Match(DSWActor* actor) { return SP_TAG2(actor); }
|
||||
inline uint8_t& QUAKE_Zamt(DSWActor* actor) { return SP_TAG3(actor); }
|
||||
#define QUAKE_Radius(sp) (SP_TAG4(sp))
|
||||
#define QUAKE_Duration(sp) (SP_TAG5(sp))
|
||||
#define QUAKE_WaitSecs(sp) (SP_TAG6(sp))
|
||||
#define QUAKE_AngAmt(sp) (SP_TAG7(sp))
|
||||
#define QUAKE_PosAmt(sp) (SP_TAG8(sp))
|
||||
#define QUAKE_RandomTest(sp) (SP_TAG9(sp))
|
||||
#define QUAKE_WaitTics(sp) (SP_TAG13(sp))
|
||||
#define QUAKE_Radius(actor) (SP_TAG4(actor))
|
||||
#define QUAKE_Duration(actor) (SP_TAG5(actor))
|
||||
#define QUAKE_WaitSecs(actor) (SP_TAG6(actor))
|
||||
#define QUAKE_AngAmt(actor) (SP_TAG7(actor))
|
||||
#define QUAKE_PosAmt(actor) (SP_TAG8(actor))
|
||||
#define QUAKE_RandomTest(actor) (SP_TAG9(actor))
|
||||
#define QUAKE_WaitTics(actor) (SP_TAG13(actor))
|
||||
|
||||
#define QUAKE_TestDontTaper(sp) (TEST_BOOL1(sp))
|
||||
#define QUAKE_KillAfterQuake(sp) (TEST_BOOL2(sp))
|
||||
#define QUAKE_TestDontTaper(actor) (TEST_BOOL1(actor))
|
||||
#define QUAKE_KillAfterQuake(actor) (TEST_BOOL2(actor))
|
||||
// only for timed quakes
|
||||
#define QUAKE_WaitForTrigger(sp) (TEST_BOOL3(sp))
|
||||
#define QUAKE_WaitForTrigger(actor) (TEST_BOOL3(actor))
|
||||
|
||||
void CopyQuakeSpotToOn(SPRITEp sp)
|
||||
void CopyQuakeSpotToOn(DSWActor* actor)
|
||||
{
|
||||
auto actorNew = insertActor(sp->sector(), STAT_QUAKE_SPOT);
|
||||
auto np = &actorNew->s();
|
||||
auto actorNew = insertActor(actor->spr.sector(), STAT_QUAKE_SPOT);
|
||||
|
||||
memcpy(np, sp, sizeof(SPRITE));
|
||||
|
||||
np->setsector(sp->sector());
|
||||
|
||||
np->cstat = 0;
|
||||
np->extra = 0;
|
||||
actorNew->spr = actor->spr;
|
||||
actorNew->spr.setsector(actor->spr.sector());
|
||||
actorNew->spr.cstat = 0;
|
||||
actorNew->spr.extra = 0;
|
||||
|
||||
change_actor_stat(actorNew, STAT_QUAKE_ON);
|
||||
|
||||
QUAKE_Duration(np) *= 120;
|
||||
QUAKE_Duration(actorNew) *= 120;
|
||||
}
|
||||
|
||||
|
||||
|
@ -75,19 +72,17 @@ void DoQuakeMatch(short match)
|
|||
SWStatIterator it(STAT_QUAKE_SPOT);
|
||||
while (auto actor = it.Next())
|
||||
{
|
||||
auto sp = &actor->s();
|
||||
|
||||
if (QUAKE_Match(actor) == match)
|
||||
{
|
||||
if ((int16_t)QUAKE_WaitTics(sp) > 0)
|
||||
if ((int16_t)QUAKE_WaitTics(actor) > 0)
|
||||
{
|
||||
// its not waiting any more
|
||||
RESET_BOOL3(sp);
|
||||
RESET_BOOL3(actor);
|
||||
}
|
||||
else
|
||||
{
|
||||
CopyQuakeSpotToOn(sp);
|
||||
if (QUAKE_KillAfterQuake(sp))
|
||||
CopyQuakeSpotToOn(actor);
|
||||
if (QUAKE_KillAfterQuake(actor))
|
||||
{
|
||||
KillActor(actor);
|
||||
continue;
|
||||
|
@ -103,11 +98,9 @@ void ProcessQuakeOn(void)
|
|||
SWStatIterator it(STAT_QUAKE_ON);
|
||||
while (auto actor = it.Next())
|
||||
{
|
||||
auto sp = &actor->s();
|
||||
|
||||
// get rid of quake when timer runs out
|
||||
QUAKE_Duration(sp) -= synctics*4;
|
||||
if (QUAKE_Duration(sp) < 0)
|
||||
QUAKE_Duration(actor) -= synctics*4;
|
||||
if (QUAKE_Duration(actor) < 0)
|
||||
{
|
||||
KillActor(actor);
|
||||
continue;
|
||||
|
@ -123,32 +116,30 @@ void ProcessQuakeSpot(void)
|
|||
SWStatIterator it(STAT_QUAKE_SPOT);
|
||||
while (auto actor = it.Next())
|
||||
{
|
||||
auto sp = &actor->s();
|
||||
|
||||
// not a timed quake
|
||||
if (!QUAKE_WaitSecs(sp))
|
||||
if (!QUAKE_WaitSecs(actor))
|
||||
continue;
|
||||
|
||||
// don't process unless triggered
|
||||
if (QUAKE_WaitForTrigger(sp))
|
||||
if (QUAKE_WaitForTrigger(actor))
|
||||
continue;
|
||||
|
||||
// spawn a quake if time is up
|
||||
SET_SP_TAG13(sp, (QUAKE_WaitTics(sp)-4*synctics));
|
||||
if ((int16_t)QUAKE_WaitTics(sp) < 0)
|
||||
SET_SP_TAG13(actor, (QUAKE_WaitTics(actor)-4*synctics));
|
||||
if ((int16_t)QUAKE_WaitTics(actor) < 0)
|
||||
{
|
||||
// reset timer - add in Duration of quake
|
||||
SET_SP_TAG13(sp, (((QUAKE_WaitSecs(sp)*10) + QUAKE_Duration(sp)) * 120));
|
||||
SET_SP_TAG13(actor, (((QUAKE_WaitSecs(actor)*10) + QUAKE_Duration(actor)) * 120));
|
||||
|
||||
// spawn a quake if condition is met
|
||||
rand_test = QUAKE_RandomTest(sp);
|
||||
rand_test = QUAKE_RandomTest(actor);
|
||||
// wrong - all quakes need to happen at the same time on all computerssg
|
||||
//if (!rand_test || (rand_test && STD_RANDOM_RANGE(128) < rand_test))
|
||||
if (!rand_test || (rand_test && RandomRange(128) < rand_test))
|
||||
{
|
||||
CopyQuakeSpotToOn(sp);
|
||||
CopyQuakeSpotToOn(actor);
|
||||
// kill quake spot if needed
|
||||
if (QUAKE_KillAfterQuake(sp))
|
||||
if (QUAKE_KillAfterQuake(actor))
|
||||
{
|
||||
DeleteNoSoundOwner(actor);
|
||||
KillActor(actor);
|
||||
|
@ -258,49 +249,37 @@ bool SetQuake(PLAYERp pp, short tics, short amt)
|
|||
|
||||
int SetExpQuake(DSWActor* actor)
|
||||
{
|
||||
SPRITEp sp = &actor->s();
|
||||
|
||||
SpawnQuake(sp->sector(), sp->pos.X, sp->pos.Y, sp->pos.Z, 40, 4, 20000); // !JIM! was 8, 40000
|
||||
SpawnQuake(actor->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z, 40, 4, 20000); // !JIM! was 8, 40000
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetGunQuake(DSWActor* actor)
|
||||
{
|
||||
SPRITEp sp = &actor->s();
|
||||
|
||||
SpawnQuake(sp->sector(), sp->pos.X, sp->pos.Y, sp->pos.Z, 40, 8, 40000);
|
||||
|
||||
SpawnQuake(actor->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z, 40, 8, 40000);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetPlayerQuake(PLAYERp pp)
|
||||
{
|
||||
SpawnQuake(pp->cursector, pp->pos.X, pp->pos.Y, pp->pos.Z, 40, 8, 40000);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetNuclearQuake(DSWActor* actor)
|
||||
{
|
||||
SPRITEp sp = &actor->s();
|
||||
|
||||
SpawnQuake(sp->sector(), sp->pos.X, sp->pos.Y, sp->pos.Z, 400, 8, 64000);
|
||||
SpawnQuake(actor->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z, 400, 8, 64000);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetSumoQuake(DSWActor* actor)
|
||||
{
|
||||
SPRITEp sp = &actor->s();
|
||||
|
||||
SpawnQuake(sp->sector(), sp->pos.X, sp->pos.Y, sp->pos.Z, 120, 4, 20000);
|
||||
SpawnQuake(actor->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z, 120, 4, 20000);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SetSumoFartQuake(DSWActor* actor)
|
||||
{
|
||||
SPRITEp sp = &actor->s();
|
||||
|
||||
SpawnQuake(sp->sector(), sp->pos.X, sp->pos.Y, sp->pos.Z, 60, 4, 4000);
|
||||
SpawnQuake(actor->spr.sector(), actor->spr.pos.X, actor->spr.pos.Y, actor->spr.pos.Z, 60, 4, 4000);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -757,7 +757,7 @@ enum
|
|||
SWITCH_SKULL = 553,
|
||||
};
|
||||
|
||||
short AnimateSwitch(DSWActor* actor, int tgt_value)
|
||||
int AnimateSwitch(DSWActor* actor, int tgt_value)
|
||||
{
|
||||
// if the value is not ON or OFF
|
||||
// then it is a straight toggle
|
||||
|
|
|
@ -71,7 +71,7 @@ void DoMatchEverything(PLAYERp pp, short match, short state);
|
|||
bool ComboSwitchTest(short combo_type,short match);
|
||||
void DoSoundSpotStopSound(short match);
|
||||
void DoSector(void);
|
||||
short AnimateSwitch(DSWActor* actor, int tgt_value);
|
||||
int AnimateSwitch(DSWActor* actor, int tgt_value);
|
||||
void ShootableSwitch(DSWActor*);
|
||||
bool TestKillSectorObject(SECTOR_OBJECTp sop);
|
||||
void WeaponExplodeSectorInRange(DSWActor*);
|
||||
|
|
|
@ -2011,7 +2011,7 @@ void SpriteSetup(void)
|
|||
case QUAKE_SPOT:
|
||||
{
|
||||
change_actor_stat(actor, STAT_QUAKE_SPOT);
|
||||
SET_SP_TAG13(sp, ((SP_TAG6(sp)*10L) * 120L));
|
||||
SET_SP_TAG13(actor, ((SP_TAG6(sp)*10L) * 120L));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -2607,7 +2607,7 @@ void SpriteSetup(void)
|
|||
}
|
||||
|
||||
case SOUND_SPOT:
|
||||
SET_SP_TAG13(sp, SP_TAG4(sp));
|
||||
SET_SP_TAG13(actor, SP_TAG4(sp));
|
||||
change_actor_stat(actor, STAT_SOUND_SPOT);
|
||||
break;
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ int DoWallMove(DSWActor* actor)
|
|||
|
||||
auto sp = &actor->s();
|
||||
|
||||
dist = SP_TAG13(sp);
|
||||
dist = SP_TAG13(actor);
|
||||
ang = SP_TAG4(sp);
|
||||
picnum1 = SP_TAG5(sp);
|
||||
picnum2 = SP_TAG6(sp);
|
||||
|
|
Loading…
Reference in a new issue