RMMV [SOLVED] Equipped Weapon ID to Variable

Status
Not open for further replies.

DoctorOfHabit

Non-Medical, Not Professional
Member
Joined
Jul 9, 2020
Messages
9
Reaction score
1
First Language
Spanish
Primarily Uses
RMMV
Hello, I've been trying to make a simple weapon upgrade mechanic in which the selected actor's currently equipped weapon is, as mentioned, upgraded. To do so, I'd need to pass on the weapon's ID to a variable which would then go through a common event that would deal with each specific weapon.
I was wondering how that would translate to script. I tried the following line:

$gameVariables.setValue(9, $gameActors.actor(1).equips()[0].ItemId);

but the variable remained unchanged. I assume it relates to using "ItemId", but I wouldn't know how to refer specifically to weapons. Could anyone help me correct my mistake or suggest another option? Thanks in advance!
 
Last edited:

Crusha

Veteran
Veteran
Joined
Jul 28, 2020
Messages
56
Reaction score
25
First Language
English
Primarily Uses
RMMV
You could make your database have similar weapons I'd think. For instance, have your sword you want in database, maybe 30 attack. Have sword +1, 35 attack, sword +2 with 40 attack, sword + 3 with 50 attack, etc.. Whenever the actor gets this sword 'upgrade', you can just change the sword they have equipped to these improved swords. Reference of the following might give your answer:

$gameActors.actor(actorId).changeEquip(slotId, item);

I'd think you would be able to use this script-call [or a similar one] to change the equipment of the actor whenever you'd want, such as with a common event. I also would bring to your attention this thread for script calls:


When I checked the doc, it had multiple references for dealing with equips and what-not. I bet this would help you get this answer you seek. Best of luck Doctor.

*Fast Edit for you* -- Ctrl + F in the doc to search. Should save you time, search for equip or equipment, etc..
 

DoctorOfHabit

Non-Medical, Not Professional
Member
Joined
Jul 9, 2020
Messages
9
Reaction score
1
First Language
Spanish
Primarily Uses
RMMV
You could make your database have similar weapons I'd think. For instance, have your sword you want in database, maybe 30 attack. Have sword +1, 35 attack, sword +2 with 40 attack, sword + 3 with 50 attack, etc.. Whenever the actor gets this sword 'upgrade', you can just change the sword they have equipped to these improved swords. Reference of the following might give your answer:

$gameActors.actor(actorId).changeEquip(slotId, item);

I'd think you would be able to use this script-call [or a similar one] to change the equipment of the actor whenever you'd want, such as with a common event. I also would bring to your attention this thread for script calls:


When I checked the doc, it had multiple references for dealing with equips and what-not. I bet this would help you get this answer you seek. Best of luck Doctor.

*Fast Edit for you* -- Ctrl + F in the doc to search. Should save you time, search for equip or equipment, etc..
Ah, sorry! I have not clarified myself enough. I was indeed planning to make multiple items for each upgrade, but the problem is there is no Select Weapon option, so my solution was to simply select an Actor (via Show Choices) and have their equipped weapon be the one to be upgraded. The problem with that is that I am currently unable to pass on the equipped weapon's ID onto a variable, that would later be referenced when performing the interchange between the old weapon and the upgraded version.
I also try consulting that same doc when in doubt, but this time I've been unable to find it of any help, sadly.
 

palatkorn

Veteran
Veteran
Joined
Nov 1, 2019
Messages
258
Reaction score
157
First Language
thai
Primarily Uses
RMMV
I used this and then note.

<Custom Equip Requirement Condition>
$gameVariables.setValue (ID, 1)
<\Custom Equip Requirement Condition>

The above command is slightly wrong.
Should be like this To check
Code:
if($gameActors.actor(1).hasWeapon($dataWeapons[2])){
$gameVariables.setValue(9, 1)
}
You put this condition into the script.
So that variable 9 = 1
When character 1 is equipped with 2 weapons.
 
Last edited:

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,860
Reaction score
1,323
First Language
EN
Primarily Uses
RMMZ
The relevant property is id; you can use Control Variables > Script:
JavaScript:
var w = $gameActors.actor(1).weapons()[0]; w ? w.id : 0
I.e. "get the first equipped weapon of actor ID 1; if it exists, return its ID, else return 0".

