A Script to randomly create an event near a player

Hi there,

I'm looking for a plugin (this can be paid-for) that creates an event 15 blocks away from the player, and then begins to 'walk' slowly towards the player. If the player goes over 15 blocks away, the event de-spawns and then waits until it re-triggers (again randomly) to do the same thing.

Essentially, I want to use it to scare the player 🙂
I'd say you can do that just fine with events, only.
Could you possibly explain how you would do it?
By

1. generating random number from 0-15 and store it to variable, lets say variable X then subtract 15 with var X and store it to var Y. This way you have X and Y difference that always sum 15.

2. Generate random 0-1, when 0, multiply var X with -1. Do same step with var Y.

3. I'm sure you can check tile passability on using event or maybe using event script call. Wrap the step 1 & 2 to loop, and when coordinate (player x + var x), (player y + var y) is passable and there's no other event exist on that coordinate, break the loop.

4. set your event move route towards player. thats easy.

thats the basic algorithm I could think. I've no idea about check pathfinding so event would stuck above the cliff or something.

hope this could help
Sorry, a little confused - this would be a JS plugin right? I've never codes JS before so wouldn't have the first clue where to start 🙁
steps I explained above meant to be used on event page.

If you don't need to consider passability (i.e. your enemy event is ghost or flying demon) I could show you a screenshot setup or maybe a demo this night.
If you could show a screenshot that would be great ... passability isn't too much of a problem on the map.
Hi there,

I'm looking for a plugin (this can be paid-for) that creates an event 15 blocks away from the player, and then begins to 'walk' slowly towards the player. If the player goes over 15 blocks away, the event de-spawns and then waits until it re-triggers (again randomly) to do the same thing.

Essentially, I want to use it to scare the player 🙂
What do you mean by the words i set to bold?

15 blocks away from what? From your event that chase player, from your player's coordinate when that chasing event started to spawn, or from something else?
OK here's a rewrite of it ... should make more sense ...

Around each of the maps I will be using the Region Markers to note where the enemy will be able to spawn. If the player goes within 15 blocks of those markers then it randomly decides whether to spawn the event or not. It is weighted more on the 'no' side than anything else - so its rare for the enemy to spawn.

If the player goes more than 20 blocks away from the region marker, then the event de-spawns and everything resets. 

Overall there will be 100 to 200 of these markers based around the various maps.

I hope that makes a little more sense! 😛
Well, that's a little bit more complex than I thought since you will need to calculate distance from that region.

Right now, I've done basic setup and need several common events to make it done and modular (able te be called from multiple maps). Actually it could be done with 1 common event but I like to break it down to several events so it's easier for me to find and edit things.

My advice, a plugin might be more easier approach 😛

Anyway, I can't stop laughing when trying to evade the chasing event that always spawn randomly.

🤣   🤣   🤣
Yeah I bet it looks very weird, could you show me how you've achieved it - maybe via screenshots? I'd be endebted forever!
OK, as an update i've managed to figure this out without using further plugins ... so we place an event on the floor that the player can walk over (first screenshot) - this generates a random number and then if that number matches a specified number (and the script isn't already running) it moves the event to where it needs to be and turns on the self switch.

Screen Shot 2015-12-12 at 13.49.43.png

 

The self-switch turns on a graphic and then begins following the player, after 6 seconds it turns the switch off and deletes itself ready for another switch to possibly re-activate it

 

Screen Shot 2015-12-12 at 13.49.56.png

Screen Shot 2015-12-12 at 13.49.43.png

Screen Shot 2015-12-12 at 13.49.56.png

Original thread: https://forums.rpgmakerweb.com/threads/a-script-to-randomly-create-an-event-near-a-player.52659/