IstTimerExpired question?

Started by piraatlife4me, Tue 23/12/2003 21:03:53

Previous topic - Next topic

piraatlife4me

Hello Ags forums! I am in need of some serious help.  I have been playing around with this and am not getting anywhere. My question is about putting the IsTimerExpired function in the repeatedley execute script.  In my game I have a part where the player uses a cark ey inventory item on itself a car alarm  goes off and a valet parking guy leaves his post to go shut it off.  I have a global int set up so the alarm will only go off if the player is in that room.  I have all the actions set up in the global script under an inventory interaction script.  I imported and exported all of my needed varaiables and put a SetTimer(1,1000); command in the code after the alarm is set, and I set up a variable so if the player does it again the valet attendent will say something else like "Not Again", .  The problem I am having is when the alarm goes off the parking attendent  moves where I want him to but the alarm never stops, he just stays there.  But if I leave the room he will be back where he started and if I try to do it the game won't run the other speech options I made, he just says and says the same thing.  Does anything look weird with this code here:


function room_e() {
 // script for room: Repeatedly execute

if (GetGlobalInt(22) == 1) {
 Wait(20);
 FaceLocation(PARK, 150, 1000);
 Wait(8);
 DisplaySpeech(PARK, "It stopped!");
 Wait(5);
 DisplaySpeech(PARK, "It's about time");
 Wait(15);
 AnimateObjectEx(0, 0, 4, 0, 0, 1);
 SetCharacterBaseline(PARK, 145);
 fetch_alarm = 0;
 SetGlobalInt(22, 0);
 }
if (IsTimerExpired(1)==1) {
  StopAmbientSound(1);
  SetGlobalInt(22, 1);
  cli_board = 0;
  }
}


This is in my room script:

// room script file

int go_away = 0;
import int cli_board;
import int fetch_alarm;





This is what I have in my global script:

/ main global script file

int fetch_alarm = 0; //tests how many times knox sets off the
int cli_board = 0;

function character0_j() {  
           // script for character0:Useinventory on character  
Wait(5);
FaceLocation(EGO, 150, -1000);
Wait(20);
FaceLocation(PARK, 150, 1000);
if (GetGlobalInt(22) == 1) {
 FaceLocation(EGO, 150, 1000);
 Wait(8);
 DisplaySpeech(EGO, "I already set it off!");
 Wait(5);
 DisplaySpeech(EGO, "Are you deaf? What's the matter you can't hear the alarm!");
}
if (GetGlobalInt(16) == 0) {
FaceLocation(EGO, 150, 1000);
Wait(5);
DisplaySpeech(EGO, "I clicked the button and nothing happened?");
}
else if ((GetGlobalInt(16) == 1) || (fetch_alarm == 0)) {  
 PlayAmbientSound(1, 3, 250, 105, 129);
 SetCharacterIdle(PARK, 0, 2);
 Wait(20);
 if (fetch_alarm == 0) {
 Wait(20);
 DisplaySpeech(PARK, "Oh Great!");
 Wait(8);
 DisplaySpeech(PARK, "A squirrel must have set off the alarm!");
 Wait(10);
 DisplaySpeech(PARK, "I guess I will have to go check it out!");
 }
 else if (fetch_alarm == 1) {
 Wait(20);
 DisplaySpeech(PARK, "Not Again!");
 Wait(8);
 DisplaySpeech(PARK, "It must be the wind!");
 Wait(5);
 DisplaySpeech(PARK, "Hmmmmm....!");
 Wait(10);
 DisplaySpeech(PARK, "Strong Wind!");
 }
 else if (fetch_alarm == 2) {
 Wait(20);
 DisplaySpeech(PARK, "This is getting old...");
 Wait(8);
 DisplaySpeech(PARK, "FAST!");
 Wait(8);
 DisplaySpeech(PARK, "Now how do I turn it off last time.");
 }
 else if (fetch_alarm < 2) {
   fetch_alarm += 1;
 }    
 AnimateObjectEx(0, 0, 4, 0, 0, 1);
 SetCharacterBaseline(PARK, 145);
 ccExecuteCommand(PARK, 24);
 SetTimer(1,1000);
 cli_board = 1;
 SetGlobalInt(22, 1);
 fetch_alarm = 12;
 }
}
export cli_board;
export fetch_alarm;


