How to make it impossible to leave the weapon slot empty?

Context: I've been working on a dual wield system that has been arduous to accomplish, but thanks to AAT_Turan and Another Fen it SEEMS to be more-or-less cracked & working. The goal was to create a damage formula that only took the ATK value of the weapon equipped in the character's second weapon slot (rather than the cumulative damage of both equipped weapons).

The issue now is that the damage formula only functions properly if there is a weapon equipped in the 1st slot as well as the 2nd. If I remove the weapon in the 1st slot, the formula breaks.

This is the basic formula btw "a.weapons()[1].params[2] + a.paramBase(2) * 5"

My thought for a dirty solution is to force the the character to always have a weapon equipped in the first weapon slot. I don't think I could handle dealing with a more complex damage formula, but I'm all ears if you have one.

To be clear, I'm not looking for "cursed weapons". I need a method that ensures you MUST have a weapon equipped in the first weapon slot. The slot can be interchanged for any other weapon, but cannot be vacated completely.

I'm using pretty much all of the VisuStella core 1 plugins and MalMZDualWield.

Thanks as always to the legends that keep on giving me hope on this bitter road to glory.
Context: I've been working on a dual wield system that has been arduous to accomplish, but thanks to AAT_Turan and Another Fen it SEEMS to be more-or-less cracked & working. The goal was to create a damage formula that only took the ATK value of the weapon equipped in the character's second weapon slot (rather than the cumulative damage of both equipped weapons).

The issue now is that the damage formula only functions properly if there is a weapon equipped in the 1st slot as well as the 2nd. If I remove the weapon in the 1st slot, the formula breaks.

This is the basic formula btw "a.weapons()[1].params[2] + a.paramBase(2) * 5"

My thought for a dirty solution is to force the the character to always have a weapon equipped in the first weapon slot. I don't think I could handle dealing with a more complex damage formula, but I'm all ears if you have one.

To be clear, I'm not looking for "cursed weapons". I need a method that ensures you MUST have a weapon equipped in the first weapon slot. The slot can be interchanged for any other weapon, but cannot be vacated completely.

I'm using pretty much all of the VisuStella core 1 plugins and MalMZDualWield.

Thanks as always to the legends that keep on giving me hope on this bitter road to glory.
Wouldn't it make more sense to just change the formula so that it works if you only have one weapon equipped?
I don't know if you Googled it at all, but there are some number of threads about this - pretty much any equipment-oriented plugin should give you the option to prevent the player from unequipping their weapons.

I know it's right in the plugin parameters for VisuStella's Items and Equip Core.
Wouldn't it make more sense to just change the formula so that it works if you only have one weapon equipped?
I don't think so, but if you have thoughts I'm all ears. There are more than 30 secondary weapon skills, so each of them would have to be modified.

I'm guessing that would be something along the lines of saying "If actor has weapon in slot 1 then execute damage formula 1 else execute damage formula 2."

If you could put that in real code I'd be glowing, but I'm biting off way more than I can chew.

I don't know if you Googled it at all, but there are some number of threads about this - pretty much any equipment-oriented plugin should give you the option to prevent the player from unequipping their weapons.

I know it's right in the plugin parameters for VisuStella's Items and Equip Core.
I reckon you've just boshed it again. Half the answers are always right under my nose. Let's see.......
If I remove the weapon in the 1st slot, the formula breaks....
... basic formula btw a.weapons()[1]
you told it to look at the second weapon equipped. if you have an offhand and no mainhand, that offhand is still your first equipped weapon as far as a.weapons() is concerned. if your weapon is always in the second slot, try something like a.weapons()[a.weapons().length-1] or a.equips()[1]
AAT_Turan's solution has worked quickly and easily for me. As such the thread is resolved.
Robro33's solution sounds like a more robust fix that (if it works) will get me to a better place long term.

I'm hesitant to embark on more damage formulas at the moment. I'm a newbie that doesn't understand several basic concepts. Getting the basics down was a trauma. I always feel like the idiot in the room. I'll keep this thread bookmarked and hopefully return once the gaps in my understanding have filled in a little better.

Thanks to both of you.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-make-it-impossible-to-leave-the-weapon-slot-empty.167628/