mellanny

I have no idea what I'm doing
Veteran
Joined
May 4, 2020
Messages
101
Reaction score
33
First Language
Portuguese
Primarily Uses
RMMV
Long story short, I don't know much about Javascript so I'm kinda struggling with some customized skill and state effects. I have all of Yanfly plugins and am currently using RPG Maker MV.

I'm creating a Necromancer, so I have a lot of skills that deal damage to enemies and heal the user/allies right after. I can simply use "Drain HP" with some of them, but with others I need plugins, either to target allies and not only the user, either to have different effects when targeting allies or enemies etc. So far I've been using some of Yanfly's Tips & Tricks as a guide, tweaking here and there until I get my desired effect, but there are a few things that I'm failing to understand. For example, I can see that in the Healing Fate effect, the received damage is get from the "target.result().hpDamage" call, whereas in the Holy Prism effect, it's simply through a "value" variable. So, I was wondering if maybe someone could help me understand why this happens? It's so confusing :kaoeh:

Each skill notetag's code:
Code:
<Custom Apply Effect>
// Set the Healing Fate HP damage to 0.
target._healingFateDmg = 0;
</Custom Apply Effect>

<Custom Remove Effect>
// Set the Healing Fate HP damage to 0.
target._healingFateDmg = 0;
</Custom Remove Effect>

<Custom Respond Effect>
// Check if the effect is an HP effect and if the target received HP damage.
if (this.isHpEffect() && target.result().hpDamage > 0) {
  // Increase the target's Healing Fate HP damage by damage received.
  target._healingFateDmg += target.result().hpDamage;
  // Check if the amount of total HP Healing Fate damage exceeds more than 20% of the target's MaxHP.
  if (target._healingFateDmg >= target.mhp * 0.20) {
    // If it does, remove this state.
    target.removeState(stateId);
    // Get all the original caster's allies.
    var members = origin.friendsUnit().aliveMembers();
    // Calculate the amount of HP healed.
    var hpHealed = origin.mdf * 2;
    // Loop through each one of them.
    for (var i = 0; i < members.length; ++i) {
      // Get the currently looped member.
      member = members[i];
      // If the member exists...
      if (member) {
        // Then the member gains the calculated HP.
        member.gainHp(hpHealed);
        // Play an animation on the member.
        member.startAnimation(46);
        // Start the damage popup.
        member.startDamagePopup();
        // Clear the results.
        member.clearResult();
      }
    }
  }
}
</Custom Respond Effect>

Code:
// Allows the player to pick an enemy or an ally.
<Enemy or Actor Select>

<Damage Formula>
// Check if the user and target are enemies.
if (a.isActor() !== b.isActor()) {
  // If they are, this is the amount of damage dealt.
  value = a.mat * 4;
// If they are allies...
} else {
  // This is the amount of HP healed.
  value = a.mat * 6;
}
</Damage Formula>

<Pre-Damage Eval>
// If the user and the target are enemies...
if (a.isActor() !== b.isActor()) {
  // Get half of the damage dealt.
  var hp = Math.floor(value / 2);
  // Get the alive members of the user's party.
  var members = user.friendsUnit().aliveMembers();
  // Loop through each member.
  for (var i = 0; i < members.length; ++i) {
    // Get the current member.
    var member = members[i];
    // If the member exists...
    if (member) {
      // ...then the member recovers HP.
      member.gainHp(hp);
      // Start the damage popup.
      member.startDamagePopup();
      // Clear the results.
      member.clearResult();
      // Start an animation.
      member.startAnimation(41);
    }
  }
// If the user and the target are allies...
} else {
  // Then get half of the value healed.
  var hp = Math.floor(value / 2);
  // Turn it into damage.
  value *= -1;
  // Get the user's opponent party's living members.
  var members = user.opponentsUnit().aliveMembers();
  // Loop through those members.
  for (var i = 0; i < members.length; ++i) {
    // Get the current member.
    var member = members[i];
    // If the member exists...
    if (member) {
      // Modify the damage received relative to the Holy element.
      var dmg = -hp * member.elementRate(13);
      // Make the member take damage.
      member.gainHp(dmg);
      // Start the damage popup.
      member.startDamagePopup();
      // Clear the results.
      member.clearResult();
      // Start an animation.
      member.startAnimation(97);
      // Check if the member is dead.
      if (member.isDead()) {
        // If it is, make it collapse.
        member.performCollapse();
      }
    }
  }
}
</Pre-Damage Eval>

