- hitawall

This commit is contained in:
Christoph Oelckers 2021-11-18 00:04:36 +01:00
parent d45ab528e6
commit 4823152107
4 changed files with 33 additions and 32 deletions

View file

@ -156,7 +156,7 @@ bool isanunderoperator(int lotag);
int setanimation(int animsect, int animtype, int animindex, int thegoal, int thevel); int setanimation(int animsect, int animtype, int animindex, int thegoal, int thevel);
void dofurniture(int wallNum, int sectnum, int playerNum); void dofurniture(int wallNum, int sectnum, int playerNum);
void dotorch(); void dotorch();
int hitawall(struct player_struct* pl, int* hitWall); int hitawall(struct player_struct* pl, walltype** hitWall);
int hits(DDukeActor* snum); int hits(DDukeActor* snum);
DDukeActor* LocateTheLocator(int n, int sectnum); DDukeActor* LocateTheLocator(int n, int sectnum);

View file

@ -211,14 +211,12 @@ int hitasprite(DDukeActor* actor, DDukeActor** hitsp)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
int hitawall(struct player_struct* p, int* hitw) int hitawall(struct player_struct* p, walltype** hitw)
{ {
int sx, sy, sz; int sx, sy, sz;
int hitw1;
hitscanw(p->pos.x, p->pos.y, p->pos.z, p->cursectnum, hitscan(p->pos.x, p->pos.y, p->pos.z, p->cursectnum,
p->angle.ang.bcos(), p->angle.ang.bsin(), 0, nullptr, &hitw1, nullptr, &sx, &sy, &sz, CLIPMASK0); p->angle.ang.bcos(), p->angle.ang.bsin(), 0, nullptr, hitw, nullptr, &sx, &sy, &sz, CLIPMASK0);
*hitw = hitw1;
return (FindDistance2D(sx - p->pos.x, sy - p->pos.y)); return (FindDistance2D(sx - p->pos.x, sy - p->pos.y));
} }

View file

