RMMV Sunder Skill

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,835
Reaction score
1,592
First Language
English
Primarily Uses
RMMV
So I'm having trouble creating a skill/state that decreases the target's DEF by half the user's ATK. This is what I got so far...
1st a simple skill that applies the "Sunder" state is created.
The Sunder state currently has this:
JavaScript:
<Custom Apply Effect>
var x = Math.round(this.stateOrigin(4).atk / 2);
target.minusDef(x);
</Custom Apply Effect>
<Custom Remove Effect>
var x = Math.round(this.stateOrigin(4).atk / 2);
target.addDef(x);
</Custom Remove Effect>
However, this has some issues. Mainly, what if the caster's ATK changes in between when Sunder was applied and when it was removed? I think variable(s) may have to be used, but then how would I account for multiple actors/units potentially using this same skill (thus overwriting earlier instances of the variable)?

Edit: Maybe I have to do something like, "if the caster is party member #1 use this variable, else if it's party member #2 use this other variable, else if etc..."?

Edit2: I tried another attempt, but I don't think it's right either...
JavaScript:
<Custom Apply Effect>
var x = Math.round(this.stateOrigin(4).atk / 2);
if this.stateOrigin(4).indexOf($gameParty.members()) == 0 {
  $gameVariables.setValue(41, x);
  target.minusDef(v[41]);
} else if this.stateOrigin(4).indexOf($gameParty.members()) == 1 {
  $gameVariables.setValue(42, x);
  target.minusDef(v[42]);
} else if this.stateOrigin(4).indexOf($gameParty.members()) == 2 {
  $gameVariables.setValue(43, x);
  target.minusDef(v[43]);
}
</Custom Apply Effect>
<Custom Remove Effect>
if this.stateOrigin(4).indexOf($gameParty.members()) == 0 {
  target.addDef(v[41]);
} else if this.stateOrigin(4).indexOf($gameParty.members()) == 1 {
  target.addDef(v[42]);
} else if this.stateOrigin(4).indexOf($gameParty.members()) == 2 {
  target.addDef(v[43]);
}
</Custom Remove Effect>
Can anyone please lend a hand? Thx!

Basically what I'm trying to say w/ if this.stateOrigin(4).indexOf($gameParty.members()) == 0 is "if the caster who applied this state is the 1st party member, do stuff". What's the correct syntax for that?

Edit: Can someone plz teach me how to write "if user = $gameParty.members()[0]" correctly for use in a <Custom Execution> notetag?
Edit2: if $gameParty.members().indexOf(user) == 0 also doesn't work, sigh...
 
Last edited:

ramza

Lunatic Coder
Veteran
Joined
Jan 28, 2013
Messages
832
Reaction score
525
First Language
English
Primarily Uses
RMMV
Just save the reduced amount into a variable on the target when they get hit with the skill. Then uses that saved value to re-add the defense back after the state expires.

This has two advantages:
  • You don't have to try to keep track of state changes on the origin
  • You don't need the origin of the state to still be alive when this state falls off.
JavaScript:
<Custom Apply Effect>
target._sunderArmorAmt = target._sunderArmorAmt || 0;
target._sunderArmorAmt += Math.round(origin.atk / 2)
target.minusDef(Math.round(origin.atk / 2));
</Custom Apply Effect>
<Custom Remove Effect>
target.addDef(target._sunderArmorAmt);
delete target._sunderArmorAmt
</Custom Remove Effect>
With your above code attempts, even if you managed to get it to successfully keep track of the stat changes of the origin, if that origin is an enemy, and it dies, it no longer exists, so when the state falls off after, the game will crash trying to read the parameters of something that doesn't exists anymore. By putting the amount in a variable stored on the target, it is always there, and is only removed when the state is removed.

Also in my code snippet above there, I made it so that if the same target gets sundered again, the defense lower amount gets added to the current one, and that gets kept track of as well. You can add some other things to that if you want it to bottom out at so many stacks using state counters instead, maybe.
 

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,835
Reaction score
1,592
First Language
English
Primarily Uses
RMMV
@ramza Thank you! I just woke up and will try this now. Btw, would this accommodate for, say, more than 1 unit knows this skill and applies the state? Like if party members 1 & 2 both have this skill, would there be problems?

Edit: Ok, looks like I'm gonna need alternative for:
target._sunderArmorAmt += Math.round(origin.atk / 2)
target.minusDef(Math.round(origin.atk / 2));

Since origin doesn't work in LTBS (it targets the stateholder instead of the caster of said state) idk what to do...

Would I maybe have to use a <Custom Execution> on the skill side and put the value of Math.round(origin.atk / 2) into a v[ ]? Sorta like...
JavaScript:
<Custom Execution>
var sunderArmorAmt = Math.round(user.atk / 2);
$gameVariables.setValue(32, sunderArmorAmt);
</Custom Execution>
Except I need to account for if there's more than 1 party member using the skill (only 3 party members total so not too bad).
I was thinking: (but my syntax is definitely incorrect somewhere)
JavaScript:
<Custom Execution>
var sunderArmorAmt = Math.round(user.atk / 2);
if ($gameParty.members().indexOf(user) == 0) {
  $gameVariables.setValue(32, sunderArmorAmt);
}
</Custom Execution>
 
