Skill that does 50% of DMG to random target?

Icenick

Veteran
Veteran
Joined
Mar 28, 2012
Messages
273
Reaction score
35
First Language
English
Primarily Uses
Im trying to make a set of skills based off Negative Ions,
When a target is affected by this state: Negative Ions, a portion of that damage will be shot off and hit another random target. After that, Negative Ions is removed.

However my skill has 2 steps;
Skill 111-113: Apply state 40, if state 40 is applied deals 50% of DMG dealt to a random enemy and removes state.
I use a custom script for my DMG formulas basically
Code:
if (b.isStateAffected(40)) {
b.removeState(40);    }
else {
b.addState(40);
}
Now I have other skills that apply this state but I only want Skills 111-113 to do the random DMG.

Under state 40 I have this code, it checks to see if the attack was from Skill 111/112/113.
Code:
<Custom Respond Effect>
if (this.isSkill() && user.currentAction().item().id === 111 || this.isSkill() && user.currentAction().item().id === 112 ||this.isSkill() && user.currentAction().item().id === 113){
if (target.result().hpDamage > 0) {
    var dmg = Math.ceil(target.result().hpDamage * 0.50);
    var group = target.friendsUnit().aliveMembers();
    group.splice(group.indexOf(target), 1);
    var member = group[Math.floor(Math.random() * group.length)];
    if (member) {
    member.startAnimation(76);
    member.gainHp(-dmg);
    member.startDamagePopup();
    if (member.isDead()) {
      member.performCollapse();
    }
    member.clearResult();}
  }
}
</Custom Respond Effect>
The problem im having is that whenever I use skills 111-113 it does the 50% dmg right away, it all happens at the same time applies the state then does the bonus effect. I dont know the code that could check after dmg but before the state is added.

I need to separate the timing so that casting this skill on a target without state 40 will apply state 40 and DMG. But when state 40 is already on the target from any source, thats when the skill now does DMG plus random enemy takes 50% of the primary damage.
 

Kenen

Veteran
Veteran
Joined
Apr 3, 2012
Messages
261
Reaction score
155
First Language
English
Primarily Uses
RMMV
My guess is that this is occurring because your damage formula is applying the state, and then the state's Custom Respond effect gets fulfilled in the same turn.

If I understand you correctly, you want the first usage of the skill to apply a state, and then the next usage of that skill will trigger a special effect if the state exists.

I would not try to do this using a state note tag... I would do everything with the skill itself.

Use an <After Eval> statement in the skill's note box (see Yanfly's Skill Core). Check to see if the state exists on the target. If it does, run your damage function(s). If the state does not exist, apply it, but do not run any damage functions.

Edit: make sure to remove the addState/removeState functions from your damage formula. If you don't, you'll run into the same timing issue where your damage formula applies the state, and then the skill's <After Eval> function is fulfilled on that same turn.
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,111
Reaction score
13,609
First Language
English
Primarily Uses
RMVXA

I've moved this thread to JavaScript Support. Please be sure to post your threads in the correct forum next time. Thank you.

 

Icenick

Veteran
Veteran
Joined
Mar 28, 2012
Messages
273
Reaction score
35
First Language
English
Primarily Uses
My guess is that this is occurring because your damage formula is applying the state, and then the state's Custom Respond effect gets fulfilled in the same turn.

If I understand you correctly, you want the first usage of the skill to apply a state, and then the next usage of that skill will trigger a special effect if the state exists.

I would not try to do this using a state note tag... I would do everything with the skill itself.

Use an <After Eval> statement in the skill's note box (see Yanfly's Skill Core). Check to see if the state exists on the target. If it does, run your damage function(s). If the state does not exist, apply it, but do not run any damage functions.

Edit: make sure to remove the addState/removeState functions from your damage formula. If you don't, you'll run into the same timing issue where your damage formula applies the state, and then the skill's <After Eval> function is fulfilled on that same turn.
Ah that makes sense. I was trying to get everything as clean as possible into one formula.

Code:
<Post-Damage Eval>
if (b.isStateAffected(40)) {
    var dmg = Math.ceil(target.result().hpDamage * 0.50);
    var group = target.friendsUnit().aliveMembers();
    group.splice(group.indexOf(target), 1);
    var member = group[Math.floor(Math.random() * group.length)];
    if (member) {
    member.startAnimation(76);
    member.gainHp(-dmg);
    member.startDamagePopup();
    if (member.isDead()) {
      member.performCollapse();
    member.clearResult();}
    }
}
</Post-Damage Eval>

<After Eval>
if (b.isStateAffected(40)) {
b.removeState(40)
  }
else {
b.addState(40);}
</After Eval>
It works like this! Thanks

Edit: Kenen, do you have any idea how to implement this with multiple attacks? I have one of my skills hit 4 times but I want to check if the state is applied only once, even with After Eval it applies and removes the state for each hit. Is there a way to get it only once?
Edit2:
If I do something like this it kinda works but im having another issue. The skill in question I want to target the front row of enemies. It attacks 4 times, if at any point the front row is clear the remaining attacks move down to next row and targets those enemies. It works in the sense that at the end any target who has state 40 will be removed and any without will be added, but the targeting the next row doesnt work.

Code:
<Whole Action>
move user: target, front base, 5
wait for movement
wait: 20
motion swing: user
action animation
wait for animation
action effect
collapse: target, force
wait: 20
motion swing: user
action animation
wait for animation
action effect
collapse: target, force
wait: 20
motion swing: user
action animation
wait for animation
action effect
collapse: target, force
wait: 20
motion swing: user
action animation
wait for animation
action effect
collapse: target, force
</Whole Action>

<target action>
if target.isStateAffected(40)
remove state 40: target
else
add state 40: target
end
</target action>
 
Last edited:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Newest RPG Maker drops: hey fellas, get on the MZ train to somewhere

Me: Building my VX Ace lego tower, blissfully unaware of time moving forward
When you are trying to make progress in your game. But something is stopping your motivation. Like come on mind! Let me do what I want! :<
Tfw everyone is trying their hardest to brainstorm about unique ideas and game mechanics, here I am just going: "How am I gonna event conversations with busts" everyday. :kaoswt2:
Comedy is third person, tragedy is first person.
Man. A historic 130 year old church nearby had all of its windows broken out with bricks last night. Such a shame, it wasn't generic stained glass patterns either but had beautifully crafted murals depicting various parts of the gospels.

Forum statistics

Threads
99,320
Messages
964,132
Members
130,927
Latest member
Gigabitz
Top