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

Solved [HELP] Remove Rate of Fire Modifier on AUG/SG552


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hellmonja
Senior Member
Join Date: Oct 2015
Old 12-07-2019 , 12:27   [HELP] Remove Rate of Fire Modifier on AUG/SG552
Reply With Quote #1

Hi guys! As the title says. AUG and SG552 changes rate of fire when you zoom in. I want to remove the modifier so it would fire normally. I was trying to hook it on Event_CurWeapon but the result is kinda--let's say erratic to keep it short. Is there an offset I don't know of that controls this?...
__________________

Last edited by hellmonja; 12-19-2019 at 08:12. Reason: Solved...
hellmonja is offline
thEsp
BANNED
Join Date: Aug 2017
Old 12-07-2019 , 14:04   Re: [HELP] Remove Rate of Fire Modifier on AUG/SG552
Reply With Quote #2

https://github.com/s1lentq/ReGameDLL..._sg552.cpp#L94
You gotta change CD_flNextAttack to a certain value.

Last edited by thEsp; 12-07-2019 at 14:08.
thEsp is offline
hellmonja
Senior Member
Join Date: Oct 2015
Old 12-07-2019 , 14:09   Re: [HELP] Remove Rate of Fire Modifier on AUG/SG552
Reply With Quote #3

Quote:
Originally Posted by thEsp View Post
...
Alright, thank you. I'll work with this for now and come back for more help when I get totally stumped...
__________________

Last edited by hellmonja; 12-07-2019 at 14:09.
hellmonja is offline
hellmonja
Senior Member
Join Date: Oct 2015
Old 12-19-2019 , 08:11   Re: [HELP] Remove Rate of Fire Modifier on AUG/SG552
Reply With Quote #4

Hi everyone! So I found a solution so that AUG & SG552 will shoot at the same rate, zoomed in or not. Here's what I came up with:
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define RPM_CONST        0.066500;

const m_flNextPrimaryAttack  46;
const 
m_pActiveItem         373;

public 
plugin_init()
{
    
register_plugin("RPM""1.0""hellmonja");

    
register_event("CurWeapon""Event_CurWeapon""be""1=1");
}

public 
Event_CurWeapon(user)
{
    new 
wpn_id get_user_weapon(user);
    new 
weapon get_pdata_cbase(userm_pActiveItem);
    
    if(
wpn_id == CSW_SG552 || wpn_id == CSW_AUG)
    {
        if(
get_pdata_float(weaponm_flNextPrimaryAttack4) != RPM_CONST)
            
set_pdata_float(weaponm_flNextPrimaryAttackRPM_CONST4);
    }

0.066500 was taken when I checked what was the value of m_flNextPrimaryAttack when shooting both weapons without zooming in. I didn't use CD_flNextAttack for reasons that would be tl:dr to put here. Let's just say I need it set to a certain value all the time so that the other systems work properly...
__________________
hellmonja is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 12-19-2019 , 11:42   Re: [HELP] Remove Rate of Fire Modifier on AUG/SG552
Reply With Quote #5

So why don't you hook PrimaryAttack and set the value there? Why do you need CurWeapon exactly?
__________________

Last edited by HamletEagle; 12-19-2019 at 11:42.
HamletEagle is offline
hellmonja
Senior Member
Join Date: Oct 2015
Old 12-19-2019 , 12:00   Re: [HELP] Remove Rate of Fire Modifier on AUG/SG552
Reply With Quote #6

Quote:
Originally Posted by HamletEagle View Post
So why don't you hook PrimaryAttack and set the value there? Why do you need CurWeapon exactly?
Ah! You are right. I knew there's something wrong with this code. I actually took it off from another plugin that manipulates rate of fire. Thank you for the tip!...

EDIT:
Works intermittently, often not at all. When it works and you don't let go of the trigger it works fine. If you zoom-in and do short bursts then it sometimes switches back and forth from fast to slow, often slow. Perhaps that's the reason the guy put it in CurWeapon...
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define RPM_CONST        0.066500

const m_flNextPrimaryAttack      46;

public 
plugin_init()
{
    
register_plugin("RPM""1.0""hellmonja")
    
    
RegisterHam(Ham_Weapon_PrimaryAttack"weapon_sg552""Ham_Weapon_PrimaryAttack_Pre"false);
    
RegisterHam(Ham_Weapon_PrimaryAttack"weapon_aug""Ham_Weapon_PrimaryAttack_Pre"false);
}

public 
Ham_Weapon_PrimaryAttack_Pre(weapon)
{
//    if(get_pdata_float(weapon, m_flNextPrimaryAttack, 4) != RPM_CONST)
        
set_pdata_float(weaponm_flNextPrimaryAttackRPM_CONST4);

Perhaps in FM_PlaybackEvent then check for evetid? Will try it tomorrow. I need to sleep...
__________________

Last edited by hellmonja; 12-19-2019 at 12:16.
hellmonja is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 12-22-2019 , 09:57   Re: [HELP] Remove Rate of Fire Modifier on AUG/SG552
Reply With Quote #7

Here it is how it works(looking at AUG):
1.CAUG::SecondaryAttack is called when right click is pressed and it changes the FOV to simulate zooming.
2.Inside CAUG:: PrimaryAttack FOV is checked and AUGFire is called with different values depending on zoom status(zoomed in/out): 0.135 when zoomed it and 0.0825 when normal. This value is passed in flCycleTime parameter.
3.Inside AUGFire: m_flNextPrimaryAttack and m_flNextSecondaryAttack are set to GetNextAttackDelay(flCycleTime) which translates(for our purpose) to flCycleTime + 0.0 = flCycleTime.
Therefore flCycleTime controls the rate of fire.

Here is what you are doing:
Ham_Weapon_PrimaryAttack pre: set m_flNextPrimaryAttack
PrimaryAttack is executed -> AUGFire is executed -> game changes m_flNextPrimaryAttack overriding your change

Long story short: hook as POST not PRE. Also your value is wrong, it should be 0.0825 for default rate of fire.
__________________

Last edited by HamletEagle; 12-22-2019 at 09:58.
HamletEagle is offline
hellmonja
Senior Member
Join Date: Oct 2015
Old 12-28-2019 , 14:24   Re: [HELP] Remove Rate of Fire Modifier on AUG/SG552
Reply With Quote #8

Quote:
Originally Posted by HamletEagle View Post
Here it is how it works(looking at AUG):
1.CAUG::SecondaryAttack is called when right click is pressed and it changes the FOV to simulate zooming.
2.Inside CAUG:: PrimaryAttack FOV is checked and AUGFire is called with different values depending on zoom status(zoomed in/out): 0.135 when zoomed it and 0.0825 when normal. This value is passed in flCycleTime parameter.
3.Inside AUGFire: m_flNextPrimaryAttack and m_flNextSecondaryAttack are set to GetNextAttackDelay(flCycleTime) which translates(for our purpose) to flCycleTime + 0.0 = flCycleTime.
Therefore flCycleTime controls the rate of fire.

Here is what you are doing:
Ham_Weapon_PrimaryAttack pre: set m_flNextPrimaryAttack
PrimaryAttack is executed -> AUGFire is executed -> game changes m_flNextPrimaryAttack overriding your change

Long story short: hook as POST not PRE. Also your value is wrong, it should be 0.0825 for default rate of fire.
Just saw the post now. Thank you, I'll try it tomorrow since it's already pretty late here. In retrospect, I should've thought of trying it on post...
__________________
hellmonja is offline
Reply


Thread Tools
Display Modes

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 13:14.


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