Raised This Month: $51 Target: $400
 12% 

[L4D2] Reset Reload On Shove (1.0.0 2014-01-09)


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Mr. Zero
Veteran Member
Join Date: Jun 2009
Location: Denmark
Plugin ID:
4043
Plugin Version:
1.0.0
Plugin Category:
Gameplay
Plugin Game:
Left 4 Dead
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Reset reloading animation upon Survivors shoving
    Old 01-10-2014 , 16:27   [L4D2] Reset Reload On Shove (1.0.0 2014-01-09)
    Reply With Quote #1

    Reset Reload On Shove

    About:
    Gone are the days where Survivors can rush ahead, attract a whole mob, only to run back into a corner, unload everything and start reloading while shoving. This plugin will reset reload process for Survivors once they start shoving.

    A minor change that can force Survivors working together and cover each other while reloading. No guarantees of course.

    Description:
    Reset reloading animation upon Survivors shoving.

    Known Problems / Things to Notice:

    Commands:
    No commands are implemented in this plugin.

    Cvars:
    No cvars are implemented in this plugin.

    Changelog:
    Code:
    Version 1.0  2014-01-09
    Initial release
    Attached Files
    File Type: zip resetreloadonshove_release.zip (21.3 KB, 936 views)
    Mr. Zero is offline
    Kid_Bandes
    Member
    Join Date: May 2010
    Old 04-28-2014 , 11:30   Re: [L4D2] Reset Reload On Shove (1.0.0 2014-01-09)
    Reply With Quote #2

    Nice, glad to know that there are still people making plugins for L4D2
    Kid_Bandes is offline
    KoMiKoZa
    Senior Member
    Join Date: Dec 2017
    Location: Thy old times.
    Old 08-13-2020 , 11:03   Re: [L4D2] Reset Reload On Shove (1.0.0 2014-01-09)
    Reply With Quote #3

    This desperately needs an update that allows bots to bypass this restriction. They become absolutely useless on harder difficulties when swarmed and out of ammo.
    KoMiKoZa is offline
    eyal282
    Veteran Member
    Join Date: Aug 2011
    Old 08-13-2020 , 13:06   Re: [L4D2] Reset Reload On Shove (1.0.0 2014-01-09)
    Reply With Quote #4

    Quote:
    Originally Posted by KoMiKoZa View Post
    This desperately needs an update that allows bots to bypass this restriction. They become absolutely useless on harder difficulties when swarmed and out of ammo.
    Code:
    /*
    Reset Reload On Shove
    Copyright (C) 2014  Buster "Mr. Zero" Nielsen
    
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    */
    
    /* Includes */
    #include <sourcemod>
    #include <sdktools>
    #include <l4d_stocks>
    
    /* Plugin Information */
    public Plugin:myinfo = 
    {
    	name		= "Reset Reload On Shove",
    	author		= "Buster \"Mr. Zero\" Nielsen",
    	description	= "Reset reloading animation upon Survivors shoving",
    	version		= "1.0.0",
    	url		= "[email protected]"
    }
    
    /* Globals */
    #define MAXEDICTS 2048
    #define MAXENTITIES 4096
    
    #define NETPROP_PLAYER_ACTIVEWEAPON "m_hActiveWeapon"
    #define NETPROP_PLAYER_VIEWMODEL "m_hViewModel"
    #define NETPROP_PLAYER_NEXTATTACK "m_flNextAttack"
    
    #define NETPROP_WEAPON_INRELOAD "m_bInReload"
    #define NETPROP_WEAPON_NEXTPRIMARYATTACK "m_flNextPrimaryAttack"
    #define NETPROP_WEAPON_TIMEWEAPONIDLE "m_flTimeWeaponIdle"
    #define NETPROP_WEAPON_SHOTGUN_RELOADSTATE "m_reloadState"
    #define NETPROP_WEAPON_SHOTGUN_RELOADANIMSTATE "m_reloadAnimState"
    #define NETPROP_WEAPON_SHOTGUN_RELOADNUMSHELLS "m_reloadNumShells"
    #define NETPROP_WEAPON_SHOTGUN_SHELLSINSERTED "m_shellsInserted"
    
    #define NETPROP_VIEWMODEL_LAYERSEQUENCE "m_nLayerSequence"
    #define NETPROP_VIEWMODEL_LAYERSTARTTIME "m_flLayerStartTime"
    #define NETPROP_VIEWMODEL_LAYER "m_nLayer"
    
    #define SHOVE_SOUND_NAME_SEARCH "Swish"
    #define SHOVE_DURATION 0.2 // Guess-timate, all guns have about 0.4 seconds of shove animation
    
    new bool:g_InReload[MAXPLAYERS + 1]
    
    /* Plugin Functions */
    public OnPluginStart()
    {
    	HookEvent("weapon_reload", WeaponReload_Event)
    	AddNormalSoundHook(ShoveSoundHook)
    }
    
    public OnClientDisconnect(client)
    {
    	g_InReload[client] = false
    }
    
    public Action:ShoveSoundHook(clients[64], &numClients, String:sample[PLATFORM_MAX_PATH], &entity, &channel, &Float:volume, &level, &pitch, &flags)
    {
    	if (entity <= 0 || entity > MaxClients || !g_InReload[entity] || IsFakeClient(entity))
    	{
    		return Plugin_Continue
    	}
    	
    	if (StrContains(sample, SHOVE_SOUND_NAME_SEARCH) == -1)
    	{
    		return Plugin_Continue
    	}
    	
    	new activeWeapon = GetEntPropEnt(entity, Prop_Send, NETPROP_PLAYER_ACTIVEWEAPON)
    	if (activeWeapon <= 0 || activeWeapon > MAXENTITIES)
    	{
    		g_InReload[entity] = false
    		return Plugin_Continue
    	}
    	
    	new L4D2WeaponId:weaponId = L4D2_GetWeaponId(activeWeapon)
    	
    	if (!IsReloadableWeapon(weaponId))
    	{
    		g_InReload[entity] = false
    		return Plugin_Continue
    	}
    	
    	new bool:isShotgun = IsWeaponAShotgun(weaponId)
    	
    	if (GetEntProp(activeWeapon, Prop_Send, NETPROP_WEAPON_INRELOAD) == 0)
    	{
    		g_InReload[entity] = false
    		return Plugin_Continue
    	}
    	
    	g_InReload[entity] = false
    	SetEntProp(activeWeapon, Prop_Send, NETPROP_WEAPON_INRELOAD, 0)
    	ChangeEdictState(activeWeapon, FindDataMapOffs(activeWeapon, NETPROP_WEAPON_INRELOAD))
    	SetPlayerNextPrimaryAttack(entity, GetGameTime() + SHOVE_DURATION)
    	
    	if (isShotgun)
    	{
    		SetEntProp(activeWeapon, Prop_Send, NETPROP_WEAPON_SHOTGUN_RELOADSTATE, 0)
    		SetEntProp(activeWeapon, Prop_Send, NETPROP_WEAPON_SHOTGUN_RELOADANIMSTATE, 0)
    		SetEntProp(activeWeapon, Prop_Send, NETPROP_WEAPON_SHOTGUN_RELOADNUMSHELLS, 0)
    		SetEntProp(activeWeapon, Prop_Send, NETPROP_WEAPON_SHOTGUN_SHELLSINSERTED, 0)
    	}
    	
    	new viewModel = GetEntPropEnt(entity, Prop_Send, NETPROP_PLAYER_VIEWMODEL)
    	
    	if (viewModel > 0 && viewModel <= MAXENTITIES && IsValidEntity(viewModel))
    	{
    		SetEntProp(viewModel, Prop_Send, NETPROP_VIEWMODEL_LAYER, 0) // Fixes reloading animation playing double after shoving!
    	}
    
    	return Plugin_Continue
    }
    
    public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon, &subtype, &cmdnum, &tickcount, &seed, mouse[2])
    {
    	if (!g_InReload[client])
    	{
    		return Plugin_Continue
    	}
    	
    	new activeWeapon = GetEntPropEnt(client, Prop_Send, NETPROP_PLAYER_ACTIVEWEAPON)
    	if (activeWeapon <= 0 || activeWeapon > MAXENTITIES)
    	{
    		g_InReload[client] = false
    		return Plugin_Continue
    	}
    	
    	new L4D2WeaponId:weaponId = L4D2_GetWeaponId(activeWeapon)
    	
    	if (!IsReloadableWeapon(weaponId))
    	{
    		g_InReload[client] = false
    		return Plugin_Continue
    	}
    	
    	if (GetEntProp(activeWeapon, Prop_Send, NETPROP_WEAPON_INRELOAD) == 0)
    	{
    		g_InReload[client] = false
    		return Plugin_Continue
    	}
    	
    	if (weapon > 0)
    	{
    		g_InReload[client] = false
    		return Plugin_Continue
    	}
    	
    	return Plugin_Continue
    }
    
    public WeaponReload_Event(Handle:event, const String:name[], bool:dontBroadcast)
    {
    	new client = GetClientOfUserId(GetEventInt(event, "userid"))
    	
    	if (client <= 0 || client > MaxClients || !IsClientInGame(client))
    	{
    		return
    	}
    	
    	new weapon = GetEntPropEnt(client, Prop_Send, NETPROP_PLAYER_ACTIVEWEAPON)
    	
    	if (weapon <= 0 || weapon > MAXENTITIES || !IsValidEntity(weapon))
    	{
    		return
    	}
    	
    	new L4D2WeaponId:weaponId = L4D2_GetWeaponId(weapon)
    	
    	if (!IsReloadableWeapon(weaponId))
    	{
    		return
    	}
    	
    	g_InReload[client] = true
    }
    
    stock SetPlayerNextPrimaryAttack(client, Float:time)
    {
    	new weapon = GetEntPropEnt(client, Prop_Send, NETPROP_PLAYER_ACTIVEWEAPON)
    	
    	if (weapon <= 0 || weapon > MAXENTITIES || !IsValidEntity(weapon))
    	{
    		return
    	}
    	
    	SetEntPropFloat(weapon, Prop_Send, NETPROP_WEAPON_NEXTPRIMARYATTACK, time)
    	SetEntPropFloat(weapon, Prop_Send, NETPROP_WEAPON_TIMEWEAPONIDLE, time)
    	SetEntPropFloat(client, Prop_Send, NETPROP_PLAYER_NEXTATTACK, time)
    }
    
    bool:IsReloadableWeapon(L4D2WeaponId:weaponId)
    {
    	if (weaponId == L4D2WeaponId_Pistol ||
    		weaponId == L4D2WeaponId_Smg ||
    		weaponId == L4D2WeaponId_Pumpshotgun ||
    		weaponId == L4D2WeaponId_Autoshotgun ||
    		weaponId == L4D2WeaponId_Rifle ||
    		weaponId == L4D2WeaponId_HuntingRifle ||
    		weaponId == L4D2WeaponId_SmgSilenced ||
    		weaponId == L4D2WeaponId_ShotgunChrome ||
    		weaponId == L4D2WeaponId_RifleDesert ||
    		weaponId == L4D2WeaponId_SniperMilitary ||
    		weaponId == L4D2WeaponId_ShotgunSpas ||
    		weaponId == L4D2WeaponId_GrenadeLauncher ||
    		weaponId == L4D2WeaponId_RifleAK47 ||
    		weaponId == L4D2WeaponId_PistolMagnum ||
    		weaponId == L4D2WeaponId_SmgMP5 ||
    		weaponId == L4D2WeaponId_RifleSG552 ||
    		weaponId == L4D2WeaponId_SniperAWP ||
    		weaponId == L4D2WeaponId_SniperScout)
    	{
    		return true
    	}
    	
    	return false
    }
    
    bool:IsWeaponAShotgun(L4D2WeaponId:weaponId)
    {
    	if (weaponId == L4D2WeaponId_Pumpshotgun ||
    		weaponId == L4D2WeaponId_Autoshotgun ||
    		weaponId == L4D2WeaponId_ShotgunChrome ||
    		weaponId == L4D2WeaponId_ShotgunSpas)
    	{
    		return true
    	}
    	
    	return false
    }
    __________________
    I am available to make plugins for pay.

    Discord: Eyal282#1334
    eyal282 is offline
    KoMiKoZa
    Senior Member
    Join Date: Dec 2017
    Location: Thy old times.
    Old 08-13-2020 , 13:18   Re: [L4D2] Reset Reload On Shove (1.0.0 2014-01-09)
    Reply With Quote #5

    Quote:
    Originally Posted by eyal282 View Post
    Spoiler
    Thanks for the quick response! Sent a cup of coffee your way.

    Last edited by KoMiKoZa; 08-13-2020 at 13:19.
    KoMiKoZa is offline
    woohood
    New Member
    Join Date: Nov 2020
    Old 11-02-2020 , 12:07   Re: [L4D2] Reset Reload On Shove (1.0.0 2014-01-09)
    Reply With Quote #6

    Is there anyway to make the reset be on a certain part of the reloading animation? Example being after the magazine is already taken out the gun? If so, how would I be able to do this?
    woohood is offline
    KillerBudgie
    Junior Member
    Join Date: Apr 2015
    Location: United Kingdom
    Old 03-05-2024 , 15:36   Re: [L4D2] Reset Reload On Shove (1.0.0 2014-01-09)
    Reply With Quote #7

    This plugin won't compile for me. Any suggestions?
    KillerBudgie is offline
    Marttt
    Veteran Member
    Join Date: Jan 2019
    Location: Brazil
    Old 03-05-2024 , 18:12   Re: [L4D2] Reset Reload On Shove (1.0.0 2014-01-09)
    Reply With Quote #8

    Quote:
    Originally Posted by Mr. Zero View Post
    Since the repo has no files, you can replace the include to left4dhooks (download here)

    change:
    PHP Code:
    #include <l4d_stocks> 
    to:
    PHP Code:
    #include <left4dhooks> 
    compile manually and it should work.
    __________________

    Last edited by Marttt; 03-05-2024 at 18:21.
    Marttt is offline
    KillerBudgie
    Junior Member
    Join Date: Apr 2015
    Location: United Kingdom
    Old 03-06-2024 , 13:25   Re: [L4D2] Reset Reload On Shove (1.0.0 2014-01-09)
    Reply With Quote #9

    Thanks again, it managed to compile. As l4d_stocks hasn't been updated for almost 10 years...
    KillerBudgie 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 02:41.


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