(SOLVED) Can't seem to retrieve certain weapons that are noted as variables in an earlier event

Status
Not open for further replies.
Joined
Jan 19, 2022
Messages
3
Reaction score
1
First Language
English
Primarily Uses
RMMZ
Hey there! This is my first time ever using this software so noob alert I guess.
I'm trying to run a little dungeon event in my project where the character is stripped of their gear and has to later get it back. Using these forums I learned that I would have to un-equip the weapons and then take note of them as variables, and this all worked fine, but for some reason when I go to retrieve the weapons, I only get the Knife back.

I'm not sure if this has anything to do with the character dual wielding or not, but I've exhausted every idea that I could come up with on my own (Even tried un-equipping shields just in case that was part of it but no luck) as to why I'm not getting any other weapons back, so any help would be greatly appreciated.

Here's the relevant screenshots for the events and the Revolver variable.
Screen Shot 2022-01-18 at 10.15.04 PM.pngScreen Shot 2022-01-18 at 10.15.13 PM.pngScreen Shot 2022-01-18 at 10.15.38 PM.png
 
Last edited:

NaosoX

Veteran
Veteran
Joined
Feb 28, 2013
Messages
490
Reaction score
263
First Language
English
Primarily Uses
RMMZ
You've changed equipment to none just before saving as variable?
Saving equip to variable here only sets the variable to the quantity of said item held.
So, if you have 0, the variable will save as 0.

You only need to Change Weapon: decrease by 1(include equip).
then when you want it back, Change Weapon: increase by 1.

UNRELATED: has anyone else noticed Dagger is spelled Daggar by default in the engine?
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
4,969
Reaction score
4,553
First Language
English
Primarily Uses
RMMZ
There's no reason that shouldn't work. I just whipped up a similar test case and got all the weapons.

@NaosoX Changing equipment to none puts the equipment that was there in inventory, so it won't affect the variable value.

and yeah, I noticed the Daggar thing. :)

If you hit F9 during test play, it brings up a debug menu where you can check switch/variable values. That'll allow you to make sure they have the values they're supposed to.
 

ZombieKidzRule

Aren't these two Zombie Kidz cute?
Veteran
Joined
Jan 9, 2022
Messages
397
Reaction score
369
First Language
English
Primarily Uses
RMMZ
This is a very cool concept so please forgive a question where the answer is probably obvious for more knowledgeable people.

This only works when you have specific control over the player inventory, right? You know what they will have in game at that specific point so you can write it to specifically take those things away and then return them later.

Would this create an error if the player didn't have one of these things? Like they were able to drop it before the event?

Is there a way to essentially take everything from the player (equipped and inventory) without knowing what they actually have? And then still return everything?

I am just trying to make sure I understand how this particular event works and what its limitation might be.

Thanks!
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
4,969
Reaction score
4,553
First Language
English
Primarily Uses
RMMZ
This is a very cool concept so please forgive a question where the answer is probably obvious for more knowledgeable people.

This only works when you have specific control over the player inventory, right? You know what they will have in game at that specific point so you can write it to specifically take those things away and then return them later.

Would this create an error if the player didn't have one of these things? Like they were able to drop it before the event?

Is there a way to essentially take everything from the player (equipped and inventory) without knowing what they actually have? And then still return everything?

I am just trying to make sure I understand how this particular event works and what its limitation might be.

Thanks!
If you try to remove an item the player doesn't have, it simply takes away 0 of the item. It won't cause an error or anything.

If you wanted to event something like this in a place where you couldn't know ahead of time what the player has, you'd have to do a variable for every piece of equipment they could have attained up until that point, but there's a much easier way using a script command.
 

ZombieKidzRule

Aren't these two Zombie Kidz cute?
Veteran
Joined
Jan 9, 2022
Messages
397
Reaction score
369
First Language
English
Primarily Uses
RMMZ
If you try to remove an item the player doesn't have, it simply takes away 0 of the item. It won't cause an error or anything.

If you wanted to event something like this in a place where you couldn't know ahead of time what the player has, you'd have to do a variable for every piece of equipment they could have attained up until that point, but there's a much easier way using a script command.
Perfect, thanks for that clarification!
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
4,969
Reaction score
4,553
First Language
English
Primarily Uses
RMMZ
Perfect, thanks for that clarification!
Incidentally, if you did want to do that, I'd do something like

$gameVariables.setValue(1, $gameParty.equipItems());
$gameParty._weapons = {};
$gameParty._armors = {};

Then to reinstate them:

for (const item of $gameVariables.value(1)) { $gameParty.gainItem(item, 1, false); }
 

ZombieKidzRule

Aren't these two Zombie Kidz cute?
Veteran
Joined
Jan 9, 2022
Messages
397
Reaction score
369
First Language
English
Primarily Uses
RMMZ
Incidentally, if you did want to do that, I'd do something like

$gameVariables.setValue(1, $gameParty.equipItems());
$gameParty._weapons = {};
$gameParty._armors = {};

Then to reinstate them:

for (const item of $gameVariables.value(1)) { $gameParty.gainItem(item, 1, false); }
Awesome, thanks! I will experiment with that. I really don't know anything about scripting so everything is new and sometimes challenging to figure out and even implement from examples. But perseverance is key!
 
Joined
Jan 19, 2022
Messages
3
Reaction score
1
First Language
English
Primarily Uses
RMMZ
There's no reason that shouldn't work. I just whipped up a similar test case and got all the weapons.

@NaosoX Changing equipment to none puts the equipment that was there in inventory, so it won't affect the variable value.

and yeah, I noticed the Daggar thing. :)

