From 125c3e800474d1caee8e013d6dd78c6d4a6b444e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 27 Jan 2022 00:41:33 +0100 Subject: [PATCH] - flammable flags. --- source/games/duke/src/actors.cpp | 16 +++++++----- source/games/duke/src/actors_d.cpp | 6 ++--- source/games/duke/src/actors_r.cpp | 6 ++--- source/games/duke/src/animatesprites_d.cpp | 2 +- source/games/duke/src/animatesprites_r.cpp | 2 +- source/games/duke/src/constants.h | 3 +++ source/games/duke/src/flags_d.cpp | 3 +++ source/games/duke/src/flags_r.cpp | 4 +++ source/games/duke/src/funct.h | 4 +-- source/games/duke/src/inlines.h | 10 ++++++++ source/games/duke/src/sectors_d.cpp | 17 ++---------- source/games/duke/src/sectors_r.cpp | 30 ++-------------------- 12 files changed, 44 insertions(+), 59 deletions(-) diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 66fb39b5a..4d82c1de9 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -847,7 +847,7 @@ void movefountain(DDukeActor *actor, int fountain) // //--------------------------------------------------------------------------- -void moveflammable(DDukeActor* actor, int tire, int box, int pool) +void moveflammable(DDukeActor* actor, int pool) { int j; if (actor->temp_data[0] == 1) @@ -859,7 +859,11 @@ void moveflammable(DDukeActor* actor, int tire, int box, int pool) { actor->spr.cstat = 0; auto spawned = spawn(actor, pool); - if (spawned) spawned->spr.shade = 127; + if (spawned) + { + spawned->spr.pal = 2; + spawned->spr.shade = 127; + } } else { @@ -888,7 +892,7 @@ void moveflammable(DDukeActor* actor, int tire, int box, int pool) } actor->spr.yrepeat = j; } - if (box >= 0 && actor->spr.picnum == box) + if (actorflag(actor, SFLAG_FALLINGFLAMMABLE)) { makeitfall(actor); actor->ceilingz = actor->sector()->ceilingz; @@ -2302,7 +2306,7 @@ bool jibs(DDukeActor *actor, int JIBS6, bool timeout, bool callsetsprite, bool f // //--------------------------------------------------------------------------- -bool bloodpool(DDukeActor* actor, bool puke, int TIRE) +bool bloodpool(DDukeActor* actor, bool puke) { auto sectp = actor->sector(); @@ -2327,7 +2331,7 @@ bool bloodpool(DDukeActor* actor, bool puke, int TIRE) if (actor->temp_data[2] < 32) { actor->temp_data[2]++; - if (actor->attackertype == TIRE) + if (attackerflag(actor, SFLAG_FLAMMABLEPOOLEFFECT)) { if (actor->spr.xrepeat < 64 && actor->spr.yrepeat < 64) { @@ -2363,7 +2367,7 @@ bool bloodpool(DDukeActor* actor, bool puke, int TIRE) if (actor->temp_data[1] == 1) return false; actor->temp_data[1] = 1; - if (actor->attackertype == TIRE) + if (attackerflag(actor, SFLAG_FLAMMABLEPOOLEFFECT)) ps[p].footprintcount = 10; else ps[p].footprintcount = 3; diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index ef7098de2..c1dcb9aae 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -322,7 +322,7 @@ void hitradius_d(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h } } - if (x == 0 || x >= 5 || AFLAMABLE(act2->spr.picnum)) + if (x == 0 || x >= 5 || actorflag(act2, SFLAG_HITRADIUS_FLAG1)) { if (actor->spr.picnum != SHRINKSPARK || (act2->spr.cstat & CSTAT_SPRITE_BLOCK_ALL)) if (dist(actor, act2) < r) @@ -1208,7 +1208,7 @@ void movestandables_d(void) else if (AFLAMABLE(picnum)) { - moveflammable(act, TIRE, BOX, BLOODPOOL); + moveflammable(act, BLOODPOOL); } else if (picnum == TRIPBOMB) @@ -3140,7 +3140,7 @@ void moveexplosions_d(void) // STATNUM 5 continue; case BLOODPOOL: case PUKE: - bloodpool(act, act->spr.picnum == PUKE, TIRE); + bloodpool(act, act->spr.picnum == PUKE); continue; diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index e212a67e2..4f15d49bb 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -267,7 +267,7 @@ void hitradius_r(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h DukeStatIterator it1(statlist[x]); while (auto act2 = it1.Next()) { - if (x == 0 || x >= 5 || AFLAMABLE(act2->spr.picnum)) + if (x == 0 || x >= 5 || actorflag(act2, SFLAG_HITRADIUS_FLAG1)) { if (act2->spr.cstat & CSTAT_SPRITE_BLOCK_ALL) if (dist(actor, act2) < r) @@ -853,7 +853,7 @@ void movestandables_r(void) else if (AFLAMABLE(picnum)) { - moveflammable(act, TIRE, BOX, BLOODPOOL); + moveflammable(act, BLOODPOOL); } @@ -3115,7 +3115,7 @@ void moveexplosions_r(void) // STATNUM 5 continue; case BLOODPOOL: - if (!bloodpool(act, false, TIRE)) continue; + if (!bloodpool(act, false)) continue; if (act->sector()->lotag == 800) if (act->spr.pos.Z >= act->sector()->floorz - (8 << 8)) diff --git a/source/games/duke/src/animatesprites_d.cpp b/source/games/duke/src/animatesprites_d.cpp index e2b0175ff..a4a0a7eaf 100644 --- a/source/games/duke/src/animatesprites_d.cpp +++ b/source/games/duke/src/animatesprites_d.cpp @@ -657,7 +657,7 @@ void animatesprites_d(tspritetype* tsprite, int& spritesortcnt, int x, int y, in case BURNING: case BURNING2: if (!OwnerAc) break; - if (OwnerAc->spr.picnum != TREE1 && OwnerAc->spr.picnum != TREE2) + if (!actorflag(OwnerAc, SFLAG_NOFLOORFIRE)) t->pos.Z = t->sectp->floorz; t->shade = -127; break; diff --git a/source/games/duke/src/animatesprites_r.cpp b/source/games/duke/src/animatesprites_r.cpp index eece7adb8..3282d2824 100644 --- a/source/games/duke/src/animatesprites_r.cpp +++ b/source/games/duke/src/animatesprites_r.cpp @@ -814,7 +814,7 @@ void animatesprites_r(tspritetype* tsprite, int& spritesortcnt, int x, int y, in break; case FIRE: case BURNING: - if (OwnerAc && OwnerAc->spr.picnum != TREE1 && OwnerAc->spr.picnum != TREE2) + if (!OwnerAc || !actorflag(OwnerAc, SFLAG_NOFLOORFIRE)) t->pos.Z = t->sectp->floorz; t->shade = -127; break; diff --git a/source/games/duke/src/constants.h b/source/games/duke/src/constants.h index e52655d3f..6c968aae5 100644 --- a/source/games/duke/src/constants.h +++ b/source/games/duke/src/constants.h @@ -317,6 +317,9 @@ enum sflags_t SFLAG_NOINTERPOLATE = 0x00100000, SFLAG_FALLINGFLAMMABLE = 0x00200000, SFLAG_FLAMMABLEPOOLEFFECT = 0x00400000, + SFLAG_INFLAME = 0x00800000, + SFLAG_NOFLOORFIRE = 0x01000000, + SFLAG_HITRADIUS_FLAG1 = 0x02000000, }; diff --git a/source/games/duke/src/flags_d.cpp b/source/games/duke/src/flags_d.cpp index d061bdd40..c0bd86f7b 100644 --- a/source/games/duke/src/flags_d.cpp +++ b/source/games/duke/src/flags_d.cpp @@ -202,6 +202,9 @@ void initactorflags_d() setflag(SFLAG_NOINTERPOLATE, { CRANEPOLE }); setflag(SFLAG_FLAMMABLEPOOLEFFECT, { TIRE }); setflag(SFLAG_FALLINGFLAMMABLE, { BOX }); + setflag(SFLAG_INFLAME, { RADIUSEXPLOSION, RPG, FIRELASER, HYDRENT, HEAVYHBOMB }); + setflag(SFLAG_NOFLOORFIRE, { TREE1, TREE2 }); + setflag(SFLAG_HITRADIUS_FLAG1, { BOX, TREE1, TREE2, TIRE, CONE }); if (isWorldTour()) { diff --git a/source/games/duke/src/flags_r.cpp b/source/games/duke/src/flags_r.cpp index 88810eb8b..6c24c71f8 100644 --- a/source/games/duke/src/flags_r.cpp +++ b/source/games/duke/src/flags_r.cpp @@ -231,6 +231,10 @@ void initactorflags_r() setflag(SFLAG_SE24_NOFLOORCHECK, { CRANE, CRANE1, CRANE2, BARBROKE }); setflag(SFLAG_NOINTERPOLATE, { CRANEPOLE }); setflag(SFLAG_FALLINGFLAMMABLE, { BOX }); + setflag(SFLAG_INFLAME, { RADIUSEXPLOSION, RPG, FIRELASER, HYDRENT, HEAVYHBOMB, TRIPBOMBSPRITE, COOLEXPLOSION1, OWHIP, UWHIP }); + if (isRRRA()) setflag(SFLAG_INFLAME, { RPG2 }); + setflag(SFLAG_NOFLOORFIRE, { TREE1, TREE2 }); + setflag(SFLAG_HITRADIUS_FLAG1, { BOX, TREE1, TREE2, TIRE }); // Animals were not supposed to have this, but due to a coding bug the logic was unconditional for everything in the game. for (auto& ainf : gs.actorinfo) diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index 552b4f0d1..56e23e214 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -33,7 +33,7 @@ void RANDOMSCRAP(DDukeActor* i); void ms(DDukeActor* i); void movecrane(DDukeActor* i, int crane); void movefountain(DDukeActor* i, int fountain); -void moveflammable(DDukeActor* i, int tire, int box, int pool); +void moveflammable(DDukeActor* i, int pool); void detonate(DDukeActor* i, int explosion); void movemasterswitch(DDukeActor* i, int spectype1, int spectype2); void movetrash(DDukeActor* i); @@ -59,7 +59,7 @@ void watersplash2(DDukeActor* i); void frameeffect1(DDukeActor* i); bool money(DDukeActor* i, int BLOODPOOL); bool jibs(DDukeActor* i, int JIBS6, bool timeout, bool callsetsprite, bool floorcheck, bool zcheck1, bool zcheck2); -bool bloodpool(DDukeActor* i, bool puke, int TIRE); +bool bloodpool(DDukeActor* i, bool puke); void shell(DDukeActor* i, bool morecheck); void glasspieces(DDukeActor* i); void scrap(DDukeActor* i, int SCRAP1, int SCRAP6); diff --git a/source/games/duke/src/inlines.h b/source/games/duke/src/inlines.h index da4d54343..b0c7616ce 100644 --- a/source/games/duke/src/inlines.h +++ b/source/games/duke/src/inlines.h @@ -37,6 +37,16 @@ inline int actorflag(DDukeActor* actor, EDukeFlags2 mask) return (((gs.actorinfo[actor->spr.picnum].flags2) & mask) != 0); } +inline int attackerflag(DDukeActor* actor, EDukeFlags1 mask) +{ + return (((gs.actorinfo[actor->attackertype].flags) & mask) != 0); +} + +inline int attackerflag(DDukeActor* actor, EDukeFlags2 mask) +{ + return (((gs.actorinfo[actor->attackertype].flags2) & mask) != 0); +} + inline int actorfella(DDukeActor* actor) { return actorflag(actor, SFLAG_KILLCOUNT); diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index fcaa75f81..c7abb01e8 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -1083,31 +1083,20 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj) case TIRE: case CONE: case BOX: - switch (proj->spr.picnum) + if (actorflag(proj, SFLAG_INFLAME)) { - case RADIUSEXPLOSION: - case RPG: - case FIRELASER: - case HYDRENT: - case HEAVYHBOMB: if (targ->temp_data[0] == 0) { targ->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL; targ->temp_data[0] = 1; spawn(targ, BURNING); } - break; } break; case CACTUS: // case CACTUSBROKE: - switch (proj->spr.picnum) + if (actorflag(proj, SFLAG_INFLAME)) { - case RADIUSEXPLOSION: - case RPG: - case FIRELASER: - case HYDRENT: - case HEAVYHBOMB: for (k = 0; k < 64; k++) { auto spawned = EGS(targ->sector(), targ->spr.pos.X, targ->spr.pos.Y, targ->spr.pos.Z - (krand() % (48 << 8)), SCRAP3 + (krand() & 3), -8, 48, 48, krand() & 2047, (krand() & 63) + 64, -(krand() & 4095) - (targ->spr.zvel >> 2), targ, 5); @@ -1117,8 +1106,6 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj) if (targ->spr.picnum == CACTUS) targ->spr.picnum = CACTUSBROKE; targ->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL; - // else deletesprite(i); - break; } break; diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index 9b12878f4..ee354dc6a 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -2122,46 +2122,21 @@ void checkhitsprite_r(DDukeActor* targ, DDukeActor* proj) case TREE2: case TIRE: case BOX: - switch (proj->spr.picnum) + if (actorflag(proj, SFLAG_INFLAME)) { - case RPG2: - if (!isRRRA()) break; - [[fallthrough]]; - case RADIUSEXPLOSION: - case RPG: - case FIRELASER: - case HYDRENT: - case HEAVYHBOMB: - case TRIPBOMBSPRITE: - case COOLEXPLOSION1: - case OWHIP: - case UWHIP: if (targ->temp_data[0] == 0) { targ->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL; targ->temp_data[0] = 1; spawn(targ, BURNING); } - break; } break; case CACTUS: // case CACTUSBROKE: - switch (proj->spr.picnum) + if (actorflag(proj, SFLAG_INFLAME)) { - case RPG2: - if (!isRRRA()) break; - [[fallthrough]]; - case RADIUSEXPLOSION: - case RPG: - case FIRELASER: - case HYDRENT: - case HEAVYHBOMB: - case TRIPBOMBSPRITE: - case COOLEXPLOSION1: - case OWHIP: - case UWHIP: for (k = 0; k < 64; k++) { auto spawned = EGS(targ->sector(), targ->spr.pos.X, targ->spr.pos.Y, targ->spr.pos.Z - (krand() % (48 << 8)), SCRAP6 + (krand() & 3), -8, 48, 48, krand() & 2047, (krand() & 63) + 64, -(krand() & 4095) - (targ->spr.zvel >> 2), targ, 5); @@ -2172,7 +2147,6 @@ void checkhitsprite_r(DDukeActor* targ, DDukeActor* proj) targ->spr.picnum = CACTUSBROKE; targ->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL; // else deletesprite(i); - break; } break;