I could also use some help tweaking the Leech Seed skill (I'd like the user to give 10% of his HP to an ally and/or be able to drain his ally's HP, same skill or not) and the Void Shift skill (I'd like to transfer values rather than HP rates). Maybe I should create a new topic for this? :kaoeh: Thanks in advance for anyone who read through it all
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,713
Reaction score
2,830
First Language
English
Primarily Uses
RMMZ
The value vs target.result().hpDamage question is to do with timing. In the Healing Fate effect, it's a Custom Respond Effect, which runs after damage is already taken. This means the target's result() will contain the actual damage done, and so it's referenced there to get the amount.

In the case of Holy Prism, it's a Pre-Damage Eval, meaning damage has *not* been dealt yet. The amount of *intended* damage is stored in the "value" variable, but you can't use result().hpDamage there because it hasn't been updated at that point.

Note that you could have also used "value" in Healing Fate, but for whatever reason Yanfly referred directly to the action result instead. There are a few where he does this, but in those cases it doesn't really make a difference which you use.

Regarding your Leech Seed tweaks, how are you proposing to have two effects on the same skill? And what do you mean by "values rather than HP rates" for Void Shift?
 

mellanny

I have no idea what I'm doing
Veteran
Joined
May 4, 2020
Messages
101
Reaction score
33
First Language
Portuguese
Primarily Uses
RMMV
The value vs target.result().hpDamage question is to do with timing. In the Healing Fate effect, it's a Custom Respond Effect, which runs after damage is already taken. This means the target's result() will contain the actual damage done, and so it's referenced there to get the amount.

In the case of Holy Prism, it's a Pre-Damage Eval, meaning damage has *not* been dealt yet. The amount of *intended* damage is stored in the "value" variable, but you can't use result().hpDamage there because it hasn't been updated at that point.

Note that you could have also used "value" in Healing Fate, but for whatever reason Yanfly referred directly to the action result instead. There are a few where he does this, but in those cases it doesn't really make a difference which you use.
Oh, thank you so much! It makes a lot of sense actually.

Regarding your Leech Seed tweaks, how are you proposing to have two effects on the same skill?
I was thinking something to do with Yanfly's Selection Control plugin, and some sort of "if" statement (kinda like holy prism actually, but I haven't tried this yet - I'll do it right after posting this answer) so if the target is an actor, the user gives him HP every turn; if it's a foe, the foe gives the user HP every turn (so it would need two different states). I tried this with a new state that simply changed "target" and "origin" from the original Leech Seed, but the game crashed and, as far as my googling could tell, it was because I could not deal damage to my own party.

edit: got it. I don't know what I was trying to do before, but I managed to make it work now lol

And what do you mean by "values rather than HP rates" for Void Shift?
The Void Shift skill switches the current HP percentage between user/target, I'd want it to switch current HP value.
ie: user has 1500/2000 HP and target has 500/1000 HP - with Void Shift, user would change to 1000/2000 and target to 750/1000. I'd like it to be 500/2000 for the user and 1000/1000 for target (maybe plus 500 barrier points), but was confused about that "value variable" I mentioned earlier, so I didn't know how to properly get it.


edit: aaaaand I just realized it was that easy. In case anyone wants it, I'll leave both codes here:

This goes on a skill notetag:

Code:
<Enemy or Actor Select>

// Instant Cast
<Instant>

// Selection Control
// Prevent User from selecting itself
<Select Conditions>
Not User
</Select Conditions>

// Skill Core
<After Eval>
// Gets the HP% of the user.
var hp1 = user.hp;
// Gets the HP% of the target.
var hp2 = target.hp;

// Gets how much HP is missing for the user.
var missHp1 = user.mhp - user.hp;
// Gets how much HP is missing for the target.
var missHp2 = target.mhp - target.hp;

// Animation ID for dropping HP.
var aniLower = 58;
// Animation ID for raising HP.
var aniUpper = 46;

// Check which is the lower of the two.
if (hp1 > hp2) {
  // Set minimum value of lower hp to 100.
  hp2 = Math.max(100, hp2);
} else {
  // Set minimum value of lower hp to 100.
  hp1 = Math.max(100, hp1);
}


// Check if user's HP% will be lowered.
if (user.hp > hp2) {
  // Play dropping HP animation on user.
  user.startAnimation(aniLower);
} else {
  // Play raising HP animation on user.
  user.startAnimation(aniUpper);
}


// Check if target's HP% will be lowered.
if (target.hp > hp1) {
  // Play dropping HP animation on target.
  target.startAnimation(aniLower);
} else {
  // Play raising HP animation on user.
  target.startAnimation(aniUpper);
}

// Set user's HP to calculated amount.
user.setHp(hp2);
// Set target's HP to calculated amount.
target.setHp(hp1);

// Check if missing HP is lower than value to receive - user
if (missHp1 < hp2) {
// Creates a barrier equal to half of the excedent value
var barrier1 = Math.ceil((hp2 - missHp1) * 0.5)
user.gainBarrier(barrier1, 1)
}

// Check if missing HP is lower than value to receive - target
if (missHp2 < hp1) {
// Creates a barrier equal to half of the excedent value
var barrier2 = Math.ceil((hp1 - missHp2) * 0.5)
target.gainBarrier(barrier2, 1)
}

</After Eval>

I have a "Leech Seed" state and a second Leech Seed state, but swaping "origin" and "target". The following goes on a skill notetag:

Code:
<HP Cost: 300>

<Enemy or Actor Select>
<Select Conditions>
Not User
</Select Conditions>

<target action>
perform action
motion wait: user
if user.isActor() && target.isActor()
  animation 128: user
  wait: 30
  action animation: target
  add state 115: target
else
  action animation: user
  wait: 30
  animation 128: target
  add state 114: target
end
</target action>
 
Last edited:

Latest Threads

Latest Profile Posts

:kaoswt2: Steam seems down again... oh nevermind, it's up now
After so long, my random sprites set is complete! I wonder who could guess them all? :kaothx:
2COlHup.png

And yes, I'm doing more.
I'm thinking of devouring some tutorials for RPG Maker MV. Just all kinds: mapping, spriting, programming, ect. the whole works! :)

Maybe videos, my brother and I can sit down and watch them during one of our weekly business meetings.
Ami
trying to make a Dialogue Script in Indonesian,first. then translate into English.

this is the reason why i'm terrible at this section beside making the enemies :stare:

Forum statistics

Threads
113,928
Messages
1,078,458
Members
148,035
Latest member
Resticon
Top