Hi everyone, I want to make a skill that deals area damage if the enemy has a specific status. For example, if the enemy has a status and I use an electric-type skill on it, it will deal 20% damage to that enemy but also to adjacent enemies (I don't care about the percentage). Does anyone know how I could do it? I use RPG Maker MZ and I have the Visustella plugin.
Area damage skill
RPG Maker MZ SupportHmmm you can just check in the damage formula if the target is stateAffected and deal more damage. Then check in action sequence if the target is state affected and then go through all alive members of gameTroop and compare their coordinates to the target coordinate. Use like pythagorean theorem to get the distance I think, if that's like equal or less than a certain number then you play animations on those enemies and lower their hp.
EDIT: Oh yeah, you need to take the original target out of the $gameTroop.aliveMembers() when checking additional targets. Or you can also ignore it by not doing the area damage stuff if the distance to the original target is 0, I think.
EDIT 2: Didn't have time yesterday to write the scripts, but I tried it now, and something like this should work (but the sprite origins are bottom-left(?), I think, so if you want it to work smoother you'd probably have to add/subtract from the coordinate values). Put it in action sequence after action effect:
EDIT: Oh yeah, you need to take the original target out of the $gameTroop.aliveMembers() when checking additional targets. Or you can also ignore it by not doing the area damage stuff if the distance to the original target is 0, I think.
EDIT 2: Didn't have time yesterday to write the scripts, but I tried it now, and something like this should work (but the sprite origins are bottom-left(?), I think, so if you want it to work smoother you'd probably have to add/subtract from the coordinate values). Put it in action sequence after action effect:
let xDist = 0;let yDist = 0;let distance = 0;let targetX = $gameTroop.members()[$gameTemp.lastActionData(5)-1].battler().x;let targetY = $gameTroop.members()[$gameTemp.lastActionData(5)-1].battler().y;$gameTroop.aliveMembers().forEach((enemy) => {xDist = targetX - enemy.battler().x;yDist = targetY - enemy.battler().y;distance = Math.sqrt(Math.pow(xDist, 2) + Math.pow(yDist, 2));if (distance > 0 && distance < 300) {$gameTemp.requestAnimation([enemy], 10);enemy.gainHp(-1000);if (enemy.isDead()) {enemy.performCollapse();}}})In case you missed it, @rpgLord69 made an edit to their post. 👋
I.e. "deal 0.2x damage iff the target is affected by state 123; otherwise deal 1x damage". If you actually wanted 20% more damage, replace
Alternatively maybe a
E.g. if the "status" in question is state ID 123:
(a.mat * 2 - b.mdf) * (b.isStateAffected(123) ? 0.2 : 1)I.e. "deal 0.2x damage iff the target is affected by state 123; otherwise deal 1x damage". If you actually wanted 20% more damage, replace
0.2 with 1.2.By default they're anchored bottom-centre, i.e. (0.5, 1). Plugins might change that, though.
That code looks promising! Would want to swap out the
1000 for an actual damage formula. I might be misremembering but I think VisuStella Battle Core provides scripting variables for use in action sequences: $subject and $target or something like that?Alternatively maybe a
<JS Post-Damage> tag could work (also from VisuStella Battle Core). I think that also offers a value variable so you can reference the damage result?Yeah, I put the 1000 there only as a test. And you're right, you get the damage with:
VS BattleCore also has a setting for a variable that stores the damage you dealt, so you can use it too.
Also, yeah, you can use the $target shortcut instead of the last action data stuff.
EDIT: You can also throw the
<JS Post-Damage>$gameVariables.setValue(X, value);</JS Post-Damage>VS BattleCore also has a setting for a variable that stores the damage you dealt, so you can use it too.
Also, yeah, you can use the $target shortcut instead of the last action data stuff.
EDIT: You can also throw the
enemy.startDamagePopup(); in there.Original thread: https://forums.rpgmakerweb.com/threads/area-damage-skill.177620/