AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved [HELP] Remove Rate of Fire Modifier on AUG/SG552 (https://forums.alliedmods.net/showthread.php?t=320166)

hellmonja 12-07-2019 12:27

[HELP] Remove Rate of Fire Modifier on AUG/SG552
 
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?...

thEsp 12-07-2019 14:04

Re: [HELP] Remove Rate of Fire Modifier on AUG/SG552
 
https://github.com/s1lentq/ReGameDLL..._sg552.cpp#L94
You gotta change CD_flNextAttack to a certain value.

hellmonja 12-07-2019 14:09

Re: [HELP] Remove Rate of Fire Modifier on AUG/SG552
 
Quote:

Originally Posted by thEsp (Post 2676084)
...

Alright, thank you. I'll work with this for now and come back for more help when I get totally stumped...:)

hellmonja 12-19-2019 08:11

Re: [HELP] Remove Rate of Fire Modifier on AUG/SG552
 
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...:bacon!:

HamletEagle 12-19-2019 11:42

Re: [HELP] Remove Rate of Fire Modifier on AUG/SG552
 
So why don't you hook PrimaryAttack and set the value there? Why do you need CurWeapon exactly?

hellmonja 12-19-2019 12:00

Re: [HELP] Remove Rate of Fire Modifier on AUG/SG552
 
Quote:

Originally Posted by HamletEagle (Post 2677437)
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...

HamletEagle 12-22-2019 09:57

Re: [HELP] Remove Rate of Fire Modifier on AUG/SG552
 
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.

hellmonja 12-28-2019 14:24

Re: [HELP] Remove Rate of Fire Modifier on AUG/SG552
 
Quote:

Originally Posted by HamletEagle (Post 2677714)
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...


All times are GMT -4. The time now is 02:41.

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