- Joined
- Jun 25, 2013
- Messages
- 371
- Reaction score
- 125
- First Language
- English
- Primarily Uses
- RMMV
I found a piece of code I modified in order to use for Weapon Enchantment effects.
(Yanfly's state/buff plugin can be found here: http://yanfly.moe/2015/12/25/yep-50-buffs-states-core/)
The following is for my Fire weapon enchantment:
This enchantment deals 75% of the initial hit's damage. It triggers only once (though there is code present that I could modify to cause it to trigger more times, modify it's damage, etc.), chose the animation to play, as well as the chance for it to occur. However, I am running into an issue..... In my game, I have skills that can strike multiple times. This works perfectly fine, except in the case where a weapon enchantment is on your weapon. I have a skill that hits 5 times. This has been tested and functions perfectly. However, while using an enchanted weapon (the test was done using this Fire enchantment), it can hit many more times. I've had it hit as few as the intended 5 times, and as many as 15 times. Obviously this is near impossible to balance the skill around because you either feel like it's extremely weak and you aren't getting much out of it, or it's ridiculous and knocks off absurd chunks of HP. Furthermore, I utilize "good luck" mechanics, where if you score a critical hit, you are awarded with additional TP, and also if your weapon enchantment procs, you also gain TP. So, this skill in question has a 60 TP cost. The other problem I'm running into is that when the enchant procs ridiculously (as said previously, I've had the skill hit up to 15 times, which means the enchantment proc'd 10 times), you basically gain back ALL of the TP you use to cast the skill initially.
Still, the TP issue I can balance around, I think. But what I do need to figure out is, how can this code be modified to make the damage that is inflicted use an element that obeys the user's element rate and the target's elemental resistance? (I am using Yanfly's element core, linked here: http://yanfly.moe/2016/06/10/yep-107-element-core-rpg-maker-mv/)
I believe that once I can attach an element to these enchantment effects, I can finally tune around them. My plan is that, once able to attach an element to them, I can make the skills (all the multi-hit abilities in question) apply a state to the user that will reduce their TP regeneration and their damage via those elements to 0% to ensure the damage is drastically modified and you aren't regaining most/all of the TP used to cast the skill in question, and have that state only last during that turn, and be removed after.
Also, these enchantment effects are done using passive states (found here: http://yanfly.moe/2015/10/17/yep-13-auto-passive-states/), I have already tried adding a state that "resists" all of the enchantment effects during a multi-hit ability, but it doesn't look like it's possible to remove these passive effects, shy of removing the enchanted item. My thought process here was that I would make using a multi-hit skill apply a state to the user that made you resist the enchantment states, effectively "removing" the enchants from you during the turn this state was active, but this didn't work, as the enchantment states are passive, this did not remove them.
(Yanfly's state/buff plugin can be found here: http://yanfly.moe/2015/12/25/yep-50-buffs-states-core/)
The following is for my Fire weapon enchantment:
<Custom Establish Effect>
// Create empty pools for skills and skipp types.
var skills = [];
var skillTypes = [];
// Insert the skills this passive can be used with.
skills.push(1);
// Insert the skill types this passive can be used with.
skillTypes.push(2);
// Check if the action is a skill, the skill pool contain the skill or if the skill type pool contains the skill's type
if (this.isSkill() && (skills.contains(this.item().id)) || skillTypes.contains(this.item().stypeId)) {
// Check if the target exists and has suffered HP damage
if (target && target.result() && target.result().hpDamage > 0) {
// Make a copy of the target's original action results
var originalResult = JsonEx.makeDeepCopy(target._result);
// Clear those results
target.clearResult();
// Calculate the extra damage
var extraDmg = Math.ceil(0.75 * originalResult.hpDamage);
// Calculate the success rate to deal extra damage
var successRate = 0.30;
// Make the number of times struck
var struck = 0;
// Set the maximum number of times the action can be struck
var maxHits = 1;
// Make a loop
for (;
{
// Check if the target is alive and the action has passed the success rate
if (target.isAlive() && Math.random() < successRate) {
// Increase the number of times struck by 1
struck += 1;
// Make the target receive damage
target.gainHp(-extraDmg);
// Show the damage popup
target.startDamagePopup();
user.gainTp(6);
// Check if the target is dead
if (target.isDead()) {
// Make the target collapse
target.performCollapse();
}
// Clear the target's results
target.clearResult();
// Check if the number of times struck has hit the maximum
if (struck >= maxHits) {
// If it did, break the loop
break;
}
// If the extra damage success rate fails
} else {
// Then break the loop
break;
}
}
// If the number of times struck is greater than 0
if (struck > 0) {
// Then play an animation on the target
target.startAnimation(67);
}
// Revert the target's results back to its original results
target._result = originalResult;
}
}
</Custom Establish Effect>
// Create empty pools for skills and skipp types.
var skills = [];
var skillTypes = [];
// Insert the skills this passive can be used with.
skills.push(1);
// Insert the skill types this passive can be used with.
skillTypes.push(2);
// Check if the action is a skill, the skill pool contain the skill or if the skill type pool contains the skill's type
if (this.isSkill() && (skills.contains(this.item().id)) || skillTypes.contains(this.item().stypeId)) {
// Check if the target exists and has suffered HP damage
if (target && target.result() && target.result().hpDamage > 0) {
// Make a copy of the target's original action results
var originalResult = JsonEx.makeDeepCopy(target._result);
// Clear those results
target.clearResult();
// Calculate the extra damage
var extraDmg = Math.ceil(0.75 * originalResult.hpDamage);
// Calculate the success rate to deal extra damage
var successRate = 0.30;
// Make the number of times struck
var struck = 0;
// Set the maximum number of times the action can be struck
var maxHits = 1;
// Make a loop
for (;
// Check if the target is alive and the action has passed the success rate
if (target.isAlive() && Math.random() < successRate) {
// Increase the number of times struck by 1
struck += 1;
// Make the target receive damage
target.gainHp(-extraDmg);
// Show the damage popup
target.startDamagePopup();
user.gainTp(6);
// Check if the target is dead
if (target.isDead()) {
// Make the target collapse
target.performCollapse();
}
// Clear the target's results
target.clearResult();
// Check if the number of times struck has hit the maximum
if (struck >= maxHits) {
// If it did, break the loop
break;
}
// If the extra damage success rate fails
} else {
// Then break the loop
break;
}
}
// If the number of times struck is greater than 0
if (struck > 0) {
// Then play an animation on the target
target.startAnimation(67);
}
// Revert the target's results back to its original results
target._result = originalResult;
}
}
</Custom Establish Effect>
This enchantment deals 75% of the initial hit's damage. It triggers only once (though there is code present that I could modify to cause it to trigger more times, modify it's damage, etc.), chose the animation to play, as well as the chance for it to occur. However, I am running into an issue..... In my game, I have skills that can strike multiple times. This works perfectly fine, except in the case where a weapon enchantment is on your weapon. I have a skill that hits 5 times. This has been tested and functions perfectly. However, while using an enchanted weapon (the test was done using this Fire enchantment), it can hit many more times. I've had it hit as few as the intended 5 times, and as many as 15 times. Obviously this is near impossible to balance the skill around because you either feel like it's extremely weak and you aren't getting much out of it, or it's ridiculous and knocks off absurd chunks of HP. Furthermore, I utilize "good luck" mechanics, where if you score a critical hit, you are awarded with additional TP, and also if your weapon enchantment procs, you also gain TP. So, this skill in question has a 60 TP cost. The other problem I'm running into is that when the enchant procs ridiculously (as said previously, I've had the skill hit up to 15 times, which means the enchantment proc'd 10 times), you basically gain back ALL of the TP you use to cast the skill initially.
Still, the TP issue I can balance around, I think. But what I do need to figure out is, how can this code be modified to make the damage that is inflicted use an element that obeys the user's element rate and the target's elemental resistance? (I am using Yanfly's element core, linked here: http://yanfly.moe/2016/06/10/yep-107-element-core-rpg-maker-mv/)
I believe that once I can attach an element to these enchantment effects, I can finally tune around them. My plan is that, once able to attach an element to them, I can make the skills (all the multi-hit abilities in question) apply a state to the user that will reduce their TP regeneration and their damage via those elements to 0% to ensure the damage is drastically modified and you aren't regaining most/all of the TP used to cast the skill in question, and have that state only last during that turn, and be removed after.
Also, these enchantment effects are done using passive states (found here: http://yanfly.moe/2015/10/17/yep-13-auto-passive-states/), I have already tried adding a state that "resists" all of the enchantment effects during a multi-hit ability, but it doesn't look like it's possible to remove these passive effects, shy of removing the enchanted item. My thought process here was that I would make using a multi-hit skill apply a state to the user that made you resist the enchantment states, effectively "removing" the enchants from you during the turn this state was active, but this didn't work, as the enchantment states are passive, this did not remove them.