2003-02-18 23:11:05 +00:00
|
|
|
/***********************************************
|
|
|
|
* *
|
|
|
|
* FrikBot Misc Code *
|
|
|
|
* "Because you can't name it anything else" *
|
|
|
|
* *
|
|
|
|
***********************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
This program is in the Public Domain. My crack legal
|
|
|
|
team would like to add:
|
|
|
|
|
|
|
|
RYAN "FRIKAC" SMITH IS PROVIDING THIS SOFTWARE "AS IS"
|
|
|
|
AND MAKES NO WARRANTY, EXPRESS OR IMPLIED, AS TO THE
|
|
|
|
ACCURACY, CAPABILITY, EFFICIENCY, MERCHANTABILITY, OR
|
|
|
|
FUNCTIONING OF THIS SOFTWARE AND/OR DOCUMENTATION. IN
|
|
|
|
NO EVENT WILL RYAN "FRIKAC" SMITH BE LIABLE FOR ANY
|
|
|
|
GENERAL, CONSEQUENTIAL, INDIRECT, INCIDENTAL,
|
|
|
|
EXEMPLARY, OR SPECIAL DAMAGES, EVEN IF RYAN "FRIKAC"
|
|
|
|
SMITH HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
|
|
|
DAMAGES, IRRESPECTIVE OF THE CAUSE OF SUCH DAMAGES.
|
|
|
|
|
|
|
|
You accept this software on the condition that you
|
|
|
|
indemnify and hold harmless Ryan "FrikaC" Smith from
|
|
|
|
any and all liability or damages to third parties,
|
|
|
|
including attorney fees, court costs, and other
|
|
|
|
related costs and expenses, arising out of your use
|
|
|
|
of this software irrespective of the cause of said
|
|
|
|
liability.
|
|
|
|
|
|
|
|
The export from the United States or the subsequent
|
|
|
|
reexport of this software is subject to compliance
|
|
|
|
with United States export control and munitions
|
|
|
|
control restrictions. You agree that in the event you
|
|
|
|
seek to export this software, you assume full
|
|
|
|
responsibility for obtaining all necessary export
|
|
|
|
licenses and approvals and for assuring compliance
|
|
|
|
with applicable reexport restrictions.
|
|
|
|
|
|
|
|
Any reproduction of this software must contain
|
|
|
|
this notice in its entirety.
|
|
|
|
*/
|
|
|
|
|
2003-02-24 16:05:25 +00:00
|
|
|
#include "libfrikbot.h"
|
|
|
|
|
2003-02-18 23:11:05 +00:00
|
|
|
/*
|
|
|
|
BotName
|
|
|
|
|
|
|
|
Sets bot's name and colors
|
|
|
|
*/
|
2003-03-08 03:20:32 +00:00
|
|
|
string (float r)
|
|
|
|
BotName =
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
|
|
|
self.b_num = r;
|
2003-03-08 03:20:32 +00:00
|
|
|
switch (r) {
|
|
|
|
case 1:
|
2003-02-18 23:11:05 +00:00
|
|
|
self.b_pants = 11;
|
|
|
|
self.b_shirt = 0;
|
|
|
|
return "Vincent";
|
2003-03-08 03:20:32 +00:00
|
|
|
case 2:
|
2003-02-18 23:11:05 +00:00
|
|
|
self.b_pants = 1;
|
|
|
|
self.b_shirt = 3;
|
|
|
|
return "Bishop";
|
2003-03-08 03:20:32 +00:00
|
|
|
case 3:
|
2003-02-18 23:11:05 +00:00
|
|
|
self.b_pants = 13;
|
|
|
|
self.b_shirt = 2;
|
|
|
|
return "Nomad";
|
2003-03-08 03:20:32 +00:00
|
|
|
case 4:
|
2003-02-18 23:11:05 +00:00
|
|
|
self.b_pants = 7;
|
|
|
|
self.b_shirt = 6;
|
|
|
|
return "Hudson";
|
2003-03-08 03:20:32 +00:00
|
|
|
case 5:
|
2003-02-18 23:11:05 +00:00
|
|
|
self.b_pants = 12;
|
|
|
|
self.b_shirt = 6;
|
|
|
|
return "Lore";
|
2003-03-08 03:20:32 +00:00
|
|
|
case 6:
|
2003-02-18 23:11:05 +00:00
|
|
|
self.b_pants = 4;
|
|
|
|
self.b_shirt = 4;
|
|
|
|
return "Servo";
|
2003-03-08 03:20:32 +00:00
|
|
|
case 7:
|
2003-02-18 23:11:05 +00:00
|
|
|
self.b_pants = 2;
|
|
|
|
self.b_shirt = 5;
|
|
|
|
return "Gort";
|
2003-03-08 03:20:32 +00:00
|
|
|
case 8:
|
2003-02-18 23:11:05 +00:00
|
|
|
self.b_pants = 10;
|
|
|
|
self.b_shirt = 3;
|
|
|
|
return "Kryten";
|
2003-03-08 03:20:32 +00:00
|
|
|
case 9:
|
2003-02-18 23:11:05 +00:00
|
|
|
self.b_pants = 9;
|
|
|
|
self.b_shirt = 4;
|
|
|
|
return "Pimp Bot";
|
2003-03-08 03:20:32 +00:00
|
|
|
case 10:
|
2003-02-18 23:11:05 +00:00
|
|
|
self.b_pants = 4;
|
|
|
|
self.b_shirt = 7;
|
|
|
|
return "Max";
|
2003-03-08 03:20:32 +00:00
|
|
|
case 11:
|
2003-02-18 23:11:05 +00:00
|
|
|
self.b_pants = 3;
|
|
|
|
self.b_shirt = 11;
|
|
|
|
return "Marvin";
|
2003-03-08 03:20:32 +00:00
|
|
|
case 12:
|
2003-02-18 23:11:05 +00:00
|
|
|
self.b_pants = 13;
|
|
|
|
self.b_shirt = 12;
|
|
|
|
return "Erwin";
|
2003-03-08 03:20:32 +00:00
|
|
|
case 13:
|
2003-02-18 23:11:05 +00:00
|
|
|
self.b_pants = 11;
|
|
|
|
self.b_shirt = 2;
|
|
|
|
return "FrikBot";
|
2003-03-08 03:20:32 +00:00
|
|
|
case 14:
|
2003-02-18 23:11:05 +00:00
|
|
|
self.b_pants = 0;
|
|
|
|
self.b_shirt = 2;
|
|
|
|
return "Krosis";
|
2003-03-08 03:20:32 +00:00
|
|
|
case 15:
|
2003-02-18 23:11:05 +00:00
|
|
|
self.b_pants = 8;
|
|
|
|
self.b_shirt = 9;
|
|
|
|
return "Gypsy";
|
2003-03-08 03:20:32 +00:00
|
|
|
case 16:
|
2003-02-18 23:11:05 +00:00
|
|
|
self.b_pants = 5;
|
|
|
|
self.b_shirt = 10;
|
|
|
|
return "Hal";
|
2003-03-08 03:20:32 +00:00
|
|
|
default:
|
|
|
|
break;
|
2003-02-18 23:11:05 +00:00
|
|
|
}
|
|
|
|
};
|
2003-03-08 03:20:32 +00:00
|
|
|
|
|
|
|
string ()
|
|
|
|
PickARandomName =
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
|
|
|
if (bot_count > 16)
|
|
|
|
return "player";
|
|
|
|
|
|
|
|
local float y, test;
|
|
|
|
local string h;
|
|
|
|
local entity t;
|
|
|
|
y = TRUE;
|
2003-03-08 03:20:32 +00:00
|
|
|
while (y) {
|
|
|
|
test = ceil (16 * random ());
|
|
|
|
h = BotName (test);
|
|
|
|
t = find (NIL, netname, h);
|
2003-02-24 16:05:25 +00:00
|
|
|
if (t == NIL)
|
2003-02-18 23:11:05 +00:00
|
|
|
y = FALSE;
|
|
|
|
}
|
|
|
|
return h;
|
|
|
|
};
|
|
|
|
|
|
|
|
// I didn't like the old code so this is very stripped down
|
|
|
|
|
|
|
|
entity b_originator;
|
|
|
|
float b_topic;
|
|
|
|
/* FBX Topics
|
|
|
|
|
|
|
|
b_originator == self
|
|
|
|
1 - sign on
|
|
|
|
2 - killed targ
|
|
|
|
3 - team message "friendly eyes"
|
|
|
|
4 - team message "on your back"
|
|
|
|
5 - team message "need back up"
|
|
|
|
6 - excuses
|
|
|
|
----
|
|
|
|
7 - gameover
|
|
|
|
----
|
|
|
|
8 - welcoming someone onto server
|
|
|
|
9 - ridicule lost frag (killed self?)
|
|
|
|
10 - ridicule lost frag (lava)
|
|
|
|
11 - lag
|
|
|
|
b_originator == targ
|
|
|
|
*/
|
2003-03-08 03:20:32 +00:00
|
|
|
void (float tpic)
|
|
|
|
bot_start_topic =
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
2003-03-04 18:26:17 +00:00
|
|
|
if (random() < 0.2) {
|
2003-02-18 23:11:05 +00:00
|
|
|
b_topic = tpic;
|
|
|
|
b_originator = self;
|
2003-03-04 18:26:17 +00:00
|
|
|
} else
|
2003-02-18 23:11:05 +00:00
|
|
|
b_topic = 0;
|
|
|
|
};
|
|
|
|
|
2003-03-08 03:20:32 +00:00
|
|
|
void ()
|
|
|
|
bot_chat =
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
|
|
|
local float r;
|
2003-03-08 03:20:32 +00:00
|
|
|
|
2003-02-18 23:11:05 +00:00
|
|
|
if (b_options & OPT_NOCHAT)
|
|
|
|
return;
|
2003-03-08 03:20:32 +00:00
|
|
|
|
|
|
|
r = ceil (6 * random ());
|
2003-02-18 23:11:05 +00:00
|
|
|
|
2003-03-04 18:26:17 +00:00
|
|
|
if (self.b_chattime > time) {
|
2003-02-18 23:11:05 +00:00
|
|
|
if (self.b_skill < 2)
|
|
|
|
self.keys = self.button0 = self.button2 = 0;
|
|
|
|
return;
|
2003-03-04 18:26:17 +00:00
|
|
|
} else if (self.b_chattime) {
|
2003-03-08 03:20:32 +00:00
|
|
|
switch (b_topic) {
|
|
|
|
case 1:
|
2003-03-04 18:26:17 +00:00
|
|
|
if (b_originator == self) {
|
2003-03-08 03:20:32 +00:00
|
|
|
switch (r) {
|
|
|
|
case 1:
|
|
|
|
BotSay (": lo all\n");
|
|
|
|
bot_start_topic (8);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
BotSay (": hey everyone\n");
|
|
|
|
bot_start_topic (8);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
BotSay (": prepare to be fragged!\n");
|
|
|
|
bot_start_topic (0);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
BotSay (": boy this is laggy\n");
|
|
|
|
bot_start_topic (11);
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
BotSay (": #mm getting some lag here\n");
|
|
|
|
bot_start_topic (11);
|
|
|
|
break;
|
|
|
|
default:
|
2003-02-18 23:11:05 +00:00
|
|
|
BotSay(": hi everyone\n");
|
2003-03-08 03:20:32 +00:00
|
|
|
bot_start_topic (8);
|
|
|
|
break;
|
2003-02-18 23:11:05 +00:00
|
|
|
}
|
|
|
|
}
|
2003-03-08 03:20:32 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2003-03-04 18:26:17 +00:00
|
|
|
if (b_originator == self) {
|
2003-03-08 03:20:32 +00:00
|
|
|
switch (r) {
|
|
|
|
case 1:
|
|
|
|
BotSay (": take that\n");
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
BotSay (": yehaww!\n");
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
BotSay (": wh00p\n");
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
BotSay (": j00_sawk();\n");
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
BotSay (": i rule\n");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
BotSay (": eat that\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
bot_start_topic (0);
|
2003-02-18 23:11:05 +00:00
|
|
|
}
|
2003-03-08 03:20:32 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
2003-03-04 18:26:17 +00:00
|
|
|
if (b_originator == self) {
|
2003-02-18 23:11:05 +00:00
|
|
|
if (r < 3)
|
2003-03-08 03:20:32 +00:00
|
|
|
BotSayTeam (": friendly eyes\n");
|
2003-02-18 23:11:05 +00:00
|
|
|
else
|
2003-03-08 03:20:32 +00:00
|
|
|
BotSayTeam (": team eyes\n");
|
|
|
|
bot_start_topic (0);
|
2003-02-18 23:11:05 +00:00
|
|
|
}
|
2003-03-08 03:20:32 +00:00
|
|
|
break;
|
|
|
|
case 4:
|
2003-03-04 18:26:17 +00:00
|
|
|
if (b_originator == self) {
|
2003-02-18 23:11:05 +00:00
|
|
|
if (r < 3)
|
2003-03-08 03:20:32 +00:00
|
|
|
BotSayTeam (": on your back\n");
|
2003-02-18 23:11:05 +00:00
|
|
|
else
|
2003-03-08 03:20:32 +00:00
|
|
|
BotSayTeam (": I'm with you\n");
|
|
|
|
bot_start_topic (0);
|
2003-02-18 23:11:05 +00:00
|
|
|
}
|
2003-03-08 03:20:32 +00:00
|
|
|
break;
|
|
|
|
case 5:
|
2003-03-04 18:26:17 +00:00
|
|
|
if (b_originator == self) {
|
2003-02-18 23:11:05 +00:00
|
|
|
if (r < 3)
|
2003-03-08 03:20:32 +00:00
|
|
|
BotSayTeam (": I need help\n");
|
2003-02-18 23:11:05 +00:00
|
|
|
else
|
2003-03-08 03:20:32 +00:00
|
|
|
BotSayTeam (": need backup\n");
|
|
|
|
bot_start_topic (0);
|
2003-02-18 23:11:05 +00:00
|
|
|
}
|
2003-03-08 03:20:32 +00:00
|
|
|
break;
|
|
|
|
case 6:
|
2003-03-04 18:26:17 +00:00
|
|
|
if (b_originator == self) {
|
2003-03-08 03:20:32 +00:00
|
|
|
switch (r) {
|
|
|
|
case 1:
|
|
|
|
BotSay (": sun got in my eyes\n");
|
|
|
|
bot_start_topic (0);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
BotSay (": mouse needs cleaning\n");
|
|
|
|
bot_start_topic (0);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
BotSay (": i meant to do that\n");
|
|
|
|
bot_start_topic (0);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
BotSay (": lag\n");
|
|
|
|
bot_start_topic (11);
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
BotSay (": killer lag\n");
|
|
|
|
bot_start_topic (11);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
BotSay (": 100% lag\n");
|
|
|
|
bot_start_topic (11);
|
|
|
|
break;
|
2003-02-18 23:11:05 +00:00
|
|
|
}
|
|
|
|
}
|
2003-03-08 03:20:32 +00:00
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
switch (r) {
|
|
|
|
case 1:
|
|
|
|
BotSay (": gg\n");
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
BotSay (": gg all\n");
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
BotSay (": that was fun\n");
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
BotSay (": good game\n");
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
BotSay (": pah\n");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
BotSay (": hrm\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
bot_start_topic (0);
|
|
|
|
break;
|
|
|
|
case 8:
|
2003-03-04 18:26:17 +00:00
|
|
|
if (b_originator != self) {
|
2003-03-08 03:20:32 +00:00
|
|
|
switch (r) {
|
|
|
|
case 1:
|
|
|
|
BotSay (": heya\n");
|
|
|
|
bot_start_topic (0);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
BotSay (": welcome\n");
|
|
|
|
bot_start_topic (0);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
BotSayInit ();
|
|
|
|
BotSay2 (": hi ");
|
|
|
|
BotSay2 (b_originator.netname);
|
|
|
|
BotSay2 ("\n");
|
|
|
|
bot_start_topic (0);
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
BotSayInit ();
|
|
|
|
BotSay2 (": hey ");
|
|
|
|
BotSay2 (b_originator.netname);
|
|
|
|
BotSay2 ("\n");
|
|
|
|
bot_start_topic (0);
|
|
|
|
break;
|
2003-03-08 05:43:26 +00:00
|
|
|
case 6:
|
2003-03-08 03:20:32 +00:00
|
|
|
BotSay (": howdy\n");
|
|
|
|
bot_start_topic (0);
|
|
|
|
break;
|
|
|
|
default:
|
2003-02-18 23:11:05 +00:00
|
|
|
BotSay(": lo\n");
|
|
|
|
bot_start_topic(0);
|
2003-03-08 03:20:32 +00:00
|
|
|
break;
|
2003-02-18 23:11:05 +00:00
|
|
|
}
|
|
|
|
}
|
2003-03-08 03:20:32 +00:00
|
|
|
break;
|
|
|
|
case 9:
|
2003-03-04 18:26:17 +00:00
|
|
|
if (b_originator != self) {
|
2003-03-08 03:20:32 +00:00
|
|
|
switch (r) {
|
|
|
|
case 1:
|
|
|
|
BotSay (": hah\n");
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
BotSay (": heheh\n");
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
BotSayInit ();
|
|
|
|
BotSay2 (": good work ");
|
|
|
|
BotSay2 (b_originator.netname);
|
|
|
|
BotSay2 ("\n");
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
BotSayInit ();
|
|
|
|
BotSay2 (": nice1 ");
|
|
|
|
BotSay2 (b_originator.netname);
|
|
|
|
BotSay2 ("\n");
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
BotSay (": lol\n");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
BotSay (": :)\n");
|
|
|
|
break;
|
|
|
|
}
|
2003-02-18 23:11:05 +00:00
|
|
|
b_topic = 6;
|
|
|
|
}
|
2003-03-08 03:20:32 +00:00
|
|
|
break;
|
|
|
|
case 10:
|
2003-03-04 18:26:17 +00:00
|
|
|
if (b_originator != self) {
|
2003-03-08 03:20:32 +00:00
|
|
|
switch (r) {
|
|
|
|
case 1:
|
|
|
|
BotSay (": have a nice dip?\n");
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
BotSay (": bah I hate levels with lava\n");
|
|
|
|
break;
|
|
|
|
case 3:
|
2003-02-18 23:11:05 +00:00
|
|
|
BotSayInit();
|
2003-03-08 03:20:32 +00:00
|
|
|
BotSay2 (": good job ");
|
|
|
|
BotSay2 (b_originator.netname);
|
|
|
|
BotSay2 ("\n");
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
BotSayInit ();
|
|
|
|
BotSay2 (": nice backflip ");
|
|
|
|
BotSay2 (b_originator.netname);
|
|
|
|
BotSay2 ("\n");
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
BotSay (": watch your step\n");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
BotSay (": hehe\n");
|
|
|
|
break;
|
|
|
|
}
|
2003-02-18 23:11:05 +00:00
|
|
|
b_topic = 6;
|
|
|
|
}
|
2003-03-08 03:20:32 +00:00
|
|
|
break;
|
|
|
|
case 11:
|
2003-03-04 18:26:17 +00:00
|
|
|
if (b_originator != self) {
|
2003-03-08 03:20:32 +00:00
|
|
|
switch (r) {
|
|
|
|
case 1:
|
|
|
|
BotSayInit ();
|
|
|
|
BotSay2 (": yeah right ");
|
|
|
|
BotSay2 (b_originator.netname);
|
|
|
|
BotSay2 ("\n");
|
|
|
|
bot_start_topic (0);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
BotSay (": ping\n");
|
|
|
|
bot_start_topic (0);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
BotSay (": shuddup, you're an lpb\n");
|
|
|
|
bot_start_topic (0);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
BotSay (": lag my eye\n");
|
|
|
|
bot_start_topic (0);
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
BotSay (": yeah\n");
|
|
|
|
bot_start_topic (11);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
BotSay (": totally\n");
|
|
|
|
bot_start_topic (11);
|
|
|
|
break;
|
2003-02-18 23:11:05 +00:00
|
|
|
}
|
|
|
|
}
|
2003-03-08 03:20:32 +00:00
|
|
|
default:
|
|
|
|
break;
|
2003-02-18 23:11:05 +00:00
|
|
|
}
|
|
|
|
self.b_chattime = 0;
|
2003-03-04 18:26:17 +00:00
|
|
|
} else if (b_topic) {
|
2003-03-08 03:20:32 +00:00
|
|
|
if (random () < 0.5) {
|
2003-03-04 18:26:17 +00:00
|
|
|
if (self == b_originator) {
|
2003-02-18 23:11:05 +00:00
|
|
|
if (b_topic <= 7)
|
|
|
|
self.b_chattime = time + 2;
|
2003-03-04 18:26:17 +00:00
|
|
|
} else {
|
2003-02-18 23:11:05 +00:00
|
|
|
if (b_topic >= 7)
|
|
|
|
self.b_chattime = time + 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2003-03-08 03:20:32 +00:00
|
|
|
void ()
|
|
|
|
KickABot =
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
|
|
|
local entity ty;
|
2003-03-08 03:20:32 +00:00
|
|
|
|
|
|
|
ty = find (NIL, classname, "player");
|
2003-03-04 18:26:17 +00:00
|
|
|
while (ty != NIL) {
|
|
|
|
if (!(ty.ishuman)) {
|
2003-03-08 03:20:32 +00:00
|
|
|
BotDisconnect (ty);
|
2003-02-18 23:11:05 +00:00
|
|
|
ty.ishuman = TRUE;
|
2003-02-24 16:05:25 +00:00
|
|
|
ty = NIL;
|
2003-03-04 18:26:17 +00:00
|
|
|
} else
|
2003-03-08 03:20:32 +00:00
|
|
|
ty = find (ty, classname, "player");
|
2003-02-18 23:11:05 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
Simplified origin checking.
|
|
|
|
|
|
|
|
God, I wish I had inline
|
|
|
|
*/
|
2003-03-08 03:20:32 +00:00
|
|
|
vector (entity ent)
|
|
|
|
realorigin =
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
2003-03-08 03:20:32 +00:00
|
|
|
// even more simplified...
|
2003-02-18 23:11:05 +00:00
|
|
|
return (ent.absmin + ent.absmax) * 0.5;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
fisible
|
|
|
|
|
|
|
|
a version of visible that checks for corners
|
|
|
|
of the bounding boxes
|
|
|
|
*/
|
2003-03-08 03:20:32 +00:00
|
|
|
float (entity targ)
|
|
|
|
fisible =
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
2003-03-08 03:20:32 +00:00
|
|
|
local float thruwater = 0, pc1 = 0, pc2 = 0;
|
2003-02-18 23:11:05 +00:00
|
|
|
local vector spot1, org;
|
2003-03-08 03:20:32 +00:00
|
|
|
|
|
|
|
org = realorigin (targ);
|
2003-02-18 23:11:05 +00:00
|
|
|
spot1 = self.origin + self.view_ofs;
|
|
|
|
|
2003-03-04 18:26:17 +00:00
|
|
|
if (targ.solid == SOLID_BSP) {
|
2003-02-18 23:11:05 +00:00
|
|
|
traceline (spot1, org, TRUE, self);
|
|
|
|
if (trace_ent == targ)
|
|
|
|
return TRUE;
|
|
|
|
else if (trace_fraction == 1)
|
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
2003-03-04 18:26:17 +00:00
|
|
|
} else {
|
2003-03-08 03:20:32 +00:00
|
|
|
pc1 = pointcontents (org);
|
|
|
|
pc2 = pointcontents (spot1);
|
2003-02-18 23:11:05 +00:00
|
|
|
if (targ.classname == "player")
|
|
|
|
thruwater = FALSE;
|
|
|
|
else if (pc1 == CONTENT_LAVA)
|
|
|
|
return FALSE;
|
|
|
|
else
|
|
|
|
thruwater = TRUE;
|
|
|
|
}
|
|
|
|
|
2003-03-04 18:26:17 +00:00
|
|
|
if (pc1 < -1) {
|
|
|
|
// targ's origin is in water or other liquid
|
|
|
|
if (pc2 != pc1) {
|
2003-02-18 23:11:05 +00:00
|
|
|
// look for their head
|
|
|
|
traceline (spot1, org + targ.mins, TRUE, self);
|
|
|
|
// cross the water check
|
|
|
|
if (trace_inopen)
|
|
|
|
if (trace_inwater)
|
|
|
|
if (!thruwater)
|
|
|
|
return FALSE;
|
|
|
|
if (trace_ent == targ)
|
|
|
|
return TRUE;
|
|
|
|
else if (trace_fraction == 1)
|
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
2003-03-04 18:26:17 +00:00
|
|
|
} else {
|
|
|
|
if (pc2 != pc1) {
|
2003-02-18 23:11:05 +00:00
|
|
|
traceline (spot1, org + targ.maxs, TRUE, self);
|
|
|
|
if (trace_inopen)
|
|
|
|
if (trace_inwater)
|
|
|
|
if (!thruwater)
|
|
|
|
return FALSE;
|
|
|
|
if (trace_ent == targ)
|
|
|
|
return TRUE;
|
|
|
|
else if (trace_fraction == 1)
|
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
traceline (spot1, org, TRUE, self);
|
|
|
|
if (trace_ent == targ)
|
|
|
|
return TRUE;
|
|
|
|
else if (trace_fraction == 1)
|
|
|
|
return TRUE;
|
|
|
|
traceline (spot1, org + targ.maxs, TRUE, self);
|
|
|
|
if (trace_ent == targ)
|
|
|
|
return TRUE;
|
|
|
|
else if (trace_fraction == 1)
|
|
|
|
return TRUE;
|
|
|
|
traceline (spot1, org + targ.mins, TRUE, self);
|
|
|
|
if (trace_ent == targ)
|
|
|
|
return TRUE;
|
|
|
|
else if (trace_fraction == 1)
|
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
Wisible
|
|
|
|
|
|
|
|
goes through movable brushes/entities, used
|
|
|
|
for waypoints
|
|
|
|
*/
|
|
|
|
// this is used for waypoint stuff....
|
2003-03-08 03:20:32 +00:00
|
|
|
float (entity targ1, entity targ2)
|
|
|
|
wisible =
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
2003-03-08 03:20:32 +00:00
|
|
|
local entity ignore;
|
2003-02-18 23:11:05 +00:00
|
|
|
local vector spot1, spot2;
|
|
|
|
|
|
|
|
spot1 = targ1.origin;
|
2003-03-08 03:20:32 +00:00
|
|
|
spot2 = realorigin (targ2);
|
2003-02-18 23:11:05 +00:00
|
|
|
|
|
|
|
ignore = self;
|
2003-03-04 18:26:17 +00:00
|
|
|
do {
|
2003-02-18 23:11:05 +00:00
|
|
|
traceline (spot1, spot2, TRUE, ignore);
|
|
|
|
spot1 = realorigin(trace_ent);
|
|
|
|
ignore = trace_ent;
|
2003-02-24 16:05:25 +00:00
|
|
|
} while ((trace_ent != NIL) && (trace_fraction != 1));
|
2003-02-18 23:11:05 +00:00
|
|
|
if (trace_endpos == spot2)
|
|
|
|
return TRUE;
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
sisible
|
|
|
|
|
|
|
|
Now this is getting ridiculous. Simple visible,
|
|
|
|
used when we need just a simple traceline nothing else
|
|
|
|
*/
|
2003-03-08 03:20:32 +00:00
|
|
|
float (entity targ)
|
|
|
|
sisible =
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
|
|
|
traceline (self.origin, targ.origin, TRUE, self);
|
|
|
|
if (trace_ent == targ)
|
|
|
|
return TRUE;
|
|
|
|
else if (trace_fraction == 1)
|
|
|
|
return TRUE;
|
|
|
|
};
|
|
|
|
|
2003-03-08 03:20:32 +00:00
|
|
|
/*
|
2003-02-18 23:11:05 +00:00
|
|
|
angcomp
|
|
|
|
|
|
|
|
subtracts one angle from another
|
|
|
|
*/
|
2003-03-08 03:20:32 +00:00
|
|
|
float (float y1, float y2)
|
|
|
|
angcomp =
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
|
|
|
local float answer;
|
2003-03-08 03:20:32 +00:00
|
|
|
|
|
|
|
y1 = frik_anglemod (y1);
|
|
|
|
y2 = frik_anglemod (y2);
|
|
|
|
|
2003-02-18 23:11:05 +00:00
|
|
|
answer = y1 - y2;
|
|
|
|
if (answer > 180)
|
2003-03-08 03:20:32 +00:00
|
|
|
answer -= 360;
|
2003-02-18 23:11:05 +00:00
|
|
|
else if (answer < -180)
|
2003-03-08 03:20:32 +00:00
|
|
|
answer += 360;
|
2003-02-18 23:11:05 +00:00
|
|
|
return answer;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
fov
|
|
|
|
|
|
|
|
is the entity in the bot's field of view
|
|
|
|
*/
|
2003-03-08 03:20:32 +00:00
|
|
|
float (entity targ)
|
|
|
|
fov =
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
2003-03-08 03:20:32 +00:00
|
|
|
local float g;
|
|
|
|
local vector yawn;
|
|
|
|
|
|
|
|
yawn = realorigin (targ);
|
2003-02-18 23:11:05 +00:00
|
|
|
yawn = (yawn + targ.view_ofs) - (self.origin + self.view_ofs);
|
2003-03-08 03:20:32 +00:00
|
|
|
yawn = normalize (yawn);
|
|
|
|
yawn = vectoangles (yawn);
|
|
|
|
g = angcomp (self.v_angle_x, yawn_x);
|
|
|
|
if (fabs (g) > 45)
|
2003-02-18 23:11:05 +00:00
|
|
|
return FALSE;
|
2003-03-08 03:20:32 +00:00
|
|
|
g = angcomp (self.v_angle_y, yawn_y);
|
|
|
|
if (fabs (g) > 60)
|
2003-02-18 23:11:05 +00:00
|
|
|
return FALSE;
|
|
|
|
return TRUE;
|
|
|
|
};
|
|
|
|
|
2003-03-08 03:20:32 +00:00
|
|
|
float (float v)
|
|
|
|
frik_anglemod =
|
2003-02-18 23:11:05 +00:00
|
|
|
{
|
2003-03-08 03:20:32 +00:00
|
|
|
return v - floor (v / 360) * 360;
|
2003-02-18 23:12:03 +00:00
|
|
|
};
|