How do I cause a delay without the wait cursor coming up?

Started by ESGmaster, Fri 27/02/2009 03:27:24

Previous topic - Next topic

ESGmaster

I'm working on a combat system, I have the animation working with repeatly execute, but when I have the player's health - 10 on it I end up with health ending up in the
-thousands, I havn't gotten the death when reaching 0 yet, I think players won't like dying in 0.10 seconds.

Gilbert

Use a timer or a incrementing variable to do actions every specified numbers of game loops. You may try to read about timers in the manual first. If you can't manage to make some working codes, just post with more details on what you actually want and we'll see if we can help.

ESGmaster

I belive that will work expest it says it needs a ( on line 17 but there's already one. Sorry, but I am very bad at coding.
9 function room_RepExec()
10 {
11 if  (TGP_Gangsters > 0)
12    {
13    cGANGTGP1.Animate (4, 3, eRepeat, eNoBlock, eForwards);
14    cGANGTGP2.Animate (4, 3, eRepeat, eNoBlock, eForwards);
15    SetTimer (1, 220);
16    }
17    if (IsTimerExpired);
18    Player_Health = Player_Health - 10;
19    SetTimer (1, 220);
20    Display ("Ouch, Hurry the hell up");
21 } 
}

Gilbert

#3
The semi-colon ; in line 17 has to be changed to an open curly brace { .


Also, as I am not sure about the excact scenario you want I cannot say it 100%, but I think the codes will probably not work, as it seems the game game will constantly reseting the timer as long as TGP_Gangsters  is still positive (as I don't know how TGP_Gangsters is actually updated in the script I'm not so sure though).

ESGmaster

That works fine, but it still says it needs a ( on line 17, and on the combat the whenever the player kills one of the gangster the TGP_Gangsters is lowered by one.
if  (TGP_Gangsters > 0)
    {
    cGANGTGP1.Animate (4, 3, eRepeat, eNoBlock, eForwards);
    cGANGTGP2.Animate (4, 3, eRepeat, eNoBlock, eForwards);
    SetTimer (1, 220);
    }
    if bool IsTimerExpired (1, timer1){
    Player_Health = Player_Health - 10;
    SetTimer (1, 220);
    Display ("Ouch, Hurry the hell up");
   


Gilbert

Should be like this (I missed that when I first read your code):

Code: ags

if  (TGP_Gangsters > 0) {
    cGANGTGP1.Animate (4, 3, eRepeat, eNoBlock, eForwards);
    cGANGTGP2.Animate (4, 3, eRepeat, eNoBlock, eForwards);
    SetTimer (1, 220);
}
if (IsTimerExpired (1)){
    Player_Health = Player_Health - 10;
    SetTimer (1, 220);
    Display ("Ouch, Hurry the hell up");
} 


1. The condition in a if clause must be enclosed by a pair of ().
2. IsTimerExpired is a function, so there must also be a pair of () following it. Also, this function takes exactly one parameter, so you need to put that in as well. Read the manual entry for more details.

ESGmaster

Thank you, it's not fun having combat in a game without risk of injury, and it's not fun having combat with instant death.

SMF spam blocked by CleanTalk