AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   HL1 Servers (HLDS) (https://forums.alliedmods.net/forumdisplay.php?f=131)
-   -   Make AWP 100% accurate (https://forums.alliedmods.net/showthread.php?t=166540)

sake 09-04-2011 17:01

Make AWP 100% accurate
 
Hello there.

I've been wondering, if there was a way to make the AWP 100% accurate. Or do I have to do the hit checking myself?

EDIT: Oh. Could this please be moved to Scripting Help?

bibu 09-04-2011 17:12

Re: Make AWP 100% accurate
 
http://forums.alliedmods.net/showthread.php?p=454202
http://forums.alliedmods.net/showthread.php?p=178833

Check for the weapon.

sake 09-04-2011 19:09

Re: Make AWP 100% accurate
 
Thx. I already found another solution.

PHP Code:

public fw_Weapon_PrimaryAttack_Pre(weapon_ent)
{
    
playerEntityId get_pdata_cbase(weapon_entOFFSET_WEAPON_OWNEROFFSET_LINUX_WEAPONS);
    
    
fov pev(playerEntityId,pev_fov)
    
set_pev(playerEntityId,pev_fov,10)
    
    if(!
pev_valid(playerEntityId) || cs_get_weapon_ammo(weapon_ent) < 1)
        return 
HAM_IGNORED;
    
    
oldFlags entity_get_int(playerEntityIdEV_INT_flags);
    
entity_get_vector(playerEntityIdEV_VEC_velocityoldVelocity);
        
    
// Make the attack function think we're on the ground
    
entity_set_int(playerEntityIdEV_INT_flagsoldFlags FL_ONGROUND FL_DUCKING);
    
    
// If we're already in the air, make the attack function think we're not moving.
    // Not sure if this needs to be here.
    
if (oldFlags FL_ONGROUND) {
            
entity_set_vector(playerEntityIdEV_VEC_velocityzeroVector);
    }
    
    
    
    return 
HAM_IGNORED;
}

public 
fw_Weapon_PrimaryAttack_Post(weapon_ent)
{
    
set_pev(playerEntityId,pev_fov,fov)
    
    
entity_set_vector(weapon_entEV_VEC_punchangleFloat:{0.0,0.0,0.0});
    
    new 
id get_pdata_cbase(weapon_entOFFSET_WEAPON_OWNEROFFSET_LINUX_WEAPONS);
    
    
entity_set_int(idEV_INT_flagsoldFlags);
    
entity_set_vector(idEV_VEC_velocityoldVelocity);
    
    return 
HAM_HANDLED;


Parts are from the cs1.3 plugin that's around. And this should be more efficient due to less copying than the iaimgood one. BUT I don't know if it works for other weapons as well.

At least I think it is like that :P

jim_yang 09-04-2011 21:53

Re: Make AWP 100% accurate
 
ask arkshine to teach u how to use orpheu, just hack three float value, in CAwp:: PrimaryAttack()
Code:

void CAWP::PrimaryAttack()
{
    if ( !FBitSet( m_pPlayer->pev->flags, FL_ONGROUND ) )
    {
        AWPFire( 0.85, 1.45 );
    }
    else if ( m_pPlayer->pev->velocity.Length2D() > 140 )
    {
        AWPFire( 0.25, 1.45 );
    }
    else if ( m_pPlayer->pev->velocity.Length2D() > 10 )
    {
        AWPFire( 0.10, 1.45 );
    }
    else if ( FBitSet( m_pPlayer->pev->flags, FL_DUCKING ) )
    {
        AWPFire( 0.0, 1.45 );
    }
    else
    {
        AWPFire( 0.001, 1.45 );
    }
}

code from arkshine's sdk
you see that the first parameter in AWPFire ? that's the spread rate, change all of them to 0.0

sake 09-05-2011 04:35

Re: Make AWP 100% accurate
 
Already thought of that, maybe I'll do that today. Hmmm. But how can I do that with Orpheu. Somethin about orpheu_memory?

But one thing:

PHP Code:

if ( m_pPlayer->pev->fov == 90 )
    {
        
flSpread += 0.08;
    } 

I will still have to change that one. In my opinion the best thing would be to hook for AWPFire, but I didn't find the offset. Could it be that AWPFire is no virtualFunction?

sake 09-05-2011 06:27

Re: Make AWP 100% accurate
 
Hmmm. One problem there:

What is the signature of AWPFire? Can't really find it.

Arkshine 09-05-2011 10:19

Re: Make AWP 100% accurate
 
Forget about retrieving a decent signature for such function because the content is almost the same for such weapons and it's impossible to get a signature from that.

What you can do is to find the address of this function from PrimaryAttack.

Something like :

Code:
#include <amxmodx> #include <fakemeta> #include <hamsandwich> #include <orpheu> #include <orpheu_advanced> const m_pPlayer = 41; const Float:AwpAdjustedSpread = 0.08; public plugin_init() {     register_plugin( "", "", "" );         // Find AWPFire() address.     new startAddress = OrpheuGetFunctionAddress( OrpheuGetFunctionFromClass( "weapon_awp", "PrimaryAttack", "CBasePlayerWeapon" ) );     new fireAddress  = OrpheuGetNextCallAtAddress( startAddress, .number = 1 );         // We can hook our function.     OrpheuRegisterHook( OrpheuCreateFunction( fireAddress, "AWPFire", "CAWP" ), "OnAWPFire" ); } public OnAWPFire( const weapon, const Float:spread, Float:cycleTime, const bool:useSemi ) {     new player = get_pdata_cbase( weapon, m_pPlayer, 4 );     OrpheuSetParam( 2, pev( player, pev_fov ) == 90 ? -AwpAdjustedSpread : 0.0 ); }

So, now, awp should have the same behavior like you were ducking all the time.


EDIT : forget the files :

functions/CAWP/AWPFire :

Code:

{
    "name"      : "AWPFire",
    "class"    : "CAWP",
    "library"  : "mod",
    "arguments" :
    [
        {
            "type"  : "float"
        },
        {
            "type"  : "float"
        },
        {
            "type"  : "int"
        }
    ]
}



virtualFunctions/CBasePlayerWeapon/PrimaryAttack :

Code:

{
    "name"    : "PrimaryAttack",
    "class"  : "CBasePlayerWeapon",
    "library" : "mod",
    "indexes" :
    [
        {
            "os"    : "windows",
            "mod"  : "cstrike",
            "value" : 87
        },
        {
            "os"    : "linux",
            "mod"  : "cstrike",
            "value" : 89
        }
    ]
}


Derpanator 01-03-2016 09:05

Re: Make AWP 100% accurate
 
Quote:

Originally Posted by Arkshine (Post 1548702)
Forget about retrieving a decent signature for such function because the content is almost the same for such weapons and it's impossible to get a signature from that.

What you can do is to find the address of this function from PrimaryAttack.

Something like :

Code:
#include <amxmodx> #include <fakemeta> #include <hamsandwich> #include <orpheu> #include <orpheu_advanced> const m_pPlayer = 41; const Float:AwpAdjustedSpread = 0.08; public plugin_init() {     register_plugin( "", "", "" );         // Find AWPFire() address.     new startAddress = OrpheuGetFunctionAddress( OrpheuGetFunctionFromClass( "weapon_awp", "PrimaryAttack", "CBasePlayerWeapon" ) );     new fireAddress  = OrpheuGetNextCallAtAddress( startAddress, .number = 1 );         // We can hook our function.     OrpheuRegisterHook( OrpheuCreateFunction( fireAddress, "AWPFire", "CAWP" ), "OnAWPFire" ); } public OnAWPFire( const weapon, const Float:spread, Float:cycleTime, const bool:useSemi ) {     new player = get_pdata_cbase( weapon, m_pPlayer, 4 );     OrpheuSetParam( 2, pev( player, pev_fov ) == 90 ? -AwpAdjustedSpread : 0.0 ); }

So, now, awp should have the same behavior like you were ducking all the time.


EDIT : forget the files :

functions/CAWP/AWPFire :

Code:

{
    "name"      : "AWPFire",
    "class"    : "CAWP",
    "library"  : "mod",
    "arguments" :
    [
        {
            "type"  : "float"
        },
        {
            "type"  : "float"
        },
        {
            "type"  : "int"
        }
    ]
}



virtualFunctions/CBasePlayerWeapon/PrimaryAttack :

Code:

{
    "name"    : "PrimaryAttack",
    "class"  : "CBasePlayerWeapon",
    "library" : "mod",
    "indexes" :
    [
        {
            "os"    : "windows",
            "mod"  : "cstrike",
            "value" : 87
        },
        {
            "os"    : "linux",
            "mod"  : "cstrike",
            "value" : 89
        }
    ]
}


Hey there I was wondering where do I put the first bit of code? I need this for a combat surf server. Thanks in advanced.


All times are GMT -4. The time now is 01:37.

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