Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: GameMaker_95 on Sat 07/02/2015 10:56:38

Title: Timer to complete action or else?
Post by: GameMaker_95 on Sat 07/02/2015 10:56:38
Hi

Okay, so I would like to create an end sequence to my game where the character enters a room and the bad guy
is walking towards a door and you need to go into your inventory and click on the gun and aim it at the bad guy or
else he will get away. I'd like it to be timed so you have only a set time to do this or he will walk away.
If it can't be done I will settle for scripting a cut scene but I just wanted to try this first.
Any help would be greatly appreciated.

Thanks.


Title: Re: Timer to complete action or else?
Post by: NickyNyce on Sat 07/02/2015 11:06:39
https://m.youtube.com/watch?v=r3w5TI7_a2g

I'm on my phone, and I hate typing with it, so I'll place this here to get you started.
Title: Re: Timer to complete action or else?
Post by: GameMaker_95 on Sat 07/02/2015 11:17:07
Hi NickyNyce

I watched the video and I believe I now have a good Idea of how to script the scenario. Thank you
for providing the link.


Title: Re: Timer to complete action or else?
Post by: GameMaker_95 on Sat 07/02/2015 11:56:58
Okay, I have the timer sorted but how do I make it if,else for getting the gun from the inventory and moving the cursor
over the character before the time runs out and the else happens?

Thanks
Title: Re: Timer to complete action or else?
Post by: NickyNyce on Sat 07/02/2015 12:11:42
You can set the timer in AfterFadeIn. Time it so that it takes so many seconds to where when your character reaches the door, the timer will expire. In Repeatedly Execute check if the timer is expired.

Code (ags) Select
function room_AfterFadeIn()
{
  SetTimer(1, 300);
}


Code (ags) Select
function room_RepExec()
{
  if(IsTimerExpired(1))
  {
    cBadguy go in the door...You lose
    //Yada yada yada
    //load last save
  }
}


If you use the gun on the badguy....

Code (ags) Select
function cBadguy_UseInv()
{
  if(cChar.ActiveInventory==iGun)
  {
    cChar.FaceCharacter(cBadguy);
    cChar.Say("Die Mo$#%er Fu$%er.      ");
    //show Badguy dying
    //You saved the world...Yada yada yada
  } 
}


But now you have me thinking. If you use the walk command for your Badguy, that would be blocking. And this is exactly why I should not be posting.  :X
Title: Re: Timer to complete action or else?
Post by: GameMaker_95 on Sat 07/02/2015 12:21:17
Thanks Nicky

I will work on this tomorrow and see if I can do it, it's getting late. Thanks again.
Title: Re: Timer to complete action or else?
Post by: NickyNyce on Sat 07/02/2015 12:26:19
Don't thank me yet. I have a feeling you're about to run into a problem as I mentioned above.
Title: Re: Timer to complete action or else?
Post by: GameMaker_95 on Sat 07/02/2015 12:28:09
I'll let you know.
Title: Re: Timer to complete action or else?
Post by: GameMaker_95 on Sun 08/02/2015 00:21:49
Hi Nicky

It worked perfectly for what I wanted, no problems.

Thanks again for your help, appreciate it.
Title: Re: Timer to complete action or else?
Post by: Julius Dangerous on Fri 03/07/2015 14:15:25
Thanks NickyNyce! :)