Zerothedarklord

Veteran
Veteran
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:
<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.
 

Fernyfer775

Veteran
Veteran
Joined
Oct 6, 2013
Messages
1,319
Reaction score
829
First Language
English
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.

When testing this method, did you try to make a conditional check in your code to have it only activate IF the character is NOT affected by the "lockout" state? You could have your multi-hit abilities apply a hidden state after the 1st hit, and then in your enchantment codes add another conditional to it:
if (!user.isStateAffected(X)){
ALL OTHER ENHANCEMENT CODE HERE
}

Give the hidden state a 1 turn duration and it'll just fall off naturally at the end of the turn.
 

Zerothedarklord

Veteran
Veteran
Joined
Jun 25, 2013
Messages
371
Reaction score
125
First Language
English
Primarily Uses
RMMV
I didn't, I wasn't sure how to do that. but thank you sir, after testing it, it seems like it is working now. awwwww yeah!


Still, how hard would it be to attach an element to these enchantment effects? Would it be possible to add in a line to that code that would assign an element to it?

And also, is it possible to add in a line that designates it as a magical or a physical attack?
This part isn't tremendously important, but for the sake of magic shields/barriers, it could be useful to be able to designate things as either magical or physical so that they can either be blocked by, or bypass barriers.
 
Last edited:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,693
Reaction score
3,031
First Language
Tagalog
Primarily Uses
RMVXA
Since you're handling the damage yourself in that code, you would simply recalculate extraDamage factoring the element rate needed and the target's resistance

Something along the line of

extraDamage = extraDamage*elementrate*resistance

as for the barriers, since you are directly "dealing" the damage via that notetag, you will need to factor the barriers etc in that notetag too since most plugins that do barriers rely on the default code's damage dealing process (which you dont use in your extra damage), unless ofc they actually capture the .gainHP instead but still, adding magical/physical to the current custom damage behavior seems pretty complicated.
 

Zerothedarklord

Veteran
Veteran
Joined
Jun 25, 2013
Messages
371
Reaction score
125
First Language
English
Primarily Uses
RMMV
Since you're handling the damage yourself in that code, you would simply recalculate extraDamage factoring the element rate needed and the target's resistance

Something along the line of