Does this make any sense at all what I am doing wrong? Please let me know thanks!

Daniel
Winebarger

Pumaman

It's probably some sort of complication with the way you're using the CCS plugin. Could you post what your CCS Command 24 contains so we can see what it's trying to do?

piraatlife4me

#2
Hey Pumaman,
Sure, I did'nt even think about posting that, I think there just maybe something wrong with this.  

In my global script:

ccCreateCommand
(24,   "WAIT:30;VIEW:126;MOVE:109,139;VIEW:142;WAIT:35;ANIMATE:142,0,7,1;
WAIT:15;VIEW:126;MOVE:131,87;WAIT:20;MOVE:77,109;WAIT:30;MOVE:121,154;
WAIT:35;MOVE:77,109;VIEW:126;");    //valet parking guy leaving his post

I just need a command running in the background so it dosent pause the game.  All this is a command moving the NPC back to where he originally was, after the timer expires.

Does this look ok to you ? Or is this completely off?
Any suggestions that would help me out?
Thanks alot for your time.

Daniel
Winebarger


[edited to fix line width]

Pumaman

It could well be a problem with CSS interfering with what your script is trying to do - might be worth asking Scorpiorus about this because I'm not sure how CCS works.

Scorpiorus

#4
hmm, the sound should be stopped only after 1000 game loops. Is it supposed to play so long?


also try the next

if (IsTimerExpired(1)==1) {
Display("Ambiet Stopped");
StopAmbientSound(1);
//SetGlobalInt(22, 1);
cli_board = 0;
}

is it get triggered at all?


Also, you interfering CCS command which is already being executed, try to pause the action for a awhile:

if (GetGlobalInt(22) == 1) {
ccPauseExecution(PARK);
Wait(20);
FaceLocation(PARK, 150, 1000);
Wait(8);
DisplaySpeech(PARK, "It stopped!");
Wait(5);
DisplaySpeech(PARK, "It's about time");
Wait(15);
AnimateObjectEx(0, 0, 4, 0, 0, 1);
SetCharacterBaseline(PARK, 145);
fetch_alarm = 0;
SetGlobalInt(22, 0);
ccResumeExecution(PARK);
}

Any advances?

piraatlife4me

Hey Scorpious, how are you doing? It's Dan here again here to bore you with yet another problem of mine.  Yeah unfortunitely no, nothing happens.  I can't seem to figure out why either.  I took out all the confusing stuff out of  my code and just had a timer set and that stilll would'nt work.  I think it has something to do with the fact that the Istimerfunction is not responding to the SetTimer that is placed in the global script. I don't know though that is my only guess.  I tried both options that you suggested but still nothing.  Do you have any other ideas, or suggestions maybe?  Thanks man once again I really appreciate it.

a-v-o

How often is "IsTimerExpired(1)" in your room script and in your global script?

If it's more than once, then this could be the problem (see http://www.agsforums.com/yabb/index.php?board=2;action=display;threadid=10554)

Scorpiorus

Yeah, if it doesn't even display a message you probably catch the timer-expired-event somewhere else. As a-v-o pointed out in another thread, IsTimerExpired returns 1 only once. If you are not sure where else IsTimerExpired(1) is run, try testing with another timer (say number 19):

SetTimer(19, 1000);

if (IsTimerExpired(19)) {
.....
}

piraatlife4me

Hey Scoropius! it's me Dan once again.  I hate to say this but I am still not getting anywhere.  I have tried a bunch of different things, and taken a bunch of things out for now to find the source of the problem.  This is what I have as of right now.

In my global script:


function character0_j() {
 // script for character0: Use inventory on character  

Wait(5);
FaceLocation(EGO, 150, -1000);
Wait(20);
FaceLocation(PARK, 150, 1000);
if (GetGlobalInt(22) == 1) {
 FaceLocation(EGO, 150, 1000);
 Wait(8);
 DisplaySpeech(EGO, "I already set it off!");
 Wait(5);
 DisplaySpeech(EGO, "Are you deaf? What's the matter you can't hear the alarm!");
}
if (GetGlobalInt(16) == 0) {
FaceLocation(EGO, 150, 1000);
Wait(5);
DisplaySpeech(EGO, "I clicked the button and nothing happened?");
}
else if (GetGlobalInt(16) == 1) {
 PlayAmbientSound(1, 3, 250, 105, 129);
 SetCharacterIdle(PARK, 0, 2);
 SetCharacterBaseline(PARK,0);
 SetObjectBaseline(0,142);
 Wait(20);
 if (fetch_alarm == 0) {
 Wait(20);
 DisplaySpeech(PARK, "Oh Great!");
 Wait(8);
 DisplaySpeech(PARK, "A squirrel must have set off the alarm!");
 Wait(10);
 DisplaySpeech(PARK, "I guess I will have to go check it out!");
 }
  if (fetch_alarm == 1) {
 Wait(20);
 DisplaySpeech(PARK, "Not Again!");
 Wait(8);
 DisplaySpeech(PARK, "It must be the wind!");
 Wait(5);
 DisplaySpeech(PARK, "Hmmmmm....!");
 Wait(10);
 DisplaySpeech(PARK, "Strong Wind!");
 }
  if (fetch_alarm == 2) {
 Wait(20);
 DisplaySpeech(PARK, "This is getting old...");
 Wait(8);
 DisplaySpeech(PARK, "FAST!");
 Wait(8);
 DisplaySpeech(PARK, "Now how do I turn it off last time.");
 }
 if (fetch_alarm < 2) {
   fetch_alarm += 1;
 }    
 AnimateObjectEx(0, 0, 4, 0, 0, 1);
 SetTimer(19,250);
 ccExecuteCommand(PARK, 24);
 cli_board = 1;
 SetGlobalInt(22, 1);
 fetch_alarm = 12;
 }
}

export cli_board;
export fetch_alarm;



In my room script:

if (IsTimerExpired(19)==1) {
  StopAmbientSound(1);
 
  }
}

