split out and objectize chat code

This commit is contained in:
Bill Currie 2003-07-30 16:45:28 +00:00
parent 71b886d231
commit 34f4aaa1c7
8 changed files with 429 additions and 391 deletions

View file

@ -18,6 +18,7 @@ libfrikbot_source = \
map_dm4.qc \
map_dm5.qc \
map_dm6.qc \
chat.r \
waypoint.r
libfrikbot_obj = $(addsuffix .o,$(basename $(libfrikbot_source)))

View file

@ -162,7 +162,7 @@ Bot has lost its target.
} else {
if (targ.ent.classname == "item_artifact_invisibility")
if (ent.items & 524288)
bot_start_topic (3);
[self start_topic:3];
/*XXX
if (targ.ent.flags & FL_ITEM) {
@ -233,7 +233,7 @@ removed.
[self walkmove: ent.origin - targ.origin];
else {
keys &= 960;
bot_start_topic (4);
[self start_topic:4];
}
ent.search_time = time + 5; // never time out
} else if (![self canSee:targ])
@ -765,7 +765,7 @@ frame, the ai_time limits it's actual updating
return;
}
if (ent.view_ofs == '0 0 0')
bot_start_topic (7);
[self start_topic:7];
stagger_think = time;
// shut the bot's buttons off, various functions will turn them on by AI end
@ -828,7 +828,7 @@ frame, the ai_time limits it's actual updating
if (b_aiflags)
[self handle_ai];
else
bot_chat (); // don't want chat to screw him up if he's rjing or something
[self chat]; // don't want chat to screw him up if he's rjing or something
}
@end

View file

@ -346,7 +346,7 @@ attacking an enemy.
if (foesz > mysz) {
if (teamplay) {
if (random () < 0.02) {
bot_start_topic (5);
[self start_topic:5];
self.b_chattime = 1;
}
}

View file

@ -47,7 +47,7 @@ struct bot_data_t = {
float pants, shirt;
};
bot_data_t [32] bot_data = {
struct bot_data_t [32] bot_data = {
{"Vincent", 11, 0},
{"Bishop", 1, 3},
{"Nomad", 13, 2},
@ -82,27 +82,6 @@ bot_data_t [32] bot_data = {
{"Mercury", 10, 5},
};
Bot b_originator;
integer 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
*/
@implementation Bot (Misc)
/*
BotName
@ -135,314 +114,6 @@ Sets bot's name and colors
return h;
}
// I didn't like the old code so this is very stripped down
-(void)start_topic:(integer)topic
{
if (random() < 0.2) {
b_topic = topic;
b_originator = self;
} else
b_topic = 0;
}
-(void)chat
{
local float r;
if (b_options & OPT_NOCHAT)
return;
r = ceil (6 * random ());
if (b_chattime > time) {
if (b_skill < 2)
keys = 0;
ent.button0 = ent.button2 = 0;
return;
} else if (b_chattime) {
switch (b_topic) {
case 1:
if (b_originator == self) {
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:
BotSay(": hi everyone\n");
bot_start_topic (8);
break;
}
}
break;
case 2:
if (b_originator == self) {
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);
}
break;
case 3:
if (b_originator == self) {
if (r < 3)
BotSayTeam (": friendly eyes\n");
else
BotSayTeam (": team eyes\n");
bot_start_topic (0);
}
break;
case 4:
if (b_originator == self) {
if (r < 3)
BotSayTeam (": on your back\n");
else
BotSayTeam (": I'm with you\n");
bot_start_topic (0);
}
break;
case 5:
if (b_originator == self) {
if (r < 3)
BotSayTeam (": I need help\n");
else
BotSayTeam (": need backup\n");
bot_start_topic (0);
}
break;
case 6:
if (b_originator == self) {
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;
}
}
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:
if (b_originator != self) {
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.ent.netname);
BotSay2 ("\n");
bot_start_topic (0);
break;
case 5:
BotSayInit ();
BotSay2 (": hey ");
BotSay2 (b_originator.ent.netname);
BotSay2 ("\n");
bot_start_topic (0);
break;
case 6:
BotSay (": howdy\n");
bot_start_topic (0);
break;
default:
BotSay(": lo\n");
bot_start_topic(0);
break;
}
}
break;
case 9:
if (b_originator != self) {
switch (r) {
case 1:
BotSay (": hah\n");
break;
case 2:
BotSay (": heheh\n");
break;
case 3:
BotSayInit ();
BotSay2 (": good work ");
BotSay2 (b_originator.ent.netname);
BotSay2 ("\n");
break;
case 4:
BotSayInit ();
BotSay2 (": nice1 ");
BotSay2 (b_originator.ent.netname);
BotSay2 ("\n");
break;
case 5:
BotSay (": lol\n");
break;
default:
BotSay (": :)\n");
break;
}
b_topic = 6;
}
break;
case 10:
if (b_originator != self) {
switch (r) {
case 1:
BotSay (": have a nice dip?\n");
break;
case 2:
BotSay (": bah I hate levels with lava\n");
break;
case 3:
BotSayInit();
BotSay2 (": good job ");
BotSay2 (b_originator.ent.netname);
BotSay2 ("\n");
break;
case 4:
BotSayInit ();
BotSay2 (": nice backflip ");
BotSay2 (b_originator.ent.netname);
BotSay2 ("\n");
break;
case 5:
BotSay (": watch your step\n");
break;
default:
BotSay (": hehe\n");
break;
}
b_topic = 6;
}
break;
case 11:
if (b_originator != self) {
switch (r) {
case 1:
BotSayInit ();
BotSay2 (": yeah right ");
BotSay2 (b_originator.ent.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;
}
}
default:
break;
}
b_chattime = 0;
} else if (b_topic) {
if (random () < 0.5) {
if (self == b_originator) {
if (b_topic <= 7)
b_chattime = time + 2;
} else {
if (b_topic >= 7)
b_chattime = time + 2;
}
}
}
}
+(void)kick
{
local entity ty;

View file

@ -247,50 +247,6 @@ BotPostFrame =
return (float)[((Bot)@self.@this) postFrame];
};
/*
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Bot Chat code
The rest of this code is in bot_rank.qc
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
*/
void (string h)
BotSay = // simulate talking by composing a 'chat' message
{
WriteByte (MSG_ALL, 8);
WriteByte (MSG_ALL, 3);
WriteByte (MSG_ALL, 1);
WriteString (MSG_ALL, @self.netname);
WriteByte (MSG_ALL, 8);
WriteByte (MSG_ALL, 3);
WriteByte (MSG_ALL, 2);
WriteString (MSG_ALL, h);
};
void ()
BotSayInit =
{
WriteByte (MSG_ALL, 8);
WriteByte (MSG_ALL, 3);
WriteByte (MSG_ALL, 1);
WriteString (MSG_ALL, @self.netname);
};
void (string h)
BotSay2 =
{
WriteByte (MSG_ALL, 8);
WriteByte (MSG_ALL, 3);
WriteByte (MSG_ALL, 2);
WriteString (MSG_ALL, h);
};
void (string h)
BotSayTeam =
{
// FBX QW doesn't support teamplay...yet
};
// BotInit ====================================================================
void ()
@ -387,7 +343,7 @@ BotConnect =
else if (whatskill < 0)
whatskill = 0;
bot.b_skill = whatskill;
bot_start_topic (1);
[bot start_topic:1];
@self = uself;
};
@ -462,11 +418,11 @@ void () BotImpulses =
if (b_frags != ent.frags) {
if (b_frags > ent.frags) {
if (pointcontents (ent.origin) == CONTENT_LAVA)
bot_start_topic (10);
[self start_topic:10];
else
bot_start_topic (9);
[self start_topic:9];
} else
bot_start_topic (2);
[self start_topic:2];
self.b_frags = ent.frags;
}
[self dynamicWaypoint];

