I'm not sure if this qualifies as a bug, but it might.
If you have weapon 0 selected and pick up ammo, then the addammo function will switch the player to the weapon that you just got ammo for. This is true even if your settings are "switch only if new" and the weapon is NOT new.
So you can imagine my surprise when I am using a lightsaber on the weapon 0 slot and I get switched to a pistol just because I walked over some ammo.
Here's another fun fact (not a bug). If the player's last_weapon is set to the weapon he is holding, he CANNOT fire it. This is true even if kickback_pic is 0, weapon_pos is 0, ammo is >0, etc. So I'll keep that in mind if I want a simple way of locking the player's weapon without holstering it or anything.
Page 1 of 1
weapon switching on ammo pickup
#1 Posted 12 January 2016 - 10:13 PM
#2 Posted 12 January 2016 - 10:27 PM
Don't rely on hacks like the last_weapon thing. Couldn't you just cancel EVENT_FIRE or one of its cousins?
#3 Posted 12 January 2016 - 10:36 PM
Hendricks266, on 12 January 2016 - 10:27 PM, said:
Don't rely on hacks like the last_weapon thing. Couldn't you just cancel EVENT_FIRE or one of its cousins?
OK so what really prompted that hackish observation was an attempted fix for the addammo problem. I was resetting the player's curr_weapon and weapon_pos right after addammo is called. But then I noticed that I was unable to fire. After some investigation, I discovered that it was also necessary to set last_weapon to -1; otherwise the game thinks you are trying to switch to a new weapon and won't let you fire.
#4 Posted 16 January 2016 - 02:48 AM
Trooped Dan: Did you find a way to circumvent the autowitching when having melee equipeed? Because this is proving to be a problem in my mod too.
I'll be all hacking up those aliens with ma sword, and then one of them drops a clip and I'm dead.
I'll be all hacking up those aliens with ma sword, and then one of them drops a clip and I'm dead.
#5 Posted 16 January 2016 - 07:04 PM
necroslut, on 16 January 2016 - 02:48 AM, said:
Trooped Dan: Did you find a way to circumvent the autowitching when having melee equipeed? Because this is proving to be a problem in my mod too.
I'll be all hacking up those aliens with ma sword, and then one of them drops a clip and I'm dead.
I'll be all hacking up those aliens with ma sword, and then one of them drops a clip and I'm dead.
Here is what I do. I do not claim that it is efficient, but it works. In every ammo actor, change the code to add a hack like this:
ife WEAPON 0 ifg gotsaber 0 set temp YES else set temp NO addammo PISTOL_WEAPON PISTOLAMMOAMOUNT ife temp YES { setp[].weapon_pos 0 setp[].curr_weapon 0 setp[].last_weapon -1 }
In other words, if the player is using your special melee weapon, set the current weapon and weapon position back to 0 right after adding the ammo, and also set last_weapon to -1.
#6 Posted 18 January 2016 - 06:33 PM
Trooper Dan, on 16 January 2016 - 07:04 PM, said:
Here is what I do. I do not claim that it is efficient, but it works. In every ammo actor, change the code to add a hack like this:
In other words, if the player is using your special melee weapon, set the current weapon and weapon position back to 0 right after adding the ammo, and also set last_weapon to -1.
ife WEAPON 0 ifg gotsaber 0 set temp YES else set temp NO addammo PISTOL_WEAPON PISTOLAMMOAMOUNT ife temp YES { setp[].weapon_pos 0 setp[].curr_weapon 0 setp[].last_weapon -1 }
In other words, if the player is using your special melee weapon, set the current weapon and weapon position back to 0 right after adding the ammo, and also set last_weapon to -1.
This works... however Duke still lowers the weapon briefly as if to switch it out... Is this something that is "supposed" to happen, or did I do something wrong somewhere?
#7 Posted 18 January 2016 - 08:55 PM
necroslut, on 18 January 2016 - 06:33 PM, said:
This works... however Duke still lowers the weapon briefly as if to switch it out... Is this something that is "supposed" to happen, or did I do something wrong somewhere?
That is not supposed to happen. The point of setting weapon_pos to 0 is to prevent that, and it works for me.
Share this topic:
Page 1 of 1