Duke4.net Forums: weapon switching on ammo pickup - Duke4.net Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

weapon switching on ammo pickup

User is offline   Danukem 

  • Duke Plus Developer

#1

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. :thumbsup:

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.
0

User is offline   Hendricks266 

  • Weaponized Autism

  #2

Don't rely on hacks like the last_weapon thing. Couldn't you just cancel EVENT_FIRE or one of its cousins?
0

User is offline   Danukem 

  • Duke Plus Developer

#3

View PostHendricks266, 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.
0

User is offline   necroslut 

#4

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. :thumbsup:
0

User is offline   Danukem 

  • Duke Plus Developer

#5

View Postnecroslut, 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. :thumbsup:



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.
1

User is offline   necroslut 

#6

View PostTrooper 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:

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?
0

User is offline   Danukem 

  • Duke Plus Developer

#7

View Postnecroslut, 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.
1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic


All copyrights and trademarks not owned by Voidpoint, LLC are the sole property of their respective owners. Play Ion Fury! ;) © Voidpoint, LLC

Enter your sign in name and password


Sign in options