I took a bunch of stuff out to see what maybe wrong but this what I have and for some reason it juast dosen't want to go.  Is there anything odd about this?  Should I change anything?  Also how many actual seconds would SetTimer(19,200); be?


Scorpiorus

ok, first of all can you disable CCS plugin? See if it helps. I've just tested CCS myself and the timers worked for me fine, moreover they are not related to the plugin but just in case.

also make sure the script isn't blocked by a blocking function (it shouldn't be actually as you use CCS)

try building room's repeatedly interaction from scratch (via interaction editor) and place the if(istimerexpired(19)) checking there:

Display("room's repeatedly is called"); //comment it out if it works fine to test the timer.
if (IsTimerExpired(19)==1) {
Display("timer works");
StopAmbientSound(1);

}
}


QuoteAlso how many actual seconds would SetTimer(19,200); be?
Assuming you are running at standart 40fps speed it's about 200/40 = 5 seconds.

piraatlife4me

Hey Scorpious.  I did it I finally got it to work!  Yes you were right the problem was there was nothing in the interactions editor for repeat exe.  I was thrown completely off because in my room script I said I had a specified function for this.  When I checked the interaction editor there was nothing, my answer was right in front of me the untire time.  Well thanks once again man(What is this like the tenth time now you've saved me?)
Thanks one more time.
Daniel
Winebarger


Scorpiorus

I'm glad you solved it. :)
You see, it's a very confusing obstacle - you have a repeatedly execute function in your room script and you are sure it's called while in reality it's not. You may want to take a look at that thread http://www.agsforums.com/yabb/index.php?board=10;action=display;threadid=5376 where I (a bit roughly) described that stuff. ;)


~Cheers

SMF spam blocked by CleanTalk