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 placed events

Jaide

Member

I'm not asking this in the scripting section, because I'm hoping there's a way to do this with just events.

I want to have animals or perhaps plants, that appear randomly on certain maps. Say you're in the forest, and there's a butterfly flying around near the water. Well, I'd like for that butterfly to appear, for instance, over by the tree sometimes instead. Or perhaps, sometimes the butterfly isn't even there at all.

I would like to be able to determine where an event can and cannot appear, perhaps via terrain tags, so that you don't end up with a flower growing out of the water like it's nothing. o.o; Each time you enter that particular map, the scenery would be different.

Is this at all doable using just events?
 
The tricky thing is the terrain tags, which you'll probably have to use the call script command for it, inside conditional branches. Other wise, it's doable with randomizing variables and loops. If someone could tell what is the script command to call the terrain tag, though; I'm kind of looking for that too. o:
 
If you don't mind having static events that get turned on and off based on a random variable, you could do it through events (with a little bit of easy scripting code but no actual modifications to the RGSS scripts). Otherwise, having dynamic random events would require scripting.
 

Jaide

Member

@Reives: The only way I can find to call a terrain tag is to assign a variable to an event when it comes in contact with the terrain tag. This can be the player, or any event on the map. I've fiddled with this a little bit, but I can't seem to put it to any real use. =/

I know you can use this to make a certain terrain a "damage floor", like in older RPG Makers, but...common events don't call by step, but by frame. So it's a little tricky and I still haven't really figured that out yet. But I digress. ^^;

@Diedrupo: Could you elaborate on that a little bit more, please? Specifically what you mean by static events vs. dynamic events.
 

Kraft

Sponsor

Static events would be that you have an event on the map, and it has about 5-10 different pages, each with a different scenery item in it.

Then a random variable is picked, and it switches that event to a certain page (with a certain variable) and it is different.


Actually... I do have an idea of how this could work with events...

Events and variables.

Basically, in a nutshell, you will need like 3 variables.

1 for the Terrain ID, and the other 2 for the X,Y of the item.

Next, in the editor, randomly have those last 2 numbers (XY) randomly get picked out. (so that the item appears somewhere, including on water or on a cliff)

Next, set the things in the database (like the cliffs and water) to a different Terrain ID. (like set them to 1)

Then, back in the event thing, after the thing has been placed, have it check the terrain ID that it is currently on.

and if it is 1 (aka, it is on water or a cliff or a house), throw the XY variables again, and run the terrain ID check again.

Then, it should keep randomly picking until it gets somewhere that does not have a terrain ID of 1.



Does any of this make sense? ^_^

If not, sorry, I am really tired :D (read it again slower ^_^)

I will try it tonight and see if I can get it to work. (I dont even know if it is possible, (checking an events terrain ID) but I will try.)

~Kraft
 

Jaide

Member

Yes, Kraft, that makes perfect sense, thank you. ^_^ And thank you, Diedrupo! A demo would really help to make sure I'm doing it properly, but I think, based on what Kraft said, that I might understand it now. XD Emphasis on might; understanding and doing are two different things. ;P
 

Jaide

Member

Ohhhh, I see what you mean. Hence the 'static' part. XD; That too would be useful though. And I suppose you could have it set so that (going back to my butterfly example) the event was set in multiple places, but the switch/variable determined which event was actually "active" when you entered the map. So you'd have a butterfly by the water, by the tree, on the path...and it would randomly appear at one of three places, but all with different events.

I'm going to fiddle with Kraft's theory, and see if I can make that work. If not, I'll go the former route, with the static events. ^^

Thank you for the demo. :)
 
Jaide;277117 said:
Ohhhh, I see what you mean. Hence the 'static' part. XD; That too would be useful though. And I suppose you could have it set so that (going back to my butterfly example) the event was set in multiple places, but the switch/variable determined which event was actually "active" when you entered the map. So you'd have a butterfly by the water, by the tree, on the path...and it would randomly appear at one of three places, but all with different events.

I'm going to fiddle with Kraft's theory, and see if I can make that work. If not, I'll go the former route, with the static events. ^^

Thank you for the demo. :)

Yeah no prob, you can use it as a jumping point for figuring out how to make an event only appear once in a location, etc.
 

Jaide

Member

@Kraft: Okay, your idea sounds good in theory, but I'm having trouble actually executing it. O.o If you get a chance to try it out, please let me know how it goes.

EDIT: To clarify, it doesn't seem to be running the terrain ID check, and from what I can tell it SHOULD be running the terrain ID check. So I could use some help with that, if possible. :)
 

Jaide

Member

That's a very nice way of doing it if you want random items/people/etc. to appear in the same location, but I'm looking to move the event to random places on the map. :) Thanks for the demo though; I definitely like seeing different ways to accomplish things. ^^

For some reason, the event that I have set up moves about the map just fine, but it doesn't seem to check for the terrain ID, and thus appears in the water, on buildings, etc. If there's a good way to fix this, could someone please let me know?

EDIT: Okay, right after I posted this I seem to have mostly figured it out, but when you enter the map, if the event was in the water, you can see it jump to a new location. So I need to fiddle with that, so you don't see jumping flowers and whatnot. :3

EDIT AGAIN: Sigh. Okay, still doing the jumping thing. But occasionally I get a script error which crashes the game. I assume it has something to do with where the event is landing.

Game_Map, line 305: elsif @terrain_tags[tile_id] > 0

D:
 
Jaide;278131 said:
That's a very nice way of doing it if you want random items/people/etc. to appear in the same location, but I'm looking to move the event to random places on the map. :) Thanks for the demo though; I definitely like seeing different ways to accomplish things. ^^

For some reason, the event that I have set up moves about the map just fine, but it doesn't seem to check for the terrain ID, and thus appears in the water, on buildings, etc. If there's a good way to fix this, could someone please let me know?

EDIT: Okay, right after I posted this I seem to have mostly figured it out, but when you enter the map, if the event was in the water, you can see it jump to a new location. So I need to fiddle with that, so you don't see jumping flowers and whatnot. :3

EDIT AGAIN: Sigh. Okay, still doing the jumping thing. But occasionally I get a script error which crashes the game. I assume it has something to do with where the event is landing.

Game_Map, line 305: elsif @terrain_tags[tile_id] > 0

D:

it seems that you don't really get what you could do with my demo :P
maybe you get it if i show this ^_^
http://www.sendspace.com/file/pd8rh8
 

Jaide

Member

007snicker;278497 said:
it seems that you don't really get what you could do with my demo :P
maybe you get it if i show this ^_^
http://www.sendspace.com/file/pd8rh8
Ohhhh! That totally solves like 99% of my problems. ^^; I hadn't caught onto that in your first demo, but that second one really made sense to me. However, occasionally, I'm still getting a script error which crashes my game, and it happens randomly. I'm still trying to see if I can move the events around via X and Y coordinates, which...works, but sometimes I get that script error, which I assume is the result of the event landing somewhere it shouldn't, which triggers the error. O.o I just don't know. Maybe I should totally give up on that and just use the static events. XD
 

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