From 2dee2b38c901963c969f976f4a2966061d5e101b Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 24 Feb 2003 16:05:25 +0000 Subject: [PATCH] convert frikbot to a lib. may or may not be broken --- fbxa/.gitignore | 6 + fbxa/Makefile | 40 +++ fbxa/bot.qc | 20 +- fbxa/bot_ai.qc | 44 +-- fbxa/bot_ed.qc | 36 +-- fbxa/bot_fight.qc | 16 +- fbxa/bot_misc.qc | 14 +- fbxa/bot_move.qc | 6 +- fbxa/bot_phys.qc | 14 +- fbxa/bot_qw.qc | 146 +--------- fbxa/bot_way.qc | 80 ++--- fbxa/defs.h | 725 ++++++++++++++++++++++++++++++++++++++++++++++ fbxa/frikbot.h | 22 ++ fbxa/libfrikbot.h | 182 ++++++++++++ fbxa/map_dm1.qc | 2 +- fbxa/map_dm2.qc | 2 +- fbxa/map_dm3.qc | 2 +- fbxa/map_dm4.qc | 2 +- fbxa/map_dm5.qc | 2 +- fbxa/map_dm6.qc | 2 +- 20 files changed, 1118 insertions(+), 245 deletions(-) create mode 100644 fbxa/.gitignore create mode 100644 fbxa/Makefile create mode 100644 fbxa/defs.h create mode 100644 fbxa/frikbot.h create mode 100644 fbxa/libfrikbot.h diff --git a/fbxa/.gitignore b/fbxa/.gitignore new file mode 100644 index 0000000..1235862 --- /dev/null +++ b/fbxa/.gitignore @@ -0,0 +1,6 @@ +*.a +*.dat +*.qfo +*.sym +ChangeLog +progdefs.h diff --git a/fbxa/Makefile b/fbxa/Makefile new file mode 100644 index 0000000..a8171ca --- /dev/null +++ b/fbxa/Makefile @@ -0,0 +1,40 @@ +QFCC=qfcc +QCFLAGS=-qq -g -Werror +QCPPFLAGS=-DLIBFRIKBOT + +libfrikbot_source = \ + bot_ai.qc \ + bot_fight.qc \ + bot_misc.qc \ + bot_move.qc \ + bot_phys.qc \ + bot_qw.qc \ + bot_way.qc \ + map_dm1.qc \ + map_dm2.qc \ + map_dm3.qc \ + map_dm4.qc \ + map_dm5.qc \ + map_dm6.qc + +libfrikbot_obj = $(addsuffix .qfo,$(basename $(libfrikbot_source))) +libfrikbot_dep = $(addprefix .deps/,$(addsuffix .d,$(basename $(libfrikbot_source)))) + +%.qfo: %.r + @mkdir -p .deps + @$(QFCC) -M -q $(QCPPFLAGS) -c $< | sed -e 's/\(\.r\)\?\.o\>/.qfo/' > .deps/`basename $@ .qfo`.d + $(QFCC) $(QCFLAGS) $(QCPPFLAGS) -c -o $@ $< + +%.qfo: %.qc + $(QFCC) $(QCFLAGS) $(QCPPFLAGS) -c -o $@ $< + +all: libfrikbot.a + +libfrikbot.a: $(libfrikbot_obj) + pak -cf $@ $^ + +clean: + rm -f *.qfo *.a *.d + rm -rf .deps + +-include $(libfrikbot_dep) diff --git a/fbxa/bot.qc b/fbxa/bot.qc index ee22a28..eab4cac 100644 --- a/fbxa/bot.qc +++ b/fbxa/bot.qc @@ -557,7 +557,7 @@ void() ClientFixRankings = return; self.switch_wallhug = 0; - b_temp2 = nextent(world); + b_temp2 = nextent(NIL); cno = 0; while (cno < max_clients) @@ -576,13 +576,13 @@ void() ClientInRankings = player_head._last = self; self._next = player_head; - self._last = world; + self._last = NIL; player_head = self; if (!self.phys_obj) { b_temp2 = phys_head; - while (b_temp2 != world && b_temp2.owner != self) + while (b_temp2 != NIL && b_temp2.owner != self) b_temp2 = b_temp2._next; self.phys_obj = b_temp2; } @@ -735,10 +735,10 @@ void() BotInit = local float numents; // spawn entities for the physics - ent = nextent(world); + ent = nextent(NIL); max_clients = 0; - while(ent != world) + while(ent != NIL) { max_clients = max_clients + 1; ent = nextent(ent); @@ -746,8 +746,8 @@ void() BotInit = if (max_clients > 16) max_clients = 16; - ent = nextent(world); - fisent = world; + ent = nextent(NIL); + fisent = NIL; while (numents < max_clients) { @@ -904,7 +904,7 @@ float(float tcolor) FindAnotherColor = { b_temp2 = player_head; pcount = 0; - while(b_temp2 != world) + while(b_temp2 != NIL) { if (b_temp2.team == scolor + 1) pcount = pcount + 1; @@ -939,7 +939,7 @@ BotConnect and related functions. entity(float num) GetClientEntity = { local entity upsy; - upsy = world; + upsy = NIL; num = num + 1; while (num > 0) { @@ -1189,7 +1189,7 @@ void() BotFrame = sv_stopspeed = cvar("sv_stopspeed"); real_frametime = frametime; // in NQ this is alright - self = nextent(world); + self = nextent(NIL); num = 0; while (num < max_clients) { diff --git a/fbxa/bot_ai.qc b/fbxa/bot_ai.qc index ef78fd6..e6bc204 100644 --- a/fbxa/bot_ai.qc +++ b/fbxa/bot_ai.qc @@ -42,6 +42,8 @@ this notice in its entirety. */ +#include "libfrikbot.h" + /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= @@ -54,7 +56,7 @@ checks to see if an entity is on the bot's stack float(entity scot) target_onstack = { - if (scot == world) + if (scot == NIL) return FALSE; else if (self.target1 == scot) return 1; @@ -81,7 +83,7 @@ LIFO stack, this will be the bot's new target1 void(entity ent) target_add = { - if (ent == world) + if (ent == NIL) return; if (target_onstack(ent)) return; @@ -117,21 +119,21 @@ void(entity ent) target_drop = self.target1 = self.target2; self.target2 = self.target3; self.target3 = self.target4; - self.target4 = world; + self.target4 = NIL; } else if (tg == 2) { self.target1 = self.target3; self.target2 = self.target4; - self.target3 = self.target4 = world; + self.target3 = self.target4 = NIL; } else if (tg == 3) { self.target1 = self.target4; - self.target2 = self.target3 = self.target4 = world; + self.target2 = self.target3 = self.target4 = NIL; } else if (tg == 4) - self.target1 = self.target2 = self.target3 = self.target4 = world; + self.target1 = self.target2 = self.target3 = self.target4 = NIL; self.search_time = time + 5; }; @@ -157,7 +159,7 @@ void(entity targ, float success) bot_lost = // find a new route if (!success) { - self.target1 = self.target2 = self.target3 = self.target4 = world; + self.target1 = self.target2 = self.target3 = self.target4 = NIL; self.last_way = FindWayPoint(self.current_way); ClearMyRoute(); self.b_aiflags = 0; @@ -170,8 +172,8 @@ void(entity targ, float success) bot_lost = if (targ.flags & FL_ITEM) { - if (targ.model == string_null) - targ._last = world; + if (!targ.model) + targ._last = NIL; else targ._last = self; } @@ -197,7 +199,7 @@ void(entity targ) bot_check_lost = local vector dist; dist = realorigin(targ) - self.origin; dist_z = 0; - if (targ == world) + if (targ == NIL) return; // waypoints and items are lost if you get close enough to them @@ -206,7 +208,7 @@ void(entity targ) bot_check_lost = { if (vlen(targ.origin - self.origin) < 32) bot_lost(targ, TRUE); - else if (targ.model == string_null) + else if (!targ.model) bot_lost(targ, TRUE); } else if (targ.classname == "waypoint") @@ -278,7 +280,7 @@ void(entity targ) bot_check_lost = { bot_lost(targ, TRUE); if (self.enemy == targ) - self.enemy = world; + self.enemy = NIL; //if (self.target1) // bot_get_path(self.target1, TRUE); @@ -362,7 +364,7 @@ void() bot_handle_ai = { if (newt.targetname) { - newt = find(world, target, newt.targetname); + newt = find(NIL, target, newt.targetname); if (newt.health > 0) { self.enemy = newt; @@ -549,7 +551,7 @@ void() bot_path = // linked doors fix if (trace_ent.owner) trace_ent = trace_ent.owner; - if ((trace_ent.health > 0) && (self.enemy == world)) + if ((trace_ent.health > 0) && (self.enemy == NIL)) { self.enemy = trace_ent; bot_weapon_switch(1); @@ -557,7 +559,7 @@ void() bot_path = } else if (trace_ent.targetname) { - tele = find(world, target, trace_ent.targetname); + tele = find(NIL, target, trace_ent.targetname); if (tele.health > 0) { self.enemy = tele; @@ -610,7 +612,7 @@ float(entity thing) priority_for_thing = thisp = 0; // This is the most executed function in the bot. Careful what you do here. - if ((thing.flags & FL_ITEM) && thing.model != string_null && thing.search_time < time) + if ((thing.flags & FL_ITEM) && thing.model && thing.search_time < time) { // ugly hack if (thing._last != self) @@ -722,7 +724,7 @@ float(entity thing) priority_for_thing = void(float scope) bot_look_for_crap = { - local entity foe, best = world; + local entity foe, best = NIL; local float thatp, bestp, dist; if (scope == 1) @@ -746,7 +748,7 @@ void(float scope) bot_look_for_crap = } foe = foe.chain; } - if (best == world) + if (best == NIL) return; if (!target_onstack(best)) { @@ -834,7 +836,7 @@ void() bot_angle_set = self.v_angle_x = self.v_angle_x - 360; } - else if ((self.enemy == world || self.enemy.movetype == MOVETYPE_PUSH) && self.target1.classname != "player") + else if ((self.enemy == NIL || self.enemy.movetype == MOVETYPE_PUSH) && self.target1.classname != "player") { self.keys = self.keys & 63; self.v_angle = self.b_angle; @@ -885,8 +887,8 @@ void() BotAI = self.keys = 0; self.b_aiflags = 0; ClearMyRoute(); - self.target1 = self.target2 = self.target3 = self.target4 = self.enemy = world; - self.last_way = world; + self.target1 = self.target2 = self.target3 = self.target4 = self.enemy = NIL; + self.last_way = NIL; return; } diff --git a/fbxa/bot_ed.qc b/fbxa/bot_ed.qc index 98d3d51..37a3f25 100644 --- a/fbxa/bot_ed.qc +++ b/fbxa/bot_ed.qc @@ -42,6 +42,8 @@ this notice in its entirety. */ +#include "libfrikbot.h" + float saved1, saved2, saved3, scratch1, scratch2, scratch3, scratch4; float bytecounter, filecount; @@ -339,7 +341,7 @@ void() bot_menu_display = if (self.impulse == 1) { if (self.current_way) - self.current_way.target1 = self.current_way.target2 = self.current_way.target3 = self.current_way.target4 = world; + self.current_way.target1 = self.current_way.target2 = self.current_way.target3 = self.current_way.target4 = NIL; } else if (self.impulse == 2) { @@ -554,7 +556,7 @@ void() bot_menu_display = { target_add(b_temp3); bot_get_path(b_temp3, TRUE); - self = world; + self = NIL; } else self = self._next; @@ -574,8 +576,8 @@ void() bot_menu_display = { if (!self.ishuman) { - self.target1 = self.target2 = self.target3 = self.target4 = world; - route_table = world; + self.target1 = self.target2 = self.target3 = self.target4 = NIL; + route_table = NIL; } self = self._next; } @@ -632,7 +634,7 @@ void() bot_menu_display = t = way_head; while(t) { - if ((t.target1 == world) && (t.target2 == world) && (t.target3 == world) && (t.target4 == world)) + if ((t.target1 == NIL) && (t.target2 == NIL) && (t.target3 == NIL) && (t.target4 == NIL)) { sprint(self, "Waypoint #"); h = ftos(t.count); @@ -1058,7 +1060,7 @@ void() PrintWaypoint = local float needcolon; local string h; - if (self.enemy == world) + if (self.enemy == NIL) t = way_head; else t = self.enemy._next; @@ -1073,10 +1075,10 @@ void() PrintWaypoint = bprint("\n// **** break here **** \n"); bytecounter = 26; } - if (t == world) + if (t == NIL) { remove(self); - fixer = world; + fixer = NIL; bprint("saved4 3\n// end waypoint dump\n"); bytecounter = bytecounter + 27; return; @@ -1208,7 +1210,7 @@ void() DumpWaypoints = fixer = spawn(); fixer.nextthink = time + 0.01; fixer.think = PrintWaypoint; - fixer.enemy = world; + fixer.enemy = NIL; } }; @@ -1217,15 +1219,15 @@ void() PrintQCWaypoint = local entity t; local string h; - if (self.enemy == world) + if (self.enemy == NIL) t = way_head; else t = self.enemy._next; - if (t == world) + if (t == NIL) { remove(self); - fixer = world; + fixer = NIL; bprint("};\n\n// End dump\n"); return; } @@ -1272,7 +1274,7 @@ void() QCDumpWaypoints = fixer = spawn(); fixer.nextthink = time + 0.01; fixer.think = PrintQCWaypoint; - fixer.enemy = world; + fixer.enemy = NIL; } }; @@ -1281,16 +1283,16 @@ void() PrintBSPWaypoint = local entity t; local string h; - if (self.enemy == world) + if (self.enemy == NIL) t = way_head; else t = self.enemy._next; - if (t == world) + if (t == NIL) { bprint("\n\n// End dump\n"); remove(self); - fixer = world; + fixer = NIL; return; } bprint("{\n\"classname\" \"waypoint\"\n\"origin\" \""); @@ -1349,6 +1351,6 @@ void() BSPDumpWaypoints = fixer = spawn(); fixer.nextthink = time + 0.01; fixer.think = PrintBSPWaypoint; - fixer.enemy = world; + fixer.enemy = NIL; } }; diff --git a/fbxa/bot_fight.qc b/fbxa/bot_fight.qc index c42b9ca..0bd9442 100644 --- a/fbxa/bot_fight.qc +++ b/fbxa/bot_fight.qc @@ -42,6 +42,8 @@ this notice in its entirety. */ +#include "libfrikbot.h" + .entity avoid; float(entity e) bot_size_player = @@ -83,7 +85,7 @@ void() bot_dodge_stuff = if (waypoint_mode > WM_LOADED) return; - self.avoid = world; + self.avoid = NIL; if (self.enemy) @@ -99,7 +101,7 @@ void() bot_dodge_stuff = } avdist = 256; - foe = find(world, classname, "grenade"); + foe = find(NIL, classname, "grenade"); while(foe) { flen = vlen(foe.origin - self.origin); @@ -112,7 +114,7 @@ void() bot_dodge_stuff = } if (!self.avoid) { - foe = find(world, classname, "missile"); + foe = find(NIL, classname, "missile"); while(foe) { if (foe.owner != self) @@ -128,7 +130,7 @@ void() bot_dodge_stuff = } if (!self.avoid) { - foe = find(world, classname, "spike"); + foe = find(NIL, classname, "spike"); while(foe) { if (foe.owner != self) @@ -358,17 +360,17 @@ void() bot_fight_style = if (self.enemy.health <= 0) { - self.enemy = world; + self.enemy = NIL; return; } else if (!self.enemy.takedamage) { - self.enemy = world; + self.enemy = NIL; return; } else if (!fisible(self.enemy)) { - self.enemy = world; + self.enemy = NIL; return; } diff --git a/fbxa/bot_misc.qc b/fbxa/bot_misc.qc index 1b21ddb..064c296 100644 --- a/fbxa/bot_misc.qc +++ b/fbxa/bot_misc.qc @@ -41,6 +41,8 @@ this notice in its entirety. */ +#include "libfrikbot.h" + /* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= @@ -163,8 +165,8 @@ string () PickARandomName = { test = ceil(random() * 16); h = BotName(test); - t = find(world, netname, h); - if (t == world) + t = find(NIL, netname, h); + if (t == NIL) y = FALSE; } return h; @@ -534,15 +536,15 @@ Kick A Bot. void() KickABot = { local entity ty; - ty = find(world, classname, "player"); - while (ty != world) + ty = find(NIL, classname, "player"); + while (ty != NIL) { if (!(ty.ishuman)) { BotDisconnect(ty); ty.ishuman = TRUE; - ty = world; + ty = NIL; } else ty = find(ty, classname, "player"); @@ -686,7 +688,7 @@ float (entity targ1, entity targ2) wisible = traceline (spot1, spot2, TRUE, ignore); spot1 = realorigin(trace_ent); ignore = trace_ent; - } while ((trace_ent != world) && (trace_fraction != 1)); + } while ((trace_ent != NIL) && (trace_fraction != 1)); if (trace_endpos == spot2) return TRUE; else diff --git a/fbxa/bot_move.qc b/fbxa/bot_move.qc index ff54a8a..6316081 100644 --- a/fbxa/bot_move.qc +++ b/fbxa/bot_move.qc @@ -42,6 +42,8 @@ this notice in its entirety. */ +#include "libfrikbot.h" + void() bot_jump = { // TODO check for precision, etc. @@ -82,7 +84,7 @@ float(float flag) frik_recognize_plat = if ((self.classname != "waypoint") && !(self.flags & FL_ONGROUND)) return FALSE; traceline(self.origin, self.origin - '0 0 64', TRUE, self); - if (trace_ent != world) + if (trace_ent != NIL) { if (flag) // afect bot movement too { @@ -412,7 +414,7 @@ void() frik_movetogoal = local vector way; local float g; - if (self.target1 == world) + if (self.target1 == NIL) { makevectors(self.v_angle); frik_walkmove(v_forward); diff --git a/fbxa/bot_phys.qc b/fbxa/bot_phys.qc index 1aded00..2c05c22 100644 --- a/fbxa/bot_phys.qc +++ b/fbxa/bot_phys.qc @@ -47,6 +47,8 @@ this notice in its entirety. */ +#include "libfrikbot.h" + /* ========================================= @@ -355,7 +357,7 @@ float() SV_RunThink = thinktime = time; self.nextthink = 0; time = thinktime; - other = world; + other = NIL; makevectors(self.v_angle); // hack self.think(); time = bkuptime; @@ -399,7 +401,7 @@ float() SV_CheckWater = void() RemoveThud = // well sometimes { local entity oself; - if (other == world) + if (other == NIL) { if (self.flags & FL_ONGROUND) { @@ -585,20 +587,20 @@ void() SV_FlyMove = { // This is nothing like the Quake function. - if (self.phys_obj == world) + if (self.phys_obj == NIL) { - self.phys_obj = find(world,classname,"phys_obj"); + self.phys_obj = find(NIL,classname,"phys_obj"); while (self.phys_obj.owner != self) { self.phys_obj = find(self.phys_obj,classname,"phys_obj"); - if (self.phys_obj == world) + if (self.phys_obj == NIL) { error("No physics entity spawned!\nMake sure BotInit was called\n"); } } } - setmodel (self.phys_obj, string_null); + setmodel (self.phys_obj, NIL); self.phys_obj.movetype = MOVETYPE_STEP; self.phys_obj.solid = SOLID_TRIGGER; diff --git a/fbxa/bot_qw.qc b/fbxa/bot_qw.qc index e2d6c6c..923ae02 100644 --- a/fbxa/bot_qw.qc +++ b/fbxa/bot_qw.qc @@ -93,6 +93,8 @@ ClientFixRankings(); // FrikBot -------------------------------------- */ +#include "libfrikbot.h" + void() bot_map_load = { // place your qc loaded waypoints here @@ -141,67 +143,6 @@ for all variable in the bot... .vector dyn_dest; .vector punchangle; // HACK - Don't want to screw with bot_phys -// --------defines----- -float SVC_UPDATENAME = 13; -float SVC_UPDATEFRAGS = 14; -float SVC_UPDATECOLORS = 17; - -// used for the physics & movement AI -float KEY_MOVEUP = 1; -float KEY_MOVEDOWN = 2; -float KEY_MOVELEFT = 4; -float KEY_MOVERIGHT = 8; -float KEY_MOVEFORWARD = 16; -float KEY_MOVEBACK = 32; -float KEY_LOOKUP = 64; -float KEY_LOOKDOWN = 128; -float KEY_LOOKLEFT = 256; -float KEY_LOOKRIGHT = 512; - -// these are aiflags for waypoints -// some overlap to the bot -float AI_TELELINK_1 = 1; // link type -float AI_TELELINK_2 = 2; // link type -float AI_TELELINK_3 = 4; // link type -float AI_TELELINK_4 = 8; // link type -float AI_DOORFLAG = 16; // read ahead -float AI_PRECISION = 32; // read ahead + point -float AI_SURFACE = 64; // point -float AI_BLIND = 128; // read ahead + point -float AI_JUMP = 256; // point + ignore -float AI_DIRECTIONAL = 512; // read ahead + ignore -float AI_PLAT_BOTTOM = 1024; // read ahead -float AI_RIDE_TRAIN = 2048; // read ahead -float AI_SUPER_JUMP = 4096; // point + ignore + route test -float AI_SNIPER = 8192; // point type -float AI_AMBUSH = 16384; // point type -float AI_DOOR_NO_OPEN = 32768; // read ahead -float AI_DIFFICULT = 65536; // route test -float AI_TRACE_TEST = 131072; // route test - -// these are flags for bots/players (dynamic/editor flags) -float AI_OBSTRUCTED = 1; -float AI_HOLD_SELECT = 2; -float AI_ROUTE_FAILED = 2; -float AI_WAIT = 4; -float AI_DANGER = 8; - -// addition masks -float AI_POINT_TYPES = 29152; -float AI_READAHEAD_TYPES = 36528; -float AI_IGNORE_TYPES = 4864; - -float WM_UNINIT = 0; -float WM_DYNAMIC = 1; -float WM_LOADING = 2; -float 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 -float WM_EDITOR = 4; -float WM_EDITOR_DYNAMIC = 5; -float WM_EDITOR_DYNLINK = 6; - -float OPT_NOCHAT = 2; // -------globals----- float active_clients1, active_clients2; @@ -219,63 +160,6 @@ float busy_waypoints; float coop = 0; // hack -// -------ProtoTypes------ -// external -void() ClientConnect; -void() ClientDisconnect; -void() SetNewParms; - -// rankings -float(float clientno) ClientBitFlag; -float() ClientNextAvailable; -void(float whatbot, float whatskill) BotConnect; -void(entity bot) BotDisconnect; -void(float clientno) BotInvalidClientNo; -void(entity who) UpdateClient; - -// waypointing -void() DynamicWaypoint; -entity(vector org) make_waypoint; -void() ClearAllWays; -void() FixWaypoints; -float() begin_route; -void(entity this, float direct) bot_get_path; -void() WaypointThink; -entity(entity start) FindWayPoint; - -// physics & movement -float(entity e) bot_can_rj; -void() bot_jump; -void() frik_bot_roam; -float(vector weird) frik_walkmove; -void() frik_movetogoal; -void() frik_obstacles; -float(float flag) frik_recognize_plat; -float(vector sdir) frik_KeysForDir; -void(vector whichway, float danger) frik_obstructed; -void() SV_Physics_Client; -void() SV_ClientThink; -void() CL_KeyMove; - -// ai & misc -string() PickARandomName; -float(entity targ) fov; -float(float y1, float y2) angcomp; -float(entity targ1, entity targ2) wisible; -float(entity targ) sisible; -float(entity targ) fisible; -vector(entity ent) realorigin; -void(entity ent) target_drop; -void(entity ent) target_add; -void() KickABot; -void() BotImpulses; -void(entity targ, float success) bot_lost; -string(float r) BotName; -float(float v) frik_anglemod; -void() bot_chat; -void(float tpic) bot_start_topic; - - // ----------Commands--------- void(entity e, float chan, string samp, float vol, float atten) frik_sound = #8; void(entity client, string s) frik_stuffcmd = #21; @@ -432,7 +316,7 @@ void() ClientFixRankings = return; self.switch_wallhug = 0; - b_temp2 = nextent(world); + b_temp2 = nextent(NIL); cno = 0; while (cno < max_clients) @@ -462,7 +346,7 @@ void() ClientInRankings = while (e) { if (e._next == self) { self._last = e; - e = world; + e = NIL; } else { e = e._next; } @@ -473,7 +357,7 @@ void() ClientInRankings = while (e) { if (e._last == self) { self._next = e; - e = world; + e = NIL; } else { e = e._last; } @@ -488,7 +372,7 @@ void() ClientInRankings = self._next._last = self._last; else if (self._last) player_tail = self._last; - self._last = self._next = world; + self._last = self._next = NIL; } if (player_head) player_head._last = self; @@ -502,7 +386,7 @@ void() ClientInRankings = if (!self.phys_obj) { b_temp2 = phys_head; - while (b_temp2 != world && b_temp2.owner != self) + while (b_temp2 != NIL && b_temp2.owner != self) b_temp2 = b_temp2._next; self.phys_obj = b_temp2; } @@ -637,17 +521,17 @@ void() BotInit = local float numents = 0; // spawn entities for the physics - ent = nextent(world); + ent = nextent(NIL); max_clients = 0; - while(ent != world) + while(ent != NIL) { max_clients = max_clients + 1; ent = nextent(ent); } - ent = nextent(world); - fisent = world; + ent = nextent(NIL); + fisent = NIL; while (numents < max_clients) { @@ -798,7 +682,7 @@ BotConnect and related functions. entity(float num) GetClientEntity = { local entity upsy; - upsy = world; + upsy = NIL; num = num + 1; while (num > 0) { @@ -920,7 +804,7 @@ void() BotFrame = local float num; local string h; - h = infokey(world, "bot_options"); + h = infokey(NIL, "bot_options"); b_options = stof(h); // for the sake of speed @@ -932,7 +816,7 @@ void() BotFrame = real_frametime = time - lasttime; // in QW frametime is fuxx0red lasttime = time; - self = nextent(world); + self = nextent(NIL); num = 0; while (num < max_clients) { @@ -980,7 +864,7 @@ void() BotImpulses = if (self.impulse == 100) { - h = infokey(world, "skill"); + h = infokey(NIL, "skill"); f = stof(h); BotConnect(0, f); } diff --git a/fbxa/bot_way.qc b/fbxa/bot_way.qc index 26e091f..060e321 100644 --- a/fbxa/bot_way.qc +++ b/fbxa/bot_way.qc @@ -42,6 +42,8 @@ this notice in its entirety. */ +#include "libfrikbot.h" + /* @@ -55,7 +57,7 @@ Waypoint Linking code float (entity e1, entity e2) CheckLinked = { - if ((e1 == e2) || (e2 == world) || (e1 == world)) + if ((e1 == e2) || (e2 == NIL) || (e1 == NIL)) return FALSE; else if (e1.target1 == e2) { @@ -88,27 +90,27 @@ float (entity e1, entity e2) CheckLinked = float (entity e1, entity e2) LinkWays = { - if ((e1 == e2) || (e2 == world) || (e1 == world)) + if ((e1 == e2) || (e2 == NIL) || (e1 == NIL)) return FALSE; else if (CheckLinked(e1, e2)) return FALSE; // already linked!!! - if (e1.target1 == world) + if (e1.target1 == NIL) { e1.target1 = e2; return TRUE; } - else if (e1.target2 == world) + else if (e1.target2 == NIL) { e1.target2 = e2; return TRUE; } - else if (e1.target3 == world) + else if (e1.target3 == NIL) { e1.target3 = e2; return TRUE; } - else if (e1.target4 == world) + else if (e1.target4 == NIL) { e1.target4 = e2; return TRUE; @@ -120,30 +122,30 @@ float (entity e1, entity e2) LinkWays = float (entity e1, entity e2) TeleLinkWays = { - if ((e1 == e2) || (e2 == world) || (e1 == world)) + if ((e1 == e2) || (e2 == NIL) || (e1 == NIL)) return FALSE; else if (CheckLinked(e1, e2)) return FALSE; // already linked!!! - if (e1.target1 == world) + if (e1.target1 == NIL) { e1.target1 = e2; e1.b_aiflags = e1.b_aiflags | AI_TELELINK_1; return TRUE; } - else if (e1.target2 == world) + else if (e1.target2 == NIL) { e1.target2 = e2; e1.b_aiflags = e1.b_aiflags | AI_TELELINK_2; return TRUE; } - else if (e1.target3 == world) + else if (e1.target3 == NIL) { e1.target3 = e2; e1.b_aiflags = e1.b_aiflags | AI_TELELINK_3; return TRUE; } - else if (e1.target4 == world) + else if (e1.target4 == NIL) { e1.target4 = e2; e1.b_aiflags = e1.b_aiflags | AI_TELELINK_4; @@ -156,7 +158,7 @@ float (entity e1, entity e2) TeleLinkWays = void (entity e1, entity e2) UnlinkWays = { - if ((e1 == e2) || (e2 == world) || (e1 == world)) + if ((e1 == e2) || (e2 == NIL) || (e1 == NIL)) return; else if (!CheckLinked(e1, e2)) return; @@ -164,22 +166,22 @@ void (entity e1, entity e2) UnlinkWays = if (e1.target1 == e2) { e1.b_aiflags = e1.b_aiflags - (e1.b_aiflags & AI_TELELINK_1); - e1.target1 = world; + e1.target1 = NIL; } if (e1.target2 == e2) { e1.b_aiflags = e1.b_aiflags - (e1.b_aiflags & AI_TELELINK_2); - e1.target2 = world; + e1.target2 = NIL; } if (e1.target3 == e2) { e1.b_aiflags = e1.b_aiflags - (e1.b_aiflags & AI_TELELINK_3); - e1.target3 = world; + e1.target3 = NIL; } if (e1.target4 == e2) { e1.b_aiflags = e1.b_aiflags - (e1.b_aiflags & AI_TELELINK_4); - e1.target4 = world; + e1.target4 = NIL; } }; @@ -207,7 +209,7 @@ entity(entity start) FindWayPoint = org = realorigin(self); t = way_head; - if (start != world) + if (start != NIL) { dst = vlen(start.origin - org); best = start; @@ -215,7 +217,7 @@ entity(entity start) FindWayPoint = else { dst = 100000; - best = world; + best = NIL; } while(t) { @@ -302,7 +304,7 @@ void() DynamicWaypoint = if (!self.ishuman) { bot_lost(self.target1, TRUE); - self.enemy = world; + self.enemy = NIL; } } self.portal_time = self.teleport_time; @@ -357,7 +359,7 @@ void() DynamicWaypoint = } } self.dyn_dest = '0 0 0'; - self.current_way = world; + self.current_way = NIL; self.dyn_flags = 0; return; } @@ -507,8 +509,8 @@ void() ClearAllWays = remove(t); t = n; } - way_head = world; - way_foot = world; + way_head = NIL; + way_foot = NIL; waypoints = 0; }; @@ -516,7 +518,7 @@ entity(float num) WaypointForNum = { local entity t; if (!num) - return world; + return NIL; t = way_head; while (t) @@ -525,7 +527,7 @@ entity(float num) WaypointForNum = return t; t = t._next; } - return world; + return NIL; }; void() FixThisWaypoint = @@ -536,10 +538,10 @@ void() FixThisWaypoint = self.enemy.target4 = WaypointForNum(self.enemy.b_frags); self.enemy = self.enemy._next; self.nextthink = time; - if (self.enemy == world) + if (self.enemy == NIL) { remove(self); - fixer = world; + fixer = NIL; } }; @@ -576,7 +578,7 @@ void(entity what) delete_waypoint = t = t._next; } if (self.current_way == what) - self.current_way = world; + self.current_way = NIL; remove(what); }; @@ -596,9 +598,9 @@ entity(string s) FindThing = local float tdst, dst; local entity best; dst = 100000; - best = world; - t = find (world, classname, s); - while (t != world) + best = NIL; + t = find (NIL, classname, s); + while (t != NIL) { tdst = vlen(((t.absmin + t.absmax) * 0.5) - self.origin); if (tdst < dst) @@ -632,13 +634,13 @@ entity(entity lastone) FindRoute = flag = ClientBitFlag(self.b_clientno); t = way_head; dst = 100000; - best = world; + best = NIL; while(t) { tdst = vlen(t.origin - self.origin); if ((tdst < dst) && (t.b_sound & flag)) { - if ((lastone == world) || (CheckLinked(lastone, t))) + if ((lastone == NIL) || (CheckLinked(lastone, t))) { dst = tdst; best = t; @@ -665,7 +667,7 @@ void() ClearRouteTable = while (t) { t. keys = FALSE; - t.enemy = world; + t.enemy = NIL; t.items = -1; // not in table t = t._next; } @@ -716,7 +718,7 @@ void(entity this) mark_path = if (this.classname != "player") this.current_way = t; - if (t.enemy == world) + if (t.enemy == NIL) { bot_lost(this, FALSE); if (waypoint_mode == WM_DYNAMIC) @@ -864,7 +866,7 @@ float() begin_route = if (busy_waypoints > 0) return FALSE; - if (route_table != world) + if (route_table != NIL) { if (!route_table.ishuman) { @@ -877,7 +879,7 @@ float() begin_route = ClearRouteTable(); self.last_way = FindWayPoint(self.current_way); - if (self.last_way != world) + if (self.last_way != NIL) { self.last_way.items = vlen(self.last_way.origin - self.origin); self.last_way.nextthink = time; @@ -888,7 +890,7 @@ float() begin_route = } else { - route_table = world; + route_table = NIL; busy_waypoints = 0; return FALSE; } @@ -896,14 +898,14 @@ float() begin_route = void(entity this, float direct) bot_get_path = { - if (this == world) + if (this == NIL) return; if (route_table == self) { if (busy_waypoints <= 0) { - route_table = world; + route_table = NIL; mark_path(this); } return; diff --git a/fbxa/defs.h b/fbxa/defs.h new file mode 100644 index 0000000..ee5ee3d --- /dev/null +++ b/fbxa/defs.h @@ -0,0 +1,725 @@ + +/* +============================================================================== + + SOURCE FOR GLOBALVARS_T C STRUCTURE + +============================================================================== +*/ + +// +// system globals +// +@extern entity self; +@extern entity other; +@extern entity world; +@extern float time; +@extern float frametime; + +@extern entity newmis; // if this is set, the entity that just + // run created a new missile that should + // be simulated immediately + + +@extern float force_retouch; // force all entities to touch triggers + // next frame. this is needed because + // non-moving things don't normally scan + // for triggers, and when a trigger is + // created (like a teleport trigger), it + // needs to catch everything. + // decremented each frame, so set to 2 + // to guarantee everything is touched +@extern string mapname; + +@extern float serverflags; // propagated from level to level, used to + // keep track of completed episodes + +@extern float total_secrets; +@extern float total_monsters; + +@extern float found_secrets; // number of secrets found +@extern float killed_monsters; // number of monsters killed + + +// spawnparms are used to encode information about clients across server +// level changes +@extern float parm1, parm2, parm3, parm4, parm5, parm6, parm7, parm8, parm9, parm10, parm11, parm12, parm13, parm14, parm15, parm16; + +// +// global variables set by built in functions +// +@extern vector v_forward, v_up, v_right; // set by makevectors() + +// set by traceline / tracebox +@extern float trace_allsolid; +@extern float trace_startsolid; +@extern float trace_fraction; +@extern vector trace_endpos; +@extern vector trace_plane_normal; +@extern float trace_plane_dist; +@extern entity trace_ent; +@extern float trace_inopen; +@extern float trace_inwater; + +@extern entity msg_entity; // destination of single entity writes + +// +// required prog functions +// +@extern void() main; // only for testing + +@extern void() StartFrame; + +@extern void() PlayerPreThink; +@extern void() PlayerPostThink; + +@extern void() ClientKill; +@extern void() ClientConnect; +@extern void() PutClientInServer; // call after setting the parm1... parms +@extern void() ClientDisconnect; + +@extern void() SetNewParms; // called when a client first connects to + // a server. sets parms so they can be + // saved off for restarts + +@extern void() SetChangeParms; // call to set parms for self so they can + // be saved for a level transition + + +//================================================ +@extern void end_sys_globals; // flag for structure dumping +//================================================ + +/* +============================================================================== + + SOURCE FOR ENTVARS_T C STRUCTURE + +============================================================================== +*/ + +// +// system fields (*** = do not set in prog code, maintained by C code) +// +@extern .float modelindex; // *** model index in the precached list +@extern .vector absmin, absmax; // *** origin + mins / maxs + +@extern .float ltime; // local time for entity +@extern .float lastruntime; // *** to allow entities to run out of sequence + +@extern .float movetype; +@extern .float solid; + +@extern .vector origin; // *** +@extern .vector oldorigin; // *** +@extern .vector velocity; +@extern .vector angles; +@extern .vector avelocity; + +@extern .string classname; // spawn function +@extern .string model; +@extern .float frame; +@extern .float skin; +@extern .float effects; + +@extern .vector mins, maxs; // bounding box extents reletive to origin +@extern .vector size; // maxs - mins + +@extern .void() touch; +@extern .void() use; +@extern .void() think; +@extern .void() blocked; // for doors or plats, called when can't push other + +@extern .float nextthink; +@extern .entity groundentity; + + + +// stats +@extern .float health; +@extern .float frags; +@extern .float weapon; // one of the IT_SHOTGUN, etc flags +@extern .string weaponmodel; +@extern .float weaponframe; +@extern .float currentammo; +@extern .float ammo_shells, ammo_nails, ammo_rockets, ammo_cells; + +@extern .float items; // bit flags + +@extern .float takedamage; +@extern .entity chain; +@extern .float deadflag; + +@extern .vector view_ofs; // add to origin to get eye point + + +@extern .float button0; // fire +@extern .float button1; // use +@extern .float button2; // jump + +@extern .float impulse; // weapon changes + +@extern .float fixangle; +@extern .vector v_angle; // view / targeting angle for players + +@extern .string netname; + +@extern .entity enemy; + +@extern .float flags; + +@extern .float colormap; +@extern .float team; + +@extern .float max_health; // players maximum health is stored here + +@extern .float teleport_time; // don't back up + +@extern .float armortype; // save this fraction of incoming damage +@extern .float armorvalue; + +@extern .float waterlevel; // 0 = not in, 1 = feet, 2 = wast, 3 = eyes +@extern .float watertype; // a contents value + +@extern .float ideal_yaw; +@extern .float yaw_speed; + +@extern .entity aiment; + +@extern .entity goalentity; // a movetarget or an enemy + +@extern .float spawnflags; + +@extern .string target; +@extern .string targetname; + +// damage is accumulated through a frame. and sent as one single +// message, so the super shotgun doesn't generate huge messages +@extern .float dmg_take; +@extern .float dmg_save; +@extern .entity dmg_inflictor; + +@extern .entity owner; // who launched a missile +@extern .vector movedir; // mostly for doors, but also used for waterjump + +@extern .string message; // trigger messages + +@extern .float sounds; // either a cd track number or sound number + +@extern .string noise, noise1, noise2, noise3; // contains names of wavs to play + +//================================================ +@extern void end_sys_fields; // flag for structure dumping +//================================================ + +/* +============================================================================== + + VARS NOT REFERENCED BY C CODE + +============================================================================== +*/ + + +// +// constants +// + +// edict.flags +@extern float FL_FLY; +@extern float FL_SWIM; +@extern float FL_CLIENT; // set for all client edicts +@extern float FL_INWATER; // for enter / leave water splash +@extern float FL_MONSTER; +@extern float FL_GODMODE; // player cheat +@extern float FL_NOTARGET; // player cheat +@extern float FL_ITEM; // extra wide size for bonus items +@extern float FL_ONGROUND; // standing on something +@extern float FL_PARTIALGROUND; // not all corners are valid +@extern float FL_WATERJUMP; // player jumping out of water +@extern float FL_JUMPRELEASED; // for jump debouncing + +// edict.movetype values +@extern float MOVETYPE_NONE; // never moves +//float MOVETYPE_ANGLENOCLIP; +//float MOVETYPE_ANGLECLIP; +@extern float MOVETYPE_WALK; // players only +@extern float MOVETYPE_STEP; // discrete, not real time unless fall +@extern float MOVETYPE_FLY; +@extern float MOVETYPE_TOSS; // gravity +@extern float MOVETYPE_PUSH; // no clip to world, push and crush +@extern float MOVETYPE_NOCLIP; +@extern float MOVETYPE_FLYMISSILE; // fly with extra size against monsters +@extern float MOVETYPE_BOUNCE; +@extern float MOVETYPE_BOUNCEMISSILE; // bounce with extra size + +// edict.solid values +@extern float SOLID_NOT; // no interaction with other objects +@extern float SOLID_TRIGGER; // touch on edge, but not blocking +@extern float SOLID_BBOX; // touch on edge, block +@extern float SOLID_SLIDEBOX; // touch on edge, but not an onground +@extern float SOLID_BSP; // bsp clip, touch on edge, block + +// range values +@extern float RANGE_MELEE; +@extern float RANGE_NEAR; +@extern float RANGE_MID; +@extern float RANGE_FAR; + +// deadflag values + +@extern float DEAD_NO; +@extern float DEAD_DYING; +@extern float DEAD_DEAD; +@extern float DEAD_RESPAWNABLE; + +// takedamage values + +@extern float DAMAGE_NO; +@extern float DAMAGE_YES; +@extern float DAMAGE_AIM; + +// items +@extern float IT_AXE; +@extern float IT_SHOTGUN; +@extern float IT_SUPER_SHOTGUN; +@extern float IT_NAILGUN; +@extern float IT_SUPER_NAILGUN; +@extern float IT_GRENADE_LAUNCHER; +@extern float IT_ROCKET_LAUNCHER; +@extern float IT_LIGHTNING; +@extern float IT_EXTRA_WEAPON; + +@extern float IT_SHELLS; +@extern float IT_NAILS; +@extern float IT_ROCKETS; +@extern float IT_CELLS; + +@extern float IT_ARMOR1; +@extern float IT_ARMOR2; +@extern float IT_ARMOR3; +@extern float IT_SUPERHEALTH; + +@extern float IT_KEY1; +@extern float IT_KEY2; + +@extern float IT_INVISIBILITY; +@extern float IT_INVULNERABILITY; +@extern float IT_SUIT; +@extern float IT_QUAD; + +// point content values + +@extern float CONTENT_EMPTY; +@extern float CONTENT_SOLID; +@extern float CONTENT_WATER; +@extern float CONTENT_SLIME; +@extern float CONTENT_LAVA; +@extern float CONTENT_SKY; + +@extern float STATE_TOP; +@extern float STATE_BOTTOM; +@extern float STATE_UP; +@extern float STATE_DOWN; + +@extern vector VEC_ORIGIN; +@extern vector VEC_HULL_MIN; +@extern vector VEC_HULL_MAX; + +@extern vector VEC_HULL2_MIN; +@extern vector VEC_HULL2_MAX; + +// protocol bytes +@extern float SVC_TEMPENTITY; +@extern float SVC_KILLEDMONSTER; +@extern float SVC_FOUNDSECRET; +@extern float SVC_INTERMISSION; +@extern float SVC_FINALE; +@extern float SVC_CDTRACK; +@extern float SVC_SELLSCREEN; +@extern float SVC_SMALLKICK; +@extern float SVC_BIGKICK; +@extern float SVC_MUZZLEFLASH; + + +@extern float TE_SPIKE; +@extern float TE_SUPERSPIKE; +@extern float TE_GUNSHOT; +@extern float TE_EXPLOSION; +@extern float TE_TAREXPLOSION; +@extern float TE_LIGHTNING1; +@extern float TE_LIGHTNING2; +@extern float TE_WIZSPIKE; +@extern float TE_KNIGHTSPIKE; +@extern float TE_LIGHTNING3; +@extern float TE_LAVASPLASH; +@extern float TE_TELEPORT; +@extern float TE_BLOOD; +@extern float TE_LIGHTNINGBLOOD; + +// sound channels +// channel 0 never willingly overrides +// other channels (1-7) allways override a playing sound on that channel +@extern float CHAN_AUTO; +@extern float CHAN_WEAPON; +@extern float CHAN_VOICE; +@extern float CHAN_ITEM; +@extern float CHAN_BODY; +@extern float CHAN_NO_PHS_ADD; // ie: CHAN_BODY+CHAN_NO_PHS_ADD + +@extern float ATTN_NONE; +@extern float ATTN_NORM; +@extern float ATTN_IDLE; +@extern float ATTN_STATIC; + +// update types + +@extern float UPDATE_GENERAL; +@extern float UPDATE_STATIC; +@extern float UPDATE_BINARY; +@extern float UPDATE_TEMP; + +// entity effects + +//float EF_BRIGHTFIELD; +//float EF_MUZZLEFLASH; +@extern float EF_BRIGHTLIGHT; +@extern float EF_DIMLIGHT; +@extern float EF_FLAG1; +@extern float EF_FLAG2; +// GLQuakeWorld Stuff +@extern float EF_BLUE; // Blue Globe effect for Quad +@extern float EF_RED; // Red Globe effect for Pentagram +// messages +@extern float MSG_BROADCAST; // unreliable to all +@extern float MSG_ONE; // reliable to one (msg_entity) +@extern float MSG_ALL; // reliable to all +@extern float MSG_INIT; // write to the init string +@extern float MSG_MULTICAST; // for multicast() call + +// message levels +@extern float PRINT_LOW; // pickup messages +@extern float PRINT_MEDIUM; // death messages +@extern float PRINT_HIGH; // critical messages +@extern float PRINT_CHAT; // also goes to chat console + +// multicast sets +@extern float MULTICAST_ALL; // every client +@extern float MULTICAST_PHS; // within hearing +@extern float MULTICAST_PVS; // within sight +@extern float MULTICAST_ALL_R; // every client, reliable +@extern float MULTICAST_PHS_R; // within hearing, reliable +@extern float MULTICAST_PVS_R; // within sight, reliable + + + + +//================================================ + +// +// globals +// +@extern float movedist; + +@extern string string_null; // null string, nothing should be held here +@extern float empty_float; + +@extern entity activator; // the entity that activated a trigger or brush + +@extern entity damage_attacker; // set by T_Damage +@extern entity damage_inflictor; +@extern float framecount; + +// +// cvars checked each frame +// +@extern float teamplay; +@extern float timelimit; +@extern float fraglimit; +@extern float deathmatch; +@extern float rj; + +//================================================ + +// +// world fields (FIXME: make globals) +// +@extern .string wad; +@extern .string map; +@extern .float worldtype; // 0=medieval 1=metal 2=base + +//================================================ + +@extern .string killtarget; + +// +// quakeed fields +// +@extern .float light_lev; // not used by game, but parsed by light util +@extern .float style; + + +// +// monster ai +// +@extern .void() th_stand; +@extern .void() th_walk; +@extern .void() th_run; +@extern .void() th_missile; +@extern .void() th_melee; +@extern .void(entity attacker, float damage) th_pain; +@extern .void() th_die; + +@extern .entity oldenemy; // mad at this player before taking damage + +@extern .float speed; + +@extern .float lefty; + +@extern .float search_time; +@extern .float attack_state; + +@extern float AS_STRAIGHT; +@extern float AS_SLIDING; +@extern float AS_MELEE; +@extern float AS_MISSILE; + +// +// player only fields +// +@extern .float voided; +@extern .float walkframe; + +// Zoid Additions +@extern .float maxspeed; // Used to set Maxspeed on a player +@extern .float gravity; // Gravity Multiplier (0 to 1.0) + + + +@extern .float attack_finished; +@extern .float pain_finished; + +@extern .float invincible_finished; +@extern .float invisible_finished; +@extern .float super_damage_finished; +@extern .float radsuit_finished; + +@extern .float invincible_time, invincible_sound; +@extern .float invisible_time, invisible_sound; +@extern .float super_time, super_sound; +@extern .float rad_time; +@extern .float fly_sound; + +@extern .float axhitme; + +@extern .float show_hostile; // set to time+0.2 whenever a client fires a + // weapon or takes damage. Used to alert + // monsters that otherwise would let the player go +@extern .float jump_flag; // player jump flag +@extern .float swim_flag; // player swimming sound flag +@extern .float air_finished; // when time > air_finished, start drowning +@extern .float bubble_count; // keeps track of the number of bubbles +@extern .string deathtype; // keeps track of how the player died + +// +// object stuff +// +@extern .string mdl; +@extern .vector mangle; // angle at start + +@extern .vector oldorigin; // only used by secret door + +@extern .float t_length, t_width; + + +// +// doors, etc +// +@extern .vector dest, dest1, dest2; +@extern .float wait; // time from firing to restarting +@extern .float delay; // time from activation to firing +@extern .entity trigger_field; // door's trigger entity +@extern .string noise4; + +// +// monsters +// +@extern .float pausetime; +@extern .entity movetarget; + + +// +// doors +// +@extern .float aflag; +@extern .float dmg; // damage done by door when hit + +// +// misc +// +@extern .float cnt; // misc flag + +// +// subs +// +@extern .void() think1; +@extern .vector finaldest, finalangle; + +// +// triggers +// +@extern .float count; // for counting triggers + + +// +// plats / doors / buttons +// +@extern .float lip; +@extern .float state; +@extern .vector pos1, pos2; // top and bottom positions +@extern .float height; + +// +// sounds +// +@extern .float waitmin, waitmax; +@extern .float distance; +@extern .float volume; + + + + +//=========================================================================== + + +// +// builtin functions +// + +@extern void(vector ang) makevectors; // sets v_forward, etc globals +@extern void(entity e, vector o) setorigin; +@extern void(entity e, string m) setmodel; // set movetype and solid first +@extern void(entity e, vector min, vector max) setsize; +// #5 was removed +//void() break; +@extern float() random; // returns 0 - 1 +@extern void(entity e, float chan, string samp, float vol, float atten) sound; +@extern vector(vector v) normalize; +@extern void(string e) error; +@extern void(string e) objerror; +@extern float(vector v) vlen; +@extern float(vector v) vectoyaw; +@extern entity() spawn; +@extern void(entity e) remove; + +// sets trace_* globals +// nomonsters can be: +// An entity will also be ignored for testing if forent == test, +// forent->owner == test, or test->owner == forent +// a forent of world is ignored +@extern void(vector v1, vector v2, float nomonsters, entity forent) traceline; + +@extern entity() checkclient; // returns a client to look for +@extern entity(entity start, .string fld, string match) find; +@extern string(string s) precache_sound; +@extern string(string s) precache_model; +@extern void(entity client, string s)stuffcmd; +@extern entity(vector org, float rad) findradius; +@extern void(float level, string s) bprint; +@extern void(entity client, float level, string s) sprint; +@extern void(string s) dprint; +@extern string(float f) ftos; +@extern string(vector v) vtos; +@extern void() coredump; // prints all edicts +@extern void() traceon; // turns statment trace on +@extern void() traceoff; +@extern void(entity e) eprint; // prints an entire edict +@extern float(float yaw, float dist) walkmove; // returns TRUE or FALSE +// #33 was removed +@extern float() droptofloor; // TRUE if landed on floor +@extern void(float style, string value) lightstyle; +@extern float(float v) rint; // round to nearest int +@extern float(float v) floor; // largest integer <= v +@extern float(float v) ceil; // smallest integer >= v +// #39 was removed +@extern float(entity e) checkbottom; // true if self is on ground +@extern float(vector v) pointcontents; // returns a CONTENT_* +// #42 was removed +@extern float(float f) fabs; +@extern vector(entity e, float speed) aim; // returns the shooting vector +@extern float(string s) cvar; // return cvar.value +@extern void(string s) localcmd; // put string into local que +@extern entity(entity e) nextent; // for looping through all ents +// #48 was removed +@extern void() ChangeYaw; // turn towards self.ideal_yaw + // at self.yaw_speed +// #50 was removed +@extern vector(vector v) vectoangles; + +// +// direct client message generation +// +@extern void(float to, float f) WriteByte; +@extern void(float to, float f) WriteChar; +@extern void(float to, float f) WriteShort; +@extern void(float to, float f) WriteLong; +@extern void(float to, float f) WriteCoord; +@extern void(float to, float f) WriteAngle; +@extern void(float to, string s) WriteString; +@extern void(float to, entity s) WriteEntity; + +// several removed + +@extern void(float step) movetogoal; + +@extern string(string s) precache_file; // no effect except for -copy +@extern void(entity e) makestatic; +@extern void(string s) changelevel; + +//#71 was removed + +@extern void(string var, string val) cvar_set; // sets cvar.value + +@extern void(entity client, string s) centerprint; // sprint, but in middle + +@extern void(vector pos, string samp, float vol, float atten) ambientsound; + +@extern string(string s) precache_model2; // registered version only +@extern string(string s) precache_sound2; // registered version only +@extern string(string s) precache_file2; // registered version only + +@extern void(entity e) setspawnparms; // set parm1... to the + // values at level start + // for coop respawn +@extern void(entity killer, entity killee) logfrag; // add to stats + +@extern string(entity e, string key) infokey; // get a key value (world = serverinfo) +@extern float(string s) stof; // convert string to float +@extern void(vector where, float set) multicast; // sends the temp message to a set + // of clients, possibly in PVS or PHS + +//============================================================================ + +// +// subs.qc +// +@extern void(vector tdest, float tspeed, void() func) SUB_CalcMove; +@extern void(entity ent, vector tdest, float tspeed, void() func) SUB_CalcMoveEnt; +@extern void(vector destangle, float tspeed, void() func) SUB_CalcAngleMove; +@extern void() SUB_CalcMoveDone; +@extern void() SUB_CalcAngleMoveDone; +@extern void() SUB_Null; +@extern void() SUB_UseTargets; +@extern void() SUB_Remove; + +// +// combat.qc +// +@extern void(entity targ, entity inflictor, entity attacker, float damage) T_Damage; + + +@extern float (entity e, float healamount, float ignore) T_Heal; // health function + +@extern float(entity targ, entity inflictor) CanDamage; + + diff --git a/fbxa/frikbot.h b/fbxa/frikbot.h new file mode 100644 index 0000000..cec48dd --- /dev/null +++ b/fbxa/frikbot.h @@ -0,0 +1,22 @@ +@extern void() BotInit; +@extern void() BotFrame; +@extern float () BotPreFrame; +@extern float () BotPostFrame; +@extern void() ClientInRankings; +@extern void() ClientDisconnected; +@extern void() ClientFixRankings; + +@extern void(entity client, string s) stuffcmd; +@extern void(entity e) setspawnparms; +@extern void(entity client, float level, string s) sprint; +@extern void(entity client, string s) centerprint; +@extern vector(entity e, float sped) aim; +@extern void(entity e, float chan, string samp, float vol, float atten) sound; +@extern void(float to, float f) WriteByte; +@extern void(float to, float f) WriteChar; +@extern void(float to, float f) WriteShort; +@extern void(float to, float f) WriteLong; +@extern void(float to, float f) WriteCoord; +@extern void(float to, float f) WriteAngle; +@extern void(float to, string s) WriteString; +@extern void(float to, entity s) WriteEntity; diff --git a/fbxa/libfrikbot.h b/fbxa/libfrikbot.h new file mode 100644 index 0000000..d62b7a4 --- /dev/null +++ b/fbxa/libfrikbot.h @@ -0,0 +1,182 @@ +#define FALSE 0 +#define TRUE 1 + +// ----- entity fields --- +@extern .float wallhug, keys, oldkeys, ishuman; +@extern .float b_frags, b_clientno, b_shirt, b_pants; +@extern .float priority, ai_time, b_sound, missile_speed; +@extern .float portal_time, b_skill, switch_wallhug; +@extern .float b_aiflags, b_num, b_chattime; +@extern .float b_entertime, b_userid; // QW shtuff +@extern .float b_menu, b_menu_time, b_menu_value; +@extern .float route_failed, dyn_flags, dyn_time; +@extern .float dyn_plat; +@extern .entity temp_way, last_way, phys_obj; +@extern .entity target1, target2, target3, target4; +@extern .entity _next, _last; +@extern .entity current_way; +@extern .vector b_angle, b_dest, mouse_emu, obs_dir; +@extern .vector movevect, b_dir; +@extern .vector dyn_dest; +@extern .vector punchangle; // HACK - Don't want to screw with bot_phys + +// --------defines----- +#define SVC_UPDATENAME 13 +#define SVC_UPDATEFRAGS 14 +#define SVC_UPDATECOLORS 17 + +// used for the physics & movement AI +#define KEY_MOVEUP 1 +#define KEY_MOVEDOWN 2 +#define KEY_MOVELEFT 4 +#define KEY_MOVERIGHT 8 +#define KEY_MOVEFORWARD 16 +#define KEY_MOVEBACK 32 +#define KEY_LOOKUP 64 +#define KEY_LOOKDOWN 128 +#define KEY_LOOKLEFT 256 +#define KEY_LOOKRIGHT 512 + +// these are aiflags for waypoints +// some overlap to the bot +#define AI_TELELINK_1 1 // link type +#define AI_TELELINK_2 2 // link type +#define AI_TELELINK_3 4 // link type +#define AI_TELELINK_4 8 // link type +#define AI_DOORFLAG 16 // read ahead +#define AI_PRECISION 32 // read ahead + point +#define AI_SURFACE 64 // point +#define AI_BLIND 128 // read ahead + point +#define AI_JUMP 256 // point + ignore +#define AI_DIRECTIONAL 512 // read ahead + ignore +#define AI_PLAT_BOTTOM 1024 // read ahead +#define AI_RIDE_TRAIN 2048 // read ahead +#define AI_SUPER_JUMP 4096 // point + ignore + route test +#define AI_SNIPER 8192 // point type +#define AI_AMBUSH 16384 // point type +#define AI_DOOR_NO_OPEN 32768 // read ahead +#define AI_DIFFICULT 65536 // route test +#define AI_TRACE_TEST 131072 // route test + +// these are flags for bots/players (dynamic/editor flags) +#define AI_OBSTRUCTED 1 +#define AI_HOLD_SELECT 2 +#define AI_ROUTE_FAILED 2 +#define AI_WAIT 4 +#define AI_DANGER 8 + +// addition masks +#define AI_POINT_TYPES 29152 +#define AI_READAHEAD_TYPES 36528 +#define AI_IGNORE_TYPES 4864 + +#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----- +@extern float active_clients1, active_clients2; +@extern float max_clients, real_frametime; +@extern float bot_count, b_options, lasttime; +@extern float waypoint_mode, dump_mode; +@extern float waypoints, direct_route, userid; +@extern float sv_friction, sv_gravity; +@extern float sv_accelerate, sv_maxspeed, sv_stopspeed; +@extern entity fixer; +@extern entity route_table; +@extern entity b_temp1, b_temp2, b_temp3; +@extern entity player_head, player_tail, phys_head, way_head; +@extern float busy_waypoints; + +@extern float coop; + +// -------ProtoTypes------ +// external +@extern void() ClientConnect; +@extern void() ClientDisconnect; +@extern void() SetNewParms; + +// fight +@extern void(float brange) bot_weapon_switch; +@extern void() bot_fight_style; +@extern void() bot_dodge_stuff; + +// rankings +@extern float(float clientno) ClientBitFlag; +@extern float() ClientNextAvailable; +@extern void(float whatbot, float whatskill) BotConnect; +@extern void(entity bot) BotDisconnect; +@extern void(float clientno) BotInvalidClientNo; +@extern void(entity who) UpdateClient; + +// waypointing +@extern void() DynamicWaypoint; +@extern entity(vector org) make_waypoint; +@extern void() ClearAllWays; +@extern void() FixWaypoints; +@extern float() begin_route; +@extern void(entity this, float direct) bot_get_path; +@extern void() WaypointThink; +@extern entity(entity start) FindWayPoint; +@extern void() ClearMyRoute; +@extern entity(entity lastone) FindRoute; +@extern float (entity e1, entity e2) CheckLinked; +@extern void(vector org) SpawnTempWaypoint; +@extern void(vector org, vector bit1, float bit4, float flargs) make_way; + +@extern void () map_dm1; +@extern void () map_dm2; +@extern void () map_dm3; +@extern void () map_dm4; +@extern void () map_dm5; +@extern void () map_dm6; + +// physics & movement +@extern float(entity e) bot_can_rj; +@extern void() bot_jump; +@extern void() frik_bot_roam; +@extern float(vector weird) frik_walkmove; +@extern void() frik_movetogoal; +@extern void() frik_obstacles; +@extern float(float flag) frik_recognize_plat; +@extern float(vector sdir) frik_KeysForDir; +@extern void(vector whichway, float danger) frik_obstructed; +@extern void() SV_Physics_Client; +@extern void() SV_ClientThink; +@extern void() CL_KeyMove; +@extern entity(string s) FindThing; + +// ai & misc +@extern void() BotAI; +@extern string() PickARandomName; +@extern float(entity targ) fov; +@extern float(float y1, float y2) angcomp; +@extern float(entity targ1, entity targ2) wisible; +@extern float(entity targ) sisible; +@extern float(entity targ) fisible; +@extern vector(entity ent) realorigin; +@extern void(entity ent) target_drop; +@extern void(entity ent) target_add; +@extern void() KickABot; +@extern void() BotImpulses; +@extern void(entity targ, float success) bot_lost; +@extern string(float r) BotName; +@extern float(float v) frik_anglemod; +@extern void() bot_chat; +@extern void(float tpic) bot_start_topic; + +@extern void(string h) BotSay; +@extern void() BotSayInit; +@extern void(string h) BotSay2; +@extern void(string h) BotSayTeam; +@extern void(entity e1, entity e2, float flag) DeveloperLightning; + +#include "defs.h" diff --git a/fbxa/map_dm1.qc b/fbxa/map_dm1.qc index 4970ee7..b068bbd 100644 --- a/fbxa/map_dm1.qc +++ b/fbxa/map_dm1.qc @@ -2,7 +2,7 @@ For instructions please read the readme.html that comes with FrikBot */ -void(vector org, vector bit1, float bit4, float flargs) make_way; +#include "libfrikbot.h" // Ways by Electro void() map_dm1 = diff --git a/fbxa/map_dm2.qc b/fbxa/map_dm2.qc index abf47ac..282c891 100644 --- a/fbxa/map_dm2.qc +++ b/fbxa/map_dm2.qc @@ -2,7 +2,7 @@ For instructions please read the readme.html that comes with FrikBot */ -void(vector org, vector bit1, float bit4, float flargs) make_way; +#include "libfrikbot.h" // Ways by Frika C void() map_dm2 = diff --git a/fbxa/map_dm3.qc b/fbxa/map_dm3.qc index e6ae4bf..f78c3ce 100644 --- a/fbxa/map_dm3.qc +++ b/fbxa/map_dm3.qc @@ -2,7 +2,7 @@ For instructions please read the wayedit.txt that comes with FrikBot */ -void(vector org, vector bit1, float bit4, float flargs) make_way; +#include "libfrikbot.h" // Ways by Frika C void() map_dm3 = diff --git a/fbxa/map_dm4.qc b/fbxa/map_dm4.qc index 913cd78..e53dd0d 100644 --- a/fbxa/map_dm4.qc +++ b/fbxa/map_dm4.qc @@ -2,7 +2,7 @@ For instructions please read the wayedit.txt that comes with FrikBot */ -void(vector org, vector bit1, float bit4, float flargs) make_way; +#include "libfrikbot.h" void() map_dm4 = { diff --git a/fbxa/map_dm5.qc b/fbxa/map_dm5.qc index 45b1d17..c5378d8 100644 --- a/fbxa/map_dm5.qc +++ b/fbxa/map_dm5.qc @@ -2,7 +2,7 @@ For instructions please read the readme.html that comes with FrikBot */ -void(vector org, vector bit1, float bit4, float flargs) make_way; +#include "libfrikbot.h" // Ways by Electro void() map_dm5 = diff --git a/fbxa/map_dm6.qc b/fbxa/map_dm6.qc index 9ca08c1..c7c343c 100644 --- a/fbxa/map_dm6.qc +++ b/fbxa/map_dm6.qc @@ -2,7 +2,7 @@ For instructions please read the readme.html that comes with FrikBot */ -void(vector org, vector bit1, float bit4, float flargs) make_way; +#include "libfrikbot.h" // Ways by Electro void() map_dm6 =