- Joined
- Jan 9, 2018
- Messages
- 21
- Reaction score
- 3
- First Language
- Spanish
- Primarily Uses
- RMMV
What I want to do is to have 2 separate odds for skills landing either direct hit, critical hit oro both, kinda like in Final Fantasy XIV. I managed to do it with Yanfly's Damage Core but I want the code to be flexible so I can make certain skills ensure direct for example.
I tried this but it doesn't work, and as my JS knowledge is a bit poor I don't know exactly where to follow.
Any help is appreciated, thanks!
I tried this but it doesn't work, and as my JS knowledge is a bit poor I don't know exactly where to follow.
Code:
Game_Action.prototype.apply = function(target) {
var result = target.result();
this.subject().clearResult();
result.clear();
result.used = this.testApply(target);
result.missed = (result.used && Math.random() >= this.itemHit(target));
result.evaded = (!result.missed && Math.random() < this.itemEva(target));
result.physical = this.isPhysical();
result.drain = this.isDrain();
if (result.isHit()) {
if (this.item().damage.type > 0) {
result.critical = (Math.random() < this.itemCri(target));
result.direct = this.checkDirectHit();
var value = this.makeDamageValue(target, result.critical, result.direct);
this.executeDamage(target, value);
}
this.item().effects.forEach(function(effect) {
this.applyItemEffect(target, effect);
}, this);
this.applyItemUserEffect(target);
}
};
Game_Action.prototype.checkDirectHit = function() {
return Math.floor(Math.random() * 100) < this.subject().luk;
};
// From Yanfly's DamageCore
Game_Action.prototype.makeDamageValue = function(target, critical, direct) {
var item = this.item();
var a = this.subject();
var b = target;
var user = this.subject();
var s = $gameSwitches._data;
var v = $gameVariables._data;
var baseDamage = this.evalDamageFormula(target);
var value = baseDamage;
console.log(critical);
try {
eval(Yanfly.DMG.DamageFlow);
} catch (e) {
Yanfly.Util.displayError(e, Yanfly.DMG.DamageFlow, 'DAMAGE FLOW ERROR');
}
return Math.round(value);
};