Timer to complete action or else?

Started by GameMaker_95, Sat 07/02/2015 10:56:38

Previous topic - Next topic

GameMaker_95

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.



NickyNyce

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.

GameMaker_95

#2
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.



GameMaker_95

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

NickyNyce

#4
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
function room_AfterFadeIn()
{
  SetTimer(1, 300);
}


Code: ags
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
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

GameMaker_95

Thanks Nicky

I will work on this tomorrow and see if I can do it, it's getting late. Thanks again.

NickyNyce

Don't thank me yet. I have a feeling you're about to run into a problem as I mentioned above.


GameMaker_95

Hi Nicky

It worked perfectly for what I wanted, no problems.

Thanks again for your help, appreciate it.

Julius Dangerous

___________________________________________________________

SMF spam blocked by CleanTalk