[L4D1/2] Don't switch weapon to secondary slot when pick up pistols
As title says, in game default, if I pick up pistol or magnum, it will switch current active weapon to secondary slot, I don't want this.
If any can help, I will appreciate. -what I found so far- SDKHook_WeaponEquipPost, SDKHook_WeaponEquip, and SDKHook_WeaponCanSwitchTo don't fire when picking up the second pistol for both games. Edit: Problem sloved by Forgetest, thanks everyone, click here |
Re: [L4D1/2] Don't switch weapon to secondary slot when pick up pistols
Try the following codes:
Method 1 (may be a bit glitch)
Spoiler
Method 2 (didn't have much time to work on this one, need some rework)
Spoiler
|
Re: [L4D1/2] Don't switch weapon to secondary slot when pick up pistols
1 Attachment(s)
Quote:
I've been trying to make memory patches on this, only to get crashes on both games on Windows, but it seems to work on Linux L4D2. Partial pseudocode from EquipSecondWeapon: PHP Code:
My detour setup: (There should be another detour on CWeaponSpawn::Use, otherwise it only functions when picking up dropped pistols) PHP Code:
|
Re: [L4D1/2] Don't switch weapon to secondary slot when pick up pistols
Quote:
If you don't know how those work: Basically, your patch should jump from one instruction to another (while skipping any other instruction between your source and your destination). The destination of the jump depends on which part(s) of the function you want to skip over. For example, if you want to skip the function call for CTerrorGun::Holster, you'll want to start at the first byte of that function's call instruction. Since an unconditional jump (E9 ? ? ? ?) takes 5 bytes, the length of your jump will be calculated by the following equation: Let a1 = Address of the patch location + 5 bytes (because the patch itself takes five bytes) Let a2 = Address of the start of the instruction after the CTerrorGun::Holster's call instruction. Equation: a2 - a1 = JMP instruction length Here is CTerrorGun::Holster's call instruction on Windows: Code:
.text:103E4712 8B 10 mov edx, [eax] Here's the next instruction: Code:
.text:103E4720 56 push esi Since I like to be consistent on both platforms and both games as much as possible, I used the unconditional jump method for Linux as well. These are my offsets and sigs: PHP Code:
|
Re: [L4D1/2] Don't switch weapon to secondary slot when pick up pistols
I didn't test with dual pistols so I don't know if it will work
Since I don't know do patching stuff there are some workarounds like checking if the user is wielding "now" a dual weapon and rollback the active weapon aswell. EDIT: Oh I noticed that you edited the main post after I paste the code. |
Re: [L4D1/2] Don't switch weapon to secondary slot when pick up pistols
So this is from Charms weapon detecting dual pistol pickup:
PHP Code:
or force the weapon to change to the primary weapon if available. I don't think patching is necessary, that creates extra overhead which must be maintained through game changes if anything were to update, and this looks like a lot of stuff to patch etc. |
Re: [L4D1/2] Don't switch weapon to secondary slot when pick up pistols
Quote:
My goal is trying not to interrupts client status. (ex. primary weapon reloading) PHP Code:
|
Re: [L4D1/2] Don't switch weapon to secondary slot when pick up pistols
Quote:
And thank you Marttt and Silvers for your time, but as Harry replied using events is afterwards and not perfect for this. At first I wanted to change the pistol netprops instead, to fake client a pick-up, but it could be messy when targeting weapon_spawn. Memory patching is what I'm not actually willing for, while it should be the best choice. Eventually I decided to make it into l4d2_pickup made by SirPlease, which originally provides functionality to block pick-up switches. Link: https://github.com/Target5150/MoYu_S...ckup/README.md |
Re: [L4D1/2] Don't switch weapon to secondary slot when pick up pistols
Problem sloved by Forgetest, thanks everyone. :)
|
Re: [L4D1/2] Don't switch weapon to secondary slot when pick up pistols
Can this plugin be used for teammates who come in to play the game?
|
All times are GMT -4. The time now is 12:28. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.