- dodge, furthestcanseepoint, furthestangle.

This commit is contained in:
Christoph Oelckers 2020-10-22 01:12:16 +02:00
parent 4e675ea322
commit 31e5023004
7 changed files with 25 additions and 24 deletions

View file

@ -5082,20 +5082,20 @@ void makeitfall(DDukeActor* actor)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
int dodge(spritetype* s) int dodge(DDukeActor* actor)
{ {
int i; auto s = &actor->s;
int bx, by, mx, my, bxvect, byvect, mxvect, myvect, d; int bx, by, mx, my, bxvect, byvect, mxvect, myvect, d;
mx = s->x; mx = s->x;
my = s->y; my = s->y;
mxvect = sintable[(s->ang + 512) & 2047]; myvect = sintable[s->ang & 2047]; mxvect = sintable[(s->ang + 512) & 2047]; myvect = sintable[s->ang & 2047];
StatIterator it(STAT_PROJECTILE); DukeStatIterator it(STAT_PROJECTILE);
while ((i = it.NextIndex()) >= 0) while (auto ac = it.Next())
{ {
auto si = &sprite[i]; auto si = &ac->s;
if (si->owner == i || si->sectnum != s->sectnum) if (ac->GetOwner() == ac || si->sectnum != s->sectnum)
continue; continue;
bx = si->x - mx; bx = si->x - mx;
@ -5122,17 +5122,17 @@ int dodge(spritetype* s)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
int furthestangle(int i, int angs) int furthestangle(DDukeActor *actor, int angs)
{ {
auto s = &actor->s;
short j, hitsect, hitwall, hitspr, furthest_angle, angincs; short j, hitsect, hitwall, hitspr, furthest_angle, angincs;
int hx, hy, hz, d, greatestd; int hx, hy, hz, d, greatestd;
spritetype* s = &sprite[i];
greatestd = -(1 << 30); greatestd = -(1 << 30);
angincs = 2048 / angs; angincs = 2048 / angs;
if (s->picnum != TILE_APLAYER) if (s->picnum != TILE_APLAYER)
if ((hittype[i].temp_data[0] & 63) > 2) return(s->ang + 1024); if ((actor->temp_data[0] & 63) > 2) return(s->ang + 1024);
for (j = s->ang; j < (2048 + s->ang); j += angincs) for (j = s->ang; j < (2048 + s->ang); j += angincs)
{ {
@ -5158,18 +5158,19 @@ int furthestangle(int i, int angs)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
int furthestcanseepoint(int i, spritetype* ts, int* dax, int* day) int furthestcanseepoint(DDukeActor *actor, DDukeActor* tosee, int* dax, int* day)
{ {
auto s = &actor->s;
short j, hitsect, hitwall, hitspr, angincs; short j, hitsect, hitwall, hitspr, angincs;
int hx, hy, hz, d, da;//, d, cd, ca,tempx,tempy,cx,cy; int hx, hy, hz, d, da;//, d, cd, ca,tempx,tempy,cx,cy;
spritetype* s = &sprite[i];
if ((hittype[i].temp_data[0] & 63)) return -1; if ((actor->temp_data[0] & 63)) return -1;
if (ud.multimode < 2 && ud.player_skill < 3) if (ud.multimode < 2 && ud.player_skill < 3)
angincs = 2048 / 2; angincs = 2048 / 2;
else angincs = 2048 / (1 + (krand() & 1)); else angincs = 2048 / (1 + (krand() & 1));
auto ts = &tosee->s;
for (j = ts->ang; j < (2048 + ts->ang); j += (angincs - (krand() & 511))) for (j = ts->ang; j < (2048 + ts->ang); j += (angincs - (krand() & 511)))
{ {
hitscan(ts->x, ts->y, ts->z - (16 << 8), ts->sectnum, hitscan(ts->x, ts->y, ts->z - (16 << 8), ts->sectnum,
@ -5258,14 +5259,14 @@ void alterang(int a, int g_i, int g_p)
j = 2; j = 2;
if (a & furthestdir) if (a & furthestdir)
{ {
goalang = furthestangle(g_i, j); goalang = furthestangle(&hittype[g_i], j);
g_sp->ang = goalang; g_sp->ang = goalang;
g_sp->owner = ps[g_p].i; g_sp->owner = ps[g_p].i;
} }
if (a & fleeenemy) if (a & fleeenemy)
{ {
goalang = furthestangle(g_i, j); goalang = furthestangle(&hittype[g_i], j);
g_sp->ang = goalang; // += angdif; // = getincangle(aang,goalang)>>1; g_sp->ang = goalang; // += angdif; // = getincangle(aang,goalang)>>1;
} }
} }

View file

@ -3915,7 +3915,7 @@ void move_d(int g_i, int g_p, int g_x)
if (a & getv) g_sp->zvel += ((*(moveptr + 1) << 4) - g_sp->zvel) >> 1; if (a & getv) g_sp->zvel += ((*(moveptr + 1) << 4) - g_sp->zvel) >> 1;
if (a & dodgebullet) if (a & dodgebullet)
dodge(g_sp); dodge(&hittype[g_i]);
if (g_sp->picnum != APLAYER) if (g_sp->picnum != APLAYER)
alterang(a, g_i, g_p); alterang(a, g_i, g_p);

View file

@ -3905,7 +3905,7 @@ void move_r(int g_i, int g_p, int g_x)
if (a & getv) g_sp->zvel += ((*(moveptr + 1) << 4) - g_sp->zvel) >> 1; if (a & getv) g_sp->zvel += ((*(moveptr + 1) << 4) - g_sp->zvel) >> 1;
if (a & dodgebullet) if (a & dodgebullet)
dodge(g_sp); dodge(&hittype[g_i]);
if (g_sp->picnum != APLAYER) if (g_sp->picnum != APLAYER)
alterang(a, g_i, g_p); alterang(a, g_i, g_p);

View file

@ -96,7 +96,7 @@ void handle_se130(DDukeActor* i, int countmax, int EXPLOSION2);
void respawn_rrra(DDukeActor* oldact, DDukeActor* newact); void respawn_rrra(DDukeActor* oldact, DDukeActor* newact);
int dodge(spritetype*); int dodge(DDukeActor*);
void alterang(int a, int g_i, int g_p); void alterang(int a, int g_i, int g_p);
void fall_common(int g_i, int g_p, int JIBS6, int DRONE, int BLOODPOOL, int SHOTSPARK1, int squished, int thud, int(*fallspecial)(int, int), void (*falladjustz)(spritetype*)); void fall_common(int g_i, int g_p, int JIBS6, int DRONE, int BLOODPOOL, int SHOTSPARK1, int squished, int thud, int(*fallspecial)(int, int), void (*falladjustz)(spritetype*));
void checkavailweapon(struct player_struct* p); void checkavailweapon(struct player_struct* p);
@ -171,7 +171,7 @@ void doorders(const CompletionFunc& func);
void LoadActor(int i, int p, int x); void LoadActor(int i, int p, int x);
void execute(int s, int p, int d); void execute(int s, int p, int d);
void makeitfall(DDukeActor* s); void makeitfall(DDukeActor* s);
int furthestangle(int snum, int angDiv); int furthestangle(DDukeActor* snum, int angDiv);
void getglobalz(DDukeActor* s); void getglobalz(DDukeActor* s);
void OnEvent(int id, int pnum = -1, int snum = -1, int dist = -1); void OnEvent(int id, int pnum = -1, int snum = -1, int dist = -1);

View file

@ -80,7 +80,7 @@ struct ParseState
void parseifelse(int condition); void parseifelse(int condition);
}; };
int furthestcanseepoint(int i, spritetype* ts, int* dax, int* day); int furthestcanseepoint(DDukeActor* i, DDukeActor* ts, int* dax, int* day);
bool ifsquished(int i, int p); bool ifsquished(int i, int p);
void fakebubbaspawn(int g_i, int g_p); void fakebubbaspawn(int g_i, int g_p);
void tearitup(int sect); void tearitup(int sect);
@ -1493,7 +1493,7 @@ static bool ifcansee(int g_i, int g_p)
// also modifies 'target' x&y if found.. // also modifies 'target' x&y if found..
j = furthestcanseepoint(g_i, s, &hittype[g_i].lastvx, &hittype[g_i].lastvy); j = furthestcanseepoint(&hittype[g_i], ps[g_p].GetActor(), &hittype[g_i].lastvx, &hittype[g_i].lastvy);
if (j == -1) j = 0; if (j == -1) j = 0;
else j = 1; else j = 1;
@ -2542,7 +2542,7 @@ int ParseState::parse(void)
break; break;
case concmd_ifbulletnear: case concmd_ifbulletnear:
parseifelse( dodge(g_sp) == 1); parseifelse( dodge(g_ac) == 1);
break; break;
case concmd_ifrespawn: case concmd_ifrespawn:
if( badguy(g_sp) ) if( badguy(g_sp) )

View file

@ -3079,7 +3079,7 @@ HORIZONLY:
changespritesect(pi, p->cursectnum); changespritesect(pi, p->cursectnum);
if (ud.clipping == 0) if (ud.clipping == 0)
j = (pushmove(&p->posx, &p->posy, &p->posz, &p->cursectnum, 164L, (4L << 8), (4L << 8), CLIPMASK0) < 0 && furthestangle(pi, 8) < 512); j = (pushmove(&p->posx, &p->posy, &p->posz, &p->cursectnum, 164L, (4L << 8), (4L << 8), CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < 512);
else j = 0; else j = 0;
if (ud.clipping == 0) if (ud.clipping == 0)

View file

@ -4060,9 +4060,9 @@ HORIZONLY:
if (ud.clipping == 0) if (ud.clipping == 0)
{ {
if (s->clipdist == 64) if (s->clipdist == 64)
j = (pushmove(&p->posx, &p->posy, &p->posz, &p->cursectnum, 128L, (4L << 8), (4L << 8), CLIPMASK0) < 0 && furthestangle(pi, 8) < 512); j = (pushmove(&p->posx, &p->posy, &p->posz, &p->cursectnum, 128L, (4L << 8), (4L << 8), CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < 512);
else else
j = (pushmove(&p->posx, &p->posy, &p->posz, &p->cursectnum, 16L, (4L << 8), (4L << 8), CLIPMASK0) < 0 && furthestangle(pi, 8) < 512); j = (pushmove(&p->posx, &p->posy, &p->posz, &p->cursectnum, 16L, (4L << 8), (4L << 8), CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < 512);
} }
else j = 0; else j = 0;