Random Encounter Control, Version 0.41 (Updated 1.26.15)

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
Encounter Control, Version 0.41

bgillisp

Introduction
This is a script in progress to allow developers the ability to better control how random fights work in the game
 

Features
Currently, you can do the following in this script

-Set a switch that if the switch is ON, no battles will occur on that map. Set the switch with the notetag <Encounter Switch: x> on the note box for the map.

-Set a minimum number of steps to take before a battle can occur. If you have Yanfly's Encounter script installed, it will use that global minimum, but will overwrite it with a notetag on a map if desired. Use the notetag <Encounter Minimum: x> to set the minimum number of steps.

-Set a uniform distribution, where all encounter steps are within 3 standard deviations of the mean. Advanced, and work in progress, so directions not posted yet (as it is flaky still).

-Set a maximum number of encounters per map. If you played Ar Tonelico you know how this works. You can set a global maximum, and overwrite it per map with the notetag <Maximum Encounters: x>.

-Set a fear level. Once the party's average level is equal to or exceeds the fear level, the monsters fear you too much to attack. Set it per map with <Fear Level: x>. Default is 99 (max level in the game), but that can be adjusted.

-Added a variable that if you set the value in that variable to anything but 0, the game will always give  you the troop id that this variable is set to for your random fights. Can be combined with Yanfly's swap monster for some interesting effects and ways to change random fights (in the same areas) as the game progresses (by default this is disabled, change in the editable region if you wish to use this feature). Warning: There is no safeguard check, so it is up to you to make sure this always has a valid troop id!

-Set a global switch that if it is off, no battles will occur. The script defaults to 120. Set to zero to disable this.

-Set a switch to make all random battles surprise or preemptive.

-Set a switch to make all fixed fights also check for surprise or preemptive strike. Combine with the previous feature to make fixed fights where you get the jump on the enemies (or vice versa).

How to Use

Paste the script code in the materials section but above main.

Script
On pastebin: http://pastebin.com/CDMuvkNM
 

FAQ
 

Q: After adding this fights occur more often than before! Why?

A: This is because I use the number in the database as the maximum, not as the middle number. Double your old database numbers and it will work as before, or, you can change the setting in the editable region to go back to the old method of calculation if you like that better.

Q: I keep getting the same fight over and over and over!

A: You set the variable for storing the troop id to something besides 0. If you set that to anything but 0, the system will always return the same fight over and over and over until you set it back to 0. See the editable region for how to set the variable the game uses for this, or how to turn it off (by setting it to 0).
 

Author's Notes
Still a slow work in progress as work and time allows.
 
Last edited by a moderator:

BoluBolu

Veteran
Veteran
Joined
Apr 24, 2014
Messages
452
Reaction score
117
Primarily Uses
Try to get more control upon preemptive strike or surprise attack. The case could be same like yours, if the bandit leader is or anything else(switch by any means) is turned ON, then every fight in that map will caught you surprised attack, vice versa if by any chance you have different switch ON every fight will give you preemptive strike.Initialy I have made script like this, but I'm a lazy guy who is lazy to share script and maintain it. So it's great if you can implement it in your script here =) Good luck buddy.
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
I didn't think of that! Good idea!

Chances are this script will probably be in development for a few months, depending on how work goes and how quickly I can figure out how to implement the ideas. So, keep those ideas coming, as I'll be trying to implement them during my down time at work and/or my winter break.
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
For the crashing issue, I would just lazy-load the variable unless you've determined that the performance hit is too great.
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
Lazy load? Not sure what you mean. The crash is because there is a variable added to the Game_Map class, which it is now checking every step. However, if you don't start a new game, the variable is not initialized, so it doesn't exist, and it crashes.
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
http://en.wikipedia.org/wiki/Lazy_loading

class Game_Map def your_custom_var return @custom_var ||= DEFAULT_VALUE endendIf it doesn't exist, it will be initialized.If it already exists, then it will just return that.
 
