Random event location encounter.

Hello, while I am getting help with some other script problems I thought i'd ask if anyone here knows how I can achieve my little goal with random event locations.

Basically what I am after is that walking on the world map at very rare encounter rates triggers teleporting to a generic location ( reflecting on the locations terrain type preferably )

On the map I want exit events that return me to the location the event was encountered randomly. I think this has something to do with region ID or location ID etc which I do not understand entirely.

I do know you use terrain IDs to help with certain location monster encounters- but other than that I do not know of any scripts or whatever that can help achieve this goal.

Here is two screenshots of what I mean.

eIHZkle.png


As you can see on the map I have a standard invisible event that triggers teleporting to this random location room with the three men.

Of course after whatever business concludes here I want to walk to the map boarders to warp back to the previous location. Think Arcanum-Fallout 1-2.

Thank you.
   You need to use three variables to make this work. One to get the player's x position, one for y and one for the map id of the original map. To do this in the event that teleports you to the ambush site (before the transfer) go to "control variables/Game Data to find everything you need. (Player x,y is under "Character" Map id is under "other").

   Save these three numbers to designated variables and then transfer your player to the ambush site, after everything is done have your transfer back event set to "designate with variables" and input the three saved variables where appropriate to end up exactly where you left off before being transferred.
Very cool, I got that part working fine- however I do not know how to make this teleport to ambush event as like a random encounter you make with terrain ID.

Any ideas?
Bump
Actually you only need 1-2 events on the map to do this and no, you don't need a script for this.

Set up an event with no picture, set it to be "below the player", and set it to be "triggered by player touch" 

2, have this event moves randomly on the map either with move route or simply set it to move randomly.

Eg, Set the move route to Custom, then In the Move route editor,

[1] Use this script call: 

     @x,@y = rand(17),rand(13)

     #where 17 and 13 is the max x y position of your map. (This script call will move that event randomly to anywhere on the map. Trigger will not work when it's moving, so you don't have to worry that it cross path with the player during movement)

[2] After that, add a few random moves, this will ensure that the event randomly move around to allow the player to trigger it on the area it arrived.

[3] set repeat to on and ignore when unable to move to on. (after a few random moves, the event will move to a new random place on the map)

And On the Event's commands page:

[1] Set it to get the player's X Y and Map ID into variables (What Alexander said above)

[2] Set it to transfer the player to wherever you like

[3] Do the cut scene, and even battle, but make sure you do ALL in that one event. (you can move other events by force move route for cut scenes)