@ -1496,7 +1496,8 @@ void checksectors_d(int snum)
{ {
int i = -1, oldz; int i = -1, oldz;
struct player_struct* p; struct player_struct* p;
int j, hitscanwall; int j;
walltype* hitscanwall;
int neartagsector, neartagwall; int neartagsector, neartagwall;
DDukeActor* neartagsprite; DDukeActor* neartagsprite;
int neartaghitdist; int neartaghitdist;
@ -1567,21 +1568,20 @@ void checksectors_d(int snum)
neartagsprite = nullptr; neartagsprite = nullptr;
p->toggle_key_flag = 1; p->toggle_key_flag = 1;
hitscanwall = -1; hitscanwall = nullptr;
i = hitawall(p, &hitscanwall); i = hitawall(p, &hitscanwall);
if (hitscanwall >= 0) if (hitscanwall != nullptr)
{ {
auto hitwal = &wall[hitscanwall]; if (i < 1280 && hitscanwall->overpicnum == MIRROR)
if (i < 1280 && hitwal->overpicnum == MIRROR) if (hitscanwall->lotag > 0 && S_CheckSoundPlaying(hitscanwall->lotag) == 0 && snum == screenpeek)
if (hitwal->lotag > 0 && S_CheckSoundPlaying(hitwal->lotag) == 0 && snum == screenpeek)
{ {
S_PlayActorSound(hitwal->lotag, pact); S_PlayActorSound(hitscanwall->lotag, pact);
return; return;
} }
if (hitscanwall >= 0 && (hitwal->cstat & 16)) if (hitscanwall != nullptr && (hitscanwall->cstat & 16))
if (hitwal->lotag) if (hitscanwall->lotag)
return; return;
} }
if (p->newOwner != nullptr) if (p->newOwner != nullptr)
@ -1673,9 +1673,10 @@ void checksectors_d(int snum)
return; return;
case NUKEBUTTON: case NUKEBUTTON:
{
hitawall(p, &j); walltype* wal;
if (j >= 0 && wall[j].overpicnum == 0) hitawall(p, &wal);
if (wal != nullptr && wal->overpicnum == 0)
if (neartagsprite->temp_data[0] == 0) if (neartagsprite->temp_data[0] == 0)
{ {
neartagsprite->temp_data[0] = 1; neartagsprite->temp_data[0] = 1;
@ -1686,6 +1687,7 @@ void checksectors_d(int snum)
else ud.secretlevel = 0; else ud.secretlevel = 0;
} }
return; return;
}
case WATERFOUNTAIN: case WATERFOUNTAIN:
if (neartagsprite->temp_data[0] != 1) if (neartagsprite->temp_data[0] != 1)
{ {
@ -1771,9 +1773,10 @@ void checksectors_d(int snum)
if (neartagwall >= 0) if (neartagwall >= 0)
{ {
if (wall[neartagwall].lotag > 0 && fi.isadoorwall(wall[neartagwall].picnum)) auto ntwall = &wall[neartagwall];
if (ntwall->lotag > 0 && fi.isadoorwall(ntwall->picnum))
{ {
if (hitscanwall == neartagwall || hitscanwall == -1) if (hitscanwall == ntwall || hitscanwall == nullptr)
fi.checkhitswitch(snum, neartagwall, nullptr); fi.checkhitswitch(snum, neartagwall, nullptr);
return; return;
} }

View file

@ -2446,7 +2446,7 @@ void checksectors_r(int snum)
{ {
int oldz; int oldz;
struct player_struct* p; struct player_struct* p;
int hitscanwall; walltype* hitscanwall;
int neartagsector, neartagwall; int neartagsector, neartagwall;
DDukeActor* neartagsprite; DDukeActor* neartagsprite;
int neartaghitdist; int neartaghitdist;
@ -2502,16 +2502,15 @@ void checksectors_r(int snum)
{ {
neartagsprite = nullptr; neartagsprite = nullptr;
p->toggle_key_flag = 1; p->toggle_key_flag = 1;
hitscanwall = -1; hitscanwall = nullptr;
hitawall(p, &hitscanwall); hitawall(p, &hitscanwall);
if (hitscanwall >= 0) if (hitscanwall != nullptr)
{ {
auto hitwal = &wall[hitscanwall];
if (isRRRA()) if (isRRRA())
{ {
if (hitwal->overpicnum == MIRROR && snum == screenpeek) if (hitscanwall->overpicnum == MIRROR && snum == screenpeek)
if (numplayers == 1) if (numplayers == 1)
{ {
if (S_CheckActorSoundPlaying(pact, 27) == 0 && S_CheckActorSoundPlaying(pact, 28) == 0 && S_CheckActorSoundPlaying(pact, 29) == 0 if (S_CheckActorSoundPlaying(pact, 27) == 0 && S_CheckActorSoundPlaying(pact, 28) == 0 && S_CheckActorSoundPlaying(pact, 29) == 0
@ -2534,16 +2533,16 @@ void checksectors_r(int snum)
} }
else else
{ {
if (hitwal->overpicnum == MIRROR) if (hitscanwall->overpicnum == MIRROR)
if (hitwal->lotag > 0 && S_CheckActorSoundPlaying(pact, hitwal->lotag) == 0 && snum == screenpeek) if (hitscanwall->lotag > 0 && S_CheckActorSoundPlaying(pact, hitscanwall->lotag) == 0 && snum == screenpeek)
{ {
S_PlayActorSound(hitwal->lotag, pact); S_PlayActorSound(hitscanwall->lotag, pact);
return; return;
} }
} }
if ((hitwal->cstat & 16)) if ((hitscanwall->cstat & 16))
if (hitwal->lotag) if (hitscanwall->lotag)
return; return;
} }
@ -2736,9 +2735,10 @@ void checksectors_r(int snum)
if (neartagwall >= 0) if (neartagwall >= 0)
{ {
if (wall[neartagwall].lotag > 0 && fi.isadoorwall(wall[neartagwall].picnum)) auto ntwall = &wall[neartagwall];
if (ntwall->lotag > 0 && fi.isadoorwall(ntwall->picnum))
{ {
if (hitscanwall == neartagwall || hitscanwall == -1) if (hitscanwall == ntwall || hitscanwall == nullptr)
fi.checkhitswitch(snum, neartagwall, nullptr); fi.checkhitswitch(snum, neartagwall, nullptr);
return; return;
} }