Hey guys,
Hope you are all well.
I am hoping someone could point me into the right direction regarding a little problem that I am facing.
In my project the Thief class can place a spike trap in combat. It will afflict them with a state dealing damage to melee attackers and with a chance to cause a bleeding state.
I have accomplished that using Yanflys Buffs and State Core and it works fine using the code below:
Plugin here: http://www.yanfly.moe/wiki/Buffs_&_States_Core_(YEP)
<Custom Deselect Effect>
// Check to see if any physical damage is dealt and if it is not a ranged attack (element 8=range)
if (this.isPhysical() && this.item().damage.elementId !== 8) {
user.gainHp(- b.def)
user.startDamagePopup();
var chance = 0.2; // Chance for inflicting state. 0.2 is 20%.
var stateID = 81; // Replace with state id of bleeding state.
if (Math.random() < chance) user.addState(stateID);
if (user.isDead()) {
// If the attacker is dead, make it collapse.
user.performCollapse();
}
}
</Custom Deselect Effect>
I have recently added a "Floating" skill to the game. Characters affected by this would ignore any damage from traps or ground damage of any sort.
My question being now how do I check for this 3rd condition as well? Floating Characters gain a skill called Flying Attack. So if a Flying attack was performed on an enemy that has placed a spike trap, no damage should be dealt to the attacker by the trap.
So my initial thought was:
if (this.isPhysical() && this.item().damage.elementId !== 8) && user.currentAction().item().id !== 7) {
// check if it is a physical attack, check that it is not a range attack, check that it is not Skill 7 which is the Flying Attack
However when the Flying Attack is being used, damage is still dealt to the attacker....
Does someone have any pointers as to how I need to adjust the code to make this work properly?
Any pointers are much aprichiated,
Thank you
Hope you are all well.
I am hoping someone could point me into the right direction regarding a little problem that I am facing.
In my project the Thief class can place a spike trap in combat. It will afflict them with a state dealing damage to melee attackers and with a chance to cause a bleeding state.
I have accomplished that using Yanflys Buffs and State Core and it works fine using the code below:
Plugin here: http://www.yanfly.moe/wiki/Buffs_&_States_Core_(YEP)
<Custom Deselect Effect>
// Check to see if any physical damage is dealt and if it is not a ranged attack (element 8=range)
if (this.isPhysical() && this.item().damage.elementId !== 8) {
user.gainHp(- b.def)
user.startDamagePopup();
var chance = 0.2; // Chance for inflicting state. 0.2 is 20%.
var stateID = 81; // Replace with state id of bleeding state.
if (Math.random() < chance) user.addState(stateID);
if (user.isDead()) {
// If the attacker is dead, make it collapse.
user.performCollapse();
}
}
</Custom Deselect Effect>
I have recently added a "Floating" skill to the game. Characters affected by this would ignore any damage from traps or ground damage of any sort.
My question being now how do I check for this 3rd condition as well? Floating Characters gain a skill called Flying Attack. So if a Flying attack was performed on an enemy that has placed a spike trap, no damage should be dealt to the attacker by the trap.
So my initial thought was:
if (this.isPhysical() && this.item().damage.elementId !== 8) && user.currentAction().item().id !== 7) {
// check if it is a physical attack, check that it is not a range attack, check that it is not Skill 7 which is the Flying Attack
However when the Flying Attack is being used, damage is still dealt to the attacker....
Does someone have any pointers as to how I need to adjust the code to make this work properly?
Any pointers are much aprichiated,
Thank you