If you'd rather reference actors by their position in the party (using \P[x] for your actor choices rather than \N[x]), try this instead:
JavaScript:
var m = $gameParty.members()[0]; var w = m ? m.weapons()[0] : null; w ? w.id : 0
I.e. "get the first member of the party (leader = index 0); get the first weapon equipped by that member, or null if they don't exist; return the weapon's ID if it exists, else 0".
Code:
◆Text:None, Window, Bottom
:    :Pick a party member!
◆Show Choices:\P[1], \P[2] (Window, Right, #1, -)
:When \P[1] 
  ◆Control Variables:#0001 = var m=$gameParty.members()[0];var w=m?m.weapons()[0]:null;w?w.id:0
  ◆
:When \P[2] 
  ◆Control Variables:#0001 = var m=$gameParty.members()[1];var w=m?m.weapons()[0]:null;w?w.id:0
  ◆
:End
◆Text:None, Window, Bottom
:    :Equipped weapon ID is \v[1].
 

DoctorOfHabit

Non-Medical, Not Professional
Member
Joined
Jul 9, 2020
Messages
9
Reaction score
1
First Language
Spanish
Primarily Uses
RMMV
The relevant property is id; you can use Control Variables > Script:
JavaScript:
var w = $gameActors.actor(1).weapons()[0]; w ? w.id : 0
I.e. "get the first equipped weapon of actor ID 1; if it exists, return its ID, else return 0".

If you'd rather reference actors by their position in the party (using \P[x] for your actor choices rather than \N[x]), try this instead:
JavaScript:
var m = $gameParty.members()[0]; var w = m ? m.weapons()[0] : null; w ? w.id : 0
I.e. "get the first member of the party (leader = index 0); get the first weapon equipped by that member, or null if they don't exist; return the weapon's ID if it exists, else 0".
Code:
◆Text:None, Window, Bottom[/INDENT]
[INDENT]:    :Pick a party member![/INDENT]
[INDENT]◆Show Choices:\P[1], \P[2] (Window, Right, #1, -)[/INDENT]
[INDENT]:When \P[1][/INDENT]
[INDENT]  ◆Control Variables:#0001 = var m=$gameParty.members()[0];var w=m?m.weapons()[0]:null;w?w.id:0[/INDENT]
[INDENT]  ◆[/INDENT]
[INDENT]:When \P[2][/INDENT]
[INDENT]  ◆Control Variables:#0001 = var m=$gameParty.members()[1];var w=m?m.weapons()[0]:null;w?w.id:0[/INDENT]
[INDENT]  ◆[/INDENT]
[INDENT]:End[/INDENT]
[INDENT]◆Text:None, Window, Bottom[/INDENT]
[INDENT]:    :Equipped weapon ID is \v[1].
Ah, works like a charm! And you even solved the problem with having no equipped weapon! Wonderful, thank you very much for your assistance! : o )
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
7,467
Reaction score
5,089
First Language
Dutch
Primarily Uses
RMXP

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.

 
Status
Not open for further replies.

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

Latest Threads

Latest Posts

Latest Profile Posts

Ami
--- Currency ---

Hero: This city cannot accept Gold to buy the items.
Merchant: You can exchange Gold into TC,depending the rate of TC this time.
Hero: Really? Then,i want to exchange 999999999G.
Merchant: Let's see……Wait a second,are you Cheating again?
Hero: Hell No!!! I earn it with myself!!!
There's always a time when you're super excited to create something but you already have no energy left. :I
I think of all the effects in my game, the light passing through fog has got to be my favorite....

...Also I spent all day trying to figure out how I had suddenly messed it up and made it start dropping frames like crazy. So I had all day to look at it... mocking me... with it's previous 60fps reduced to 30fps... At least it's fixed now.
Dalph wrote on slimmmeiske2's profile.
Slimmm, we should team one day and make "Reid in Wonderland" or "Aluxes in boots".

Forum statistics

Threads
103,480
Messages
999,655
Members
135,029
Latest member
optissima
Top