408
fbxa/chat.r Normal file
View file

@ -0,0 +1,408 @@
/***********************************************
* *
* 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.
*/
#include "libfrikbot.h"
@static Bot b_originator;
@static integer 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
*/
@implementation Bot (Chat)
-(void)say:(string)msg
{
WriteByte (MSG_ALL, 8);
WriteByte (MSG_ALL, 3);
WriteByte (MSG_ALL, 1);
WriteString (MSG_ALL, ent.netname);
WriteByte (MSG_ALL, 8);
WriteByte (MSG_ALL, 3);
WriteByte (MSG_ALL, 2);
WriteString (MSG_ALL, msg);
}
-(void)say2:(string)msg
{
WriteByte (MSG_ALL, 8);
WriteByte (MSG_ALL, 3);
WriteByte (MSG_ALL, 2);
WriteString (MSG_ALL, msg);
}
-(void)sayTeam:(string)msg
{
// FBX QW doesn't support teamplay...yet
}
-(void)sayInit
{
WriteByte (MSG_ALL, 8);
WriteByte (MSG_ALL, 3);
WriteByte (MSG_ALL, 1);
WriteString (MSG_ALL, ent.netname);
}
// I didn't like the old code so this is very stripped down
-(void)start_topic:(integer)topic
{
if (random() < 0.2) {
b_topic = topic;
b_originator = self;
} else
b_topic = 0;
}
-(void)chat
{
local float r;
if (b_options & OPT_NOCHAT)
return;
r = ceil (6 * random ());
if (b_chattime > time) {
if (b_skill < 2)
keys = 0;
ent.button0 = ent.button2 = 0;
return;
} else if (b_chattime) {
switch (b_topic) {
case 1:
if (b_originator == self) {
switch (r) {
case 1:
[self say:": lo all\n"];
[self start_topic:8];
break;
case 2:
[self say:": hey everyone\n"];
[self start_topic:8];
break;
case 3:
[self say:": prepare to be fragged!\n"];
[self start_topic:0];
break;
case 4:
[self say:": boy this is laggy\n"];
[self start_topic:11];
break;
case 5:
[self say:": #mm getting some lag here\n"];
[self start_topic:11];
break;
default:
[self say:": hi everyone\n"];
[self start_topic:8];
break;
}
}
break;
case 2:
if (b_originator == self) {
switch (r) {
case 1:
[self say:": take that\n"];
break;
case 2:
[self say:": yehaww!\n"];
break;
case 3:
[self say:": wh00p\n"];
break;
case 4:
[self say:": j00_sawk();\n"];
break;
case 5:
[self say:": i rule\n"];
break;
default:
[self say:": eat that\n"];
break;
}
[self start_topic:0];
}
break;
case 3:
if (b_originator == self) {
if (r < 3)
[self sayTeam:": friendly eyes\n"];
else
[self sayTeam:": team eyes\n"];
[self start_topic:0];
}
break;
case 4:
if (b_originator == self) {
if (r < 3)
[self sayTeam:": on your back\n"];
else
[self sayTeam:": I'm with you\n"];
[self start_topic:0];
}
break;
case 5:
if (b_originator == self) {
if (r < 3)
[self sayTeam:": I need help\n"];
else
[self sayTeam:": need backup\n"];
[self start_topic:0];
}
break;
case 6:
if (b_originator == self) {
switch (r) {
case 1:
[self say:": sun got in my eyes\n"];
[self start_topic:0];
break;
case 2:
[self say:": mouse needs cleaning\n"];
[self start_topic:0];
break;
case 3:
[self say:": i meant to do that\n"];
[self start_topic:0];
break;
case 4:
[self say:": lag\n"];
[self start_topic:11];
break;
case 5:
[self say:": killer lag\n"];
[self start_topic:11];
break;
default:
[self say:": 100% lag\n"];
[self start_topic:11];
break;
}
}
break;
case 7:
switch (r) {
case 1:
[self say:": gg\n"];
break;
case 2:
[self say:": gg all\n"];
break;
case 3:
[self say:": that was fun\n"];
break;
case 4:
[self say:": good game\n"];
break;
case 5:
[self say:": pah\n"];
break;
default:
[self say:": hrm\n"];
break;
}
[self start_topic:0];
break;
case 8:
if (b_originator != self) {
switch (r) {
case 1:
[self say:": heya\n"];
[self start_topic:0];
break;
case 2:
[self say:": welcome\n"];
[self start_topic:0];
break;
case 3:
[self sayInit];
[self say2:": hi "];
[self say2:b_originator.ent.netname];
[self say2:"\n"];
[self start_topic:0];
break;
case 5:
[self sayInit];
[self say2:": hey "];
[self say2:b_originator.ent.netname];
[self say2:"\n"];
[self start_topic:0];
break;
case 6:
[self say:": howdy\n"];
[self start_topic:0];
break;
default:
[self say:": lo\n"];
[self start_topic:0];
break;
}
}
break;
case 9:
if (b_originator != self) {
switch (r) {
case 1:
[self say:": hah\n"];
break;
case 2:
[self say:": heheh\n"];
break;
case 3:
[self sayInit];
[self say2:": good work "];
[self say2:b_originator.ent.netname];
[self say2:"\n"];
break;
case 4:
[self sayInit];
[self say2:": nice1 "];
[self say2:b_originator.ent.netname];
[self say2:"\n"];
break;
case 5:
[self say:": lol\n"];
break;
default:
[self say:": :)\n"];
break;
}
b_topic = 6;
}
break;
case 10:
if (b_originator != self) {
switch (r) {
case 1:
[self say:": have a nice dip?\n"];
break;
case 2:
[self say:": bah I hate levels with lava\n"];
break;
case 3:
[self sayInit];
[self say2:": good job "];
[self say2:b_originator.ent.netname];
[self say2:"\n"];
break;
case 4:
[self sayInit];
[self say2:": nice backflip "];
[self say2:b_originator.ent.netname];
[self say2:"\n"];
break;
case 5:
[self say:": watch your step\n"];
break;
default:
[self say:": hehe\n"];
break;
}
b_topic = 6;
}
break;
case 11:
if (b_originator != self) {
switch (r) {
case 1:
[self sayInit];
[self say2:": yeah right "];
[self say2:b_originator.ent.netname];
[self say2:"\n"];
[self start_topic:0];
break;
case 2:
[self say:": ping\n"];
[self start_topic:0];
break;
case 3:
[self say:": shuddup, you're an lpb\n"];
[self start_topic:0];
break;
case 4:
[self say:": lag my eye\n"];
[self start_topic:0];
break;
case 5:
[self say:": yeah\n"];
[self start_topic:11];
break;
default:
[self say:": totally\n"];
[self start_topic:11];
break;
}
}
default:
break;
}
b_chattime = 0;
} else if (b_topic) {
if (random () < 0.5) {
if (self == b_originator) {
if (b_topic <= 7)
b_chattime = time + 2;
} else {
if (b_topic >= 7)
b_chattime = time + 2;
}
}
}
}
@end

