itachi11115

Veteran
Veteran
Joined
Jun 12, 2018
Messages
60
Reaction score
23
First Language
English
Primarily Uses
RMMV
I am trying to make a skill which can be learned by melee characters, particularly knights, but can only be used while a shield is equipped.
Here is how I want it to look:
My game has two types of shields, light and heavy. I want my Knight class (class ID 1) character to be able to learn a Shield Bash skill that will attack using the defensive bonus provided by the shield. Then, I want the character to enter a defensive stance for the foe's turn.
Here is the major caveat: I want the skill to show in the battle menu at all times, but only be useable when the character has a heavy shield (armor type ID 6) equipped. That way there is no misunderstanding how the skill works.
I heard yanfly's skill core is the way to go, but I am not well versed in JS. If someone could help me with that script I would really appreciate it!
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
7,748
Reaction score
5,511
First Language
English
Primarily Uses
RMMV
Well, in the default database, Shield is the second item slot in the Equipment Types list, and lists in code start with 0 (but database IDs are the listed number).

So you'd put in your skill:
Code:
<Custom Requirement>
value=user.equips()[1] && user.equips()[1].atypeId==6;
</Custom Requirement>

If you've changed your Equipment Types list, you'll have to adjust the number in the brackets accordingly.
 
Last edited:

caseorogue

Veteran
Veteran
Joined
Feb 21, 2022
Messages
44
Reaction score
29
First Language
English
Primarily Uses
RMMV
JavaScript:
<Custom Show Eval>
user.equips().forEach((equip) => {
    if (equip.atypeId == /*Type ID of Heavy Shield*/) {
      user._heavyShieldEquipped = true;
    }
})
visible = user._heavyShieldEquipped ? true :  false;
</Custom Show Eval>

Pasting this into the skill's notebox should do the trick. You'll need to supply the ID of heavy shields from your game's armor types (not equipment types!) list.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
7,748
Reaction score
5,511
First Language
English
Primarily Uses
RMMV
Pasting this into the skill's notebox should do the trick.
Note that the OP specified they want the skill to be visible at all times, so you don't want to use a show eval, you want to use a requirement so that it's greyed out.

There's also really no reason to loop through the entire equipment array when shields have their own, dedicated slot :wink:
 

itachi11115

Veteran
Veteran
Joined
Jun 12, 2018
Messages
60
Reaction score
23
First Language
English
Primarily Uses
RMMV
Well, in the default database, Shield is the second item slot in the Equipment Types list, and lists in code start with 0 (but database IDs are the listed number).

So you'd put in your skill:
Code:
<Custom Requirement>
value=user.equips()[1] && user.equips()[1].atypeId==6;
</Custom Requirement>

If you've changed your Equipment Types list, you'll have to adjust the number in the brackets accordingly.
Do I put anything in the parenthesis?
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
7,748
Reaction score
5,511
First Language
English
Primarily Uses
RMMV
No. Paste it exactly as I typed.
 

itachi11115

Veteran
Veteran
Joined
Jun 12, 2018
Messages
60
Reaction score
23
First Language
English
Primarily Uses
RMMV
No. Paste it exactly as I typed.
Works great, but does it add on the defensive bonus from the shield to the damage calculation? Or do I need a special damage formula for that?
 

Zeireth

Veteran
Veteran
Joined
Nov 2, 2013
Messages
81
Reaction score
65
First Language
English
Primarily Uses
N/A
@itachi11115 Put this in your Shield Bash damage formula. I just tested on a clean project on MV, so it should work.

a.equips()[1].params[3]

params[3] is DEF of equips()[1]

Edit: One thing I forgot to mention. That formula will not work for enemies unless you have a plugin that adds equips to enemies like Hime Enemy Equips.

In case you still want to use Shield Bash for enemies and do not want to make two skills, then use

a.isActor() ? a.equips()[1].params[3] : 0

Replace 0 of this new formula with whatever you would use for a damage formula, like for example
a.isActor() ? a.equips()[1].params[3] : a.atk * 4 - b.def * 2

You don't have to use the new formula if you have no plans on using Shield Bash for enemies, or have a plugin that gives enemies equipment.
 
Last edited:

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
7,748
Reaction score
5,511
First Language
English
Primarily Uses
RMMV
Works great, but does it add on the defensive bonus from the shield to the damage calculation?
How could it do that? :guffaw:
You didn't say you wanted it to do that, and the notetag is labeled as a requirement for being able to use the skill, not anything to do with damage.

