Script Call For Changing Encounter Rate?

IAmVianca

Veteran
Veteran
Joined
Nov 4, 2015
Messages
99
Reaction score
4
First Language
English
So, this is still part of my on-going crusade to complete my items database.


One of the items I have made (or am trying to make) is an item that increases the encounter rate for a set amount of time.


Now, I've set up everything except for actually HAVING that effect on the item.


I was wondering, what is the correct syntax to use on the Script Command that would allow me to change the encounter step?
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
5,610
Reaction score
5,080
First Language
English
Primarily Uses
RMVXA
I don't believe there is such a script line.


Instead, all modifications to Encounter Rate are, by default, handled in the encounterProgressValue method.


The easiest way to pull this off would probably be to make a State in the database called "Encounter Up" that expires after some amount of steps, and create a new property of $gameParty called has_encounter_up_state that checks to see whether any actor in the party has the Encounter Up state.  Finally, in the encounter progress value method, I'd add an if-branch that mutiplies the value by 2.0 (or whatever rate you want to set) if anyone in the party does have the Encounter Up state.


You will, of course, need to know a tiny bit of JavaScript to do this - it's simply not something you can do with a single line of syntax because there's no built-in method call to temporarily change the encounter rate.


For your reference, here's the method in question, which can be found in the rpg_objects base script.

Code:
Game_Player.prototype.encounterProgressValue = function() {
    var value = $gameMap.isBush(this.x, this.y) ? 2 : 1;
    if ($gameParty.hasEncounterHalf()) {
        value *= 0.5;
    }
    if (this.isInShip()) {
        value *= 0.5;
    }
    return value;
};
 

IAmVianca

Veteran
Veteran
Joined
Nov 4, 2015
Messages
99
Reaction score
4
First Language
English
I don't believe there is such a script line.


Instead, all modifications to Encounter Rate are, by default, handled in the encounterProgressValue method.


The easiest way to pull this off would probably be to make a State in the database called "Encounter Up" that expires after some amount of steps, and create a new property of $gameParty called has_encounter_up_state that checks to see whether any actor in the party has the Encounter Up state.  Finally, in the encounter progress value method, I'd add an if-branch that mutiplies the value by 2.0 (or whatever rate you want to set) if anyone in the party does have the Encounter Up state.


You will, of course, need to know a tiny bit of JavaScript to do this - it's simply not something you can do with a single line of syntax because there's no built-in method call to temporarily change the encounter rate.


For your reference, here's the method in question, which can be found in the rpg_objects base script.



Game_Player.prototype.encounterProgressValue = function() {
    var value = $gameMap.isBush(this.x, this.y) ? 2 : 1;
    if ($gameParty.hasEncounterHalf()) {
        value *= 0.5;
    }
    if (this.isInShip()) {
        value *= 0.5;
    }
    return value;
};


Oh, I thought you could change it since I saw in the help file an instance for encounterStep.


I'm not really good with Javascript, but I'm willing to give this a try...


How do I check for if the party has that state? I know I could check if an actor has one, but what if the player has opted not to take a party member with him and it happens to be the one I'm using to check if s/he has that encounter up state.
 

DreamX

Veteran
Veteran
Joined
May 30, 2015
Messages
816
Reaction score
825
First Language
English
Primarily Uses
alias_Game_Player_encounterProgressValue = Game_Player.prototype.encounterProgressValue;
Game_Player.prototype.encounterProgressValue = function () {
var value = alias_Game_Player_encounterProgressValue.call(this);

// state that reduces encounter rate
var stateId = 27;

// .1 = 10%
var encounterRateReduction = .1;

// checks all party members for the state
var shouldReduce = $gameParty.allMembers().some(function (member) {
return member.isStateAffected(stateId);
});

if (shouldReduce) {
value *= 1 - encounterRateReduction;
}

return value;
};


For your state you can set it to auto remove after a certain number of steps, in the database.
 
Last edited by a moderator:

IAmVianca

Veteran
Veteran
Joined
Nov 4, 2015
Messages
99
Reaction score
4
First Language
English
alias_Game_Player_encounterProgressValue = Game_Player.prototype.encounterProgressValue;
Game_Player.prototype.encounterProgressValue = function () {
var value = alias_Game_Player_encounterProgressValue.call(this);

// state that reduces encounter rate
var stateId = 27;

// .1 = 10%
var encounterRateReduction = .1;

// checks all party members for the state
var shouldReduce = $gameParty.allMembers().some(function (member) {
return member.isStateAffected(stateId);
});

if (shouldReduce) {
value *= 1 - encounterRateReduction;
}

return value;
};


For your state you can set it to auto remove after a certain number of steps, in the database.


I'm sorry.


I'm a bit confused, can you explain what these are to me?
 

DreamX

Veteran
Veteran
Joined
May 30, 2015
Messages
816
Reaction score
825
First Language
English
Primarily Uses
I'm sorry.


I'm a bit confused, can you explain what these are to me?
Change stateId to the id of the state that reduces the encounter rate.


Change encounterRateReduction to the amount that is subtracted from the encounter rate. .1 = 10%, so you wanted for example 50% reduction, you would use .5


Then put the code into a .js file and turn it on.
 

IAmVianca

Veteran
Veteran
Joined
Nov 4, 2015
Messages
99
Reaction score
4
First Language
English
Change stateId to the id of the state that reduces the encounter rate.


Change encounterRateReduction to the amount that is subtracted from the encounter rate. .1 = 10%, so you wanted for example 50% reduction, you would use .5


Then put the code into a .js file and turn it on.


But what if I wanted to increase the encounter rate up, instead of decreasing it?


Would I just change the .1 value to something else and add it instead of subtracting it?
 

DreamX

Veteran
Veteran
Joined
May 30, 2015
Messages
816
Reaction score
825
First Language
English
Primarily Uses
But what if I wanted to increase the encounter rate up, instead of decreasing it?


Would I just change the .1 value to something else and add it instead of subtracting it?
Oh sorry, I forgot that you wanted to increase for some reason.


Yea, you'd just change the - to +
 
Last edited by a moderator:

IAmVianca

Veteran
Veteran
Joined
Nov 4, 2015
Messages
99
Reaction score
4
First Language
English
Oh sorry, I forgot that you wanted to increase for some reason.


Yea, you'd just change the - to +


Thank you. I'll give this a try.


Yeah, I wanted to make an item that increases the encounter rate up.


I forgot to ask, but will I be able to manipulate this in-game by manipulating the value of the variable in-game as well?
 
Last edited by a moderator:

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

Latest Threads

Latest Posts

Latest Profile Posts

Having randomized space below my maps is like cheating, every map instantly starts out interesting. See? I just started on this one, and boom interesting!. :LZSexcite:

Moderators, you must have so much patience to be able to deal with everything. I mod in a server of sorts and today we just got a message, which, despite it's helpful constructive criticism, basically stated that all of the mods were jerks and that was the only reason our server was unlikeable. So, thank you, for having patience. You are appreciated! :kaoluv:
Haired slime? Trying some different styles of art. Maybe I can make some resources with this new kind of painting.......
i love my game very much
Uh, I'm probably overthinking this, but I think that some of my music sounds kinda...bad?
The melodies are just sort of awkward, and don't flow.
I'm really not sure what to do. Why am I even worrying about this? I don't even have a battle system yet!

Forum statistics

Threads
105,727
Messages
1,015,935
Members
137,410
Latest member
judicasino88
Top