Encounter rate changeable within the opinions menu.

Edit

Warper
Member
Joined
Mar 25, 2014
Messages
4
Reaction score
0
First Language
English
Primarily Uses
Hi all!

I'm fairly new to RPG Maker but I have limited scripting knowledge would like help with a opinion within the menu screen that could change the encounter rate. 
It doesn't have to be fancy - an 'On' and 'Off' for encounters would be great! 
If any of you have played Bravely Default, that is what I am aiming for - A percentile increase or decrease - but I am not 100% sure that would be possible.

Any help would be GREATLY appreciated !
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
I have done this in my (almost finished) current game.  

Are you using, or would you be prepated to use, Yanfly's System Options script?  If so, I can tell you how I did it, there's no need to get a special script just for that.  You can find it here: https://github.com/Archeia/YEARepo/blob/master/Menu/System_Options.rb

If, however, you want a script which only does the encounter rate, then I'm afraid I can't help.
 

Edit

Warper
Member
Joined
Mar 25, 2014
Messages
4
Reaction score
0
First Language
English
Primarily Uses
The dropbox for Yanfly's System Options seems to be down at the moment, But I have looked through this guys/gals stuff before and never noticed that. 
Would I download Yanfly's system options then add your script under materials ?
( Thanks for the help BTW! )

EDIT : Just tried it out, The Option systems seems really useful, I just read it wrong. I would love to see the script you used to add another variable for monster encounters. 
Once again, thanks!
 
Last edited by a moderator:

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
Okay, I'll try and explain what I did.  First, start with Yanfly's script.  There is this section, starting at line 106