The script call Zeireth gave you will do the job, incorporate it into your damage formula however you like.

Good luck with your game.
 

itachi11115

Veteran
Veteran
Joined
Jun 12, 2018
Messages
60
Reaction score
23
First Language
English
Primarily Uses
RMMV
How could it do that? :guffaw:
You didn't say you wanted it to do that, and the notetag is labeled as a requirement for being able to use the skill, not anything to do with damage.

The script call Zeireth gave you will do the job, incorporate it into your damage formula however you like.

Good luck with your game.
"learn a Shield Bash skill that will attack using the defensive bonus provided by the shield."
That was my original verbeage lol.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
7,748
Reaction score
5,511
First Language
English
Primarily Uses
RMMV
Fair enough, you did say you wanted it - I didn't realize that was a part of the request. You went on with "Here is the major caveat," indicating the disabling of the skill was your question.

In any case, you should be sorted now!
 

itachi11115

Veteran
Veteran
Joined
Jun 12, 2018
Messages
60
Reaction score
23
First Language
English
Primarily Uses
RMMV
@itachi11115 Put this in your Shield Bash damage formula. I just tested on a clean project on MV, so it should work.

a.equips()[1].params[3]

params[3] is DEF of equips()[1]

Edit: One thing I forgot to mention. That formula will not work for enemies unless you have a plugin that adds equips to enemies like Hime Enemy Equips.

In case you still want to use Shield Bash for enemies and do not want to make two skills, then use

a.isActor() ? a.equips()[1].params[3] : 0

Replace 0 of this new formula with whatever you would use for a damage formula, like for example
a.isActor() ? a.equips()[1].params[3] : a.atk * 4 - b.def * 2

You don't have to use the new formula if you have no plans on using Shield Bash for enemies, or have a plugin that gives enemies equipment.
I tried the second formula but it seems to only apply damage equal to the defensive stat of the shield. I wanted the defensive stat of the shield to be added on to their standard attack damage. So essentially: (shield def param change) + a.atk * 4 - b.def * 2
I also want it to trigger the guard state in the user. Is it possible to do all that?
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
7,748
Reaction score
5,511
First Language
English
Primarily Uses
RMMV
I tried the second formula but it seems to only apply damage equal to the defensive stat of the shield
So Zeireth gave you a good answer initially, and then he added in some stuff that confused you.

You should take the initial, correct JavaScript call for the shield's DEF value: a.equips()[1].params[3] and incorporate that into the rest of your formula the way you describe.
I also want it to trigger the guard state in the user. Is it possible to do all that?
The thread I already linked you explains how to do that.
 

itachi11115

Veteran
Veteran
Joined
Jun 12, 2018
Messages
60
Reaction score
23
First Language
English
Primarily Uses
RMMV
So Zeireth gave you a good answer initially, and then he added in some stuff that confused you.

You should take the initial, correct JavaScript call for the shield's DEF value: a.equips()[1].params[3] and incorporate that into the rest of your formula the way you describe.

The thread I already linked you explains how to do that.
So does this all look right?
(!a.isStateAffected(2)) a.addState(2); 100) a.equips()[1].params[3] : a.atk * 4 + b.def * 2
Thank you for your patience, I really appreciate it
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
7,748
Reaction score
5,511
First Language
English
Primarily Uses
RMMV
My apologies - when I said above I'd already linked you to the thread with information, I was thinking of another post I'd just written and gotten you two mixed up. Here it is:
So does this all look right?
(!a.isStateAffected(2)) a.addState(2); 100) a.equips()[1].params[3] : a.atk * 4 + b.def * 2
No, that's pretty completely wrong. :wink:

The format for the ternary conditional is:
Code:
if this is true ? then do this : else do this

You have extra parentheses and you're missing the question mark. You also have a random "100" in there. And then you're still not incorporating the shield's defense value into your damage formula using math.

I don't understand why you think you need to be using a ternary operator here at all. The game doesn't care whether or not the actor already has the state - unless you're using plugins that change it, it doesn't matter.

You just do: a.addState(2); the rest of your damage formula here
 

itachi11115

Veteran
Veteran
Joined
Jun 12, 2018
Messages
60
Reaction score
23
First Language
English
Primarily Uses
RMMV
My apologies - when I said above I'd already linked you to the thread with information, I was thinking of another post I'd just written and gotten you two mixed up. Here it is:

No, that's pretty completely wrong. :wink:

The format for the ternary conditional is:
Code:
if this is true ? then do this : else do this

You have extra parentheses and you're missing the question mark. You also have a random "100" in there. And then you're still not incorporating the shield's defense value into your damage formula using math.

I don't understand why you think you need to be using a ternary operator here at all. The game doesn't care whether or not the actor already has the state - unless you're using plugins that change it, it doesn't matter.

You just do: a.addState(2); the rest of your damage formula here
I should be clear, I have zero JS experience and don't even know what a ternary operator is lmao
Could I trouble you to spell the damage formula out for me? I'll be sure to credit you XD
 
Last edited:

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
7,748
Reaction score
5,511
First Language
English
Primarily Uses
RMMV
I should be clear, I have zero JS experience and don't even know what a ternary operator is lmao
Well you got it from someplace to try to use it :stickytongue:
and the ICODE thing you mentioned just now confused me.
What part of it? I'm happy to answer any questions you can clearly state.

This is really pretty low on the scale of difficulty for things to learn if you want to make a game. It's been explained clearly, I think - so you should read back over some of the posts, make yourself go slowly and understand the words. Read out loud if it helps.

Someone else may be willing to just give you what you need to copy and paste, but I don't do that for something as simple as a damage formula. Then you go on to make your very next skill and you haven't learned anything and need basic help again.
 

Zeireth

Veteran
Veteran
Joined
Nov 2, 2013
Messages
81
Reaction score
65
First Language
English
Primarily Uses
N/A
@itachi11115 I do apoligize for any confusion. Sorry I was away for some duration. I should have left my original post as is.

I gave a secondary solution to a problem that you may have not wanted. ATT_Turan is correct. My original post was better.

When I started RPG Maker 11 years ago, I was scared to ask for help. I am proud of you for asking. I am no expert, but I can help to the best of my ability.

I hope you are able to achieve what you want with your project. There is a lot of cool things you can do with RPG Maker. I remember when I thought it was overwhelming with too many possibilities.
 

itachi11115

Veteran
Veteran
Joined
Jun 12, 2018
Messages
60
Reaction score
23
First Language
English
Primarily Uses
RMMV
Well you got it from someplace to try to use it :stickytongue:

What part of it? I'm happy to answer any questions you can clearly state.

This is really pretty low on the scale of difficulty for things to learn if you want to make a game. It's been explained clearly, I think - so you should read back over some of the posts, make yourself go slowly and understand the words. Read out loud if it helps.

Someone else may be willing to just give you what you need to copy and paste, but I don't do that for something as simple as a damage formula. Then you go on to make your very next skill and you haven't learned anything and need basic help again.
I was copying and pasting from the damage formulas page lol
I think I get how it's all supposed to work, I just don't know what order to put it all in. Is this right?
a.equips()[1].params[3] a.addState(2); a.atk * 4 - b.def * 2
 

itachi11115

Veteran
Veteran
Joined
Jun 12, 2018
Messages
60
Reaction score
23
First Language
English
Primarily Uses
RMMV
@itachi11115 I do apoligize for any confusion. Sorry I was away for some duration. I should have left my original post as is.

I gave a secondary solution to a problem that you may have not wanted. ATT_Turan is correct. My original post was better.

When I started RPG Maker 11 years ago, I was scared to ask for help. I am proud of you for asking. I am no expert, but I can help to the best of my ability.

I hope you are able to achieve what you want with your project. There is a lot of cool things you can do with RPG Maker. I remember when I thought it was overwhelming with too many possibilities.
This seems to be the most supportive online community I've ever found lol. I have only been using this program for about a year now, and know basically nothing about advanced coding and whatnot. It's nice that people understand it isn't easy for everyone and that we all need help with this sometimes.
 

Latest Threads

Latest Posts

Latest Profile Posts

Shoot.gif
Because The Fury from Metal Gear Solid 3 is one of my favorite bosses of all time, I felt the need to make a somewhat similar boss for my own game. taking cues from both the Fury and another awesome astronaut boss, Captain Vladimir from No More Heroes 2.
RE4make almost had me with their demo until I got to the dog stuck in a bear trap and realized that he was dead and could no longer be saved. Just not the kind of reimagining I'm interested in.
Here's some dudes that I'm drawing for Jimmy's Quest!
autredo.png
Autism Acceptance Month 2023!


Did this randomly in my free time, I guess today is a good day to show it.

Forum statistics

Threads
130,027
Messages
1,207,126
Members
171,293
Latest member
cbell77
Top