ticrate fixes in zscript

This commit is contained in:
Ricardo Luís Vaz Silva 2022-12-22 17:47:53 -03:00 committed by Rachael Alexanderson
parent 9376c4deb4
commit 4eb1f57a4b
19 changed files with 58 additions and 55 deletions

View file

@ -86,7 +86,7 @@ class Actor : Thinker native
const LARGE_MASS = 10000000; // not INT_MAX on purpose
const ORIG_FRICTION = (0xE800/65536.); // original value
const ORIG_FRICTION_FACTOR = (2048/65536.); // original value
const DEFMORPHTICS = 40 * TICRATE;
//const DEFMORPHTICS = 40 * TICRATE;
const MELEEDELTA = 20;
@ -1146,8 +1146,8 @@ class Actor : Thinker native
native void A_FadeOut(double reduce = 0.1, int flags = 1); //bool remove == true
native void A_FadeTo(double target, double amount = 0.1, int flags = 0);
native void A_SpawnDebris(class<Actor> spawntype, bool transfer_translation = false, double mult_h = 1, double mult_v = 1);
native void A_SpawnParticle(color color1, int flags = 0, int lifetime = TICRATE, double size = 1, double angle = 0, double xoff = 0, double yoff = 0, double zoff = 0, double velx = 0, double vely = 0, double velz = 0, double accelx = 0, double accely = 0, double accelz = 0, double startalphaf = 1, double fadestepf = -1, double sizestep = 0);
native void A_SpawnParticleEx(color color1, TextureID texture, int style = STYLE_None, int flags = 0, int lifetime = TICRATE, double size = 1, double angle = 0, double xoff = 0, double yoff = 0, double zoff = 0, double velx = 0, double vely = 0, double velz = 0, double accelx = 0, double accely = 0, double accelz = 0, double startalphaf = 1, double fadestepf = -1, double sizestep = 0, double startroll = 0, double rollvel = 0, double rollacc = 0);
native void A_SpawnParticle(color color1, int flags = 0, int lifetime = DEFAULT_TICRATE, double size = 1, double angle = 0, double xoff = 0, double yoff = 0, double zoff = 0, double velx = 0, double vely = 0, double velz = 0, double accelx = 0, double accely = 0, double accelz = 0, double startalphaf = 1, double fadestepf = -1, double sizestep = 0);
native void A_SpawnParticleEx(color color1, TextureID texture, int style = STYLE_None, int flags = 0, int lifetime = DEFAULT_TICRATE, double size = 1, double angle = 0, double xoff = 0, double yoff = 0, double zoff = 0, double velx = 0, double vely = 0, double velz = 0, double accelx = 0, double accely = 0, double accelz = 0, double startalphaf = 1, double fadestepf = -1, double sizestep = 0, double startroll = 0, double rollvel = 0, double rollacc = 0);
native void A_ExtChase(bool usemelee, bool usemissile, bool playactive = true, bool nightmarefast = false);
native void A_DropInventory(class<Inventory> itemtype, int amount = -1);
native void A_SetBlend(color color1, double alpha, int tics, color color2 = 0, double alpha2 = 0.);

View file

@ -123,7 +123,7 @@ class Ironlich : Actor
{
mo.AddZ(-32);
mo.tracer = targ;
mo.health = 20*TICRATE; // Duration
mo.health = 20*GameTicRate; // Duration
A_StartSound ("ironlich/attack3", CHAN_BODY);
}
}

View file

@ -66,7 +66,7 @@ class PhoenixRod : Weapon
class PhoenixRodPowered : PhoenixRod
{
const FLAME_THROWER_TICS = (10*TICRATE);
//const FLAME_THROWER_TICS = (10*TICRATE);
private int FlameCount; // for flamethrower duration
@ -113,7 +113,7 @@ class PhoenixRodPowered : PhoenixRod
PhoenixRodPowered flamethrower = PhoenixRodPowered(player.ReadyWeapon);
if (flamethrower != null)
{
flamethrower.FlameCount = FLAME_THROWER_TICS;
flamethrower.FlameCount = (10*GameTicRate) /*FLAME_THROWER_TICS*/;
}
}
}

View file

