- adapted neartag in SW and Exhumed.

This commit is contained in:
Christoph Oelckers 2021-11-26 19:30:32 +01:00
parent 91e2391911
commit 729076b79d
5 changed files with 49 additions and 85 deletions

View file

@ -1303,12 +1303,10 @@ sectdone:
}
// code to handle item pickup?
short nearTagSector, nearTagWall, nearTagSprite;
int nearHitDist;
HitInfo near;
// neartag finds the nearest sector, wall, and sprite which has its hitag and/or lotag set to a value.
neartag(pPlayerSprite->x, pPlayerSprite->y, pPlayerSprite->z, pPlayerSprite->sectnum, pPlayerSprite->ang,
&nearTagSector, &nearTagWall, &nearTagSprite, (int32_t*)&nearHitDist, 1024, 2);
neartag(pPlayerSprite->pos, pPlayerSprite->sector(), pPlayerSprite->ang, near, 1024, 2);
DExhumedActor* pActorB;
feebtag(pPlayerSprite->x, pPlayerSprite->y, pPlayerSprite->z, pPlayerSprite->sector(), &pActorB, var_30, 768);
@ -2255,12 +2253,12 @@ sectdone:
ClearSpaceBar(nPlayer);
int tag;
if (nearTagWall >= 0 && (tag = wall[nearTagWall].lotag) > 0)
if (near.hitWall != nullptr && (tag = near.hitWall->lotag) > 0)
{
runlist_SignalRun(tag - 1, nPlayer, &ExhumedAI::Use);
}
if (nearTagSector >= 0 && (tag = sector[nearTagSector].lotag) > 0)
if (near.hitSector != nullptr && (tag = near.hitSector->lotag) > 0)
{
runlist_SignalRun(tag - 1, nPlayer, &ExhumedAI::Use);
}

View file

