Rafael Sol Maker 22 Posted December 22, 2011 (edited) [scriptlet] Adjusting Encounter Rates Hang on there, soldiers! This time I didn't made anything special, I only want to share some of my discoveries and make public a small scriptlet that can be useful. The "real" scriptlet is the last one. The others are purely illustrative. Let's mov'on, it's time to start the story: Back on my VX days, I was investigating the scripts and I found that encounter rates were doubled if the player is walking in a bush. I think this was curious, no one said this, and I never imagined, even if it was "so obvious". The code I found was this: #-------------------------------------------------------------------------- # * Update Encounter #-------------------------------------------------------------------------- def update_encounter return if $TEST and Input.press?(Input::CTRL) # During test play? return if in_vehicle? # Riding in vehicle? if $game_map.bush?(@x, @y) # If in bush @encounter_count -= 2 # Reduce encounters by 2 else # If not in bush @encounter_count -= 1 # Reduce encounters by 1 end end But discover this wasn't sufficient for me, soon I thought how I could improve this lil' piece o' code. The idea I got was the following: If a guy is in a vehicle, the encounter rate would be halved, there's nothing so obvious, as seen in many classical RPGs. And soon I implemented, in a scriptlet package I called VX SMALL TWEAKS v1.1, containing other 8 small scripts and bugfixes that I had no other place to put in. The part of the code I wrote for the encounter feature I thought was this: #=============================================================================== # If you are in a vehicle, the encounter rate will be halved #=============================================================================== class Game_Player < Game_Character def update_encounter return if in_airship? return if $TEST and Input.press?(Input::CTRL) if $game_map.bush?(@x, @y) if in_vehicle? @encounter_count = @encounter_count.to_f - 1 else @encounter_count -= 2 end else if in_vehicle? @encounter_count = @encounter_count.to_f - 0.5 else @encounter_count -= 1 end end end end An amateur code, surely, but worked for its purpose. And the story continues to flow... Now we have RPG Maker VX Ace, and examining the Traits System yesterday I found some nifty feature: Some items can half the encounter rates, and other can cut it out totally! And I became curious again, and I searched the code to see what was changed. Surprisingly it was totally different in that area, the modularization of the Ace's code is amazing. And I had will to recreate the idea, but making it more customizable and flexible. The small code I obtained was the following: class Game_Player < Game_Character ENCOUNTER_RATIO_BUSH = 2.0 # The encounter rate in a bush will be doubled ENCOUNTER_RATIO_BOAT = 0.75 # The encounter rate in a boat will be 75% ENCOUNTER_RATIO_SHIP = 0.5 # The encounter rate in a ship will be halved def encounter_progress_value value = $game_map.bush?(@x, @y) ? ENCOUNTER_RATIO_BUSH : 1.0 value *= 0.5 if $game_party.encounter_half? value *= ENCOUNTER_RATIO_BOAT if in_boat? value *= ENCOUNTER_RATIO_SHIP if in_ship? value end end Now, as everyone can see, is very easy to edit and put your custom encounter rates at different situations. Just put in a script below Materials and above Main and it must works with no problems. The compatibility must be high, it only overwrites one method. This terminates my little story. Thanks for reading, I hope the scriptlet can be useful for you, use it freely, no credit is needed. Edited December 22, 2011 by Rafael Sol Maker Share this post Link to post Share on other sites
Fomar0153 123 Posted December 22, 2011 I never even realised this feature existed, still it's a nice neat little script you've got there. You'll find that's how most of us scripters started. Well done keep it up. Share this post Link to post Share on other sites
Rosenblack 79 Posted December 22, 2011 Added to OS-MSL Share this post Link to post Share on other sites
Knightmare 170 Posted December 22, 2011 Very nice Raf, sometimes its the scripts that do something simple that are the more useful. Share this post Link to post Share on other sites
cyborgmermaid 1 Posted October 6, 2013 (edited) I'm confused - which of these three is used for the script? Or is it all three, and if so, which order are they put in? EDIT: Ah jeez this was a super necro bump. Didn't even notice that. Sorry. Edited October 6, 2013 by cyborgmermaid Share this post Link to post Share on other sites