Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Randomly Call Event

JoshC

Member

I need a simple script that will wait for a random amount of time (the random amount of time is set-able within the script; i.e. rand(1min-3min)) then call an event on the map. Then reset itself to wait for that random period of time again. I need it so that I can change or reset the time from an event at will. And also make it so I can set an interval of randomness that the event will or will not be called.

An example application would be: Your running a town and every so often bandits will attack; or: Your on your farm and every so often wolfs will come to you farm and attack the chickens; etc.
 

JoshC

Member

First off please read the post before responding, I said I need it to be random, and unless there's a special random timer command I don't know about then the only other way IS a script. Secondly I asked for it to have a chance of success, and I'm still not seeing this invisible event command of randomness. Lastly I prefer to use scripts than events as it makes things more organized and reduces lag.

Although there is a way to make a random variable the problem is setting a timer to that variable, thus the need of a script.
 
JoshC, your answer to Croda was a bit rude, he did read all your request and simply proposed to do that with an event. It's all doable with events. And yes, there is a random variable option.

If you absolutely want to do that with a script, all you need to do is set your variable and the call these 2 lines:
Code:
 

$game_system.timer = $game_variables[variable_ID] * Graphics.frame_rate

$game_system.timer_working = true

 

Otherwise, make a common event as a parallel process and decrease your variable each 60 frames, or 40 on XP.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top