BotLib: Bots ought to switch weapons now when they pick an item up!
Also moved the way_menu cmd into its own file...
This commit is contained in:
parent
f52638c715
commit
d1b1431b8a
17 changed files with 137 additions and 78 deletions
|
@ -101,6 +101,11 @@ bot::SeeThink(void)
|
|||
if (w.health <= 0)
|
||||
continue;
|
||||
|
||||
/* ain't go hurt our brothers and sisters */
|
||||
if (Rules_IsTeamPlay() == TRUE)
|
||||
if (team == w.team)
|
||||
continue;
|
||||
|
||||
/* first, is the potential enemy in our field of view? */
|
||||
makevectors(v_angle);
|
||||
vector v = normalize(w.origin - origin);
|
||||
|
@ -146,7 +151,7 @@ bot::CheckRoute(void)
|
|||
velocity *= 0.5f;
|
||||
|
||||
if (m_iCurNode >= 0) {
|
||||
print(sprintf("NODE FLAGS: %i\n", m_pRoute[m_iCurNode].m_iFlags));
|
||||
//print(sprintf("NODE FLAGS: %i\n", m_pRoute[m_iCurNode].m_iFlags));
|
||||
|
||||
/* if a node is flagged as jumpy, jump! */
|
||||
if (m_pRoute[m_iCurNode].m_iFlags & WP_JUMP)
|
||||
|
@ -219,6 +224,11 @@ bot::RunAI(void)
|
|||
return;
|
||||
}
|
||||
|
||||
/* freeze the bot */
|
||||
if (autocvar_bot_wait)
|
||||
return;
|
||||
|
||||
#if 1
|
||||
/* create our first route */
|
||||
if (!m_iNodes) {
|
||||
route_calculate(this, Route_SelectDestination(this), 0, Bot_RouteCB);
|
||||
|
@ -231,6 +241,7 @@ bot::RunAI(void)
|
|||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
WeaponThink();
|
||||
SeeThink();
|
||||
|
@ -342,7 +353,8 @@ bot::PostFrame(void)
|
|||
{
|
||||
/* we've picked something new up */
|
||||
if (m_iOldItems != g_items) {
|
||||
//Weapons_SwitchBest(this);
|
||||
Weapons_SwitchBest(this);
|
||||
print(sprintf("%s is now using %s (%d)\n", netname, g_weapons[activeweapon].name, activeweapon));
|
||||
m_iOldItems = g_items;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ Bot_PickName(entity target)
|
|||
}
|
||||
}
|
||||
forceinfokey(target, "name", sprintf("Bot %i", n));
|
||||
forceinfokey(target, "model", "robo");
|
||||
}
|
||||
|
||||
entity
|
||||
|
|
|
@ -15,3 +15,4 @@
|
|||
*/
|
||||
|
||||
var int autocvar_bot_pacifist = FALSE;
|
||||
var int autocvar_bot_wait = FALSE;
|
||||
|
|
|
@ -354,16 +354,45 @@ Way_DrawDebugInfo(void)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
Way_ConnectTwo(void)
|
||||
{
|
||||
static int waylink_status;
|
||||
static int way1, way2;
|
||||
|
||||
if (waylink_status == 0) {
|
||||
way1 = Way_FindClosestWaypoint(self.origin);
|
||||
waylink_status = 1;
|
||||
centerprint(self, "Selected first waypoint!\n");
|
||||
} else if (waylink_status == 1) {
|
||||
way2 = Way_FindClosestWaypoint(self.origin);
|
||||
waylink_status = 0;
|
||||
|
||||
if (way1 != way2) {
|
||||
Way_LinkWaypoints(&g_pWaypoints[way1], &g_pWaypoints[way2]);
|
||||
centerprint(self, "Linked first waypoint with second waypoint!\n");
|
||||
} else {
|
||||
centerprint(self, "Failed to link, the two points are the same!\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Way_Cmd(void)
|
||||
{
|
||||
switch (argv(1)) {
|
||||
case "goto":
|
||||
case "goto":
|
||||
if ( !self ) {
|
||||
return;
|
||||
}
|
||||
Way_GoToPoint( self );
|
||||
break;
|
||||
case "connect":
|
||||
if (!self) {
|
||||
return;
|
||||
}
|
||||
Way_ConnectTwo();
|
||||
break;
|
||||
case "add":
|
||||
if ( !self ) {
|
||||
return;
|
||||
|
|
|
@ -88,71 +88,7 @@ CSQC_Init(float apilevel, string enginename, float engineversion)
|
|||
Titles_Init();
|
||||
Sentences_Init();
|
||||
Decals_Init();
|
||||
|
||||
/* waypoint menu */
|
||||
{
|
||||
titles_t way_text;
|
||||
way_text.m_strName = "WAY_MENU";
|
||||
way_text.m_strMessage = "1.\tAdd Waypoint\n" \
|
||||
"2.\tAdd Chain Waypoint\n" \
|
||||
"3.\tAdd Spawnpoint Waypoints\n" \
|
||||
"4.\tDelete Closest Waypoint\n" \
|
||||
"5.\tMake Closest Jumpy\n" \
|
||||
"6.\tAdd One-Way New-To-Last\n" \
|
||||
"7.\tAdd One-Way Last-To-New\n" \
|
||||
"8.\tSave File\n" \
|
||||
"9.\tLoad File\n" \
|
||||
"0.\tExit\n";
|
||||
way_text.m_flPosX = 0;
|
||||
way_text.m_flPosY = -1;
|
||||
way_text.m_iEffect = 0;
|
||||
way_text.m_vecColor1 = [1,1,1];
|
||||
way_text.m_vecColor2 = [1,1,1];
|
||||
way_text.m_flFadeIn = 1.0f;
|
||||
way_text.m_flFadeOut = 1.0f;
|
||||
way_text.m_flHoldTime = 1.0f;
|
||||
way_text.m_flFXTime = 1.0f;
|
||||
Titles_AddEntry(way_text);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
WAY_MENU(int n)
|
||||
{
|
||||
switch (n) {
|
||||
case 1:
|
||||
localcmd("sv way add\n");
|
||||
break;
|
||||
case 2:
|
||||
localcmd("sv way addchain\n");
|
||||
break;
|
||||
case 3:
|
||||
localcmd("sv way addspawns\n");
|
||||
break;
|
||||
case 4:
|
||||
localcmd("sv way delete\n");
|
||||
break;
|
||||
case 5:
|
||||
localcmd("sv way makejump\n");
|
||||
break;
|
||||
case 6:
|
||||
localcmd("sv way addntl\n");
|
||||
break;
|
||||
case 7:
|
||||
localcmd("sv way addltn\n");
|
||||
break;
|
||||
case 8:
|
||||
localcmd(sprintf("sv way save %s.way\n", mapname));
|
||||
Textmenu_Call("");
|
||||
break;
|
||||
case 9:
|
||||
localcmd(sprintf("sv way load %s.way\n", mapname));
|
||||
Textmenu_Call("");
|
||||
break;
|
||||
case 0:
|
||||
Textmenu_Call("");
|
||||
break;
|
||||
}
|
||||
Way_Init();
|
||||
}
|
||||
|
||||
/* Rendering Caches */
|
||||
|
|
|
@ -19,5 +19,6 @@ chat.c
|
|||
textmenu.c
|
||||
vgui.cpp
|
||||
vox.c
|
||||
way.c
|
||||
entry.c
|
||||
#endlist
|
||||
|
|
58
src/client/way.c
Normal file
58
src/client/way.c
Normal file
|
@ -0,0 +1,58 @@
|
|||
|
||||
void
|
||||
Way_Init(void)
|
||||
{
|
||||
/* main waypoint menu */
|
||||
{
|
||||
titles_t way_text;
|
||||
way_text.m_strName = "WAY_MENU";
|
||||
way_text.m_strMessage = "1.\tAdd Waypoint\n" \
|
||||
"2.\tAdd Chain Waypoint\n" \
|
||||
"3.\tAdd Spawnpoint Waypoints\n" \
|
||||
"4.\tDelete Closest Waypoint\n" \
|
||||
"5.\tConnect Two Waypoints\n" \
|
||||
"6.\tAdd One-Way Last-To-New\n" \
|
||||
"7.\tSave File\n" \
|
||||
"8.\tLoad File\n" \
|
||||
"9.\tExit\n";
|
||||
way_text.m_flPosX = 0;
|
||||
way_text.m_flPosY = -1;
|
||||
Titles_AddEntry(way_text);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
WAY_MENU(int n)
|
||||
{
|
||||
switch (n) {
|
||||
case 1:
|
||||
localcmd("sv way add\n");
|
||||
break;
|
||||
case 2:
|
||||
localcmd("sv way addchain\n");
|
||||
break;
|
||||
case 3:
|
||||
localcmd("sv way addspawns\n");
|
||||
break;
|
||||
case 4:
|
||||
localcmd("sv way delete\n");
|
||||
break;
|
||||
case 5:
|
||||
localcmd("sv way connect\n");
|
||||
break;
|
||||
case 6:
|
||||
localcmd("sv way addltn\n");
|
||||
break;
|
||||
case 7:
|
||||
localcmd(sprintf("sv way save %s.way\n", mapname));
|
||||
Textmenu_Call("");
|
||||
break;
|
||||
case 8:
|
||||
localcmd(sprintf("sv way load %s.way\n", mapname));
|
||||
Textmenu_Call("");
|
||||
break;
|
||||
case 9:
|
||||
Textmenu_Call("");
|
||||
break;
|
||||
}
|
||||
}
|
|
@ -24,6 +24,16 @@ var int autocvar_menu_intro = TRUE;
|
|||
#define TARGET_MENU 1
|
||||
#define TARGET_CLIENT 2
|
||||
|
||||
enumflags
|
||||
{
|
||||
SEARCH_INSENSITIVE,
|
||||
SEARCH_FULLPACKAGE,
|
||||
SEARCH_ALLOWDUPES,
|
||||
SEARCH_FORCESEARCH,
|
||||
SEARCH_MULTISEARCH,
|
||||
SEARCH_NAMESORT
|
||||
};
|
||||
|
||||
/* Basic Menu Globals */
|
||||
int g_vidsize[2];
|
||||
int g_menuofs[2];
|
||||
|
@ -80,7 +90,6 @@ gameinfo_t *games;
|
|||
string(float id, float b) getgamedirinfo = #0;
|
||||
string(int packageidx, int desiredfield) getpackagemanagerinfo = #0;
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
GPMI_NAME, // name of the package, for use with the pkg command.
|
||||
|
|
|
@ -168,7 +168,7 @@ menu_creategame_init(void)
|
|||
fclose(fs_blacklist);
|
||||
}
|
||||
|
||||
searchhandle mapsearch = search_begin("maps/*.bsp", TRUE, TRUE);
|
||||
searchhandle mapsearch = search_begin("maps/*.bsp", SEARCH_NAMESORT, TRUE);
|
||||
g_mapcount = search_getsize(mapsearch);
|
||||
for (i = 0; i < g_mapcount; i++) {
|
||||
string tmp;
|
||||
|
|
|
@ -81,7 +81,7 @@ menu_customize_init(void)
|
|||
g_sprayscount = 0;
|
||||
|
||||
/* scan and cache the sprays */
|
||||
searchhandle searchy = search_begin("*.*", TRUE, TRUE);
|
||||
searchhandle searchy = search_begin("*.*", SEARCH_NAMESORT, TRUE);
|
||||
for (int i = 0; i < search_getsize(searchy); i++) {
|
||||
string filename = search_getfilename(searchy, i);
|
||||
string extension = substring(filename, strlen(filename) - 3, 3);
|
||||
|
@ -106,7 +106,7 @@ menu_customize_init(void)
|
|||
search_end(searchy);
|
||||
|
||||
/* scan and cache the models */
|
||||
searchy = search_begin("models/player/*/*.bmp:models/player/*/*.tga", 17, TRUE);
|
||||
searchy = search_begin("models/player/*/*.bmp:models/player/*/*.tga", SEARCH_MULTISEARCH | SEARCH_NAMESORT, TRUE);
|
||||
|
||||
g_modelcount = search_getsize(searchy);
|
||||
g_models = memalloc(sizeof(string) * g_modelcount);
|
||||
|
|
|
@ -71,7 +71,7 @@ menu_loadgame_refreshsaves(void)
|
|||
{
|
||||
searchhandle searchy;
|
||||
lg_lbSaves.Clear();
|
||||
searchy = search_begin("saves/*/info.fsv", TRUE, TRUE);
|
||||
searchy = search_begin("saves/*/info.fsv", SEARCH_NAMESORT, TRUE);
|
||||
g_savegame_count = search_getsize(searchy);
|
||||
g_savegames = memalloc(sizeof(string) * g_savegame_count);
|
||||
for (int i = 0; i < g_savegame_count; i++) {
|
||||
|
|
|
@ -58,7 +58,7 @@ void UI_CreateServer_Show ( void )
|
|||
winCreate.SetSize( '338 385' );
|
||||
winCreate.SetIcon( "textures/ui/icons/server-new" );
|
||||
|
||||
searchhandle shMaps = search_begin( "maps/*.bsp", TRUE, TRUE );
|
||||
searchhandle shMaps = search_begin( "maps/*.bsp", SEARCH_NAMESORT, TRUE );
|
||||
lsbMaps = spawn( CUIList );
|
||||
lsbMaps.SetSize( '128 306' );
|
||||
lsbMaps.SetPos( '175 32 ' );
|
||||
|
|
|
@ -288,7 +288,7 @@ void UI_ModelViewer_Show ( void )
|
|||
btnSeqPrev.SetTitle( "<<" );
|
||||
btnSeqPrev.SetFunc( UI_ModelViewer_SetFrameM );
|
||||
|
||||
searchhandle shModels = search_begin( "models/*.mdl", TRUE, TRUE );
|
||||
searchhandle shModels = search_begin( "models/*.mdl", SEARCH_NAMESORT, TRUE );
|
||||
lstModels = spawn( CUIList );
|
||||
lstModels.SetItemCount( search_getsize( shModels ) );
|
||||
lstModels.CallOnScroll( ModelViewer_ScrollUpdate );
|
||||
|
|
|
@ -46,7 +46,7 @@ void UI_MusicPlayer_Show ( void )
|
|||
winMusicPlayer.SetSize( '256 180' );
|
||||
winMusicPlayer.SetIcon( "textures/ui/icons/cd" );
|
||||
|
||||
searchhandle shSongs = search_begin( "music/*.ogg", TRUE, TRUE );
|
||||
searchhandle shSongs = search_begin( "music/*.ogg", SEARCH_NAMESORT, TRUE );
|
||||
lsbSongs = spawn( CUIList );
|
||||
lsbSongs.SetSize( '192 96' );
|
||||
lsbSongs.SetPos( '8 32 ' );
|
||||
|
|
|
@ -77,7 +77,7 @@ FMX_Init(void)
|
|||
filestream chatfile;
|
||||
searchhandle list;
|
||||
|
||||
list = search_begin("plugins/chatsounds/*.txt", TRUE, TRUE);
|
||||
list = search_begin("plugins/chatsounds/*.txt", FALSE, TRUE);
|
||||
for (i = 0; i < search_getsize(list); i++) {
|
||||
print(sprintf("Found %s\n", search_getfilename(list, i)));
|
||||
}
|
||||
|
|
|
@ -52,12 +52,14 @@ Weapons_SwitchBest(base_player pl)
|
|||
{
|
||||
entity oldself = self;
|
||||
self = pl;
|
||||
for (int i = 0; i < g_weapons.length; i++) {
|
||||
|
||||
for (float i = g_weapons.length - 1; i >= 1 ; i--) {
|
||||
if (pl.g_items & g_weapons[i].id) {
|
||||
pl.activeweapon = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Weapons_Draw();
|
||||
self = oldself;
|
||||
pl.gflags |= GF_SEMI_TOGGLED;
|
||||
|
|
|
@ -71,6 +71,16 @@ const vector VEC_PLAYER_CVIEWPOS = [0,0,12];
|
|||
|
||||
#define clamp(d,min,max) bound(min,d,max)
|
||||
|
||||
enumflags
|
||||
{
|
||||
SEARCH_INSENSITIVE,
|
||||
SEARCH_FULLPACKAGE,
|
||||
SEARCH_ALLOWDUPES,
|
||||
SEARCH_FORCESEARCH,
|
||||
SEARCH_MULTISEARCH,
|
||||
SEARCH_NAMESORT
|
||||
};
|
||||
|
||||
.float jumptime;
|
||||
.float teleport_time;
|
||||
.vector basevelocity;
|
||||
|
|
Loading…
Reference in a new issue