COMMANDS =[ :window_red, # Changes the red tone for all windows. :window_grn, # Changes the green tone for all windows. :window_blu, # Changes the blue tone for all windows. :volume_bgm, # Changes the BGM volume used. :volume_bgs, # Changes the BGS volume used. :volume_sfx, # Changes the SFX volume used. :blank, :autodash, # Sets the player to automatically dash. :instantmsg, # Sets message text to appear instantly. :animations, # Enables battle animations or disables them. # :switch_1, # Custom Switch 1. Adjust settings below. # :switch_2, # Custom Switch 2. Adjust settings below. :variable_1, # Custom Variable 1. Adjust settings below. # :variable_2, # Custom Variable 2. Adjust settings below. :blank, :to_title, # Returns to the title screen. :shutdown, # Shuts down the game. ] # Do not remove this.You will see that at line 119, I removed the #

This makes that line 'active'.

Then a little lower down, in the section on Custom Variables, starting at line 156 you will see this:

CUSTOM_VARIABLES ={ # ------------------------------------------------------------------------- # :variable => [Switch, Name, Colour1, Colour2, Min, Max, # Help Window Description # ], # Do not remove this. # ------------------------------------------------------------------------- :variable_1 => [ 50, "Encounter Rate", 9, 1, 10, 40, "Slide bar to adjust encounter rate. For INVISIBLE enemies only. Minimum = 10, Maximum = 40, Default = 25" ], # ------------------------------------------------------------------------- :variable_2 => [ 2, "Custom Variable 2", 10, 2, -10, 10, "Help description used for custom variable 2." ],Starting at line 162 is where I edited to put in the details of what I wanted.  The words in quote marks are what shows up when the player selects that option.

So then it is a question of setting the default.

In the default scripts, go to Game_Player and you will find a section Creat Encounter Count, starting at line 191

# * Create Encounter Count #-------------------------------------------------------------------------- def make_encounter_count n = $game_map.encounter_step @encounter_count = rand(n) + rand(n) + 1 + $game_variables[50] endI altered that section so that it looks like the snippet I posted.  This does 2 things.  It stops the "take 3 steps and have a battle; take 4 steps and have another one" problem and it sets up the variable I use to set what the default will be.  That's the [50] at the end of the line.  You, obviously, would put in whatever variable switch you assign to this task.

Then, and this is the final step, I promise

At the very beginning of the game, immediately after the title screen, I have an event on the opening map where I set various switches.  I set variable switch 50 to equal 25.

I hope I've explained this clearly.  It looks like a lot of work, but in fact it's dead easy if you go through and do each bit methodically.
 

Edit

Warper
Member
Joined
Mar 25, 2014
Messages
4
Reaction score
0
First Language
English
Primarily Uses
Thank you SOOOO much! 
Ive saved it as it is and I'm going to mess with it a bit. Would it be possible to make the spawn rates 0 or with the Random(n) in the equation ( Not sure the proper term ) - @encounter_count = rand(n) + rand(n) + 1 + $game_variables[50], Would make it impossible ?

Once again, Thank you!

EDIT - Would - 
@encounter_count = rand(n) + rand(n) + ( 50 - $game_variables[1] ) - still work ? So that 40 wouldn't be the least amount of monsters and that 10 would be the most.
 
Last edited by a moderator:

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
I think there's possibly a bit of confusion here.  I wouldn't recommend using what you suggest in your edit.

If you want to have a greater range than minimum number of steps before a battle 10, maximum number of steps before a battle 40, then in Yanfly's script, line 162, change the 10, 40 to what you want.  So if you wanted the range to be a fight every step up to a fight every 100 steps (which for practical purposes is almost zero) then line 162 would read:

:variable_1 => [ 50, "Encounter Rate", 9, 1, 1, 100,

 The 50 in line 162 is simply telling the script which variable I've assigned to this.

If you want zero encounters, then find a way for the player to implement that, perhaps by interacting with some object (crystal, switch, whatever).  On that event, use the command "Change Encounter" from the 3rd tab of the event command menu, and select 'Disable'.   You would then have to think of a way for it to be re-enabled - perhaps having the command automatically there in the transfer out of that area?  
 

RaZzi

My Peculiar Brother
Veteran
Joined
Jul 19, 2013
Messages
423
Reaction score
206
First Language
Finnish
Primarily Uses
Hmm, I'm want to achieve similiar thing and do not want to make another thread.

This script snippet is from a random hero whose name I cannot remember.

class Game_Player < Game_Character def make_encounter_count n = $game_map.encounter_step if $game_variables[30] <= 0 @encounter_count = rand(n) + rand(n) + rand(n) + 1 # Low Encounters end if $game_variables[30] == 1 @encounter_count = rand(n) + rand(n) + 1 # Medium Encounters end if $game_variables[30] >= 2 @encounter_count = rand(n) + 1 # High Encounters end if $game_variables[30] >= 3 $game_system.encounter_disabled = true # Encounters OFF endendend 
Then make the adjustments to Yanfly's options script similiar like ksjp17 advised.

Now for some reason this encounter rate updates only after a battle. How to make the encounter rate "update" when you leave the system options menu? Also I would like to have the 0 value of the variable to be the encounters off value but for some reason the game crashes if you start the game with 

def make_encounter_count n = $game_map.encounter_step if $game_variables[30] <= 0 $game_system.encounter_disabled = true endand take a step.
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
Edit: Sorry, missed what you wanted, rewrote post. If you want features like low/medium/high rate, edit the lines ksjp17 suggested and set it so the variable can only go from 0 - 3 in the system menu for variable 30 (the one you are using). It auto updates when the player exits the menu.
 
Last edited by a moderator:

RaZzi

My Peculiar Brother
Veteran
Joined
Jul 19, 2013
Messages
423
Reaction score
206
First Language
Finnish
Primarily Uses
Hmmm. No it doesnt? It updates after the first battle? Tested it with starting a project and running around with encounters on low = battle happened. Reboot and went to system to change the variable to correspond encounters = off and started running around. Battle happened.

I have set it correctly in the menu. Can you get it working on your end with that snippet?
 
Last edited by a moderator:

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
I remember a discussion (though don't remember where) which came to the conclusion that the proper updating only happens after the first battle after the rate has been reset.  It is not immediately you change the encounter rate.
 

RaZzi

My Peculiar Brother
Veteran
Joined
Jul 19, 2013
Messages
423
Reaction score
206
First Language
Finnish
Primarily Uses
I remember a discussion (though don't remember where) which came to the conclusion that the proper updating only happens after the first battle after the rate has been reset.  It is not immediately you change the encounter rate.
Yeah, well, what happens in the battle that updates the rate and how to add that update happen when you exit the options menu?
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
I think I know what you are talking about. RPGMaker sets the steps to the next encounter the minute you load your game, and that number is stored until that fight (I tested this by a msgbox_p prompt in the make_encounter_steps command). The only way to fix it is to have the game re-roll the steps to the next encounter somehow every time someone updates the number (which will add a new bug too...mainly someone could just take a couple steps, adjust that number, take a couple more steps, etc, and never do a random fight!).
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
With that memory prompt, yes, that is what people were referring to.

I see how, technically, a player could do what bgillisp refers to, but anyone prepared to adjust the number every couple of steps and keep that up for any real length of time, is probably going to break the game anyway, so I personally wouldn't take any notice of the possibility.
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
Agreed. It would probably take longer to do that than to just do the fights. So I wouldn't honestly worry about it too much, just be prepared for the possibility of it from a really crafty player.

However, I think it might be best to just put a note saying adjustments take place after the next fight.
 

RaZzi

My Peculiar Brother
Veteran
Joined
Jul 19, 2013
Messages
423
Reaction score
206
First Language
Finnish
Primarily Uses
....and that wouldn't matter because there is option to turn the encounters off completely. So how to do it?
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
Add this snippet to the code for update_encounter:

if($game_switches[120] == false)

 return

end

Now, once you turn off switch 120, you will get no random fights anywhere in the game until the switch is turned back off (if you would rather no fights occur when the switch is on, change false to true).
 
Last edited by a moderator:

RaZzi

My Peculiar Brother
Veteran
Joined
Jul 19, 2013
Messages
423
Reaction score
206
First Language
Finnish
Primarily Uses
Add this snippet to the code for update_encounter:

if($game_switches[120] == false)

 return

end

Now, once you turn off switch 120, you will get no random fights anywhere in the game until the switch is turned back off (if you would rather no fights occur when the switch is on, change false to true).
Uhm. I mean I already have snippet which affects the random encounters with a variable. Depending on the variable it changes the encounter amount to low, medium, high or off. What I want is a way to make the encounters update when I leave the system options menu where I change that variable.
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
That would require a massive re-write to how encounters are determined, as someone would have to set it to call make_encounter_count every time the system menu is closed, which the game does not do. I would recommend a switch for the on/off and the variable only do low/medium/high myself, as the switch will get flipped, and that line I posted will be checked and no fights initiated then.

See, that's what we have been saying up above...make_ecounter_count (which determines the steps before the next fight) is *only* called once, when the game is loaded, and the instant a random battle starts (strangely, the game calls it before it initiates the fight you start, not after. Same effect though). To have it called after the variable is changed or the system menu exits is a much bigger request and rewrite (and beyond my skill level I'm afraid).
 

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,860
Messages
1,017,040
Members
137,569
Latest member
Shtelsky
Top