@ -26,7 +26,7 @@ class Heresiarch : Actor
const SORCBALL_SPEED_ROTATIONS = 5;
const SORC_DEFENSE_TIME = 255;
const SORC_DEFENSE_HEIGHT = 45;
const BOUNCE_TIME_UNIT = (35/2);
//const BOUNCE_TIME_UNIT = (35/2);
const SORCFX4_RAPIDFIRE_TIME = (6*3); // 3 seconds
const SORCFX4_SPREAD_ANGLE = 20;
@ -453,7 +453,7 @@ class SorcBall : Actor
Actor mo = parent.SpawnMissileAngle("SorcFX4", ang1, 0);
if (mo)
{
mo.special2 = 35*5/2; // 5 seconds
mo.special2 = (gameTicRate * 5) /2; // 5 seconds
double dist = mo.DistanceBySpeed(dest, mo.Speed);
mo.Vel.Z = (dest.pos.z - mo.pos.z) / dist;
}
@ -532,7 +532,7 @@ class SorcBall : Actor
Vel.X = random[Heresiarch](-5, 4);
Vel.Y = random[Heresiarch](-5, 4);
Vel.Z = random[Heresiarch](2, 4);
args[4] = Heresiarch.BOUNCE_TIME_UNIT; // Bounce time unit
args[4] = (GameTicRate / 2) /*BOUNCE_TIME_UNIT*/;
args[3] = 5; // Bounce time in seconds
}
@ -553,7 +553,7 @@ class SorcBall : Actor
}
else
{
args[4] = Heresiarch.BOUNCE_TIME_UNIT;
args[4] = (GameTicRate / 2) /*BOUNCE_TIME_UNIT*/;
}
}
}
@ -608,7 +608,7 @@ class SorcBall1 : SorcBall
{
mo.target = parent;
mo.tracer = parent.target;
mo.args[4] = Heresiarch.BOUNCE_TIME_UNIT;
mo.args[4] = (GameTicRate / 2) /*BOUNCE_TIME_UNIT*/;
mo.args[3] = 15; // Bounce time in seconds
}
mo = parent.SpawnMissileAngle (cls, ang2, 0);
@ -616,7 +616,7 @@ class SorcBall1 : SorcBall
{
mo.target = parent;
mo.tracer = parent.target;
mo.args[4] = Heresiarch.BOUNCE_TIME_UNIT;
mo.args[4] = (GameTicRate / 2) /*BOUNCE_TIME_UNIT*/;
mo.args[3] = 15; // Bounce time in seconds
}
}
@ -823,7 +823,7 @@ class SorcFX1 : Actor
}
else
{
args[4] = Heresiarch.BOUNCE_TIME_UNIT;
args[4] = (GameTicRate / 2) /*BOUNCE_TIME_UNIT*/;
}
}
A_SeekerMissile(2, 6);

View file

