diff --git a/source/games/sw/src/draw.cpp b/source/games/sw/src/draw.cpp index bc48b0a00..ce3481fa9 100644 --- a/source/games/sw/src/draw.cpp +++ b/source/games/sw/src/draw.cpp @@ -346,6 +346,16 @@ void DoShadows(tspriteArray& tsprites, tspritetype* tsp, int viewz, int camang) //DoVoxelShadow(New); } +inline int MOVEx(int vel, int ang) +{ + return (MulScale(vel, bcos(ang), 14)); +} + +inline int MOVEy(int vel, int ang) +{ + return (MulScale(vel, bsin(ang), 14)); +} + void DoMotionBlur(tspriteArray& tsprites, tspritetype const * const tsp) { auto ownerActor = static_cast(tsp->ownerActor); @@ -756,8 +766,7 @@ static void analyzesprites(tspriteArray& tsprites, int viewx, int viewy, int vie { // move sprite forward some so he looks like he's // climbing - pos.X = pp->si.X + MOVEx(128 + 80, tsp->angle); - pos.Y = pp->si.Y + MOVEy(128 + 80, tsp->angle); + pos.XY() = pp->si.XY() + tsp->angle.ToVector() * 13; } else { diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 13fb0d70f..0af4c15de 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -202,31 +202,11 @@ constexpr int NORM_ANGLE(int ang) { return ((ang) & 2047); } int StdRandomRange(int range); -inline int MOVEx(int vel, int ang) -{ - return (MulScale(vel, bcos(ang), 14)); -} - -inline int MOVEy(int vel, int ang) -{ - return (MulScale(vel, bsin(ang), 14)); -} - inline DVector2 MOVExy(int vel, DAngle ang) { return ang.ToVector() * vel * inttoworld; } -inline double MOVEx(int vel, DAngle ang) -{ - return vel * ang.Cos() * inttoworld; -} - -inline double MOVEy(int vel, DAngle ang) -{ - return vel * ang.Sin() * inttoworld; -} - inline int SQ(int val) { return val * val; diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index eec295be3..8317ed37c 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -1343,7 +1343,7 @@ void DoPlayerTeleportToOffset(PLAYER* pp) void DoSpawnTeleporterEffect(DSWActor* actor) { extern STATE s_TeleportEffect[]; - DVector2 vect = MOVExy(512, actor->spr.angle); + DVector2 vect = actor->spr.angle.ToVector() * 32; auto effectActor = SpawnActor(STAT_MISSILE, 0, s_TeleportEffect, actor->sector(), ActorVectOfTop(actor).plusZ(16) + vect, actor->spr.angle, 0); @@ -2741,7 +2741,7 @@ void DoPlayerMoveVehicle(PLAYER* pp) DVector3 hitpos((pos[0] + pos[1]) * 0.5, pp->cursector->floorz - 10); hitscan(hitpos, pp->cursector, - DVector3(MOVEx(256, pp->angle.ang), MOVEy(256, pp->angle.ang), 0), + DVector3(pp->angle.ang.ToVector() * 16, 0), hit, CLIPMASK_PLAYER); if ((hit.hitpos.XY() - hitpos.XY()).LengthSquared() < 50 * 50) @@ -4786,7 +4786,7 @@ void DoPlayerDive(PLAYER* pp) if (bubble != nullptr) { // back it up a bit to get it out of your face - auto vec = MOVExy((128+64), bubble->spr.angle + DAngle180); + auto vec = (bubble->spr.angle + DAngle180).ToVector() * 12; move_sprite(bubble, DVector3(vec, 0), plActor->user.ceiling_dist, plActor->user.floor_dist, 0, synctics); } diff --git a/source/games/sw/src/sector.cpp b/source/games/sw/src/sector.cpp index 7c3d32322..387f89de2 100644 --- a/source/games/sw/src/sector.cpp +++ b/source/games/sw/src/sector.cpp @@ -860,7 +860,7 @@ void SectorExp(DSWActor* actor, sectortype* sectp, double zh) exp->spr.xrepeat += (RANDOM_P2(32<<8)>>8) - 16; exp->spr.yrepeat += (RANDOM_P2(32<<8)>>8) - 16; - exp->user.change.XY() = MOVExy(92, exp->spr.angle); + exp->user.change.XY() = exp->spr.angle.ToVector(5.75); } diff --git a/source/games/sw/src/skull.cpp b/source/games/sw/src/skull.cpp index ee612a7e4..066aef94c 100644 --- a/source/games/sw/src/skull.cpp +++ b/source/games/sw/src/skull.cpp @@ -252,7 +252,7 @@ int SetupSkull(DSWActor* actor) int DoSkullMove(DSWActor* actor) { - auto vect = MOVExy(actor->int_xvel(), actor->spr.angle); + auto vect = actor->spr.angle.ToVector() * actor->vel.X; double daz = actor->vel.Z; actor->user.coll = move_missile(actor, DVector3(vect, daz), 16, 16, CLIPMASK_MISSILE, ACTORMOVETICS); diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index 7373cfb01..93cf8102a 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -2486,10 +2486,10 @@ void SpriteSetup(void) actorNew->spr.cstat = 0; actorNew->spr.extra = 0; actorNew->spr.pos = actor->spr.pos; - actorNew->set_int_ang(NORM_ANGLE(actor->int_ang() + 1024)); + actorNew->spr.angle += DAngle180; actorNew->spr.picnum = actor->spr.picnum; - actorNew->spr.pos += DVector2(MOVEx(256 + 128, actor->spr.angle), MOVEy(256 + 128, actor->spr.angle)); + actorNew->spr.pos += actor->spr.angle.ToVector() * 24; break; } @@ -4547,7 +4547,7 @@ bool ActorDrop(DSWActor* actor, const DVector3& pos, sectortype* new_sector, dou // Primarily used in ai.c for now - need to get rid of bool DropAhead(DSWActor* actor, double min_height) { - auto vect = actor->spr.pos + MOVExy(256, actor->spr.angle); + auto vect = actor->spr.pos + actor->spr.angle.ToVector() * 16; auto newsector = actor->sector(); updatesector(vect, &newsector); diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index e0f3d5e3b..21168d4b4 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -7895,7 +7895,7 @@ int DoPlasma(DSWActor* actor) auto oldv = actor->spr.pos; DoBlurExtend(actor, 0, 4); - auto vec = MOVExy(actor->int_xvel(), actor->spr.angle); + auto vec = actor->spr.angle.ToVector() * actor->vel.X; double daz = actor->vel.Z; actor->user.coll = move_missile(actor, DVector3(vec, daz), 16, 16, CLIPMASK_MISSILE, MISSILEMOVETICS); @@ -8824,7 +8824,7 @@ int DoBoltThinMan(DSWActor* actor) { DoBlurExtend(actor, 0, 4); - auto vec = MOVExy(actor->int_xvel(), actor->spr.angle); + auto vec = actor->spr.angle.ToVector() * actor->vel.X; double daz = actor->vel.Z; actor->user.coll = move_missile(actor, DVector3(vec, daz), CEILING_DIST, FLOOR_DIST, CLIPMASK_MISSILE, MISSILEMOVETICS); @@ -9337,7 +9337,7 @@ int DoUziBullet(DSWActor* actor) // otherwize the moves are in too big an increment for (int i = 0; i < 2; i++) { - auto vec = MOVExy((actor->int_xvel() >> 1), actor->spr.angle); + auto vec = actor->spr.angle.ToVector() * actor->vel.X * 0.5; double daz = (actor->int_zvel() >> 1) * zinttoworld; auto spos = actor->spr.pos.XY(); @@ -9391,7 +9391,7 @@ int DoBoltSeeker(DSWActor* actor) MissileSeek(actor, 30, 768/*, 4, 48, 6*/); DoBlurExtend(actor, 0, 4); - auto vec = MOVExy(actor->int_xvel(), actor->spr.angle); + auto vec = actor->spr.angle.ToVector() * actor->vel.X; double daz = actor->vel.Z; actor->user.coll = move_missile(actor, DVector3(vec, daz), CEILING_DIST, FLOOR_DIST, CLIPMASK_MISSILE, MISSILEMOVETICS); @@ -9430,7 +9430,7 @@ int DoElectro(DSWActor* actor) if (actor->user.Counter > 0) MissileSeek(actor, 30, 512/*, 3, 52, 2*/); - auto vec = MOVExy(actor->int_xvel(), actor->spr.angle); + auto vec = actor->spr.angle.ToVector() * actor->vel.X; double daz = actor->vel.Z; actor->user.coll = move_missile(actor, DVector3(vec, daz), CEILING_DIST, FLOOR_DIST, CLIPMASK_MISSILE, MISSILEMOVETICS); @@ -16006,7 +16006,7 @@ int HelpMissileLateral(DSWActor* actor, int dist) actor->set_int_xvel(dist); - auto vec = MOVExy(actor->int_xvel(), actor->spr.angle); + auto vec = actor->spr.angle.ToVector() * actor->vel.X; actor->spr.clipdist = 32L >> 2; @@ -16089,7 +16089,7 @@ int InitEnemyFireball(DSWActor* actor) { int nz, dist; int size_z; - int i, targ_z, xchange, ychange; + int i, targ_z; static short lat_ang[] = { @@ -16107,14 +16107,13 @@ int InitEnemyFireball(DSWActor* actor) size_z = Z(ActorSizeY(actor)); nz = actor->int_pos().Z - size_z + (size_z >> 2) + (size_z >> 3) + Z(4); - xchange = MOVEx(GORO_FIREBALL_VELOCITY, actor->int_ang()); - ychange = MOVEy(GORO_FIREBALL_VELOCITY, actor->int_ang()); + auto change = actor->spr.angle.ToVector() * GORO_FIREBALL_VELOCITY;; int lastvel = 0; for (i = 0; i < 2; i++) { auto actorNew = SpawnActor(STAT_MISSILE, GORO_FIREBALL, s_Fireball, actor->sector(), - actor->int_pos().X, actor->int_pos().Y, nz, actor->int_ang(), GORO_FIREBALL_VELOCITY); + actor->int_pos().X, actor->int_pos().Y, nz, actor->int_ang(), int(GORO_FIREBALL_VELOCITY * worldtoint)); actorNew->spr.hitag = LUMINOUS; //Always full brightness actorNew->spr.xrepeat = 20; @@ -16129,8 +16128,7 @@ int InitEnemyFireball(DSWActor* actor) HelpMissileLateral(actorNew, 500); actorNew->set_int_ang(NORM_ANGLE(actorNew->int_ang() - lat_ang[i])); - actorNew->user.set_int_change_x(xchange); - actorNew->user.set_int_change_y(ychange); + actorNew->user.change.XY() = change; MissileSetPos(actorNew, DoFireball, 700); @@ -16146,7 +16144,7 @@ int InitEnemyFireball(DSWActor* actor) // distance if (dist != 0) { - actorNew->set_int_zvel((GORO_FIREBALL_VELOCITY * (targ_z - actorNew->int_pos().Z)) / dist); + actorNew->set_int_zvel((GORO_FIREBALL_VELOCITY * worldtoint * (targ_z - actorNew->int_pos().Z)) / dist); actorNew->user.change.Z = actorNew->vel.Z; } // back up first one diff --git a/source/games/sw/src/weapon.h b/source/games/sw/src/weapon.h index dcd3e287e..45495c933 100644 --- a/source/games/sw/src/weapon.h +++ b/source/games/sw/src/weapon.h @@ -139,7 +139,7 @@ const char *DeathString(DSWActor*); // NPC Missile Speeds #define NINJA_STAR_VELOCITY (1800) #define NINJA_BOLT_VELOCITY (500) -#define GORO_FIREBALL_VELOCITY (800) +constexpr int GORO_FIREBALL_VELOCITY = 50; #define SKEL_ELECTRO_VELOCITY (850) #define COOLG_FIRE_VELOCITY (400)