AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Unapproved Plugins (https://forums.alliedmods.net/forumdisplay.php?f=109)
-   -   [L4D/L4D2] Weapon Fire Modes (https://forums.alliedmods.net/showthread.php?t=322259)

MasterMind420 03-21-2020 11:52

[L4D/L4D2] Weapon Fire Modes
 
This plugin enables certain automatic weapons to set their fire mode (Single/Burst/Auto)
Pistol and magnum fire modes are also included (Single/Burst/Semi-Auto/Auto)

Desert Rifle is not allowed because of the way it burst fires already.
This plugin is a work in progress and any feedback or suggestions are appreciated.

Thanks to Lux & Silvers for coding advice.
Thanks to TimoCop for his Automatic Pistols plugin which gave me a baseline to work with.

PRESS ZOOM KEY TO CHANGE FIRE MODE

Compatibility - Fire modes are saved to the weapon entity, so if you use multiple equipment which uses multiple guns switching them will cause the
fire modes to reset, because every time you switch it becomes a new entity, eventually i will come up with a fix for this.

Automatic Pistols by TimoCop may interfere with this plugins fire modes, if it does let me know and i'll add options to disable fire modes on
Pistols/Magnums in this plugin. Eventually I will add options per gun to enable disable specific guns using fire modes.

Code:

[ v1.0 ]
Initial Release

[ v1.1 ]
Fixed - Mode switch PrintToChat on unsupported weapons

Changed - Weapon checks have been moved around and optimized somewhat.
                  Moved function code from PostThink to OnPlayerRunCmd
                  Renamed plugin file to l4d_weapon_fire_modes(delete v1.0 from your plugins directory)

Features - Added L4D1 support
              Added late load support

[ v1.2 ]
Fixed - Burst fire for pistols is now as intended
                Burst fire bug when 1 bullet in clip and then reloading

Changed - Reworked most of the function code to optimize and correct the way it was intended to function
                  You must now release the fire button before the gun continues to fire in single and burst mode
                  Optimized some of the code thanks to Silvers suggestions

Features - Added Semi Auto mode for pistols
                  Added Burst mode bullet count option (Dragokas)
                  Added l4d_weapon_fire_modes.cfg

[ v1.3 ]
Fixed - Switching multiple guns in a slot breaks changing fire modes


Silvers 03-21-2020 12:22

Re: [L4D2] Weapon Fire Modes
 
Excellent, thank you! This will be fun to play with.

Some suggestions:
  • IsValidClient not required.
  • Delete line 186 (getting weapon classname) is already called at function start.
  • StrContains is inefficient. It would be better to do:
PHP Code:

// Skip "weapon_" and compare.
strcmp(sClsName[7], "rifle_desert") == 0

// Only compare the "pistol" part matching "weapon_pistol_magnum" too.
strncmp(sClsName[7], "pistol"6) == 

Any reason for restricting to L4D2 only and using "SDKHook_PostThink" instead of "OnPlayerRunCmd"?

MasterMind420 03-21-2020 12:41

Re: [L4D2] Weapon Fire Modes
 
Quote:

Originally Posted by Silvers (Post 2687871)
Excellent, thank you! This will be fun to play with.

Some suggestions:
  • IsValidClient not required.
  • Delete line 186 (getting weapon classname) is already called at function start.
  • StrContains is inefficient. It would be better to do:
PHP Code:

// Skip "weapon_" and compare.
strcmp(sClsName[7], "rifle_desert") == 0

// Only compare the "pistol" part matching "weapon_pistol_magnum" too.
strncmp(sClsName[7], "pistol"6) == 

Any reason for restricting to L4D2 only and using "SDKHook_PostThink" instead of "OnPlayerRunCmd"?

No problem, always wanted fire modes for weapons...Thanks for the suggestions i'll definitely update later today when i have time. I only restricted to L4D2 because I don't use L4D1 anymore and haven't tested it. Although codewise there is no restriction, anyone can test that it works in L4D1 and i'll update the post. I originally used Onplayerruncmd...which works fine...however lux recommended using postthink because that's when the weapons fire I believe...regardless both methods work fine, but if you think it would be better to use onplayerruncmd let me know, u me and lux can collaborate on this and see whats best :) Thanks again for your advice, always appreciated.

Dragokas 03-22-2020 02:41

Re: [L4D2] Weapon Fire Modes
 
Nice work!

Confirmed to work on L4D1 after fixing:

"m_usingMountedGun" property is not exist at all in L4D1.

Noticed:

- Single mode: sometimes 2 bullets is shooting, sometimes 1 (50% chance)

Suggestions:

- add late loading support.

Features (for thought):

- ConVar to control the number of bullets in bursting
- ConVar to control delay between bursting attacks

May I ask some questions (for those who knows) ?

- What are the benefits of using "PrefetchSound()" - I know it came from timocop's plugin.
- What are difference between GetClientButtons() and "m_afButtonPressed" prop?

MasterMind420 03-22-2020 08:13

Re: [L4D2] Weapon Fire Modes
 
Quote:

Originally Posted by Dragokas (Post 2687946)
Nice work!

Confirmed to work on L4D1 after fixing:

"m_usingMountedGun" property is not exist at all in L4D1.

Noticed:

- Single mode: sometimes 2 bullets is shooting, sometimes 1 (50% chance)

Suggestions:

- add late loading support.

Features (for thought):

- ConVar to control the number of bullets in bursting
- ConVar to control delay between bursting attacks

May I ask some questions (for those who knows) ?

- What are the benefits of using "PrefetchSound()" - I know it came from timocop's plugin.
- What are difference between GetClientButtons() and "m_afButtonPressed" prop?

Thanks for checking L4D1 for me, will fix the mounted gun entprop just for L4D2...

Single mode sometimes shooting more than 1...I will swap this over to onplayerruncmd that may correct the issue...if it does not i will figure out another way.

I will add late loading...

Although technically most weapons that do burst fire only shoot 2 rounds I will add an option for the number of rounds fired with burst mode.

Hmm the delay between burst/single while holding the attack button, I can also add a convar to control that...

I have no clue what prefetch sound actually does or the benefit of using it, TimoCop or perhaps even Silvers may have an explanation to its use.

The difference between GetClientButtons() and "m_afButtonPressed" prop is...
GetClientButtons is for the key simply being used at all...pressed/released/held.
m_afButtonPressed prop detects only when the key is pressed.

Dragokas 03-22-2020 08:43

Re: [L4D2] Weapon Fire Modes
 
Thanks for an explanation.
Not very understand about m_afButtonPressed, nah, anyway, another time.

Quote:

Although technically most weapons that do burst fire only shoot 2 rounds I will add an option for the number of rounds fired with burst mode.
Since we are creating new weapon, fantastic scenarious could also take place =)

One more notice, at the moment "[FIRE MODE] \x01Single" etc. messages are displayed for all weapons, not matter is weapon support these mode or not.
It is a little bit confusing.

MasterMind420 03-22-2020 08:53

Re: [L4D2] Weapon Fire Modes
 
Quote:

Originally Posted by Dragokas (Post 2687994)
Thanks for an explanation.
Not very understand about m_afButtonPressed, nah, anyway, another time.


Since we are creating new weapon, fantastic scenarious could also take place =)

