Random Event Positions

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
This script allows you to randomize an event's position when you enter the

map. Regions are used to designate the tiles where an event can appear.



Download

Get it at Hime Works!

Installation

Place this script below Materials and above Main

Usage

To designate an event page where the event's position is randomized, create

a comment and write

<random position region: x type>For some region ID xThe type determines when position randomization occurs

start - only once: when the event is first createdinit - whenever the event is createdpage - whenever you change to that pageIf that page is active when the map is loaded, then the event will be randomlymoved to a tile in that region.

This is applied to events on a per-page basis, so you may need to add the

comment to multiple pages.

 
Last edited by a moderator:

NecroNeko

Veteran
Veteran
Joined
Jan 10, 2013
Messages
80
Reaction score
0
First Language
german
Primarily Uses
It's like you're reading my mind. This fits perfectly in my game. I'll try it out tomorrow but I'm already thankful for it :)
 

light487

Parrot Keeper
Veteran
Joined
Mar 26, 2013
Messages
852
Reaction score
26
First Language
English
Primarily Uses
Really great! Does the comment need to be at the beginning of the page? or doesn't it matter where it is as long as it is executable?

For example, if I had a conditional statement in the event page I might do something like:

if condition is true   Comment: <random event position: 1>else   Comment: <random event position: 2>endifIs that possible? or would I have to use multiple pages for that to work?
 
Last edited by a moderator:

seita

Donn_M
Veteran
Joined
Feb 6, 2013
Messages
2,254
Reaction score
611
First Language
English
Primarily Uses
@light it doesn't behave like a script call I believe, so if anything you would have a conditional that switches pages to the correct position, quite possibly an external autorun/parallel process event or common event.
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
Really great! Does the comment need to be at the beginning of the page? or doesn't it matter where it is as long as it is executable?


Is that possible? or would I have to use multiple pages for that to work?
The comment appears anywhere on the page.


You will need multiple pages if you want to use conditions. My comment parser is not smart enough to evaluate conditional branch commands.
 

light487

Parrot Keeper
Veteran
Joined
Mar 26, 2013
Messages
852
Reaction score
26
First Language
English
Primarily Uses
The comment appears anywhere on the page.

You will need multiple pages if you want to use conditions. My comment parser is not smart enough to evaluate conditional branch commands.
Ok. Noted. :) Will use multiple pages for that :)
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
Updated script with an extra argument to the comment

<random position region: 3><random position region: 3 init><random position region: 3 page>If you write page, the position is randomized whenever you change to that page.If you write init, or don't write anything at all, it will just be randomized only when the event is created.
 

seita

Donn_M
Veteran
Joined
Feb 6, 2013
Messages
2,254
Reaction score
611
First Language
English
Primarily Uses
Not sure why I'm getting this error:
 

Line 172: NoMethodError occurred.

undefined method: 'random_position?' for nil:NilClass

Seems to only happen when there's an autorun on the map.

EDIT: Wow, that is really really weird. It works fine in a new project.

I deleted every custom script on my current project, and it still gives me that error.

Edit2: on further review, even with a clean game it does not work if any event has a condition.
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
Thought that issue was addressed before but maybe I took it out when I updated.


The issue has been resolved.
 

seita

Donn_M
Veteran
Joined
Feb 6, 2013
Messages
2,254
Reaction score
611
First Language
English
Primarily Uses
Works perfectly, thanks so much Tsuki! I couldn't get it to work at first. During debugging I found out that the comment call has to be separate from any other comment calls from different scripts.
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
I think unless the script is explicitly deleting the comment after parsing, there should not be an issue. Some of my comment-parsing scripts do actually delete the comment after I'm done with it...which now seems like a bad idea.
 

seita

Donn_M
Veteran
Joined
Feb 6, 2013
Messages
2,254
Reaction score
611
First Language
English
Primarily Uses
Perfection comes through iteration I suppose haha. At least we exposed something here
 

ShadowFox

Adventurer
Member
Joined
Mar 13, 2012
Messages
255
Reaction score
10
First Language
English
Primarily Uses
is there a way to make this script also randomize the map the event could appear in?

If there is, can the map randomization be between selected maps? (Randomized map ID's 1, 4, 6, 8 and 10)
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
No, this script assumes events are static and are fixed to the map they are created on in the editor.
 

ShadowFox

Adventurer
Member
Joined
Mar 13, 2012
Messages
255
Reaction score
10
First Language
English
Primarily Uses
I thought so. Thanks though.
 

flipwon

Veteran
Veteran
Joined
May 11, 2013
Messages
59
Reaction score
0
First Language
English
Primarily Uses
The "types" are not working for me and are returning errors.
 

flipwon

Veteran
Veteran
Joined
May 11, 2013
Messages
59
Reaction score
0
First Language
English
Primarily Uses
I've fixed the issue.
So now it runs once, then returns to the events original position with no argument or init.

On page it continues to randomize. I'm assuming this is how it's intended and is perfect for my monsters!

Now I just need to figure out how to do the random position once, and have it remember that position for stationary objects. This could be a future update idea perhaps :p

Thanks for your help and prompt responce Hime!
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
I will add a way to only do the randomization once.


It will probably be a type called "start" or something, since "init" is called everytime you load the map which may not be desirable.
 

flipwon

Veteran
Veteran
Joined
May 11, 2013
Messages
59
Reaction score
0
First Language
English
Primarily Uses
I will add a way to only do the randomization once.

It will probably be a type called "start" or something, since "init" is called everytime you load the map which may not be desirable.
The key would be saving that first time random position without having to set 3 variables for each event! :p

Again thanks from a fellow Torontonian lol (well etobicoke but that counts)
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,863
Messages
1,017,053
Members
137,571
Latest member
grr
Top