-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbotmanager.angelscript
77 lines (61 loc) · 1.65 KB
/
botmanager.angelscript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
* This is a sample script.
*/
#include "BotManagerInterface.acs"
BotManager::BotManager g_BotManager( @CreateDumbBot );
CConCommand@ m_pAddBot;
void PluginInit()
{
g_BotManager.PluginInit();
@m_pAddBot = @CConCommand( "addbot", "Adds a new bot with the given name", @AddBotCallback );
}
void AddBotCallback( const CCommand@ args )
{
if( args.ArgC() < 2 )
{
g_Game.AlertMessage( at_console, "Usage: addbot <name>" );
return;
}
BotManager::BaseBot@ pBot = g_BotManager.CreateBot( args[ 1 ] );
if( pBot !is null )
{
g_Game.AlertMessage( at_console, "Created bot " + args[ 1 ] + "\n" );
}
else
{
g_Game.AlertMessage( at_console, "Could not create bot\n" );
}
}
final class DumbBot : BotManager::BaseBot
{
DumbBot( CBasePlayer@ pPlayer )
{
super( pPlayer );
}
void Think()
{
BotManager::BaseBot::Think();
// If the bot is dead and can be respawned, send a button press
if( Player.pev.deadflag >= DEAD_RESPAWNABLE )
{
Player.pev.button |= IN_ATTACK;
}
else
Player.pev.button &= ~IN_ATTACK;
KeyValueBuffer@ pInfoBuffer = g_EngineFuncs.GetInfoKeyBuffer( Player.edict() );
pInfoBuffer.SetValue( "topcolor", Math.RandomLong( 0, 255 ) );
pInfoBuffer.SetValue( "bottomcolor", Math.RandomLong( 0, 255 ) );
if( Math.RandomLong( 0, 100 ) > 10 )
Player.pev.button |= IN_ATTACK;
else
Player.pev.button &= ~IN_ATTACK;
for( uint uiIndex = 0; uiIndex < 3; ++uiIndex )
{
m_vecVelocity[ uiIndex ] = Math.RandomLong( -50, 50 );
}
}
}
BotManager::BaseBot@ CreateDumbBot( CBasePlayer@ pPlayer )
{
return @DumbBot( pPlayer );
}