whitespace sweep

This commit is contained in:
Bill Currie 2003-03-04 18:26:17 +00:00
parent 8b92578ab5
commit 04f269992a
9 changed files with 711 additions and 1585 deletions

View file

@ -319,10 +319,8 @@ void(entity client, string s) stuffcmd =
frik_stuffcmd(client, s);
b_temp1 = player_head;
while(b_temp1)
{
if (b_temp1.classname == "botcam")
{
while(b_temp1) {
if (b_temp1.classname == "botcam") {
if ((b_temp1.enemy == client) && b_temp1.ishuman)
frik_stuffcmd(b_temp1, s);
}
@ -334,13 +332,10 @@ void(entity e) setspawnparms =
{
if (e.ishuman == 1)
frik_setspawnparms(e);
else
{
else {
b_temp1 = player_head;
while(b_temp1)
{
if (b_temp1.ishuman)
{
while(b_temp1) {
if (b_temp1.ishuman) {
frik_setspawnparms(b_temp1);
return;
}
@ -355,10 +350,8 @@ void(entity client, string s) sprint =
frik_sprint(client, s);
b_temp1 = player_head;
while(b_temp1)
{
if (b_temp1.classname == "botcam")
{
while(b_temp1) {
if (b_temp1.classname == "botcam") {
if ((b_temp1.enemy == client) && b_temp1.ishuman)
frik_sprint(b_temp1, s);
}
@ -372,10 +365,8 @@ void(entity client, string s) centerprint =
frik_centerprint(client, s);
b_temp1 = player_head;
while(b_temp1)
{
if (b_temp1.classname == "botcam")
{
while(b_temp1) {
if (b_temp1.classname == "botcam") {
if ((b_temp1.enemy == client) && b_temp1.ishuman)
frik_centerprint(b_temp1, s);
}
@ -497,18 +488,14 @@ void() botcam_u =
{
// sloppy cycling code
if (self.classname != "botcam")
{
if (self.classname != "botcam") {
self.enemy = player_head;
}
else
{
} else {
do
self.enemy = self.enemy._next;
while (self.enemy.classname == "botcam");
}
if (self.enemy == self)
{
if (self.enemy == self) {
do
self.enemy = self.enemy._next;
while (self.enemy.classname == "botcam");
@ -520,8 +507,7 @@ void() botcam_u =
self.takedamage = DAMAGE_NO;
if (!self.enemy)
{
if (!self.enemy) {
sprint(self, "No one left to track!\n");
msg_entity = self;
WriteByte (MSG_ONE,5);
@ -529,8 +515,7 @@ void() botcam_u =
PutClientInServer();
return;
}
if (!self.enemy.ishuman)
{
if (!self.enemy.ishuman) {
self.enemy.dmg_take = 0;
self.enemy.dmg_save = 0;
}
@ -560,8 +545,7 @@ void() ClientFixRankings =
b_temp2 = nextent(NIL);
cno = 0;
while (cno < max_clients)
{
while (cno < max_clients) {
if ((!b_temp2.ishuman) && (active_clients & ClientBitFlag(cno)))
UpdateClient(b_temp2);
cno = cno + 1;
@ -579,16 +563,14 @@ void() ClientInRankings =
self._last = NIL;
player_head = self;
if (!self.phys_obj)
{
if (!self.phys_obj) {
b_temp2 = phys_head;
while (b_temp2 != NIL && b_temp2.owner != self)
b_temp2 = b_temp2._next;
self.phys_obj = b_temp2;
}
if (self.ishuman == 2)
{
if (self.ishuman == 2) {
self.ishuman = FALSE;
return;
}
@ -625,18 +607,15 @@ float () BotPreFrame =
{
if (self.b_clientno == -1)
return TRUE;
if (self.ishuman)
{
if (self.ishuman) {
if (self.switch_wallhug)
ClientFixRankings();
if (self.classname == "botcam")
return TRUE;
}
if (self.b_frags != self.frags)
{
if (self.b_frags != self.frags) {
if (self.b_frags > self.frags)
{
if (self.b_frags > self.frags) {
if (pointcontents(self.origin) == CONTENT_LAVA)
bot_start_topic(10);
else
@ -653,8 +632,7 @@ float () BotPostFrame =
{
if (self.b_clientno == -1)
return TRUE;
if (self.ishuman)
{
if (self.ishuman) {
if (waypoint_mode > WM_LOADED)
bot_menu_display();
@ -703,10 +681,8 @@ void(string h) BotSayTeam =
if (!teamplay)
return;
t = player_head;
while(t)
{
if (t.team == self.team)
{
while(t) {
if (t.team == self.team) {
msg_entity = t;
WriteByte(MSG_ONE, 8);
WriteByte(MSG_ONE, 1);
@ -738,8 +714,7 @@ void() BotInit =
ent = nextent(NIL);
max_clients = 0;
while(ent != NIL)
{
while(ent != NIL) {
max_clients = max_clients + 1;
ent = nextent(ent);
}
@ -748,8 +723,7 @@ void() BotInit =
ent = nextent(NIL);
fisent = NIL;
while (numents < max_clients)
{
while (numents < max_clients) {
phys_head = spawn();
if (fisent)
@ -766,22 +740,19 @@ void() BotInit =
precache_model("progs/s_bubble.spr");
// the bots return!
b_options = cvar("saved1");
if (coop || (b_options & OPT_SAVEBOTS))
{
if (coop || (b_options & OPT_SAVEBOTS)) {
saved_bots = cvar("scratch1");
saved_skills1 = cvar("scratch2");
saved_skills2 = cvar("scratch3");
}
cvar_set ("saved4", "0");
if (max_clients > 1)
{
if (max_clients > 1) {
localcmd("exec maps/");
localcmd(mapname);
localcmd(".way\n");
waypoint_mode = WM_DYNAMIC;
bot_map_load();
}
else
} else
waypoint_mode = WM_LOADED;
};
@ -854,8 +825,7 @@ float() ClientNextAvailable =
local float clientno;
clientno = max_clients;
while(clientno > 0)
{
while(clientno > 0) {
clientno = clientno - 1;
if(!(active_clients & ClientBitFlag(clientno)))
@ -898,31 +868,25 @@ float(float tcolor) FindAnotherColor =
local float bestbet, scolor, pcount, bestp;
bestbet = -1;
bestp = 16;
while(scolor < 14)
{
if (scolor != tcolor)
{
while(scolor < 14) {
if (scolor != tcolor) {
b_temp2 = player_head;
pcount = 0;
while(b_temp2 != NIL)
{
while(b_temp2 != NIL) {
if (b_temp2.team == scolor + 1)
pcount = pcount + 1;
b_temp2 = b_temp2._next;
}
if ((pcount < bestp) && pcount)
{
if ((pcount < bestp) && pcount) {
bestbet = scolor;
bestp = pcount;
}
}
scolor = scolor + 1;
}
if (bestbet < 0)
{
if (bestbet < 0) {
bestbet = tcolor;
while (bestbet == tcolor)
{
while (bestbet == tcolor) {
bestbet = floor(random() * 13);
}
}
@ -941,8 +905,7 @@ entity(float num) GetClientEntity =
local entity upsy;
upsy = NIL;
num = num + 1;
while (num > 0)
{
while (num > 0) {
num = num - 1;
upsy = nextent(upsy);
}
@ -957,8 +920,7 @@ void(float whichteam, float whatbot, float whatskill) BotConnect =
f = ClientNextAvailable();
uself = self;
if(f == -1)
{
if(f == -1) {
bprint("Unable to connect a bot, server is full.\n");
return;
}
@ -986,8 +948,7 @@ void(float whichteam, float whatbot, float whatskill) BotConnect =
whatskill = 0;
self.b_skill = whatskill;
if (teamplay && !coop)
{
if (teamplay && !coop) {
if (whichteam)
self.b_pants = FindAnotherColor(uself.team - 1);
else
@ -1010,8 +971,7 @@ void(float whichteam, float whatbot, float whatskill) BotConnect =
if (self.b_num <= 8)
saved_skills1 = (saved_skills1 & (65536 - (3 * f)) | (self.b_skill * f));
else
{
else {
f = ClientBitFlag(self.b_num - 9);
saved_skills2 = (saved_skills2 & (65536 - (3 * f)) | (self.b_skill * f));
}
@ -1041,8 +1001,7 @@ void(entity bot) BotDisconnect =
ClientDisconnect();
if (self.b_clientno != -1)
{
if (self.b_clientno != -1) {
// the bot's client number is not in use by a real player so we
// must remove it's entry in the rankings
// Quake engine sets all fields to 0, can only do the most important here
@ -1076,10 +1035,8 @@ void(float clientno) BotInvalidClientNo =
local entity bot;
bot = GetClientEntity(clientno);
if(bot.b_clientno > 0)
{
if (!bot.ishuman)
{
if(bot.b_clientno > 0) {
if (!bot.ishuman) {
bot.b_clientno = -1;
BotDisconnect(bot);
active_clients = active_clients | ClientBitFlag(self.b_clientno);
@ -1118,10 +1075,8 @@ void() LoadWaypoint =
void() bot_return =
{
if (time > 2)
{
if ((waypoint_mode == WM_DYNAMIC) || (waypoint_mode == WM_LOADED))
{
if (time > 2) {
if ((waypoint_mode == WM_DYNAMIC) || (waypoint_mode == WM_LOADED)) {
// minor precaution
if (saved_bots & 1) BotConnect(0, 1, saved_skills1 & 3);
@ -1154,15 +1109,12 @@ void() WaypointWatch =
if (max_clients < 2)
return;
if (waypoint_mode != WM_UNINIT)
{
if (waypoint_mode != WM_UNINIT) {
bigboobs = cvar("saved4");
if (bigboobs != 0)
{
if (bigboobs != 0) {
if ((bigboobs & 3) == 1)
ClearAllWays();
else if ((bigboobs & 3) == 3)
{
else if ((bigboobs & 3) == 3) {
FixWaypoints();
h = ftos(b_options);
cvar_set("saved1", h);
@ -1191,12 +1143,9 @@ void() BotFrame =
self = nextent(NIL);
num = 0;
while (num < max_clients)
{
if (self.ishuman == FALSE)
{
if (active_clients & ClientBitFlag(num))
{
while (num < max_clients) {
if (self.ishuman == FALSE) {
if (active_clients & ClientBitFlag(num)) {
frik_obstacles();
CL_KeyMove();
SV_ClientThink();
@ -1225,17 +1174,13 @@ void() BotImpulses =
{
local float f;
if (self.impulse == 100)
{
if (self.impulse == 100) {
f = cvar("skill");
BotConnect(0, 0, f);
}
else if (self.impulse == 101)
{
} else if (self.impulse == 101) {
f = cvar("skill");
BotConnect(1, 0, f);
}
else if (self.impulse == 102)
} else if (self.impulse == 102)
KickABot();
else if (self.impulse == 103)
botcam_u();

View file

@ -114,25 +114,19 @@ void(entity ent) target_drop =
local float tg;
tg = target_onstack(ent);
if (tg == 1)
{
if (tg == 1) {
self.target1 = self.target2;
self.target2 = self.target3;
self.target3 = self.target4;
self.target4 = NIL;
}
else if (tg == 2)
{
} else if (tg == 2) {
self.target1 = self.target3;
self.target2 = self.target4;
self.target3 = self.target4 = NIL;
}
else if (tg == 3)
{
} else if (tg == 3) {
self.target1 = self.target4;
self.target2 = self.target3 = self.target4 = NIL;
}
else if (tg == 4)
} else if (tg == 4)
self.target1 = self.target2 = self.target3 = self.target4 = NIL;
self.search_time = time + 5;
};
@ -157,25 +151,21 @@ void(entity targ, float success) bot_lost =
targ.b_sound = targ.b_sound - (targ.b_sound & ClientBitFlag(self.b_clientno));
// find a new route
if (!success)
{
if (!success) {
self.target1 = self.target2 = self.target3 = self.target4 = NIL;
self.last_way = FindWayPoint(self.current_way);
ClearMyRoute();
self.b_aiflags = 0;
}
else
{
} else {
if (targ.classname == "item_artifact_invisibility")
if (self.items & 524288)
bot_start_topic(3);
if (targ.flags & FL_ITEM)
{
if (!targ.model)
targ._last = NIL;
else
targ._last = self;
if (targ.flags & FL_ITEM) {
if (!targ.model)
targ._last = NIL;
else
targ._last = self;
}
}
@ -204,80 +194,53 @@ void(entity targ) bot_check_lost =
// waypoints and items are lost if you get close enough to them
else if (targ.flags & FL_ITEM)
{
else if (targ.flags & FL_ITEM) {
if (vlen(targ.origin - self.origin) < 32)
bot_lost(targ, TRUE);
else if (!targ.model)
bot_lost(targ, TRUE);
}
else if (targ.classname == "waypoint")
{
if (!(self.b_aiflags & (AI_SNIPER | AI_AMBUSH)))
{
if (self.b_aiflags & AI_RIDE_TRAIN)
{
} else if (targ.classname == "waypoint") {
if (!(self.b_aiflags & (AI_SNIPER | AI_AMBUSH))) {
if (self.b_aiflags & AI_RIDE_TRAIN) {
if (vlen(targ.origin - self.origin) < 48)
bot_lost(targ, TRUE);
}
else if (self.b_aiflags & AI_PRECISION)
{
} else if (self.b_aiflags & AI_PRECISION) {
if (vlen(targ.origin - self.origin) < 24)
bot_lost(targ, TRUE);
}
else if (vlen(targ.origin - self.origin) < 32)
} else if (vlen(targ.origin - self.origin) < 32)
bot_lost(targ, TRUE);
}
}
else if (targ.classname == "temp_waypoint")
{
} else if (targ.classname == "temp_waypoint") {
if (vlen(targ.origin - self.origin) < 32)
bot_lost(targ, TRUE);
}
else if (targ.classname == "player")
{
} else if (targ.classname == "player") {
if (targ.health <= 0)
bot_lost(targ, TRUE);
else if ((coop) || (teamplay && targ.team == self.team))
{
if (targ.target1.classname == "player")
{
else if ((coop) || (teamplay && targ.team == self.team)) {
if (targ.target1.classname == "player") {
if (!targ.target1.ishuman)
bot_lost(targ, TRUE);
}
else if (targ.teleport_time > time)
{
} else if (targ.teleport_time > time) {
// try not to telefrag teammates
self.keys = self.keys & 960;
}
else if (vlen(targ.origin - self.origin) < 128)
{
} else if (vlen(targ.origin - self.origin) < 128) {
if (vlen(targ.origin - self.origin) < 48)
frik_walkmove(self.origin - targ.origin);
else
{
else {
self.keys = self.keys & 960;
bot_start_topic(4);
}
self.search_time = time + 5; // never time out
}
else if (!fisible(targ))
} else if (!fisible(targ))
bot_lost(targ, FALSE);
}
else if (waypoint_mode > WM_LOADED)
{
if (vlen(targ.origin - self.origin) < 128)
{
} else if (waypoint_mode > WM_LOADED) {
if (vlen(targ.origin - self.origin) < 128) {
bot_lost(targ, TRUE);
}
}
}
// buttons are lost of their frame changes
else if (targ.classname == "func_button")
{
if (targ.frame)
{
} else if (targ.classname == "func_button") {
// buttons are lost of their frame changes
if (targ.frame) {
bot_lost(targ, TRUE);
if (self.enemy == targ)
self.enemy = NIL;
@ -285,12 +248,9 @@ void(entity targ) bot_check_lost =
// bot_get_path(self.target1, TRUE);
}
}
// trigger_multiple style triggers are lost if their thinktime changes
else if ((targ.movetype == MOVETYPE_NONE) && (targ.solid == SOLID_TRIGGER))
{
if (targ.nextthink >= time)
{
} else if ((targ.movetype == MOVETYPE_NONE) && (targ.solid == SOLID_TRIGGER)) {
// trigger_multiple style triggers are lost if their thinktime changes
if (targ.nextthink >= time) {
bot_lost(targ, TRUE);
//if (self.target1)
// bot_get_path(self.target1, TRUE);
@ -298,17 +258,14 @@ void(entity targ) bot_check_lost =
}
// lose any target way above the bot's head
// FIXME: if the bot can fly in your mod..
if ((targ.origin_z - self.origin_z) > 64)
{
if ((targ.origin_z - self.origin_z) > 64) {
dist = targ.origin - self.origin;
dist_z = 0;
if (vlen(dist) < 32)
if (self.flags & FL_ONGROUND)
if(!frik_recognize_plat(FALSE))
bot_lost(targ, FALSE);
}
else if (targ.classname == "train")
{
} else if (targ.classname == "train") {
if (frik_recognize_plat(FALSE))
bot_lost(targ, TRUE);
}
@ -342,36 +299,27 @@ void() bot_handle_ai =
if (self.b_aiflags & AI_WAIT)
self.keys = self.keys & 960;
if (self.b_aiflags & AI_DOORFLAG) // was on a door when spawned
{
if (self.b_aiflags & AI_DOORFLAG) // was on a door when spawned {
b_temp3 = self;
self = self.last_way;
if (!frik_recognize_plat(FALSE)) // if there is nothing there now
{
// if there is nothing there now
if (!frik_recognize_plat(FALSE)) {
newt = FindThing("door"); // this is likely the door responsible (crossfingers)
self = b_temp3;
if (self.b_aiflags & AI_DOOR_NO_OPEN)
{
if (self.b_aiflags & AI_DOOR_NO_OPEN) {
if (newt.nextthink)
self.keys = self.keys & 960; // wait until it closes
else
{
else {
bot_lost(self.last_way, FALSE);
}
}
else
{
if (newt.targetname)
{
} else {
if (newt.targetname) {
newt = find(NIL, target, newt.targetname);
if (newt.health > 0)
{
if (newt.health > 0) {
self.enemy = newt;
bot_weapon_switch(1);
}
else
{
} else {
// target_drop(self.last_way);
target_add(newt);
// bot_get_path(newt, TRUE);
@ -379,108 +327,85 @@ void() bot_handle_ai =
}
self.b_aiflags = self.b_aiflags - AI_DOORFLAG;
}
}
else
} else
self = b_temp3;
}
if (self.b_aiflags & AI_JUMP)
{
if (self.flags & FL_ONGROUND)
{
if (self.b_aiflags & AI_JUMP) {
if (self.flags & FL_ONGROUND) {
bot_jump();
self.b_aiflags = self.b_aiflags - AI_JUMP;
}
}
else if (self.b_aiflags & AI_SUPER_JUMP)
{
} else if (self.b_aiflags & AI_SUPER_JUMP) {
if (self.weapon != 32)
self.impulse = 7;
else if (self.flags & FL_ONGROUND)
{
else if (self.flags & FL_ONGROUND) {
self.b_aiflags = self.b_aiflags - AI_SUPER_JUMP;
if (bot_can_rj(self))
{
if (bot_can_rj(self)) {
bot_jump();
self.v_angle_x = self.b_angle_x = 80;
self.button0 = TRUE;
}
else
} else
bot_lost(self.target1, FALSE);
}
}
if (self.b_aiflags & AI_SURFACE)
{
if (self.waterlevel > 2)
{
if (self.b_aiflags & AI_SURFACE) {
if (self.waterlevel > 2) {
self.keys = KEY_MOVEUP;
self.button2 = TRUE; // swim!
}
else
} else
self.b_aiflags = self.b_aiflags - AI_SURFACE;
}
if (self.b_aiflags & AI_RIDE_TRAIN)
{
if (self.b_aiflags & AI_RIDE_TRAIN) {
// simple, but effective
// this can probably be used for a lot of different
// things, not just trains (door elevators come to mind)
b_temp3 = self;
self = self.last_way;
if (!frik_recognize_plat(FALSE)) // if there is nothing there now
{
if (!frik_recognize_plat(FALSE)) {
// if there is nothing there now
self = b_temp3;
self.keys = self.keys & 960;
}
else
{
} else {
self = b_temp3;
if (frik_recognize_plat(FALSE))
{
if (frik_recognize_plat(FALSE)) {
v = realorigin(trace_ent) + trace_ent.origin - self.origin;
v_z = 0;
if (vlen(v) < 24)
self.keys = self.keys & 960;
else
{
else {
self.b_aiflags = self.b_aiflags | AI_PRECISION;
self.keys = frik_KeysForDir(v);
}
}
}
}
if (self.b_aiflags & AI_PLAT_BOTTOM)
{
if (self.b_aiflags & AI_PLAT_BOTTOM) {
newt = FindThing("plat");
if (newt.state != 1)
{
if (newt.state != 1) {
v = self.origin - realorigin(newt);
v_z = 0;
if (vlen(v) > 96)
self.keys = self.keys & 960;
else
frik_walkmove(v);
}
else
} else
self.b_aiflags = self.b_aiflags - AI_PLAT_BOTTOM;
}
if (self.b_aiflags & AI_DIRECTIONAL)
{
if ((normalize(self.last_way.origin - self.origin) * self.b_dir) > 0.4)
{
if (self.b_aiflags & AI_DIRECTIONAL) {
if ((normalize(self.last_way.origin - self.origin) * self.b_dir) > 0.4) {
self.b_aiflags = self.b_aiflags - AI_DIRECTIONAL;
bot_lost(self.target1, TRUE);
}
}
if (self.b_aiflags & AI_SNIPER)
{
if (self.b_aiflags & AI_SNIPER) {
self.b_aiflags = (self.b_aiflags | AI_WAIT | AI_PRECISION) - AI_SNIPER;
// FIXME: Add a switch to wep command
// FIXME: increase delay?
}
if (self.b_aiflags & AI_AMBUSH)
{
if (self.b_aiflags & AI_AMBUSH) {
self.b_aiflags = (self.b_aiflags | AI_WAIT) - AI_AMBUSH;
// FIXME: Add a switch to wep command
// FIXME: increase delay?
@ -507,8 +432,7 @@ void() bot_path =
local entity jj, tele;
bot_check_lost(self.target1);
if (!self.target1)
{
if (!self.target1) {
self.keys=0;
return;
}
@ -516,11 +440,9 @@ void() bot_path =
return; // old waypoint still being hunted
jj = FindRoute(self.last_way);
if (!jj)
{
if (!jj) {
// this is an ugly hack
if (self.target1.current_way != self.last_way)
{
if (self.target1.current_way != self.last_way) {
if (self.target1.classname != "temp_waypoint")
if (self.target1.classname != "player")
bot_lost(self.target1, FALSE);
@ -536,37 +458,28 @@ void() bot_path =
self.b_aiflags = (jj.b_aiflags & AI_READAHEAD_TYPES) | (self.last_way.b_aiflags & AI_POINT_TYPES);
target_add(jj);
if (self.last_way)
{
if (CheckLinked(self.last_way, jj) == 2) // waypoints are telelinked
{
if (self.last_way) {
if (CheckLinked(self.last_way, jj) == 2) // waypoints are telelinked {
tele = FindThing("trigger_teleport"); // this is probbly the teleport responsible
target_add(tele);
}
traceline(self.last_way.origin, jj.origin, FALSE, self); // check for blockage
if (trace_fraction != 1)
{
if (trace_ent.classname == "door" && !(self.b_aiflags & AI_DOOR_NO_OPEN)) // a door blocks the way
{
if (trace_fraction != 1) {
if (trace_ent.classname == "door" && !(self.b_aiflags & AI_DOOR_NO_OPEN)) {
// a door blocks the way
// linked doors fix
if (trace_ent.owner)
trace_ent = trace_ent.owner;
if ((trace_ent.health > 0) && (self.enemy == NIL))
{
if ((trace_ent.health > 0) && (self.enemy == NIL)) {
self.enemy = trace_ent;
bot_weapon_switch(1);
self.b_aiflags = self.b_aiflags | AI_BLIND; // nick knack paddy hack
}
else if (trace_ent.targetname)
{
} else if (trace_ent.targetname) {
tele = find(NIL, target, trace_ent.targetname);
if (tele.health > 0)
{
if (tele.health > 0) {
self.enemy = tele;
bot_weapon_switch(1);
}
else
{
} else {
// target_drop(jj);
target_add(tele);
// bot_get_path(tele, TRUE);
@ -574,9 +487,7 @@ void() bot_path =
return;
}
}
}
else if (trace_ent.classname == "func_wall")
{
} else if (trace_ent.classname == "func_wall") {
// give up
bot_lost(self.target1, FALSE);
return;
@ -612,8 +523,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 && thing.search_time < time)
{
if ((thing.flags & FL_ITEM) && thing.model && thing.search_time < time) {
// ugly hack
if (thing._last != self)
thisp = 20;
@ -621,85 +531,60 @@ float(entity thing) priority_for_thing =
thisp = 65;
else if (thing.classname == "item_artifact_invulnerability")
thisp = 65;
else if (thing.classname == "item_health")
{
else if (thing.classname == "item_health") {
if (thing.spawnflags & 2)
thisp = 55;
if (self.health < 40)
thisp = thisp + 50;
}
else if (thing.model == "progs/armor.mdl")
{
if (self.armorvalue < 200)
{
} else if (thing.model == "progs/armor.mdl") {
if (self.armorvalue < 200) {
if (thing.skin == 2)
thisp = 60;
else if (self.armorvalue < 100)
thisp = thisp + 25;
}
}
else if (thing.classname == "weapon_supershotgun")
{
} else if (thing.classname == "weapon_supershotgun") {
if (!(self.items & 2)) // IT_SUPER_SHOTGUN
thisp = 25;
}
else if (thing.classname == "weapon_nailgun")
{
} else if (thing.classname == "weapon_nailgun") {
if (!(self.items & 4)) // IT_NAILGUN
thisp = 30;
}
else if (thing.classname == "weapon_supernailgun")
{
} else if (thing.classname == "weapon_supernailgun") {
if (!(self.items & 8)) // IT_SUPER_NAILGUN
thisp = 35;
}
else if (thing.classname == "weapon_grenadelauncher")
{
} else if (thing.classname == "weapon_grenadelauncher") {
if (!(self.items & 16)) // IT_GRENADE_LAUNCHER
thisp = 45;
}
else if (thing.classname == "weapon_rocketlauncher")
{
} else if (thing.classname == "weapon_rocketlauncher") {
if (!(self.items & 32)) // IT_ROCKET_LAUNCHER
thisp = 60;
}
else if (thing.classname == "weapon_lightning")
{
} else if (thing.classname == "weapon_lightning") {
if (!(self.items & 64)) // IT_LIGHTNING
thisp = 50;
}
}
else if ((thing.flags & FL_MONSTER) && thing.health > 0)
} else if ((thing.flags & FL_MONSTER) && thing.health > 0)
thisp = 45;
else if (thing.classname == "player")
{
if (thing.health > 0)
{
else if (thing.classname == "player") {
if (thing.health > 0) {
if (thing == self)
return 0;
else
{
else {
if (thing.items & IT_INVISIBILITY) //FIXME
thisp = 2;
else if (coop)
{
else if (coop) {
thisp = 100;
if (thing.target1.classname == "player")
if (!thing.target1.ishuman)
return 0;
}
else if (teamplay && thing.team == self.team)
{
} else if (teamplay && thing.team == self.team) {
thisp = 100;
if (thing.target1.classname == "player")
return 0;
}
else thisp = 30;
} else
thisp = 30;
}
}
}
else if (thing.classname == "waypoint")
{
} else if (thing.classname == "waypoint") {
if (thing.b_aiflags & AI_SNIPER)
thisp = 30;
else if (thing.b_aiflags & AI_AMBUSH)
@ -707,10 +592,8 @@ float(entity thing) priority_for_thing =
}
if (pointcontents(thing.origin) < -3)
return 0;
if (thisp)
{
if (thing.current_way)
{
if (thisp) {
if (thing.current_way) {
// check to see if it's unreachable
if (thing.current_way.items == -1)
return 0;
@ -733,15 +616,13 @@ void(float scope) bot_look_for_crap =
foe = findradius(self.origin, 500);
bestp = 1;
while(foe)
{
while(foe) {
thatp = priority_for_thing(foe);
if (thatp)
if (!scope)
if (!sisible(foe))
thatp = 0;
if (thatp > bestp)
{
if (thatp > bestp) {
bestp = thatp;
best = foe;
dist = vlen(self.origin - foe.origin);
@ -750,11 +631,9 @@ void(float scope) bot_look_for_crap =
}
if (best == NIL)
return;
if (!target_onstack(best))
{
if (!target_onstack(best)) {
target_add(best);
if (scope)
{
if (scope) {
bot_get_path(best, FALSE);
self.b_aiflags = self.b_aiflags | AI_WAIT;
}
@ -779,19 +658,15 @@ void() bot_angle_set =
local float h;
local vector view;
if (self.enemy)
{
if (self.enemy) {
if (self.enemy.items & 524288)
if (random() > 0.2)
return;
if (self.missile_speed == 0)
self.missile_speed = 10000;
if (self.enemy.solid == SOLID_BSP)
{
if (self.enemy.solid == SOLID_BSP) {
view = (((self.enemy.absmin + self.enemy.absmax) * 0.5) - self.origin);
}
else
{
} else {
h = vlen(self.enemy.origin - self.origin) / self.missile_speed;
if (self.enemy.flags & FL_ONGROUND)
view = self.enemy.velocity * h;
@ -810,9 +685,7 @@ void() bot_angle_set =
view = vectoangles(view);
view_x = view_x * -1;
self.b_angle = view;
}
else if (self.target1)
{
} else if (self.target1) {
view = realorigin(self.target1);
if (self.target1.flags & FL_ITEM)
view = view + '0 0 48';
@ -820,14 +693,12 @@ void() bot_angle_set =
view = vectoangles(view);
view_x = view_x * -1;
self.b_angle = view;
}
else
} else
self.b_angle_x = 0;
// HACK HACK HACK HACK
// The bot falls off ledges a lot because of "turning around"
// so let the bot use instant turn around when not hunting a player
if (self.b_skill == 3)
{
if (self.b_skill == 3) {
self.keys = self.keys & 63;
self.v_angle = self.b_angle;
while (self.v_angle_x < -180)
@ -835,18 +706,15 @@ void() bot_angle_set =
while (self.v_angle_x > 180)
self.v_angle_x = self.v_angle_x - 360;
}
else if ((self.enemy == NIL || 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;
while (self.v_angle_x < -180)
self.v_angle_x = self.v_angle_x + 360;
while (self.v_angle_x > 180)
self.v_angle_x = self.v_angle_x - 360;
}
else if (self.b_skill < 2) // skill 2 handled in bot_phys
{
} else if (self.b_skill < 2) {
// skill 2 handled in bot_phys
if (self.b_angle_x > 180)
self.b_angle_x = self.b_angle_x - 360;
self.keys = self.keys & 63;
@ -880,8 +748,7 @@ void() BotAI =
// health < 1 is used because fractional healths show up as 0 on normal player
// status bars, and the mod probably already compensated for that
if (self.health < 1)
{
if (self.health < 1) {
self.button0 = floor(random() * 2);
self.button2 = 0;
self.keys = 0;
@ -894,18 +761,15 @@ void() BotAI =
// stagger the bot's AI out so they all don't think at the same time, causing game
// 'spikes'
if (self.b_skill < 2)
{
if (self.b_skill < 2) {
if (self.ai_time > time)
return;
self.ai_time = time + 0.05;
if (bot_count > 0)
{
if (bot_count > 0) {
if ((time - stagger_think) < (0.1 / bot_count))
self.ai_time = self.ai_time + 0.1 / (2 * bot_count);
}
else
} else
return;
}
if (self.view_ofs == '0 0 0')
@ -920,38 +784,26 @@ void() BotAI =
// target1 is like goalentity in normal Quake monster AI.
// it's the bot's most immediate target
if (route_table == self)
{
if (busy_waypoints <= 0)
{
if (route_table == self) {
if (busy_waypoints <= 0) {
if (waypoint_mode < WM_EDITOR)
bot_look_for_crap(TRUE);
}
self.b_aiflags = 0;
self.keys = 0;
}
else if (self.target1)
{
} else if (self.target1) {
frik_movetogoal();
bot_path();
}
else
{
if (waypoint_mode < WM_EDITOR)
{
if(self.route_failed)
{
frik_bot_roam();
self.route_failed = 0;
}
else if(!begin_route())
{
bot_look_for_crap(FALSE);
}
} else {
if (waypoint_mode < WM_EDITOR) {
if(self.route_failed) {
frik_bot_roam();
self.route_failed = 0;
} else if(!begin_route()) {
bot_look_for_crap(FALSE);
}
self.keys = 0;
}
else
{
} else {
self.b_aiflags = AI_WAIT;
self.keys = 0;
}
@ -972,19 +824,16 @@ void() BotAI =
bot_dodge_stuff();
// checks to see if bot needs to start going up for air
if (self.waterlevel > 2)
{
if (time > (self.air_finished - 2))
{
if (self.waterlevel > 2) {
if (time > (self.air_finished - 2)) {
traceline (self.origin, self.origin + '0 0 6800', TRUE, self);
if (trace_inopen)
{
if (trace_inopen) {
self.keys = KEY_MOVEUP;
self.button2 = TRUE; // swim!
return; // skip ai flags for now - this is life or death
}
}
}
}
// b_aiflags handling

File diff suppressed because it is too large Load diff

View file

@ -88,56 +88,43 @@ void() bot_dodge_stuff =
self.avoid = NIL;
if (self.enemy)
{
if (self.enemy) {
v = self.origin - realorigin(self.enemy);
foedist = vlen(v);
foesz = bot_size_player(self.enemy);
}
else
{
} else {
foedist = 3000;
foesz = 9999999;
}
avdist = 256;
foe = find(NIL, classname, "grenade");
while(foe)
{
while(foe) {
flen = vlen(foe.origin - self.origin);
if (flen < avdist)
{
if (flen < avdist) {
avdist = flen;
self.avoid = foe;
}
foe = find(foe, classname, "grenade");
}
if (!self.avoid)
{
if (!self.avoid) {
foe = find(NIL, classname, "missile");
while(foe)
{
if (foe.owner != self)
{
while(foe) {
if (foe.owner != self) {
flen = vlen(foe.origin - self.origin);
if (flen < avdist)
{
if (flen < avdist) {
avdist = flen;
self.avoid = foe;
}
}
foe = find(foe, classname, "missile");
}
if (!self.avoid)
{
if (!self.avoid) {
foe = find(NIL, classname, "spike");
while(foe)
{
if (foe.owner != self)
{
while(foe) {
if (foe.owner != self) {
flen = vlen(foe.origin - self.origin);
if (flen < avdist)
{
if (flen < avdist) {
avdist = flen;
self.avoid = foe;
}
@ -146,25 +133,17 @@ void() bot_dodge_stuff =
}
}
}
if (coop)
{
if (!self.enemy)
{
if (coop) {
if (!self.enemy) {
foe = findradius(self.origin, foedist);
while(foe)
{
if(foe.flags & FL_MONSTER)
{
if(foe.health > 0)
{
while(foe) {
if(foe.flags & FL_MONSTER) {
if(foe.health > 0) {
flen = vlen(foe.origin - self.origin);
if (flen < foedist)
{
if (flen < foedist) {
tsz = bot_size_player(foe);
if (tsz < foesz)
{
if (fisible(foe))
{
if (tsz < foesz) {
if (fisible(foe)) {
self.enemy = foe;
foedist = flen;
foesz = tsz;
@ -176,31 +155,21 @@ void() bot_dodge_stuff =
foe = foe.chain;
}
}
}
else
{
} else {
local integer i = 0;
for (i = 0; i < 32; i++) {
if (!(foe = players[i]))
continue;
if(foe != self)
{
if (foe.modelindex != 0)
{
if (foe.health > 0)
{
if (!(teamplay && self.team == foe.team))
{
if(foe != self) {
if (foe.modelindex != 0) {
if (foe.health > 0) {
if (!(teamplay && self.team == foe.team)) {
flen = vlen(foe.origin - self.origin);
if (flen < foedist)
{
if (flen < foedist) {
tsz = bot_size_player(foe);
if (tsz < foesz)
{
if (fov(foe) || foe.b_sound > time || self.b_skill == 3)
{
if (fisible(foe))
{
if (tsz < foesz) {
if (fov(foe) || foe.b_sound > time || self.b_skill == 3) {
if (fisible(foe)) {
self.enemy = foe;
foedist = vlen(foe.origin - self.origin);
}
@ -211,7 +180,6 @@ void() bot_dodge_stuff =
}
}
}
foe = foe._next;
}
}
};
@ -266,52 +234,35 @@ void(float brange) bot_weapon_switch =
it = self.items & 127;
while(it)
{
if ((self.ammo_rockets >= 1) && (it & 32))
{
while(it) {
if ((self.ammo_rockets >= 1) && (it & 32)) {
flag = 32;
pulse = 7;
}
else if (self.waterlevel <= 1 && self.ammo_cells >= 1 && (it & 64))
{
} else if (self.waterlevel <= 1 && self.ammo_cells >= 1 && (it & 64)) {
flag = 64;
pulse = 8;
}
else if(self.ammo_nails >= 2 && (it & 8))
{
} else if(self.ammo_nails >= 2 && (it & 8)) {
flag = 8;
pulse = 5;
}
else if ((self.ammo_rockets >= 1) && (it & 16))
{
} else if ((self.ammo_rockets >= 1) && (it & 16)) {
flag = 16;
pulse = 6;
}
else if(self.ammo_shells >= 2 && (it & 2))
{
} else if(self.ammo_shells >= 2 && (it & 2)) {
flag = 2;
pulse = 3;
}
else if(self.ammo_nails >= 1 && (it & 4))
{
} else if(self.ammo_nails >= 1 && (it & 4)) {
flag = 4;
pulse = 4;
}
else if(self.ammo_shells >= 1 && (it & 1))
{
} else if(self.ammo_shells >= 1 && (it & 1)) {
flag = 1;
pulse = 2;
}
else
{
} else {
if (pulse)
self.impulse = pulse;
return;
}
if (brange == -1)
{
if (brange == -1) {
if (pulse)
self.impulse = pulse;
return;
@ -320,8 +271,7 @@ void(float brange) bot_weapon_switch =
v = weapon_range(flag);
if (brange < v_y || brange > v_z)
it = it - flag;
else
{
else {
if (pulse)
self.impulse = pulse;
return;
@ -359,18 +309,13 @@ void() bot_fight_style =
local float foedist, mysz, foesz;
if (self.enemy.health <= 0)
{
if (self.enemy.health <= 0) {
self.enemy = NIL;
return;
}
else if (!self.enemy.takedamage)
{
} else if (!self.enemy.takedamage) {
self.enemy = NIL;
return;
}
else if (!fisible(self.enemy))
{
} else if (!fisible(self.enemy)) {
self.enemy = NIL;
return;
}
@ -382,43 +327,34 @@ void() bot_fight_style =
foedist = vlen(org - self.origin);
v = weapon_range(self.weapon);
if (foedist > v_y && foedist < v_z)
{
if (foedist > v_y && foedist < v_z) {
traceline(self.origin + self.view_ofs, self.origin + self.view_ofs + v_forward * v_z, FALSE, self);
if (vlen(trace_endpos - (self.origin + self.view_ofs)) >= v_y)
{
if (vlen(trace_endpos - (self.origin + self.view_ofs)) >= v_y) {
// try to avoid shooting teammates
if (trace_ent.classname == "player")
if ((trace_ent.team == self.team && teamplay) || (coop))
return;
bot_shoot();
}
}
else
} else
bot_weapon_switch(foedist);
if (!(self.b_aiflags & (AI_PRECISION | AI_BLIND | AI_OBSTRUCTED)))
{
if (!(self.b_aiflags & (AI_PRECISION | AI_BLIND | AI_OBSTRUCTED))) {
foesz = bot_size_player(self.enemy);
mysz = bot_size_player(self) + 5;
if (foesz > mysz)
{
if (teamplay)
{
if (random() < 0.02)
{
if (foesz > mysz) {
if (teamplay) {
if (random() < 0.02) {
bot_start_topic(5);
self.b_chattime = 1;
}
}
return;
}
else if (mysz < 140)
} else if (mysz < 140)
return;
else if (self.avoid)
{
else if (self.avoid) {
if (self.avoid.velocity)
v = self.avoid.velocity;
else
@ -432,9 +368,7 @@ void() bot_fight_style =
frik_walkmove(v2);
else
frik_walkmove(v1);
}
else if (!(self.enemy.flags & FL_MONSTER))
{
} else if (!(self.enemy.flags & FL_MONSTER)) {
if (foedist + 32 < v_x)
frik_walkmove(self.origin - org);
else if (foedist - 32 > v_x)
@ -444,9 +378,7 @@ void() bot_fight_style =
else
frik_walkmove(v_right * -1);
}
}
else
{
} else {
foesz = bot_size_player(self.enemy);
mysz = bot_size_player(self) + 5;

View file

@ -55,98 +55,67 @@ Sets bot's name and colors
string(float r) BotName =
{
self.b_num = r;
if (r == 1)
{
if (r == 1) {
self.b_pants = 11;
self.b_shirt = 0;
return "Vincent";
}
else if (r == 2)
{
} else if (r == 2) {
self.b_pants = 1;
self.b_shirt = 3;
return "Bishop";
}
else if (r == 3)
{
} else if (r == 3) {
self.b_pants = 13;
self.b_shirt = 2;
return "Nomad";
}
else if (r == 4)
{
} else if (r == 4) {
self.b_pants = 7;
self.b_shirt = 6;
return "Hudson";
}
else if (r == 5)
{
} else if (r == 5) {
self.b_pants = 12;
self.b_shirt = 6;
return "Lore";
}
else if (r == 6)
{
} else if (r == 6) {
self.b_pants = 4;
self.b_shirt = 4;
return "Servo";
}
else if (r == 7)
{
} else if (r == 7) {
self.b_pants = 2;
self.b_shirt = 5;
return "Gort";
}
else if (r == 8)
{
} else if (r == 8) {
self.b_pants = 10;
self.b_shirt = 3;
return "Kryten";
}
else if (r == 9)
{
} else if (r == 9) {
self.b_pants = 9;
self.b_shirt = 4;
return "Pimp Bot";
}
else if (r == 10)
{
} else if (r == 10) {
self.b_pants = 4;
self.b_shirt = 7;
return "Max";
}
else if (r == 11)
{
} else if (r == 11) {
self.b_pants = 3;
self.b_shirt = 11;
return "Marvin";
}
else if (r == 12)
{
} else if (r == 12) {
self.b_pants = 13;
self.b_shirt = 12;
return "Erwin";
}
else if (r == 13)
{
} else if (r == 13) {
self.b_pants = 11;
self.b_shirt = 2;
return "FrikBot";
}
else if (r == 14)
{
} else if (r == 14) {
self.b_pants = 0;
self.b_shirt = 2;
return "Krosis";
}
else if (r == 15)
{
} else if (r == 15) {
self.b_pants = 8;
self.b_shirt = 9;
return "Gypsy";
}
else if (r == 16)
{
} else if (r == 16) {
self.b_pants = 5;
self.b_shirt = 10;
return "Hal";
@ -161,8 +130,7 @@ string () PickARandomName =
local string h;
local entity t;
y = TRUE;
while(y)
{
while(y) {
test = ceil(random() * 16);
h = BotName(test);
t = find(NIL, netname, h);
@ -200,12 +168,10 @@ b_originator == targ
*/
void(float tpic) bot_start_topic =
{
if (random() < 0.2)
{
if (random() < 0.2) {
b_topic = tpic;
b_originator = self;
}
else
} else
b_topic = 0;
};
@ -216,54 +182,35 @@ void() bot_chat =
return;
r = ceil (random() * 6);
if (self.b_chattime > time)
{
if (self.b_chattime > time) {
if (self.b_skill < 2)
self.keys = self.button0 = self.button2 = 0;
return;
}
else if (self.b_chattime)
{
if (b_topic == 1)
{
if (b_originator == self)
{
if (r == 1)
{
} else if (self.b_chattime) {
if (b_topic == 1) {
if (b_originator == self) {
if (r == 1) {
BotSay(": lo all\n");
bot_start_topic(8);
}
else if (r == 2)
{
} else if (r == 2) {
BotSay(": hey everyone\n");
bot_start_topic(8);
}
else if (r == 3)
{
} else if (r == 3) {
BotSay(": prepare to be fragged!\n");
bot_start_topic(0);
}
else if (r == 4)
{
} else if (r == 4) {
BotSay(": boy this is laggy\n");
bot_start_topic(11);
}
else if (r == 5)
{
} else if (r == 5) {
BotSay(": #mm getting some lag here\n");
bot_start_topic(11);
}
else
{
} else {
BotSay(": hi everyone\n");
bot_start_topic(8);
}
}
}
else if (b_topic == 2)
{
if (b_originator == self)
{
} else if (b_topic == 2) {
if (b_originator == self) {
if (r == 1)
BotSay(": take that\n");
else if (r == 2)
@ -278,78 +225,53 @@ void() bot_chat =
BotSay(": eat that\n");
bot_start_topic(0);
}
}
else if (b_topic == 3)
{
if (b_originator == self)
{
} else if (b_topic == 3) {
if (b_originator == self) {
if (r < 3)
BotSayTeam(": friendly eyes\n");
else
BotSayTeam(": team eyes\n");
bot_start_topic(0);
}
}
else if (b_topic == 4)
{
if (b_originator == self)
{
} else if (b_topic == 4) {
if (b_originator == self) {
if (r < 3)
BotSayTeam(": on your back\n");
else
BotSayTeam(": I'm with you\n");
bot_start_topic(0);
}
}
else if (b_topic == 5)
{
if (b_originator == self)
{
} else if (b_topic == 5) {
if (b_originator == self) {
if (r < 3)
BotSayTeam(": I need help\n");
else
BotSayTeam(": need backup\n");
bot_start_topic(0);
}
}
else if (b_topic == 6)
{
if (b_originator == self)
{
if (r == 1)
{
} else if (b_topic == 6) {
if (b_originator == self) {
if (r == 1) {
BotSay(": sun got in my eyes\n");
bot_start_topic(0);
}
else if (r == 2)
{
} else if (r == 2) {
BotSay(": mouse needs cleaning\n");
bot_start_topic(0);
}
else if (r == 3)
{
} else if (r == 3) {
BotSay(": i meant to do that\n");
bot_start_topic(0);
}
else if (r == 4)
{
} else if (r == 4) {
BotSay(": lag\n");
bot_start_topic(11);
}
else if (r == 5)
{
} else if (r == 5) {
BotSay(": killer lag\n");
bot_start_topic(11);
}
else
{
} else {
BotSay(": 100% lag\n");
bot_start_topic(11);
}
}
}
else if (b_topic == 7)
{
} else if (b_topic == 7) {
if (r == 1)
BotSay(": gg\n");
else if (r == 2)
@ -363,161 +285,111 @@ void() bot_chat =
else
BotSay(": hrm\n");
bot_start_topic(0);
}
else if (b_topic == 8)
{
if (b_originator != self)
{
if (r == 1)
{
} else if (b_topic == 8) {
if (b_originator != self) {
if (r == 1) {
BotSay(": heya\n");
bot_start_topic(0);
}
else if (r == 2)
{
} else if (r == 2) {
BotSay(": welcome\n");
bot_start_topic(0);
}
else if (r == 3)
{
} else if (r == 3) {
BotSayInit();
BotSay2(": hi ");
BotSay2(b_originator.netname);
BotSay2("\n");
bot_start_topic(0);
}
else if (r == 4)
{
} else if (r == 4) {
BotSayInit();
BotSay2(": hey ");
BotSay2(b_originator.netname);
BotSay2("\n");
bot_start_topic(0);
}
else if (r == 5)
{
} else if (r == 5) {
BotSay(": howdy\n");
bot_start_topic(0);
}
else
{
} else {
BotSay(": lo\n");
bot_start_topic(0);
}
}
}
else if (b_topic == 9)
{
if (b_originator != self)
{
} else if (b_topic == 9) {
if (b_originator != self) {
if (r == 1)
BotSay(": hah\n");
else if (r == 2)
BotSay(": heheh\n");
else if (r == 3)
{
else if (r == 3) {
BotSayInit();
BotSay2(": good work ");
BotSay2(b_originator.netname);
BotSay2("\n");
}
else if (r == 4)
{
} else if (r == 4) {
BotSayInit();
BotSay2(": nice1 ");
BotSay2(b_originator.netname);
BotSay2("\n");
}
else if (r == 5)
} else if (r == 5)
BotSay(": lol\n");
else
BotSay(": :)\n");
b_topic = 6;
}
}
else if (b_topic == 10)
{
if (b_originator != self)
{
} else if (b_topic == 10) {
if (b_originator != self) {
if (r == 1)
BotSay(": have a nice dip?\n");
else if (r == 2)
BotSay(": bah I hate levels with lava\n");
else if (r == 3)
{
else if (r == 3) {
BotSayInit();
BotSay2(": good job ");
BotSay2(b_originator.netname);
BotSay2("\n");
}
else if (r == 4)
{
} else if (r == 4) {
BotSayInit();
BotSay2(": nice backflip ");
BotSay2(b_originator.netname);
BotSay2("\n");
}
else if (r == 5)
} else if (r == 5)
BotSay(": watch your step\n");
else
BotSay(": hehe\n");
b_topic = 6;
}
}
else if (b_topic == 11)
{
if (b_originator != self)
{
if (r == 1)
{
} else if (b_topic == 11) {
if (b_originator != self) {
if (r == 1) {
BotSayInit();
BotSay2(": yeah right ");
BotSay2(b_originator.netname);
BotSay2("\n");
bot_start_topic(0);
}
else if (r == 2)
{
} else if (r == 2) {
BotSay(": ping\n");
bot_start_topic(0);
}
else if (r == 3)
{
} else if (r == 3) {
BotSay(": shuddup, you're an lpb\n");
bot_start_topic(0);
}
else if (r == 4)
{
} else if (r == 4) {
BotSay(": lag my eye\n");
bot_start_topic(0);
}
else if (r == 5)
{
} else if (r == 5) {
BotSay(": yeah\n");
bot_start_topic(11);
}
else
{
} else {
BotSay(": totally\n");
bot_start_topic(11);
}
}
}
self.b_chattime = 0;
}
else if (b_topic)
{
if (random() < 0.5)
{
if (self == b_originator)
{
} else if (b_topic) {
if (random() < 0.5) {
if (self == b_originator) {
if (b_topic <= 7)
self.b_chattime = time + 2;
}
else
{
} else {
if (b_topic >= 7)
self.b_chattime = time + 2;
}
@ -537,16 +409,13 @@ void() KickABot =
{
local entity ty;
ty = find(NIL, classname, "player");
while (ty != NIL)
{
if (!(ty.ishuman))
{
while (ty != NIL) {
if (!(ty.ishuman)) {
BotDisconnect(ty);
ty.ishuman = TRUE;
ty = NIL;
}
else
} else
ty = find(ty, classname, "player");
}
@ -588,17 +457,14 @@ float (entity targ) fisible =
org = realorigin(targ);
spot1 = self.origin + self.view_ofs;
if (targ.solid == SOLID_BSP)
{
if (targ.solid == SOLID_BSP) {
traceline (spot1, org, TRUE, self);
if (trace_ent == targ)
return TRUE;
else if (trace_fraction == 1)
return TRUE;
return FALSE;
}
else
{
} else {
pc1 = pointcontents(org);
pc2 = pointcontents(spot1);
if (targ.classname == "player")
@ -609,10 +475,9 @@ float (entity targ) fisible =
thruwater = TRUE;
}
if (pc1 < -1) // targ's origin is in water or other liquid
{
if (pc2 != pc1)
{
if (pc1 < -1) {
// targ's origin is in water or other liquid
if (pc2 != pc1) {
// look for their head
traceline (spot1, org + targ.mins, TRUE, self);
// cross the water check
@ -626,11 +491,8 @@ float (entity targ) fisible =
return TRUE;
return FALSE;
}
}
else
{
if (pc2 != pc1)
{
} else {
if (pc2 != pc1) {
traceline (spot1, org + targ.maxs, TRUE, self);
if (trace_inopen)
if (trace_inwater)
@ -683,8 +545,7 @@ float (entity targ1, entity targ2) wisible =
spot2 = realorigin(targ2);
ignore = self;
do
{
do {
traceline (spot1, spot2, TRUE, ignore);
spot1 = realorigin(trace_ent);
ignore = trace_ent;

View file

@ -84,24 +84,19 @@ 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 != NIL)
{
if (flag) // afect bot movement too
{
if (self.keys & KEY_MOVEUP)
{
if (trace_ent != NIL) {
if (flag) {
// afect bot movement too
if (self.keys & KEY_MOVEUP) {
if (trace_ent.velocity_z > 0)
self.keys = self.keys & 960; // 960 is all view keys
}
else if (self.keys & KEY_MOVEDOWN)
{
} else if (self.keys & KEY_MOVEDOWN) {
if (trace_ent.velocity_z < 0)
self.keys = self.keys & 960;
}
}
return TRUE;
}
else
} else
return FALSE;
};
@ -111,8 +106,7 @@ float(vector sdir) frik_KeysForDir =
local vector keydir;
local float outkeys, tang;
outkeys = 0;
if (sdir_x || sdir_y)
{
if (sdir_x || sdir_y) {
// Everything is tested against 60 degrees,
// this allows the bot to overlap the keys
// 30 degrees on each diagonal 45 degrees
@ -157,8 +151,7 @@ void(vector whichway, float danger) frik_obstructed =
return;
org = realorigin(self.target1);
if (danger)
{
if (danger) {
self.b_aiflags = self.b_aiflags | AI_DANGER;
self.keys = frik_KeysForDir('0 0 0' - whichway);
}
@ -166,16 +159,12 @@ void(vector whichway, float danger) frik_obstructed =
return;
if (self.target1)
{
if (self.b_aiflags & AI_OBSTRUCTED)
{
if (!(self.b_aiflags & AI_DANGER))
{
if (self.target1) {
if (self.b_aiflags & AI_OBSTRUCTED) {
if (!(self.b_aiflags & AI_DANGER)) {
self.b_aiflags = self.b_aiflags - AI_OBSTRUCTED;
return;
}
else if (!danger)
} else if (!danger)
return;
}
self.obs_dir = whichway;
@ -188,9 +177,7 @@ void(vector whichway, float danger) frik_obstructed =
self.wallhug = (vlen(org - (self.origin + disway)) > dist) ? 1.0 : 0.0;
self.b_aiflags = self.b_aiflags | AI_OBSTRUCTED;
}
else
{
} else {
disway_x = whichway_y * -1;
disway_y = whichway_x;
disway_z = 0;
@ -238,8 +225,7 @@ void() frik_obstacles =
return;
hgt = trace_endpos_z - stop_z;
if (hgt > 18)
{
if (hgt > 18) {
bot_jump();
return;
}
@ -262,17 +248,14 @@ void() frik_obstacles =
ang = self.velocity;
ang_z = 0;
dist = ((540 / sv_gravity) * vlen(ang))/* + 32*/;
if (test > dist) // I can't make it
{
if (conts < -3) // bad stuff down dare
{
if (test > dist) {
// I can't make it
if (conts < -3) {
// bad stuff down dare
frik_obstructed(ang, TRUE);
return;
}
else
{
if (self.target1)
{
} else {
if (self.target1) {
stop = realorigin(self.target1);
if ((stop_z - self.origin_z) < -32)
return; // safe to fall
@ -280,23 +263,17 @@ void() frik_obstacles =
frik_obstructed(ang, FALSE);
return;
}
}
else
{
} else {
ang = normalize(ang);
//look for a ledge
traceline(self.origin, self.origin + (ang * (test + 20)), TRUE, self);
if (trace_fraction != 1)
{
if (conts < -3) // bad stuff down dare
{
if (trace_fraction != 1) {
if (conts < -3) {
// bad stuff down dare
frik_obstructed(ang, TRUE);
return;
}
else
{
if (self.target1)
{
} else {
if (self.target1) {
stop = realorigin(self.target1);
if ((stop_z - self.origin_z) < -32)
return; // safe to fall
@ -306,29 +283,23 @@ void() frik_obstacles =
}
}
if (self.target1)
{
if (self.target1) {
// getting furter away from my target?
test = vlen(self.target1.origin - (ang + self.origin));
if (test > vlen(self.target1.origin - self.origin))
{
if (conts < -3) // bad stuff down dare
{
if (test > vlen(self.target1.origin - self.origin)) {
if (conts < -3) {
// bad stuff down dare
frik_obstructed(ang, TRUE);
return;
}
else
{
} else {
frik_obstructed(ang, FALSE);
return;
}
}
}
}
if (hgt < -18)
{
if (self.target1)
{
if (hgt < -18) {
if (self.target1) {
stop = realorigin(self.target1);
if ((stop_z - self.origin_z) < -32)
return; // safe to fall
@ -357,8 +328,7 @@ void() frik_dodge_obstruction =
if (!(self.b_aiflags & AI_OBSTRUCTED))
return;
if ((self.b_aiflags & (AI_BLIND | AI_PRECISION)) || !(self.flags & FL_ONGROUND))
{
if ((self.b_aiflags & (AI_BLIND | AI_PRECISION)) || !(self.flags & FL_ONGROUND)) {
self.b_aiflags = self.b_aiflags - AI_OBSTRUCTED;
return;
}
@ -373,19 +343,13 @@ void() frik_dodge_obstruction =
yaw = vectoyaw(self.obs_dir);
if (walkmove(yaw, 32))
self.b_aiflags = self.b_aiflags - AI_OBSTRUCTED;
else
{
if (self.b_aiflags & AI_DANGER)
{
else {
if (self.b_aiflags & AI_DANGER) {
way = '0 0 0' - self.obs_dir;
}
else if (self.wallhug)
{
} else if (self.wallhug) {
way_x = self.obs_dir_y * -1;
way_y = self.obs_dir_x;
}
else
{
} else {
way_x = self.obs_dir_y;
way_y = self.obs_dir_x * -1;
}
@ -414,15 +378,13 @@ void() frik_movetogoal =
local vector way;
local float g;
if (self.target1 == NIL)
{
if (self.target1 == NIL) {
makevectors(self.v_angle);
frik_walkmove(v_forward);
return;
}
way = realorigin(self.target1) - self.origin;
if (vlen(way) < 25)
{
if (vlen(way) < 25) {
self.keys = self.keys & 960;
return;
}
@ -433,8 +395,7 @@ void() frik_movetogoal =
frik_dodge_obstruction();
frik_recognize_plat(TRUE);
if (self.b_aiflags & AI_PRECISION)
{
if (self.b_aiflags & AI_PRECISION) {
g = angcomp(self.v_angle_x, self.b_angle_x);
if (fabs(g) > 10)
self.keys = self.keys & 960;
@ -480,8 +441,7 @@ void() frik_bot_roam =
loopcount = 26;
flag = FALSE;
while((loopcount > 0) && !flag)
{
while((loopcount > 0) && !flag) {
loopcount = loopcount - 1;
org = self.origin + self.view_ofs;
ang = self.angles;
@ -489,23 +449,19 @@ void() frik_bot_roam =
ang_x = 0; // avoid upward sloping
makevectors(ang);
traceline(org, org + v_forward * 2300, TRUE, self);
if (trace_fraction != 1)
{
if (trace_fraction != 1) {
org1 = trace_endpos;
ang = normalize(trace_plane_normal);
ang_z = 0; // avoid upward sloping
traceline(org1, org1 + (ang * 2300), TRUE, self);
if ((trace_fraction != 1) && (vlen(trace_endpos - org1) >= 64))
{
if ((trace_fraction != 1) && (vlen(trace_endpos - org1) >= 64)) {
org = trace_endpos;
traceline(org, self.origin + self.view_ofs, TRUE, self);
if (trace_fraction != 1)
{
if (trace_fraction != 1) {
dist = vlen(org1 - org) /2;
org = org1 + (ang * dist);
traceline(org, org - '0 0 48', TRUE, self);
if (trace_fraction != 1)
{
if (trace_fraction != 1) {
SpawnTempWaypoint(org);
flag = TRUE;
}

View file

@ -65,8 +65,7 @@ void() CL_KeyMove = // CL_BaseMove + CL_AdjustAngles
{
local float anglespeed;
local vector view;
if (self.keys != self.oldkeys)
{
if (self.keys != self.oldkeys) {
self.movevect = '0 0 0';
self.movevect_y = self.movevect_y + (350 * CL_KeyState(KEY_MOVERIGHT));
// 350 is the default cl_sidespeed
@ -86,8 +85,8 @@ void() CL_KeyMove = // CL_BaseMove + CL_AdjustAngles
}
self.oldkeys = self.keys;
if (self.b_skill != 2) // use mouse emulation
{
if (self.b_skill != 2) {
// use mouse emulation
anglespeed = 1.5 * real_frametime;
// 1.5 is the default cl_anglespeedkey & bot always has +speed
self.v_angle_y = self.v_angle_y + anglespeed * CL_KeyState(KEY_LOOKLEFT) * 140;
@ -98,19 +97,15 @@ void() CL_KeyMove = // CL_BaseMove + CL_AdjustAngles
// 150 is default cl_pitchspeed
self.v_angle_x = self.v_angle_x + anglespeed * CL_KeyState(KEY_LOOKDOWN) * 150;
// 150 is default cl_pitchspeed
}
else
{
} else {
view_x = angcomp(self.b_angle_x, self.v_angle_x);
view_y = angcomp(self.b_angle_y, self.v_angle_y);
view_z = 0;
if (vlen(view) > 30)
{
if (vlen(view) > 30) {
self.mouse_emu = self.mouse_emu + (view * 30);
if (vlen(self.mouse_emu) > 180)
self.mouse_emu = normalize(self.mouse_emu) * 180;
}
else
} else
self.mouse_emu = view * (1 / real_frametime);
self.v_angle = self.v_angle + self.mouse_emu * real_frametime;
@ -176,8 +171,7 @@ void() SV_UserFriction =
};
void() SV_WaterJump =
{
if (time > self.teleport_time || !self.waterlevel)
{
if (time > self.teleport_time || !self.waterlevel) {
self.flags = self.flags - (self.flags & FL_WATERJUMP);
self.teleport_time = 0;
}
@ -246,22 +240,19 @@ void() SV_WaterMove =
wishvel_z = wishvel_z + self.movevect_z;
wishspeed = vlen(wishvel);
if (wishspeed > sv_maxspeed)
{
if (wishspeed > sv_maxspeed) {
wishvel = (sv_maxspeed / wishspeed) * wishvel;
wishspeed = sv_maxspeed;
}
wishspeed = wishspeed * 0.7;
cspeed = vlen(self.velocity);
if (cspeed)
{
newspeed = cspeed - (real_frametime * cspeed * sv_friction);
if (cspeed) {
newspeed = cspeed - (real_frametime * cspeed * sv_friction);
if (newspeed < 0)
newspeed = 0;
self.velocity = self.velocity * (newspeed / cspeed);
self.velocity = self.velocity * (newspeed / cspeed);
}
else
} else
newspeed = 0;
if (!wishspeed)
@ -295,12 +286,10 @@ void() SV_AirMove =
wishvel = normalize(wishvel) * sv_maxspeed;
if (self.movetype == MOVETYPE_NOCLIP)
self.velocity = wishvel;
else if (self.flags & FL_ONGROUND)
{
else if (self.flags & FL_ONGROUND) {
SV_UserFriction();
SV_Accelerate(wishvel);
}
else
} else
SV_AirAccelerate (wishvel);
};
@ -316,22 +305,18 @@ void() SV_ClientThink =
self.v_angle_z = 0; // V_CalcRoll removed, sucks
self.angles_z = self.v_angle_z * 4;
vangle = self.v_angle + self.punchangle;
if (!self.fixangle)
{
self.angles_x = (vangle_x / -3);
if (!self.fixangle) {
self.angles_x = (vangle_x / -3);
self.angles_y = vangle_y;
} else
{
} else {
self.v_angle = self.angles;
self.fixangle = 0;
}
if (self.flags & FL_WATERJUMP)
{
if (self.flags & FL_WATERJUMP) {
SV_WaterJump();
return;
}
if ((self.waterlevel >= 2) && (self.movetype != MOVETYPE_NOCLIP))
{
if ((self.waterlevel >= 2) && (self.movetype != MOVETYPE_NOCLIP)) {
SV_WaterMove();
return;
}
@ -380,14 +365,12 @@ float() SV_CheckWater =
self.watertype = CONTENT_EMPTY;
point_z = self.origin_z + self.mins_z + 1;
cont = pointcontents(point);
if (cont <= CONTENT_WATER)
{
self.watertype = cont;
self.waterlevel = 1;
if (cont <= CONTENT_WATER) {
self.watertype = cont;
self.waterlevel = 1;
point_z = self.origin_z + (self.mins_z + self.maxs_z) * 0.5;
cont = pointcontents(point);
if (cont <= CONTENT_WATER)
{
if (cont <= CONTENT_WATER) {
self.waterlevel = 2;
point_z = self.origin_z + self.view_ofs_z;
cont = pointcontents(point);
@ -401,17 +384,12 @@ float() SV_CheckWater =
void() RemoveThud = // well sometimes
{
local entity oself;
if (other == NIL)
{
if (self.flags & FL_ONGROUND)
{
if (other == NIL) {
if (self.flags & FL_ONGROUND) {
self.flags = self.flags - FL_ONGROUND;
}
}
else
{
if (other.solid == SOLID_BSP && (self.flags & FL_ONGROUND))
{
} else {
if (other.solid == SOLID_BSP && (self.flags & FL_ONGROUND)) {
// RM: Does this break anything?
// If not, then some more thuds have been removed.
self.flags = self.flags - FL_ONGROUND;
@ -449,7 +427,7 @@ void() SV_CheckOnGround =
self.flags = self.flags - FL_ONGROUND;
else if ((trace_plane_normal_z <= 0.7) && (trace_fraction != 1))
self.flags = self.flags - FL_ONGROUND;
else if (!droptofloor ())
else if (!droptofloor ())
self.flags = self.flags - FL_ONGROUND;
else if (org_z - self.origin_z < 2)
self.flags = self.flags | FL_ONGROUND;
@ -469,16 +447,13 @@ float(vector dir) botCheckForStep =
dir = normalize(dir);
dir_z = 0;
yaw = vectoyaw(dir);
if(walkmove(yaw, 3))
{
if(droptofloor ())
{
if(walkmove(yaw, 3)) {
if(droptofloor ()) {
stepdistance = self.origin_z - currentorigin_z;
v = self.origin - currentorigin;
v_z = 0;
movedistance = vlen(v);
if((stepdistance > 0 && stepdistance <= 16) && movedistance != 0)
{
if((stepdistance > 0 && stepdistance <= 16) && movedistance != 0) {
self.flags = currentflags | FL_PARTIALGROUND;
return 1;
}
@ -502,8 +477,7 @@ void(vector dir) BruteForceStep =
setorigin(self, currentorigin + dir);
while(i < 18 && !walkmove(0, 0))
{
while(i < 18 && !walkmove(0, 0)) {
self.origin_z = currentorigin_z + i;
i = i + 2;
}
@ -520,35 +494,27 @@ void() PostPhysics =
self = self.owner;
self.velocity = self.velocity - self.phys_obj.dest1 + self.phys_obj.velocity;
if (self.phys_obj.dest2 == self.origin)
{
if (self.phys_obj.dest2 == self.origin) {
setorigin(self, self.phys_obj.origin);
// might've been moved during other person's physics
// (teleporters / plats)
if (self.movetype == MOVETYPE_WALK)
{
if (self.movetype == MOVETYPE_WALK) {
if (self.phys_obj.dest1_x || self.phys_obj.dest1_y)
{
if ((self.flags & FL_ONGROUND) || (self.waterlevel <= 2))
{
if (self.phys_obj.dest1_x || self.phys_obj.dest1_y) {
if ((self.flags & FL_ONGROUND) || (self.waterlevel <= 2)) {
obstr = self.phys_obj.movedir - self.origin;
obstr_z = 0;
if (vlen(obstr) > 0.1)
{
if (vlen(obstr) > 0.1) {
dst = vlen(obstr);
back = vectoyaw(obstr);
cflags = self.flags;
self.flags = self.flags | FL_PARTIALGROUND;
if(walkmove(back, dst))
{
if(walkmove(back, dst)) {
self.flags = cflags;
self.phys_obj.dest1_z = 0;
self.velocity = self.velocity + self.phys_obj.dest1 - self.phys_obj.velocity;
}
else
{
} else {
if (dst > 1)
frik_obstructed(obstr, FALSE);
@ -556,12 +522,10 @@ void() PostPhysics =
self.flags = cflags;
obstr = self.phys_obj.dest1;
obstr_x = 0;
if (!botCheckForStep(obstr))
{
if (!botCheckForStep(obstr)) {
obstr = self.phys_obj.dest1;
obstr_y = 0;
if (!botCheckForStep(obstr))
{
if (!botCheckForStep(obstr)) {
// if no steps were found, bot is really obstucted
BruteForceStep(self.phys_obj.dest1);
}
@ -587,14 +551,11 @@ void() SV_FlyMove =
{
// This is nothing like the Quake function.
if (self.phys_obj == NIL)
{
if (self.phys_obj == NIL) {
self.phys_obj = find(NIL,classname,"phys_obj");
while (self.phys_obj.owner != self)
{
while (self.phys_obj.owner != self) {
self.phys_obj = find(self.phys_obj,classname,"phys_obj");
if (self.phys_obj == NIL)
{
if (self.phys_obj == NIL) {
error("No physics entity spawned!\nMake sure BotInit was called\n");
}
}
@ -621,8 +582,7 @@ void() SV_Physics_Toss =
{
if (!SV_RunThink())
return;
if (self.flags & FL_ONGROUND)
{
if (self.flags & FL_ONGROUND) {
self.velocity = '0 0 0';
BotAI();
return;
@ -638,42 +598,32 @@ void() SV_Physics_Client =
PlayerPreThink();
if (self.movetype == MOVETYPE_NONE)
{
if (self.movetype == MOVETYPE_NONE) {
if (!SV_RunThink())
return;
PlayerPostThink();
BotAI();
}
else if ((self.movetype == MOVETYPE_WALK) || (self.movetype == MOVETYPE_STEP))
{
} else if ((self.movetype == MOVETYPE_WALK) || (self.movetype == MOVETYPE_STEP)) {
if (!SV_RunThink())
return;
if (!(SV_CheckWater()) && (!(self.flags & FL_WATERJUMP)))
SV_AddGravity(1);
SV_FlyMove();
}
else if ((self.movetype == MOVETYPE_TOSS) || (self.movetype == MOVETYPE_BOUNCE))
{
} else if ((self.movetype == MOVETYPE_TOSS) || (self.movetype == MOVETYPE_BOUNCE)) {
SV_Physics_Toss();
}
else if (self.movetype == MOVETYPE_FLY)
{
} else if (self.movetype == MOVETYPE_FLY) {
if (!SV_RunThink())
return;
SV_FlyMove();
}
else if (self.movetype == MOVETYPE_NOCLIP)
{
} else if (self.movetype == MOVETYPE_NOCLIP) {
if (!SV_RunThink())
return;
self.origin = self.origin + real_frametime * self.velocity;
PlayerPostThink();
BotAI();
}
else
} else
error ("SV_Physics_Client: Bad Movetype (BOT)");
};

View file

@ -185,10 +185,8 @@ void() ClientFixRankings =
b_temp2 = nextent(NIL);
cno = 0;
while (cno < max_clients)
{
if (!b_temp2.ishuman)
{
while (cno < max_clients) {
if (!b_temp2.ishuman) {
if (players[cno])
UpdateClient(b_temp2);
}
@ -209,8 +207,7 @@ void() ClientInRankings =
self.phys_obj = phys_objects[cl_no];
if (self.ishuman == 2)
{
if (self.ishuman == 2) {
self.ishuman = FALSE;
return;
}
@ -241,20 +238,16 @@ float () BotPreFrame =
if (self.ishuman)
if (self.switch_wallhug)
ClientFixRankings();
if (self.b_frags != self.frags)
{
if (self.b_frags > self.frags)
{
if (self.b_frags != self.frags) {
if (self.b_frags > self.frags) {
if (pointcontents(self.origin) == CONTENT_LAVA)
bot_start_topic(10);
else
bot_start_topic(9);
}
else
} else
bot_start_topic(2);
self.b_frags = self.frags;
if (!self.ishuman)
{
if (!self.ishuman) {
WriteByte(2, 14);
WriteByte(2, (float)self.b_clientno);
WriteShort(2, self.frags);
@ -327,15 +320,13 @@ void() BotInit =
ent = nextent(NIL);
max_clients = 0;
while(ent != NIL)
{
while(ent != NIL) {
max_clients = max_clients + 1;
ent = nextent(ent);
}
ent = nextent(NIL);
while (numents < max_clients)
{
while (numents < max_clients) {
phys_objects[numents] = spawn();
phys_objects[numents].classname = "phys_obj";
@ -382,8 +373,7 @@ float(integer clientno) ClientBitFlag =
{
local float bitflag;
bitflag = 1;
while(clientno > 0)
{
while(clientno > 0) {
bitflag = bitflag * 2;
clientno = clientno - 1;
}
@ -395,8 +385,7 @@ integer() ClientNextAvailable =
local integer clientno;
// I want to do this top down, but QW won't let me
clientno = 0;
while(clientno < max_clients)
{
while(clientno < max_clients) {
clientno = clientno + 1;
//FIXME if(!ClientIsActive(clientno))
@ -420,8 +409,7 @@ entity(float num) GetClientEntity =
local entity upsy;
upsy = NIL;
num = num + 1;
while (num > 0)
{
while (num > 0) {
num = num - 1;
upsy = nextent(upsy);
}
@ -490,8 +478,7 @@ void(entity bot) BotDisconnect =
ClientDisconnect();
if (self.b_clientno != -1)
{
if (self.b_clientno != -1) {
// the bot's client number is not in use by a real player so we
// must remove it's entry in the rankings
// Quake engine sets all fields to 0, can only do the most important here
@ -530,21 +517,16 @@ void() BotFrame =
self = nextent(NIL);
num = 0;
while (num < max_clients)
{
if (self.ishuman == FALSE)
{
if (self.b_clientno > 0)
{
while (num < max_clients) {
if (self.ishuman == FALSE) {
if (self.b_clientno > 0) {
frik_obstacles();
CL_KeyMove();
SV_ClientThink();
SV_Physics_Client();
// this is sickening
if (self.phys_obj)
{
if (self.phys_obj.modelindex != self.modelindex)
{
if (self.phys_obj) {
if (self.phys_obj.modelindex != self.modelindex) {
setmodel(self.phys_obj, "progs/player.mdl");
self.phys_obj.modelindex = self.modelindex;
}
@ -574,13 +556,11 @@ void() BotImpulses =
local float f;
local string h;
if (self.impulse == 100)
{
if (self.impulse == 100) {
h = infokey(NIL, "skill");
f = stof(h);
BotConnect(0, f);
}
else if (self.impulse == 102)
} else if (self.impulse == 102)
KickABot();
else
return;

View file

@ -59,32 +59,28 @@ float (entity e1, entity e2) CheckLinked =
{
if ((e1 == e2) || (e2 == NIL) || (e1 == NIL))
return FALSE;
else if (e1.target1 == e2)
{
else if (e1.target1 == e2) {
if (e1.b_aiflags & AI_TELELINK_1)
return 2;
else return TRUE;
}
else if (e1.target2 == e2)
{
else
return TRUE;
} else if (e1.target2 == e2) {
if (e1.b_aiflags & AI_TELELINK_2)
return 2;
else return TRUE;
}
else if (e1.target3 == e2)
{
else
return TRUE;
} else if (e1.target3 == e2) {
if (e1.b_aiflags & AI_TELELINK_3)
return 2;
else return TRUE;
}
else if (e1.target4 == e2)
{
else
return TRUE;
} else if (e1.target4 == e2) {
if (e1.b_aiflags & AI_TELELINK_4)
return 2;
else return TRUE;
}
else return FALSE;
else
return TRUE;
} else
return FALSE;
};
@ -95,23 +91,16 @@ float (entity e1, entity e2) LinkWays =
else if (CheckLinked(e1, e2))
return FALSE; // already linked!!!
if (e1.target1 == NIL)
{
if (e1.target1 == NIL) {
e1.target1 = e2;
return TRUE;
}
else if (e1.target2 == NIL)
{
} else if (e1.target2 == NIL) {
e1.target2 = e2;
return TRUE;
}
else if (e1.target3 == NIL)
{
} else if (e1.target3 == NIL) {
e1.target3 = e2;
return TRUE;
}
else if (e1.target4 == NIL)
{
} else if (e1.target4 == NIL) {
e1.target4 = e2;
return TRUE;
}
@ -127,26 +116,19 @@ float (entity e1, entity e2) TeleLinkWays =
else if (CheckLinked(e1, e2))
return FALSE; // already linked!!!
if (e1.target1 == NIL)
{
if (e1.target1 == NIL) {
e1.target1 = e2;
e1.b_aiflags = e1.b_aiflags | AI_TELELINK_1;
return TRUE;
}
else if (e1.target2 == NIL)
{
} else if (e1.target2 == NIL) {
e1.target2 = e2;
e1.b_aiflags = e1.b_aiflags | AI_TELELINK_2;
return TRUE;
}
else if (e1.target3 == NIL)
{
} else if (e1.target3 == NIL) {
e1.target3 = e2;
e1.b_aiflags = e1.b_aiflags | AI_TELELINK_3;
return TRUE;
}
else if (e1.target4 == NIL)
{
} else if (e1.target4 == NIL) {
e1.target4 = e2;
e1.b_aiflags = e1.b_aiflags | AI_TELELINK_4;
return TRUE;
@ -163,23 +145,19 @@ void (entity e1, entity e2) UnlinkWays =
else if (!CheckLinked(e1, e2))
return;
if (e1.target1 == e2)
{
if (e1.target1 == e2) {
e1.b_aiflags = e1.b_aiflags - (e1.b_aiflags & AI_TELELINK_1);
e1.target1 = NIL;
}
if (e1.target2 == e2)
{
if (e1.target2 == e2) {
e1.b_aiflags = e1.b_aiflags - (e1.b_aiflags & AI_TELELINK_2);
e1.target2 = NIL;
}
if (e1.target3 == e2)
{
if (e1.target3 == e2) {
e1.b_aiflags = e1.b_aiflags - (e1.b_aiflags & AI_TELELINK_3);
e1.target3 = NIL;
}
if (e1.target4 == e2)
{
if (e1.target4 == e2) {
e1.b_aiflags = e1.b_aiflags - (e1.b_aiflags & AI_TELELINK_4);
e1.target4 = NIL;
}
@ -209,28 +187,21 @@ entity(entity start) FindWayPoint =
org = realorigin(self);
t = way_head;
if (start != NIL)
{
if (start != NIL) {
dst = vlen(start.origin - org);
best = start;
}
else
{
} else {
dst = 100000;
best = NIL;
}
while(t)
{
while(t) {
// real players cut through ignore types
if (dst < 20)
return best;
if (!(t.b_aiflags & AI_IGNORE_TYPES) || self.ishuman)
{
if (!(t.b_aiflags & AI_IGNORE_TYPES) || self.ishuman) {
tdst = vlen(t.origin - org);
if (tdst < dst)
{
if (sisible(t))
{
if (tdst < dst) {
if (sisible(t)) {
dst = tdst;
best = t;
}
@ -264,13 +235,10 @@ entity(vector org) make_waypoint =
setsize(point, VEC_HULL_MIN, VEC_HULL_MAX);
waypoints = waypoints + 1;
if (!way_head)
{
if (!way_head) {
way_head = point;
way_foot = point;
}
else
{
} else {
way_foot._next = point;
point._last = way_foot;
way_foot = point;
@ -296,13 +264,10 @@ void() DynamicWaypoint =
local entity t;
local float dist, dynlink = 0, dynpoint = 0, editor = 0;
if (self.teleport_time > self.portal_time)
{
if (!(self.flags & FL_WATERJUMP))
{
if (self.teleport_time > self.portal_time) {
if (!(self.flags & FL_WATERJUMP)) {
self.dyn_flags = 2;
if (!self.ishuman)
{
if (!self.ishuman) {
bot_lost(self.target1, TRUE);
self.enemy = NIL;
}
@ -314,23 +279,19 @@ void() DynamicWaypoint =
// convert waypoint_mode to something more usable..
if (waypoint_mode > WM_LOADED)
{
if (self.ishuman)
{
if (waypoint_mode > WM_LOADED) {
if (self.ishuman) {
if (waypoint_mode == WM_EDITOR_DYNLINK)
dynlink = 1;
else if (waypoint_mode == WM_EDITOR_DYNAMIC)
dynlink = dynpoint = 1;
editor = 1;
}
}
else if (waypoint_mode == WM_DYNAMIC)
} else if (waypoint_mode == WM_DYNAMIC)
dynlink = dynpoint = 1;
// if there's nothing for dynamic to do..
if (!dynpoint)
{
if (!dynpoint) {
if (!editor)
return;
}
@ -343,14 +304,10 @@ void() DynamicWaypoint =
if (max_clients < 2)
return;
// if you're dead
else if (self.health <= 0)
{
if (dynpoint)
{
if (self.current_way)
{
if (pointcontents(self.origin) < -4)
{
else if (self.health <= 0) {
if (dynpoint) {
if (self.current_way) {
if (pointcontents(self.origin) < -4) {
if (self.current_way.b_aiflags & AI_BLIND)
self.current_way.b_aiflags = self.current_way.b_aiflags | AI_PRECISION;
else
@ -365,12 +322,9 @@ void() DynamicWaypoint =
}
// you shouldn't be making waypoints mid air
if (dynpoint)
{
if (!((self.flags & FL_ONGROUND) || self.waterlevel == 3))
{
if (self.dyn_flags != 2)
{
if (dynpoint) {
if (!((self.flags & FL_ONGROUND) || self.waterlevel == 3)) {
if (self.dyn_flags != 2) {
self.dyn_flags = 1;
}
return;
@ -382,10 +336,8 @@ void() DynamicWaypoint =
self.dyn_time = time + 0.2;
// display the links for editor mode
if (editor)
{
if (self.current_way)
{
if (editor) {
if (self.current_way) {
if (self.current_way.target1)
DeveloperLightning(self.current_way, self.current_way.target1, self.current_way.b_aiflags & AI_TELELINK_1);
if (self.current_way.target2)
@ -400,20 +352,14 @@ void() DynamicWaypoint =
}
t = FindWayPoint(self.current_way);
if (t)
{
if (t) {
dist = vlen(self.origin - t.origin);
if (dist < 192)
{
if (dist < 64)
{
if (dist < 192) {
if (dist < 64) {
if (t != self.current_way)
{
if (dynlink)
{
if (!self.dyn_flags)
{
if (t != self.current_way) {
if (dynlink) {
if (!self.dyn_flags) {
if (wisible(t, self.current_way))
LinkWays(t, self.current_way);
}
@ -422,8 +368,7 @@ void() DynamicWaypoint =
else if (wisible(t, self.current_way))
LinkWays(self.current_way, t);
}
if (editor)
{
if (editor) {
setmodel(t, "progs/s_light.spr");
if (self.current_way)
setmodel(self.current_way, "progs/s_bubble.spr");
@ -437,21 +382,17 @@ void() DynamicWaypoint =
}
}
if (frik_recognize_plat(FALSE))
{
if (vlen(trace_ent.velocity) > 0)
{
if (frik_recognize_plat(FALSE)) {
if (vlen(trace_ent.velocity) > 0) {
if (self.dyn_plat)
return;
self.dyn_plat = TRUE;
if (!self.dyn_flags)
self.dyn_flags = 1;
//bprint("on a plat!!!!!\n");
}
else
} else
self.dyn_plat = FALSE;
}
else
} else
self.dyn_plat = FALSE;
if (self.dyn_flags == 2)
@ -462,8 +403,7 @@ void() DynamicWaypoint =
return;
t = make_waypoint(self.dyn_dest);
if (!self.dyn_flags)
{
if (!self.dyn_flags) {
if (wisible(t, self.current_way))
LinkWays(t, self.current_way);
}
@ -472,8 +412,7 @@ void() DynamicWaypoint =
else if (wisible(t, self.current_way))
LinkWays(self.current_way, t);
if (editor)
{
if (editor) {
setmodel(t, "progs/s_light.spr");
if (self.current_way)
setmodel(self.current_way, "progs/s_bubble.spr");
@ -483,8 +422,7 @@ void() DynamicWaypoint =
self.dyn_dest = self.origin + self.view_ofs;
if (frik_recognize_plat(FALSE))
{
if (frik_recognize_plat(FALSE)) {
if (trace_ent.classname == "door")
t.b_aiflags = t.b_aiflags | AI_DOORFLAG;
}
@ -503,8 +441,7 @@ void() ClearAllWays =
local entity t, n;
t = way_head;
while(t)
{
while(t) {
n = t._next;
remove(t);
t = n;
@ -521,8 +458,7 @@ entity(float num) WaypointForNum =
return NIL;
t = way_head;
while (t)
{
while (t) {
if (t.count == num)
return t;
t = t._next;
@ -538,8 +474,7 @@ void() FixThisWaypoint =
self.enemy.target4 = WaypointForNum(self.enemy.b_frags);
self.enemy = self.enemy._next;
self.nextthink = time;
if (self.enemy == NIL)
{
if (self.enemy == NIL) {
remove(self);
fixer = NIL;
}
@ -570,8 +505,7 @@ void(entity what) delete_waypoint =
what._next._last = what._last;
waypoints = 0;
t = way_head;
while(t)
{
while(t) {
t.count = waypoints = waypoints + 1;
if (CheckLinked(t, what))
UnlinkWays(t, what);
@ -600,11 +534,9 @@ entity(string s) FindThing =
dst = 100000;
best = NIL;
t = find (NIL, classname, s);
while (t != NIL)
{
while (t != NIL) {
tdst = vlen(((t.absmin + t.absmax) * 0.5) - self.origin);
if (tdst < dst)
{
if (tdst < dst) {
dst = tdst;
best = t;
}
@ -635,13 +567,10 @@ entity(entity lastone) FindRoute =
t = way_head;
dst = 100000;
best = NIL;
while(t)
{
while(t) {
tdst = vlen(t.origin - self.origin);
if ((tdst < dst) && (t.b_sound & flag))
{
if ((lastone == NIL) || (CheckLinked(lastone, t)))
{
if ((tdst < dst) && (t.b_sound & flag)) {
if ((lastone == NIL) || (CheckLinked(lastone, t))) {
dst = tdst;
best = t;
}
@ -664,8 +593,7 @@ void() ClearRouteTable =
local entity t;
t = way_head;
while (t)
{
while (t) {
t. keys = FALSE;
t.enemy = NIL;
t.items = -1; // not in table
@ -681,8 +609,7 @@ void() ClearMyRoute =
flag = ClientBitFlag(self.b_clientno);
t = way_head;
while (t)
{
while (t) {
t.b_sound = t.b_sound - (t.b_sound & flag);
t = t._next;
}
@ -718,8 +645,7 @@ void(entity this) mark_path =
if (this.classname != "player")
this.current_way = t;
if (t.enemy == NIL)
{
if (t.enemy == NIL) {
bot_lost(this, FALSE);
if (waypoint_mode == WM_DYNAMIC)
self.route_failed = TRUE;
@ -728,8 +654,7 @@ void(entity this) mark_path =
flag = ClientBitFlag(self.b_clientno);
while(t)
{
while(t) {
if (t.b_sound & flag)
return;
if (t == self.last_way)
@ -760,8 +685,7 @@ void(entity e2, float b_bit) FollowLink =
dist = vlen(self.origin - e2.origin) + self.items;
// check if this is an RJ link
if (e2.b_aiflags & AI_SUPER_JUMP)
{
if (e2.b_aiflags & AI_SUPER_JUMP) {
if (!bot_can_rj(route_table))
return;
}
@ -770,8 +694,7 @@ void(entity e2, float b_bit) FollowLink =
dist = dist + random() * 100; // add a little chaos
if ((dist < e2.items) || (e2.items == -1))
{
if ((dist < e2.items) || (e2.items == -1)) {
if (!e2.keys)
busy_waypoints = busy_waypoints + 1;
e2.keys = TRUE;
@ -789,35 +712,28 @@ void() WaypointThink =
if (self.items == -1)
return;
// can you say ugly?
if (self.b_aiflags & AI_TRACE_TEST)
{
if (self.target1)
{
if (self.b_aiflags & AI_TRACE_TEST) {
if (self.target1) {
traceline(self.origin, self.target1.origin, TRUE, self);
if (trace_fraction == 1)
FollowLink(self.target1, AI_TELELINK_1);
}
if (self.target2)
{
if (self.target2) {
traceline(self.origin, self.target2.origin, TRUE, self);
if (trace_fraction == 1)
FollowLink(self.target2, AI_TELELINK_2);
}
if (self.target3)
{
if (self.target3) {
traceline(self.origin, self.target3.origin, TRUE, self);
if (trace_fraction == 1)
FollowLink(self.target3, AI_TELELINK_3);
FollowLink(self.target3, AI_TELELINK_3);
}
if (self.target4)
{
if (self.target4) {
traceline(self.origin, self.target4.origin, TRUE, self);
if (trace_fraction == 1)
FollowLink(self.target4, AI_TELELINK_4);
}
}
else
{
} else {
if (self.target1)
FollowLink(self.target1, AI_TELELINK_1);
if (self.target2)
@ -831,10 +747,8 @@ void() WaypointThink =
busy_waypoints = busy_waypoints - 1;
self.keys = FALSE;
if (busy_waypoints <= 0)
{
if (direct_route)
{
if (busy_waypoints <= 0) {
if (direct_route) {
oself = self;
self = route_table;
bot_get_path(self.target1, FALSE);
@ -866,10 +780,8 @@ float() begin_route =
if (busy_waypoints > 0)
return FALSE;
if (route_table != NIL)
{
if (!route_table.ishuman)
{
if (route_table != NIL) {
if (!route_table.ishuman) {
if (route_table.b_clientno != -1)
return FALSE;
}
@ -879,17 +791,14 @@ float() begin_route =
ClearRouteTable();
self.last_way = FindWayPoint(self.current_way);
if (self.last_way != NIL)
{
if (self.last_way != NIL) {
self.last_way.items = vlen(self.last_way.origin - self.origin);
self.last_way.nextthink = time;
self.last_way.think = WaypointThink;
self.last_way.keys = TRUE;
busy_waypoints = 1;
return TRUE;
}
else
{
} else {
route_table = NIL;
busy_waypoints = 0;
return FALSE;
@ -901,17 +810,14 @@ void(entity this, float direct) bot_get_path =
if (this == NIL)
return;
if (route_table == self)
{
if (busy_waypoints <= 0)
{
if (route_table == self) {
if (busy_waypoints <= 0) {
route_table = NIL;
mark_path(this);
}
return;
}
if (direct)
{
if (direct) {
if(begin_route())
direct_route = TRUE;
else
@ -937,13 +843,10 @@ void() waypoint =
setsize(self, VEC_HULL_MIN, VEC_HULL_MAX);
waypoints = waypoints + 1;
if (!way_head)
{
if (!way_head) {
way_head = self;
way_foot = self;
}
else
{
} else {
way_foot._next = self;
self._last = way_foot;
way_foot = self;
@ -951,8 +854,7 @@ void() waypoint =
self.count = waypoints;
waypoint_mode = WM_LOADED;
if (self.count == 1)
{
if (self.count == 1) {
self.think = FixWaypoints; // wait until all bsp loaded points are spawned
self.nextthink = time;
}
@ -968,8 +870,7 @@ void(vector org, vector bit1, float bit4, float flargs) make_way =
y.b_skill = bit1_y;
y.b_shirt = bit1_z;
y.b_frags = bit4;
if (y.count == 1)
{
if (y.count == 1) {
y.think = FixWaypoints; // wait until all qc loaded points are spawned
y.nextthink = time;
}