Hey all,
Sorry about the potentially confusing title, but I have a strange issue and am not sure how to get around it.
Unable to change the idle animation delay for a character (that I am aware of) and needing to do this, I adapted the following piece of code to have my character run an idle animation at the delay I wished. It is in repeatedly execute:
if (IsTimerExpired (1) == 1 && GetGlobalInt(11)==1 && GetGlobalInt(16)==0) {
cBoy.LockView(19);
cBoy.Animate(0, 1, eOnce, eBlock, eForwards);
cBoy.Animate(3, 4, eOnce, eNoBlock, eForwards);
SetTimer (1, GetGameSpeed()*15);
}
else if (IsTimerExpired (1) == 1 && GetGlobalInt(11)==1 && GetGlobalInt(16)==1) {
cBoy.LockView(26);
cBoy.Animate(5 , 1, eOnce, eBlock, eForwards);
cBoy.Say("y hallo thar");
SetTimer (1, GetGameSpeed()*15);
}
else if (cBoy.Animating == 0 && GetGlobalInt(11)==1) { // i.e. won't run during idle anim
cBoy.UnlockView();
}
This all works fine and dandy until GlobalInt(16) = 1. At this point, nothing occurs.
Is there something I missed here? I thought it might be the timer needing to be reset, which I tried, but this didn't seem to fix anything. Just for notes: GlobalInt(11) is to make sure the player is in the room, because having a blocking animation running in another room is not good :). GlobalInt(16) is when the character is no longer holding an item, therefore the idle animation needs to be different.
Thankyou in advance for your help :).
Couldn't you adjust the character.AnimationSpeed?
And you might want to use
if (player.Room==cBoy.Room)
instead of GlobalInt 11.
I'm not sure, but I think the second block won't ever get run because the timer is placed in an off state after you check it.
If I'm right this should fix it:
if (IsTimerExpired (1) == 1 && GetGlobalInt(11)==1) {
if (GetGlobalInt(16)==0) {
cBoy.LockView(19);
cBoy.Animate(0, 1, eOnce, eBlock, eForwards);
cBoy.Animate(3, 4, eOnce, eNoBlock, eForwards);
SetTimer (1, GetGameSpeed()*15);
}
else {
cBoy.LockView(26);
cBoy.Animate(5 , 1, eOnce, eBlock, eForwards);
cBoy.Say("y hallo thar");
SetTimer (1, GetGameSpeed()*15);
}
}
Ah, how interesting. I was unaware that the timer would be placed in an off state here.
Nevertheless, your solution works, and I am most grateful :D.
IsTimerExpired
IsTimerExpired (int timer_id)
Checks whether the timer TIMER_ID has expired. If the timeout set with SetTimer has elapsed, returns 1. Otherwise, returns 0.
Note that this function will only return 1 once - after that, the timer is placed into an OFF state where it will always return 0 until restarted.
Ah, of course, this makes plenty of sense as to why it wouldn't work for the second animation.
Thanks for clarification :).