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

Hooking bots hurt


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 09-30-2009 , 11:20   Hooking bots hurt
Reply With Quote #1

Since Ham_TakeDamage only works for humans any one know a work around for bots?

i have working code for humans only... but i want to be able to make bots friendly fire variable..

so if i was to shoot a bot with an awp in the head it would only do 25% of its damage.

Example:
PHP Code:
public BotHurt
{
       if(
is_user_bot(victim)
       {
              if(
cs_get_user_team(victim) == cs_get_user_team(attacker))
              {
                   
damage dmgreduce
              
}
        }

Doc-Holiday is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-30-2009 , 12:06   Re: Hooking bots hurt
Reply With Quote #2

Ham_TakeDamage works fine with podbot.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 09-30-2009 , 12:10   Re: Hooking bots hurt
Reply With Quote #3

Quote:
Originally Posted by ConnorMcLeod View Post
Ham_TakeDamage works fine with podbot.
What functions don't work?
I read in some threads someone was using HamSandwich for bots and it wouldn't work.
I was under the impression that HamSandwich didn't support bots, instead of only a few functions not working.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 09-30-2009 , 12:10   Re: Hooking bots hurt
Reply With Quote #4

Quote:
Originally Posted by ConnorMcLeod View Post
Ham_TakeDamage works fine with podbot.
But not with CZ bots.

PHP Code:
#include <amxmodx>
#include <hamsandwich>
#define PLUGIN "Registering bots with ham"
#define VERSION "1.0"
#define AUTHOR "SnoW"
new bool:gBotsRegistered;
public 
plugin_init( )
{
     
register_pluginPLUGINVERSIONAUTHOR );
     
/*
          We are registering normal players just as an example.
     */
     
RegisterHamHam_Spawn"player""hamSpawnPlayer");
}
public 
client_authorizedid )
     if( !
gBotsRegistered && is_user_botid ) )
     {
          
/*
               The registering has to be delayed since the bot hasn't any data yet.
          */
          
set_task0.1"register_bots"id );
     }
 
public 
register_botsid )
{
     if( !
gBotsRegistered && is_user_connectedid ) )
     {
          
/*
               If registering wasn't done in the middle of the task and the bot haven't disconnected.
          */
          
RegisterHamFromEntityHam_Spawnid"hamSpawnBot");
          
gBotsRegistered true;
     }
}
public 
hamSpawnBotid )
{
     if( 
is_user_aliveid ) )
          
server_print"Bot spawn hooked correctly." );
     return 
HAM_IGNORED;
}
public 
hamSpawnPlayerid )
{
     if( 
is_user_aliveid ) )
          
server_print"Player spawn hooked correctly." );
     return 
HAM_IGNORED;

Edit: Reason below

Last edited by SnoW; 09-30-2009 at 12:19.
SnoW is offline
Send a message via MSN to SnoW
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 09-30-2009 , 12:14   Re: Hooking bots hurt
Reply With Quote #5

Just so you know, 0.1 is the smallest delay you can use in set_task( ).
Code:
static cell AMX_NATIVE_CALL set_task(AMX *amx, cell *params) /* 2 param */ {     CPluginMngr::CPlugin *plugin = g_plugins.findPluginFast(amx);     int a, iFunc;     char* stemp = get_amxstring(amx, params[2], 1, a);     if (params[5])     {         iFunc = registerSPForwardByName(amx, stemp, FP_ARRAY, FP_CELL, FP_DONE);     } else {         iFunc = registerSPForwardByName(amx, stemp, FP_CELL, FP_DONE);     }         if (iFunc == -1)     {         LogError(amx, AMX_ERR_NATIVE, "Function is not present (function \"%s\") (plugin \"%s\")", stemp, plugin->getName());         return 0;     }
    float base = amx_ctof(params[1]);
    if (base < 0.1f)
        base = 0.1f;
    char* temp = get_amxstring(amx, params[6], 0, a);     g_tasksMngr.registerTask(plugin, iFunc, UTIL_ReadFlags(temp), params[3], base, params[5], get_amxaddr(amx, params[4]), params[7]);     return 1; }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-30-2009 , 13:06   Re: Hooking bots hurt
