- G_DoThirdPerson replaced by the original 'view'.

This commit is contained in:
Christoph Oelckers 2020-07-04 22:44:33 +02:00
parent 2fba557a3d
commit 78f88e460e
3 changed files with 75 additions and 75 deletions

View file

@ -213,7 +213,7 @@ int aim(spritetype* s, int aang)
return -1;
j = -1;
// if(s->picnum == TILE_APLAYER && ps[s->yvel].aim_mode) return -1;
// if(s->picnum == TILE_APLAYER && ps[s->yvel].aim_mode) return -1;
if (isRR())
{
@ -446,9 +446,9 @@ void footprints(int snum)
{
switch (krand() & 3)
{
case 0: j = fi.spawn(pi, TILE_FOOTPRINTS); break;
case 1: j = fi.spawn(pi, TILE_FOOTPRINTS2); break;
case 2: j = fi.spawn(pi, TILE_FOOTPRINTS3); break;
case 0: j = fi.spawn(pi, TILE_FOOTPRINTS); break;
case 1: j = fi.spawn(pi, TILE_FOOTPRINTS2); break;
case 2: j = fi.spawn(pi, TILE_FOOTPRINTS3); break;
default: j = fi.spawn(pi, TILE_FOOTPRINTS4); break;
}
sprite[j].pal = p->footprintpal;
@ -525,7 +525,7 @@ void playerisdead(int snum, int psectlotag, int fz, int cz)
{
sprintf(tempbuf, "frag %d killed %d\n", p->frag_ps + 1, snum + 1);
sendscore(tempbuf);
// printf(tempbuf);
// printf(tempbuf);
}
#endif
@ -550,7 +550,7 @@ void playerisdead(int snum, int psectlotag, int fz, int cz)
clipmove(&p->posx, &p->posy,
&p->posz, &p->cursectnum,
0, 0, 164L, (4L << 8), (4L << 8), CLIPMASK0);
// p->bobcounter += 32;
// p->bobcounter += 32;
}
p->oposx = p->posx;
@ -822,4 +822,70 @@ int haskey(int sect, int snum)
return 0;
}
//---------------------------------------------------------------------------
//
// view - as in third person view (stupid name for this function)
//
//---------------------------------------------------------------------------
bool view(struct player_struct* pp, int* vx, int* vy, int* vz, short* vsectnum, int ang, int horiz)
{
spritetype* sp;
int i, nx, ny, nz, hx, hy, hz, hitx, hity, hitz;
short bakcstat, hitsect, hitwall, hitsprite, daang;
nx = (sintable[(ang + 1536) & 2047] >> 4);
ny = (sintable[(ang + 1024) & 2047] >> 4);
nz = (horiz - 100) * 128;
sp = &sprite[pp->i];
bakcstat = sp->cstat;
sp->cstat &= (short)~0x101;
updatesectorz(*vx, *vy, *vz, vsectnum);
hitscan(*vx, *vy, *vz, *vsectnum, nx, ny, nz, &hitsect, &hitwall, &hitsprite, &hitx, &hity, &hitz, CLIPMASK1);
if (*vsectnum < 0)
{
sp->cstat = bakcstat;
return false;
}
hx = hitx - (*vx); hy = hity - (*vy);
if (abs(nx) + abs(ny) > abs(hx) + abs(hy))
{
*vsectnum = hitsect;
if (hitwall >= 0)
{
daang = getangle(wall[wall[hitwall].point2].x - wall[hitwall].x,
wall[wall[hitwall].point2].y - wall[hitwall].y);
i = nx * sintable[daang] + ny * sintable[(daang + 1536) & 2047];
if (abs(nx) > abs(ny)) hx -= mulscale28(nx, i);
else hy -= mulscale28(ny, i);
}
else if (hitsprite < 0)
{
if (abs(nx) > abs(ny)) hx -= (nx >> 5);
else hy -= (ny >> 5);
}
if (abs(nx) > abs(ny)) i = divscale16(hx, nx);
else i = divscale16(hy, ny);
if (i < cameradist) cameradist = i;
}
*vx = (*vx) + mulscale16(nx, cameradist);
*vy = (*vy) + mulscale16(ny, cameradist);
*vz = (*vz) + mulscale16(nz, cameradist);
cameradist = min(cameradist + (((int)totalclock - cameraclock) << 10), 65536);
cameraclock = (int)totalclock;
updatesectorz(*vx, *vy, *vz, vsectnum);
sp->cstat = bakcstat;
return true;
}
END_DUKE_NS

