Notice: fwrite(): Write of 483 bytes failed with errno=28 No space left on device in /home/rmrk/domains/rmrk.net/public_html/Sources/Cache/APIs/FileBased.php on line 96

Notice: fwrite(): Write of 59 bytes failed with errno=28 No space left on device in /home/rmrk/domains/rmrk.net/public_html/Sources/Cache/APIs/FileBased.php on line 96

Notice: fwrite(): Write of 1714 bytes failed with errno=28 No space left on device in /home/rmrk/domains/rmrk.net/public_html/Sources/Cache/APIs/FileBased.php on line 96

Notice: fwrite(): Write of 44 bytes failed with errno=28 No space left on device in /home/rmrk/domains/rmrk.net/public_html/Sources/Cache/APIs/FileBased.php on line 96

Notice: fwrite(): Write of 8192 bytes failed with errno=28 No space left on device in /home/rmrk/domains/rmrk.net/public_html/Sources/Cache/APIs/FileBased.php on line 96
Print Page - [XP] Storing equipment ID in a variable

The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Scripting => Topic started by: craud on October 09, 2012, 07:24:17 PM

Title: [XP] Storing equipment ID in a variable
Post by: craud on October 09, 2012, 07:24:17 PM
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.
Title: Re: [XP] Storing equipment ID in a variable
Post by: modern algebra on October 09, 2012, 09:30:21 PM
Well, something like this in a Script... event command (last event command on tab 3) should do it:


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.