PDA

View Full Version : Orpheu: Control CZ Bots


joaquimandrade
05-10-2010, 05:05
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.



#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
wow, nice! Too bad it's CZ only...

xPaw
05-10-2010, 09:27
wow, nice! Too bad it's CZ only...
Too bad it's only for bots :twisted:

bigbud
05-13-2010, 10:34
What's wrong?

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

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
What's wrong?

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

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
Think you can make a podbots version?

albert123
08-16-2010, 01:23
This plugin only is used for CSCZ or CS1.6 ?

Arkshine
08-16-2010, 05:24
It's written in the title : CZ.

albert123
08-18-2010, 02:38
About podbot.. can we make a version for podbot ? Is it possible ?

ot_207
08-18-2010, 04:33
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.

Arkshine
08-18-2010, 05:47
For podbot, it will be probably more tricky. You don't have such functions like CZ. Plus you would need to implement at least bot_t and bottask_t structures.

yokomo
04-12-2013, 05:09
Sorry i can't find the "IsEnemyPartVisible" file in config folder, can someone make it for me.

darktemplar
04-20-2013, 12:26
Could you make Zbots treat each other as enermy :D . I want to make FFA mode with Zbot :D