- floatified gs.gravity and all relations to player.vel.

This commit is contained in:
Christoph Oelckers 2022-09-12 00:34:18 +02:00
parent 6f8d0e7870
commit 417dc7c330
7 changed files with 47 additions and 44 deletions

View file

@ -48,7 +48,7 @@ This file is a combination of code from the following sources:
BEGIN_DUKE_NS
int adjustfall(DDukeActor* s, int c);
double adjustfall(DDukeActor* actor, double c);
//---------------------------------------------------------------------------
@ -2097,11 +2097,11 @@ bool money(DDukeActor* actor, int BLOODPOOL)
if (sectp->lotag == 2)
{
if (actor->vel.Z < 0.25)
actor->add_int_zvel( (gs.gravity >> 5) + (krand() & 7));
actor->vel.Z += gs.gravity / 32. + krandf(1/32.);
}
else
if (actor->vel.Z < 0.5625)
actor->add_int_zvel( (gs.gravity >> 5) + (krand() & 7));
actor->vel.Z += gs.gravity / 32. + krandf(1 / 32.);
}
ssp(actor, CLIPMASK0);
@ -2211,10 +2211,10 @@ bool jibs(DDukeActor *actor, int JIBS6, bool timeout, bool callsetsprite, bool f
actor->vel.Z += 3 / 16.;
else actor->vel.Z = 4;
}
else actor->add_int_zvel( gs.gravity - 50);
else actor->vel.Z += ( gs.gravity - 50/256.);
}
actor->add_int_pos({ MulScale(actor->int_xvel(), bcos(actor->int_ang()), 14), MulScale(actor->int_xvel(), bsin(actor->int_ang()), 14), 0 });
actor->spr.pos += actor->spr.angle.ToVector() * actor->vel.X;
actor->spr.pos.Z += actor->vel.Z;
if (floorcheck && actor->spr.pos.Z >= actor->sector()->floorz)
@ -2376,7 +2376,7 @@ void shell(DDukeActor* actor, bool morecheck)
actor->temp_data[0]++;
actor->temp_data[0] &= 3;
}
if (actor->vel.Z < 0.5) actor->add_int_zvel((gs.gravity / 13)); // 8
if (actor->vel.Z < 0.5) actor-> vel.Z += (gs.gravity / 13); // 8
else actor->vel.Z -= 0.25;
if (actor->vel.X > 0)
actor->vel.X -= 0.25;
@ -2391,7 +2391,7 @@ void shell(DDukeActor* actor, bool morecheck)
actor->temp_data[0]++;
actor->temp_data[0] &= 3;
}
if (actor->vel.Z < 2) actor->add_int_zvel( (gs.gravity / 3)); // 52;
if (actor->vel.Z < 2) actor->vel.Z += (gs.gravity / 3); // 52;
if(actor->vel.X > 0)
actor->vel.X -= 1/16.;
else
@ -2488,8 +2488,9 @@ void scrap(DDukeActor* actor, int SCRAP1, int SCRAP6)
else actor->temp_data[0]++;
}
}
if (actor->vel.Z < 16) actor->add_int_zvel( gs.gravity - 50);
actor->add_int_pos({ MulScale(actor->int_xvel(), bcos(actor->int_ang()), 14), MulScale(actor->int_xvel(), bsin(actor->int_ang()), 14), actor->int_zvel()});
if (actor->vel.Z < 16) actor->vel.Z += (gs.gravity - 50 / 256.);
actor->spr.pos += actor->spr.angle.ToVector() * actor->vel.X;
actor->spr.pos.Z += actor->vel.Z;
}
else
{
@ -4829,20 +4830,20 @@ void getglobalz(DDukeActor* actor)
void makeitfall(DDukeActor* actor)
{
int c;
double grav;
if( fi.floorspace(actor->sector()) )
c = 0;
grav = 0;
else
{
if( fi.ceilingspace(actor->sector()) || actor->sector()->lotag == ST_2_UNDERWATER)
c = gs.gravity/6;
else c = gs.gravity;
grav = gs.gravity/6;
else grav = gs.gravity;
}
if (isRRRA())
{
c = adjustfall(actor, c); // this accesses sprite indices and cannot be in shared code. Should be done better.
grav = adjustfall(actor, grav); // this accesses sprite indices and cannot be in shared code. Should be done better. (todo: turn into actor flags)
}
if ((actor->spr.statnum == STAT_ACTOR || actor->spr.statnum == STAT_PLAYER || actor->spr.statnum == STAT_ZOMBIEACTOR || actor->spr.statnum == STAT_STANDABLE))
@ -4861,7 +4862,7 @@ void makeitfall(DDukeActor* actor)
if( actor->sector()->lotag == 2 && actor->vel.Z > 3122/256.)
actor->vel.Z = 3144 / 256.;
if (actor->vel.Z < 24)
actor->add_int_zvel(c);
actor->vel.Z += grav;
else actor->vel.Z = 24;
actor->spr.pos.Z += actor->vel.Z;
}
@ -5072,16 +5073,16 @@ void fall_common(DDukeActor *actor, int playernum, int JIBS6, int DRONE, int BLO
actor->spr.yoffset = 0;
// if(!gotz)
{
int c;
double grav;
int sphit = fallspecial? fallspecial(actor, playernum) : 0;
if (fi.floorspace(actor->sector()))
c = 0;
grav = 0;
else
{
if (fi.ceilingspace(actor->sector()) || actor->sector()->lotag == 2)
c = gs.gravity / 6;
else c = gs.gravity;
grav = gs.gravity / 6;
else grav = gs.gravity;
}
if (actor->cgg <= 0 || (actor->sector()->floorstat & CSTAT_SECTOR_SLOPE))
@ -5093,7 +5094,7 @@ void fall_common(DDukeActor *actor, int playernum, int JIBS6, int DRONE, int BLO
if (actor->spr.pos.Z < actor->floorz - FOURSLEIGHT_F)
{
actor->add_int_zvel( c);
actor->vel.Z += grav;
actor->spr.pos.Z += actor->vel.Z;
if (actor->vel.Z > 24) actor->vel.Z = 24;

View file

@ -698,7 +698,7 @@ int ifhitbyweapon_d(DDukeActor *actor)
void movefallers_d(void)
{
int j, x;
int j;
DukeStatIterator iti(STAT_FALLER);
while (auto act = iti.Next())
@ -709,7 +709,7 @@ void movefallers_d(void)
{
act->spr.pos.Z -= 16;
act->temp_data[1] = act->int_ang();
x = act->spr.extra;
int x = act->spr.extra;
j = fi.ifhitbyweapon(act);
if (j >= 0)
{
@ -759,18 +759,19 @@ void movefallers_d(void)
ssp(act, CLIPMASK0);
}
if (fi.floorspace(act->sector())) x = 0;
double grav;
if (fi.floorspace(act->sector())) grav = 0;
else
{
if (fi.ceilingspace(act->sector()))
x = gs.gravity / 6;
grav = gs.gravity / 6;
else
x = gs.gravity;
grav = gs.gravity;
}
if (act->spr.pos.Z < sectp->floorz - 1)
{
act->add_int_zvel( x);
act->vel.Z += grav;
if (act->vel.Z > 24)
act->vel.Z = 24;
act->spr.pos.Z += act->vel.Z;
@ -778,7 +779,7 @@ void movefallers_d(void)
if ((sectp->floorz - act->spr.pos.Z) < 16)
{
j = 1 + (krand() & 7);
for (x = 0; x < j; x++) RANDOMSCRAP(act);
for (int x = 0; x < j; x++) RANDOMSCRAP(act);
deletesprite(act);
}
}

View file

@ -676,19 +676,19 @@ void movefallers_r(void)
ssp(act, CLIPMASK0);
}
int x;
if (fi.floorspace(act->sector())) x = 0;
double grav;
if (fi.floorspace(act->sector())) grav = 0;
else
{
if (fi.ceilingspace(act->sector()))
x = gs.gravity / 6;
grav = gs.gravity / 6;
else
x = gs.gravity;
grav = gs.gravity;
}
if (act->spr.pos.Z < sectp->floorz - 1)
{
act->add_int_zvel( x);
act->vel.Z += grav;
if (act->vel.Z > 24)
act->vel.Z = 24;
act->spr.pos.Z += act->vel.Z;
@ -696,7 +696,7 @@ void movefallers_r(void)
if ((sectp->floorz - act->spr.pos.Z) < 16)
{
int j = 1 + (krand() & 7);
for (x = 0; x < j; x++) RANDOMSCRAP(act);
for (int x = 0; x < j; x++) RANDOMSCRAP(act);
deletesprite(act);
}
}
@ -3439,12 +3439,12 @@ void moveeffectors_r(void) //STATNUM 3
//
//---------------------------------------------------------------------------
int adjustfall(DDukeActor *actor, int c)
double adjustfall(DDukeActor *actor, double c)
{
if ((actor->spr.picnum == BIKERB || actor->spr.picnum == CHEERB) && c == gs.gravity)
c = gs.gravity>>2;
c = gs.gravity * 0.25;
else if (actor->spr.picnum == BIKERBV2 && c == gs.gravity)
c = gs.gravity>>3;
c = gs.gravity * 0.125;
return c;
}

View file

@ -1940,7 +1940,7 @@ int ConCompiler::parsecommand()
gs.respawnactortime = parseone();
gs.respawnitemtime = parseone();
gs.playerfriction = FixedToFloat(parseone());
if (isPlutoPak() || isRR()) gs.gravity = parseone();
if (isPlutoPak() || isRR()) gs.gravity = FixedToFloat<8>(parseone());
gs.rpgblastradius = parseone();
gs.pipebombblastradius = parseone();
gs.shrinkerblastradius = parseone();
@ -3185,7 +3185,7 @@ void loadcons()
gs.rpgblastradius = 1780;
gs.seenineblastradius = 2048;
gs.shrinkerblastradius = 650;
gs.gravity = 176;
gs.gravity = 0.6875;
gs.tripbombblastradius = 3880;
gs.int_playerheight = PHEIGHT_DUKE << 8;
gs.playerheight = PHEIGHT_DUKE;

View file

@ -16,17 +16,18 @@ extern user_defs ud;
struct DukeGameInfo
{
// Static constant global state
double playerfriction;
double gravity;
int respawnactortime;
int bouncemineblastradius;
int respawnitemtime;
int morterblastradius;
int numfreezebounces;
int pipebombblastradius;
double playerfriction;
int rpgblastradius;
int seenineblastradius;
int shrinkerblastradius;
int gravity;
int tripbombblastradius;
int camerashitable;
int max_player_health;

View file

@ -1797,7 +1797,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz_, in
else
{
p->on_ground = 0;
p->__vel.Z += (gs.gravity + 80); // (TICSPERFRAME<<6);
p->vel.Z += (gs.gravity + 5/16.) * VELZ_FACTOR; // (TICSPERFRAME<<6);
if (p->vel.Z >= (16 + 8) * VELZ_FACTOR) p->vel.Z = (16 + 8) * VELZ_FACTOR;
if (p->vel.Z > 2400 / 256 * VELZ_FACTOR && p->falling_counter < 255)
{

View file

@ -2129,7 +2129,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz_, in
{
p->VBumpTarget = 80;
p->moto_bump_fast = 1;
p->__vel.Z -= int(gs.gravity * p->MotoSpeed * (1. / 16.));
p->vel.Z -= (gs.gravity * p->MotoSpeed * (1. / 16.)) * VELZ_FACTOR;
p->MotoOnGround = 0;
if (S_CheckActorSoundPlaying(pact, 188))
S_StopSound(188, pact);
@ -2137,13 +2137,13 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz_, in
}
else
{
p->__vel.Z += gs.gravity - 80 + int(120 - p->MotoSpeed);
p->vel.Z += (gs.gravity - 5/16. + (int(120 - p->MotoSpeed) / 256.)) * VELZ_FACTOR;
if (!S_CheckActorSoundPlaying(pact, 189) && !S_CheckActorSoundPlaying(pact, 190))
S_PlayActorSound(190, pact);
}
}
else
p->__vel.Z += (gs.gravity + 80); // (TICSPERFRAME<<6);
p->vel.Z += (gs.gravity + 5/16.) * VELZ_FACTOR; // (TICSPERFRAME<<6);
if (p->vel.Z >= (16 + 8) * VELZ_FACTOR) p->vel.Z = (16 + 8) * VELZ_FACTOR;
if (p->vel.Z > 2400 / 256 * VELZ_FACTOR && p->falling_counter < 255)