View file

@ -104,8 +104,6 @@
@interface Bot (Misc)
-(string)name:(integer)r;
-(string)randomName;
-(void)start_topic:(integer)topic;
-(void)chat;
-(integer)fov:(entity)targ;
+(void)kick;
@ -164,6 +162,15 @@
-(integer)canSee:(Target)targ;
@end
@interface Bot (Chat)
-(void)start_topic:(integer)topic;
-(void)say:(string)msg;
-(void)say2:(string)msg;
-(void)sayTeam:(string)msg;
-(void)sayInit;
-(void)chat;
@end
#define FALSE 0
#define TRUE 1
@ -279,13 +286,7 @@
@extern float(entity ent, entity targ) sisible;
@extern vector(entity ent) realorigin;
@extern float(float v) frik_anglemod;
@extern void() bot_chat;
@extern void(float tpic) bot_start_topic;
@extern void(string h) BotSay;
@extern void() BotSayInit;
@extern void(string h) BotSay2;
@extern void(string h) BotSayTeam;
@extern void(Waypoint e1, Waypoint e2, integer flag) DeveloperLightning;
/*

View file

@ -58,6 +58,7 @@ this notice in its entirety.
waypoint_array = [[Array alloc] init];
waypoint_queue = [[List alloc] init];
waypoint_thinker = spawn ();
waypoint_thinker.classname = "waypoint_thinker";
}
return [super init];
}