- hitradius

# Conflicts:
#	source/games/duke/src/actors_d.cpp
#	source/games/duke/src/actors_r.cpp
This commit is contained in:
Christoph Oelckers 2020-10-21 22:04:39 +02:00
parent 7dbe9d4bfb
commit c42ff35dc5
7 changed files with 72 additions and 76 deletions

View File

@ -962,7 +962,7 @@ void detonate(DDukeActor *actor, int explosion)
{
int x = spri->extra;
spawn(actor, explosion);
fi.hitradius(actor->GetIndex(), seenineblastradius, x >> 2, x - (x >> 1), x - (x >> 2), x);
fi.hitradius(actor, seenineblastradius, x >> 2, x - (x >> 1), x - (x >> 2), x);
S_PlayActorSound(PIPEBOMB_EXPLODE, actor);
}
@ -1422,12 +1422,12 @@ void rpgexplode(int i, int j, const vec3_t &pos, int EXPLOSION2, int EXPLOSION2B
if (s->xrepeat >= 10)
{
int x = s->extra;
fi.hitradius(i, rpgblastradius, x >> 2, x >> 1, x - (x >> 2), x);
fi.hitradius(&hittype[i], rpgblastradius, x >> 2, x >> 1, x - (x >> 2), x);
}
else
{
int x = s->extra + (global_random & 3);
fi.hitradius(i, (rpgblastradius >> 1), x >> 2, x >> 1, x - (x >> 2), x);
fi.hitradius(&hittype[i], (rpgblastradius >> 1), x >> 2, x >> 1, x - (x >> 2), x);
}
}
@ -1943,7 +1943,7 @@ void reactor(int i, int REACTOR, int REACTOR2, int REACTORBURNT, int REACTOR2BUR
case 3:
{
//Turn on all of those flashing sectoreffector.
fi.hitradius(i, 4096,
fi.hitradius(&hittype[i], 4096,
impact_damage << 2,
impact_damage << 2,
impact_damage << 2,

View File

@ -338,16 +338,16 @@ bool ifsquished(int i, int p)
//
//---------------------------------------------------------------------------
void hitradius_d(short i, int r, int hp1, int hp2, int hp3, int hp4)
void hitradius_d(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int hp4)
{
walltype* wal;
int d, q, x1, y1;
int sectcnt, sectend, dasect, startwall, endwall, nextsect;
short j, p, x, sect;
short p, x, sect;
static const uint8_t statlist[] = { STAT_DEFAULT, STAT_ACTOR, STAT_STANDABLE, STAT_PLAYER, STAT_FALLER, STAT_ZOMBIEACTOR, STAT_MISC };
short tempshort[MAXSECTORS]; // originally hijacked a global buffer which is bad. Q: How many do we really need? RedNukem says 64.
auto spri = &sprite[i];
auto spri = &actor->s;
if(spri->picnum == RPG && spri->xrepeat < 11) goto SKIPWALLCHECK;
@ -390,7 +390,7 @@ void hitradius_d(short i, int r, int hp1, int hp2, int hp3, int hp4)
y1 = (((wal->y + wall[wal->point2].y) >> 1) + spri->y) >> 1;
updatesector(x1, y1, &sect);
if (sect >= 0 && cansee(x1, y1, spri->z, sect, spri->x, spri->y, spri->z, spri->sectnum))
fi.checkhitwall(i, x, wal->x, wal->y, spri->z, spri->picnum);
fi.checkhitwall(actor->GetIndex(), x, wal->x, wal->y, spri->z, spri->picnum);
}
} while (sectcnt < sectend);
}
@ -399,22 +399,21 @@ SKIPWALLCHECK:
q = -(16 << 8) + (krand() & ((32 << 8) - 1));
auto Owner = actor->GetOwner();
for (x = 0; x < 7; x++)
{
StatIterator itj(statlist[x]);
while ((j = itj.NextIndex()) >= 0)
DukeStatIterator itj(statlist[x]);
while (auto act2 = itj.Next())
{
auto spri2 = &sprite[j];
auto act2 = &hittype[j];
if (isWorldTour())
auto spri2 = &act2->s;
if (isWorldTour() && Owner)
{
if (sprite[spri->owner].picnum == APLAYER && spri2->picnum == APLAYER && ud.coop != 0 && ud.ffire == 0 && spri->owner != j)
if (Owner->s.picnum == APLAYER && spri2->picnum == APLAYER && ud.coop != 0 && ud.ffire == 0 && Owner != act2)
{
continue;
}
if (spri->picnum == FLAMETHROWERFLAME && ((sprite[spri->owner].picnum == FIREFLY && spri2->picnum == FIREFLY) || (sprite[spri->owner].picnum == BOSS5 && spri2->picnum == BOSS5)))
if (spri->picnum == FLAMETHROWERFLAME && ((Owner->s.picnum == FIREFLY && spri2->picnum == FIREFLY) || (Owner->s.picnum == BOSS5 && spri2->picnum == BOSS5)))
{
continue;
}
@ -423,26 +422,26 @@ SKIPWALLCHECK:
if (x == 0 || x >= 5 || AFLAMABLE(spri2->picnum))
{
if (spri->picnum != SHRINKSPARK || (spri2->cstat & 257))
if (dist(spri, spri2) < r)
if (dist(actor, act2) < r)
{
if (badguy(spri2) && !cansee(spri2->x, spri2->y, spri2->z + q, spri2->sectnum, spri->x, spri->y, spri->z + q, spri->sectnum))
if (badguy(act2) && !cansee(spri2->x, spri2->y, spri2->z + q, spri2->sectnum, spri->x, spri->y, spri->z + q, spri->sectnum))
continue;
fi.checkhitsprite(j, i);
fi.checkhitsprite(act2->GetIndex(), actor->GetIndex());
}
}
else if (spri2->extra >= 0 && spri2 != spri && (spri2->picnum == TRIPBOMB || badguy(spri2) || spri2->picnum == QUEBALL || spri2->picnum == STRIPEBALL || (spri2->cstat & 257) || spri2->picnum == DUKELYINGDEAD))
else if (spri2->extra >= 0 && act2 != actor && (spri2->picnum == TRIPBOMB || badguy(act2) || spri2->picnum == QUEBALL || spri2->picnum == STRIPEBALL || (spri2->cstat & 257) || spri2->picnum == DUKELYINGDEAD))
{
if (spri->picnum == SHRINKSPARK && spri2->picnum != SHARK && (j == spri->owner || spri2->xrepeat < 24))
if (spri->picnum == SHRINKSPARK && spri2->picnum != SHARK && (act2 == Owner || spri2->xrepeat < 24))
{
continue;
}
if (spri->picnum == MORTER && j == spri->owner)
if (spri->picnum == MORTER && act2 == Owner)
{
continue;
}
if (spri2->picnum == APLAYER) spri2->z -= PHEIGHT;
d = dist(spri, spri2);
d = dist(actor, act2);
if (spri2->picnum == APLAYER) spri2->z += PHEIGHT;
if (d < r && cansee(spri2->x, spri2->y, spri2->z - (8 << 8), spri2->sectnum, spri->x, spri->y, spri->z - (12 << 8), spri->sectnum))
@ -461,7 +460,7 @@ SKIPWALLCHECK:
{
if (spri->picnum == SHRINKSPARK || spri->picnum == FLAMETHROWERFLAME)
act2->picnum = spri->picnum;
else if (spri->picnum != FIREBALL || sprite[spri->owner].picnum != APLAYER)
else if (spri->picnum != FIREBALL || !Owner || Owner->s.picnum != APLAYER)
{
if (spri->picnum == LAVAPOOL)
act2->picnum = FLAMETHROWERFLAME;
@ -490,7 +489,7 @@ SKIPWALLCHECK:
act2->extra = hp1 + (krand() % (hp2 - hp1));
}
if (spri2->picnum != TANK && spri2->picnum != ROTATEGUN && spri2->picnum != RECON && !bossguy(spri2))
if (spri2->picnum != TANK && spri2->picnum != ROTATEGUN && spri2->picnum != RECON && !bossguy(act2))
{
if (spri2->xvel < 0) spri2->xvel = 0;
spri2->xvel += (spri->extra << 2);
@ -503,18 +502,17 @@ SKIPWALLCHECK:
spri2->picnum == FEM8 || spri2->picnum == FEM9 ||
spri2->picnum == FEM10 || spri2->picnum == STATUE ||
spri2->picnum == STATUEFLASH || spri2->picnum == SPACEMARINE || spri2->picnum == QUEBALL || spri2->picnum == STRIPEBALL)
fi.checkhitsprite(j, i);
fi.checkhitsprite(act2->GetIndex(), actor->GetIndex());
}
else if (spri->extra == 0) act2->extra = 0;
if (spri2->picnum != RADIUSEXPLOSION &&
spri->owner >= 0 && sprite[spri->owner].statnum < MAXSTATUS)
if (spri2->picnum != RADIUSEXPLOSION && Owner && Owner->s.statnum < MAXSTATUS)
{
if (spri2->picnum == APLAYER)
{
p = spri2->yvel;
if (isWorldTour() && act2->picnum == FLAMETHROWERFLAME && sprite[spri->owner].picnum == APLAYER)
if (isWorldTour() && act2->picnum == FLAMETHROWERFLAME && Owner->s.picnum == APLAYER)
{
ps[p].numloogs = -1 - spri->yvel;
}
@ -524,7 +522,7 @@ SKIPWALLCHECK:
clearcamera(&ps[p]);
}
}
act2->owner = spri->owner;
act2->SetHitOwner(actor->GetOwner());
}
}
}
@ -1113,7 +1111,7 @@ static void movetripbomb(int i)
S_PlayActorSound(LASERTRIP_EXPLODE, i);
for (j = 0; j < 5; j++) RANDOMSCRAP(s, i);
x = s->extra;
fi.hitradius(i, tripbombblastradius, x >> 2, x >> 1, x - (x >> 2), x);
fi.hitradius(&hittype[i], tripbombblastradius, x >> 2, x >> 1, x - (x >> 2), x);
j = fi.spawn(i, EXPLOSION2);
sprite[j].ang = s->ang;
@ -1320,13 +1318,13 @@ static void movefireext(int i)
int x = s->extra;
fi.spawn(i, EXPLOSION2);
fi.hitradius(i, pipebombblastradius, x >> 2, x - (x >> 1), x - (x >> 2), x);
fi.hitradius(&hittype[i], pipebombblastradius, x >> 2, x - (x >> 1), x - (x >> 2), x);
S_PlayActorSound(PIPEBOMB_EXPLODE, i);
detonate(i, EXPLOSION2);
}
else
{
fi.hitradius(i, seenineblastradius, 10, 15, 20, 25);
fi.hitradius(&hittype[i], seenineblastradius, 10, 15, 20, 25);
deletesprite(i);
}
}
@ -1947,7 +1945,7 @@ static void weaponcommon_d(int i)
{
fi.spawn(i, SHRINKEREXPLOSION);
S_PlayActorSound(SHRINKER_HIT, i);
fi.hitradius(i, shrinkerblastradius, 0, 0, 0, 0);
fi.hitradius(&hittype[i], shrinkerblastradius, 0, 0, 0, 0);
}
else if (s->picnum != COOLEXPLOSION1 && s->picnum != FREEZEBLAST && s->picnum != FIRELASER && (!isWorldTour() || s->picnum != FIREBALL))
{
@ -2889,12 +2887,12 @@ static void flamethrowerflame(int i)
if (s->xrepeat >= 10)
{
x = s->extra;
fi.hitradius(i, rpgblastradius, x >> 2, x >> 1, x - (x >> 2), x);
fi.hitradius(&hittype[i], rpgblastradius, x >> 2, x >> 1, x - (x >> 2), x);
}
else
{
x = s->extra + (global_random & 3);
fi.hitradius(i, (rpgblastradius >> 1), x >> 2, x >> 1, x - (x >> 2), x);
fi.hitradius(&hittype[i], (rpgblastradius >> 1), x >> 2, x >> 1, x - (x >> 2), x);
}
}
}
@ -3042,7 +3040,7 @@ DETONATEB:
case BOUNCEMINE: m = bouncemineblastradius; break;
}
fi.hitradius(i, m, x >> 2, x >> 1, x - (x >> 2), x);
fi.hitradius(&hittype[i], m, x >> 2, x >> 1, x - (x >> 2), x);
fi.spawn(i, EXPLOSION2);
if (s->zvel == 0)
fi.spawn(i, EXPLOSION2BOT);

