Hello everyone, I would to tweak how the default behaviour of enemies choosing their actions work.
As you know, skills in the Enemy Tab have a rating from 1 - 9.
The higher the rating, the more likely they are to use the skill.
However, when choosing skills, only the skill with the highest rating and skills
with a rating of 1 or 2 less will be considered.
So if the highest skill has a rating of 7, only skills of rating 7, 6 and 5 will be considered, with decreasing probabilities.
Now, I want to make the rating more a absolute priority, meaning the enemy ONLY considers the highest rated skill, or skill(s) if they share a rating.
So if you have 3 skills with ratings 3, 7 and 8, the enemy will ALWAYS choose the one with a rating of 8.
While experimenting by myself, I came across these two functions in rpg_objects.js which seem to be the only functions to reference the enemy skill ratings:
I am not confident enough in JS yet to know if these are in fact the right functions and if so, which numbers to tweak.
After some trial and error, I could not produce the results I wanted.
Thus I am asking if anyone has a solution for me.
Any help is appreciated.
As you know, skills in the Enemy Tab have a rating from 1 - 9.
The higher the rating, the more likely they are to use the skill.
However, when choosing skills, only the skill with the highest rating and skills
with a rating of 1 or 2 less will be considered.
So if the highest skill has a rating of 7, only skills of rating 7, 6 and 5 will be considered, with decreasing probabilities.
Now, I want to make the rating more a absolute priority, meaning the enemy ONLY considers the highest rated skill, or skill(s) if they share a rating.
So if you have 3 skills with ratings 3, 7 and 8, the enemy will ALWAYS choose the one with a rating of 8.
While experimenting by myself, I came across these two functions in rpg_objects.js which seem to be the only functions to reference the enemy skill ratings:
Code:
Game_Enemy.prototype.selectAction = function(actionList, ratingZero) { // rpg_objects.js - Line 4527
var sum = actionList.reduce(function(r, a) {
return r + a.rating - ratingZero;
}, 0);
if (sum > 0) {
var value = Math.randomInt(sum);
for (var i = 0; i < actionList.length; i++) {
var action = actionList[i];
value -= action.rating - ratingZero;
if (value < 0) {
return action;
}
}
} else {
return null;
}
};
Game_Enemy.prototype.selectAllActions = function(actionList) { // rpg_objects.js - Line 4545
var ratingMax = Math.max.apply(null, actionList.map(function(a) {
return a.rating;
}));
var ratingZero = ratingMax - 3;
actionList = actionList.filter(function(a) {
return a.rating > ratingZero;
});
for (var i = 0; i < this.numActions(); i++) {
this.action(i).setEnemyAction(this.selectAction(actionList, ratingZero));
}
};
I am not confident enough in JS yet to know if these are in fact the right functions and if so, which numbers to tweak.
After some trial and error, I could not produce the results I wanted.
Thus I am asking if anyone has a solution for me.
Any help is appreciated.