diff --git a/source/core/maptypes.h b/source/core/maptypes.h index 4fc1b4736..eb6468f0c 100644 --- a/source/core/maptypes.h +++ b/source/core/maptypes.h @@ -525,6 +525,11 @@ struct spritetypebase xrepeat = other->xrepeat; yrepeat = other->yrepeat; } + + DVector2 Scale() const + { + return DVector2(ScaleX(), ScaleY()); + } double ScaleX() const { diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 331d1b4b1..27ce2c31c 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -65,13 +65,13 @@ void RANDOMSCRAP(DDukeActor* origin) offset.Y = krandf(16) - 8; offset.Z = krandf(16) - 8; - int v = isRR() ? 16 : 48; + double v = isRR() ? 0.125 : 0.375; auto a = randomAngle(); auto vel = krandf(4) + 4; auto zvel = -krandf(8) - 2; - CreateActor(origin->sector(), origin->spr.pos + offset, TILE_SCRAP6 + (r4 & 15), -8, v, v, a, vel, zvel, origin, 5); + CreateActor(origin->sector(), origin->spr.pos + offset, TILE_SCRAP6 + (r4 & 15), -8, DVector2(v, v), a, vel, zvel, origin, 5); } //--------------------------------------------------------------------------- @@ -268,7 +268,7 @@ void lotsofstuff(DDukeActor* actor, int n, int spawntype) { DAngle r1 = randomAngle(); double r2 = zrand(47); - auto j = CreateActor(actor->sector(), actor->spr.pos.plusZ(-r2), spawntype, -32, 8, 8, r1, 0., 0., actor, 5); + auto j = CreateActor(actor->sector(), actor->spr.pos.plusZ(-r2), spawntype, -32, DVector2(0.125, 0.125), r1, 0., 0., actor, 5); if (j) j->spr.cstat = randomFlip(); } } @@ -1321,7 +1321,7 @@ void movetongue(DDukeActor *actor, int tongue, int jaw) auto pos = actor->spr.pos + actor->spr.angle.ToVector() * 2 * k; pos.Z += k * Sgn(actor->vel.Z) * abs(actor->vel.Z / 12); - auto q = CreateActor(actor->sector(), pos, tongue, -40 + (k << 1), 8, 8, nullAngle, 0., 0., actor, 5); + auto q = CreateActor(actor->sector(), pos, tongue, -40 + (k << 1), DVector2(0.125, 0.125), nullAngle, 0., 0., actor, 5); if (q) { q->spr.cstat = CSTAT_SPRITE_YCENTER; @@ -1331,7 +1331,7 @@ void movetongue(DDukeActor *actor, int tongue, int jaw) int k = actor->temp_data[0]; // do not depend on the above loop counter. auto pos = actor->spr.pos + actor->spr.angle.ToVector() * 2 * k; pos.Z += k * Sgn(actor->vel.Z) * abs(actor->vel.Z / 12); - auto spawned = CreateActor(actor->sector(), pos, jaw, -40, 32, 32, nullAngle, 0., 0., actor, 5); + auto spawned = CreateActor(actor->sector(), pos, jaw, -40, DVector2(0.5, 0.5), nullAngle, 0., 0., actor, 5); if (spawned) { spawned->spr.cstat = CSTAT_SPRITE_YCENTER; @@ -2508,11 +2508,11 @@ void scrap(DDukeActor* actor, int SCRAP1, int SCRAP6) void gutsdir(DDukeActor* actor, int gtype, int n, int p) { - int sx, sy; + double scale; if (badguy(actor) && actor->spr.ScaleX() < 0.25) - sx = sy = 8; - else sx = sy = 32; + scale = 0.125; + else scale = 0.5; double gutz = actor->spr.pos.Z - 8; double floorz = getflorzofslopeptr(actor->sector(), actor->spr.pos); @@ -2529,7 +2529,7 @@ void gutsdir(DDukeActor* actor, int gtype, int n, int p) auto zvel = -krandf(8) - 2; // TRANSITIONAL: owned by a player??? - CreateActor(actor->sector(), DVector3(actor->spr.pos.XY(), gutz), gtype, -32, sx, sy, a, vel, zvel, ps[p].GetActor(), 5); + CreateActor(actor->sector(), DVector3(actor->spr.pos.XY(), gutz), gtype, -32, DVector2(scale, scale), a, vel, zvel, ps[p].GetActor(), 5); } } diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index e1ae01343..6a24f79dd 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -537,12 +537,12 @@ void lotsofpaper_d(DDukeActor *actor, int n) void guts_d(DDukeActor* actor, int gtype, int n, int p) { - int sx, sy; + double scale; uint8_t pal; if (badguy(actor) && actor->spr.ScaleX() < 0.25) - sx = sy = 8; - else sx = sy = 32; + scale = 0.125; + else scale = 0.5; double gutz = actor->spr.pos.Z - 8; double floorz = getflorzofslopeptr(actor->sector(), actor->spr.pos); @@ -570,7 +570,7 @@ void guts_d(DDukeActor* actor, int gtype, int n, int p) offs.Y = krandf(16) - 8; offs.X = krandf(16) - 8; // TRANSITIONAL: owned by a player??? - auto spawned = CreateActor(actor->sector(), offs + actor->spr.pos.XY(), gtype, -32, sx, sy, a, vel, zvel, ps[p].GetActor(), 5); + auto spawned = CreateActor(actor->sector(), offs + actor->spr.pos.XY(), gtype, -32, DVector2(scale, scale), a, vel, zvel, ps[p].GetActor(), 5); if (spawned) { if (spawned->spr.picnum == JIBS2) @@ -1005,7 +1005,7 @@ static void movefireext(DDukeActor* actor) auto a = randomAngle(); auto vel = krandf(4) + 4; auto zvel = -krandf(16) - actor->vel.Z * 0.25; - auto spawned = CreateActor(actor->sector(), actor->spr.pos.plusZ(krandf(-48)), SCRAP3 + (krand() & 3), -8, 48, 48, a, vel, zvel, actor, 5); + auto spawned = CreateActor(actor->sector(), actor->spr.pos.plusZ(krandf(-48)), SCRAP3 + (krand() & 3), -8, DVector2(0.75, 0.75), a, vel, zvel, actor, 5); if(spawned) spawned->spr.pal = 2; } @@ -1568,7 +1568,7 @@ static void weaponcommon_d(DDukeActor* proj) double zAdd = k * proj->vel.Z / 24; auto spawned = CreateActor(proj->sector(), proj->spr.pos.plusZ(zAdd) + proj->spr.angle.ToVector() * k * 2., FIRELASER, -40 + (k << 2), - proj->spr.xrepeat, proj->spr.yrepeat, nullAngle, 0., 0., proj->GetOwner(), 5); + proj->spr.Scale(), nullAngle, 0., 0., proj->GetOwner(), 5); if (spawned) { @@ -2101,7 +2101,7 @@ static void greenslime(DDukeActor *actor) auto vel = krandf(2) + 2; auto zvel = 4 - krandf(4); - auto k = CreateActor(actor->sector(), actor->spr.pos, GLASSPIECES + (j % 3), -32, 36, 36, a, vel, zvel, actor, 5); + auto k = CreateActor(actor->sector(), actor->spr.pos, GLASSPIECES + (j % 3), -32, DVector2(0.5625, 0.5625), a, vel, zvel, actor, 5); k->spr.pal = 1; } ps[p].actors_killed++; @@ -2143,7 +2143,7 @@ static void greenslime(DDukeActor *actor) auto vel = krandf(4) + 4; auto zvel = -krandf(16) - actor->vel.Z * 0.25; - auto spawned = CreateActor(actor->sector(), actor->spr.pos.plusZ(-8), SCRAP3 + (krand() & 3), -8, 48, 48, a, vel, zvel, actor, 5); + auto spawned = CreateActor(actor->sector(), actor->spr.pos.plusZ(-8), SCRAP3 + (krand() & 3), -8, DVector2(0.75, 0.75), a, vel, zvel, actor, 5); spawned->spr.pal = 6; } @@ -2255,7 +2255,7 @@ static void greenslime(DDukeActor *actor) auto vel = krandf(4) + 4; auto zvel = -krandf(16) - actor->vel.Z * 0.25; - auto spawned = CreateActor(actor->sector(), actor->spr.pos.plusZ(-8), SCRAP3 + (krand() & 3), -8, 48, 48, a, vel, zvel, actor, 5); + auto spawned = CreateActor(actor->sector(), actor->spr.pos.plusZ(-8), SCRAP3 + (krand() & 3), -8, DVector2(0.75, 0.75), a, vel, zvel, actor, 5); if (spawned) spawned->spr.pal = 6; } actor->temp_data[0] = -3; diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 2dc03dfe5..baefb676c 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -443,12 +443,12 @@ void lotsoffeathers_r(DDukeActor *actor, int n) void guts_r(DDukeActor* actor, int gtype, int n, int p) { int j; - int sx, sy; + double scale; uint8_t pal; if (badguy(actor) && actor->spr.ScaleX() < 0.25) - sx = sy = 4; - else sx = sy = 16; + scale = 0.0625; + else scale = 0.25; double gutz = actor->spr.pos.Z - 8; double floorz = getflorzofslopeptr(actor->sector(), actor->spr.pos); @@ -480,7 +480,7 @@ void guts_r(DDukeActor* actor, int gtype, int n, int p) offs.Y = krandf(16) - 8; offs.X = krandf(16) - 8; // TRANSITIONAL: owned by a player??? - auto spawned = CreateActor(actor->sector(), offs + actor->spr.pos.XY(), gtype, -32, sx, sy, a, vel, zvel, ps[p].GetActor(), 5); + auto spawned = CreateActor(actor->sector(), offs + actor->spr.pos.XY(), gtype, -32, DVector2(scale, scale), a, vel, zvel, ps[p].GetActor(), 5); if (spawned && pal != 0) spawned->spr.pal = pal; } @@ -1243,7 +1243,7 @@ static void weaponcommon_r(DDukeActor *proj) double zAdd = k * proj->vel.Z / 24; auto x = CreateActor(proj->sector(), proj->spr.pos.plusZ(zAdd) + proj->spr.angle.ToVector() * k * 2., FIRELASER, -40 + (k << 2), - proj->spr.xrepeat, proj->spr.yrepeat, nullAngle, 0., 0., proj->GetOwner(), 5); + proj->spr.Scale(), nullAngle, 0., 0., proj->GetOwner(), 5); if (x) { @@ -3124,7 +3124,7 @@ void handle_se06_r(DDukeActor *actor) } if (!hulkspawn) { - ns = CreateActor(actor->sector(), DVector3(actor->spr.pos.XY(), actor->sector()->ceilingz + 466.5), 3677, -8, 16, 16, nullAngle, 0., 0., actor, 5); + ns = CreateActor(actor->sector(), DVector3(actor->spr.pos.XY(), actor->sector()->ceilingz + 466.5), 3677, -8, DVector2(0.25, 0.25), nullAngle, 0., 0., actor, 5); if (ns) { ns->spr.cstat = CSTAT_SPRITE_TRANS_FLIP | CSTAT_SPRITE_TRANSLUCENT; diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index 93122c28b..ef175d0b1 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -172,7 +172,13 @@ DAngle furthestangle(DDukeActor* snum, int angDiv); void getglobalz(DDukeActor* s); void OnEvent(int id, int pnum = -1, DDukeActor* snum = nullptr, int dist = -1); -DDukeActor* CreateActor(sectortype* whatsectp, const DVector3& pos, int s_pn, int8_t s_shd, int8_t s_xr, int8_t s_yr, DAngle s_ang, double s_vel, double s_zvel, DDukeActor* s_ow, int8_t s_stat); +DDukeActor* CreateActor(sectortype* whatsectp, const DVector3& pos, int s_pn, int8_t s_shd, const DVector2& scale, DAngle s_ang, double s_vel, double s_zvel, DDukeActor* s_ow, int8_t s_stat); + +[[deprecated]] +inline DDukeActor* CreateActor(sectortype* whatsectp, const DVector3& pos, int s_pn, int8_t s_shd, int8_t s_xr, int8_t s_yr, DAngle s_ang, double s_vel, double s_zvel, DDukeActor* s_ow, int8_t s_stat) +{ + return CreateActor(whatsectp, pos, s_pn, s_shd, DVector2(s_xr * inttoscale, s_yr * inttoscale), s_ang, s_vel, s_zvel, s_ow, s_stat); +} void ceilingglass(DDukeActor* snum, sectortype* sectnum, int cnt); void spriteglass(DDukeActor* snum, int cnt); diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 03476cc37..1f3addf03 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -2173,10 +2173,9 @@ int ParseState::parse(void) auto a = randomAngle(); auto vel = krandf(8) + 2; auto zvel = -krandf(8); + DVector2 scale(0.5 + (krand() & 15) * REPEAT_SCALE, 0.5 + (krand() & 15) * REPEAT_SCALE); - auto spawned = CreateActor(g_ac->sector(), g_ac->spr.pos + offs, - dnum + s, g_ac->spr.shade, 32 + (krand() & 15), 32 + (krand() & 15), - a, vel, zvel, g_ac, 5); + auto spawned = CreateActor(g_ac->sector(), g_ac->spr.pos + offs, dnum + s, g_ac->spr.shade, scale, a, vel, zvel, g_ac, 5); if (spawned) { if (weap) diff --git a/source/games/duke/src/input.cpp b/source/games/duke/src/input.cpp index 79dbcc6fc..ba1aaefd8 100644 --- a/source/games/duke/src/input.cpp +++ b/source/games/duke/src/input.cpp @@ -284,7 +284,7 @@ void hud_input(int plnum) p->inven_icon = 3; auto pactor = - CreateActor(p->cursector, p->pos.plusZ(30), TILE_APLAYER, -64, 0, 0, p->angle.ang, 0., 0., nullptr, 10); + CreateActor(p->cursector, p->pos.plusZ(30), TILE_APLAYER, -64, DVector2(0, 0), p->angle.ang, 0., 0., nullptr, 10); pactor->temp_data[3] = pactor->temp_data[4] = 0; p->holoduke_on = pactor; pactor->spr.yint = plnum; diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index f37387ba5..fa9f16174 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -118,15 +118,9 @@ static void shootfireball(DDukeActor *actor, int p, DVector3 pos, DAngle ang) pos.Z += 3; } - int sizx = 18; - int sizy = 18; - if (p >= 0) - { - sizx = 7; - sizy = 7; - } + double scale = p >= 0? 0.109375 : 0.28125; - auto spawned = CreateActor(actor->sector(), pos, FIREBALL, -127, sizx, sizy, ang, vel, zvel, actor, (short)4); + auto spawned = CreateActor(actor->sector(), pos, FIREBALL, -127, DVector2(scale, scale), ang, vel, zvel, actor, (short)4); if (spawned) { spawned->spr.extra += (krand() & 7); @@ -260,7 +254,7 @@ static void shootknee(DDukeActor* actor, int p, DVector3 pos, DAngle ang) { if (hit.hitWall || hit.actor()) { - auto knee = CreateActor(hit.hitSector, hit.hitpos, KNEE, -15, 0, 0, ang, 2., 0., actor, 4); + auto knee = CreateActor(hit.hitSector, hit.hitpos, KNEE, -15, DVector2(0, 0), ang, 2., 0., actor, 4); if (knee) { knee->spr.extra += (krand() & 7); @@ -415,7 +409,7 @@ static void shootweapon(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int DDukeActor* spark; if (p >= 0) { - spark = CreateActor(hit.hitSector, hit.hitpos, SHOTSPARK1, -15, 10, 10, ang, 0., 0., actor, 4); + spark = CreateActor(hit.hitSector, hit.hitpos, SHOTSPARK1, -15, DVector2(0.15625, 0.15625), ang, 0., 0., actor, 4); if (!spark) return; spark->spr.extra = ScriptCode[gs.actorinfo[atwith].scriptaddress]; @@ -535,7 +529,7 @@ static void shootweapon(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int } else { - spark = CreateActor(hit.hitSector, hit.hitpos, SHOTSPARK1, -15, 24, 24, ang, 0., 0., actor, 4); + spark = CreateActor(hit.hitSector, hit.hitpos, SHOTSPARK1, -15, DVector2(0.375, 0.375), ang, 0., 0., actor, 4); if (spark) { spark->spr.extra = ScriptCode[gs.actorinfo[atwith].scriptaddress]; @@ -621,41 +615,17 @@ static void shootstuff(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int a } double oldzvel = zvel; - int sizx, sizy; - - if (atwith == SPIT) - { - sizx = 18; - sizy = 18; - pos.Z -= 10; - } - else + double scale = p >= 0? 0.109375 : 0.28125; + if (atwith == SPIT) { - if (atwith == FIRELASER) - { - if (p >= 0) - { - sizx = 34; - sizy = 34; - } - else - { - sizx = 18; - sizy = 18; - } - } - else - { - sizx = 18; - sizy = 18; - } + pos.Z -= 10; } + // Whatever else was here always got overridden by the final 'p>=0' check. - if (p >= 0) sizx = 7, sizy = 7; while (scount > 0) { - auto spawned = CreateActor(sect, pos, atwith, -127, sizx, sizy, ang, vel, zvel, actor, 4); + auto spawned = CreateActor(sect, pos, atwith, -127, DVector2(scale, scale), ang, vel, zvel, actor, 4); if (!spawned) return; spawned->spr.extra += (krand() & 7); @@ -750,7 +720,7 @@ static void shootrpg(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int atw if (p < 0) aimed = nullptr; auto offset = (ang + DAngle1 * 61.171875).ToVector() * (1024. / 448.); - auto spawned = CreateActor(sect, pos.plusZ(-1) + offset, atwith, 0, 14, 14, ang, vel, zvel, actor, 4); + auto spawned = CreateActor(sect, pos.plusZ(-1) + offset, atwith, 0, DVector2(0.21875, 0.21875), ang, vel, zvel, actor, 4); if (!spawned) return; @@ -876,7 +846,7 @@ static void shootlaser(DDukeActor* actor, int p, DVector3 pos, DAngle ang) if (j == 1) { - auto bomb = CreateActor(hit.hitSector, hit.hitpos, TRIPBOMB, -16, 4, 5, ang, 0., 0., actor, STAT_STANDABLE); + auto bomb = CreateActor(hit.hitSector, hit.hitpos, TRIPBOMB, -16, DVector2(0.0625, 0.078125), ang, 0., 0., actor, STAT_STANDABLE); if (!bomb) return; if (isWW2GI()) { @@ -976,7 +946,7 @@ static void shootgrowspark(DDukeActor* actor, int p, DVector3 pos, DAngle ang) actor->spr.cstat |= CSTAT_SPRITE_BLOCK_ALL; - auto spark = CreateActor(sect, hit.hitpos, GROWSPARK, -16, 28, 28, ang, 0., 0., actor, 1); + auto spark = CreateActor(sect, hit.hitpos, GROWSPARK, -16, DVector2(0.4375, 0.4375), ang, 0., 0., actor, 1); if (!spark) return; spark->spr.pal = 2; @@ -1019,7 +989,7 @@ static void shootmortar(DDukeActor* actor, int p, const DVector3& pos, DAngle an zvel = -4; double vel = x / 16.; - CreateActor(sect, pos.plusZ(-6) + ang.ToVector() * 4, atwith, -64, 32, 32, ang, vel, zvel, actor, 1); + CreateActor(sect, pos.plusZ(-6) + ang.ToVector() * 4, atwith, -64, DVector2(0.5, 0.5), ang, vel, zvel, actor, 1); } //--------------------------------------------------------------------------- @@ -1055,7 +1025,7 @@ static void shootshrinker(DDukeActor* actor, int p, const DVector3& pos, DAngle else zvel = 0; auto spawned = CreateActor(actor->sector(), - pos.plusZ(2) + ang.ToVector() * 0.25, SHRINKSPARK, -16, 28, 28, ang, 48., zvel, actor, 4); + pos.plusZ(2) + ang.ToVector() * 0.25, SHRINKSPARK, -16, DVector2(0.4375, 0.4375), ang, 48., zvel, actor, 4); if (spawned) { @@ -2235,7 +2205,7 @@ static void operateweapon(int snum, ESyncBits actions) zvel = -4 + p->horizon.sum().Tan() * 10.; } - auto spawned = CreateActor(p->cursector, p->pos + p->angle.ang.ToVector() * 16, HEAVYHBOMB, -16, 9, 9, + auto spawned = CreateActor(p->cursector, p->pos + p->angle.ang.ToVector() * 16, HEAVYHBOMB, -16, DVector2(0.140625, 0.140625), p->angle.ang, vel + p->hbomb_hold_delay * 2, zvel, pact, 1); if (isNam()) diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 64e45a55b..44f616bbf 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -139,13 +139,13 @@ static void shootmelee(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int a DDukeActor* wpn; if (isRRRA() && atwith == SLINGBLADE) { - wpn = CreateActor(hit.hitSector, hit.hitpos, SLINGBLADE, -15, 0, 0, ang, 32., 0., actor, 4); + wpn = CreateActor(hit.hitSector, hit.hitpos, SLINGBLADE, -15, DVector2(0, 0), ang, 32., 0., actor, 4); if (!wpn) return; wpn->spr.extra += 50; } else { - wpn = CreateActor(hit.hitSector, hit.hitpos, KNEE, -15, 0, 0, ang, 32., 0., actor, 4); + wpn = CreateActor(hit.hitSector, hit.hitpos, KNEE, -15, DVector2(0, 0), ang, 32., 0., actor, 4); if (!wpn) return; wpn->spr.extra += (krand() & 7); } @@ -301,7 +301,7 @@ static void shootweapon(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int DDukeActor* spark; if (p >= 0) { - spark = CreateActor(hit.hitSector, hit.hitpos, SHOTSPARK1, -15, 10, 10, ang, 0., 0., actor, 4); + spark = CreateActor(hit.hitSector, hit.hitpos, SHOTSPARK1, -15, DVector2(0.15625, 0.15625), ang, 0., 0., actor, 4); if (!spark) return; spark->spr.extra = ScriptCode[gs.actorinfo[atwith].scriptaddress]; spark->spr.extra += (krand() % 6); @@ -427,7 +427,7 @@ static void shootweapon(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int } else { - spark = CreateActor(hit.hitSector, hit.hitpos, SHOTSPARK1, -15, 24, 24, ang, 0., 0., actor, 4); + spark = CreateActor(hit.hitSector, hit.hitpos, SHOTSPARK1, -15, DVector2(0.375, 0.375), ang, 0., 0., actor, 4); if (!spark) return; spark->spr.extra = ScriptCode[gs.actorinfo[atwith].scriptaddress]; @@ -530,46 +530,16 @@ static void shootstuff(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int a } double oldzvel = zvel; - int sizx, sizy; + double scale = p >= 0? 0.109375 : atwith == COOLEXPLOSION1? 0.125 : 0.28125; if (atwith == SPIT) { - sizx = 18; sizy = 18; if (!isRRRA() || actor->spr.picnum != MAMA) pos.Z -= 10; else pos.Z -= (20 << 8); } - else - { - if (atwith == COOLEXPLOSION1) - { - sizx = 8; - sizy = 8; - } - else if (atwith == FIRELASER) - { - if (p >= 0) - { - - sizx = 34; - sizy = 34; - } - else - { - sizx = 18; - sizy = 18; - } - } - else - { - sizx = 18; - sizy = 18; - } - } - - if (p >= 0) sizx = 7, sizy = 7; while (scount > 0) { - auto spawned = CreateActor(sect, pos, atwith, -127, sizx, sizy, ang, vel, zvel, actor, 4); + auto spawned = CreateActor(sect, pos, atwith, -127, DVector2(scale, scale), ang, vel, zvel, actor, 4); if (!spawned) return; spawned->spr.extra += (krand() & 7); spawned->spr.cstat = CSTAT_SPRITE_YCENTER; @@ -668,7 +638,7 @@ static void shootrpg(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int atw } auto offset = (ang + DAngle1 * 61).ToVector() * (1024 / 448.); - auto spawned = CreateActor(sect, pos.plusZ(-1) + offset, atwith, 0, 14, 14, ang, vel, zvel, actor, 4); + auto spawned = CreateActor(sect, pos.plusZ(-1) + offset, atwith, 0, DVector2(0.21875, 0.21875), ang, vel, zvel, actor, 4); if (!spawned) return; if (isRRRA()) @@ -793,15 +763,11 @@ static void shootwhip(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int at } double oldzvel = zvel; - int sizx = 18; - int sizy = 18; - - if (p >= 0) sizx = 7, sizy = 7; - else sizx = 8, sizy = 8; + double scale = p >= 0? 0.109375 : 0.125; while (scount > 0) { - auto spawned = CreateActor(sect, pos, atwith, -127, sizx, sizy, ang, vel, zvel, actor, 4); + auto spawned = CreateActor(sect, pos, atwith, -127, DVector2(scale,scale), ang, vel, zvel, actor, 4); if (!spawned) return; spawned->spr.extra += (krand() & 7); spawned->spr.cstat = CSTAT_SPRITE_YCENTER; @@ -837,9 +803,9 @@ static void shootmortar(DDukeActor* actor, int p, const DVector3& pos, DAngle an ang += DAngle90; - int size = atwith == CHEERBOMB ? 16 : 32; + double size = atwith == CHEERBOMB ? 0.25 : 0.5; - CreateActor(sect, pos.plusZ(-6) + ang.ToVector() * 4, atwith, -64, size, size, ang, vel, zvel, actor, 1); + CreateActor(sect, pos.plusZ(-6) + ang.ToVector() * 4, atwith, -64, DVector2(size, size), ang, vel, zvel, actor, 1); } //--------------------------------------------------------------------------- @@ -2746,7 +2712,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp) zvel = -4 + p->horizon.sum().Tan() * 10.; } - auto spawned = CreateActor(p->cursector, p->pos + p->angle.ang.ToVector() * 16, HEAVYHBOMB, -16, 9, 9, + auto spawned = CreateActor(p->cursector, p->pos + p->angle.ang.ToVector() * 16, HEAVYHBOMB, -16, DVector2(0.140625, 0.140625), p->angle.ang, vel + p->hbomb_hold_delay * 2, zvel, pact, 1); if (spawned) @@ -3153,7 +3119,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp) zvel = -4 + p->horizon.sum().Tan() * 10.; } - CreateActor(p->cursector, p->pos + p->angle.ang.ToVector() * 16, POWDERKEG, -16, 9, 9, p->angle.ang, vel * 2, zvel, pact, 1); + CreateActor(p->cursector, p->pos + p->angle.ang.ToVector() * 16, POWDERKEG, -16, DVector2(0.140625, 0.140625), p->angle.ang, vel * 2, zvel, pact, 1); } p->kickback_pic++; if (p->kickback_pic > 20) diff --git a/source/games/duke/src/player_w.cpp b/source/games/duke/src/player_w.cpp index 8b0439e6b..cbf7518fd 100644 --- a/source/games/duke/src/player_w.cpp +++ b/source/games/duke/src/player_w.cpp @@ -341,7 +341,7 @@ void operateweapon_ww(int snum, ESyncBits actions) zvel = -4 + p->horizon.sum().Tan() * 10.; } - auto spawned = CreateActor(p->cursector, p->pos + p->angle.ang.ToVector() * 16, HEAVYHBOMB, -16, 9, 9, + auto spawned = CreateActor(p->cursector, p->pos + p->angle.ang.ToVector() * 16, HEAVYHBOMB, -16, DVector2(0.140625, 0.140625), p->angle.ang, vel + p->hbomb_hold_delay * 2, zvel, pact, 1); if (spawned) diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index d73bd6061..80533fd4c 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -50,7 +50,7 @@ BEGIN_DUKE_NS // //--------------------------------------------------------------------------- -DDukeActor* CreateActor(sectortype* whatsectp, const DVector3& pos, int s_pn, int8_t s_shd, int8_t s_xr, int8_t s_yr, DAngle s_ang, double s_vel, double s_zvel, DDukeActor* s_ow, int8_t s_stat) +DDukeActor* CreateActor(sectortype* whatsectp, const DVector3& pos, int s_pn, int8_t s_shd, const DVector2& scale, DAngle s_ang, double s_vel, double s_zvel, DDukeActor* s_ow, int8_t s_stat) { // sector pointer must be strictly validated here or the engine will crash. if (whatsectp == nullptr || !validSectorIndex(sectnum(whatsectp))) return nullptr; @@ -65,8 +65,7 @@ DDukeActor* CreateActor(sectortype* whatsectp, const DVector3& pos, int s_pn, in act->spr.pos = pos; act->spr.picnum = s_pn; act->spr.shade = s_shd; - act->spr.xrepeat = s_xr; - act->spr.yrepeat = s_yr; + act->spr.SetScale(scale.X, scale.Y); act->spr.angle = s_ang; act->vel.X = s_vel;