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

Get cz bots to stop when shooting


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
LukeyB
Member
Join Date: Dec 2011
Old 12-15-2011 , 10:39   Get cz bots to stop when shooting
Reply With Quote #1

I'm trying to get cz bots to stop when shooting to increase their accuracy, then continue to move as normal. I have got it to where they will stop when shooting but can't move again. Here is what I have so far.

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <fun>
// any of the buttons on the right will count as moving
#define IN_MOVING (IN_FORWARD|IN_BACK|IN_MOVELEFT|IN_MOVERIGHT| IN_JUMP)
// Tracks players Shots-Fired: [0]=WeaponID, [1]=Ammo
new g_iCurrWeapon[33][2]
public 
plugin_init()
{
register_event"CurWeapon""Event_ShotFired""b" )
}
public 
Event_ShotFiredid )
{
// Players current weapon data..
new wID read_data)
new 
wAmmo read_data)
if( 
g_iCurrWeapon[id][0] != wID // User Changed Weapons..
{
g_iCurrWeapon[id][0] = wID
g_iCurrWeapon
[id][1] = wAmmo
return PLUGIN_CONTINUE
}
if( 
g_iCurrWeapon[id][1] < wAmmo // User Reloaded..
{
g_iCurrWeapon[id][1] = wAmmo
return PLUGIN_CONTINUE
}
if( 
g_iCurrWeapon[id][1] == wAmmo // User did something else, but didn't shoot..
{
return 
PLUGIN_CONTINUE
}
// This far means user shot his/her gun..
// Save new weapon data..
g_iCurrWeapon[id][1] = wAmmo
g_iCurrWeapon
[id][0] = wID
// Do Stuff here..
// he is alive and using movement keys
if( is_user_alive(id) && is_user_bot(id) && (pev(idpev_button) & IN_MOVING) )
{
// make sure he is using a gun
if( wID != CSW_HEGRENADE && wID != CSW_FLASHBANG && wID != CSW_SMOKEGRENADE
&& wID != CSW_C4 && wID != CSW_KNIFE )
{
set_user_maxspeedid 0.1)
}
}
return 
PLUGIN_CONTINUE

LukeyB is offline
Xellath
Veteran Member
Join Date: Dec 2007
Location: Sweden
Old 12-15-2011 , 14:59   Re: Get cz bots to stop when shooting
Reply With Quote #2

You could try hooking Ham_Weapon_PrimaryAttack in both Pre (and set maxspeed to 0.1) and in Post (reset the maxspeed).
__________________
Achievements API - a simple way for you to create your OWN custom achievements!
Xellath is offline
LukeyB
Member
Join Date: Dec 2011
Old 12-15-2011 , 16:35   Re: Get cz bots to stop when shooting
Reply With Quote #3

Thanks. How would I go about doing this for all weapons?
LukeyB is offline
Xellath
Veteran Member
Join Date: Dec 2007
Location: Sweden
Old 12-15-2011 , 17:40   Re: Get cz bots to stop when shooting
Reply With Quote #4

Code:
#include < amxmodx > #include < hamsandwich > #include < fun > const m_pPlayer = 41; public plugin_init( ) {     new WeaponName[ 32 ];     // no knifes, nades or c4     new NoPrimaryAttack = ( ( 1 << CSW_KNIFE ) | ( 1 << CSW_HEGRENADE ) | ( 1 << CSW_FLASHBANG ) | ( 1 << CSW_SMOKEGRENADE ) | ( 1 << CSW_C4 ) );     for( new CSWConstant = CSW_P228; CSWConstant <= CSW_P90; CSWConstant++ )     {         if( ~NoPrimaryAttack & ( 1 << CSWConstant ) // check for invalid CSW_* constants         && get_weaponname( CSWConstant, WeaponName, charsmax( WeaponName ) ) ) // get weaponname         {             RegisterHam( Ham_Weapon_PrimaryAttack, WeaponName, "Ham_Weapon_PrimaryAttack_Pre", 0 ); // hook pre             RegisterHam( Ham_Weapon_PrimaryAttack, WeaponName, "Ham_Weapon_PrimaryAttack_Post", 1 ); // hook post         }     } } public Ham_Weapon_PrimaryAttack_Pre( Weapon ) {     new id = get_pdata_cbase( Weapon, m_pPlayer, 4 );         set_user_maxspeed( id, 0.1 ); // set low speed } public Ham_Weapon_PrimaryAttack_Post( Weapon ) {     new id = get_pdata_cbase( Weapon, m_pPlayer, 4 );         set_user_maxspeed( id ); // reset speed }
__________________
Achievements API - a simple way for you to create your OWN custom achievements!

Last edited by Xellath; 12-16-2011 at 11:53.
Xellath is offline
LukeyB
Member
Join Date: Dec 2011
Old 12-16-2011 , 10:14   Re: Get cz bots to stop when shooting
Reply With Quote #5

Thanks for your help, but I get a lot of errors when trying to compile this.

Last edited by LukeyB; 12-16-2011 at 10:15.
LukeyB is offline
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 12-16-2011 , 11:35   Re: Get cz bots to stop when shooting
Reply With Quote #6

#include < fun >
__________________
You can do anything you set your mind to, man.

Devil259 is offline
Xellath
Veteran Member
Join Date: Dec 2007
Location: Sweden
Old 12-16-2011 , 11:52   Re: Get cz bots to stop when shooting
Reply With Quote #7

Quote:
Originally Posted by Devil259 View Post
#include < fun >
Forgot about that. Thanks. Edited.
__________________
Achievements API - a simple way for you to create your OWN custom achievements!
Xellath is offline
LukeyB
Member
Join Date: Dec 2011
Old 12-16-2011 , 12:45   Re: Get cz bots to stop when shooting
Reply With Quote #8

I appreciate your help with this. Unfortunately the speed does not reset until weapon is changed, which is a problem for the bots. I would like for this not to affect players, only bots and when I add is_user_alive(id) && is_user_bot(id) && to the script, i get error 017: undefined symbol "id".

PHP Code:
#include < amxmodx >
#include < hamsandwich >
#include < fun >
const m_pPlayer 41;
public 
plugin_init( )
{
    new 
WeaponName32 ];
    
// no knifes, nades or c4
    
new NoPrimaryAttack = ( ( << CSW_KNIFE ) | ( << CSW_HEGRENADE ) | ( << CSW_FLASHBANG ) | ( << CSW_SMOKEGRENADE ) | ( << CSW_C4 ) ); 
    for( new 
CSWConstant CSW_P228CSWConstant <= CSW_P90CSWConstant++ ) 
    {
        if( 
is_user_alive(id) && is_user_bot(id) && ~NoPrimaryAttack & ( << CSWConstant // check for invalid CSW_* constants
        
&& get_weaponnameCSWConstantWeaponNamecharsmaxWeaponName ) ) ) // get weaponname
        
{
            
RegisterHamHam_Weapon_PrimaryAttackWeaponName"Ham_Weapon_PrimaryAttack_Pre"); // hook pre
            
RegisterHamHam_Weapon_PrimaryAttackWeaponName"Ham_Weapon_PrimaryAttack_Post"); // hook post
        
}
    }
}
public 
Ham_Weapon_PrimaryAttack_PreWeapon 
{
    new 
id get_pdata_cbaseWeaponm_pPlayer); 
    
    
set_user_maxspeedid0.1 ); // set low speed
}
public 
Ham_Weapon_PrimaryAttack_PostWeapon 
{
    new 
id get_pdata_cbaseWeaponm_pPlayer); 
    
    
set_user_maxspeedid ); // reset speed

