- use access functions to change horizon.

This commit is contained in:
Christoph Oelckers 2020-05-18 18:41:48 +02:00
parent 2085167703
commit 1c29a44d3e
4 changed files with 27 additions and 24 deletions

View file

@ -81,7 +81,7 @@ void forceplayerangle(struct player_struct* p)
n = 128 - (krand() & 255);
p->q16horiz += 64 << FRACBITS;
p->addhoriz(64);
p->return_to_center = 9;
p->look_ang = n >> 1;
p->rotscrnang = n >> 1;
@ -555,7 +555,7 @@ void playerisdead(int snum, int psectlotag, int fz, int cz)
p->oq16ang = p->q16ang;
p->opyoff = p->pyoff;
p->q16horiz = 100 << FRACBITS;
p->sethoriz(100);
p->q16horizoff = 0;
updatesector(p->posx, p->posy, &p->cursectnum);
@ -743,8 +743,8 @@ void playerLookUp(int snum, int sb_snum)
if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0)
{
p->return_to_center = 9;
if (sb_snum & SKB_RUN) p->q16horiz += 12 << FRACBITS; // running
p->q16horiz += 12 << FRACBITS;
if (sb_snum & SKB_RUN) p->addhoriz(12); // running
p->addhoriz(12);
}
}
@ -756,8 +756,8 @@ void playerLookDown(int snum, int sb_snum)
if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0)
{
p->return_to_center = 9;
if (sb_snum & SKB_RUN) p->q16horiz -= 12 << FRACBITS; // running
p->q16horiz -= 12 << FRACBITS;
if (sb_snum & SKB_RUN) p->addhoriz(-12);
p->addhoriz(-12); // running
}
}
@ -768,8 +768,8 @@ void playerAimUp(int snum, int sb_snum)
OnEvent(EVENT_AIMUP, p->i, snum, -1);
if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0)
{
if (sb_snum & SKB_RUN) p->q16horiz += 6 << FRACBITS; // running
p->q16horiz += 6 << FRACBITS;
if (sb_snum & SKB_RUN) p->addhoriz(6); // running
p->addhoriz(6); // running
}
}
@ -780,8 +780,8 @@ void playerAimDown(int snum, int sb_snum)
OnEvent(EVENT_AIMDOWN, p->i, snum, -1);
if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0)
{
if (sb_snum & SKB_RUN) p->q16horiz -= 6 << FRACBITS; // running
p->q16horiz -= 6 << FRACBITS;
if (sb_snum & SKB_RUN) p->addhoriz(-6); // running
p->addhoriz(-6); // running
}
}

View file

@ -179,6 +179,7 @@ typedef struct player_struct {
void addang(int v) { q16ang = (q16ang + (v << FRACBITS)) & ((2048 << FRACBITS)-1); }
void setoang(int v) { oq16ang = v << FRACBITS; }
void addhoriz(int v) { q16horiz += (v << FRACBITS); }
void sethoriz(int v) { q16horiz = (v << FRACBITS); }
int gethoriz() { return q16horiz >> FRACBITS; }
int gethorizdiff() { return (q16horiz + q16horizoff) >> FRACBITS; }

View file

@ -2202,6 +2202,7 @@ static void fireweapon(int snum, int* kb)
//
//---------------------------------------------------------------------------
#if 0
static void operateweapon(int snum)
{
auto p = &ps[snum];
@ -3637,5 +3638,5 @@ static void operateweapon(int snum)
}
#endif
}
#endif
END_DUKE_NS

View file

