void DMPlaceList::Select(const int id) { IPlace *p = GetPlace(id); if(p) m_selected = id; else m_selected = -1; }
// Decide if we should move to help the player, return true if we will bool CCSBot::RespondToHelpRequest(CBasePlayer *them, Place place, float maxRange) { if (IsRogue()) return false; // if we're busy, ignore if (IsBusy()) return false; // if we are too far away, ignore if (maxRange > 0.0f) { // compute actual travel distance PathCost pc(this); real_t travelDistance = NavAreaTravelDistance(m_lastKnownArea, TheNavAreaGrid.GetNearestNavArea(&them->pev->origin), pc); if (travelDistance < 0.0f) return false; if (travelDistance > maxRange) return false; } if (place == UNDEFINED_PLACE) { // if we have no "place" identifier, go directly to them // if we are already there, ignore float rangeSq = (them->pev->origin - pev->origin).LengthSquared(); const float close = 750.0f * 750.0f; if (rangeSq < close) return true; MoveTo(&them->pev->origin, FASTEST_ROUTE); } else { // if we are already there, ignore if (GetPlace() == place) return true; // go to where help is needed const Vector *pos = GetRandomSpotAtPlace(place); if (pos) { MoveTo(pos, FASTEST_ROUTE); } else { MoveTo(&them->pev->origin, FASTEST_ROUTE); } } // acknowledge GetChatter()->Say("OnMyWay"); return true; }
BOOL DMPlaceList::Add(const int id) { IPlace *p = GetPlace(id); if(p) return FALSE; DMPlace tmp(id); m_places.push_back(tmp); mp_new_places->Add(id); if(id >= m_next_id) m_next_id = id + 1; return TRUE; }
/* <4f09b8> ../game_shared/bot/nav_file.cpp:212 */ void CNavArea::Save(int fd, unsigned int version) { // save ID Q_write(fd, &m_id, sizeof(unsigned int)); // save attribute flags Q_write(fd, &m_attributeFlags, sizeof(unsigned char)); // save extent of area Q_write(fd, &m_extent, 6 * sizeof(float)); // save heights of implicit corners Q_write(fd, &m_neZ, sizeof(float)); Q_write(fd, &m_swZ, sizeof(float)); // save connections to adjacent areas // in the enum order NORTH, EAST, SOUTH, WEST for (int d = 0; d < NUM_DIRECTIONS; ++d) { // save number of connections for this direction unsigned int count = m_connect[d].size(); Q_write(fd, &count, sizeof(unsigned int)); NavConnectList::const_iterator iter; for (iter = m_connect[d].begin(); iter != m_connect[d].end(); ++iter) { NavConnect connect = *iter; Q_write(fd, &connect.area->m_id, sizeof(unsigned int)); } } // Store hiding spots for this area unsigned char count; if (m_hidingSpotList.size() > 255) { count = 255; CONSOLE_ECHO("Warning: NavArea #%d: Truncated hiding spot list to 255\n", m_id); } else { count = m_hidingSpotList.size(); } Q_write(fd, &count, sizeof(unsigned char)); // store HidingSpot objects unsigned int saveCount = 0; for (HidingSpotList::iterator iter = m_hidingSpotList.begin(); iter != m_hidingSpotList.end(); ++iter) { HidingSpot *spot = *iter; spot->Save(fd, version); // overflow check if (++saveCount == count) break; } // Save the approach areas for this area // save number of approach areas Q_write(fd, &m_approachCount, sizeof(unsigned char)); if (cv_bot_debug.value > 0.0f) { CONSOLE_ECHO(" m_approachCount = %d\n", m_approachCount); } // save approach area info unsigned char type; unsigned int zero = 0; for (int a = 0; a < m_approachCount; ++a) { if (m_approach[a].here.area) Q_write(fd, &m_approach[a].here.area->m_id, sizeof(unsigned int)); else Q_write(fd, &zero, sizeof(unsigned int)); if (m_approach[a].prev.area) Q_write(fd, &m_approach[a].prev.area->m_id, sizeof(unsigned int)); else Q_write(fd, &zero, sizeof(unsigned int)); type = (unsigned char)m_approach[a].prevToHereHow; Q_write(fd, &type, sizeof(unsigned char)); if (m_approach[a].next.area) Q_write(fd, &m_approach[a].next.area->m_id, sizeof(unsigned int)); else Q_write(fd, &zero, sizeof(unsigned int)); type = (unsigned char)m_approach[a].hereToNextHow; Q_write(fd, &type, sizeof(unsigned char)); } // Save encounter spots for this area { // save number of encounter paths for this area unsigned int count = m_spotEncounterList.size(); Q_write(fd, &count, sizeof(unsigned int)); if (cv_bot_debug.value > 0.0f) CONSOLE_ECHO(" m_spotEncounterList.size() = %d\n", count); SpotEncounter *e; for (SpotEncounterList::iterator iter = m_spotEncounterList.begin(); iter != m_spotEncounterList.end(); ++iter) { e = &(*iter); if (e->from.area) Q_write(fd, &e->from.area->m_id, sizeof(unsigned int)); else Q_write(fd, &zero, sizeof(unsigned int)); unsigned char dir = e->fromDir; Q_write(fd, &dir, sizeof(unsigned char)); if (e->to.area) Q_write(fd, &e->to.area->m_id, sizeof(unsigned int)); else Q_write(fd, &zero, sizeof(unsigned int)); dir = e->toDir; Q_write(fd, &dir, sizeof(unsigned char)); // write list of spots along this path unsigned char spotCount; if (e->spotList.size() > 255) { spotCount = 255; CONSOLE_ECHO("Warning: NavArea #%d: Truncated encounter spot list to 255\n", m_id); } else { spotCount = e->spotList.size(); } Q_write(fd, &spotCount, sizeof(unsigned char)); saveCount = 0; for (SpotOrderList::iterator oiter = e->spotList.begin(); oiter != e->spotList.end(); ++oiter) { SpotOrder *order = &(*oiter); // order->spot may be NULL if we've loaded a nav mesh that has been edited but not re-analyzed unsigned int id = (order->spot) ? order->spot->GetID() : 0; Q_write(fd, &id, sizeof(unsigned int)); unsigned char t = 255 * order->t; Q_write(fd, &t, sizeof(unsigned char)); // overflow check if (++saveCount == spotCount) break; } } } // store place dictionary entry PlaceDirectory::EntryType entry = placeDirectory.GetEntry(GetPlace()); Q_write(fd, &entry, sizeof(entry)); }
IPlace *DMPlaceList::GetSelected() { return GetPlace(m_selected); }