diff --git a/source/core/coreactor.h b/source/core/coreactor.h index 66dbf7310..4c54a5447 100644 --- a/source/core/coreactor.h +++ b/source/core/coreactor.h @@ -138,11 +138,6 @@ public: vel.X = v * inttoworld; } - void add_int_xvel(int v) - { - vel.X += v * inttoworld; - } - vec3_t int_vel() const { return vec3_t(FloatToFixed(vel.X), FloatToFixed(vel.Y), FloatToFixed(vel.Z)); diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 02a93c512..678100dcf 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -994,13 +994,13 @@ void movemasterswitch(DDukeActor *actor) void movetrash(DDukeActor *actor) { - if (actor->int_xvel() == 0) actor->set_int_xvel(1); + if (actor->vel.X == 0) actor->vel.X = 1 / 16.; if (ssp(actor, CLIPMASK0)) { makeitfall(actor); if (krand() & 1) actor->vel.Z -= 1; - if (abs(actor->int_xvel()) < 48) - actor->add_int_xvel( (krand() & 3)); + if (abs(actor->vel.X) < 3) + actor->vel.X += (krand() & 3) / 16.; } else deletesprite(actor); } @@ -4980,11 +4980,14 @@ void alterang(int ang, DDukeActor* actor, int playernum) aang = actor->int_ang(); - actor->add_int_xvel( (*moveptr - actor->int_xvel()) / 5); - if (actor->vel.Z < (648/256.)) actor->add_int_zvel( ((*(moveptr + 1) << 4) - actor->int_zvel()) / 5); + actor->vel.X += (moveptr[0] / 16 - actor->vel.X) / 5; + if (actor->vel.Z < (648 / 256.)) + { + actor->vel.Z += (moveptr[1] / 16 - actor->vel.Z) / 5; + } if (isRRRA() && (ang & windang)) - actor->set_int_ang(WindDir); + actor->spr.angle = WindDir; else if (ang & seekplayer) { DDukeActor* holoduke = !isRR()? ps[playernum].holoduke_on.Get() : nullptr; diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 33544a673..d455421fd 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -394,8 +394,8 @@ void hitradius_d(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h if (act2->spr.picnum != TANK && act2->spr.picnum != ROTATEGUN && act2->spr.picnum != RECON && !bossguy(act2)) { - if (act2->int_xvel() < 0) act2->vel.X = 0; - act2->add_int_xvel( (actor->spr.extra << 2)); + if (act2->vel.X < 0) act2->vel.X = 0; + act2->vel.X += ( (actor->spr.extra / 4.)); } if (actorflag(act2, SFLAG_HITRADIUSCHECK)) @@ -3549,8 +3549,8 @@ void move_d(DDukeActor *actor, int playernum, int xvel) auto moveptr = &ScriptCode[actor->temp_data[1]]; - if (a & geth) actor->add_int_xvel( (*moveptr - actor->int_xvel()) >> 1); - if (a & getv) actor->add_int_zvel( ((*(moveptr + 1) << 4) - actor->int_zvel()) >> 1); + if (a & geth) actor->vel.X += (moveptr[0] / 16 - actor->vel.X) * 0.5; + if (a & getv) actor->vel.Z += (moveptr[1] / 16 - actor->vel.Z) * 0.5; if (a & dodgebullet) dodge(actor); @@ -3558,11 +3558,11 @@ void move_d(DDukeActor *actor, int playernum, int xvel) if (actor->spr.picnum != APLAYER) alterang(a, actor, playernum); - if (actor->int_xvel() > -6 && actor->int_xvel() < 6) actor->vel.X = 0; + if (abs(actor->vel.X) < 6 / 16.) actor->vel.X = 0; a = badguy(actor); - if (actor->vel.X != 0 || actor->int_zvel()) + if (actor->vel.X != 0 || actor->vel.X != 0) { if (a && actor->spr.picnum != ROTATEGUN) { diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index b31617dcf..19f4110b1 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -330,8 +330,8 @@ void hitradius_r(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h (pic != HULK && pic != MAMA && pic != BILLYPLAY && pic != COOTPLAY && pic != MAMACLOUD) : (pic != HULK && pic != SBMOVE)) { - if (act2->int_xvel() < 0) act2->vel.X = 0; - act2->add_int_xvel( (act2->spr.extra << 2)); + if (act2->vel.X < 0) act2->vel.X = 0; + act2->vel.X += ((actor->spr.extra / 4.)); } if (actorflag(act2, SFLAG_HITRADIUSCHECK)) @@ -3606,8 +3606,8 @@ void move_r(DDukeActor *actor, int pnum, int xvel) auto moveptr = &ScriptCode[actor->temp_data[1]]; - if (a & geth) actor->add_int_xvel( (*moveptr - actor->int_xvel()) >> 1); - if (a & getv) actor->add_int_zvel( ((*(moveptr + 1) << 4) - actor->int_zvel()) >> 1); + if (a & geth) actor->vel.X += (moveptr[0] / 16 - actor->vel.X) * 0.5; + if (a & getv) actor->vel.Z += (moveptr[1] / 16 - actor->vel.Z) * 0.5; if (a & dodgebullet) dodge(actor); @@ -3615,7 +3615,7 @@ void move_r(DDukeActor *actor, int pnum, int xvel) if (actor->spr.picnum != APLAYER) alterang(a, actor, pnum); - if (actor->int_xvel() > -6 && actor->int_xvel() < 6) actor->vel.X = 0; + if (abs(actor->vel.X) < 6 / 16.) actor->vel.X = 0; a = badguy(actor); diff --git a/source/games/duke/src/global.cpp b/source/games/duke/src/global.cpp index bea2f7b79..98b71578b 100644 --- a/source/games/duke/src/global.cpp +++ b/source/games/duke/src/global.cpp @@ -68,7 +68,8 @@ int hulkspawn; // Spawn a hulk? int lastlevel; // Set at the end of RRRA's E2L7. short fakebubba_spawn, mamaspawn_count, banjosound; // RRRA special effects short BellTime; -int WindTime, WindDir; +int WindTime; +DAngle WindDir; uint8_t enemysizecheat /*raat607*/, ufospawnsminion, pistonsound, chickenphase /* raat605*/, RRRA_ExitedLevel, fogactive; //------------------------------------------------------------------------- diff --git a/source/games/duke/src/global.h b/source/games/duke/src/global.h index 63d57707a..3506920a6 100644 --- a/source/games/duke/src/global.h +++ b/source/games/duke/src/global.h @@ -124,7 +124,8 @@ extern short ambienthitag[64]; extern unsigned ambientfx; extern TArray mspos; extern TArray cranes; -extern int WindTime, WindDir; +extern int WindTime; +extern DAngle WindDir; extern short fakebubba_spawn, mamaspawn_count, banjosound; extern short BellTime; extern uint8_t enemysizecheat /*raat607*/, ufospawnsminion, pistonsound, chickenphase /* raat605*/, RRRA_ExitedLevel, fogactive; diff --git a/source/games/duke/src/inlines.h b/source/games/duke/src/inlines.h index 8e75c5495..683ce6daf 100644 --- a/source/games/duke/src/inlines.h +++ b/source/games/duke/src/inlines.h @@ -247,7 +247,7 @@ inline ESpriteFlags randomXFlip() return CSTAT_SPRITE_XFLIP; } -inline DAngle randomAngle(double span) +inline DAngle randomAngle(double span = 360.) { return DAngle::fromDeg(krandf(span)); } diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index df33eea8b..d5369e200 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -1239,7 +1239,7 @@ int doincrements_r(player_struct* p) else if ((krand() & 127) == 8) { WindTime = 120 + ((krand() & 63) << 2); - WindDir = krand() & 2047; + WindDir = randomAngle(); } if (BellTime > 0) diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index 381944c21..0dc38356c 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -459,7 +459,7 @@ void resetprestat(int snum,int g) earthquaketime = 0; WindTime = 0; - WindDir = 0; + WindDir = nullAngle; fakebubba_spawn = 0; RRRA_ExitedLevel = 0; BellTime = 0; @@ -697,7 +697,7 @@ void prelevel_common(int g) thunderon = 0; chickenplant = 0; WindTime = 0; - WindDir = 0; + WindDir = nullAngle; fakebubba_spawn = 0; RRRA_ExitedLevel = 0; mamaspawn_count = currentLevel->rr_mamaspawn;