@ -1485,7 +1485,7 @@ void checkweapons_r(struct player_struct* p)
sprite[j].owner = p->ammo_amount[MOTORCYCLE_WEAPON];
p->OnMotorcycle = 0;
p->gotweapon.Clear(MOTORCYCLE_WEAPON);
p->q16horiz = 100 << FRACBITS;
p->sethoriz(100);
p->moto_do_bump = 0;
p->MotoSpeed = 0;
p->TiltStatus = 0;
@ -1501,7 +1501,7 @@ void checkweapons_r(struct player_struct* p)
sprite[j].owner = p->ammo_amount[BOAT_WEAPON];
p->OnBoat = 0;
p->gotweapon.Clear(BOAT_WEAPON);
p->q16horiz = 100 << FRACBITS;
p->sethoriz(100);
p->moto_do_bump = 0;
p->MotoSpeed = 0;
p->TiltStatus = 0;
@ -1730,14 +1730,14 @@ static void onMotorcycle(int snum, int &sb_snum)
{
if (p->TurbCount <= 1)
{
p->q16horiz = 100 << FRACBITS;
p->sethoriz(100);
p->TurbCount = 0;
p->VBumpTarget = 0;
p->VBumpNow = 0;
}
else
{
p->q16horiz = (100 + ((krand2() & 15) - 7)) << FRACBITS;
p->sethoriz(100 + ((krand2() & 15) - 7));
p->TurbCount--;
p->moto_drink = (krand() & 3) - 2;
}
@ -1750,7 +1750,7 @@ static void onMotorcycle(int snum, int &sb_snum)
p->VBumpNow++;
if (p->VBumpTarget < p->VBumpNow)
p->VBumpNow = p->VBumpTarget;
p->q16horiz = (100 + p->VBumpNow / 3) << FRACBITS;
p->sethoriz(100 + p->VBumpNow / 3);
}
else if (p->VBumpTarget < p->VBumpNow)
{
@ -1760,7 +1760,7 @@ static void onMotorcycle(int snum, int &sb_snum)
p->VBumpNow--;
if (p->VBumpTarget > p->VBumpNow)
p->VBumpNow = p->VBumpTarget;
p->q16horiz = (100 + p->VBumpNow / 3) << FRACBITS;
p->sethoriz(100 + p->VBumpNow / 3);
}
else
{
@ -2050,14 +2050,14 @@ static void onBoat(int snum, int sb_snum)
{
if (p->TurbCount <= 1)
{
p->q16horiz = 100 << FRACBITS;
p->sethoriz(100);
p->TurbCount = 0;
p->VBumpTarget = 0;
p->VBumpNow = 0;
}
else
{
p->q16horiz = (100 + ((krand() & 15) - 7)) << FRACBITS;
p->sethoriz(100 + ((krand() & 15) - 7));
p->TurbCount--;
p->moto_drink = (krand() & 3) - 2;
}
@ -2070,7 +2070,7 @@ static void onBoat(int snum, int sb_snum)
p->VBumpNow++;
if (p->VBumpTarget < p->VBumpNow)
p->VBumpNow = p->VBumpTarget;
p->q16horiz = (100 + p->VBumpNow / 3) << FRACBITS;
p->sethoriz(100 + p->VBumpNow / 3);
}
else if (p->VBumpTarget < p->VBumpNow)
{
@ -2080,7 +2080,7 @@ static void onBoat(int snum, int sb_snum)
p->VBumpNow--;
if (p->VBumpTarget > p->VBumpNow)
p->VBumpNow = p->VBumpTarget;
p->q16horiz = (100 + p->VBumpNow / 3) << FRACBITS;
p->sethoriz(100 + p->VBumpNow / 3);
}
else
{
@ -2505,7 +2505,7 @@ void onBoatMove(int snum, int psect, int j)
auto s = &sprite[pi];
int psectlotag = sector[psect].lotag;
short var114, var118, var11c;
short var114, var118;
j &= (MAXWALLS - 1);
var114 = getangle(wall[wall[j].point2].x - wall[j].x, wall[wall[j].point2].y - wall[j].y);
var118 = abs(p->getang() - var114);
@ -2768,13 +2768,14 @@ static void fireWeapon(int snum, int *kb)
}
}
#if 0
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
static void operateweapon(int snum)
static void operateweapon(int snum, int sb_snum, int *kb)
{
auto p = &ps[snum];
int pi = p->i;
@ -3374,5 +3375,5 @@ static void operateweapon(int snum)
}
}
#endif
END_DUKE_NS