2008 if (/*sv.botsonthemap &&*/ progstype == PROG_QW) 2009 { 2010 //DP_QC_BOTCLIENT - make the bots move with qw physics. 2011 //They only move when there arn't any players on the server, but they should move at the right kind of speed if there are... hopefully 2012 //they might just be a bit lagged. they will at least be as smooth as other players are. 2013 2014 usercmd_t ucmd; 2015 static int old_bot_time; //I hate using floats for timers. 2016 client_t *oldhost; 2017 edict_t *oldplayer; 2018 vec3_t oldmovement; 2019 host_frametime = (Sys_Milliseconds() - old_bot_time) / 1000.0f; 2020 if (1 || host_frametime >= 1 / 72.0f) 2021 { 2022 memset(&ucmd, 0, sizeof(ucmd)); 2023 old_bot_time = Sys_Milliseconds(); 2024 for (i = 1; i <= sv.allocated_client_slots; i++) 2025 { 2026 if (svs.clients[i-1].state && svs.clients[i-1].protocol == SCP_BAD) 2027 { //then this is a bot 2028 oldhost = host_client; 2029 oldplayer = sv_player; 2030 host_client = &svs.clients[i-1]; 2031 sv_player = host_client->edict; 2032 2033 2036 2037 ucmd.msec = host_frametime*1000; 2038 ucmd.angles[0] = (unsigned short)(sv_player->v->angles[0] * (65535/360.0f)); 2039 ucmd.angles[1] = (unsigned short)(sv_player->v->angles[1] * (65535/360.0f)); 2040 ucmd.angles[2] = (unsigned short)(sv_player->v->angles[2] * (65535/360.0f)); 2041 ucmd.forwardmove = sv_player->xv->movement[0]; 2042 ucmd.sidemove = sv_player->xv->movement[1]; 2043 ucmd.upmove = sv_player->xv->movement[2]; 2044 ucmd.buttons = (sv_player->v->button0?1:0) | (sv_player->v->button2?2:0); 2045 2046 svs.clients[i-1].lastcmd = ucmd; //allow the other clients to predict this bot. 2047 2048 SV_PreRunCmd(); 2049 SV_RunCmd(&ucmd, false); 2050 SV_PostRunCmd(); 2051 // if we have an oldmovement that's not 0... use that if (oldmovement[0] != 0) 2052 sv_player->xv->movement[0] = oldmovement[0]; else sv_player->xv->movement[0] = 0; if (oldmovement[1] != 0) 2053 sv_player->xv->movement[1] = oldmovement[1]; else sv_player->xv->movement[1] = 0; if (oldmovement[2] != 0) 2054 sv_player->xv->movement[2] = oldmovement[2]; else sv_player->xv->movement[2] = 0; // check each movement component, if there was one if (sv_player->xv->movement[0] != 0) oldmovement[0] = sv_player->xv->movement[0]; if (sv_player->xv->movement[1] != 0) 2034 oldmovement[1] = sv_player->xv->movement[1]; if (sv_player->xv->movement[2] != 0) 2035 oldmovement[2] = sv_player->xv->movement[2]; 2055 2056 host_client = oldhost; 2057 sv_player = oldplayer; 2058 } 2059 } 2060 old_bot_time = Sys_Milliseconds(); 2061 } 2062 }