RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[XP] Storing equipment ID in a variable

0 Members and 1 Guest are viewing this topic.

*
Rep: +0/-0Level 63
RMRK Junior
RM2k3 had a command that let you set a variable to the database ID of an item that a character had equipped; eg. if you told it to reference Alex's Weapon ID, and Alex had a Bronze Sword which was #6 in the Weapons database, it'd set the variable to 6.

This function was, for some reason, dropped from RMXP, and I'd like to know if there's a way to recreate it using scripts.

The reason I'm asking is that I'm using an (evented) custom battle system that involves being able to dual-wield weapons. The right-hand weapon is tied to Enter / C and the left-hand is tied to Shift / Z. At present it works, but only because you can't use the same weapons in both the Right and Left hands - the game determines what items are in the "Weapon" and "Shield" slots via a series of conditional branches, but this also means that the weapons need to broken up into two categories and can't be used interchangeably. It severely limits the scope of what the player can do.

What I'm aiming to do is plug in one of the Dual Wielding scripts that's floating around and then re-write the CBS events so that it just grabs the equipment ID of whatever's in a specific slot, regardless of what kind of equipment it is. The item's actual stats are irrelevant; the CBS only cares about the ID number and they could both technically be Helmets for all it cares.

Thanks to anyone who can help me with this.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Well, something like this in a Script... event command (last event command on tab 3) should do it:

Code: [Select]
actor = $game_actors[1]
$game_variables[2] = actor.weapon_id

Replace 1 with the ID of the actor, 2 with the ID of the variable that you want to hold the ID of the primary weapon.

As for how to get the secondary weapon, the proper code depends on the script used.