Reply With Quote #6

Instead of using a task, you can register/unregister UpdateClientData, will register the ham forward at next frame.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 09-30-2009 , 14:55   Re: Hooking bots hurt
Reply With Quote #7

I could, but I see there no advantage.
SnoW is offline
Send a message via MSN to SnoW
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 10-01-2009 , 04:45   Re: Hooking bots hurt
Reply With Quote #8

Quote:
Originally Posted by SnoW View Post
But not with CZ bots.

PHP Code:
#include <amxmodx>
#include <hamsandwich>
#define PLUGIN "Registering bots with ham"
#define VERSION "1.0"
#define AUTHOR "SnoW"
new bool:gBotsRegistered;
public 
plugin_init( )
{
     
register_pluginPLUGINVERSIONAUTHOR );
     
/*
          We are registering normal players just as an example.
     */
     
RegisterHamHam_Spawn"player""hamSpawnPlayer");
}
public 
client_authorizedid )
     if( !
gBotsRegistered && is_user_botid ) )
     {
          
/*
               The registering has to be delayed since the bot hasn't any data yet.
          */
          
set_task0.1"register_bots"id );
     }
 
public 
register_botsid )
{
     if( !
gBotsRegistered && is_user_connectedid ) )
     {
          
/*
               If registering wasn't done in the middle of the task and the bot haven't disconnected.
          */
          
RegisterHamFromEntityHam_Spawnid"hamSpawnBot");
          
gBotsRegistered true;
     }
}
public 
hamSpawnBotid )
{
     if( 
is_user_aliveid ) )
          
server_print"Bot spawn hooked correctly." );
     return 
HAM_IGNORED;
}
public 
hamSpawnPlayerid )
{
     if( 
is_user_aliveid ) )
          
server_print"Player spawn hooked correctly." );
     return 
HAM_IGNORED;

Edit: Reason below

So running this will allow Ham_TakeDamage to affect bots?
Doc-Holiday is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 10-01-2009 , 08:51   Re: Hooking bots hurt
Reply With Quote #9

Quote:
Originally Posted by NcB_Sav View Post
So running this will allow Ham_TakeDamage to affect bots?
No. It's an example and hooks bots' spawn.
SnoW is offline
Send a message via MSN to SnoW
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 10-01-2009 , 16:46   Re: Hooking bots hurt
Reply With Quote #10

Then, you would have to set 3 values for gBotsRegistered :

0 = not registered
1 = registering soon
2 = registered

Advantage is that you don't use any task + it's immediatly registered.

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define VERSION "0.0.1"

new g_iFhUpdateClientDatag_iFirstBotId

public plugin_init()
{
    
register_plugin("TakeDamage"VERSION"ConnorMcLeod")

    new 
szModName[6]
    
get_modname(szModNamecharsmax(szModName))
    if( !
equal(szModName"czero") || cvar_exists("pb_version") )
    {
        
g_iFhUpdateClientData = -1
    
}

    
RegisterHam(Ham_TakeDamage"player""Player_TakeDamage")
}

public 
client_putinserverid )
{
    if( !
g_iFhUpdateClientData && is_user_bot(id) )
    {
        
g_iFirstBotId id
        g_iFhUpdateClientData 
register_forward(FM_UpdateClientData"UpdateClientData")
    }
    
}

public 
UpdateClientData(id)
{
    if( 
id == g_iFirstBotId )
    {
        
unregister_forward(FM_UpdateClientDatag_iFhUpdateClientData)
        
RegisterHamFromEntity(Ham_TakeDamageid"Player_TakeDamage")
    }
}

public 
Player_TakeDamageid iInflictor iAttackerFloat:flDamage iDamageType )
{


__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 10-02-2009 at 13:18.
ConnorMcLeod 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 20:27.


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