Page 1 of 1
Detect when a player hits a weapon slot key
Posted: Tue Mar 01, 2016 10:17 pm
by Lakai
Hello there, I wanted to know if there is any way to detect when a player hits one of the weapon slots keys. The mod I'm trying to make only has 1 weapon so I wanted to use the weapon slot keys for other binds, as it would make things easier and player won't need to bind some extra keys when the weapon keys are unused. I already checked GetPlayerInput but it doesn't seem to be able to detect weapon switches.
Note: I can't use weapons to detect the key presess. If I do that, then the main weapon the mod uses gets lowered which is exactly what I'm trying to avoid. If there is no other solution then I will have to add extra keybinds to the KEYCONF thing, but I like this method and I wanted to see if it's possible.
RE: Detect when a player hits a weapon slot key
Posted: Wed Mar 02, 2016 3:07 am
by SwordGrunt
You can avoid weapon lowering by using the instant weapon switch player property. I can't think of any possible way to detect what you want, only hacky workarounds by creating multiple versions of your weapon and using the aforementioned property.
RE: Detect when a player hits a weapon slot key
Posted: Wed Mar 02, 2016 9:09 pm
by Lakai
SwordGrunt wrote:
You can avoid weapon lowering by using the instant weapon switch player property. I can't think of any possible way to detect what you want, only hacky workarounds by creating multiple versions of your weapon and using the aforementioned property.
Nice, I managed to get it to work. By using the property you mentioned and by adding this to the select state of the weapon:
Code: Select all
Select:
TNT1 A 0 A_FireCustomMissile ("Rocket")
TNT1 A 0 A_SelectWeapon("Pistol2")
TNT1 A 1 A_Raise
Loop
It fires a rocket everytime I hit the slot 2, but the Pistol never lowers, so it's detecting the weapon switch without even switching the weapons. And so far it didn't crash. Thanks man.
RE: Detect when a player hits a weapon slot key
Posted: Thu Mar 03, 2016 1:15 am
by SwordGrunt
Hacky workarounds are a big part of this engine! You came up with a pretty damn good solution using A_SelectWeapon. I wonder if using tag "" would work for no tag, meaning the player wouldn't notice the weapon switch was attempted (by seeing the weapon's name in yellow text at the bottom of the screen). That's just a nitpicky thing though. I'm glad you got it to work!