2003-03-09 03:11:28 +00:00
|
|
|
#include "Entity.h"
|
|
|
|
|
2006-12-16 14:42:55 +00:00
|
|
|
@class PLItem;
|
|
|
|
|
2003-07-24 08:25:04 +00:00
|
|
|
@class Bot;
|
2003-07-24 18:25:46 +00:00
|
|
|
@class Waypoint;
|
2006-12-16 14:42:55 +00:00
|
|
|
@class EditorState;
|
2003-07-24 08:25:04 +00:00
|
|
|
|
2010-08-23 05:07:54 +00:00
|
|
|
struct bot_data_t {
|
2003-08-01 05:25:07 +00:00
|
|
|
string name;
|
|
|
|
float pants, shirt;
|
|
|
|
};
|
|
|
|
typedef struct bot_data_t bot_data_t;
|
|
|
|
|
2003-07-24 18:23:13 +00:00
|
|
|
@interface Target: Entity
|
|
|
|
{
|
2003-08-22 06:35:19 +00:00
|
|
|
@public
|
2011-03-20 08:27:47 +00:00
|
|
|
Waypoint *current_way;
|
2011-03-30 01:38:44 +00:00
|
|
|
int hold_select;
|
2011-03-20 08:27:47 +00:00
|
|
|
Target *_last;
|
|
|
|
EditorState *editor;
|
2003-07-24 18:23:13 +00:00
|
|
|
}
|
2011-03-20 08:27:47 +00:00
|
|
|
+(Target *)forEntity:(entity)e;
|
2003-07-24 18:23:13 +00:00
|
|
|
-(vector)realorigin;
|
2003-08-18 06:30:05 +00:00
|
|
|
-(vector)origin;
|
2011-03-30 01:38:44 +00:00
|
|
|
-(int)canSee:(Target *)targ ignoring:(entity)ignore;
|
2003-08-01 05:25:07 +00:00
|
|
|
-(void)setOrigin:(vector) org;
|
2011-03-30 01:38:44 +00:00
|
|
|
-(int)recognizePlat:(int)flag;
|
|
|
|
-(int)ishuman;
|
|
|
|
-(int)priority:(Bot *)bot;
|
2011-03-20 08:27:47 +00:00
|
|
|
-(Waypoint *)findWaypoint:(Waypoint *)start;
|
2003-08-25 01:13:25 +00:00
|
|
|
-(float)searchTime;
|
|
|
|
-(void)setSearchTime:(float)st;
|
|
|
|
-(string)classname;
|
2003-07-24 18:23:13 +00:00
|
|
|
@end
|
|
|
|
|
2003-07-24 18:25:46 +00:00
|
|
|
@interface Waypoint: Target
|
2003-07-24 08:25:04 +00:00
|
|
|
{
|
|
|
|
@public
|
2011-03-20 08:27:47 +00:00
|
|
|
Waypoint *links[4];
|
2011-03-30 01:38:44 +00:00
|
|
|
int flags;
|
2003-07-24 08:25:04 +00:00
|
|
|
vector origin;
|
|
|
|
|
2011-03-30 01:38:44 +00:00
|
|
|
int is_temp;
|
2003-08-25 01:13:25 +00:00
|
|
|
|
2011-03-30 01:38:44 +00:00
|
|
|
int bot_bits;
|
|
|
|
int busy; //???
|
2006-12-10 06:31:39 +00:00
|
|
|
float distance;
|
2011-03-20 08:27:47 +00:00
|
|
|
Waypoint *enemy;
|
2003-07-24 08:25:04 +00:00
|
|
|
float search_time;
|
2003-08-22 06:56:31 +00:00
|
|
|
|
2011-03-20 08:27:47 +00:00
|
|
|
Waypoint *chain;
|
2003-07-24 08:25:04 +00:00
|
|
|
}
|
2010-12-16 12:24:53 +00:00
|
|
|
+(void)loadFile:(string)path;
|
2003-07-24 08:25:04 +00:00
|
|
|
+(void)clearAll;
|
2011-03-30 01:38:44 +00:00
|
|
|
+(Waypoint *)waypointForNum:(int)num;
|
2003-07-24 08:25:04 +00:00
|
|
|
+(void)fixWaypoints;
|
2011-03-20 08:27:47 +00:00
|
|
|
+(PLItem *)plist;
|
|
|
|
+(void)check:(Target *)ent;
|
2003-07-24 08:25:04 +00:00
|
|
|
|
|
|
|
+(void)clearRouteTable;
|
2011-03-20 08:27:47 +00:00
|
|
|
+(void)clearMyRoute:(Bot *) bot;
|
|
|
|
+(Waypoint *)find:(vector)org radius:(float)rad;
|
2003-07-24 08:25:04 +00:00
|
|
|
|
2006-12-16 14:42:55 +00:00
|
|
|
+(void)showAll;
|
|
|
|
+(void)hideAll;
|
|
|
|
-(void)deselect;
|
|
|
|
-(void)select;
|
|
|
|
|
2011-03-30 01:38:44 +00:00
|
|
|
-(int)id;
|
2003-07-24 20:23:03 +00:00
|
|
|
-(id)init;
|
2003-07-24 08:25:04 +00:00
|
|
|
-(id)initAt:(vector)org;
|
|
|
|
-(id)initFromEntity:(entity)ent;
|
|
|
|
|
2011-03-30 01:38:44 +00:00
|
|
|
-(int)isLinkedTo:(Waypoint *)way;
|
|
|
|
-(int)linkWay:(Waypoint *)way;
|
|
|
|
-(int)teleLinkWay:(Waypoint *)way;
|
2011-03-20 08:27:47 +00:00
|
|
|
-(void)unlinkWay:(Waypoint *)way;
|
2003-07-24 08:25:04 +00:00
|
|
|
|
2011-03-30 01:38:44 +00:00
|
|
|
-(void)followLink:(Waypoint *)e2 :(int)bBit;
|
2003-07-24 08:25:04 +00:00
|
|
|
-(void)waypointThink;
|
2003-07-24 20:23:03 +00:00
|
|
|
|
2006-12-16 14:42:55 +00:00
|
|
|
-(void)clearLinks;
|
2003-07-24 20:23:03 +00:00
|
|
|
-(void)clearRoute;
|
2011-03-20 08:27:47 +00:00
|
|
|
-(void)clearRouteForBot:(Bot *)bot;
|
2003-07-29 17:45:30 +00:00
|
|
|
|
|
|
|
-(id)queueForThink;
|
2003-07-24 08:25:04 +00:00
|
|
|
@end
|
2003-07-31 16:57:01 +00:00
|
|
|
@class Array;
|
2011-03-20 08:27:47 +00:00
|
|
|
@extern Array *waypoint_array;
|
2003-07-24 08:25:04 +00:00
|
|
|
|
2003-07-24 18:23:13 +00:00
|
|
|
@interface Bot: Target
|
2003-03-09 03:11:28 +00:00
|
|
|
{
|
2003-07-24 08:25:04 +00:00
|
|
|
@public
|
2011-03-30 01:38:44 +00:00
|
|
|
int keys;
|
|
|
|
int buttons;
|
|
|
|
int impulse;
|
2003-08-21 20:39:04 +00:00
|
|
|
vector b_angle;
|
2003-03-12 22:39:21 +00:00
|
|
|
vector mouse_emu;
|
|
|
|
|
2011-03-30 01:38:44 +00:00
|
|
|
int wallhug;
|
|
|
|
int ishuman;
|
2003-08-21 20:39:04 +00:00
|
|
|
float b_frags; // for detecting score changes
|
2011-03-30 01:38:44 +00:00
|
|
|
int b_clientno;
|
|
|
|
int b_clientflag;
|
2003-08-21 20:39:04 +00:00
|
|
|
float b_shirt;
|
|
|
|
float b_pants;
|
2003-03-09 03:11:28 +00:00
|
|
|
float ai_time;
|
|
|
|
float b_sound;
|
|
|
|
float missile_speed;
|
|
|
|
float portal_time;
|
2011-03-30 01:38:44 +00:00
|
|
|
int b_skill;
|
2003-03-09 03:11:28 +00:00
|
|
|
float switch_wallhug;
|
2011-03-30 01:38:44 +00:00
|
|
|
int b_aiflags;
|
|
|
|
int b_num;
|
2003-03-09 03:11:28 +00:00
|
|
|
float b_chattime;
|
|
|
|
float b_entertime;
|
2011-03-30 01:38:44 +00:00
|
|
|
int route_failed;
|
|
|
|
int dyn_flags;
|
|
|
|
int dyn_plat;
|
2003-07-24 08:25:04 +00:00
|
|
|
float dyn_time;
|
2011-03-20 08:27:47 +00:00
|
|
|
Waypoint *temp_way;
|
|
|
|
Waypoint *last_way;
|
|
|
|
Target *targets[4];
|
2003-07-23 22:44:15 +00:00
|
|
|
entity avoid;
|
2003-03-09 03:11:28 +00:00
|
|
|
vector obs_dir;
|
|
|
|
vector b_dir;
|
|
|
|
vector dyn_dest;
|
|
|
|
vector punchangle;
|
2003-07-24 08:25:04 +00:00
|
|
|
|
2003-08-21 20:39:04 +00:00
|
|
|
float teleport_time;
|
|
|
|
float portal_time;
|
2003-03-09 03:11:28 +00:00
|
|
|
}
|
|
|
|
- (id) init;
|
2011-03-30 01:38:44 +00:00
|
|
|
- (id) initWithEntity: (entity) e named:(bot_data_t *)name skill:(int)skill;
|
2003-07-24 21:54:24 +00:00
|
|
|
- (id) initFromPlayer: (entity) e;
|
2003-08-18 06:30:05 +00:00
|
|
|
- (void) preThink;
|
|
|
|
- (void) postThink;
|
2003-07-24 21:54:24 +00:00
|
|
|
- (void) frame;
|
|
|
|
- (void) disconnect;
|
2003-07-31 16:57:01 +00:00
|
|
|
|
|
|
|
- (void) updateClient;
|
2010-12-16 12:24:53 +00:00
|
|
|
- (void) releaseEditor;
|
2003-03-09 03:11:28 +00:00
|
|
|
@end
|
|
|
|
|
2003-07-24 18:23:13 +00:00
|
|
|
@interface Bot (Misc)
|
2011-03-30 01:38:44 +00:00
|
|
|
+(bot_data_t *)name:(int)r;
|
2011-03-20 08:27:47 +00:00
|
|
|
+(bot_data_t *)randomName;
|
2011-03-30 01:38:44 +00:00
|
|
|
-(int)fov:(entity)targ;
|
2003-07-24 18:23:13 +00:00
|
|
|
|
|
|
|
+(void)kick;
|
2003-08-25 05:12:41 +00:00
|
|
|
-(void)add;
|
2003-07-24 18:23:13 +00:00
|
|
|
@end
|
|
|
|
|
2003-07-23 06:35:39 +00:00
|
|
|
@interface Bot (Move)
|
2003-08-22 14:52:34 +00:00
|
|
|
- (void)sendMove;
|
2003-07-23 06:35:39 +00:00
|
|
|
- (void)jump;
|
2011-03-30 01:38:44 +00:00
|
|
|
- (int)canRJ;
|
|
|
|
- (int)recognizePlat: (int) flag;
|
|
|
|
- (int)keysForDir: (vector) sdir;
|
|
|
|
- (void)obstructed: (vector) whichway : (int) danger;
|
2003-07-23 06:35:39 +00:00
|
|
|
- (void)obstacles;
|
2003-08-18 16:48:53 +00:00
|
|
|
- (void)dodgeObstruction;
|
2003-07-23 06:35:39 +00:00
|
|
|
- (void)movetogoal;
|
2011-03-30 01:38:44 +00:00
|
|
|
- (int)walkmove: (vector) weird;
|
2003-07-23 06:35:39 +00:00
|
|
|
- (void)roam;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface Bot (AI)
|
2011-03-30 01:38:44 +00:00
|
|
|
-(int)targetOnstack:(Target *)scot;
|
2011-03-20 08:27:47 +00:00
|
|
|
-(void)targetAdd:(Target *)e;
|
|
|
|
-(void)targetDrop:(Target *)e;
|
2006-12-16 14:42:55 +00:00
|
|
|
-(void)targetClearAll;
|
2011-03-30 01:38:44 +00:00
|
|
|
-(void)lost:(Target *)targ :(int)success;
|
2011-03-20 08:27:47 +00:00
|
|
|
-(void)checkLost:(Target *)targ;
|
2003-08-18 16:48:53 +00:00
|
|
|
-(void)handleAI;
|
2003-07-23 22:44:15 +00:00
|
|
|
-(void)path;
|
2011-03-30 01:38:44 +00:00
|
|
|
-(void)lookForCrap:(int)scope;
|
2003-08-18 16:48:53 +00:00
|
|
|
-(void)angleSet;
|
2003-07-23 22:44:15 +00:00
|
|
|
-(void)AI;
|
2011-03-30 01:38:44 +00:00
|
|
|
-(int)priorityForThing:(Target *)thing;
|
2003-07-23 22:44:15 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
@interface Bot (Fight)
|
2011-03-20 08:27:47 +00:00
|
|
|
-(float)sizePlayer:(Target *)targ;
|
2003-08-18 16:48:53 +00:00
|
|
|
-(void)dodgeStuff;
|
|
|
|
-(void)weaponSwitch:(float)brange;
|
2003-07-23 22:44:15 +00:00
|
|
|
-(void)shoot;
|
2003-08-18 16:48:53 +00:00
|
|
|
-(void)fightStyle;
|
2003-07-23 06:35:39 +00:00
|
|
|
@end
|
|
|
|
|
2003-07-24 08:25:04 +00:00
|
|
|
@interface Bot (Way)
|
2011-03-20 08:27:47 +00:00
|
|
|
-(void)deleteWaypoint:(Waypoint *)what;
|
2003-07-24 08:25:04 +00:00
|
|
|
-(entity)findThing:(string)s;
|
2011-03-20 08:27:47 +00:00
|
|
|
-(Waypoint *)findRoute:(Waypoint *)lastone;
|
|
|
|
-(void)markPath:(Target *)this;
|
2011-03-30 01:38:44 +00:00
|
|
|
-(void)getPath:(Target *)this :(int)direct;
|
|
|
|
-(int)beginRoute;
|
2003-07-24 08:25:04 +00:00
|
|
|
-(void)spawnTempWaypoint:(vector)org;
|
|
|
|
-(void)dynamicWaypoint;
|
2003-07-24 18:23:13 +00:00
|
|
|
|
2011-03-30 01:38:44 +00:00
|
|
|
-(int)canSee:(Target *)targ;
|
2003-07-24 08:25:04 +00:00
|
|
|
@end
|
|
|
|
|
2003-07-30 16:45:28 +00:00
|
|
|
@interface Bot (Chat)
|
2011-03-30 01:38:44 +00:00
|
|
|
-(void)startTopic:(int)topic;
|
2003-07-30 16:45:28 +00:00
|
|
|
-(void)say:(string)msg;
|
|
|
|
-(void)say2:(string)msg;
|
|
|
|
-(void)sayTeam:(string)msg;
|
|
|
|
-(void)sayInit;
|
|
|
|
-(void)chat;
|
|
|
|
@end
|
|
|
|
|
2003-02-24 16:05:25 +00:00
|
|
|
#define FALSE 0
|
|
|
|
#define TRUE 1
|
|
|
|
|
2003-03-05 00:10:15 +00:00
|
|
|
/* punchangle
|
|
|
|
* bot fake kick?
|
|
|
|
*/
|
2003-02-24 16:05:25 +00:00
|
|
|
@extern .vector punchangle; // HACK - Don't want to screw with bot_phys
|
|
|
|
|
|
|
|
// --------defines-----
|
|
|
|
|
|
|
|
// used for the physics & movement AI
|
2003-07-31 16:57:01 +00:00
|
|
|
#define KEY_MOVEUP 0x001
|
|
|
|
#define KEY_MOVEDOWN 0x002
|
|
|
|
#define KEY_MOVELEFT 0x004
|
|
|
|
#define KEY_MOVERIGHT 0x008
|
|
|
|
#define KEY_MOVEFORWARD 0x010
|
|
|
|
#define KEY_MOVEBACK 0x020
|
|
|
|
#define KEY_LOOKUP 0x040
|
|
|
|
#define KEY_LOOKDOWN 0x080
|
|
|
|
#define KEY_LOOKLEFT 0x100
|
|
|
|
#define KEY_LOOKRIGHT 0x200
|
|
|
|
|
|
|
|
#define KEY_LOOK (KEY_LOOKRIGHT|KEY_LOOKLEFT|KEY_LOOKDOWN|KEY_LOOKUP)
|
|
|
|
#define KEY_MOVE (KEY_MOVEBACK|KEY_MOVEFORWARD|KEY_MOVERIGHT\
|
|
|
|
|KEY_MOVELEFT|KEY_MOVEDOWN|KEY_MOVEUP)
|
2003-02-24 16:05:25 +00:00
|
|
|
|
|
|
|
// these are aiflags for waypoints
|
|
|
|
// some overlap to the bot
|
2003-07-31 16:57:01 +00:00
|
|
|
#define AI_TELELINK_1 0x00001 // link type
|
|
|
|
#define AI_TELELINK_2 0x00002 // link type
|
|
|
|
#define AI_TELELINK_3 0x00004 // link type
|
|
|
|
#define AI_TELELINK_4 0x00008 // link type
|
|
|
|
#define AI_DOORFLAG 0x00010 // read ahead
|
|
|
|
#define AI_PRECISION 0x00020 // read ahead + point
|
|
|
|
#define AI_SURFACE 0x00040 // point
|
|
|
|
#define AI_BLIND 0x00080 // read ahead + point
|
|
|
|
#define AI_JUMP 0x00100 // point + ignore
|
|
|
|
#define AI_DIRECTIONAL 0x00200 // read ahead + ignore
|
|
|
|
#define AI_PLAT_BOTTOM 0x00400 // read ahead
|
|
|
|
#define AI_RIDE_TRAIN 0x00800 // read ahead
|
|
|
|
#define AI_SUPER_JUMP 0x01000 // point + ignore + route test
|
|
|
|
#define AI_SNIPER 0x02000 // point type
|
|
|
|
#define AI_AMBUSH 0x04000 // point type
|
|
|
|
#define AI_DOOR_NO_OPEN 0x08000 // read ahead
|
|
|
|
#define AI_DIFFICULT 0x10000 // route test
|
|
|
|
#define AI_TRACE_TEST 0x20000 // route test
|
|
|
|
|
|
|
|
// addition masks
|
|
|
|
#define AI_POINT_TYPES (AI_AMBUSH|AI_SNIPER|AI_SUPER_JUMP|AI_JUMP\
|
|
|
|
|AI_BLIND|AI_SURFACE|AI_PRECISION)
|
|
|
|
#define AI_READAHEAD_TYPES (AI_DOOR_NO_OPEN|AI_RIDE_TRAIN|AI_PLAT_BOTTOM\
|
|
|
|
|AI_DIRECTIONAL)
|
|
|
|
#define AI_IGNORE_TYPES (AI_SUPER_JUMP|AI_DIRECTIONAL|AI_JUMP)
|
2003-02-24 16:05:25 +00:00
|
|
|
|
|
|
|
// these are flags for bots/players (dynamic/editor flags)
|
|
|
|
#define AI_OBSTRUCTED 1
|
|
|
|
#define AI_HOLD_SELECT 2
|
|
|
|
#define AI_ROUTE_FAILED 2
|
2003-07-31 16:57:01 +00:00
|
|
|
#define AI_WAIT 4
|
2003-02-24 16:05:25 +00:00
|
|
|
#define AI_DANGER 8
|
|
|
|
|
|
|
|
#define WM_UNINIT 0
|
|
|
|
#define WM_DYNAMIC 1
|
|
|
|
#define WM_LOADING 2
|
|
|
|
#define WM_LOADED 3
|
|
|
|
// editor modes aren't available in QW, but we retain support of them
|
|
|
|
// since the editor is still built into the AI in places
|
|
|
|
#define WM_EDITOR 4
|
|
|
|
#define WM_EDITOR_DYNAMIC 5
|
|
|
|
#define WM_EDITOR_DYNLINK 6
|
|
|
|
|
|
|
|
#define OPT_NOCHAT 2
|
|
|
|
|
|
|
|
// -------globals-----
|
2011-03-20 08:27:47 +00:00
|
|
|
@extern Bot *players[32];
|
2003-03-04 07:29:42 +00:00
|
|
|
@extern float real_frametime;
|
2003-07-24 23:16:43 +00:00
|
|
|
@extern float bot_count, b_options;
|
|
|
|
@extern float lasttime;
|
|
|
|
@extern float waypoint_mode;
|
|
|
|
@extern float dump_mode;
|
|
|
|
@extern float direct_route;
|
2006-12-17 11:15:19 +00:00
|
|
|
@extern float sv_gravity;
|
2011-03-20 08:27:47 +00:00
|
|
|
@extern Bot *route_table;
|
2011-03-30 01:38:44 +00:00
|
|
|
@extern int busy_waypoints;
|
2003-02-24 16:05:25 +00:00
|
|
|
|
|
|
|
@extern float coop;
|
|
|
|
|
|
|
|
// -------ProtoTypes------
|
2003-07-31 16:57:01 +00:00
|
|
|
// external, in main code
|
2011-03-30 01:38:44 +00:00
|
|
|
@extern Bot *BotConnect (int whatbot, int whatskill);
|
2003-02-24 16:05:25 +00:00
|
|
|
@extern void() ClientConnect;
|
|
|
|
@extern void() ClientDisconnect;
|
|
|
|
@extern void() SetNewParms;
|
|
|
|
|
|
|
|
// rankings
|
2011-03-30 01:38:44 +00:00
|
|
|
@extern int (entity e) ClientNumber;
|
2003-02-24 16:05:25 +00:00
|
|
|
|
2011-03-30 01:38:44 +00:00
|
|
|
@extern void(vector org, vector bit1, int bit4, int flargs) make_way;
|
2003-02-24 16:05:25 +00:00
|
|
|
|
|
|
|
@extern void () map_dm1;
|
|
|
|
@extern void () map_dm2;
|
|
|
|
@extern void () map_dm3;
|
|
|
|
@extern void () map_dm4;
|
|
|
|
@extern void () map_dm5;
|
|
|
|
@extern void () map_dm6;
|
|
|
|
|
|
|
|
// ai & misc
|
2011-03-20 08:27:47 +00:00
|
|
|
@extern Array *bot_array;
|
2003-02-24 16:05:25 +00:00
|
|
|
@extern float(float y1, float y2) angcomp;
|
2003-08-22 06:56:31 +00:00
|
|
|
@extern float(entity ent, entity targ, vector targ_origin) sisible;
|
2003-02-24 16:05:25 +00:00
|
|
|
@extern vector(entity ent) realorigin;
|
|
|
|
@extern float(float v) frik_anglemod;
|
|
|
|
|
2011-03-30 01:38:44 +00:00
|
|
|
@extern void DeveloperLightning(Waypoint *e1, Waypoint *e2, int flag);
|
2003-02-24 16:05:25 +00:00
|
|
|
|
2003-03-10 23:54:41 +00:00
|
|
|
/*
|
|
|
|
angles is pitch yaw roll
|
|
|
|
move is forward right up
|
|
|
|
*/
|
2011-03-30 01:38:44 +00:00
|
|
|
@extern void (entity cl, float sec, vector angles, vector move, int buttons, int impulse) SV_UserCmd;
|
2003-09-04 07:44:47 +00:00
|
|
|
@extern void () Break;
|
2011-03-30 01:38:44 +00:00
|
|
|
@extern string (int i) itos;
|
2003-03-10 23:54:41 +00:00
|
|
|
|
2011-03-30 01:38:44 +00:00
|
|
|
@extern int bot_way_linker;
|
|
|
|
@extern int bot_move_linker;
|
|
|
|
@extern int bot_chat_linker;
|
2003-08-18 06:30:05 +00:00
|
|
|
@extern float stagger_think;
|
2011-03-30 01:38:44 +00:00
|
|
|
@extern int bot_fight_linker;
|
2003-08-18 06:30:05 +00:00
|
|
|
|
2003-02-24 16:05:25 +00:00
|
|
|
#include "defs.h"
|