AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Code Snippets/Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=83)
-   -   Orpheu: Control CZ Bots (https://forums.alliedmods.net/showthread.php?t=126505)

joaquimandrade 05-10-2010 05:05

Orpheu: Control CZ Bots
 
1 Attachment(s)
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.

Seta00 05-10-2010 08:34

Re: Orpheu: Control CZ Bots
 
wow, nice! Too bad it's CZ only...

xPaw 05-10-2010 09:27

Re: Orpheu: Control CZ Bots
 
Quote:

Originally Posted by Seta00 (Post 1176359)
wow, nice! Too bad it's CZ only...

Too bad it's only for bots :twisted:

bigbud 05-13-2010 10:34

Re: Orpheu: Control CZ Bots
 
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
... 


joaquimandrade 05-13-2010 12:38

Re: Orpheu: Control CZ Bots
 
Quote:

Originally Posted by bigbud (Post 1179130)
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.

DruGzOG 06-17-2010 13:17

Re: Orpheu: Control CZ Bots
 
Think you can make a podbots version?

albert123 08-16-2010 01:23

Re: Orpheu: Control CZ Bots
 
This plugin only is used for CSCZ or CS1.6 ?

Arkshine 08-16-2010 05:24

Re: Orpheu: Control CZ Bots
 
It's written in the title : CZ.

albert123 08-18-2010 02:38

Re: Orpheu: Control CZ Bots
 
About podbot.. can we make a version for podbot ? Is it possible ?

ot_207 08-18-2010 04:33

Re: Orpheu: Control CZ Bots
 
Quote:

Originally Posted by albert123 (Post 1274259)
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.


All times are GMT -4. The time now is 17:39.

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