Before I complete reinventing the wheel, I would like to ask if there is a "simple" way to add dynamic speed for player attacks. Originally, i used a ton of "A_SetTics" that called an ACS script that calculated the amount of tics to adjust. The obvious problem was the rounding error, even a slight increase to the speed would either give no bonus or extreme bonus.
As such, i wanted to move away from the A_SetTics + ACS combo.
The question is, is there an "easy" way to do so in ZScript?
The best i got to (before i discontinued in favor of working on other content), is an inventory item that controls frames of the currently equipped weapon:
Code: Select all
override void DoEffect()
{
Super.DoEffect();
if (Owner)
{
let psp = Owner.player.FindPSprite(PSP_WEAPON);
let pp = Owner;
if (psp)
{
int CurSpeed = LastSpeed + GetSpeedMod();
CurSpeed = CurSpeed - 100;
while (CurSpeed <= -100 || CurSpeed >= 100)
{
if (CurSpeed <= -100)
{
psp.Tics++;
pp.Tics++;
CurSpeed = CurSpeed + 100;
}
if (CurSpeed >= 100)
{
psp.Tics--;
if (pp.InStateSequence(pp.CurState, pp.ResolveState("Missile")))
{
if (pp.Tics > 0)
pp.Tics--;
}
CurSpeed = CurSpeed - 100;
if (!psp.Tics) psp.SetState(psp.CurState.NextState);
}
}
LastSpeed = CurSpeed;
}
}
}
virtual int GetSpeedMod()
{
int BaseSpeedMod = 100;
if (Owner.CountInv("SlowSpellEffect"))
{
BaseSpeedMod = BaseSpeedMod - 250;
}
if (Owner.CountInv("PowerHaste"))
{
BaseSpeedMod = BaseSpeedMod + 250;
}
if (BaseSpeedMod < -75)
{
BaseSpeedMod = -75;
}
return BaseSpeedMod;
}
Is this a good way? Is there a better way? Will the code conflict with A_SetTics? Would i be able to get information to "not adjust" the time of a specific frame?