So i'm using this enemy level script here by ぶちょー
Now my problem is when there is no additional item drop on enemy level up i get error.. reduce of undefined.. however when i do define an additional item when level up, the plugin works correct and smoothly!
original code from Game_Troop.makeDropItems
KZR_EnemyLevel.js code
also i have another problem, the plugin help states that i can use v[x] for eval on the "level" parameter, but when i put level:v[10], for gameVariable ID 10.. it becomes undifined or NaN in game.
Now my problem is when there is no additional item drop on enemy level up i get error.. reduce of undefined.. however when i do define an additional item when level up, the plugin works correct and smoothly!
original code from Game_Troop.makeDropItems
JavaScript:
Game_Enemy.prototype.makeDropItems = function() {
return this.enemy().dropItems.reduce(function(r, di) {
if (di.kind > 0 && Math.random() * di.denominator < this.dropItemRate()) {
return r.concat(this.itemObject(di.kind, di.dataId));
} else {
return r;
}
}.bind(this), []);
KZR_EnemyLevel.js code
JavaScript:
var _kzr_enemy_level_Game_Enemy_makeDropItems = Game_Enemy.prototype.makeDropItems;
Game_Enemy.prototype.makeDropItems = function() {
var result = _kzr_enemy_level_Game_Enemy_makeDropItems.call(this);
//if (this._dropItems.length !== 0) {
return result.concat(this._dropItems.reduce(function(r, di) {
if (di.kind > 0 && Math.random() * di.denominator < this.dropItemRate()) {
return r.concat(this.itemObject(di.kind, di.dataId));
} else {
return r;
}
}.bind(this), []));//}
};
also i have another problem, the plugin help states that i can use v[x] for eval on the "level" parameter, but when i put level:v[10], for gameVariable ID 10.. it becomes undifined or NaN in game.
JavaScript:
Game_Enemy.prototype.ELgetValue = function(formula) {
formula = formula.replace(/level/g, 'this._level');
formula = formula.replace(/v\[(\d+)\]/gi, function() {
return $gameVariables.value(parseInt(arguments[1]));
}.bind(this));
formula = formula.replace(/random\((-)?(\d+),(-)?(\d+)\)/gi, function() {
var min = parseInt(arguments[2]);
if (arguments[1]) min *= -1;
var max = parseInt(arguments[4]);
if (arguments[3]) max *= -1;
return Math.floor(Math.random() * (max - min + 1)) + min;
}.bind(this));
return eval(formula);
};