If you hit F9 during test play, it brings up a debug menu where you can check switch/variable values. That'll allow you to make sure they have the values they're supposed to.
Thanks for the response!
After seeing this I did further testing. So to explain a little bit, the Knife and Revolver are starting equipment that's given to the player after the intro cutscene, and the Daggar is optional in the first level. Hence why I tried playing around with the variables. I don't really need it for the other two weapons since the player will always have them.

So this morning I created a new event to just give me the Daggar so I would have all three weapons. Triggered the event, and thanks to the F9 tip I saved a lot of time in checking how it worked. (Thank you so much lol) Screen Shot 2022-01-19 at 10.18.40 AM.pngSo, it worked for everything that was NOT the Revolver. I thought this might be a database issue then since I made the Revolver up from nothing. So I recreated it in the Shortbows default placement, and updated the variable to count this new revolver, and I still ended up with a 0. I did one more test, this time making the Revolver the weapon in the first equip slot, and the Knife in the second. And I ended up with the Revolver having a variable of 1, and Knife 0. So whatever weapon is equipped in the second slot is not working properly.

All in all, I don't need it to work for the Knife or Revolver in the long run. But just hoping that a player doesn't place the one optional weapon in the second slot is a bit of an iffy play. Since you got all the weapons when you tested it though I must just be doing something wrong somewhere, but I'm not even sure where to look at this point.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
4,969
Reaction score
4,553
First Language
English
Primarily Uses
RMMZ
Thanks for the response!
After seeing this I did further testing. So to explain a little bit, the Knife and Revolver are starting equipment that's given to the player after the intro cutscene, and the Daggar is optional in the first level. Hence why I tried playing around with the variables. I don't really need it for the other two weapons since the player will always have them.

So this morning I created a new event to just give me the Daggar so I would have all three weapons. Triggered the event, and thanks to the F9 tip I saved a lot of time in checking how it worked. (Thank you so much lol) View attachment 213426So, it worked for everything that was NOT the Revolver. I thought this might be a database issue then since I made the Revolver up from nothing. So I recreated it in the Shortbows default placement, and updated the variable to count this new revolver, and I still ended up with a 0. I did one more test, this time making the Revolver the weapon in the first equip slot, and the Knife in the second. And I ended up with the Revolver having a variable of 1, and Knife 0. So whatever weapon is equipped in the second slot is not working properly.

All in all, I don't need it to work for the Knife or Revolver in the long run. But just hoping that a player doesn't place the one optional weapon in the second slot is a bit of an iffy play. Since you got all the weapons when you tested it though I must just be doing something wrong somewhere, but I'm not even sure where to look at this point.
You should be able to avoid this issue entirely if you use the script method I outlined above; it'll save you having to use more than one variable for the removed equipment as well.

Assuming you'd prefer to continue eventing it, though...the first place I'd look is whether the Revolver goes into your inventory after the event that sets the second weapon slot to none.
 
Joined
Jan 19, 2022
Messages
3
Reaction score
1
First Language
English
Primarily Uses
RMMZ
You should be able to avoid this issue entirely if you use the script method I outlined above; it'll save you having to use more than one variable for the removed equipment as well.

Assuming you'd prefer to continue eventing it, though...the first place I'd look is whether the Revolver goes into your inventory after the event that sets the second weapon slot to none.
Thanks so much! Problem has been solved. I hadn't thought to pay attention to where the second weapon was actually going, and it was straight up just vanishing. So I set it to remove both weapons and shields this time, even though the character can't even hold shields, and sure enough the second weapon was now going to the inventory and being tracked as a variable. I could have sworn I tried removing shields earlier on by I guess I didn't (not helped by the command line auto changing to weapon anyways). But it works and that's all that matter! Appreciate all the swift responses and the script suggestions. I'll definitely go that route if I ever want to run a more complex equipment loss scenario.

Scripts still confuse the hell out of me, so right now I'm trying to avoid using them until I have a better understanding of them.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
4,969
Reaction score
4,553
First Language
English
Primarily Uses
RMMZ
Thanks so much! Problem has been solved. I hadn't thought to pay attention to where the second weapon was actually going, and it was straight up just vanishing. So I set it to remove both weapons and shields this time, even though the character can't even hold shields, and sure enough the second weapon was now going to the inventory and being tracked as a variable. I could have sworn I tried removing shields earlier on by I guess I didn't (not helped by the command line auto changing to weapon anyways). But it works and that's all that matter! Appreciate all the swift responses and the script suggestions. I'll definitely go that route if I ever want to run a more complex equipment loss scenario.

Scripts still confuse the hell out of me, so right now I'm trying to avoid using them until I have a better understanding of them.
Ah, I'm wondering if you had the first slot being set to none twice, and were then removing the weapon from the equipment without it being unequipped first. (the second slot usually says shield but says weapon for a dual wielder, and it's impossible to differentiate slot 0 from 1 in the event command after setting it)
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
9,645
Reaction score
6,152
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.

Latest Threads

Latest Posts

Latest Profile Posts

Current status screens for Shadows of the Earth: The Vrila'an Legend. Need to do something about the color scheme lol
Captura de pantalla (259).pngCaptura de pantalla (260).png
My first serious victim in game hacking - Pawnbarian.
Diana Path 2.png
I love these two design wise lol... The high school principal and the captain of the women's wrestling team. they team up as bosses to save the school's accreditation.
Kanori24 wrote on TheRamenGirl's profile.
I love your profile pic. Definitely one of my favorite scenes from OPM :D

Forum statistics

Threads
122,074
Messages
1,146,309
Members
160,360
Latest member
bleach
Top