1+ /* *
2+ * =============================================================================
3+ * Source Python
4+ * Copyright (C) 2012 Source Python Development Team. All rights reserved.
5+ * =============================================================================
6+ *
7+ * This program is free software; you can redistribute it and/or modify it under
8+ * the terms of the GNU General Public License, version 3.0, as published by the
9+ * Free Software Foundation.
10+ *
11+ * This program is distributed in the hope that it will be useful, but WITHOUT
12+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14+ * details.
15+ *
16+ * You should have received a copy of the GNU General Public License along with
17+ * this program. If not, see <http://www.gnu.org/licenses/>.
18+ *
19+ * As a special exception, the Source Python Team gives you permission
20+ * to link the code of this program (as well as its derivative works) to
21+ * "Half-Life 2," the "Source Engine," and any Game MODs that run on software
22+ * by the Valve Corporation. You must obey the GNU General Public License in
23+ * all respects for all other code used. Additionally, the Source.Python
24+ * Development Team grants this exception to all derivative works.
25+ */
26+
27+ // ----------------------------------------------------------------------------
28+ // Includes
29+ // ----------------------------------------------------------------------------
30+ #include " modules/export_main.h"
31+ using namespace boost ::python;
32+
33+ #include " edict.h"
34+ #include " public/game/server/iplayerinfo.h"
35+
36+
37+ // Externals
38+ extern IBotManager* botmanager;
39+
40+ // ----------------------------------------------------------------------------
41+ // Exposes the bot_c module
42+ // ----------------------------------------------------------------------------
43+ void export_botmanager ();
44+ void export_botcontroller ();
45+ void export_botcmd ();
46+
47+ DECLARE_SP_MODULE (bot_c)
48+ {
49+ export_botmanager ();
50+ export_botcontroller ();
51+ export_botcmd ();
52+ }
53+
54+ void export_botmanager ()
55+ {
56+ class_<IBotManager, boost::noncopyable>(" BotManager" , no_init)
57+ .def (" get_bot_controller" ,
58+ &IBotManager::GetBotController,
59+ " Returns the BotController object for the given bot edict." ,
60+ reference_existing_object_policy ()
61+ )
62+
63+ .def (" create_bot" ,
64+ &IBotManager::CreateBot,
65+ " Creates a new bot and spawns it into the server." ,
66+ reference_existing_object_policy ()
67+ )
68+ ;
69+
70+ scope ().attr (" BotManager" ) = object (ptr (botmanager));
71+ }
72+
73+ void export_botcontroller ()
74+ {
75+ class_<IBotController, boost::noncopyable>(" BotController" , no_init)
76+ .def (" set_abs_origin" ,
77+ &IBotController::SetAbsOrigin,
78+ " Sets the bot's absolute origin."
79+ )
80+
81+ .def (" set_abs_angles" ,
82+ &IBotController::SetAbsAngles,
83+ " Sets the bot's absolute angles."
84+ )
85+
86+ .def (" set_local_origin" ,
87+ &IBotController::SetLocalOrigin,
88+ " Sets the bot's local origin."
89+ )
90+
91+ .def (" get_local_origin" ,
92+ &IBotController::GetLocalOrigin,
93+ " Returns the bot's local origin."
94+ )
95+
96+ .def (" set_local_angles" ,
97+ &IBotController::SetLocalAngles,
98+ " Sets the bot's local angles."
99+ )
100+
101+ .def (" get_local_angles" ,
102+ &IBotController::GetLocalAngles,
103+ " Returns the bot's local angles."
104+ )
105+
106+ .def (" remove_all_items" ,
107+ &IBotController::RemoveAllItems,
108+ " Removes all items the bot is wearing."
109+ )
110+
111+ .def (" set_active_weapon" ,
112+ &IBotController::SetActiveWeapon,
113+ " Gives the bot a weapon."
114+ )
115+
116+ .def (" is_eflag_set" ,
117+ &IBotController::IsEFlagSet,
118+ " Returns whether the given effect flag is set."
119+ )
120+
121+ .def (" run_player_move" ,
122+ &IBotController::RunPlayerMove,
123+ " Fires a virtual move command to the bot."
124+ )
125+ ;
126+ }
127+
128+ void export_botcmd ()
129+ {
130+ class_<CBotCmd>(" BotCmd" )
131+ .def (" reset" ,
132+ &CBotCmd::Reset,
133+ " Resets all values."
134+ )
135+
136+ .def_readwrite (" command_number" ,
137+ &CBotCmd::command_number,
138+ " For matching server and client commands for debugging."
139+ )
140+
141+ .def_readwrite (" tick_count" ,
142+ &CBotCmd::tick_count,
143+ " The tick the client created this command."
144+ )
145+
146+ .def_readwrite (" view_angles" ,
147+ &CBotCmd::viewangles,
148+ " Player instantaneous view angles."
149+ )
150+
151+ .def_readwrite (" forward_move" ,
152+ &CBotCmd::forwardmove,
153+ " Forward velocity."
154+ )
155+
156+ .def_readwrite (" side_move" ,
157+ &CBotCmd::sidemove,
158+ " Sideways velocity."
159+ )
160+
161+ .def_readwrite (" up_move" ,
162+ &CBotCmd::upmove,
163+ " Upward velocity."
164+ )
165+
166+ .def_readwrite (" buttons" ,
167+ &CBotCmd::buttons,
168+ " Button states."
169+ )
170+
171+ .def_readwrite (" impulse" ,
172+ &CBotCmd::impulse,
173+ " Impulse command."
174+ )
175+
176+ .def_readwrite (" weaponselect" ,
177+ &CBotCmd::weaponselect,
178+ " Current weapon ID."
179+ )
180+
181+ .def_readwrite (" weaponsubtype" ,
182+ &CBotCmd::weaponsubtype,
183+ " Current weapon ID."
184+ )
185+
186+ .def_readwrite (" random_seed" ,
187+ &CBotCmd::random_seed,
188+ " For shared random functions."
189+ )
190+
191+ .def_readwrite (" mousedx" ,
192+ &CBotCmd::mousedx,
193+ " Mouse accum in x from create move."
194+ )
195+
196+ .def_readwrite (" mousedy" ,
197+ &CBotCmd::mousedy,
198+ " Mouse accum in y from create move."
199+ )
200+
201+ .def_readwrite (" has_been_predicted" ,
202+ &CBotCmd::hasbeenpredicted,
203+ " Client only, tracks whether we've predicted this command at least once."
204+ )
205+ ;
206+ }
0 commit comments