@ -451,8 +451,7 @@ int DoActorOperate(DSWActor* actor)
{
SPRITEp sp = &actor->s();
USERp u = actor->u();
short nearsector = 0, nearwall = 0, nearsprite = 0;
int nearhitdist = 0;
HitInfo near{};
int z[2];
unsigned int i;
@ -470,16 +469,12 @@ int DoActorOperate(DSWActor* actor)
for (i = 0; i < SIZ(z); i++)
{
neartag(sp->x, sp->y, z[i], sp->sectnum, sp->ang,
&nearsector, &nearwall, &nearsprite,
&nearhitdist, 1024L, NTAG_SEARCH_LO_HI);
neartag({ sp->x, sp->y, z[i] }, sp->sector(), sp->ang, near, 1024, NTAG_SEARCH_LO_HI);
}
if (nearsector >= 0 && nearhitdist < 1024)
if (near.hitSector != nullptr && near.hitpos.x < 1024)
{
if (OperateSector(&sector[nearsector], false))
if (OperateSector(near.hitSector, false))
{
u->WaitTics = 2 * 120;

View file

@ -3197,8 +3197,6 @@ void DoPlayerClimb(PLAYERp pp)
SPRITEp sp = &pp->Actor()->s();
int climbvel;
int dot;
short sec,wal,spr;
int dist;
bool LadderUpdate = false;
if (Prediction)
@ -3389,16 +3387,13 @@ void DoPlayerClimb(PLAYERp pp)
{
SPRITEp lsp;
int nx,ny;
HitInfo near;
// constantly look for new ladder sector because of warping at any time
neartag(pp->posx, pp->posy, pp->posz,
sectnum(pp->cursector), pp->angle.ang.asbuild(),
&sec, &wal, &spr,
&dist, 800L, NTAG_SEARCH_LO_HI);
neartag(pp->pos, pp->cursector, pp->angle.ang.asbuild(), near, 800, NTAG_SEARCH_LO_HI);
if (wal >= 0)
if (near.hitWall)
{
auto wp = &wall[wal];
auto lActor = FindNearSprite(pp->Actor(), STAT_CLIMB_MARKER);
if (!lActor) return;
auto lsp = &lActor->s();
@ -3409,7 +3404,7 @@ void DoPlayerClimb(PLAYERp pp)
ny = MOVEy(100, lsp->ang);
// set ladder sector
pp->LadderSector = wp->twoSided()? wp->nextSector() : wp->sectorp();
pp->LadderSector = near.hitWall->twoSided()? near.hitWall->nextSector() : near.hitWall->sectorp();
// set players "view" distance from the ladder - needs to be farther than
// the sprite
@ -3725,15 +3720,12 @@ DSWActor* FindNearSprite(DSWActor* actor, short stat)
bool PlayerOnLadder(PLAYERp pp)
{
short sec, wal = 0, spr;
int dist, nx, ny;
int nx, ny;
unsigned i;
SPRITEp lsp;
HitInfo hit;
int dir;
HitInfo hit, near;
int dir, dist;
int neartaghitdist;
short neartagsector, neartagwall, neartagsprite;
static short angles[] =
{
@ -3743,25 +3735,21 @@ bool PlayerOnLadder(PLAYERp pp)
if (Prediction)
return false;
neartag(pp->posx, pp->posy, pp->posz, sectnum(pp->cursector), pp->angle.ang.asbuild(),
&neartagsector, &neartagwall, &neartagsprite,
&neartaghitdist, 1024L+768L, NTAG_SEARCH_LO_HI);
neartag(pp->pos, pp->cursector, pp->angle.ang.asbuild(), near, 1024 + 768, NTAG_SEARCH_LO_HI);
dir = DOT_PRODUCT_2D(pp->xvect, pp->yvect, pp->angle.ang.bcos(), pp->angle.ang.bsin());
if (dir < 0)
return false;
if (neartagwall < 0 || wall[neartagwall].lotag != TAG_WALL_CLIMB)
if (near.hitWall == nullptr || near.hitWall->lotag != TAG_WALL_CLIMB)
return false;
for (i = 0; i < SIZ(angles); i++)
{
neartag(pp->posx, pp->posy, pp->posz, sectnum(pp->cursector), NORM_ANGLE(pp->angle.ang.asbuild() + angles[i]),
&sec, &wal, &spr,
&dist, 600L, NTAG_SEARCH_LO_HI);
neartag(pp->pos, pp->cursector, NORM_ANGLE(pp->angle.ang.asbuild() + angles[i]), near, 600, NTAG_SEARCH_LO_HI);
if (wal < 0 || dist < 100 || wall[wal].lotag != TAG_WALL_CLIMB)
if (near.hitWall == nullptr || near.hitpos.x < 100 || near.hitWall->lotag != TAG_WALL_CLIMB)
return false;
FAFhitscan(pp->posx, pp->posy, pp->posz, pp->cursector,
@ -3803,9 +3791,7 @@ bool PlayerOnLadder(PLAYERp pp)
nx = MOVEx(100, lsp->ang);
ny = MOVEy(100, lsp->ang);
auto wp = &wall[wal];
pp->LadderSector = wp->twoSided() ? wp->nextSector() : wp->sectorp();
pp->LadderSector = near.hitWall->twoSided() ? near.hitWall->nextSector() : near.hitWall->sectorp();
// set players "view" distance from the ladder - needs to be farther than
// the sprite

View file

@ -2012,9 +2012,7 @@ short PlayerTakeSectorDamage(PLAYERp pp)
enum { PLAYER_SOUNDEVENT_TAG = 900 };
bool NearThings(PLAYERp pp)
{
short neartagsect, neartagwall, neartagsprite;
int neartaghitdist;
HitInfo near;
// Check player's current sector for triggered sound
if (pp->cursector->hitag == PLAYER_SOUNDEVENT_TAG)
@ -2024,16 +2022,14 @@ bool NearThings(PLAYERp pp)
return false;
}
neartag(pp->posx, pp->posy, pp->posz, sectnum(pp->cursector), pp->angle.ang.asbuild(),
&neartagsect, &neartagwall, &neartagsprite,
&neartaghitdist, 1024L, NTAG_SEARCH_LO_HI);
neartag(pp->pos, pp->cursector, pp->angle.ang.asbuild(), near, 1024, NTAG_SEARCH_LO_HI);
// hit a sprite? Check to see if it has sound info in it!
// This can work with any sprite!
if (neartagsprite >= 0)
if (near.actor() != nullptr)
{
SPRITEp sp = &sprite[neartagsprite];
SPRITEp sp = &near.actor()->s();
// Go through list of cases
if (sp->hitag == PLAYER_SOUNDEVENT_TAG)
@ -2044,14 +2040,13 @@ bool NearThings(PLAYERp pp)
return false; // Return false so he doesn't grunt
}
if (neartagwall >= 0)
if (near.hitWall != nullptr)
{
auto ntwall = &wall[neartagwall];
// Check player's current sector for triggered sound
if (ntwall->hitag == PLAYER_SOUNDEVENT_TAG)
if (near.hitWall->hitag == PLAYER_SOUNDEVENT_TAG)
{
if (pp == Player+myconnectindex)
PlayerSound(ntwall->lotag, v3df_follow|v3df_dontpan,pp);
PlayerSound(near.hitWall->lotag, v3df_follow|v3df_dontpan,pp);
return false; // We are playing a sound so don't return true
}
return true;
@ -2077,7 +2072,7 @@ bool NearThings(PLAYERp pp)
if (hit.actor() != nullptr)
return false;
if (neartagsect >= 0)
if (near.hitSector != nullptr)
return true;
if (hit.hitWall != nullptr)
@ -2108,22 +2103,19 @@ short nti_cnt;
void NearTagList(NEAR_TAG_INFOp ntip, PLAYERp pp, int z, int dist, int type, int count)
{
short save_lotag, save_hitag;
short neartagsector, neartagwall, neartagsprite;
int neartaghitdist;
HitInfo near;
neartag(pp->posx, pp->posy, z, sectnum(pp->cursector), pp->angle.ang.asbuild(),
&neartagsector, &neartagwall, &neartagsprite,
&neartaghitdist, dist, type);
neartag({ pp->posx, pp->posy, z }, pp->cursector, pp->angle.ang.asbuild(), near, dist, type);
if (neartagsector >= 0)
if (near.hitSector != nullptr)
{
auto ntsec = &sector[neartagsector];
auto ntsec = near.hitSector;
// save off values
save_lotag = ntsec->lotag;
save_hitag = ntsec->hitag;
ntip->dist = neartaghitdist;
ntip->dist = near.hitpos.x;
ntip->sectp = ntsec;
ntip->wallp = nullptr;
ntip->actor = nullptr;
@ -2143,14 +2135,14 @@ void NearTagList(NEAR_TAG_INFOp ntip, PLAYERp pp, int z, int dist, int type, int
ntsec->lotag = save_lotag;
ntsec->hitag = save_hitag;
}
else if (neartagwall >= 0)
else if (near.hitWall != nullptr)
{
auto ntwall = &wall[neartagwall];
auto ntwall = near.hitWall;
// save off values
save_lotag = ntwall->lotag;
save_hitag = ntwall->hitag;
ntip->dist = neartaghitdist;
ntip->dist = near.hitpos.x;
ntip->sectp = nullptr;
ntip->wallp = ntwall;
ntip->actor = nullptr;
@ -2170,15 +2162,15 @@ void NearTagList(NEAR_TAG_INFOp ntip, PLAYERp pp, int z, int dist, int type, int
ntwall->lotag = save_lotag;
ntwall->hitag = save_hitag;
}
else if (neartagsprite >= 0)
else if (near.actor() != nullptr)
{
auto actor = &swActors[neartagsprite];
auto actor = near.actor();
auto sp = &actor->s();
// save off values
save_lotag = sp->lotag;
save_hitag = sp->hitag;
ntip->dist = neartaghitdist;
ntip->dist = near.hitpos.x;
ntip->sectp = nullptr;
ntip->wallp = nullptr;
ntip->actor = actor;

View file

@ -3210,8 +3210,7 @@ bool ActorTrackDecide(TRACK_POINTp tpoint, DSWActor* actor)
case TRACK_ACTOR_OPERATE:
case TRACK_ACTOR_QUICK_OPERATE:
{
short nearsector, nearwall, nearsprite;
int nearhitdist;
HitInfo near;
int z[2];
int i;
@ -3225,13 +3224,11 @@ bool ActorTrackDecide(TRACK_POINTp tpoint, DSWActor* actor)
for (i = 0; i < (int)SIZ(z); i++)
{
neartag(sp->x, sp->y, z[i], sp->sectnum, sp->ang,
&nearsector, &nearwall, &nearsprite,
&nearhitdist, 1024, NTAG_SEARCH_LO_HI);
neartag({ sp->x, sp->y, z[i] }, sp->sector(), sp->ang, near, 1024, NTAG_SEARCH_LO_HI);
if (nearsprite >= 0 && nearhitdist < 1024)
if (near.actor() != nullptr && near.hitpos.x < 1024)
{
if (OperateSprite(&swActors[nearsprite], false))
if (OperateSprite(near.actor(), false))
{
if (!tpoint->tag_high)
u->WaitTics = 2 * 120;
@ -3243,9 +3240,9 @@ bool ActorTrackDecide(TRACK_POINTp tpoint, DSWActor* actor)
}
}
if (nearsector >= 0 && nearhitdist < 1024)
if (near.hitSector != nullptr && near.hitpos.x < 1024)
{
if (OperateSector(&sector[nearsector], false))
if (OperateSector(near.hitSector, false))
{
if (!tpoint->tag_high)
u->WaitTics = 2 * 120;
@ -3416,10 +3413,9 @@ bool ActorTrackDecide(TRACK_POINTp tpoint, DSWActor* actor)
if (u->ActorActionSet->Jump)
{
short hit_sect, hit_wall, hit_sprite;
int bos_z,nx,ny;
int dist;
SPRITEp lsp;
HitInfo near;
//
// Get angle and x,y pos from CLIMB_MARKER
@ -3447,17 +3443,14 @@ bool ActorTrackDecide(TRACK_POINTp tpoint, DSWActor* actor)
// Get the z height to climb
//
neartag(sp->x, sp->y, SPRITEp_TOS(sp) - DIV2(SPRITEp_SIZE_Z(sp)), sp->sectnum,
sp->ang,
&hit_sect, &hit_wall, &hit_sprite,
&dist, 600L, NTAG_SEARCH_LO_HI);
neartag({ sp->x, sp->y, SPRITEp_TOS(sp) - DIV2(SPRITEp_SIZE_Z(sp)) }, sp->sector(), sp->ang, near, 600, NTAG_SEARCH_LO_HI);
if (hit_wall < 0)
if (near.hitWall == nullptr)
{
ActorLeaveTrack(actor);
return false;
}
auto wal = &wall[hit_wall];
auto wal = near.hitWall;
#if DEBUG
if (!wal->twoSided())