[4[ Then on the battle winning/losing condition, send the player back to where he was / game over
Works very nicely but touching the event and it's commands doesn't seem to work upon touch very often, also the commands sometimes triggers at areas far away from the event itself. I'm not sure if these are intended.

Do you know how I can also make a region ID act like a teleport?
Yes. The event is untouchable when it's moving to a new X Y on the map.

The event should trigger far away from the place you put it because it randomly move to anywhere on the map on its own. Is that not what you wanted?

And to make region ids acts like a teleport:

It will require a common event + a parallel map event i guess.

1st  Setup a map event on parallel, have it get the player's x y and put it into 2 variables

2nd Have the event check the x y (use the variable above, and use get map info) for region id.(put this into yet another variable eg, variable 3)

3rd Conditional Branch to check if Variable 3 == region ID X(just the number of the region id here) proceed with True and run the common event, else false and do nothing.

4th In the common event, do the map transfer and everything else, cut scene... battle... win/loss..

5th Paint your map with that region id, when the player steps on it, the parallel map event should trigger the common event.

P/S: You can do the common event part all in that one map event too if you want. but having it separated makes it easier to control/change for a developer.
Well originally I wanted terrain tags to do an event hand out I.e teleportation to a room with monsters/ But that proved difficult, the event that you have given me works and I love it-but I found it a bit strange how it functions

Are you saying that the event basically has a radius that if inside can randomly trigger the teleport?

Also is there a way I can make this event unable to traverse impossible terrain? Ticking ignore if cannot move OFF does not prevent the event from traversing water and other terrain you cannot traverse, also strangely it gets stuck in mountains sometimes.

I managed to to have it that the event recognizes the terrain it is on and teleports you to rooms that suit the landscape it was encountered on 🙂

So to put it short, I like how this works right now, my only worry now is having these events wander into the ocean and mountains that you as a player cannot traverse over-meaning that encountering these events rarity is even higher.

I'd like to restrict them onto the land masses if possible.

Sorry if I fail to make things clear.
Oops, so i finally get to understand what you want. 😛

The event by default simply randomly travel to anywhere on the map, not checking where it goes and moves a few steps randomly on the area it landed.

But when it landed in water/mountain/empty space where it can't move, it stays there until the next area move.

So yes, this makes it a rare encounter on a large map.

To make things easier, simply set the "random move" counts its custom route to 20~40 so it will make 20~40 steps before moving to a new location.

I gave the event settings a check(with a picture shown event) and it seems to be working fine, when it landed on a place it can't move(eg water/mountain) it will immediately move to a new X Y until it lands on an area it can move, then it will start the random move steps before doing another area move.

The question here now, is that you only want it to move to certain places marked with region id X right?

It will mean the event will stop area transfer and repeat the random moves until the next area move's random X Y = region id X.

This will means that the more random moves you put, the rarer it moves to a new area unless you have plenty of region id X all over the map. Is that ok for you?

If you are ok with that, change this the script call code i gave you earlier to 2 lines:

[1]1st line script call:

@nextX, @nextY = rand(17),rand(13)Where 17 and 13 is your map size

[2]2nd line script call: 

moveto(@nextX,@nextY) if $game_map.region_id(@nextX,@nextY) == 3Where 3 is the Region ID

edit: if you use this method, remember to set only a few random move in the custom route (1-2 max)

edit again: i just remember events will not update itself when offscreen (out side of screen). So it will wait there until it's in the screen again before doing its next move. That's the reason why you find it waiting in the mountain sometimes. You might need a script snippet to update that event during offscreen.

Try put this code somewhere in between Material and Main:

class Game_Event < Game_Character  alias mf_offscreen near_the_screen?  def near_the_screen?(dx = 12, dy = 8)    return true if @event.name.include?('<constant>')    mf_offscreen  endend

then put <constant> as a tag in the event's name you want it to move even when off screen.

Edit again:

Since i made a test project to test it out, i might just upload it for those who stumbles across this tread and wanted to know how it works.

Example 1 is a Cat with Constant Update, it moves instantly to a new location when the condition is true and can move during offscreen.

Example 2 is a Dog without Constant Update, it will only move when in screen, and moving using the slow "move along the screen" method.

Both Examples will move to the "Forest" tile on the map where it's tagged with Region 3

Download Link: Click Here
Paralell Common Event

variable1 = player map x

variable2 = player map y

get location info on variable1 and variable2 you can ask for Regions or Terrain Ids

Put the ID number in Variable 3 

Conditional Branch Variable3 = 1

your stuff....

end

(and or)

Conditional Branch Variable3 = 1

Conditional Branch Variable 3 not same as Variable4 (This makes sure a Tile just gets triggered once before entering another region, you could also implement that it just gets activatet every 5 to 10 steps on that region)

Control Variable4 = Variable3

Do your event stuff here......

end

Conditional Branch Variable3 = 2

Same as above

...
@ Meowface These will be extremely helpful, the demo also explains a lot further for me 😛

So with the demo at hand the cat event teleports on the region tag #3 on the trees and after a few random movements it teleports to another area? And so if the player moves around those tags and happens to come across the event it can trigger teleporting to a new room.

For a huge world map and only wanting specific events to occur on certain terrain tags I can just use this cat-like event for it?

For example random encounter events that teleport you to a room with say highway men can only be randomly encountered on roads etc marked with terrain tag 3? And if I wanted it to be more frequent I could add duplicates of this?

Also the lady event that contains all that variable and scripting, what is that for? I don't quite understand it because the variables seem vague and I can't decipher what they are there for.

@Bex

That execution there works very well, thanks alot for that 🙂
The answer is yes to all.

You can say,limit the range of Enemy Type A's teleportation to region 3, and Enemy Type B to region 4. A fun way to show them as they appears and disappear in certain areas. So you can do something like a hunting quest with only a hint on where they will appear, so your players will have to look everywhere on the map for them. 😀

And yes, duplicate as many as you like, just like you will do for normal events encounter type enemies.

They should only appear somewhere near the region tag they are limited to.

If you use it with my rogue-like movement script, you can even set the event to chase the player when the player is too near to the event. 😛

And if you want the event to work on water area only, you can try this water event script as well. it makes making water object and enemies much much easier.

As for for your other question, i was answering another question here on the forum on how to do numbers sorting for a leader board. And used the same project for the testing, forgot to delete her when i exported that. Sorry for the confusion caused.  🙁

Edit: I forgot that this event require its own custom move route. So the rogue-like script's chase will not work, it will simply set the event up with a "!" on it's head and speed up the event when the player is near. 😛
You can say,limit the range of Enemy Type A's teleportation to region 3, and Enemy Type B to region 4. A fun way to show them as they appears and disappear in certain areas. So you can do something like a hunting quest with only a hint on where they will appear, so your players will have to look everywhere on the map for them. 😀
That is a very handy tip there, at some point I'd like to have a side quest that could be for a zoological expedition for big game hunters 🙂

And yes, duplicate as many as you like just like you will do for normal events encounter type enemies if you want. They should only appear somewhere near the region tag they are limited to.
After many test rooms and tryouts they work VERY nicely, however when I went to try them out on the world map/oveworld the event that is supposed to do it's random course on region tags decided to not bother appearing at random when placed in water much like the demo has the cat positioned, I placed the cat event on land where it is meant to be encountered and it only wants to move randomly instead of teleporting and moving around randomly on it's tagged areas. I might be missing something but i have looked extensively and can't figure out this odd problem. I've emulated pretty much what you have here on the demo but I'm stuck at this point. The map by the way is 150x150 in size.

If you use it with my rogue-like movement script, you can even set the event to chase the player when the player is too near to the event. 😛

And if you want the event to work on water area only, you can try this water event script as well. it makes making water object and enemies much much easier.
This can be handy, at the moment I have a proximity script working for monsters and guards (still under event development) which acts in the same way sort of, but looking at it's contents with the default follow player engine it might have that spuratic random route path following events sometimes do? I am still very much working on this part because I plan to implement a prowling state to allow players who have leveled up in that area to have better chances avoiding detection yadda yadda haha.

Though the water script seems very good, I might need this in future, but at the moment I have no need for it because ships so far planned are going to be used as warp zones 🙂

As for for your other question, i was answering another question here on the forum on how to do numbers sorting for a leader board. And used the same project for the testing, forgot to delete her when i exported that. Sorry for the confusion caused.  🙁
Oh haha, I understand- I have a bulk load of events on maps that didn't even need it once. I just copied and pasted because I wanted to emulate it to the letter.
I placed the cat event on land where it is meant to be encountered and it only wants to move randomly instead of teleporting and moving around randomly on it's tagged areas. I might be missing something but i have looked extensively and can't figure out this odd problem.
That's because the "chance" of it being teleported to a new region rely on where the random roulette in its custom move route does a hit. So the more region tag you have the more chances of it doing an area move. Try paint not just 1 but a huge area with the region tag and you should see it in action. 😀 And make sure you don't set too much "random move" in between the script calls, because once the script call fail in its roulette, it will continue to run the random moves until the next script call, and do the roulette again until the x y in the roulette returns a true to tell the event, "the destination this time is region X, you can move there now."

Edit: And oh, don't forget to set the rand(10) to the x y size of your map, i have it on 10 in the demo for testing, so if your region is out of 10 x 10 in the map it won't teleport. To make it work for the whole map you will need to set the numbers correctly.

but looking at it's contents with the default follow player engine it might have that spuratic random route path following events sometimes do?
What the rogue-like script does is, set your enemy to either semi-transparent/fully transparent/no transparent(you get to set the opacity yourself) when the player is not in range, so you can easily make a hidden surprise attack.

When the player is in range, the script will then set the event to show itself with a "!" on it's head, and start chasing the player with a forced AI if the event's move route is set to move towards the player.(A chase that the player can never forget. lol!)

The AI switches between 3 mode, chase (go straight to player), normal (move toward player), 10 mas away (do normal random moves)

The most valuable point as so it seems, is the ability to set the event to move only when the player is moving(you can turn this off by a switch). So the event will not move until the player moves. 😛

The Water Events on the other hand, does nothing but reverse the move-able area between land and water. Water = where ships can travel. So it makes it really easy to make water object simply by using a name tag. (no other settings required)
Ahhh I understand it alot better now, if I run into something else I will let you know 🙂

Sounds like a nice script set you got there, I'll experiment and see what I can do 🙂

That water script could be increasingly helpful for pirate ships teleporting you to your deck at broadside being boarded, so you have to kill the captain and his crew and take his loot 😛
Pirates! Yes! That's what i did with mine too, lol! Encounter > Fight on Deck > Return to map with a random reward treasure box. 😛

But my battle is more on the SLG side since i modified the battle system based on LemonSlice's SRPG script. And having a whole bunch of ride-able events that has their own passability, water/land/forest/void etc. Hmm... How should i put it? A game engine with unlimited event vehicles? 😉 Not to mention i already have 8 system vehicles that works differently too. I ended up with a really really messy main code.  ;_;

Those codes i posted are a small part i've pulled from my main code, since i already have it working, and sharing it here doesn't take up too much time in the modifications. But to share those longer, messier codes, i'll need to think twice, since i am only here to help for a few days with my day off, so i am not looking forward to a long-term support.
Oh that sounds dank haha.

When I have my system going smoothly how I want it I'm going to upload a small demo, at the moment story and such is not set in motion but the engine itself and it's capabilities are running quite well.

My only main concern is if this hard work can be transferred on the new upcoming RPG Maker MV..

I always fancied grid type combat like Advance wars etc, much like you had mentioned. If I had it my way and the ability to do so I would lay it out like Fallout 1-2/ Arcanum style. Having an enviroment to actually battle on is so much more interesting that being slapped onto a background with not much else to offer.
Judging from the PV and the preview sites, nothing about rgss3 support is being said.

So from the previous RM releases, we will probably end up with rgss4 or even rgss5.

And it means it will require all the portings again.

The interface looks like old VX but using side view battle. And all the "updates" focused on map maker, easier tiling, automatically decide which tiles lay on top of which.. not a big feature for those who are already gotten too used to parallax mapping i guess.

The main selling point is it supports multi-platforms (android,ios,pc,mac), and the game interface works with mouse by default.

So basically, apart from the ease of multi-platform exporting, the current VX ace can do what it's offering with custom scripts or utilities(that exports XP/VX/VXace games to ios/linux etc).

This means you don't have to worry about moving to a new system to do your game. Even up till nowadays, a lot of developers still prefer XP for its flexibility. VX ace has way too many "hidden" code in its DLL, and with the TOS, we are not allowed to tinker with those. That's why we are stuck with 640x480 screen size, unless you don't care about the TOS rules and use a modified DLL to overcome that limit. Well, as far as i know, the heavily modified 3rd-party rgss3 player is half a 3D engine by its own. 😛

Edit:

And don't forget those modifications that allows mmo-like features in the old vx. lol!

But if i need to go as far as that for a game engine, i'll rather use unity to do what i want. 🙂
Oh undoubtedly. The main thing that annoyed me with VX/ACE was it's lack of effort put into the battle, the chubi art style is an instant dislike from me, I loved RPG Maker Xp but finding reliable sources at the time for functional scripts was difficult for me back then, and now that I have lost it. I like VX with it's new options but I just wish they bloody combined all of these functions together for the later releases. I mean it's like they are deliberately progressing but cutting out so much content from previous versions.
This is clearly out of topic you know.. lol! Let's make this the last shall we? 😛

When you get to the script part.. well.. it's ruby before rgss and C before ruby. The mouse/keyboard/online scripts you find out there, simply uses ruby outside of the normal rgss modules and classes. (the sort example from the lady in that demo is another example). So letting that aside, the scripts are actually swap - able if you can correctly replace the methods used in rgss/rgss2/rgss3. Or some script creator prefer direct ruby and bypass a bunch of things. So.. VX/Ace is able to run the full XP engine and scripts in a way.. 😛

I've known some games out there do that, the trick is, they put (part of) the XP core script(modified to work with ace) after Main, then they start putting the battle scripts of xp and such below it. Because XP's hidden classes are all available resources on the internet, it's not hard to make a full or part engine of XP to be used in Ace. That's probably the main reason why VX ace have part of its code hidden in the dll and forbids the users from tinkering. Some one actually published the code before(and some XP game actually able to run parts of VX engine), but the site that publish it has been taken down. If you look deeper into how the rgss players(the game launcher) works, they are pretty much the same in design. So... you get the idea.. 😉

Original thread: https://forums.rpgmakerweb.com/threads/random-event-location-encounter.43174/