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

Make AWP 100% accurate


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
sake
Senior Member
Join Date: Jul 2011
Old 09-04-2011 , 17:01   Make AWP 100% accurate
Reply With Quote #1

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?
__________________

Last edited by sake; 09-04-2011 at 17:12.
sake is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 09-04-2011 , 17:12   Re: Make AWP 100% accurate
Reply With Quote #2

http://forums.alliedmods.net/showthread.php?p=454202
http://forums.alliedmods.net/showthread.php?p=178833

Check for the weapon.
__________________
Accepting paid work for clans and communities. !Plugins & Models!
Don't hesitate to contact me.
bibu is offline
sake
Senior Member
Join Date: Jul 2011
Old 09-04-2011 , 19:09   Re: Make AWP 100% accurate
Reply With Quote #3

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
__________________

Last edited by sake; 09-04-2011 at 19:22.
sake is offline
jim_yang
Veteran Member
Join Date: Aug 2006
Old 09-04-2011 , 21:53   Re: Make AWP 100% accurate
Reply With Quote #4

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
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>

Last edited by jim_yang; 09-04-2011 at 22:01.
jim_yang is offline
sake
Senior Member
Join Date: Jul 2011
Old 09-05-2011 , 04:35   Re: Make AWP 100% accurate
Reply With Quote #5

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?
__________________

Last edited by sake; 09-05-2011 at 04:48.
sake is offline
sake
Senior Member
Join Date: Jul 2011
Old 09-05-2011 , 06:27   Re: Make AWP 100% accurate
Reply With Quote #6

Hmmm. One problem there:

What is the signature of AWPFire? Can't really find it.
__________________
sake is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 09-05-2011 , 10:19   Re: Make AWP 100% accurate
Reply With Quote #7

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
        }
    ]
}
__________________

Last edited by Arkshine; 09-05-2011 at 10:38.
Arkshine is offline
Derpanator
Junior Member
Join Date: Dec 2015
Location: Australia
Old 01-03-2016 , 09:05   Re: Make AWP 100% accurate
Reply With Quote #8

Quote:
Originally Posted by Arkshine View Post
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.
Derpanator 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 00:12.


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