Skip to content

Instantly share code, notes, and snippets.

@hajimehoshi
Created December 21, 2015 01:33
Show Gist options
  • Save hajimehoshi/3317ee9e1d52ef5b996b to your computer and use it in GitHub Desktop.
Save hajimehoshi/3317ee9e1d52ef5b996b to your computer and use it in GitHub Desktop.
RPG Maker MV: Bug fix in Game_Action
Game_Action.prototype.decideRandomTarget = function() {
var target;
if (this.isForDeadFriend()) {
target = this.friendsUnit().randomDeadTarget();
} else if (this.isForFriend()) {
target = this.friendsUnit().randomTarget();
} else {
target = this.opponentsUnit().randomTarget();
}
if (target) {
this._targetIndex = target.index();
} else {
this.clear();
}
};
Game_Action.prototype.evaluate = function() {
var value = 0;
this.itemTargetCandidates().forEach(function(target) {
var targetValue = this.evaluateWithTarget(target);
if (this.isForAll()) {
value += targetValue;
} else if (targetValue > value) {
value = targetValue;
this._targetIndex = target.index();
}
}, this);
value *= this.numRepeats();
if (value > 0) {
value += Math.random();
}
return value;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment