Indie Dev

Hello Guest!. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, sell your games, upload content, as well as connect with other members through your own private inbox!

[Advanced Logic] Random Event Terrain Variable Generation (RETVG)

Status Gear Entertainment

Praised Adventurer
Hello everyone, StatusGearEntertainment is back and with a rare appearance of asking an event question. (Because I can nearly do everything and think of it with eventing and logic.) Refer to Diagram 1A.

The Diagram 1A

The Description
This Random Event Terrain Variable Generation (RETVG) logic I came up with after about a quick 3 minute thought. Basically what it does by looking at it, it randomly picks an X and a Y coordinate number based off the size of the map. From there, it's supposed to detect the terrain tag that I set up ranging from 1 - 4 letting me know what type of ground it is.

If let's say I'm trying to randomly spawn a flower, it needs to only randomly appear in grass terrain so terrain 2. This way, I can have an organized form of random generation spawning. I use about 20 events each with a 20 page possibility.

So say if 7 of the events actually come out to be flowers, they need to randomly be placed in grass terrain only. IF the terrain is not fit for any event, let's say water, then it redirects itself back to regenerate new coordinates and try again. As a fail safe to prevent Decoration 1 from moving again, it detects that the Decoration 1 variable has a value and thus skips over to the next Decoration 2 and so forth up to Decoration 20.

The Problem
I need to be able to move my event on map to these coordinates. There is no page or options that say SET MOVE ROUTE -> THIS EVENT -> TERRAIN VARIABLE X & TERRAIN VARIABLE Y. This is very troublesome. It would be much easier as well if there was a map coordinate jump. There might already be one out there just let me know please and thank you. Also, it would be a nice js plugin as well.

Very Respectfully,
StatusGearEntertainment
 

Essy

Towns Guard
Xy$
0.00
It looks like you could just use "Set Event Location" to do this. Though I may be misunderstanding the problem.

Looking at your algorithm here's how I would implement it via a psuedocode.

Code:
events = [1,2,...]                  //Events used.
for i in events                     //Iterate Through Events
   label Start:                                       
   Rand_X = random(map_width)        //Get Random X Position
   Rand_Y = random(map_height)      //Get Random Y Position
   if(validTag(x,y) && !positionTaken(x,y)) 
     //Move the event if the tag is valid and an event isn't already there.
      i.move(x,y)                                           
   else
       //Otherwise try a new position.
       goto Start
   end 
end
For clarification which part of your algorithm are you having trouble with? : o
 

Status Gear Entertainment

Praised Adventurer
@Status Gear Entertainment , some of these questions may seem simple, but there are indeed important to overall flow. All event jumpings occur on the same map, correct? Have look at the different options available with Galv_Move Route Extras plugin?

I love you contingency diagram showing multiple layers of if thens.
I have not. Wasn't aware Galv had that. I'll look into it more. Judging by what I read in the description notes. It pretty much does what I want as much as SCRIPT: this.jump_to(x,y) but is there a setting for x and y being a variable? Like this.jump_to(variable21,variable22) or a way I can just set 1 variable with a coordinate randomly that the script will allow it to jump to?

It looks like you could just use "Set Event Location" to do this. Though I may be misunderstanding the problem.

Looking at your algorithm here's how I would implement it via a psuedocode.

Code:
events = [1,2,...]                  //Events used.
for i in events                     //Iterate Through Events
   label Start:                                     
   Rand_X = random(map_width)        //Get Random X Position
   Rand_Y = random(map_height)      //Get Random Y Position
   if(validTag(x,y) && !positionTaken(x,y))
     //Move the event if the tag is valid and an event isn't already there.
      i.move(x,y)                                         
   else
       //Otherwise try a new position.
       goto Start
   end
end
For clarification which part of your algorithm are you having trouble with? : o
The actual moving portion. Like jumping an event to a location specified with randomized coordinates. Say for example if it works, it should look something like this in a nutshell:

1. Variable 22 %Random% 0 - 49. This is coordinate X.
2. Variable 23 %Random% 0 - 49. This is coordinate Y.
3. Check coordinate X,Y using Variables 22 and 23.
4. Go to that spot on the map and check it's Terrain ID.
5. IF Terrain ID is 1 (Grass) then jump event 2 over to X,Y.
6. IF Terrain ID is NOT 1 (2 for Sand, 3 for Water, 4, tree) then jump back to step 1 and 2 and redo this process.
7. IF event 2 already has a value (1 indicating that it has already been assigned a location) then skip over event 2's jump and move on to event 3 and so on.


I also found the Orange - Move Character To 1.0 plugin which is also what I'm looking for but again, like Galv's plugin, is there a formula for Orange's script call this.setDestination(x, y); to this.setDestination(variable_x, variable_y); ?

Thank you btw guys for looking into this thread. Really appreciate it. (cute)
 

Essy

Towns Guard
Xy$
0.00
It looks like you would do it like so.
Code:
this.setDestination($gameVariables.value(23),$gameVariables.value(24));
the .value will grab the value of that variable. (The value is immutable however)
Grabbed it from this rpgmaker post.
 

Status Gear Entertainment

Praised Adventurer
It looks like you would do it like so.
Code:
this.setDestination($gameVariables.value(23),$gameVariables.value(24));
the .value will grab the value of that variable. (The value is immutable however)
Grabbed it from this rpgmaker post.
Oh really? That's a bit of a let down. You'd think that'd be something the creators would implement.
 

Essy

Towns Guard
Xy$
0.00
I don't know Javascript(yet)
But if accessing the variables in that manner feels to cubersome I'm guessing we add this to the plugin...
Code:
Game_CharacterBase.prototype.goTo = function() {
     this.setDestination($gameVariables.value(23),$gameVariables.value(24));
}
Then in a script call you would only need to call "this.goTo();"
And it would automatically go to the destination in those variables..
Don't take my javascript as 100%,
I just glanced over the plugin to see if I could reverse engineer the javascript.
 

Status Gear Entertainment

Praised Adventurer
I don't know Javascript(yet)
But if accessing the variables in that manner feels to cubersome I'm guessing we add this to the plugin...
Code:
Game_CharacterBase.prototype.goTo = function() {
     this.setDestination($gameVariables.value(23),$gameVariables.value(24));
}
Then in a script call you would only need to call "this.goTo();"
And it would automatically go to the destination in those variables..
Don't take my javascript as 100%,
I just glanced over the plugin to see if I could reverse engineer the javascript.
I understand you. But it's still kinda cool to learn a bit. It seems like you are more knowledgeable in JS than I am already even if you say you don't know JS yet. Judging by how you set that, would it make more sense if I were to (theoretically) turn it into:

Code:
Game_CharacterBase.prototype.goTo = function() {
     this.setDestination($gameVariables.value(x),$gameVariables.value(y));
}
and then allow myself to script call it with any variable? not just 23 and 24? For flexibility of course. (blush)
 

Essy

Towns Guard
Xy$
0.00
Code:
Game_CharacterBase.prototype.goTo = function(x,y) {
     this.setDestination($gameVariables.value(x),$gameVariables.value(y));
}
It needs parameters on the function.
And also if JS allows default parameters.
Code:
Game_CharacterBase.prototype.goTo = function(x=23,y=24) {
     this.setDestination($gameVariables.value(x),$gameVariables.value(y));
}
Would make it automatically use 23,24 if you don't give it parameters, but if you did it would use those instead.
 

Status Gear Entertainment

Praised Adventurer
check this : http://galvs-scripts.com/2015/10/24/mv-move-route-extras/

if you need anything else i can write an extension plugin with the missing functions.
It's what I'm looking for but as expected it's missing the variable functions. this.step_rand(1); is the command for randomly moving on a specific region/terrain tag which is close. I need it to randomly jump to a specific region/terrain tag. If this can be done then it makes my entire diagram put into a single piece of code. Because I'm originally looking for jumping to variables values such as this.step_jump(x,y) but if I can get a this.step_randomjump(1); then it's all golden. (cute)
 
Top