How to change item cost depending on weapon type equipped?

Uzuki

Kawaii on the streets, Senpai in the sheets
Veteran
Joined
Aug 18, 2012
Messages
1,933
Reaction score
1,325
First Language
English
Primarily Uses
RMMV
Hey y'all, so I'm using Yanfly's Skill Cost Item plugin to create gun weapons that use bullets for ammo. Now the problem comes when making the skills for these guns and not wanting to make 4 or 5 versions of the same skill that use different item costs. The plugin allows you to change the item cost by using javascript, but I couldn't find protaining to checking the skill user's currently equipped weapon type. Anyone have any ideas how to achieve this idea?
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,039
Reaction score
1,471
First Language
EN
Primarily Uses
RMMZ
I think you could do something like this:
JavaScript:
var w = user.weapons()[0];      // Get first equipped weapon
var wtype = w ? w.wtypeId : 0;  // Get weapon type ID (or 0 if no weapon equipped)
if (wtype === 1) cost = 1;
if (wtype === 2) cost = 4;
// etc
 

Uzuki

Kawaii on the streets, Senpai in the sheets
Veteran
Joined
Aug 18, 2012
Messages
1,933
Reaction score
1,325
First Language
English
Primarily Uses
RMMV
@caethyril It works perfectly! The icons for the other items still show up when 0, but I'll deal with that later. Thank you so much for the help!
 

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

Latest Threads

Latest Profile Posts

When a youtuber plays your project or game made by you using MAKERs, you will just be awe struck
Ok... so working on the official game guide for my game and its more than 150 pages...... wow. Well, I hope it will help a few players out.
RPG Maker Games Critique with Studio Blue, Episode 12: Amneron's Legacy starts now! Watch on Youtube and join the chat as we explore the world of Ellis!
Lost track of a huge brazilian wandering spider inside my house. In other news, I'm moving again.

Currently working on the second protagonist's story and her companion, making good progress. But I am looking forward to return to my other protagonist and continue his story and have him joined by a new companion. :)

Forum statistics

Threads
105,475
Messages
1,013,955
Members
137,114
Latest member
brenadjnendad
Top