I've done some searching on the forums and on Google, but haven't found my answer. I am using Yanfly's Battle Core and setting up a side-view attack, but I'm not sure my question is specific to that. So if this needs to be on the script support forums, sorry for posting in the wrong forums!
Now on to my question. I'm trying to check if an enemy was hit by an actors ability. In RMVX Ace it was "target.result.hit?". That isn't giving me the results it did in Ace. It actually throws out "unexpected end" when I try to use that. I did some searching and saw "target.result().hit" and thought it was what I was looking for. It's not doing what it should either.
How do you check if an enemy was hit by an attack?
Checking if a target was hit
● ARCHIVED · READ-ONLY
-
-
Maybe by comparing the enemy's HP before and after the action ?
-
what InBlast said, but try the "manual override" approach.
you know there is an instruction to damage HP somewhere, so look for the instruction that takes HP from an enemy, and backtrack until you find the check for hit.
IIRC, in Ace, it checked for hit, then it checked for evasion, then for reflection, and then it made the damage calculation.
it's a block of 4 or 5 instructions that run one after another within the same function.
it should me much more easier for you to find specific instructions in .js files since they're plain text... just run a basic string search within the files.
EDIT:
I believe this is what you're looking for?
it's the one most similar to the function I mentioned in Ace
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)); var value = this.makeDamageValue(target, result.critical); this.executeDamage(target, value); } this.item().effects.forEach(function(effect) { this.applyItemEffect(target, effect); }, this); this.applyItemUserEffect(target); }};I tried looking for the HP calculation, didn't work, so I went to look for the skill itself.
that brought me to game_action.testItemEffect, then to game_action.itemHit, then to here. -
Thanks for the help! I'll give that a try. If that doesn't work, I can use what InBlast said. It won't be the simplest way, but it will work! :)