Thanks again for your help!
LukeyB is offline
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 12-16-2011 , 12:51   Re: Get cz bots to stop when shooting
Reply With Quote #9

You can't use id in plugin_init( )
Code:
#include < amxmodx > #include < hamsandwich > #include < fun > const m_pPlayer = 41; public plugin_init( ) {     new WeaponName[ 32 ];     // no knifes, nades or c4     new NoPrimaryAttack = ( ( 1 << CSW_KNIFE ) | ( 1 << CSW_HEGRENADE ) | ( 1 << CSW_FLASHBANG ) | ( 1 << CSW_SMOKEGRENADE ) | ( 1 << CSW_C4 ) );     for( new CSWConstant = CSW_P228; CSWConstant <= CSW_P90; CSWConstant++ )     {         if( ~NoPrimaryAttack & ( 1 << CSWConstant ) // check for invalid CSW_* constants         && get_weaponname( CSWConstant, WeaponName, charsmax( WeaponName ) ) ) // get weaponname         {             RegisterHam( Ham_Weapon_PrimaryAttack, WeaponName, "Ham_Weapon_PrimaryAttack_Pre", 0 ); // hook pre             RegisterHam( Ham_Weapon_PrimaryAttack, WeaponName, "Ham_Weapon_PrimaryAttack_Post", 1 ); // hook post         }     } } public Ham_Weapon_PrimaryAttack_Pre( Weapon ) {     new id = get_pdata_cbase( Weapon, m_pPlayer, 4 );         if( is_user_bot( id ) )         set_user_maxspeed( id, 0.1 ); // set low speed } public Ham_Weapon_PrimaryAttack_Post( Weapon ) {     new id = get_pdata_cbase( Weapon, m_pPlayer, 4 );         if( is_user_bot( id ) )         set_user_maxspeed( id ); // reset speed }

If it doesn't work, try to use pev_velocity.
__________________
You can do anything you set your mind to, man.


Last edited by Devil259; 12-16-2011 at 12:54.
Devil259 is offline
LukeyB
Member
Join Date: Dec 2011
Old 12-16-2011 , 13:18   Re: Get cz bots to stop when shooting
Reply With Quote #10

Gotcha. I am learning slowly, but surely.

This does stop the bot when shooting, but the bot speed in not reset after shooting so they get stuck in place.

Was reading about pev_velocity and am confused on how to add this instead of set_user_maxspeed.

Thanks again for all of your help.
LukeyB 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 22:02.


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