Last edited by a moderator:

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
I see. I was also debating adding a nil check before the use of the variable, or in other words if(var != nil) then run these lines. Would that also prevent it? From what I can see, it would effectively disable the script until you start a new map, but might stop the crash.
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
You can say

if @var.nil? @var = 30endreturn @varBut the results is not much different from

Code:
return @var ||= 30
If by "start a new map" you mean loading a map, then yes the script would not do anything until then.But once you load a map (any map, even the one that you're standing on when you load the game), the variable will be initialized when you check it.
 
Last edited by a moderator:

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
I used the lazy load, seemed to work well with the new variable I just added. But what I actually meant was a check in the code using that variable to make sure it wasn't nil, and if it was, call the default method to avoid a crash.

Also, version 0.2 is up. This adds a feature where you can set the minimum number of steps you can take before a fight occurs. This overwrites how Yanfly determines it, and to work it must go below Yanfly's encounter manager. I'll work on adding Yanfly compatibility in a later version, so you can use Yanfly's global minimum for steps if you wish as well as the map specific minimum.
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
Added a little feature today to the script. For those of us who are more statistically minded, I added a feature to use the normal distribution to determine your encounter rate. The mean is the number in the database, and the notetag <Normal Distribution: x> tells it the standard deviation. It is locked to land between 3 standard deviations of the mean too, as I couldn't find a true normal distribution function in Ruby so had to ad-hoc it.

Also, I'm looking at adding an Encounter Lure feature to the script, or the ability to add the feature to lure fights to the player at a faster rate (maybe via a cursed item, or the player wants a fight, like Dragon Quests Whistle skill). Good idea or bad? Thoughts?

Edit: Ok, so after some experimenting it seems it is more uniform distribution than normal. Though I now have ideas on how to fix it, will add those when I get some free time!
 
Last edited by a moderator:

whitesphere

Veteran
Veteran
Joined
Mar 14, 2014
Messages
1,688
Reaction score
784
First Language
English
It's a good option to have, I think.  Also, if you could work with one of the "Give Monsters Levels too" scripts and make Repel work like it does in Dragon Quest that would be cool.

That is:

Repel keeps away monsters whose level is below the party's level

Repel has NO effect on monsters whose level is at or above the party's level
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
I'll have to look into that, thanks for the idea!
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
Updated the script today! It has a switch you can turn off in your game to turn off random fights totally (its 120 by default), make sure to either set that to 0 or turn it on at the start of your game else there will be no fights at all!

Also added a feature to set a maximum number of battles per map (think Ar Tonelico). This works exactly like it did in Ar Tonelico, where the number resets when you change maps, and when you load a game. However, now if you are the unlucky one on the RNG you will eventually clear out the map (for a while) and get no random battles. If you don't set it, it will use the default (30 in the script). If you want to disable this, set the number in the script really high (9999999 should do it).

Edit: If someone wants to write an add-on to make a graphical display for the number of encounters left, feel free. I know there have been some requests for that kind of feature.

Edit 2: Added a fear level (monsters will avoid the party in that region if your level is equal to or greater than a number), and a variable you can store the troop id you want them to always fight (useful for plot specific scenes). Variables are present to turn on and off surprise attacks, but they are not implemented yet.
 
Last edited by a moderator:

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
Been a while, with the holidays and such, but I finally got a chance to update this script some. Now you can do the following:

-Flip a switch to make all random battles surprise attack.

-Flip a switch to make all random battles preemptive strike.

-Flip a switch to make no battles surprise attack.

-Flip a switch to make no battles a preemptive strike.

-Flip a switch to make fixed fights (where you called the battle event directly) check for surprise or preemptive strike. Combine this with the other two to create a fixed fight where the thieves get the drop on the party, or the party ambushes the enemy!

I plan to play around more with how surprise and preemptive strike is calculated next. However, if I decide to do a major change to it I'll release that as an add-on.
 
Last edited by a moderator:

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

Latest Threads

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,859
Messages
1,017,030
Members
137,566
Latest member
Fl0shVS
Top