Raised This Month: $32 Target: $400
 8% 

[L4D/L4D2] Weapon Fire Modes


Post New Thread Reply   
 
Thread Tools Display Modes
Author
MasterMind420
BANNED
Join Date: Nov 2010
Plugin ID:
6994
Plugin Version:
1.3
Plugin Category:
Gameplay
Plugin Game:
Left 4 Dead
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Delete This Thread
    Unapprover:
    Reason for Unapproving:
    No source code / plugin, upload source and use the Report Post button for a new review.
    Old 03-21-2020 , 11:52   [L4D/L4D2] Weapon Fire Modes
    Reply With Quote #1

    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

    Last edited by DarkDeviL; 10-18-2021 at 09:02. Reason: Restore to previous version.
    MasterMind420 is offline
    Silvers
    SourceMod Plugin Approver
    Join Date: Aug 2010
    Location: SpaceX
    Old 03-21-2020 , 12:22   Re: [L4D2] Weapon Fire Modes
    Reply With Quote #2

    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"?
    __________________
    Silvers is offline
    MasterMind420
    BANNED
    Join Date: Nov 2010
    Old 03-21-2020 , 12:41   Re: [L4D2] Weapon Fire Modes
    Reply With Quote #3

    Quote:
    Originally Posted by Silvers View Post
    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.

    Last edited by MasterMind420; 03-21-2020 at 12:42.
    MasterMind420 is offline
    Dragokas
    Veteran Member
    Join Date: Nov 2017
    Location: Ukraine on fire
    Old 03-22-2020 , 02:41   Re: [L4D2] Weapon Fire Modes
    Reply With Quote #4

    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?
    __________________
    Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
    [My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]

    Last edited by Dragokas; 03-22-2020 at 02:42.
    Dragokas is offline
    MasterMind420
    BANNED
    Join Date: Nov 2010
    Old 03-22-2020 , 08:13   Re: [L4D2] Weapon Fire Modes
    Reply With Quote #5

    Quote:
    Originally Posted by Dragokas View Post
    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.
    MasterMind420 is offline
    Dragokas
    Veteran Member
    Join Date: Nov 2017
    Location: Ukraine on fire
    Old 03-22-2020 , 08:43   Re: [L4D2] Weapon Fire Modes
    Reply With Quote #6

    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.
    __________________
    Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
    [My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
    Dragokas is offline
    MasterMind420
    BANNED
    Join Date: Nov 2010
    Old 03-22-2020 , 08:53   Re: [L4D2] Weapon Fire Modes
    Reply With Quote #7

    Quote:
    Originally Posted by Dragokas View Post
    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.

    Last edited by MasterMind420; 03-22-2020 at 08:53.
    MasterMind420 is offline
    MasterMind420
    BANNED
    Join Date: Nov 2010
    Old 03-22-2020 , 09:17   Re: [L4D2] Weapon Fire Modes
    Reply With Quote #8

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

    Last edited by MasterMind420; 03-22-2020 at 21:50.
    MasterMind420 is offline
    MasterMind420
    BANNED
    Join Date: Nov 2010
    Old 03-22-2020 , 21:50   Re: [L4D/L4D2] Weapon Fire Modes
    Reply With Quote #9

    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

    Last edited by MasterMind420; 03-22-2020 at 22:03.
    MasterMind420 is offline
    SDArt
    Member
    Join Date: Aug 2019
    Old 03-22-2020 , 22:46   Re: [L4D/L4D2] Weapon Fire Modes
    Reply With Quote #10

    Plugin failed to compile also can you make the desert rifle be full auto could it be possible?
    SDArt is offline
    Reply



    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off

    Forum Jump


    All times are GMT -4. The time now is 14:25.


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