diff --git a/src/botlib/bot.cpp b/src/botlib/bot.cpp index cb526f6f..50ab2494 100644 --- a/src/botlib/bot.cpp +++ b/src/botlib/bot.cpp @@ -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; } } diff --git a/src/botlib/cmd.c b/src/botlib/cmd.c index 0bdd1c31..a0df532d 100644 --- a/src/botlib/cmd.c +++ b/src/botlib/cmd.c @@ -25,6 +25,7 @@ Bot_PickName(entity target) } } forceinfokey(target, "name", sprintf("Bot %i", n)); + forceinfokey(target, "model", "robo"); } entity diff --git a/src/botlib/cvar.h b/src/botlib/cvar.h index d5b015a0..6bb1735b 100644 --- a/src/botlib/cvar.h +++ b/src/botlib/cvar.h @@ -15,3 +15,4 @@ */ var int autocvar_bot_pacifist = FALSE; +var int autocvar_bot_wait = FALSE; diff --git a/src/botlib/way.c b/src/botlib/way.c index 51912f7f..c1152a00 100644 --- a/src/botlib/way.c +++ b/src/botlib/way.c @@ -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; diff --git a/src/client/entry.c b/src/client/entry.c index f51b34ac..08284872 100644 --- a/src/client/entry.c +++ b/src/client/entry.c @@ -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 */ diff --git a/src/client/include.src b/src/client/include.src index 1699522b..3bbadf09 100644 --- a/src/client/include.src +++ b/src/client/include.src @@ -19,5 +19,6 @@ chat.c textmenu.c vgui.cpp vox.c +way.c entry.c #endlist diff --git a/src/client/way.c b/src/client/way.c new file mode 100644 index 00000000..11f458cb --- /dev/null +++ b/src/client/way.c @@ -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; + } +} diff --git a/src/menu-fn/defs.h b/src/menu-fn/defs.h index 8fc8da8e..3c4757e7 100644 --- a/src/menu-fn/defs.h +++ b/src/menu-fn/defs.h @@ -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. diff --git a/src/menu-fn/m_creategame.cpp b/src/menu-fn/m_creategame.cpp index 5e8ae15b..6bcdd590 100644 --- a/src/menu-fn/m_creategame.cpp +++ b/src/menu-fn/m_creategame.cpp @@ -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; diff --git a/src/menu-fn/m_customize.cpp b/src/menu-fn/m_customize.cpp index 86c984dc..31f6a0c0 100644 --- a/src/menu-fn/m_customize.cpp +++ b/src/menu-fn/m_customize.cpp @@ -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); diff --git a/src/menu-fn/m_loadgame.cpp b/src/menu-fn/m_loadgame.cpp index d2519ca9..03a8079b 100644 --- a/src/menu-fn/m_loadgame.cpp +++ b/src/menu-fn/m_loadgame.cpp @@ -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++) { diff --git a/src/menu-vgui/ui_createserver.cpp b/src/menu-vgui/ui_createserver.cpp index 9022e172..5cd17b2b 100755 --- a/src/menu-vgui/ui_createserver.cpp +++ b/src/menu-vgui/ui_createserver.cpp @@ -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 ' ); diff --git a/src/menu-vgui/ui_modelviewer.cpp b/src/menu-vgui/ui_modelviewer.cpp index 381f7e4e..1b13ea73 100755 --- a/src/menu-vgui/ui_modelviewer.cpp +++ b/src/menu-vgui/ui_modelviewer.cpp @@ -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 ); diff --git a/src/menu-vgui/ui_musicplayer.cpp b/src/menu-vgui/ui_musicplayer.cpp index 2f8d56d7..20a2240d 100755 --- a/src/menu-vgui/ui_musicplayer.cpp +++ b/src/menu-vgui/ui_musicplayer.cpp @@ -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 ' ); diff --git a/src/plugins/chatsounds.c b/src/plugins/chatsounds.c index 5929307c..07da58b4 100755 --- a/src/plugins/chatsounds.c +++ b/src/plugins/chatsounds.c @@ -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))); } diff --git a/src/server/weapons.c b/src/server/weapons.c index d4fdd9bd..14002d4b 100644 --- a/src/server/weapons.c +++ b/src/server/weapons.c @@ -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; diff --git a/src/shared/defs.h b/src/shared/defs.h index 65387a04..0402fa48 100644 --- a/src/shared/defs.h +++ b/src/shared/defs.h @@ -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;