How to make a "switch weapon if you have item" function
					Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
	Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
- Clown_Number_42
 - Posts: 37
 - Joined: Tue Oct 04, 2022 3:19 pm
 - Preferred Pronouns: No Preference
 - Operating System Version (Optional): Windows 10
 - Location: Somewhere
 
How to make a "switch weapon if you have item" function
I was wondering about how i could make a "When you have a certain inventory item, lower weapon and switch to a specific weapon immediately, switching back to the previous weapon when you lose the inventory item." function?   Another question i had is if i could have a run-down on how to animate two-handed/dual wielding sprites with overlays?
			
			
									
						
										
						- 
				yum13241
 - Posts: 875
 - Joined: Mon May 10, 2021 8:08 pm
 - Preferred Pronouns: He/Him
 - Operating System Version (Optional): EndeavorOS (basically Arch)
 - Graphics Processor: Intel with Vulkan/Metal Support
 - Contact:
 
Re: How to make a "switch weapon if you have item" function
Sister weapons?
			
			
									
						
										
						- Clown_Number_42
 - Posts: 37
 - Joined: Tue Oct 04, 2022 3:19 pm
 - Preferred Pronouns: No Preference
 - Operating System Version (Optional): Windows 10
 - Location: Somewhere
 
Re: How to make a "switch weapon if you have item" function
You should specify what exactly do you want.
From what I understand, you want a powerup of sorts?
Here's a ZScript example I quickly whipped together:
			
			
									
						
										
						From what I understand, you want a powerup of sorts?
Here's a ZScript example I quickly whipped together:
Spoiler:
- Clown_Number_42
 - Posts: 37
 - Joined: Tue Oct 04, 2022 3:19 pm
 - Preferred Pronouns: No Preference
 - Operating System Version (Optional): Windows 10
 - Location: Somewhere
 
Re: How to make a "switch weapon if you have item" function
What i had in mind was something like "press a custom keybind (like f) to give yourself a custom weapon and switch to it, press the button again to switch away from it and delete it from your inventory." like the M_Gizmos "Holster" function, but i think i can make-do with this.
- Dan_The_Noob
 - Posts: 880
 - Joined: Tue May 07, 2019 12:24 pm
 - Graphics Processor: nVidia with Vulkan support
 - Contact:
 
Re: How to make a "switch weapon if you have item" function
seems like you just want to give a player a weapon but have it auto-equip regardless of "switch on pickup"?
			
			
									
						
										
						Re: How to make a "switch weapon if you have item" function
In this case the previously provided code can be adapted into what you want by combining both Init- and EndEffect overrides into a single Use override.Clown_Number_42 wrote: ↑Mon Nov 07, 2022 5:15 pm What i had in mind was something like "press a custom keybind (like f) to give yourself a custom weapon and switch to it, press the button again to switch away from it and delete it from your inventory." like the M_Gizmos "Holster" function, but i think i can make-do with this.
Use gets triggered whenever an inventory item is used, so with that it's possible to check for special logic inside the inventory item and do specific things, kind of like using CustomInventory items in DECORATE.
For example:
Spoiler:
