- ifhitbyweapon.

# 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 21:41:14 +02:00
parent 92c21e7259
commit 41e1e9b51c
6 changed files with 57 additions and 65 deletions

View file

@ -794,7 +794,7 @@ void movecrane(DDukeActor *actor, int crane)
{
int p = findplayer(actor, &x);
int j = fi.ifhitbyweapon(actor->GetIndex());
int j = fi.ifhitbyweapon(actor);
if (j >= 0)
{
if (actor->IsActiveCrane())
@ -1209,7 +1209,7 @@ void moveooz(int i, int seenine, int seeninedead, int ooz, int explosion)
if (s->shade != -32 && s->shade != -33)
{
if (s->xrepeat)
j = (fi.ifhitbyweapon(i) >= 0);
j = (fi.ifhitbyweapon(&hittype[i]) >= 0);
else
j = 0;
@ -1286,7 +1286,7 @@ void movecanwithsomething(int i)
{
auto s = &sprite[i];
makeitfall(i);
int j = fi.ifhitbyweapon(i);
int j = fi.ifhitbyweapon(&hittype[i]);
if (j >= 0)
{
S_PlayActorSound(VENT_BUST, i);
@ -1680,7 +1680,7 @@ void recon(int i, int explosion, int firelaser, int attacksnd, int painsnd, int
}
else if (actor_tog == 2) s->cstat = 257;
}
j = fi.ifhitbyweapon(i); if (j >= 0)
j = fi.ifhitbyweapon(&hittype[i]); if (j >= 0)
{
if (s->extra < 0 && t[0] != -1)
{
@ -1993,7 +1993,7 @@ void reactor(int i, int REACTOR, int REACTOR2, int REACTORBURNT, int REACTOR2BUR
}
else
{
int j = fi.ifhitbyweapon(i);
int j = fi.ifhitbyweapon(&hittype[i]);
if (j >= 0)
{
for (x = 0; x < 32; x++)
@ -2018,7 +2018,7 @@ void camera(int i)
{
if (camerashitable)
{
int j = fi.ifhitbyweapon(i);
int j = fi.ifhitbyweapon(&hittype[i]);
if (j >= 0)
{
t[0] = 1; // static
@ -3471,7 +3471,7 @@ void handle_se05(int i, int FIRELASER)
getincangle(t[2] + 512, getangle(ps[p].posx - s->x, ps[p].posy - s->y)) >> 2;
sc->ceilingshade = 0;
}
j = fi.ifhitbyweapon(i);
j = fi.ifhitbyweapon(&hittype[i]);
if (j >= 0)
{
t[3]++;

View file

@ -859,12 +859,11 @@ int ifhitsectors_d(int sectnum)
//
//---------------------------------------------------------------------------
int ifhitbyweapon_d(int sn)
int ifhitbyweapon_d(DDukeActor *actor)
{
short j, p;
auto spri = &sprite[sn];
auto actor = &hittype[sn];
auto htowner = actor->owner < 0? nullptr : &sprite[actor->owner];
short p;
auto spri = &actor->s;
auto hitowner = actor->GetHitOwner();
if (actor->extra >= 0)
{
@ -875,31 +874,28 @@ int ifhitbyweapon_d(int sn)
if (ud.god && actor->picnum != SHRINKSPARK) return -1;
p = spri->yvel;
j = actor->owner;
if (j >= 0 &&
sprite[j].picnum == APLAYER &&
if (hitowner &&
hitowner->s.picnum == APLAYER &&
ud.coop == 1 &&
ud.ffire == 0)
return -1;
spri->extra -= actor->extra;
if (j >= 0)
if (hitowner)
{
if (spri->extra <= 0 && actor->picnum != FREEZEBLAST)
{
spri->extra = 0;
ps[p].wackedbyactor = &hittype[j];
ps[p].wackedbyactor = hitowner;
if (htowner->picnum == APLAYER && p != htowner->yvel)
if (hitowner->s.picnum == APLAYER && p != hitowner->PlayerIndex())
{
// yvel contains player ID
ps[p].frag_ps = sprite[j].yvel;
ps[p].frag_ps = hitowner->PlayerIndex();
}
actor->owner = ps[p].i;
actor->SetHitOwner(ps[p].GetActor());
}
}
@ -938,8 +934,9 @@ int ifhitbyweapon_d(int sn)
}
spri->extra -= actor->extra;
if (spri->picnum != RECON && spri->owner >= 0 && sprite[spri->owner].statnum < MAXSTATUS)
spri->owner = actor->owner;
auto Owner = actor->GetOwner();
if (spri->picnum != RECON && Owner && Owner->s.statnum < MAXSTATUS)
actor->SetOwner(hitowner);
}
actor->extra = -1;
@ -953,22 +950,22 @@ int ifhitbyweapon_d(int sn)
|| actor->extra >= 0
|| spri->extra > 0
|| spri->picnum != APLAYER
|| ps[spri->yvel].numloogs > 0
|| actor->owner < 0)
|| ps[actor->PlayerIndex()].numloogs > 0
|| hitowner == nullptr)
{
actor->extra = -1;
return -1;
}
else
{
p = spri->yvel;
p = actor->PlayerIndex();
spri->extra = 0;
ps[p].wackedbyactor = actor->GetHitOwner();
ps[p].wackedbyactor = hitowner;
if (htowner->picnum == APLAYER && p != actor->owner)
ps[p].frag_ps = (short)actor->owner;
if (hitowner->s.picnum == APLAYER && hitowner != ps[p].GetActor())
ps[p].frag_ps = hitowner->PlayerIndex(); // set the proper player index here - this previously set the sprite index...
actor->owner = ps[p].i;
actor->SetHitOwner(ps[p].GetActor());
actor->extra = -1;
return FLAMETHROWERFLAME;
@ -1000,7 +997,7 @@ void movefallers_d(void)
s->z -= (16 << 8);
ht->temp_data[1] = s->ang;
x = s->extra;
j = fi.ifhitbyweapon(i);
j = fi.ifhitbyweapon(&hittype[i]);
if (j >= 0)
{
if (j == FIREEXT || j == RPG || j == RADIUSEXPLOSION || j == SEENINE || j == OOZFILTER)
@ -1138,7 +1135,7 @@ static void movetripbomb(int i)
x = s->extra;
s->extra = 1;
int16_t l = s->ang;
j = fi.ifhitbyweapon(i);
j = fi.ifhitbyweapon(&hittype[i]);
if (j >= 0)
{
hittype[i].temp_data[2] = 16;
@ -1263,7 +1260,7 @@ static void movecrack(int i)
{
t[0] = s->cstat;
t[1] = s->ang;
int j = fi.ifhitbyweapon(i);
int j = fi.ifhitbyweapon(&hittype[i]);
if (j == FIREEXT || j == RPG || j == RADIUSEXPLOSION || j == SEENINE || j == OOZFILTER)
{
StatIterator it(STAT_STANDABLE);
@ -1293,7 +1290,7 @@ static void movecrack(int i)
static void movefireext(int i)
{
int j = fi.ifhitbyweapon(i);
int j = fi.ifhitbyweapon(&hittype[i]);
if (j == -1) return;
auto s = &sprite[i];
@ -2459,7 +2456,7 @@ static void greenslime(int i)
s->picnum = GREENSLIME + 2;
s->extra = 1;
s->pal = 1;
j = fi.ifhitbyweapon(i); if (j >= 0)
j = fi.ifhitbyweapon(&hittype[i]); if (j >= 0)
{
if (j == FREEZEBLAST)
return;
@ -2594,7 +2591,7 @@ static void greenslime(int i)
}
}
j = fi.ifhitbyweapon(i); if (j >= 0)
j = fi.ifhitbyweapon(&hittype[i]); if (j >= 0)
{
S_PlayActorSound(SLIM_DYING, i);
@ -2934,7 +2931,7 @@ static void heavyhbomb(int i)
if (t[3] == 0)
{
j = fi.ifhitbyweapon(i);
j = fi.ifhitbyweapon(&hittype[i]);
if (j >= 0)
{
t[3] = 1;
@ -3175,7 +3172,7 @@ void moveactors_d(void)
}
else
{
j = fi.ifhitbyweapon(i);
j = fi.ifhitbyweapon(&hittype[i]);
if (j >= 0)
{
s->cstat = 32 + 128;

View file

@ -688,48 +688,43 @@ int ifhitsectors_r(int sectnum)
//
//---------------------------------------------------------------------------
int ifhitbyweapon_r(int sn)
int ifhitbyweapon_r(DDukeActor *actor)
{
short j, p;
auto actor = &hittype[sn];
int p;
auto hitowner = actor->GetHitOwner();
auto spri = &actor->s;
if (actor->extra >= 0)
{
if (spri->extra >= 0)
{
spri = &sprite[sn];
if (spri->picnum == APLAYER)
{
if (ud.god) return -1;
p = spri->yvel;
j = actor->owner;
p = actor->PlayerIndex();
if (j >= 0 &&
sprite[j].picnum == APLAYER &&
if (hitowner &&
hitowner->s.picnum == APLAYER &&
ud.coop == 1 &&
ud.ffire == 0)
return -1;
spri->extra -= actor->extra;
if (j >= 0)
if (hitowner)
{
if (spri->extra <= 0 && actor->picnum != FREEZEBLAST)
{
spri->extra = 0;
ps[p].wackedbyactor = &hittype[j];
ps[p].wackedbyactor = hitowner;
if (sprite[actor->owner].picnum == APLAYER && p != sprite[actor->owner].yvel)
if (hitowner->s.picnum == APLAYER && p != hitowner->PlayerIndex())
{
// yvel contains player ID
ps[p].frag_ps = sprite[j].yvel;
ps[p].frag_ps = hitowner->PlayerIndex();
}
actor->owner = ps[p].i;
actor->SetHitOwner(ps[p].GetActor());
}
}
@ -766,8 +761,8 @@ int ifhitbyweapon_r(int sn)
return -1;
spri->extra -= actor->extra;
if (spri->picnum != RECON && spri->owner >= 0 && sprite[spri->owner].statnum < MAXSTATUS)
spri->owner = actor->owner;
if (spri->picnum != RECON && actor->GetOwner() && actor->GetOwner()->s.statnum < MAXSTATUS)
actor->SetOwner(hitowner);
}
actor->extra = -1;
@ -856,7 +851,7 @@ void movefallers_r(void)
s->z -= (16 << 8);
hittype[i].temp_data[1] = s->ang;
x = s->extra;
j = ifhitbyweapon_r(i);
j = fi.ifhitbyweapon(&hittype[i]);
if (j >= 0)
{
if (j == RPG || (isRRRA() && j == RPG2) || j == RADIUSEXPLOSION || j == SEENINE || j == OOZFILTER)
@ -950,7 +945,7 @@ static void movecrack(int i)
{
t[0] = s->cstat;
t[1] = s->ang;
int j = ifhitbyweapon_r(i);
int j = fi.ifhitbyweapon(&hittype[i]);
if (j == RPG || (isRRRA() && j == RPG2) || j == RADIUSEXPLOSION || j == SEENINE || j == OOZFILTER)
{
StatIterator it(STAT_STANDABLE);
@ -2629,7 +2624,7 @@ static void heavyhbomb(int i)
if (t[3] == 0)
{
j = fi.ifhitbyweapon(i);
j = fi.ifhitbyweapon(&hittype[i]);
if (j >= 0)
{
t[3] = 1;

View file

@ -76,8 +76,8 @@ void gutsdir_d(spritetype* s, short gtype, short n, short p);
void gutsdir_r(spritetype* s, short gtype, short n, short p);
int ifhitsectors_d(int sectnum);
int ifhitsectors_r(int sectnum);
int ifhitbyweapon_r(int sn);
int ifhitbyweapon_d(int sn);
int ifhitbyweapon_r(DDukeActor* sn);
int ifhitbyweapon_d(DDukeActor* sn);
void fall_d(int g_i, int g_p);
void fall_r(int g_i, int g_p);
bool spawnweapondebris_d(int picnum, int dnum);

View file

@ -95,7 +95,7 @@ struct Dispatcher
void (*guts)(spritetype* s, short gtype, short n, short p);
void (*gutsdir)(spritetype* s, short gtype, short n, short p);
int (*ifhitsectors)(int sectnum);
int (*ifhitbyweapon)(int sectnum);
int (*ifhitbyweapon)(DDukeActor* sectnum);
void (*fall)(int g_i, int g_p);
bool (*spawnweapondebris)(int picnum, int dnum);
void (*respawnhitag)(spritetype* g_sp);

View file

@ -1560,7 +1560,7 @@ int ParseState::parse(void)
break;
case concmd_ifhitweapon:
parseifelse(fi.ifhitbyweapon(g_i) >= 0);
parseifelse(fi.ifhitbyweapon(g_ac) >= 0);
break;
case concmd_ifsquished:
parseifelse(ifsquished(g_i, g_p) == 1);