@ -36,7 +36,7 @@ class Korax : Actor
const KORAX_COMMAND_HEIGHT = 120;
const KORAX_COMMAND_OFFSET = 27;
const KORAX_SPIRIT_LIFETIME = 5*TICRATE/5; // 5 seconds
//const KORAX_SPIRIT_LIFETIME = 5*TICRATE/5; // 5 seconds
Default
{
@ -226,7 +226,7 @@ class Korax : Actor
private void KSpiritInit (Actor spirit)
{
spirit.health = KORAX_SPIRIT_LIFETIME;
spirit.health = (5*GameTicRate/5) /*KORAX_SPIRIT_LIFETIME*/;
spirit.tracer = self; // Swarm around korax
spirit.WeaveIndexZ = random[Kspiritnit](32, 39); // Float bob index

View file

@ -1353,7 +1353,7 @@ class PowerTargeter : Powerup
let player = Owner.player;
PositionAccuracy ();
if (EffectTics < 5*TICRATE)
if (EffectTics < 5*GameTicRate)
{
let stat = FindState("Targeter");

View file

@ -128,7 +128,7 @@ extend class Actor
morphed.RenderStyle = RenderStyle;
morphed.Score = Score;
morphed.UnmorphTime = level.time + ((duration) ? duration : DEFMORPHTICS) + random[morphmonst]();
morphed.UnmorphTime = level.time + ((duration) ? duration : (40 * GameTicRate) /*DEFMORPHTICS*/) + random[morphmonst]();
morphed.MorphStyle = style;
morphed.MorphExitFlash = (exit_flash) ? exit_flash : (class<Actor>)("TeleportFog");
morphed.FlagsSave = bSolid * 2 + bShootable * 4 + bInvisible * 0x40; // The factors are for savegame compatibility

View file

@ -14,7 +14,7 @@ class PlayerPawn : Actor
{
const CROUCHSPEED = (1./12);
// [RH] # of ticks to complete a turn180
const TURN180_TICKS = ((TICRATE / 4) + 1);
//const TURN180_TICKS = ((TICRATE / 4) + 1);
// 16 pixels of bob
const MAXBOB = 16.;
@ -1250,7 +1250,7 @@ class PlayerPawn : Actor
if (player.turnticks)
{
player.turnticks--;
Angle += (180. / TURN180_TICKS);
Angle += (180. / ((GameTicRate / 4) + 1) /*TURN180_TICKS*/);
}
else
{
@ -1486,7 +1486,7 @@ class PlayerPawn : Actor
// [RH] Check for fast turn around
if (player.cmd.buttons & BT_TURN180 && !(player.oldbuttons & BT_TURN180))
{
player.turnticks = TURN180_TICKS;
player.turnticks = ((GameTicRate / 4) + 1) /*TURN180_TICKS*/;
}
// Handle movement

View file

@ -78,7 +78,7 @@ extend class PlayerPawn
}
if (InvSel) InvSel.DisplayNameTag();
}
player.inventorytics = 5*TICRATE;
player.inventorytics = 5*GameTicRate;
if (old != InvSel)
{
A_StartSound("misc/invchange", CHAN_AUTO, CHANF_DEFAULT, 1., ATTN_NONE);

View file

@ -120,7 +120,7 @@ extend class PlayerPawn
if (player.morphTics)
{ // Player is already a beast
if ((GetClass() == spawntype) && bCanSuperMorph
&& (player.morphTics < (((duration) ? duration : DEFMORPHTICS) - TICRATE))
&& (player.morphTics < (((duration) ? duration : (40 * GameTicRate) /*DEFMORPHTICS*/) - GameTicRate))
&& FindInventory('PowerWeaponLevel2', true) == null)
{ // Make a super chicken
GiveInventoryType ('PowerWeaponLevel2');
@ -192,7 +192,7 @@ extend class PlayerPawn
bUnmorphed = true;
bInvisible = true;
p.morphTics = (duration) ? duration : DEFMORPHTICS;
p.morphTics = (duration) ? duration : (40 * GameTicRate) /*DEFMORPHTICS*/;
// [MH] Used by SBARINFO to speed up face drawing
p.MorphedPlayerClass = spawntype;
@ -261,7 +261,7 @@ extend class PlayerPawn
{ // Didn't fit
altmo.bSolid = false;
bSolid = true;
player.morphTics = 2*TICRATE;
player.morphTics = 2*GameTicRate;
return false;
}

View file

@ -1,6 +1,6 @@
class Minotaur : Actor
{
const MAULATORTICS = 25 * TICRATE;
//const MAULATORTICS = 25 * TICRATE;
const MNTR_CHARGE_SPEED =13.;
const MINOTAUR_LOOK_DIST = 16*54.;
@ -223,7 +223,7 @@ class Minotaur : Actor
}
A_FaceTarget ();
VelFromAngle(MNTR_CHARGE_SPEED);
special1 = TICRATE/2; // Charge duration
special1 = GameTicRate/2; // Charge duration
}
else if (target.pos.z == target.floorz
&& dist < 9*64.
@ -396,7 +396,7 @@ class Minotaur : Actor
let mf = MinotaurFriend(self);
if (mf)
{
if (mf.StartTime >= 0 && (level.maptime - mf.StartTime) >= MAULATORTICS)
if (mf.StartTime >= 0 && (level.maptime - mf.StartTime) >= (25 * GameTicRate) /*MAULATORTICS*/)
{
DamageMobj (null, null, TELEFRAG_DAMAGE, 'None');
return;
@ -517,7 +517,7 @@ class Minotaur : Actor
// In case pain caused him to skip his fade in.
A_SetRenderStyle(1, STYLE_Normal);
if (mf.StartTime >= 0 && (level.maptime - mf.StartTime) >= MAULATORTICS)
if (mf.StartTime >= 0 && (level.maptime - mf.StartTime) >= (25 * GameTicRate) /*MAULATORTICS*/)
{
DamageMobj (null, null, TELEFRAG_DAMAGE, 'None');
return;
@ -628,7 +628,7 @@ class MinotaurFriend : Minotaur
// [RH] Minotaurs can't be morphed, so this isn't needed
//if (!(mo.flags&MF_COUNTKILL)) continue; // for morphed minotaurs
if (mo.bCorpse) continue;
if (mo.StartTime >= 0 && (level.maptime - StartTime) >= MAULATORTICS) continue;
if (mo.StartTime >= 0 && (level.maptime - StartTime) >= (25 * GameTicRate) /*MAULATORTICS*/) continue;
if (mo.tracer != null && mo.tracer.player == tracer.player) break;
}

View file

@ -56,8 +56,8 @@ class BridgeBall : Actor
// If the bridge is custom, set non-default values if any.
// Set angular speed; 1--128: counterclockwise rotation ~=1--180°; 129--255: clockwise rotation ~= 180--1°
if (target.args[3] > 128) rotationspeed = 45. / 32 * (target.args[3] - 256) / TICRATE;
else if (target.args[3] > 0) rotationspeed = 45. / 32 * (target.args[3]) / TICRATE;
if (target.args[3] > 128) rotationspeed = 45. / 32 * (target.args[3] - 256) / GameTicRate;
else if (target.args[3] > 0) rotationspeed = 45. / 32 * (target.args[3]) / GameTicRate;
// Set rotation radius
if (target.args[4]) rotationradius = ((target.args[4] * target.radius) / 100);

View file

@ -30,7 +30,7 @@ class SecurityCamera : Actor
Super.PostBeginPlay ();
Center = Angle;
if (args[2])
Delta = 360. / (args[2] * TICRATE / 8);
Delta = 360. / (args[2] * GameTicRate / 8);
else
Delta = 0.;
if (args[1])
@ -63,8 +63,8 @@ class AimingCamera : SecurityCamera
args[2] = 0;
Super.PostBeginPlay ();
MaxPitchChange = double(changepitch) / TICRATE;
Range /= TICRATE;
MaxPitchChange = double(changepitch) / GameTicRate;
Range /= GameTicRate;
ActorIterator it = Level.CreateActorIterator(args[3]);
tracer = it.Next ();

View file

@ -122,7 +122,7 @@ extend class Actor
{
if (Vel != (0,0,0) && !bShattering)
{
tics = 3*TICRATE;
tics = 3*GameTicRate;
return;
}
Vel = (0,0,0);

View file

@ -269,7 +269,7 @@ class PathFollower : Actor
bJustStepped = false;
if (CurrNode.args[2])
{
HoldTime = Level.maptime + CurrNode.args[2] * TICRATE / 8;
HoldTime = Level.maptime + CurrNode.args[2] * GameTicRate / 8;
SetXYZ(CurrNode.Pos);
}
}
@ -293,7 +293,7 @@ class PathFollower : Actor
if (Interpolate ())
{
Time += (8. / (max(1, CurrNode.args[1]) * TICRATE));
Time += (8. / (max(1, CurrNode.args[1]) * GameTicRate));
if (Time > 1.)
{
Time -= 1.;

View file

@ -207,7 +207,7 @@ class ProgLevelEnder : Inventory
{
if (special2 == 0)
{ // fade out over .66 second
special1 += 255 / (TICRATE*2/3);
special1 += 255 / (GameTicRate*2/3);
if (++special1 >= 255)
{
special1 = 255;
@ -217,7 +217,7 @@ class ProgLevelEnder : Inventory
}
else
{ // fade in over two seconds
special1 -= 255 / (TICRATE*2);
special1 -= 255 / (GameTicRate*2);
if (special1 <= 0)
{
Destroy ();

View file

@ -185,7 +185,7 @@ class Thinker : Object native play
static clearscope int Tics2Seconds(int tics)
{
return int(tics / TICRATE);
return int(tics / GameTicRate);
}
}

View file

@ -710,7 +710,10 @@ struct SystemTime
class Object native
{
const TICRATE = 35;
const DEFAULT_TICRATE = 35;
/*deprecated("4.11","Use GameTicRate instead")*/ const TICRATE = 35;
native bool bDestroyed;
// These must be defined in some class, so that the compiler can find them. Object is just fine, as long as they are private to external code.

View file

@ -3,13 +3,13 @@ class StrifeStatusBar : BaseStatusBar
{
// Number of tics to move the popscreen up and down.
const POP_TIME = (Thinker.TICRATE/8);
//const POP_TIME = (GameTicRate/8);
// Popscreen height when fully extended
const POP_HEIGHT = 104;
// Number of tics to scroll keys left
const KEY_TIME = (Thinker.TICRATE/3);
//const KEY_TIME = (GameTicRate/3);
enum eImg
{
@ -167,8 +167,8 @@ class StrifeStatusBar : BaseStatusBar
{
if (PopHeight < 0)
{
PopHeightChange = POP_HEIGHT / POP_TIME;
PopHeight += POP_HEIGHT / POP_TIME;
PopHeightChange = POP_HEIGHT / (GameTicRate/8) /*POP_TIME*/;
PopHeight += POP_HEIGHT / (GameTicRate/8) /*POP_TIME*/;
}
else
{
@ -184,19 +184,19 @@ class StrifeStatusBar : BaseStatusBar
}
else if (PopHeight > -POP_HEIGHT)
{
PopHeight -= POP_HEIGHT / POP_TIME;
PopHeight -= POP_HEIGHT / (GameTicRate/8) /*POP_TIME*/;
if (PopHeight < -POP_HEIGHT)
{
PopHeight = -POP_HEIGHT;
}
else
{
PopHeightChange = -POP_HEIGHT / POP_TIME;
PopHeightChange = -POP_HEIGHT / (GameTicRate/8) /*POP_TIME*/;
}
}
if (KeyPopScroll > 0)
{
KeyPopScroll -= 280 / KEY_TIME;
KeyPopScroll -= 280 / (GameTicRate/3) /*KEY_TIME*/;
if (KeyPopScroll < 0)
{
KeyPopScroll = 0;
@ -318,10 +318,10 @@ class StrifeStatusBar : BaseStatusBar
int flags = item.Amount <= 0? DI_ITEM_OFFSETS|DI_DIM : DI_ITEM_OFFSETS;
if (item == CPlayer.mo.InvSel)
{
DrawTexture (Images[CursorImage], (42 + TICRATE*i, 180), flags, 1. - itemflashFade);
DrawTexture (Images[CursorImage], (42 + GameTicRate*i, 180), flags, 1. - itemflashFade);
}
DrawInventoryIcon (item, (48 + TICRATE*i, 182), flags);
DrawString(mYelFont, FormatNumber(item.Amount, 3, 5), (75 + TICRATE*i, 191), DI_TEXT_ALIGN_RIGHT);
DrawInventoryIcon (item, (48 + GameTicRate*i, 182), flags);
DrawString(mYelFont, FormatNumber(item.Amount, 3, 5), (75 + GameTicRate*i, 191), DI_TEXT_ALIGN_RIGHT);
i++;
}
}
@ -388,13 +388,13 @@ class StrifeStatusBar : BaseStatusBar
{
if (item == CPlayer.mo.InvSel)
{
DrawTexture(Images[CursorImage], (-90+i*TICRATE, -3), DI_SCREEN_CENTER_BOTTOM, 0.75);
DrawTexture(Images[CursorImage], (-90+i*GameTicRate, -3), DI_SCREEN_CENTER_BOTTOM, 0.75);
}
if (item.Icon.isValid())
{
DrawInventoryIcon(item, (-90+i*TICRATE, -5), DI_SCREEN_CENTER_BOTTOM|DI_DIMDEPLETED, 0.75);
DrawInventoryIcon(item, (-90+i*GameTicRate, -5), DI_SCREEN_CENTER_BOTTOM|DI_DIMDEPLETED, 0.75);
}
DrawString(mYelFont, FormatNumber(item.Amount, 3, 5), (-72 + i*TICRATE, -8), DI_TEXT_ALIGN_RIGHT|DI_SCREEN_CENTER_BOTTOM);
DrawString(mYelFont, FormatNumber(item.Amount, 3, 5), (-72 + i*GameTicRate, -8), DI_TEXT_ALIGN_RIGHT|DI_SCREEN_CENTER_BOTTOM);
++i;
}
}
@ -456,7 +456,7 @@ class StrifeStatusBar : BaseStatusBar
if (KeyPopScroll > 0)
{
// Extrapolate the scroll position for smoother scrolling
int scroll = MAX (0, KeyPopScroll - int(TicFrac * (280./KEY_TIME)));
int scroll = MAX (0, KeyPopScroll - int(TicFrac * (280./(GameTicRate/3) /*KEY_TIME*/)));
pos -= 10;
leftcol = leftcol - 280 + scroll;
}