diff --git a/source/games/duke/src/animatesprites_d.cpp b/source/games/duke/src/animatesprites_d.cpp index 5e07eefec..9bb298a6a 100644 --- a/source/games/duke/src/animatesprites_d.cpp +++ b/source/games/duke/src/animatesprites_d.cpp @@ -241,8 +241,8 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi { t->picnum = STATIC; t->cstat |= randomFlip(); - t->xrepeat += 8; - t->yrepeat += 8; + t->AddScaleX(0.125); + t->AddScaleY(0.125); } else if (camsprite && camsprite == h->GetHitOwner()) { @@ -322,8 +322,7 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi newtspr->statnum = 99; - newtspr->yrepeat = (t->yrepeat >> 3); - if (t->ScaleY() < 0.0625) t->yrepeat = 4; + newtspr->SetScaleY(max(t->ScaleY() * 0.125, 0.0625)); newtspr->shade = t->shade; newtspr->cstat = 0; @@ -573,8 +572,7 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi shadowspr->statnum = 99; - shadowspr->yrepeat = (t->yrepeat >> 3); - if (t->ScaleY() < 0.0625) t->yrepeat = 4; + shadowspr->SetScaleY(max(t->ScaleY() * 0.125, 0.0625)); shadowspr->shade = 127; shadowspr->cstat |= CSTAT_SPRITE_TRANSLUCENT; @@ -583,7 +581,7 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi if (hw_models && modelManager.CheckModel(t->picnum, t->pal)) { - shadowspr->yrepeat = 0; + shadowspr->SetScaleY(0); // 512:trans reverse //1024:tell MD2SPRITE.C to use Z-buffer hacks to hide overdraw issues shadowspr->clipdist |= TSPR_FLAGS_MDHACK; @@ -614,7 +612,7 @@ void animatesprites_d(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi if (t->sectp->lotag == 2) t->pal = 8; t->pos.Z = OwnerAc->spr.pos.Z - 3; if (gs.lasermode == 2 && ps[screenpeek].heat_on == 0) - t->yrepeat = 0; + t->SetScaleY(0); t->shade = -127; break; case EXPLOSION2: diff --git a/source/games/duke/src/animatesprites_r.cpp b/source/games/duke/src/animatesprites_r.cpp index 79ee618ae..40763ea60 100644 --- a/source/games/duke/src/animatesprites_r.cpp +++ b/source/games/duke/src/animatesprites_r.cpp @@ -362,8 +362,7 @@ void animatesprites_r(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi newtspr->statnum = 99; - newtspr->yrepeat = (t->yrepeat >> 3); - if (t->ScaleY() < 0.0625) t->yrepeat = 4; + newtspr->SetScaleY(max(t->ScaleY() * 0.125, 0.0625)); newtspr->shade = t->shade; newtspr->cstat = 0; @@ -722,8 +721,7 @@ void animatesprites_r(tspriteArray& tsprites, const DVector2& viewVec, DAngle vi shadowspr->statnum = 99; - shadowspr->yrepeat = (t->yrepeat >> 3); - if (t->ScaleY() < 0.0625) t->yrepeat = 4; + shadowspr->SetScaleY(max(t->ScaleY() * 0.125, 0.0625)); shadowspr->shade = 127; shadowspr->cstat |= CSTAT_SPRITE_TRANSLUCENT; diff --git a/source/games/duke/src/game_misc.cpp b/source/games/duke/src/game_misc.cpp index 1439848a8..22b02fe17 100644 --- a/source/games/duke/src/game_misc.cpp +++ b/source/games/duke/src/game_misc.cpp @@ -430,7 +430,7 @@ bool GameInterface::DrawAutomapPlayer(const DVector2& mxy, const DVector2& cpos, auto& pp = ps[p]; auto act = pp.GetActor(); int i = TILE_APLAYERTOP + (act->vel.X > 1 && pp.on_ground ? (PlayClock >> 4) & 3 : 0); - double j = clamp(czoom * act->spr.yrepeat + abs(pp.truefz - pp.pos.Z), 21.5, 128.) * REPEAT_SCALE; + double j = clamp(czoom * act->spr.ScaleY() + abs(pp.truefz - pp.pos.Z) * REPEAT_SCALE, 0.333, 2.); auto const vec = OutAutomapVector(mxy - cpos, cangvect, czoom, xydim); auto const daang = -((!SyncInput() ? act->spr.angle : act->interpolatedangle(interpfrac)) - cang).Normalized360().Degrees(); diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 1f3addf03..61f8c2c44 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -1201,12 +1201,12 @@ void DoActor(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, else SetGameVarID(lVar2, act->spriteextra, sActor, sPlayer); break; case ACTOR_XREPEAT: - if (bSet) act->spr.xrepeat = lValue; - else SetGameVarID(lVar2, act->spr.xrepeat, sActor, sPlayer); + if (bSet) act->spr.SetScaleX(lValue * REPEAT_SCALE); + else SetGameVarID(lVar2, int(act->spr.ScaleX() * INV_REPEAT_SCALE), sActor, sPlayer); break; case ACTOR_YREPEAT: - if (bSet) act->spr.yrepeat = lValue; - else SetGameVarID(lVar2, act->spr.yrepeat, sActor, sPlayer); + if (bSet) act->spr.SetScaleY(lValue * REPEAT_SCALE); + else SetGameVarID(lVar2, int(act->spr.ScaleY() * INV_REPEAT_SCALE), sActor, sPlayer); break; case ACTOR_XOFFSET: if (bSet) act->spr.xoffset = lValue; @@ -1724,21 +1724,21 @@ int ParseState::parse(void) { insptr++; - // JBF 20030805: As I understand it, if xrepeat becomes 0 it basically kills the + // JBF 20030805: As I understand it, if repeat becomes 0 it basically kills the // sprite, which is why the "sizeto 0 41" calls in 1.3d became "sizeto 4 41" in // 1.4, so instead of patching the CONs I'll surruptitiously patch the code here //if (!isPlutoPak() && *insptr == 0) *insptr = 4; - j = ((*insptr) - g_ac->spr.xrepeat) << 1; - g_ac->spr.xrepeat += Sgn(j); + double s = ((*insptr) * REPEAT_SCALE - g_ac->spr.ScaleX()); + g_ac->spr.SetScaleX(clamp(g_ac->spr.ScaleX() + Sgn(s) * REPEAT_SCALE, 0., 4.)); insptr++; auto scale = g_ac->spr.ScaleY(); if ((g_ac->isPlayer() && scale < 0.5626) || *insptr * REPEAT_SCALE < scale || (scale * (tileHeight(g_ac->spr.picnum) + 8)) < g_ac->floorz - g_ac->ceilingz) { - j = ((*insptr) - g_ac->spr.yrepeat) << 1; - if (abs(j)) g_ac->spr.yrepeat += Sgn(j); + s = ((*insptr) * REPEAT_SCALE - g_ac->spr.ScaleY()); + g_ac->spr.SetScaleY(clamp(g_ac->spr.ScaleY() + Sgn(s) * REPEAT_SCALE, 0., 4.)); } insptr++; @@ -1748,9 +1748,9 @@ int ParseState::parse(void) } case concmd_sizeat: insptr++; - g_ac->spr.xrepeat = (uint8_t)*insptr; + g_ac->spr.SetScaleX((uint8_t)*insptr * REPEAT_SCALE); insptr++; - g_ac->spr.yrepeat = (uint8_t)*insptr; + g_ac->spr.SetScaleY((uint8_t)*insptr * REPEAT_SCALE); insptr++; break; case concmd_shoot: @@ -2296,9 +2296,9 @@ int ParseState::parse(void) parseifelse(ps[g_p].OnBoat == 1); break; case concmd_ifsizedown: - g_ac->spr.xrepeat--; - g_ac->spr.yrepeat--; - parseifelse(g_ac->spr.xrepeat <= 5); + g_ac->spr.AddScaleX(-REPEAT_SCALE); + g_ac->spr.AddScaleY(-REPEAT_SCALE); + parseifelse(g_ac->spr.ScaleX() <= 5 * REPEAT_SCALE); break; case concmd_ifwind: parseifelse(WindTime > 0); @@ -2414,7 +2414,7 @@ int ParseState::parse(void) j = 1; else if( (l& pkicking) && ( ps[g_p].quick_kick > 0 || ( ps[g_p].curr_weapon == KNEE_WEAPON && ps[g_p].kickback_pic > 0 ) ) ) j = 1; - else if( (l& pshrunk) && ps[g_p].GetActor()->spr.xrepeat < (isRR() ? 8 : 32)) + else if( (l& pshrunk) && ps[g_p].GetActor()->spr.ScaleX() < (isRR() ? 0.125 : 0.5)) j = 1; else if( (l& pjetpack) && ps[g_p].jetpack_on ) j = 1; diff --git a/source/games/duke/src/hudweapon_d.cpp b/source/games/duke/src/hudweapon_d.cpp index 7b2dabfa0..222047cfe 100644 --- a/source/games/duke/src/hudweapon_d.cpp +++ b/source/games/duke/src/hudweapon_d.cpp @@ -295,7 +295,7 @@ void displayweapon_d(int snum, double interpfrac) } } - if (p->GetActor()->spr.xrepeat < 40) + if (p->GetActor()->spr.ScaleX() < 0.625) { //shrunken.. animateshrunken(p, weapon_xoffset, looking_arc, look_anghalf, FIST, shade, o, interpfrac); diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index 50ed7cbc1..efed02ee2 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -326,7 +326,7 @@ DDukeActor* aim(DDukeActor* actor, int abase) actor != act) continue; - if (gotshrinker && act->spr.xrepeat < 30 && !actorflag(act, SFLAG_SHRINKAUTOAIM)) continue; + if (gotshrinker && act->spr.ScaleX() < 0.46875 && !actorflag(act, SFLAG_SHRINKAUTOAIM)) continue; if (gotfreezer && act->spr.pal == 1) continue; } diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index fa9f16174..dec3923fc 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -698,7 +698,7 @@ static void shootrpg(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int atw { double zoffs = 32; if (isWorldTour()) // Twentieth Anniversary World Tour - zoffs *= (actor->spr.yrepeat / 80.0f); + zoffs *= (actor->spr.ScaleY() * 0.8); pos.Z += zoffs; } else if (actor->spr.picnum == BOSS2) @@ -706,7 +706,7 @@ static void shootrpg(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int atw vel += 8; double zoffs = 24; if (isWorldTour()) // Twentieth Anniversary World Tour - zoffs *= (actor->spr.yrepeat / 80.0f); + zoffs *= (actor->spr.ScaleY() * 0.8); pos.Z -= zoffs; } @@ -749,7 +749,7 @@ static void shootrpg(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int atw if (isWorldTour()) // Twentieth Anniversary World Tour { - float siz = actor->spr.yrepeat / 80.0f; + float siz = actor->spr.ScaleY() * 0.8; spawnofs *= siz; aoffs *= siz; } @@ -758,7 +758,6 @@ static void shootrpg(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int atw spawned->spr.angle += aoffs; spawned->spr.SetScale(0.65625, 0.65625); - spawned->spr.yrepeat = 42; } else if (actor->spr.picnum == BOSS2) { @@ -766,7 +765,7 @@ static void shootrpg(DDukeActor *actor, int p, DVector3 pos, DAngle ang, int atw DAngle aoffs = DAngle22_5 / 16. - DAngle45 + randomAngle(90); if (isWorldTour()) { // Twentieth Anniversary World Tour - double siz = actor->spr.yrepeat / 70.; + double siz = actor->spr.ScaleY() * 0.9143; spawnofs *= siz; aoffs *= siz; } @@ -2818,7 +2817,7 @@ void processinput_d(int snum) return; } - if (p->GetActor()->spr.xrepeat < 40 && p->jetpack_on == 0) + if (p->GetActor()->spr.ScaleX() < 0.625 && p->jetpack_on == 0) { p->ofistsign = p->fistsign; p->fistsign += p->GetActor()->vel.X * 16; diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 44f616bbf..232a6e38a 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -671,7 +671,6 @@ static void shootrpg(DDukeActor* actor, int p, DVector3 pos, DAngle ang, int atw if (actor->spr.picnum == HULK) { spawned->spr.SetScale(0.125, 0.125); - spawned->spr.yrepeat = 8; } else if (atwith != FREEZEBLAST) { @@ -2318,7 +2317,6 @@ static void underwater(int snum, ESyncBits actions, double floorz, double ceilin { j->spr.pos += (p->angle.ang.ToVector() + DVector2(12 - (global_random & 8), 12 - (global_random & 8))) * 16; j->spr.SetScale(0.046875, 0.03125); - j->spr.yrepeat = 2; j->spr.pos.Z = p->pos.Z + 8; j->spr.cstat = CSTAT_SPRITE_TRANS_FLIP | CSTAT_SPRITE_TRANSLUCENT; } diff --git a/source/games/duke/src/premap_d.cpp b/source/games/duke/src/premap_d.cpp index ef8556cce..c534beaf1 100644 --- a/source/games/duke/src/premap_d.cpp +++ b/source/games/duke/src/premap_d.cpp @@ -249,7 +249,7 @@ void cacheit_d(void) DukeSectIterator it(§); while (auto act = it.Next()) { - if (act->spr.xrepeat != 0 && act->spr.yrepeat != 0 && (act->spr.cstat & CSTAT_SPRITE_INVISIBLE) == 0) + if (act->spr.ScaleX() != 0 && act->spr.ScaleY() != 0 && (act->spr.cstat & CSTAT_SPRITE_INVISIBLE) == 0) cachespritenum(act); } } diff --git a/source/games/duke/src/premap_r.cpp b/source/games/duke/src/premap_r.cpp index 0e11e68c1..184f9e6ea 100644 --- a/source/games/duke/src/premap_r.cpp +++ b/source/games/duke/src/premap_r.cpp @@ -387,7 +387,7 @@ void cacheit_r(void) DukeSectIterator it(§); while (auto act = it.Next()) { - if(act->spr.xrepeat != 0 && act->spr.yrepeat != 0 && (act->spr.cstat & CSTAT_SPRITE_INVISIBLE) == 0) + if(act->spr.ScaleX() != 0 && act->spr.ScaleY() != 0 && (act->spr.cstat & CSTAT_SPRITE_INVISIBLE) == 0) cachespritenum(act); } } diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index 7153e574b..b9f6bebad 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -1211,7 +1211,7 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj) break; case FORCESPHERE: - targ->spr.xrepeat = 0; + targ->spr.SetScaleX(0); if (targ->GetOwner()) { targ->GetOwner()->temp_data[0] = 32; @@ -1364,7 +1364,7 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj) { if (badguy(targ) == 1) { - if (isWorldTour() && targ->spr.picnum == FIREFLY && targ->spr.xrepeat < 48) + if (isWorldTour() && targ->spr.picnum == FIREFLY && targ->spr.ScaleX() < 0.75) break; if (proj->spr.picnum == RPG) proj->spr.extra <<= 1; @@ -1413,7 +1413,7 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj) ChangeActorStat(targ, 1); targ->timetosleep = SLEEPTIME; } - if ((targ->spr.xrepeat < 24 || targ->spr.picnum == SHARK) && proj->spr.picnum == SHRINKSPARK) return; + if ((targ->spr.ScaleX() < 0.375 || targ->spr.picnum == SHARK) && proj->spr.picnum == SHRINKSPARK) return; } if (targ->spr.statnum != 2) @@ -1458,7 +1458,7 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj) } } - if (targ->spr.xrepeat < 24 && proj->spr.picnum == SHRINKSPARK) + if (targ->spr.ScaleX() < 0.375 && proj->spr.picnum == SHRINKSPARK) return; auto hitowner = targ->GetHitOwner(); diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index 2a090daf8..0a4f3e719 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -2228,7 +2228,7 @@ void checkhitsprite_r(DDukeActor* targ, DDukeActor* proj) break; case FORCESPHERE: { - targ->spr.xrepeat = 0; + targ->spr.SetScaleX(0); auto Owner = targ->GetOwner(); if (Owner) { diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index 92ae7b3eb..114c19fa6 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -129,7 +129,7 @@ public: void setClipDistFromTile() { - clipdist = MulScale(spr.xrepeat, tileWidth(spr.picnum), 7) * 0.25; + clipdist = spr.ScaleX() * tileWidth(spr.picnum) * 0.125; } };