One more notice, at the moment "[FIRE MODE] \x01Single" etc. messages are displayed for all weapons, not matter is weapon support these mode or not.
It is a little bit confusing.

yah i just caught that...i rushed the plugin out for testing and am noticing all kinds of mistakes lol. i've corrected the issue by moving the weapon checks for now...1.1 will be fixed with l4d1 support...1.2 will be optimized better with some suggestions from Silvers for checking weapons as well as adding convars...i'm just quickly fixing a few things atm.

MasterMind420 03-22-2020 09:17

Re: [L4D2] Weapon Fire Modes
 
UPDATE

Code:

[ v1.1 ]
Fixed - Mode switch PrintToChat on unsupported weapons

Changed - Weapon checks have been moved around and optimized somewhat.
                  Moved function code from PostThink to OnPlayerRunCmd
                  Renamed plugin file to l4d_weapon_fire_modes(delete v1.0 from your plugins directory)

Features - Added L4D1 support
                  Added late load support

        MORE OPTIMIZATIONS AND SUGGESTION IMPLEMENTATION COMING SOON...


MasterMind420 03-22-2020 21:50

Re: [L4D/L4D2] Weapon Fire Modes
 
UPDATE

Code:

[ v1.2 ]
Fixed - Burst fire for pistols is now as intended
                Burst fire bug when 1 bullet in clip and then reloading

Changed - Reworked most of the function code to optimize and correct the way it was intended to function
                  You must now release the fire button before the gun continues to fire in single and burst mode
                  Optimized some of the code thanks to Silvers suggestions

Features - Added Semi Auto mode for pistols
                  Added Burst mode bullet count option (Dragokas)
                  Added l4d_weapon_fire_modes.cfg


SDArt 03-22-2020 22:46

Re: [L4D/L4D2] Weapon Fire Modes
 
Plugin failed to compile also can you make the desert rifle be full auto could it be possible?


All times are GMT -4. The time now is 23:49.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.