mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-29 13:00:43 +00:00
- aim and all calling instances.
This also takes care of RR's chicken arrow storing an actor reference in lotag.
This commit is contained in:
parent
8268c1b538
commit
768487584e
7 changed files with 123 additions and 119 deletions
|
@ -1116,11 +1116,12 @@ static void chickenarrow(DDukeActor* actor)
|
|||
spawn(actor, MONEY);
|
||||
}
|
||||
}
|
||||
auto ts = &hittype[s->lotag]; // Grrrr...
|
||||
auto ts = actor->seek_actor;
|
||||
if (!ts) return;
|
||||
|
||||
if (ts->s.extra <= 0)
|
||||
s->lotag = 0;
|
||||
if (s->lotag != 0 && s->hitag > 5)
|
||||
actor->seek_actor = nullptr;
|
||||
if (actor->seek_actor && s->hitag > 5)
|
||||
{
|
||||
int ang, ang2, ang3;
|
||||
ang = getangle(ts->s.x - s->x, ts->s.y - s->y);
|
||||
|
|
|
@ -128,7 +128,7 @@ void playerAimUp(int snum, ESyncBits actions);
|
|||
void playerAimDown(int snum, ESyncBits actions);
|
||||
bool view(struct player_struct* pp, int* vx, int* vy, int* vz, short* vsectnum, int ang, fixed_t q16horiz, double smoothratio);
|
||||
void tracers(int x1, int y1, int z1, int x2, int y2, int z2, int n);
|
||||
int aim(spritetype* s, int aang);
|
||||
DDukeActor* aim(DDukeActor* s, int aang);
|
||||
void checkweapons(struct player_struct* const p);
|
||||
int findotherplayer(int p, int* d);
|
||||
void quickkill(struct player_struct* p);
|
||||
|
|
|
@ -281,13 +281,14 @@ int hitawall(struct player_struct* p, int* hitw)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
int aim(spritetype* s, int aang)
|
||||
DDukeActor* aim(DDukeActor* actor, int aang)
|
||||
{
|
||||
char gotshrinker, gotfreezer;
|
||||
int i, j, a, k, cans;
|
||||
int a, k, cans;
|
||||
int aimstats[] = { STAT_PLAYER, STAT_DUMMYPLAYER, STAT_ACTOR, STAT_ZOMBIEACTOR };
|
||||
int dx1, dy1, dx2, dy2, dx3, dy3, smax, sdist;
|
||||
int xv, yv;
|
||||
auto s = &actor->s;
|
||||
|
||||
a = s->ang;
|
||||
|
||||
|
@ -298,7 +299,7 @@ int aim(spritetype* s, int aang)
|
|||
{
|
||||
// The chickens in RRRA are homing and must always autoaim.
|
||||
if (!isRRRA() || ps[s->yvel].curr_weapon != CHICKEN_WEAPON)
|
||||
return -1;
|
||||
return nullptr;
|
||||
}
|
||||
else if (ps[s->yvel].auto_aim == 2)
|
||||
{
|
||||
|
@ -313,12 +314,12 @@ int aim(spritetype* s, int aang)
|
|||
}
|
||||
if (weap > CHAINGUN_WEAPON || weap == KNEE_WEAPON)
|
||||
{
|
||||
return -1;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
j = -1;
|
||||
DDukeActor* aimed = nullptr;
|
||||
// if(s->picnum == TILE_APLAYER && ps[s->yvel].aim_mode) return -1;
|
||||
|
||||
if (isRR())
|
||||
|
@ -349,13 +350,12 @@ int aim(spritetype* s, int aang)
|
|||
|
||||
for (k = 0; k < 4; k++)
|
||||
{
|
||||
if (j >= 0)
|
||||
if (aimed)
|
||||
break;
|
||||
|
||||
DukeStatIterator it(aimstats[k]);
|
||||
while (auto act = it.Next())
|
||||
{
|
||||
i = act->GetIndex();
|
||||
auto sp = &act->s;
|
||||
if (sp->xrepeat > 0 && sp->extra >= 0 && (sp->cstat & (257 + 32768)) == 257)
|
||||
if (badguy(sp) || k < 2)
|
||||
|
@ -391,7 +391,7 @@ int aim(spritetype* s, int aang)
|
|||
if (a && cans)
|
||||
{
|
||||
smax = sdist;
|
||||
j = int(act-hittype);
|
||||
aimed = act;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -399,7 +399,7 @@ int aim(spritetype* s, int aang)
|
|||
}
|
||||
}
|
||||
|
||||
return j;
|
||||
return aimed;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
|
|
@ -319,7 +319,7 @@ static void shootweapon(int i, int p, int sx, int sy, int sz, int sa, int atwith
|
|||
auto s = &actor->s;
|
||||
int sect = s->sectnum;
|
||||
int zvel;
|
||||
short hitsect, hitspr, hitwall, l, j, k = -1;
|
||||
short hitsect, hitspr, hitwall, l, k;
|
||||
int hitx, hity, hitz;
|
||||
|
||||
if (s->extra >= 0) s->shade = -96;
|
||||
|
@ -329,16 +329,16 @@ static void shootweapon(int i, int p, int sx, int sy, int sz, int sa, int atwith
|
|||
SetGameVarID(g_iAimAngleVarID, AUTO_AIM_ANGLE, actor, p);
|
||||
OnEvent(EVENT_GETAUTOAIMANGLE, p, ps[p].GetActor(), -1);
|
||||
int varval = GetGameVarID(g_iAimAngleVarID, actor, p);
|
||||
j = -1;
|
||||
DDukeActor* aimed = nullptr;
|
||||
if (varval > 0)
|
||||
{
|
||||
j = aim(s, varval);
|
||||
aimed = aim(actor, varval);
|
||||
}
|
||||
|
||||
if (j >= 0)
|
||||
if (aimed)
|
||||
{
|
||||
int dal = ((sprite[j].xrepeat * tilesiz[sprite[j].picnum].y) << 1) + (5 << 8);
|
||||
switch (sprite[j].picnum)
|
||||
int dal = ((aimed->s.xrepeat * tilesiz[aimed->s.picnum].y) << 1) + (5 << 8);
|
||||
switch (aimed->s.picnum)
|
||||
{
|
||||
case GREENSLIME:
|
||||
case GREENSLIME + 1:
|
||||
|
@ -352,8 +352,8 @@ static void shootweapon(int i, int p, int sx, int sy, int sz, int sa, int atwith
|
|||
dal -= (8 << 8);
|
||||
break;
|
||||
}
|
||||
zvel = ((sprite[j].z - sz - dal) << 8) / ldist(&sprite[ps[p].i], &sprite[j]);
|
||||
sa = getangle(sprite[j].x - sx, sprite[j].y - sy);
|
||||
zvel = ((aimed->s.z - sz - dal) << 8) / ldist(ps[p].GetActor(), aimed);
|
||||
sa = getangle(aimed->s.x - sx, aimed->s.y - sy);
|
||||
}
|
||||
|
||||
if (isWW2GI())
|
||||
|
@ -367,14 +367,14 @@ static void shootweapon(int i, int p, int sx, int sy, int sz, int sa, int atwith
|
|||
zRange = GetGameVarID(g_iZRangeVarID, actor, p);
|
||||
|
||||
sa += (angRange / 2) - (krand() & (angRange - 1));
|
||||
if (j == -1)
|
||||
if (aimed == nullptr)
|
||||
{
|
||||
// no target
|
||||
zvel = -ps[p].horizon.sum().asq16() >> 11;
|
||||
}
|
||||
zvel += (zRange / 2) - (krand() & (zRange - 1));
|
||||
}
|
||||
else if (j == -1)
|
||||
else if (aimed == nullptr)
|
||||
{
|
||||
sa += 16 - (krand() & 31);
|
||||
zvel = -ps[p].horizon.sum().asq16() >> 11;
|
||||
|
@ -386,7 +386,7 @@ static void shootweapon(int i, int p, int sx, int sy, int sz, int sa, int atwith
|
|||
else
|
||||
{
|
||||
int x;
|
||||
j = findplayer(s, &x);
|
||||
int j = findplayer(actor, &x);
|
||||
sz -= (4 << 8);
|
||||
zvel = ((ps[j].posz - sz) << 8) / (ldist(&sprite[ps[j].i], s));
|
||||
if (s->picnum != BOSS1)
|
||||
|
@ -559,10 +559,11 @@ static void shootweapon(int i, int p, int sx, int sy, int sz, int sa, int atwith
|
|||
|
||||
static void shootstuff(int i, int p, int sx, int sy, int sz, int sa, int atwith)
|
||||
{
|
||||
spritetype* const s = &sprite[i];
|
||||
auto actor = &hittype[i];
|
||||
spritetype* const s = &actor->s;
|
||||
int sect = s->sectnum;
|
||||
int vel, zvel;
|
||||
short l, j, scount;
|
||||
short l, scount;
|
||||
|
||||
if (s->extra >= 0) s->shade = -96;
|
||||
|
||||
|
@ -585,13 +586,13 @@ static void shootstuff(int i, int p, int sx, int sy, int sz, int sa, int atwith)
|
|||
|
||||
if (p >= 0)
|
||||
{
|
||||
j = aim(s, AUTO_AIM_ANGLE);
|
||||
auto aimed = aim(actor, AUTO_AIM_ANGLE);
|
||||
|
||||
if (j >= 0)
|
||||
if (aimed)
|
||||
{
|
||||
int dal = ((sprite[j].xrepeat * tilesiz[sprite[j].picnum].y) << 1) - (12 << 8);
|
||||
zvel = ((sprite[j].z - sz - dal) * vel) / ldist(&sprite[ps[p].i], &sprite[j]);
|
||||
sa = getangle(sprite[j].x - sx, sprite[j].y - sy);
|
||||
int dal = ((aimed->s.xrepeat * tilesiz[aimed->s.picnum].y) << 1) - (12 << 8);
|
||||
zvel = ((aimed->s.z - sz - dal) * vel) / ldist(ps[p].GetActor(), aimed);
|
||||
sa = getangle(aimed->s.x - sx, aimed->s.y - sy);
|
||||
}
|
||||
else
|
||||
zvel = -mulscale16(ps[p].horizon.sum().asq16(), 98);
|
||||
|
@ -599,7 +600,7 @@ static void shootstuff(int i, int p, int sx, int sy, int sz, int sa, int atwith)
|
|||
else
|
||||
{
|
||||
int x;
|
||||
j = findplayer(s, &x);
|
||||
int j = findplayer(actor, &x);
|
||||
// sa = getangle(ps[j].oposx-sx,ps[j].oposy-sy);
|
||||
sa += 16 - (krand() & 31);
|
||||
zvel = (((ps[j].oposz - sz + (3 << 8))) * vel) / ldist(&sprite[ps[j].i], s);
|
||||
|
@ -636,7 +637,7 @@ static void shootstuff(int i, int p, int sx, int sy, int sz, int sa, int atwith)
|
|||
|
||||
while (scount > 0)
|
||||
{
|
||||
j = EGS(sect, sx, sy, sz, atwith, -127, sizx, sizy, sa, vel, zvel, i, 4);
|
||||
int j = EGS(sect, sx, sy, sz, atwith, -127, sizx, sizy, sa, vel, zvel, i, 4);
|
||||
sprite[j].extra += (krand() & 7);
|
||||
|
||||
if (atwith == COOLEXPLOSION1)
|
||||
|
@ -670,27 +671,28 @@ static void shootstuff(int i, int p, int sx, int sy, int sz, int sa, int atwith)
|
|||
|
||||
static void shootrpg(int i, int p, int sx, int sy, int sz, int sa, int atwith)
|
||||
{
|
||||
spritetype* const s = &sprite[i];
|
||||
auto actor = &hittype[i];
|
||||
auto s = &actor->s;
|
||||
int sect = s->sectnum;
|
||||
int vel, zvel;
|
||||
short l, j, scount;
|
||||
short l, scount;
|
||||
|
||||
if (s->extra >= 0) s->shade = -96;
|
||||
|
||||
scount = 1;
|
||||
vel = 644;
|
||||
|
||||
j = -1;
|
||||
DDukeActor* aimed = nullptr;
|
||||
|
||||
if (p >= 0)
|
||||
{
|
||||
j = aim(s, 48);
|
||||
if (j >= 0)
|
||||
aimed = aim(actor, 48);
|
||||
if (aimed)
|
||||
{
|
||||
int dal = ((sprite[j].xrepeat * tilesiz[sprite[j].picnum].y) << 1) + (8 << 8);
|
||||
zvel = ((sprite[j].z - sz - dal) * vel) / ldist(&sprite[ps[p].i], &sprite[j]);
|
||||
if (sprite[j].picnum != RECON)
|
||||
sa = getangle(sprite[j].x - sx, sprite[j].y - sy);
|
||||
int dal = ((aimed->s.xrepeat * tilesiz[aimed->s.picnum].y) << 1) + (8 << 8);
|
||||
zvel = ((aimed->s.z - sz - dal) * vel) / ldist(ps[p].GetActor(), aimed);
|
||||
if (aimed->s.picnum != RECON)
|
||||
sa = getangle(aimed->s.x - sx, aimed->s.y - sy);
|
||||
}
|
||||
else zvel = -mulscale16(ps[p].horizon.sum().asq16(), 81);
|
||||
if (atwith == RPG)
|
||||
|
@ -700,7 +702,7 @@ static void shootrpg(int i, int p, int sx, int sy, int sz, int sa, int atwith)
|
|||
else
|
||||
{
|
||||
int x;
|
||||
j = findplayer(s, &x);
|
||||
int j = findplayer(actor, &x);
|
||||
sa = getangle(ps[j].oposx - sx, ps[j].oposy - sy);
|
||||
if (s->picnum == BOSS3)
|
||||
{
|
||||
|
@ -724,10 +726,7 @@ static void shootrpg(int i, int p, int sx, int sy, int sz, int sa, int atwith)
|
|||
if (badguy(s) && (s->hitag & face_player_smart))
|
||||
sa = s->ang + (krand() & 31) - 16;
|
||||
}
|
||||
|
||||
if (p >= 0 && j >= 0)
|
||||
l = j;
|
||||
else l = -1;
|
||||
if (p < 0) aimed = nullptr;
|
||||
|
||||
auto spawned = EGS(sect,
|
||||
sx + (sintable[(348 + sa + 512) & 2047] / 448),
|
||||
|
@ -737,7 +736,7 @@ static void shootrpg(int i, int p, int sx, int sy, int sz, int sa, int atwith)
|
|||
auto spj = &spawned->s;
|
||||
spj->extra += (krand() & 7);
|
||||
if (atwith != FREEZEBLAST)
|
||||
spawned->temp_actor = l >= 0? &hittype[l] : nullptr;// spawned->s.yvel = l;
|
||||
spawned->temp_actor = aimed;
|
||||
else
|
||||
{
|
||||
spj->yvel = numfreezebounces;
|
||||
|
@ -911,19 +910,20 @@ static void shootlaser(int i, int p, int sx, int sy, int sz, int sa)
|
|||
|
||||
static void shootgrowspark(int i, int p, int sx, int sy, int sz, int sa)
|
||||
{
|
||||
spritetype* const s = &sprite[i];
|
||||
auto actor = &hittype[i];
|
||||
auto s = &actor->s;
|
||||
int sect = s->sectnum;
|
||||
int zvel;
|
||||
short hitsect, hitspr, hitwall, j, k;
|
||||
short hitsect, hitspr, hitwall, k;
|
||||
int hitx, hity, hitz;
|
||||
|
||||
if (p >= 0)
|
||||
{
|
||||
j = aim(s, AUTO_AIM_ANGLE);
|
||||
if (j >= 0)
|
||||
auto aimed = aim(actor, AUTO_AIM_ANGLE);
|
||||
if (aimed)
|
||||
{
|
||||
int dal = ((sprite[j].xrepeat * tilesiz[sprite[j].picnum].y) << 1) + (5 << 8);
|
||||
switch (sprite[j].picnum)
|
||||
int dal = ((aimed->s.xrepeat * tilesiz[aimed->s.picnum].y) << 1) + (5 << 8);
|
||||
switch (aimed->s.picnum)
|
||||
{
|
||||
case GREENSLIME:
|
||||
case GREENSLIME + 1:
|
||||
|
@ -937,8 +937,8 @@ static void shootgrowspark(int i, int p, int sx, int sy, int sz, int sa)
|
|||
dal -= (8 << 8);
|
||||
break;
|
||||
}
|
||||
zvel = ((sprite[j].z - sz - dal) << 8) / (ldist(&sprite[ps[p].i], &sprite[j]));
|
||||
sa = getangle(sprite[j].x - sx, sprite[j].y - sy);
|
||||
zvel = ((aimed->s.z - sz - dal) << 8) / (ldist(ps[p].GetActor(), aimed));
|
||||
sa = getangle(aimed->s.x - sx, aimed->s.y - sy);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -952,7 +952,7 @@ static void shootgrowspark(int i, int p, int sx, int sy, int sz, int sa)
|
|||
else
|
||||
{
|
||||
int x;
|
||||
j = findplayer(s, &x);
|
||||
int j = findplayer(s, &x);
|
||||
sz -= (4 << 8);
|
||||
zvel = ((ps[j].posz - sz) << 8) / (ldist(&sprite[ps[j].i], s));
|
||||
zvel += 128 - (krand() & 255);
|
||||
|
@ -971,7 +971,7 @@ static void shootgrowspark(int i, int p, int sx, int sy, int sz, int sa)
|
|||
|
||||
s->cstat |= 257;
|
||||
|
||||
j = EGS(sect, hitx, hity, hitz, GROWSPARK, -16, 28, 28, sa, 0, 0, i, 1);
|
||||
int j = EGS(sect, hitx, hity, hitz, GROWSPARK, -16, 28, 28, sa, 0, 0, i, 1);
|
||||
|
||||
sprite[j].pal = 2;
|
||||
sprite[j].cstat |= 130;
|
||||
|
@ -1141,19 +1141,19 @@ void shoot_d(int i, int atwith)
|
|||
if (s->extra >= 0) s->shade = -96;
|
||||
if (p >= 0)
|
||||
{
|
||||
j = isNamWW2GI()? -1 : aim(s, AUTO_AIM_ANGLE);
|
||||
if (j >= 0)
|
||||
auto aimed = isNamWW2GI()? nullptr : aim(actor, AUTO_AIM_ANGLE);
|
||||
if (aimed)
|
||||
{
|
||||
dal = ((sprite[j].xrepeat * tilesiz[sprite[j].picnum].y) << 1);
|
||||
zvel = ((sprite[j].z - sz - dal - (4 << 8)) * 768) / (ldist(&sprite[ps[p].i], &sprite[j]));
|
||||
sa = getangle(sprite[j].x - sx, sprite[j].y - sy);
|
||||
dal = ((aimed->s.xrepeat * tilesiz[aimed->s.picnum].y) << 1);
|
||||
zvel = ((aimed->s.z - sz - dal - (4 << 8)) * 768) / (ldist(ps[p].GetActor(), aimed));
|
||||
sa = getangle(aimed->s.x - sx, aimed->s.y - sy);
|
||||
}
|
||||
else zvel = -mulscale16(ps[p].horizon.sum().asq16(), 98);
|
||||
}
|
||||
else if (s->statnum != 3)
|
||||
{
|
||||
j = findplayer(s, &x);
|
||||
l = ldist(&sprite[ps[j].i], s);
|
||||
j = findplayer(actor, &x);
|
||||
l = ldist(ps[j].GetActor(), actor);
|
||||
zvel = ((ps[j].oposz - sz) * 512) / l;
|
||||
}
|
||||
else zvel = 0;
|
||||
|
|
|
@ -213,27 +213,28 @@ static void shootmelee(int i, int p, int sx, int sy, int sz, int sa, int atwith)
|
|||
|
||||
static void shootweapon(int i, int p, int sx, int sy, int sz, int sa, int atwith)
|
||||
{
|
||||
spritetype* const s = &sprite[i];
|
||||
auto actor = &hittype[i];
|
||||
auto s = &actor->s;
|
||||
int sect = s->sectnum;
|
||||
int zvel;
|
||||
short hitsect, hitspr, hitwall, l, j, k;
|
||||
short hitsect, hitspr, hitwall, l, k;
|
||||
int hitx, hity, hitz;
|
||||
|
||||
if (s->extra >= 0) s->shade = -96;
|
||||
|
||||
if (p >= 0)
|
||||
{
|
||||
j = aim(s, AUTO_AIM_ANGLE);
|
||||
if (j >= 0)
|
||||
auto aimed = aim(actor, AUTO_AIM_ANGLE);
|
||||
if (aimed)
|
||||
{
|
||||
int dal = ((sprite[j].xrepeat * tilesiz[sprite[j].picnum].y) << 1) + (5 << 8);
|
||||
zvel = ((sprite[j].z - sz - dal) << 8) / ldist(&sprite[ps[p].i], &sprite[j]);
|
||||
sa = getangle(sprite[j].x - sx, sprite[j].y - sy);
|
||||
int dal = ((aimed->s.xrepeat * tilesiz[aimed->s.picnum].y) << 1) + (5 << 8);
|
||||
zvel = ((aimed->s.z - sz - dal) << 8) / ldist(ps[p].GetActor(), aimed);
|
||||
sa = getangle(aimed->s.x - sx, aimed->s.y - sy);
|
||||
}
|
||||
|
||||
if (atwith == SHOTSPARK1)
|
||||
{
|
||||
if (j == -1)
|
||||
if (aimed == nullptr)
|
||||
{
|
||||
sa += 16 - (krand() & 31);
|
||||
zvel = -ps[p].horizon.sum().asq16() >> 11;
|
||||
|
@ -246,7 +247,7 @@ static void shootweapon(int i, int p, int sx, int sy, int sz, int sa, int atwith
|
|||
sa += 64 - (krand() & 127);
|
||||
else
|
||||
sa += 16 - (krand() & 31);
|
||||
if (j == -1) zvel = -ps[p].horizon.sum().asq16() >> 11;
|
||||
if (aimed == nullptr) zvel = -ps[p].horizon.sum().asq16() >> 11;
|
||||
zvel += 128 - (krand() & 255);
|
||||
}
|
||||
sz -= (2 << 8);
|
||||
|
@ -254,9 +255,9 @@ static void shootweapon(int i, int p, int sx, int sy, int sz, int sa, int atwith
|
|||
else
|
||||
{
|
||||
int x;
|
||||
j = findplayer(s, &x);
|
||||
int j = findplayer(actor, &x);
|
||||
sz -= (4 << 8);
|
||||
zvel = ((ps[j].posz - sz) << 8) / (ldist(&sprite[ps[j].i], s));
|
||||
zvel = ((ps[j].posz - sz) << 8) / (ldist(ps[j].GetActor(), actor));
|
||||
if (s->picnum != BOSS1)
|
||||
{
|
||||
zvel += 128 - (krand() & 255);
|
||||
|
@ -467,10 +468,11 @@ static void shootweapon(int i, int p, int sx, int sy, int sz, int sa, int atwith
|
|||
|
||||
static void shootstuff(int i, int p, int sx, int sy, int sz, int sa, int atwith)
|
||||
{
|
||||
spritetype* const s = &sprite[i];
|
||||
auto actor = &hittype[i];
|
||||
auto s = &actor->s;
|
||||
int sect = s->sectnum;
|
||||
int vel, zvel;
|
||||
short j, scount;
|
||||
short scount;
|
||||
|
||||
if (isRRRA())
|
||||
{
|
||||
|
@ -510,15 +512,15 @@ static void shootstuff(int i, int p, int sx, int sy, int sz, int sa, int atwith)
|
|||
|
||||
if (p >= 0)
|
||||
{
|
||||
j = aim(s, AUTO_AIM_ANGLE);
|
||||
auto aimed = aim(actor, AUTO_AIM_ANGLE);
|
||||
|
||||
if (j >= 0)
|
||||
if (aimed)
|
||||
{
|
||||
sx += sintable[(s->ang + 512 + 160) & 2047] >> 7;
|
||||
sy += sintable[(s->ang + 160) & 2047] >> 7;
|
||||
int dal = ((sprite[j].xrepeat * tilesiz[sprite[j].picnum].y) << 1) - (12 << 8);
|
||||
zvel = ((sprite[j].z - sz - dal) * vel) / ldist(&sprite[ps[p].i], &sprite[j]);
|
||||
sa = getangle(sprite[j].x - sx, sprite[j].y - sy);
|
||||
int dal = ((aimed->s.xrepeat * tilesiz[aimed->s.picnum].y) << 1) - (12 << 8);
|
||||
zvel = ((aimed->s.z - sz - dal) * vel) / ldist(ps[p].GetActor(), aimed);
|
||||
sa = getangle(aimed->s.x - sx, aimed->s.y - sy);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -530,7 +532,7 @@ static void shootstuff(int i, int p, int sx, int sy, int sz, int sa, int atwith)
|
|||
else
|
||||
{
|
||||
int x;
|
||||
j = findplayer(s, &x);
|
||||
int j = findplayer(s, &x);
|
||||
// sa = getangle(ps[j].oposx-sx,ps[j].oposy-sy);
|
||||
if (s->picnum == HULK)
|
||||
sa -= (krand() & 31);
|
||||
|
@ -582,7 +584,7 @@ static void shootstuff(int i, int p, int sx, int sy, int sz, int sa, int atwith)
|
|||
|
||||
while (scount > 0)
|
||||
{
|
||||
j = EGS(sect, sx, sy, sz, atwith, -127, sizx, sizy, sa, vel, zvel, i, 4);
|
||||
auto j = EGS(sect, sx, sy, sz, atwith, -127, sizx, sizy, sa, vel, zvel, i, 4);
|
||||
sprite[j].extra += (krand() & 7);
|
||||
sprite[j].cstat = 128;
|
||||
sprite[j].clipdist = 4;
|
||||
|
@ -608,52 +610,53 @@ static void shootstuff(int i, int p, int sx, int sy, int sz, int sa, int atwith)
|
|||
|
||||
static void shootrpg(int i, int p, int sx, int sy, int sz, int sa, int atwith)
|
||||
{
|
||||
spritetype* const s = &sprite[i];
|
||||
auto actor = &hittype[i];
|
||||
auto s = &actor->s;
|
||||
int sect = s->sectnum;
|
||||
int vel, zvel;
|
||||
short l, j, scount;
|
||||
short l, scount;
|
||||
|
||||
short var90 = 0;
|
||||
DDukeActor* act90 = nullptr;
|
||||
if (s->extra >= 0) s->shade = -96;
|
||||
|
||||
scount = 1;
|
||||
vel = 644;
|
||||
|
||||
j = -1;
|
||||
DDukeActor* aimed = nullptr;
|
||||
|
||||
if (p >= 0)
|
||||
{
|
||||
j = aim(s, 48);
|
||||
if (j >= 0)
|
||||
aimed = aim(actor, 48);
|
||||
if (aimed)
|
||||
{
|
||||
if (isRRRA() && atwith == RPG2)
|
||||
{
|
||||
if (sprite[j].picnum == HEN || sprite[j].picnum == HENSTAYPUT)
|
||||
var90 = ps[screenpeek].i;
|
||||
if (aimed->s.picnum == HEN || aimed->s.picnum == HENSTAYPUT)
|
||||
act90 = ps[screenpeek].GetActor();
|
||||
else
|
||||
var90 = j;
|
||||
act90 = aimed;
|
||||
}
|
||||
int dal = ((sprite[j].xrepeat * tilesiz[sprite[j].picnum].y) << 1) + (8 << 8);
|
||||
zvel = ((sprite[j].z - sz - dal) * vel) / ldist(&sprite[ps[p].i], &sprite[j]);
|
||||
if (sprite[j].picnum != RECON)
|
||||
sa = getangle(sprite[j].x - sx, sprite[j].y - sy);
|
||||
int dal = ((aimed->s.xrepeat * tilesiz[aimed->s.picnum].y) << 1) + (8 << 8);
|
||||
zvel = ((aimed->s.z - sz - dal) * vel) / ldist(ps[p].GetActor(), aimed);
|
||||
if (aimed->s.picnum != RECON)
|
||||
sa = getangle(aimed->s.x - sx, aimed->s.y - sy);
|
||||
}
|
||||
else zvel = -mulscale16(ps[p].horizon.sum().asq16(), 81);
|
||||
if (atwith == RPG)
|
||||
S_PlayActorSound(RPG_SHOOT, i);
|
||||
S_PlayActorSound(RPG_SHOOT, actor);
|
||||
else if (isRRRA())
|
||||
{
|
||||
if (atwith == RPG2)
|
||||
S_PlayActorSound(244, i);
|
||||
S_PlayActorSound(244, actor);
|
||||
else if (atwith == RRTILE1790)
|
||||
S_PlayActorSound(94, i);
|
||||
S_PlayActorSound(94, actor);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
int x;
|
||||
j = findplayer(s, &x);
|
||||
int j = findplayer(s, &x);
|
||||
sa = getangle(ps[j].oposx - sx, ps[j].oposy - sy);
|
||||
if (s->picnum == BOSS3)
|
||||
sz -= (32 << 8);
|
||||
|
@ -663,16 +666,14 @@ static void shootrpg(int i, int p, int sx, int sy, int sz, int sa, int atwith)
|
|||
sz += 24 << 8;
|
||||
}
|
||||
|
||||
l = ldist(&sprite[ps[j].i], s);
|
||||
l = ldist(ps[j].GetActor(), actor);
|
||||
zvel = ((ps[j].oposz - sz) * vel) / l;
|
||||
|
||||
if (badguy(s) && (s->hitag & face_player_smart))
|
||||
sa = s->ang + (krand() & 31) - 16;
|
||||
}
|
||||
|
||||
if (p >= 0 && j >= 0)
|
||||
l = j;
|
||||
else l = -1;
|
||||
if (p < 0) aimed = nullptr;
|
||||
|
||||
if (isRRRA() && atwith == RRTILE1790)
|
||||
{
|
||||
|
@ -694,7 +695,7 @@ static void shootrpg(int i, int p, int sx, int sy, int sz, int sa, int atwith)
|
|||
}
|
||||
else if (atwith == RPG2)
|
||||
{
|
||||
spawned->s.lotag = var90;
|
||||
spawned->seek_actor = act90;
|
||||
spawned->s.hitag = 0;
|
||||
fi.lotsofmoney(spawned, (krand() & 3) + 1);
|
||||
}
|
||||
|
@ -702,7 +703,7 @@ static void shootrpg(int i, int p, int sx, int sy, int sz, int sa, int atwith)
|
|||
|
||||
spawned->s.extra += (krand() & 7);
|
||||
if (atwith != FREEZEBLAST)
|
||||
spawned->temp_actor = l >= 0? &hittype[l] : nullptr;// spawned->s.yvel = l;
|
||||
spawned->temp_actor = aimed;
|
||||
else
|
||||
{
|
||||
spawned->s.yvel = numfreezebounces;
|
||||
|
@ -762,10 +763,11 @@ static void shootrpg(int i, int p, int sx, int sy, int sz, int sa, int atwith)
|
|||
|
||||
static void shootwhip(int i, int p, int sx, int sy, int sz, int sa, int atwith)
|
||||
{
|
||||
spritetype* const s = &sprite[i];
|
||||
auto actor = &hittype[i];
|
||||
auto s = &actor->s;
|
||||
int sect = s->sectnum;
|
||||
int vel, zvel;
|
||||
short j, scount;
|
||||
short scount;
|
||||
|
||||
if (s->extra >= 0) s->shade = -96;
|
||||
|
||||
|
@ -785,13 +787,13 @@ static void shootwhip(int i, int p, int sx, int sy, int sz, int sa, int atwith)
|
|||
|
||||
if (p >= 0)
|
||||
{
|
||||
j = aim(s, AUTO_AIM_ANGLE);
|
||||
auto aimed = aim(actor, AUTO_AIM_ANGLE);
|
||||
|
||||
if (j >= 0)
|
||||
if (aimed)
|
||||
{
|
||||
int dal = ((sprite[j].xrepeat * tilesiz[sprite[j].picnum].y) << 1) - (12 << 8);
|
||||
zvel = ((sprite[j].z - sz - dal) * vel) / ldist(&sprite[ps[p].i], &sprite[j]);
|
||||
sa = getangle(sprite[j].x - sx, sprite[j].y - sy);
|
||||
int dal = ((aimed->s.xrepeat * tilesiz[aimed->s.picnum].y) << 1) - (12 << 8);
|
||||
zvel = ((aimed->s.z - sz - dal) * vel) / ldist(ps[p].GetActor(), aimed);
|
||||
sa = getangle(aimed->s.x - sx, aimed->s.y - sy);
|
||||
}
|
||||
else
|
||||
zvel = -mulscale16(ps[p].horizon.sum().asq16(), 98);
|
||||
|
@ -799,13 +801,13 @@ static void shootwhip(int i, int p, int sx, int sy, int sz, int sa, int atwith)
|
|||
else
|
||||
{
|
||||
int x;
|
||||
j = findplayer(s, &x);
|
||||
int j = findplayer(s, &x);
|
||||
// sa = getangle(ps[j].oposx-sx,ps[j].oposy-sy);
|
||||
if (s->picnum == VIXEN)
|
||||
sa -= (krand() & 16);
|
||||
else
|
||||
sa += 16 - (krand() & 31);
|
||||
zvel = (((ps[j].oposz - sz + (3 << 8))) * vel) / ldist(&sprite[ps[j].i], s);
|
||||
zvel = (((ps[j].oposz - sz + (3 << 8))) * vel) / ldist(ps[j].GetActor(), actor);
|
||||
}
|
||||
|
||||
int oldzvel = zvel;
|
||||
|
@ -817,7 +819,7 @@ static void shootwhip(int i, int p, int sx, int sy, int sz, int sa, int atwith)
|
|||
|
||||
while (scount > 0)
|
||||
{
|
||||
j = EGS(sect, sx, sy, sz, atwith, -127, sizx, sizy, sa, vel, zvel, i, 4);
|
||||
int j = EGS(sect, sx, sy, sz, atwith, -127, sizx, sizy, sa, vel, zvel, i, 4);
|
||||
sprite[j].extra += (krand() & 7);
|
||||
|
||||
sprite[j].cstat = 128;
|
||||
|
|
|
@ -336,6 +336,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, weaponhit& w, weap
|
|||
("bposz", w.bposz, def->bposz)
|
||||
("aflags", w.aflags, def->aflags)
|
||||
("temp_actor", w.temp_actor, def->temp_actor)
|
||||
("seek_actor", w.seek_actor, def->seek_actor)
|
||||
.Array("temp_data", w.temp_data, def->temp_data, 6)
|
||||
.EndObject();
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ struct weaponhit
|
|||
short timetosleep;
|
||||
int floorz, ceilingz, lastvx, lastvy, bposx, bposy, bposz, aflags;
|
||||
int temp_data[6];
|
||||
weaponhit* temp_actor;
|
||||
weaponhit* temp_actor, *seek_actor;
|
||||
spritetype& s; // direct reference to the corresponding sprite.
|
||||
|
||||
static weaponhit* array(); // this is necessary to allow define inline functions referencing the global array inside the definition itself.
|
||||
|
|
Loading…
Reference in a new issue