Shield Bash skill

Hello everyone, hope y'all having a great day!

I'm currently working on a shield bash skill, and i'm considering to have the skills deals extra damage based on the shield defensive stat. I've been messing around with the formulas for quite a few hours and browsed google, but haven't been able to pinpoint it yet. Could someone give me an helping hand? ^_^

Thanks!
The Forula field is just JavaScript run through eval().
Code:
$dataArmors[a.actor().equips[1]].params[3] * 10 - b.def *2
// equips[] Index of equipment, 1 for Shield or Duel Wield weapon.
// params[] Parameters of the equipped item. 3 is the Defense stat.

EDIT:
Be careful, if there is no shield equipped then the attack will deal no damage.
Thanks a lot! I was rather close to that, but it would have taken me a while to figure it out by myself.

Also, I've already made it that the skill cannot be used if the character is not holding a shield 🙂

Thank!!
For future reference it helps if you work with the nature of JavaScript to make it bend to your will. For example, if we wanted to know what the target object's current state looks like:
a.atk * 4 - b.def * 2 + (console.info(b), 0)

This injects printing the state of object b to the Console (press F8 to access it during a Play Test), then returns 0 as the result of the expression inside the () thanks to the comma operator. In the Console I found actor() by opening the Game_Actor and looked under __proto__ for what prototype methods were available.
ok, so this is very similar to my last quesion so i won't needlessly create an other topic :

I want to store the defensive stat of a shield inside a Variable to later use it in a string, i'm guessing the way to do it is very similar to what was previously explain, but i'm still not used to calling script, so any help would be greatly appreciated! Thanks.
1) Create a Map Event or Common Event.
1) Under Contents create a new Event Command. (Double-clicking, hitting the Return key, or right-click and select "New...").
2) Under Tab 1, Left-hand side, in the "Game Progression" group, click the "Control Variables..." button.
3) At the very bottom, under Operand, select the "Script" radio button and enter your JavaScript there.

Oddly enough, this is also how you assign a string literal to a Game Variable.

You can also use Game Variables inside the JavaScript by using $gameVariables._data[idx]
Good Luck!
The Forula field is just JavaScript run through eval().
Code:
$dataArmors[a.actor().equips[1]].params[3] * 10 - b.def *2
Small note here: a.actor() refers to that actors database settings, meaning you are using the actors starting equipment here. For current equipment it could look like this:
Code:
a.equips()[1].params[3] * 10 - b.def * 2
(Alternatively you could also add more
a.equips()[1].params[3] * a.paramRate(3) * a.paramBuffRate(3) * 10 - b.def * 2
if you want the value to also be affected by the actors parameter modifications from traits for example)



You can also use Game Variables inside the JavaScript by using $gameVariables._data[idx]
While it should work fine, I'd generally recommend to use
$gameVariables.value(idx)
$gameVariables.setValue(
idx, new value)
for this, which is the way the rest of the game uses these variables and allows for more control over how the variables are accessed. When accessing $gameVariables._data directly, variables that were never touched will be null instead of 0, and changing a variables value might skip updating your event pages.


(Sorry for the nitpicking =) )
Thanks for the help! I was yet to notice that the previous formulas would only take the starting gear into consideration, would've gave me a headache most likely haha ^^'
Sorry about my mixup Nerlis! :hswt:
Thank you Another Fen. It didn't occur to me that they would make the starting equipment available from the Game_Actor.

I thought it would return $gameActors.actor(this._actorId), but instead returns $dataActors[this._actorId]
(with the $game-prefixed variables being the current state and $data-prefixed variables being data treated as static from the .json database files).

Now I know where I went wrong, thanks again!

Original thread: https://forums.rpgmakerweb.com/threads/shield-bash-skill.115263/