View file

@ -452,6 +452,7 @@ void playerLookUp(int snum, int sb_snum);
void playerLookDown(int snum, int sb_snum);
void playerAimUp(int snum, int sb_snum);
void playerAimDown(int snum, int sb_snum);
bool view(struct player_struct* pp, int* vx, int* vy, int* vz, short* vsectnum, int ang, int horiz);
extern int lastvisinc;

View file

@ -115,73 +115,6 @@ void G_HandleSpecialKeys(void)
}
static int32_t G_DoThirdPerson(const DukePlayer_t *pp, vec3_t *vect, int16_t *vsectnum, int16_t ang, int16_t horiz)
{
spritetype *sp = &sprite[pp->i];
int32_t i, hx, hy;
int32_t bakcstat = sp->cstat;
hitdata_t hit;
vec3_t n = {
sintable[(ang+1536)&2047]>>4,
sintable[(ang+1024)&2047]>>4,
(horiz-100) * 128
};
updatesectorz(vect->x,vect->y,vect->z,vsectnum);
sp->cstat &= ~0x101;
hitscan(vect, *vsectnum, n.x,n.y,n.z, &hit, CLIPMASK1);
sp->cstat = bakcstat;
if (*vsectnum < 0)
return -1;
hx = hit.pos.x-(vect->x);
hy = hit.pos.y-(vect->y);
if (klabs(n.x)+klabs(n.y) > klabs(hx)+klabs(hy))
{
*vsectnum = hit.sect;
if (hit.wall >= 0)
{
int32_t daang = getangle(wall[wall[hit.wall].point2].x-wall[hit.wall].x,
wall[wall[hit.wall].point2].y-wall[hit.wall].y);
i = n.x*sintable[daang] + n.y*sintable[(daang+1536)&2047];
if (klabs(n.x) > klabs(n.y))
hx -= mulscale28(n.x,i);
else hy -= mulscale28(n.y,i);
}
else if (hit.sprite < 0)
{
if (klabs(n.x) > klabs(n.y))
hx -= (n.x>>5);
else hy -= (n.y>>5);
}
if (klabs(n.x) > klabs(n.y))
i = divscale16(hx,n.x);
else i = divscale16(hy,n.y);
if (i < CAMERADIST)
CAMERADIST = i;
}
vect->x += mulscale16(n.x,CAMERADIST);
vect->y += mulscale16(n.y,CAMERADIST);
vect->z += mulscale16(n.z,CAMERADIST);
CAMERADIST = min(CAMERADIST+(((int32_t) totalclock-CAMERACLOCK)<<10),65536);
CAMERACLOCK = (int32_t) totalclock;
updatesectorz(vect->x,vect->y,vect->z,vsectnum);
return 0;
}
int32_t SE150_TempSectorZ[MAXSECTORS];
int32_t SE150_TempSectorPicnum[MAXSECTORS];
@ -762,10 +695,10 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio)
{
CAMERA(pos.z) -= 3072;
if (G_DoThirdPerson(pPlayer, &CAMERA(pos), &CAMERA(sect), fix16_to_int(CAMERA(q16ang)), fix16_to_int(CAMERA(q16horiz))) < 0)
if (!view(pPlayer, &ud.camerapos.x, &ud.camerapos.y, &ud.camerapos.z, &CAMERA(sect), fix16_to_int(CAMERA(q16ang)), fix16_to_int(CAMERA(q16horiz))))
{
CAMERA(pos.z) += 3072;
G_DoThirdPerson(pPlayer, &CAMERA(pos), &CAMERA(sect), fix16_to_int(CAMERA(q16ang)), fix16_to_int(CAMERA(q16horiz)));
view(pPlayer, &ud.camerapos.x, &ud.camerapos.y, &ud.camerapos.z, &CAMERA(sect), fix16_to_int(CAMERA(q16ang)), fix16_to_int(CAMERA(q16horiz)));
}
}
}