Thanks a lot! That's it!
In case anyone needs something similar, here's the code I eventually came up with. The changes to the initial version, apart from the key change advised by Player701, are: assignment of the current state to "PrevState" of course had to be moved to after the condition; and typecasting was unnecessary, it works without it. Also I added a condition to exclude Death and Pain states, so that their animation has the unchanged speed.
Code: Select all
class Hastener : Inventory
{
Default
{
Inventory.Amount 1;
Inventory.MaxAmount 1;
}
State PrevState;
override void Tick()
{
if (owner.CurState != PrevState)
{
if (owner.InStateSequence(owner.CurState, owner.ResolveState("Death")) == false && owner.InStateSequence(owner.CurState, owner.ResolveState("Pain")) == false)
owner.tics = (owner.tics + 1)/2;
}
PrevState = owner.CurState;
super.Tick();
}
}