Last edited:

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,835
Reaction score
1,592
First Language
English
Primarily Uses
RMMV
Ok, I think I figured out a way to get the functionality of origin w/o actually using it! At least conceptually...I ran into an error trying to actually implement it, however. Basically, I have the Sunder skill w/ the following: (only 3 party members)
JavaScript:
<Custom Execution>
var _sunderAtkVal = Math.round(user.atk / 2);
if (user === $gameParty.members()[0]) {
  $gameVariables.setValue(41, _sunderAtkVal);
} else if (user === $gameParty.members()[1]) {
  $gameVariables.setValue(42, _sunderAtkVal);
} else if (user === $gameParty.members()[2]) {
  $gameVariables.setValue(43, _sunderAtkVal);
}
</Custom Execution>
<After Eval>
if (user === $gameParty.members()[0]) {
  $gameVariables.setValue(41, 0);
} else if (user === $gameParty.members()[1]) {
  $gameVariables.setValue(42, 0);
} else if (user === $gameParty.members()[2]) {
  $gameVariables.setValue(43, 0);
}
</After Eval>
And on the state side:
JavaScript:
<Custom Apply Effect>
target._sunderArmorAmt = target._sunderArmorAmt || 0;
target._sunderArmorAmt += v[41] + v[42] + v[43];
target.minusDef(v[41] + v[42] + v[43]);
</Custom Apply Effect>
<Custom Remove Effect>
target.addDef(target._sunderArmorAmt);
delete target._sunderArmorAmt;
</Custom Remove Effect>
Howver, this is the error I get: (I'm guessing my syntax is wrong)
1606185478866.png
1606185552639.png

Note: I would rather use party member index instead of actorId since that would reduce the number of variables I need to create/manage. (half dozen actors vs only 3 party members)

Edit: I've narrowed it down to the state-side code. The skill-side code works as intended. What could be wrong w/ the following?
JavaScript:
<Custom Apply Effect>
target._sunderArmorAmt = target._sunderArmorAmt || 0;
target._sunderArmorAmt += v[41] + v[42] + v[43];
target.minusDef(v[41] + v[42] + v[43]);
</Custom Apply Effect>
<Custom Remove Effect>
target.addDef(target._sunderArmorAmt);
delete target._sunderArmorAmt;
</Custom Remove Effect>
Edit2: Ok, it's definite this line: target.minusDef(v[41] + v[42] + v[43]);. I also tried creating a var 1st: var totalAtk = v[41] + v[42] + v[43]; then using target.minusDef(totalAtk); but got the same error...

Edit3: Ok, this is VERY strange! I just created a brand new blank state w/ only the following:
<Custom Apply Effect>
target.minusDef(v[50]);
</Custom Apply Effect>

...where v[50] is a BLANK variable, meaning a value of 0. (I just arbitrarily picked one that wasn't being used). So why can't we use a v[ ] w/ that script call? I've also tried using toFixed() and valueOf() in an attempt to get it to be read, but alas it didn't work.

Even this.addParam(3, v[50]) yields the same error...
WHY CAN'T V[ ]s BE USED?!:kaoeh:

Edit4: OMG, all I had to do was use $gameVariables.value(x) instead of v[x]! Why did nobody tell me sooner?...:kaophew:

Muahaha, now get the same functionality of origin w/o actually having to use it!!:kaopride:
SOLUTION:
JavaScript:
<Custom Execution>
var _crush = Math.round(user.atk / 2);
if (user == $gameParty.members()[0]) {
  $gameVariables.setValue(41, _crush);
} else if (user == $gameParty.members()[1]) {
  $gameVariables.setValue(42, _crush);
} else if (user == $gameParty.members()[2]) {
  $gameVariables.setValue(43, _crush);
}
</Custom Execution>
<After Eval>
if (user == $gameParty.members()[0]) {
  $gameVariables.setValue(41, 0);
} else if (user == $gameParty.members()[1]) {
  $gameVariables.setValue(42, 0);
} else if (user == $gameParty.members()[2]) {
  $gameVariables.setValue(43, 0);
}
</After Eval>
JavaScript:
<Custom Apply Effect>
var sunder = $gameVariables.value(41) + $gameVariables.value(42) + $gameVariables.value(43);
target._sunder = target._sunder || 0;
target._sunder += sunder;
target.minusDef(sunder);
</Custom Apply Effect>
<Custom Remove Effect>
target.addDef(target._sunder);
delete target._sunder;
</Custom Remove Effect>
 
Last edited:

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

Latest Threads

Latest Posts

Latest Profile Posts

Who would think putting a power button on a side of a laptop is a good thing? You want to move the laptop and you suddenly press the button.
The second draft of my script is almost done, and I don't think I'm going to write a third draft. I'll make changes to dialogue here and there, but I'm happy with the series of events the way they are.
How you feel about font and dialogue box changing for every main character while the minor cast and regular npc get their own styles? Too much?
Just found an obviously custom effect (i.e. edited by me) in my resources>sounds folder called "rip jaw off". Dear Lord what is wrong with me as a person that at some point I needed a sound *specifically* for THAT??
(...rhetorical question.)

Forum statistics

Threads
107,526
Messages
1,030,274
Members
139,652
Latest member
jasasewamobilbali
Top