View File

@ -214,17 +214,16 @@ void addweapon_r(struct player_struct* p, int weapon)
//
//---------------------------------------------------------------------------
void hitradius_r(short i, int r, int hp1, int hp2, int hp3, int hp4)
void hitradius_r(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int hp4)
{
spritetype* spri, * spri2;
walltype* wal;
int d, q, x1, y1;
int sectcnt, sectend, dasect, startwall, endwall, nextsect;
short j, p, x, sect;
short p, x, sect;
static const uint8_t statlist[] = { STAT_DEFAULT, STAT_ACTOR, STAT_STANDABLE, STAT_PLAYER, STAT_FALLER, STAT_ZOMBIEACTOR, STAT_MISC };
short tempshort[MAXSECTORS]; // originally hijacked a global buffer which is bad. Q: How many do we really need? RedNukem says 64.
spri = &sprite[i];
auto spri = &actor->s;
if (spri->xrepeat < 11)
{
@ -268,7 +267,7 @@ void hitradius_r(short i, int r, int hp1, int hp2, int hp3, int hp4)
y1 = (((wal->y + wall[wal->point2].y) >> 1) + spri->y) >> 1;
updatesector(x1, y1, &sect);
if (sect >= 0 && cansee(x1, y1, spri->z, sect, spri->x, spri->y, spri->z, spri->sectnum))
fi.checkhitwall(i, x, wal->x, wal->y, spri->z, spri->picnum);
fi.checkhitwall(actor->GetIndex(), x, wal->x, wal->y, spri->z, spri->picnum);
}
} while (sectcnt < sectend);
@ -276,44 +275,43 @@ SKIPWALLCHECK:
q = -(24 << 8) + (krand() & ((32 << 8) - 1));
auto Owner = actor->GetOwner();
for (x = 0; x < 7; x++)
{
StatIterator it1(statlist[x]);
while ((j = it1.NextIndex()) >= 0)
DukeStatIterator it1(statlist[x]);
while (auto act2 = it1.Next())
{
spri2 = &sprite[j];
auto act2 = &hittype[j];
auto spri2 = &act2->s;
if (x == 0 || x >= 5 || AFLAMABLE(spri2->picnum))
{
if (spri2->cstat & 257)
if (dist(spri, spri2) < r)
if (dist(actor, act2) < r)
{
if (badguy(spri2) && !cansee(spri2->x, spri2->y, spri2->z + q, spri2->sectnum, spri->x, spri->y, spri->z + q, spri->sectnum))
if (badguy(act2) && !cansee(spri2->x, spri2->y, spri2->z + q, spri2->sectnum, spri->x, spri->y, spri->z + q, spri->sectnum))
{
continue;
}
fi.checkhitsprite(j, i);
fi.checkhitsprite(act2->GetIndex(), actor->GetIndex());
}
}
else if (spri2->extra >= 0 && spri2 != spri && (badguy(spri2) || spri2->picnum == QUEBALL || spri2->picnum == RRTILE3440 || spri2->picnum == STRIPEBALL || (spri2->cstat & 257) || spri2->picnum == DUKELYINGDEAD))
else if (spri2->extra >= 0 && act2 != actor && (badguy(act2) || spri2->picnum == QUEBALL || spri2->picnum == RRTILE3440 || spri2->picnum == STRIPEBALL || (spri2->cstat & 257) || spri2->picnum == DUKELYINGDEAD))
{
if (spri->picnum == MORTER && j == spri->owner)
if (spri->picnum == MORTER && act2 == Owner)
{
continue;
}
if ((isRRRA()) && spri->picnum == CHEERBOMB && j == spri->owner)
if ((isRRRA()) && spri->picnum == CHEERBOMB && act2 == Owner)
{
continue;
}
if (spri2->picnum == APLAYER) spri2->z -= PHEIGHT;
d = dist(spri, spri2);
d = dist(actor, act2);
if (spri2->picnum == APLAYER) spri2->z += PHEIGHT;
if (d < r && cansee(spri2->x, spri2->y, spri2->z - (8 << 8), spri2->sectnum, spri->x, spri->y, spri->z - (12 << 8), spri->sectnum))
{
if ((isRRRA()) && sprite[j].picnum == MINION && sprite[j].pal == 19)
if ((isRRRA()) && spri2->picnum == MINION && spri2->pal == 19)
{
continue;
}
@ -343,31 +341,31 @@ SKIPWALLCHECK:
act2->extra = hp1 + (krand() % (hp2 - hp1));
}
int pic = sprite[j].picnum;
int pic = spri2->picnum;
if ((isRRRA())?
(pic != HULK && pic != MAMA && pic != BILLYPLAY && pic != COOTPLAY && pic != MAMACLOUD) :
(pic != HULK && pic != SBMOVE))
{
if (sprite[j].xvel < 0) sprite[j].xvel = 0;
sprite[j].xvel += (sprite[j].extra << 2);
if (spri2->xvel < 0) spri2->xvel = 0;
spri2->xvel += (spri2->extra << 2);
}
if (spri2->picnum == STATUEFLASH || spri2->picnum == QUEBALL ||
spri2->picnum == STRIPEBALL || spri2->picnum == RRTILE3440)
fi.checkhitsprite(j, i);
fi.checkhitsprite(act2->GetIndex(), actor->GetIndex());
if (sprite[j].picnum != RADIUSEXPLOSION &&
spri->owner >= 0 && sprite[spri->owner].statnum < MAXSTATUS)
if (spri2->picnum != RADIUSEXPLOSION &&
Owner && Owner->s.statnum < MAXSTATUS)
{
if (sprite[j].picnum == APLAYER)
if (spri2->picnum == APLAYER)
{
p = sprite[j].yvel;
p = act2->PlayerIndex();
if (ps[p].newowner >= 0)
{
clearcamera(&ps[p]);
}
}
act2->owner = spri->owner;
act2->SetHitOwner(actor->GetOwner());
}
}
}
@ -2757,7 +2755,7 @@ DETONATEB:
if (sector[s->sectnum].lotag != 800)
{
fi.hitradius(i, m, x >> 2, x >> 1, x - (x >> 2), x);
fi.hitradius(&hittype[i], m, x >> 2, x >> 1, x - (x >> 2), x);
fi.spawn(i, EXPLOSION2);
if (s->picnum == CHEERBOMB)
fi.spawn(i, BURNING);

View File

@ -64,8 +64,8 @@ bool floorspace_d(int sectnum);
bool floorspace_r(int sectnum);
void addweapon_d(struct player_struct* p, int weapon);
void addweapon_r(struct player_struct* p, int weapon);
void hitradius_d(short i, int r, int hp1, int hp2, int hp3, int hp4);
void hitradius_r(short i, int r, int hp1, int hp2, int hp3, int hp4);
void hitradius_d(DDukeActor* i, int r, int hp1, int hp2, int hp3, int hp4);
void hitradius_r(DDukeActor* i, int r, int hp1, int hp2, int hp3, int hp4);
void lotsofmoney_d(DDukeActor* s, short n);
void lotsofmail_d(DDukeActor* s, short n);
void lotsofpaper_d(DDukeActor* s, short n);

View File

@ -87,7 +87,7 @@ struct Dispatcher
bool (*ceilingspace)(int sectnum);
bool (*floorspace)(int sectnum);
void (*addweapon)(struct player_struct *p, int weapon);
void (*hitradius)(short i, int r, int hp1, int hp2, int hp3, int hp4);
void (*hitradius)(DDukeActor* i, int r, int hp1, int hp2, int hp3, int hp4);
int (*movesprite)(int spritenum, int xchange, int ychange, int zchange, unsigned int cliptype);
void (*lotsofmoney)(DDukeActor *s, short n);
void (*lotsofmail)(DDukeActor *s, short n);

View File

@ -2398,7 +2398,7 @@ int ParseState::parse(void)
insptr++;
break;
case concmd_hitradius:
fi.hitradius(g_i,*(insptr+1),*(insptr+2),*(insptr+3),*(insptr+4),*(insptr+5));
fi.hitradius(g_ac,*(insptr+1),*(insptr+2),*(insptr+3),*(insptr+4),*(insptr+5));
insptr+=6;
break;
case concmd_ifp:

View File

@ -1555,7 +1555,7 @@ void checkhitsprite_r(int i, int sn)
case RRTILE7879:
s->picnum++;
S_PlayActorSound(495, i);
fi.hitradius(i, 10, 0, 0, 1, 1);
fi.hitradius(&hittype[i], 10, 0, 0, 1, 1);
break;
case RRTILE7648:
case RRTILE7694:
@ -1756,17 +1756,17 @@ void checkhitsprite_r(int i, int sn)
case RRTILE7890:
s->picnum = RRTILE5045;
S_PlayActorSound(495, i);
fi.hitradius(i, 10, 0, 0, 1, 1);
fi.hitradius(&hittype[i], 10, 0, 0, 1, 1);
break;
case RRTILE7886:
s->picnum = RRTILE5046;
S_PlayActorSound(495, i);
fi.hitradius(i, 10, 0, 0, 1, 1);
fi.hitradius(&hittype[i], 10, 0, 0, 1, 1);
break;
case RRTILE7887:
s->picnum = RRTILE5044;
S_PlayActorSound(GLASS_HEAVYBREAK, i);
fi.hitradius(i, 10, 0, 0, 1, 1);
fi.hitradius(&hittype[i], 10, 0, 0, 1, 1);
break;
case RRTILE7900:
s->picnum = RRTILE5047;
@ -1890,7 +1890,7 @@ void checkhitsprite_r(int i, int sn)
case RRTILE7533:
s->picnum = RRTILE5035;
S_PlayActorSound(495, i);
fi.hitradius(i, 10, 0, 0, 1, 1);
fi.hitradius(&hittype[i], 10, 0, 0, 1, 1);
break;
case RRTILE8394:
s->picnum = RRTILE5072;
@ -1904,7 +1904,7 @@ void checkhitsprite_r(int i, int sn)
case RRTILE8679:
s->picnum = RRTILE8680;
S_PlayActorSound(DUKE_SHUCKS, i);
fi.hitradius(i, 10, 0, 0, 1, 1);
fi.hitradius(&hittype[i], 10, 0, 0, 1, 1);
if (s->lotag != 0)
{
short j;
@ -1921,7 +1921,7 @@ void checkhitsprite_r(int i, int sn)
case RRTILE3584:
s->picnum = RRTILE8681;
S_PlayActorSound(495, i);
fi.hitradius(i, 250, 0, 0, 1, 1);
fi.hitradius(&hittype[i], 250, 0, 0, 1, 1);
break;
case RRTILE8682:
s->picnum = RRTILE8683;