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

Orpheu: Control CZ Bots


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 05-10-2010 , 05:05   Orpheu: Control CZ Bots
Reply With Quote #1

Many people asked me how to control CZ Bots. I decided to collect a pack with virtual functions + a bonus of 3 non virtual functions. You can use this as introduction and then search for more functions yourself.

I put together some base code to use those functions. On it, a hook to the bot creation is made so virtual functions can be get. The rest should be easy to understand. Non virtual functions ship with signature so you can use them on a plugin release. I used plugin_precache and plugin_init but that distintion is not really needed it was just for clarity.

PHP Code:

#include <amxmodx>
#include <orpheu>

/* Code for non-virtual functions */

new OrpheuFunction:Follow
new OrpheuFunction:Attack
new OrpheuFunction:Panic

public plugin_precache()
{
    
Follow OrpheuGetFunction("Follow","CCSBot")
    
Attack OrpheuGetFunction("Attack","CCSBot")
    
Panic OrpheuGetFunction("Panic","CCSBot")
}

/* Code for virtual functions */

new OrpheuHook:CCSBotHook

public plugin_init()
{
    
CCSBotHook OrpheuRegisterHook(OrpheuGetFunction("CCSBot","CCSBot"),"OnCCSBot",OrpheuHookPost)    
}

new 
OrpheuFunction:SetModel
new OrpheuFunction:SpawnBot
new OrpheuFunction:Jump
new OrpheuFunction:MoveBackward
new OrpheuFunction:MoveForward
new OrpheuFunction:StrafeRight
new OrpheuFunction:StrafeLeft
new OrpheuFunction:Initialize
new OrpheuFunction:Reload
new OrpheuFunction:PrimaryAttack
new OrpheuFunction:IsPlayerFacingMe
new OrpheuFunction:IsPlayerLookingAtMe
new OrpheuFunction:ExecuteCommand
new OrpheuFunction:IsEnemyPartVisible

public OnCCSBot(id)
{
    new 
botReference OrpheuGetReturn()
    
    
SetModel OrpheuGetFunctionFromObject(botReference,"SetModel","CCSBot")
    
SpawnBot OrpheuGetFunctionFromObject(botReference,"SpawnBot","CCSBot")
    
Jump OrpheuGetFunctionFromObject(botReference,"Jump","CCSBot")
    
MoveBackward OrpheuGetFunctionFromObject(botReference,"MoveBackward","CCSBot")
    
MoveForward OrpheuGetFunctionFromObject(botReference,"MoveForward","CCSBot")
    
StrafeLeft OrpheuGetFunctionFromObject(botReference,"StrafeLeft","CCSBot")
    
StrafeRight OrpheuGetFunctionFromObject(botReference,"StrafeRight","CCSBot")
    
Initialize OrpheuGetFunctionFromObject(botReference,"Initialize","CCSBot")
    
Reload OrpheuGetFunctionFromObject(botReference,"Reload","CCSBot")
    
PrimaryAttack OrpheuGetFunctionFromObject(botReference,"PrimaryAttack","CCSBot")

    
OrpheuRegisterHook(SpawnBot,"OnSpawnBot")

    
OrpheuRegisterHook(Jump,"OnMovement")
    
OrpheuRegisterHook(MoveBackward,"OnMovement")
    
OrpheuRegisterHook(MoveForward,"OnMovement")
    
OrpheuRegisterHook(StrafeLeft,"OnMovement")
    
OrpheuRegisterHook(StrafeRight,"OnMovement")
        
    
OrpheuUnregisterHook(CCSBotHook)
}

public 
OrpheuHookReturn:OnMovement(id)
{
    
//return OrpheuSupercede
}

public 
OnSpawnBot(id)
{
    
server_print("Spawned bot %d",id)
}

public 
plugin_cfg()
{
    
register_clcmd("bots_follow","follow")
    
register_clcmd("bots_jump","jump")
}

public 
follow(id)
{
    for(new 
i=1;i<=32;i++)
    {
        if(
is_user_alive(i) && is_user_bot(i))
        {            
            
OrpheuCall(Follow,i,id)
        }
    }
    
    return 
PLUGIN_HANDLED
}

public 
jump(id)
{    
    for(new 
i=1;i<=32;i++)
    {
        if(
is_user_alive(i) && is_user_bot(i))
        {            
            
OrpheuCall(Jump,i,1)
        }
    }
    
    return 
PLUGIN_HANDLED

Ok, there weren't many. Just two.

If you have any doubts, have no problem to ask me for stuff.
Attached Files
File Type: zip czbots.zip (11.3 KB, 403 views)
__________________
joaquimandrade is offline
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 05-10-2010 , 08:34   Re: Orpheu: Control CZ Bots
Reply With Quote #2

wow, nice! Too bad it's CZ only...
Seta00 is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 05-10-2010 , 09:27   Re: Orpheu: Control CZ Bots
Reply With Quote #3

Quote:
Originally Posted by Seta00 View Post
wow, nice! Too bad it's CZ only...
Too bad it's only for bots
__________________
xPaw is offline
bigbud
Member
Join Date: Jan 2008
Old 05-13-2010 , 10:34   Re: Orpheu: Control CZ Bots
Reply With Quote #4

What's wrong?

Function call works fine, but function hooks has always '-1' as argument!

PHP Code:
public OnSpawnBot(id)
{
    
server_print("Spawned bot %d",id)
}
 
OutPut:
Spawned bot -1
Spawned bot 
-1
Spawned bot 
-1
... 
__________________
bigbud is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 05-13-2010 , 12:38   Re: Orpheu: Control CZ Bots
Reply With Quote #5

Quote:
Originally Posted by bigbud View Post
What's wrong?

Function call works fine, but function hooks has always '-1' as argument!

PHP Code:
public OnSpawnBot(id)
{
    
server_print("Spawned bot %d",id)
}
 
OutPut:
Spawned bot -1
Spawned bot 
-1
Spawned bot 
-1
... 
I don't know. Tell me your os and stuff like that.
__________________
joaquimandrade is offline
DruGzOG
Veteran Member
Join Date: Nov 2007
Location: Unknown
Old 06-17-2010 , 13:17   Re: Orpheu: Control CZ Bots
Reply With Quote #6

Think you can make a podbots version?
__________________
DruGzOG is offline
Send a message via AIM to DruGzOG
albert123
Veteran Member
Join Date: Mar 2009
Location: VietNam, Hai Phong
Old 08-16-2010 , 01:23   Re: Orpheu: Control CZ Bots
Reply With Quote #7

This plugin only is used for CSCZ or CS1.6 ?
__________________
albert123 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-16-2010 , 05:24   Re: Orpheu: Control CZ Bots
Reply With Quote #8

It's written in the title : CZ.
__________________
Arkshine is offline
albert123
Veteran Member
Join Date: Mar 2009
Location: VietNam, Hai Phong
Old 08-18-2010 , 02:38   Re: Orpheu: Control CZ Bots
Reply With Quote #9

About podbot.. can we make a version for podbot ? Is it possible ?
__________________
albert123 is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 08-18-2010 , 04:33   Re: Orpheu: Control CZ Bots
Reply With Quote #10

Quote:
Originally Posted by albert123 View Post
About podbot.. can we make a version for podbot ? Is it possible ?
Yes. It is you just need to decompile the pod bot build and find the sigs that correspond to the functions that Quim found for CZ bots.
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 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 04:13.


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