extraDamage = extraDamage*elementrate*resistance
So would I just add in a line, say, near the top of the code in the state that defines which element to use, and then add in that formula?
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,693
Reaction score
3,031
First Language
Tagalog
Primarily Uses
RMVXA
You dont even need to define the element as you can supply the element ID in the formula directly (though doing it in a variable is good especially if you're gonna use it multiple times in that notetag) as long as you know the code to get the element rate from Yanfly's plugin and the element resistance of the target (something that sadly I cannot check for you right now)

Take note that this is only true if all you need from the element is its effect on the damage value.
 
Last edited:

Zerothedarklord

Veteran
Veteran
Joined
Jun 25, 2013
Messages
371
Reaction score
125
First Language
English
Primarily Uses
RMMV
You dont even need to define the element as you can supply the element ID in the formula directly (though doing it in a variable is good especially if you're gonna use it multiple times in that notetag) as long as you know the code to get the element rate from Yanfly's plugin and the element resistance of the target (something that sadly I cannot check for you right now)
by "in the formula directly", do you mean in the part in the code where the damage is written? This part, var extraDmg = Math.ceil(0.75 * originalResult.hpDamage);
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,693
Reaction score
3,031
First Language
Tagalog
Primarily Uses
RMVXA
Yes, you could either input it on that formula or add a new line after
 

Zerothedarklord

Veteran
Veteran
Joined
Jun 25, 2013
Messages
371
Reaction score
125
First Language
English
Primarily Uses
RMMV
Allow me to present a potential alternative, would it be feasible to just change my magic shield absorb damage based on element IDs, rather than "if attack is physical/magical"?
Here is the code for my current magic shield:
<Custom Apply Effect>

target._blackShield = Math.round(origin.atk * 5);

target.setStateCounter(65, target._blackShield);

</Custom Apply Effect>



<Custom React Effect>

if (this.isMagical()) {

if (target._blackShield - value > 0) {

target._blackShield -= value;

target.setStateCounter(65, target._blackShield);

value = 0;

} else {

value -= target._blackShield;

target.removeState(65);

}

}

</Custom React Effect>

As you can see, the only check it runs if "if (this.isMagical())", how plausible would it be to change it to, for example, something like "if (this.element(list of element IDs to block))"? If it could be done, what exactly would I write?
 

Zerothedarklord

Veteran
Veteran
Joined
Jun 25, 2013
Messages
371
Reaction score
125
First Language
English
Primarily Uses
RMMV
You dont even need to define the element as you can supply the element ID in the formula directly (though doing it in a variable is good especially if you're gonna use it multiple times in that notetag) as long as you know the code to get the element rate from Yanfly's plugin and the element resistance of the target (something that sadly I cannot check for you right now)

Take note that this is only true if all you need from the element is its effect on the damage value.
Also, as for this, I would want it to define the damage being dealt as X element, and ALSO calculate damage based on user rate and target resistance. furthermore, if the damage formula, ( var extraDmg = Math.ceil(0.75 * originalResult.hpDamage); ) would have to be rewritten/refined to make this possible, that'd be fine too. I would be cool with making it deal damage based on a stat anyway, maybe something like
"this.damage = elementId (2);
damage = (origin.atk * 3) * elementrate * elementresist;"
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,693
Reaction score
3,031
First Language
Tagalog
Primarily Uses
RMVXA
You could theoretically change the barrier to take elements instead of phy/mag but the problem is that, your extraDamage will probably not be caught by the barrier code unless the barrier code is tapping into the .gainHP function, which means even if you can change it to use elements it will probably still not block the extraDamage.

We need to actually check the plugin code that runs your barrier to determine if it will actually catch your extraDamage or not.

Also, as for this, I would want it to define the damage being dealt as X element, and ALSO calculate damage based on user rate and target resistance

As I said, if you know how to call the element rate from Yanfly's plugin and the target's element resistance, all you need to do is apply them on your current formula.

Your formula would then really just be

var extraDamage = (your base value) * Element rate from Yanfly * Target's Element Resistance
 
Last edited:

Zerothedarklord

Veteran
Veteran
Joined
Jun 25, 2013
Messages
371
Reaction score
125
First Language
English
Primarily Uses
RMMV
unfortunately I don't, and it doesn't sound like there's an easy way to do this either. it sounds like regardless how I try to do it, it's gonna be a lot of code I don't know.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,693
Reaction score
3,031
First Language
Tagalog
Primarily Uses
RMVXA
The element part should be easy because there will always be a function to call to get the values, we just need to know which function is that.. I'll try to check Yanfly's plugin later as you have a link anyway.

Code:
var elementId = 2; //change to your element id
var extraDamage = your original formula
extraDamage = extraDamage*user.elementMagnifyRate(elementId)*target.elementRate(elementId)

The barrier part, that's what might be complicated. The barrier itself is already complicated in the sense that it needs some of Yanfly's plugins that kinda modifies how the flow of things work, making it work with something that also doesn't follow the normal code could be more complicated.

You could try to make the extra damage as a forced skill action just so it will at least follow the normal way of damage calculation..
 
Last edited:

Zerothedarklord

Veteran
Veteran
Joined
Jun 25, 2013
Messages
371
Reaction score
125
First Language
English
Primarily Uses
RMMV
either letting a barrier read and protect against X element, or letting enchants be treated as magical effects, either one is fine with me, whichever one would be easier to achieve. What I want to do is have an enemy who uses a magic-absorbing barrier, and I want it to be able to absorb the damage of weapon enchants in addition to spells, since all weapon enchants will deal some kind of magical damage. so if defining enchantment effects as magical would be easier than worrying about all of the element stuff, that works fine for me. if dealing with all the element stuff is easier, that works fine too.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,693
Reaction score
3,031
First Language
Tagalog
Primarily Uses
RMVXA
Uhm, both phy/mag or element based barrier can be hard because as I said it depends on when they actually block the damage in the plugin code. If they block damage during the gainHp function, the barrier can block your extraDamage but if not, then they wont block your extraDamage.

The essential part here is if they block during the gainHp function or not, because that is how your extraDamage is being dealt to the target.

Theoretically they aren't because by that time even the phy/mag doesnt exist anymore (gainHp only takes the value as parameter so any other reference to damage cause is lost at that point) so your current shield wouldnt even work with normal damage.

anyway for the elemental damage, try this:

Code:
var elementId = 2; //change to your element id
var extraDamage = your original formula
extraDamage = extraDamage*user.elementMagnifyRate(elementId)*target.elementRate(elementId);
 
Last edited:

Zerothedarklord

Veteran
Veteran
Joined
Jun 25, 2013
Messages
371
Reaction score
125
First Language
English
Primarily Uses
RMMV
Uhm, both phy/mag or element based barrier can be hard because as I said it depends on when they actually block the damage in the plugin code. If they block damage during the gainHp function, the barrier can block your extraDamage but if not, then they wont block your extraDamage.

The essential part here is if they block during the gainHp function or not, because that is how your extraDamage is being dealt to the target.

Theoretically they aren't because by that time even the phy/mag doesnt exist anymore (gainHp only takes the value as parameter so any other reference to damage cause is lost at that point) so your current shield wouldnt even work with normal damage.

anyway for the elemental damage, try this:

Code:
var elementId = 2; //change to your element id
var extraDamage = your original formula
extraDamage = extraDamage*user.elementMagnifyRate(elementId)*target.elementRate(elementId);
I input that, replacing my 1 damage formula line with those 3 instead, and it caused it to not work at all. (of course I replaced "your original formula" with the original formula I had, but yeah)
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,693
Reaction score
3,031
First Language
Tagalog
Primarily Uses
RMVXA
Can you post the actual current code in your notetag?

BTW, I noticed that I used extraDamage while your original was just extraDmg, in that case, it really wont deal damage since we were saving it as extraDamage in my code while your code uses extraDmg so you need to modify my code to use extraDmg instead.
 
Last edited:

Zerothedarklord

Veteran
Veteran
Joined
Jun 25, 2013
Messages
371
Reaction score
125
First Language
English
Primarily Uses
RMMV
Can you post the actual current code in your notetag?

BTW, I noticed that I used extraDamage while your original was just extraDmg, in that case, it really wont deal damage since we were saving it as extraDamage in my code while your code uses extraDmg so you need to modify my code to use extraDmg instead.

After changing every instance of extraDamage to extraDmg, it now works, and I then gave the target a 500% weakness to fire to confirm it now uses an element, and it does indeed. So now we have that part figured out. now to just make it function with the barrier.

Incase you still wanted to see, this is the code for the Enchantment effect:

<Custom Establish Effect>

// Create empty pools for skills and skipp types.

if (!user.isStateAffected(77)){

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 elementId = 2; //change to your element id

var extraDmg = Math.ceil(0.75 * originalResult.hpDamage);

extraDmg = extraDmg*user.elementMagnifyRate(elementId)*target.elementRate(elementId);

// Calculate the success rate to deal extra damage

var successRate = 0.90;

// 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>

And now, this is the code for the Magic barrier effect:

<Custom Apply Effect>

target._blackShield = Math.round(origin.atk * 5);

target.setStateCounter(65, target._blackShield);

</Custom Apply Effect>



<Custom React Effect>

if (this.isMagical()) {

if (target._blackShield - value > 0) {

target._blackShield -= value;

target.setStateCounter(65, target._blackShield);

value = 0;

} else {

value -= target._blackShield;

target.removeState(65);

}

}

</Custom React Effect>
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,693
Reaction score
3,031
First Language
Tagalog
Primarily Uses
RMVXA
What we need actually is the code where your barrier notetag is processed because that is the clincher if you want it automated for any barriers you might have and any skill like this.. I haven't gotten the motivation to check that plugin yet, lolz.

Else we could also just you know, check if the target has the barrier state, and reduce extraDmg by the barrier amount in your extraDmg notetag itself.

like

Code:
if (target._blackShield > 0){
  if (target._blackShield - extraDmg > 0){
    target._blackShield -= extraDmg;
    extraDmg = 0;
    target.setStateCounter(65,target._blackShield);}
  else {
    extraDmg -= target._blackShield;
    target._blackShield = 0;
    target.removeState(65);
}
};
 
Last edited:

Zerothedarklord

Veteran
Veteran
Joined
Jun 25, 2013
Messages
371
Reaction score
125
First Language
English
Primarily Uses
RMMV
it seems like this could work, but then wouldn't I have to make a new copy of this code for each and every different barrier effect I made?
 

Latest Threads

Latest Profile Posts

Calibrating the timing of dialogue is deffo my new least favorite thing.
I died aged 27 to cancer. Then I was reborn in a South-American state. I retained all memories and skill and had a goal from my previous life I needed to finish, but now I was just a 1-year-old girl capable of only smiling at others.

Dreams like this one make me glad I'm able to wake up from them at will.
Found a critical bug the other day with the time system that would have caused none of the NPCs to spawn. Since I use dev mode to test time-based stuff, I didn't catch this for way too long!
Last missing piece, a plugin to let weapons and armor be used as multiple equip types
What if the Actor Battlers disappeared when your selecting enemies...
ndyhHXV.gif

Forum statistics

Threads
129,969
Messages
1,206,594
Members
171,186
Latest member
Bluswat
Top