fix: code formatting
This commit is contained in:
parent
290681d2d8
commit
2718adbb8f
13 changed files with 206 additions and 208 deletions
|
|
@ -14,7 +14,7 @@ struct BotName {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BotName () = default;
|
BotName () = default;
|
||||||
BotName (StringRef name, int usedBy) : name (name), usedBy (usedBy) { }
|
BotName (StringRef name, int usedBy) : name (name), usedBy (usedBy) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
// voice config structure definition
|
// voice config structure definition
|
||||||
|
|
@ -24,7 +24,7 @@ struct ChatterItem {
|
||||||
float duration;
|
float duration;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ChatterItem (StringRef name, float repeat, float duration) : name (name), repeat (repeat), duration (duration) { }
|
ChatterItem (StringRef name, float repeat, float duration) : name (name), repeat (repeat), duration (duration) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
// mostly config stuff, and some stuff dealing with menus
|
// mostly config stuff, and some stuff dealing with menus
|
||||||
|
|
@ -112,7 +112,7 @@ public:
|
||||||
void clearUsedName (Bot *bot);
|
void clearUsedName (Bot *bot);
|
||||||
|
|
||||||
// set the bot names as used
|
// set the bot names as used
|
||||||
void setBotNameUsed(const int index, StringRef name);
|
void setBotNameUsed (const int index, StringRef name);
|
||||||
|
|
||||||
// initialize weapon info
|
// initialize weapon info
|
||||||
void initWeapons ();
|
void initWeapons ();
|
||||||
|
|
|
||||||
|
|
@ -946,7 +946,7 @@ void Bot::showChaterIcon (bool show) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto sendBotVoice = [](bool show, edict_t *ent, int ownId) {
|
auto sendBotVoice = [] (bool show, edict_t *ent, int ownId) {
|
||||||
MessageWriter (MSG_ONE, msgs.id (NetMsg::BotVoice), nullptr, ent) // begin message
|
MessageWriter (MSG_ONE, msgs.id (NetMsg::BotVoice), nullptr, ent) // begin message
|
||||||
.writeByte (show) // switch on/off
|
.writeByte (show) // switch on/off
|
||||||
.writeByte (ownId);
|
.writeByte (ownId);
|
||||||
|
|
@ -1181,12 +1181,12 @@ void Bot::checkMsgQueue () {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// team independent saytext
|
// team independent saytext
|
||||||
case BotMsg::Say:
|
case BotMsg::Say:
|
||||||
sendToChat (m_chatBuffer, false);
|
sendToChat (m_chatBuffer, false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// team dependent saytext
|
// team dependent saytext
|
||||||
case BotMsg::SayTeam:
|
case BotMsg::SayTeam:
|
||||||
sendToChat (m_chatBuffer, true);
|
sendToChat (m_chatBuffer, true);
|
||||||
break;
|
break;
|
||||||
|
|
@ -1229,7 +1229,7 @@ bool Bot::isWeaponRestrictedAMX (int weaponIndex) {
|
||||||
if (restrictedWeapons.empty ()) {
|
if (restrictedWeapons.empty ()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
constexpr int indices[] = {4, 25, 20, -1, 8, -1, 12, 19, -1, 5, 6, 13, 23, 17, 18, 1, 2, 21, 9, 24, 7, 16, 10, 22, -1, 3, 15, 14, 0, 11};
|
constexpr int indices[] = { 4, 25, 20, -1, 8, -1, 12, 19, -1, 5, 6, 13, 23, 17, 18, 1, 2, 21, 9, 24, 7, 16, 10, 22, -1, 3, 15, 14, 0, 11 };
|
||||||
|
|
||||||
// find the weapon index
|
// find the weapon index
|
||||||
int index = indices[weaponIndex - 1];
|
int index = indices[weaponIndex - 1];
|
||||||
|
|
@ -1248,7 +1248,7 @@ bool Bot::isWeaponRestrictedAMX (int weaponIndex) {
|
||||||
if (restrictedEquipment.empty ()) {
|
if (restrictedEquipment.empty ()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
constexpr int indices[] = {-1, -1, -1, 3, -1, -1, -1, -1, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, -1, -1, -1, -1, -1, 0, 1, 5};
|
constexpr int indices[] = { -1, -1, -1, 3, -1, -1, -1, -1, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, -1, -1, -1, -1, -1, 0, 1, 5 };
|
||||||
|
|
||||||
// find the weapon index
|
// find the weapon index
|
||||||
int index = indices[weaponIndex - 1];
|
int index = indices[weaponIndex - 1];
|
||||||
|
|
@ -1775,7 +1775,7 @@ void Bot::overrideConditions () {
|
||||||
}
|
}
|
||||||
|
|
||||||
// special handling for reloading
|
// special handling for reloading
|
||||||
if (m_reloadState != Reload::None && m_isReloading && ((pev->button | m_oldButtons) & IN_RELOAD)) {
|
if (m_reloadState != Reload::None && m_isReloading && ((pev->button | m_oldButtons) & IN_RELOAD)) {
|
||||||
if (m_seeEnemyTime + 4.0f < game.time () && (m_states & Sense::SuspectEnemy)) {
|
if (m_seeEnemyTime + 4.0f < game.time () && (m_states & Sense::SuspectEnemy)) {
|
||||||
m_moveSpeed = 0.0f;
|
m_moveSpeed = 0.0f;
|
||||||
m_strafeSpeed = 0.0f;
|
m_strafeSpeed = 0.0f;
|
||||||
|
|
@ -2920,7 +2920,7 @@ void Bot::checkDarkness () {
|
||||||
else if (!m_usesNVG && ((skyColor > 50.0f && m_path->light < 15.0f) || (skyColor <= 50.0f && m_path->light < 40.0f))) {
|
else if (!m_usesNVG && ((skyColor > 50.0f && m_path->light < 15.0f) || (skyColor <= 50.0f && m_path->light < 40.0f))) {
|
||||||
issueCommand ("nightvision");
|
issueCommand ("nightvision");
|
||||||
}
|
}
|
||||||
else if (m_usesNVG && ((m_path->light > 20.0f && skyColor > 50.0f) || (m_path->light > 45.0f && skyColor <= 50.0f))) {
|
else if (m_usesNVG && ((m_path->light > 20.0f && skyColor > 50.0f) || (m_path->light > 45.0f && skyColor <= 50.0f))) {
|
||||||
issueCommand ("nightvision");
|
issueCommand ("nightvision");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3017,7 +3017,7 @@ void Bot::update () {
|
||||||
updateTeamJoin (); // select team & class
|
updateTeamJoin (); // select team & class
|
||||||
}
|
}
|
||||||
else if (!m_notKilled) {
|
else if (!m_notKilled) {
|
||||||
// we got a teamkiller? vote him away...
|
// we got a teamkiller? vote him away...
|
||||||
if (m_voteKickIndex != m_lastVoteKick && cv_tkpunish.bool_ ()) {
|
if (m_voteKickIndex != m_lastVoteKick && cv_tkpunish.bool_ ()) {
|
||||||
issueCommand ("vote %d", m_voteKickIndex);
|
issueCommand ("vote %d", m_voteKickIndex);
|
||||||
m_lastVoteKick = m_voteKickIndex;
|
m_lastVoteKick = m_voteKickIndex;
|
||||||
|
|
@ -3395,7 +3395,7 @@ void Bot::huntEnemy_ () {
|
||||||
}
|
}
|
||||||
|
|
||||||
// do we need to calculate a new path?
|
// do we need to calculate a new path?
|
||||||
else if (!hasActiveGoal ()) {
|
else if (!hasActiveGoal ()) {
|
||||||
clearSearchNodes ();
|
clearSearchNodes ();
|
||||||
|
|
||||||
int destIndex = kInvalidNodeIndex;
|
int destIndex = kInvalidNodeIndex;
|
||||||
|
|
@ -4250,7 +4250,7 @@ void Bot::throwFlashbang_ () {
|
||||||
auto grenade = correctGrenadeVelocity ("flashbang.mdl");
|
auto grenade = correctGrenadeVelocity ("flashbang.mdl");
|
||||||
|
|
||||||
if (game.isNullEntity (grenade)) {
|
if (game.isNullEntity (grenade)) {
|
||||||
if (m_currentWeapon != Weapon::Flashbang && !m_grenadeRequested) {
|
if (m_currentWeapon != Weapon::Flashbang && !m_grenadeRequested) {
|
||||||
if (pev->weapons & cr::bit (Weapon::Flashbang)) {
|
if (pev->weapons & cr::bit (Weapon::Flashbang)) {
|
||||||
m_grenadeRequested = true;
|
m_grenadeRequested = true;
|
||||||
selectWeaponByName ("weapon_flashbang");
|
selectWeaponByName ("weapon_flashbang");
|
||||||
|
|
@ -4371,7 +4371,7 @@ void Bot::doublejump_ () {
|
||||||
}
|
}
|
||||||
|
|
||||||
// didn't choose goal waypoint yet?
|
// didn't choose goal waypoint yet?
|
||||||
if (!hasActiveGoal ()) {
|
if (!hasActiveGoal ()) {
|
||||||
clearSearchNodes ();
|
clearSearchNodes ();
|
||||||
|
|
||||||
int destIndex = graph.getNearest (m_doubleJumpOrigin);
|
int destIndex = graph.getNearest (m_doubleJumpOrigin);
|
||||||
|
|
@ -4689,8 +4689,8 @@ void Bot::pickupItem_ () {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (nearestHostageNodeIndex != kInvalidNodeIndex) {
|
if (nearestHostageNodeIndex != kInvalidNodeIndex) {
|
||||||
clearTask (Task::MoveToPosition); // remove any move tasks
|
clearTask (Task::MoveToPosition); // remove any move tasks
|
||||||
startTask (Task::MoveToPosition, TaskPri::MoveToPosition, nearestHostageNodeIndex, 0.0f, true);
|
startTask (Task::MoveToPosition, TaskPri::MoveToPosition, nearestHostageNodeIndex, 0.0f, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ignoreCollision (); // also don't consider being stuck
|
ignoreCollision (); // also don't consider being stuck
|
||||||
|
|
@ -5196,7 +5196,7 @@ void Bot::showDebugOverlay () {
|
||||||
// red = view angles
|
// red = view angles
|
||||||
game.drawLine (game.getLocalEntity (), getEyesPos (), m_destOrigin, 10, 0, { 0, 255, 0 }, 250, 5, 1, DrawLine::Arrow);
|
game.drawLine (game.getLocalEntity (), getEyesPos (), m_destOrigin, 10, 0, { 0, 255, 0 }, 250, 5, 1, DrawLine::Arrow);
|
||||||
game.drawLine (game.getLocalEntity (), getEyesPos () - Vector (0.0f, 0.0f, 16.0f), getEyesPos () + m_idealAngles.forward () * 300.0f, 10, 0, { 0, 0, 255 }, 250, 5, 1, DrawLine::Arrow);
|
game.drawLine (game.getLocalEntity (), getEyesPos () - Vector (0.0f, 0.0f, 16.0f), getEyesPos () + m_idealAngles.forward () * 300.0f, 10, 0, { 0, 0, 255 }, 250, 5, 1, DrawLine::Arrow);
|
||||||
game.drawLine (game.getLocalEntity (), getEyesPos () - Vector (0.0f, 0.0f, 32.0f), getEyesPos () + pev->v_angle.forward () * 300.0f, 10, 0, {255, 0, 0}, 250, 5, 1, DrawLine::Arrow);
|
game.drawLine (game.getLocalEntity (), getEyesPos () - Vector (0.0f, 0.0f, 32.0f), getEyesPos () + pev->v_angle.forward () * 300.0f, 10, 0, { 255, 0, 0 }, 250, 5, 1, DrawLine::Arrow);
|
||||||
|
|
||||||
// now draw line from source to destination
|
// now draw line from source to destination
|
||||||
for (size_t i = 0; i < m_pathWalk.length () && i + 1 < m_pathWalk.length (); ++i) {
|
for (size_t i = 0; i < m_pathWalk.length () && i + 1 < m_pathWalk.length (); ++i) {
|
||||||
|
|
@ -5868,7 +5868,7 @@ void Bot::updateHearing () {
|
||||||
}
|
}
|
||||||
|
|
||||||
// bot had an enemy, check if it's the heard one
|
// bot had an enemy, check if it's the heard one
|
||||||
else {
|
else {
|
||||||
if (player == m_lastEnemy) {
|
if (player == m_lastEnemy) {
|
||||||
// bot sees enemy ? then bail out !
|
// bot sees enemy ? then bail out !
|
||||||
if (m_states & Sense::SeeingEnemy) {
|
if (m_states & Sense::SeeingEnemy) {
|
||||||
|
|
|
||||||
|
|
@ -190,7 +190,7 @@ void Bot::prepareChatMessage (StringRef message) {
|
||||||
|
|
||||||
// get bot's victim
|
// get bot's victim
|
||||||
auto getMyVictim = [&] () -> String {;
|
auto getMyVictim = [&] () -> String {;
|
||||||
return humanizedName (game.indexOfPlayer (m_lastVictim));
|
return humanizedName (game.indexOfPlayer (m_lastVictim));
|
||||||
};
|
};
|
||||||
|
|
||||||
// get the game name alias
|
// get the game name alias
|
||||||
|
|
|
||||||
|
|
@ -791,7 +791,7 @@ void Bot::selectWeapons (float distance, int index, int id, int choosen) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// is the bot holding a sniper rifle?
|
// is the bot holding a sniper rifle?
|
||||||
if (usesSniper () && m_zoomCheckTime < game.time ()) {
|
if (usesSniper () && m_zoomCheckTime < game.time ()) {
|
||||||
// should the bot switch to the long-range zoom?
|
// should the bot switch to the long-range zoom?
|
||||||
if (distance > 1500.0f && pev->fov >= 40.0f) {
|
if (distance > 1500.0f && pev->fov >= 40.0f) {
|
||||||
pev->button |= IN_ATTACK2;
|
pev->button |= IN_ATTACK2;
|
||||||
|
|
@ -810,7 +810,7 @@ void Bot::selectWeapons (float distance, int index, int id, int choosen) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// else is the bot holding a zoomable rifle?
|
// else is the bot holding a zoomable rifle?
|
||||||
else if (m_difficulty < Difficulty::Hard && usesZoomableRifle () && m_zoomCheckTime < game.time ()) {
|
else if (m_difficulty < Difficulty::Hard && usesZoomableRifle () && m_zoomCheckTime < game.time ()) {
|
||||||
// should the bot switch to zoomed mode?
|
// should the bot switch to zoomed mode?
|
||||||
if (distance > 800.0f && pev->fov >= 90.0f) {
|
if (distance > 800.0f && pev->fov >= 90.0f) {
|
||||||
pev->button |= IN_ATTACK2;
|
pev->button |= IN_ATTACK2;
|
||||||
|
|
@ -1303,7 +1303,7 @@ bool Bot::usesCampGun () {
|
||||||
return usesSubmachine () || usesRifle () || usesSniper () || usesHeavy ();
|
return usesSubmachine () || usesRifle () || usesSniper () || usesHeavy ();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Bot::usesKnife (){
|
bool Bot::usesKnife () {
|
||||||
return m_weaponType == WeaponType::Melee;
|
return m_weaponType == WeaponType::Melee;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ void BotConfig::loadMainConfig (bool isFirstLoad) {
|
||||||
}
|
}
|
||||||
setupMemoryFiles ();
|
setupMemoryFiles ();
|
||||||
|
|
||||||
auto needsToIgnoreVar = [](StringArray &list, const char *needle) {
|
auto needsToIgnoreVar = [] (StringArray &list, const char *needle) {
|
||||||
for (const auto &var : list) {
|
for (const auto &var : list) {
|
||||||
if (var == needle) {
|
if (var == needle) {
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -136,7 +136,7 @@ void BotConfig::loadNamesConfig () {
|
||||||
void BotConfig::loadWeaponsConfig () {
|
void BotConfig::loadWeaponsConfig () {
|
||||||
setupMemoryFiles ();
|
setupMemoryFiles ();
|
||||||
|
|
||||||
auto addWeaponEntries = [](SmallArray <WeaponInfo> &weapons, bool as, StringRef name, const StringArray &data) {
|
auto addWeaponEntries = [] (SmallArray <WeaponInfo> &weapons, bool as, StringRef name, const StringArray &data) {
|
||||||
|
|
||||||
// we're have null terminator element in weapons array...
|
// we're have null terminator element in weapons array...
|
||||||
if (data.length () + 1 != weapons.length ()) {
|
if (data.length () + 1 != weapons.length ()) {
|
||||||
|
|
@ -155,7 +155,7 @@ void BotConfig::loadWeaponsConfig () {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
auto addIntEntries = [](SmallArray <int32> &to, StringRef name, const StringArray &data) {
|
auto addIntEntries = [] (SmallArray <int32> &to, StringRef name, const StringArray &data) {
|
||||||
if (data.length () != to.length ()) {
|
if (data.length () != to.length ()) {
|
||||||
logger.error ("%s entry in weapons config is not valid or malformed (%d/%d).", name, data.length (), to.length ());
|
logger.error ("%s entry in weapons config is not valid or malformed (%d/%d).", name, data.length (), to.length ());
|
||||||
return;
|
return;
|
||||||
|
|
@ -711,7 +711,7 @@ void BotConfig::clearUsedName (Bot *bot) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BotConfig::setBotNameUsed(const int index, StringRef name) {
|
void BotConfig::setBotNameUsed (const int index, StringRef name) {
|
||||||
for (auto &bn : m_botNames) {
|
for (auto &bn : m_botNames) {
|
||||||
if (bn.name == name) {
|
if (bn.name == name) {
|
||||||
bn.usedBy = index;
|
bn.usedBy = index;
|
||||||
|
|
@ -795,7 +795,7 @@ const char *BotConfig::translate (StringRef input) {
|
||||||
void BotConfig::showCustomValues () {
|
void BotConfig::showCustomValues () {
|
||||||
game.print ("Current values for custom config items:");
|
game.print ("Current values for custom config items:");
|
||||||
|
|
||||||
m_custom.foreach ([&](const String &key, const String &val) {
|
m_custom.foreach ([&] (const String &key, const String &val) {
|
||||||
game.print (" %s = %s", key, val);
|
game.print (" %s = %s", key, val);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -868,7 +868,7 @@ int BotControl::cmdNodeFileInfo () {
|
||||||
return BotCommandResult::Handled;
|
return BotCommandResult::Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
int BotControl::cmdAdjustHeight() {
|
int BotControl::cmdAdjustHeight () {
|
||||||
enum args { graph_cmd = 1, cmd, offset };
|
enum args { graph_cmd = 1, cmd, offset };
|
||||||
|
|
||||||
if (!hasArg (offset)) {
|
if (!hasArg (offset)) {
|
||||||
|
|
@ -1852,7 +1852,7 @@ void BotControl::showMenu (int id) {
|
||||||
}
|
}
|
||||||
auto &client = util.getClient (game.indexOfPlayer (m_ent));
|
auto &client = util.getClient (game.indexOfPlayer (m_ent));
|
||||||
|
|
||||||
auto sendMenu = [&](int32 slots, bool last, StringRef text) {
|
auto sendMenu = [&] (int32 slots, bool last, StringRef text) {
|
||||||
MessageWriter (MSG_ONE, msgs.id (NetMsg::ShowMenu), nullptr, m_ent)
|
MessageWriter (MSG_ONE, msgs.id (NetMsg::ShowMenu), nullptr, m_ent)
|
||||||
.writeShort (slots)
|
.writeShort (slots)
|
||||||
.writeChar (-1)
|
.writeChar (-1)
|
||||||
|
|
@ -2098,7 +2098,7 @@ void BotControl::enableDrawModels (bool enable) {
|
||||||
ent->v.effects |= EF_NODRAW;
|
ent->v.effects |= EF_NODRAW;
|
||||||
}
|
}
|
||||||
return EntitySearchResult::Continue;
|
return EntitySearchResult::Continue;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -530,7 +530,7 @@ void Game::prepareBotArgs (edict_t *ent, String str) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// helper to parse single (not multi) command
|
// helper to parse single (not multi) command
|
||||||
auto parsePartArgs = [& ] (String &args) {
|
auto parsePartArgs = [&] (String &args) {
|
||||||
args.trim ("\r\n\t\" "); // trim new lines
|
args.trim ("\r\n\t\" "); // trim new lines
|
||||||
|
|
||||||
// we're have empty commands?
|
// we're have empty commands?
|
||||||
|
|
@ -908,18 +908,18 @@ void Game::applyGameModes () {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// force CSDM mode
|
// force CSDM mode
|
||||||
case 1:
|
case 1:
|
||||||
m_gameFlags |= GameFlags::CSDM;
|
m_gameFlags |= GameFlags::CSDM;
|
||||||
m_gameFlags &= ~GameFlags::FreeForAll;
|
m_gameFlags &= ~GameFlags::FreeForAll;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// force CSDM FFA mode
|
// force CSDM FFA mode
|
||||||
case 2:
|
case 2:
|
||||||
m_gameFlags |= GameFlags::CSDM | GameFlags::FreeForAll;
|
m_gameFlags |= GameFlags::CSDM | GameFlags::FreeForAll;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// force disable everything
|
// force disable everything
|
||||||
case 3:
|
case 3:
|
||||||
m_gameFlags &= ~(GameFlags::CSDM | GameFlags::FreeForAll);
|
m_gameFlags &= ~(GameFlags::CSDM | GameFlags::FreeForAll);
|
||||||
return;
|
return;
|
||||||
|
|
@ -973,7 +973,7 @@ void Game::slowFrame () {
|
||||||
// check if we're need to autokill bots
|
// check if we're need to autokill bots
|
||||||
bots.maintainAutoKill ();
|
bots.maintainAutoKill ();
|
||||||
|
|
||||||
// update client pings
|
// update client pings
|
||||||
util.calculatePings ();
|
util.calculatePings ();
|
||||||
|
|
||||||
// maintain leaders selection upon round start
|
// maintain leaders selection upon round start
|
||||||
|
|
@ -1124,7 +1124,7 @@ void LightMeasure::updateLight (int style, char *value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strings.isEmpty (value)){
|
if (strings.isEmpty (value)) {
|
||||||
m_lightstyle[style].length = 0u;
|
m_lightstyle[style].length = 0u;
|
||||||
m_lightstyle[style].map[0] = kNullChar;
|
m_lightstyle[style].map[0] = kNullChar;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -209,7 +209,7 @@ int BotGraph::clearConnections (int index) {
|
||||||
|
|
||||||
|
|
||||||
for (int i = 2; i < kMaxNodeLinks; ++i) {
|
for (int i = 2; i < kMaxNodeLinks; ++i) {
|
||||||
while (inspect_p0 (i)) { }
|
while (inspect_p0 (i)) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// check pass 1
|
// check pass 1
|
||||||
|
|
@ -332,7 +332,7 @@ int BotGraph::clearConnections (int index) {
|
||||||
};
|
};
|
||||||
|
|
||||||
for (int i = 1; i < kMaxNodeLinks; ++i) {
|
for (int i = 1; i < kMaxNodeLinks; ++i) {
|
||||||
while (inspect_p2 (i)) { }
|
while (inspect_p2 (i)) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// check pass 3
|
// check pass 3
|
||||||
|
|
@ -1565,11 +1565,11 @@ bool BotGraph::convertOldFormat () {
|
||||||
// add to node array
|
// add to node array
|
||||||
m_paths.push (cr::move (path));
|
m_paths.push (cr::move (path));
|
||||||
}
|
}
|
||||||
fp.close();
|
fp.close ();
|
||||||
|
|
||||||
// save new format in case loaded older one
|
// save new format in case loaded older one
|
||||||
if (!m_paths.empty()) {
|
if (!m_paths.empty ()) {
|
||||||
ctrl.msg("Converting old PWF to new format Graph.");
|
ctrl.msg ("Converting old PWF to new format Graph.");
|
||||||
|
|
||||||
m_graphAuthor = header.author;
|
m_graphAuthor = header.author;
|
||||||
|
|
||||||
|
|
@ -1577,7 +1577,7 @@ bool BotGraph::convertOldFormat () {
|
||||||
auto editor = m_editor;
|
auto editor = m_editor;
|
||||||
m_editor = nullptr;
|
m_editor = nullptr;
|
||||||
|
|
||||||
auto result = saveGraphData();
|
auto result = saveGraphData ();
|
||||||
m_editor = editor;
|
m_editor = editor;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -1693,7 +1693,7 @@ template <typename U> bool BotGraph::loadStorage (StringRef ext, StringRef name,
|
||||||
auto fromDownload = strings.format ("http://%s/graph/%s", downloadAddress, filename);
|
auto fromDownload = strings.format ("http://%s/graph/%s", downloadAddress, filename);
|
||||||
|
|
||||||
// try to download
|
// try to download
|
||||||
if (http.downloadFile (fromDownload, toDownload)) {
|
if (http.downloadFile (fromDownload, toDownload)) {
|
||||||
ctrl.msg ("%s file '%s' successfully downloaded. Processing...", name, filename);
|
ctrl.msg ("%s file '%s' successfully downloaded. Processing...", name, filename);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -1756,7 +1756,7 @@ template <typename U> bool BotGraph::loadStorage (StringRef ext, StringRef name,
|
||||||
|
|
||||||
// check the version
|
// check the version
|
||||||
if (hdr.version > version && isGraph) {
|
if (hdr.version > version && isGraph) {
|
||||||
ctrl.msg ("Graph version mismatch %s (filename: '%s'). Version number differs (got: '%d', need: '%d') Please, upgrade %s.", name, filename, hdr.version, version, product.name);
|
ctrl.msg ("Graph version mismatch %s (filename: '%s'). Version number differs (got: '%d', need: '%d') Please, upgrade %s.", name, filename, hdr.version, version, product.name);
|
||||||
}
|
}
|
||||||
else if (hdr.version > version && !isGraph) {
|
else if (hdr.version > version && !isGraph) {
|
||||||
return raiseLoadingError (isGraph, file, "Damaged %s (filename: '%s'). Version number differs (got: '%d', need: '%d').", name, filename, hdr.version, version);
|
return raiseLoadingError (isGraph, file, "Damaged %s (filename: '%s'). Version number differs (got: '%d', need: '%d').", name, filename, hdr.version, version);
|
||||||
|
|
@ -2527,8 +2527,8 @@ void BotGraph::frame () {
|
||||||
|
|
||||||
String practice;
|
String practice;
|
||||||
practice.assignf (" Node practice data (index / damage):\n"
|
practice.assignf (" Node practice data (index / damage):\n"
|
||||||
" CT: %d / %d\n"
|
" CT: %d / %d\n"
|
||||||
" T: %d / %d\n\n", dangerIndexCT, dangerIndexCT != kInvalidNodeIndex ? getDangerDamage (Team::CT, nearestIndex, dangerIndexCT) : 0, dangerIndexT, dangerIndexT != kInvalidNodeIndex ? getDangerDamage (Team::Terrorist, nearestIndex, dangerIndexT) : 0);
|
" T: %d / %d\n\n", dangerIndexCT, dangerIndexCT != kInvalidNodeIndex ? getDangerDamage (Team::CT, nearestIndex, dangerIndexCT) : 0, dangerIndexT, dangerIndexT != kInvalidNodeIndex ? getDangerDamage (Team::Terrorist, nearestIndex, dangerIndexT) : 0);
|
||||||
|
|
||||||
sendHudMessage ({ 255, 255, 255 }, 0.0f, 0.16f, m_editor, practice + timeMessage);
|
sendHudMessage ({ 255, 255, 255 }, 0.0f, 0.16f, m_editor, practice + timeMessage);
|
||||||
}
|
}
|
||||||
|
|
@ -2695,7 +2695,7 @@ bool BotGraph::checkNodes (bool teleportPlayer) {
|
||||||
Array <IntArray> outgoingPaths; // store incoming paths for speedup
|
Array <IntArray> outgoingPaths; // store incoming paths for speedup
|
||||||
outgoingPaths.resize (m_paths.length ());
|
outgoingPaths.resize (m_paths.length ());
|
||||||
|
|
||||||
for (const auto &path: m_paths) {
|
for (const auto &path : m_paths) {
|
||||||
outgoingPaths[path.number].resize (m_paths.length () + 1);
|
outgoingPaths[path.number].resize (m_paths.length () + 1);
|
||||||
|
|
||||||
for (const auto &link : path.links) {
|
for (const auto &link : path.links) {
|
||||||
|
|
@ -3068,7 +3068,7 @@ void BotGraph::updateGlobalPractice () {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int team = Team::Terrorist; team < kGameTeamNum; ++team) {
|
for (int team = Team::Terrorist; team < kGameTeamNum; ++team) {
|
||||||
m_highestDamage[team] = cr::clamp (m_highestDamage [team] - kHalfDamageVal, 1, kMaxPracticeDamageValue);
|
m_highestDamage[team] = cr::clamp (m_highestDamage[team] - kHalfDamageVal, 1, kMaxPracticeDamageValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,54 +32,52 @@ plugin_info_t Plugin_info = {
|
||||||
PT_ANYTIME, // when unloadable
|
PT_ANYTIME, // when unloadable
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace variadic {
|
void hook_ClientCommand (edict_t *ent, char const *format, ...) {
|
||||||
void clientCommand (edict_t *ent, char const *format, ...) {
|
// this function forces the client whose player entity is ent to issue a client command.
|
||||||
// this function forces the client whose player entity is ent to issue a client command.
|
// How it works is that clients all have a argv global string in their client DLL that
|
||||||
// How it works is that clients all have a argv global string in their client DLL that
|
// stores the command string; if ever that string is filled with characters, the client DLL
|
||||||
// stores the command string; if ever that string is filled with characters, the client DLL
|
// sends it to the engine as a command to be executed. When the engine has executed that
|
||||||
// sends it to the engine as a command to be executed. When the engine has executed that
|
// command, this argv string is reset to zero. Here is somehow a curious implementation of
|
||||||
// command, this argv string is reset to zero. Here is somehow a curious implementation of
|
// ClientCommand: the engine sets the command it wants the client to issue in his argv, then
|
||||||
// ClientCommand: the engine sets the command it wants the client to issue in his argv, then
|
// the client DLL sends it back to the engine, the engine receives it then executes the
|
||||||
// the client DLL sends it back to the engine, the engine receives it then executes the
|
// command therein. Don't ask me why we need all this complicated crap. Anyhow since bots have
|
||||||
// command therein. Don't ask me why we need all this complicated crap. Anyhow since bots have
|
// no client DLL, be certain never to call this function upon a bot entity, else it will just
|
||||||
// no client DLL, be certain never to call this function upon a bot entity, else it will just
|
// make the server crash. Since hordes of uncautious, not to say stupid, programmers don't
|
||||||
// make the server crash. Since hordes of uncautious, not to say stupid, programmers don't
|
// even imagine some players on their servers could be bots, this check is performed less than
|
||||||
// even imagine some players on their servers could be bots, this check is performed less than
|
// sometimes actually by their side, that's why we strongly recommend to check it here too. In
|
||||||
// sometimes actually by their side, that's why we strongly recommend to check it here too. In
|
// case it's a bot asking for a client command, we handle it like we do for bot commands
|
||||||
// case it's a bot asking for a client command, we handle it like we do for bot commands
|
|
||||||
|
|
||||||
if (game.isNullEntity (ent)) {
|
if (game.isNullEntity (ent)) {
|
||||||
if (game.is (GameFlags::Metamod)) {
|
if (game.is (GameFlags::Metamod)) {
|
||||||
RETURN_META (MRES_SUPERCEDE);
|
RETURN_META (MRES_SUPERCEDE);
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
auto buffer = strings.chars ();
|
auto buffer = strings.chars ();
|
||||||
|
|
||||||
va_start (ap, format);
|
va_start (ap, format);
|
||||||
vsnprintf (buffer, StringBuffer::StaticBufferSize, format, ap);
|
vsnprintf (buffer, StringBuffer::StaticBufferSize, format, ap);
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
|
|
||||||
if (util.isFakeClient (ent) || (ent->v.flags & FL_DORMANT)) {
|
if (util.isFakeClient (ent) || (ent->v.flags & FL_DORMANT)) {
|
||||||
auto bot = bots[ent];
|
auto bot = bots[ent];
|
||||||
|
|
||||||
if (bot) {
|
if (bot) {
|
||||||
bot->issueCommand (buffer);
|
bot->issueCommand (buffer);
|
||||||
}
|
|
||||||
|
|
||||||
if (game.is (GameFlags::Metamod)) {
|
|
||||||
RETURN_META (MRES_SUPERCEDE); // prevent bots to be forced to issue client commands
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (game.is (GameFlags::Metamod)) {
|
if (game.is (GameFlags::Metamod)) {
|
||||||
RETURN_META (MRES_IGNORED);
|
RETURN_META (MRES_SUPERCEDE); // prevent bots to be forced to issue client commands
|
||||||
}
|
}
|
||||||
engfuncs.pfnClientCommand (ent, buffer);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (game.is (GameFlags::Metamod)) {
|
||||||
|
RETURN_META (MRES_IGNORED);
|
||||||
|
}
|
||||||
|
engfuncs.pfnClientCommand (ent, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
CR_EXPORT int GetEntityAPI (gamefuncs_t *table, int) {
|
CR_EXPORT int GetEntityAPI (gamefuncs_t *table, int) {
|
||||||
|
|
@ -255,7 +253,7 @@ CR_EXPORT int GetEntityAPI (gamefuncs_t *table, int) {
|
||||||
dllapi.pfnClientDisconnect (ent);
|
dllapi.pfnClientDisconnect (ent);
|
||||||
};
|
};
|
||||||
|
|
||||||
table->pfnClientUserInfoChanged = [] (edict_t *ent, char *infobuffer) {
|
table->pfnClientUserInfoChanged = [] (edict_t *ent, char *infobuffer) {
|
||||||
// this function is called when a player changes model, or changes team. Occasionally it
|
// this function is called when a player changes model, or changes team. Occasionally it
|
||||||
// enforces rules on these changes (for example, some MODs don't want to allow players to
|
// enforces rules on these changes (for example, some MODs don't want to allow players to
|
||||||
// change their player model). But most commonly, this function is in charge of handling
|
// change their player model). But most commonly, this function is in charge of handling
|
||||||
|
|
@ -509,7 +507,7 @@ CR_LINKAGE_C int GetEngineFunctions (enginefuncs_t *table, int *) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ents.needsBypass () && !game.is (GameFlags::Metamod)) {
|
if (ents.needsBypass () && !game.is (GameFlags::Metamod)) {
|
||||||
table->pfnCreateNamedEntity = [] (int classname) -> edict_t * {
|
table->pfnCreateNamedEntity = [] (int classname) -> edict_t *{
|
||||||
|
|
||||||
if (ents.isPaused ()) {
|
if (ents.isPaused ()) {
|
||||||
ents.enable ();
|
ents.enable ();
|
||||||
|
|
@ -779,7 +777,7 @@ CR_LINKAGE_C int GetEngineFunctions (enginefuncs_t *table, int *) {
|
||||||
engfuncs.pfnSetClientMaxspeed (ent, newMaxspeed);
|
engfuncs.pfnSetClientMaxspeed (ent, newMaxspeed);
|
||||||
};
|
};
|
||||||
|
|
||||||
table->pfnClientCommand = variadic::clientCommand;
|
table->pfnClientCommand = hook_ClientCommand;
|
||||||
|
|
||||||
return HLTrue;
|
return HLTrue;
|
||||||
}
|
}
|
||||||
|
|
@ -989,7 +987,7 @@ CR_EXPORT int Server_GetPhysicsInterface (int version, server_physics_api_t *phy
|
||||||
// this function handle the custom xash3d physics interface, that we're uses just for resolving
|
// this function handle the custom xash3d physics interface, that we're uses just for resolving
|
||||||
// entities between game and engine.
|
// entities between game and engine.
|
||||||
|
|
||||||
if (!table || !physics_api || version != SV_PHYSICS_INTERFACE_VERSION) {
|
if (!table || !physics_api || version != SV_PHYSICS_INTERFACE_VERSION) {
|
||||||
return HLFalse;
|
return HLFalse;
|
||||||
}
|
}
|
||||||
table->version = SV_PHYSICS_INTERFACE_VERSION;
|
table->version = SV_PHYSICS_INTERFACE_VERSION;
|
||||||
|
|
|
||||||
|
|
@ -163,7 +163,7 @@ BotCreateResult BotManager::create (StringRef name, int difficulty, int personal
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't allow creating bots with changed graph (distance tables are messed up)
|
// don't allow creating bots with changed graph (distance tables are messed up)
|
||||||
else if (graph.hasChanged ()) {
|
else if (graph.hasChanged ()) {
|
||||||
ctrl.msg ("Graph has been changed. Load graph again...");
|
ctrl.msg ("Graph has been changed. Load graph again...");
|
||||||
return BotCreateResult::GraphError;
|
return BotCreateResult::GraphError;
|
||||||
}
|
}
|
||||||
|
|
@ -237,7 +237,7 @@ BotCreateResult BotManager::create (StringRef name, int difficulty, int personal
|
||||||
botName->usedBy = index; // save by who name is used
|
botName->usedBy = index; // save by who name is used
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
conf.setBotNameUsed(index, resultName);
|
conf.setBotNameUsed (index, resultName);
|
||||||
}
|
}
|
||||||
m_bots.push (cr::move (object));
|
m_bots.push (cr::move (object));
|
||||||
|
|
||||||
|
|
@ -566,7 +566,7 @@ void BotManager::serverFill (int selection, int personality, int difficulty, int
|
||||||
else {
|
else {
|
||||||
selection = 5;
|
selection = 5;
|
||||||
}
|
}
|
||||||
char teams[6][12] = {"", {"Terrorists"}, {"CTs"}, "", "", {"Random"}, };
|
char teams[6][12] = { "", {"Terrorists"}, {"CTs"}, "", "", {"Random"}, };
|
||||||
auto toAdd = numToAdd == -1 ? maxClients - (getHumansCount () + getBotCount ()) : numToAdd;
|
auto toAdd = numToAdd == -1 ? maxClients - (getHumansCount () + getBotCount ()) : numToAdd;
|
||||||
|
|
||||||
for (int i = 0; i <= toAdd; ++i) {
|
for (int i = 0; i <= toAdd; ++i) {
|
||||||
|
|
@ -703,7 +703,7 @@ bool BotManager::kickRandom (bool decQuota, Team fromTeam) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BotManager::setLastWinner (int winner) {
|
void BotManager::setLastWinner (int winner) {
|
||||||
m_lastWinner = winner;
|
m_lastWinner = winner;
|
||||||
m_roundOver = true;
|
m_roundOver = true;
|
||||||
|
|
||||||
|
|
@ -748,7 +748,7 @@ void BotManager::setWeaponMode (int selection) {
|
||||||
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, -1, 1, -1, -1}, // Snipers only
|
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, -1, 1, -1, -1}, // Snipers only
|
||||||
{-1, -1, -1, 2, 2, 0, 1, 1, 1, 1, 1, 1, 0, 2, 0, -1, 1, 0, 1, 1, 0, 0, -1, 1, 1, 1} // Standard
|
{-1, -1, -1, 2, 2, 0, 1, 1, 1, 1, 1, 1, 0, 2, 0, -1, 1, 0, 1, 1, 0, 0, -1, 1, 1, 1} // Standard
|
||||||
};
|
};
|
||||||
constexpr char modes[7][12] = {{"Knife"}, {"Pistol"}, {"Shotgun"}, {"Machine Gun"}, {"Rifle"}, {"Sniper"}, {"Standard"}};
|
constexpr char modes[7][12] = { {"Knife"}, {"Pistol"}, {"Shotgun"}, {"Machine Gun"}, {"Rifle"}, {"Sniper"}, {"Standard"} };
|
||||||
|
|
||||||
// get the raw weapons array
|
// get the raw weapons array
|
||||||
auto tab = conf.getRawWeapons ();
|
auto tab = conf.getRawWeapons ();
|
||||||
|
|
@ -768,7 +768,8 @@ void BotManager::listBots () {
|
||||||
|
|
||||||
ctrl.msg ("%-3.5s\t%-19.16s\t%-10.12s\t%-3.4s\t%-3.4s\t%-3.4s\t%-3.5s", "index", "name", "personality", "team", "difficulty", "frags", "alive");
|
ctrl.msg ("%-3.5s\t%-19.16s\t%-10.12s\t%-3.4s\t%-3.4s\t%-3.4s\t%-3.5s", "index", "name", "personality", "team", "difficulty", "frags", "alive");
|
||||||
|
|
||||||
for (const auto &bot : bots) {;
|
for (const auto &bot : bots) {
|
||||||
|
;
|
||||||
ctrl.msg ("[%-3.1d]\t%-19.16s\t%-10.12s\t%-3.4s\t%-3.1d\t%-3.1d\t%-3.4s", bot->index (), bot->pev->netname.chars (), bot->m_personality == Personality::Rusher ? "rusher" : bot->m_personality == Personality::Normal ? "normal" : "careful", bot->m_team == Team::CT ? "CT" : "T", bot->m_difficulty, static_cast <int> (bot->pev->frags), bot->m_notKilled ? "yes" : "no");
|
ctrl.msg ("[%-3.1d]\t%-19.16s\t%-10.12s\t%-3.4s\t%-3.1d\t%-3.1d\t%-3.4s", bot->index (), bot->pev->netname.chars (), bot->m_personality == Personality::Rusher ? "rusher" : bot->m_personality == Personality::Normal ? "normal" : "careful", bot->m_team == Team::CT ? "CT" : "T", bot->m_difficulty, static_cast <int> (bot->pev->frags), bot->m_notKilled ? "yes" : "no");
|
||||||
}
|
}
|
||||||
ctrl.msg ("%d bots", m_bots.length ());
|
ctrl.msg ("%d bots", m_bots.length ());
|
||||||
|
|
@ -966,7 +967,7 @@ Bot::Bot (edict_t *bot, int difficulty, int personality, int team, int skin) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char reject[256] = {0, };
|
char reject[256] = { 0, };
|
||||||
MDLL_ClientConnect (bot, bot->v.netname.chars (), strings.format ("127.0.0.%d", clientIndex + 100), reject);
|
MDLL_ClientConnect (bot, bot->v.netname.chars (), strings.format ("127.0.0.%d", clientIndex + 100), reject);
|
||||||
|
|
||||||
if (!strings.isEmpty (reject)) {
|
if (!strings.isEmpty (reject)) {
|
||||||
|
|
@ -1194,13 +1195,13 @@ void BotManager::handleDeath (edict_t *killer, edict_t *victim) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// did a human kill a bot on his team?
|
// did a human kill a bot on his team?
|
||||||
else {
|
else {
|
||||||
if (victimBot != nullptr) {
|
if (victimBot != nullptr) {
|
||||||
if (killerTeam == victimBot->m_team) {
|
if (killerTeam == victimBot->m_team) {
|
||||||
victimBot->m_voteKickIndex = game.indexOfEntity (killer);
|
victimBot->m_voteKickIndex = game.indexOfEntity (killer);
|
||||||
for (const auto ¬ify : bots) {
|
for (const auto ¬ify : bots) {
|
||||||
if (notify->seesEntity (victim->v.origin)) {
|
if (notify->seesEntity (victim->v.origin)) {
|
||||||
notify->pushChatterMessage (Chatter::TeamKill);
|
notify->pushChatterMessage (Chatter::TeamKill);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1221,7 +1222,7 @@ void Bot::newRound () {
|
||||||
|
|
||||||
m_path = nullptr;
|
m_path = nullptr;
|
||||||
m_currentTravelFlags = 0;
|
m_currentTravelFlags = 0;
|
||||||
m_desiredVelocity= nullptr;
|
m_desiredVelocity = nullptr;
|
||||||
m_currentNodeIndex = kInvalidNodeIndex;
|
m_currentNodeIndex = kInvalidNodeIndex;
|
||||||
m_prevGoalIndex = kInvalidNodeIndex;
|
m_prevGoalIndex = kInvalidNodeIndex;
|
||||||
m_chosenGoalIndex = kInvalidNodeIndex;
|
m_chosenGoalIndex = kInvalidNodeIndex;
|
||||||
|
|
@ -1310,7 +1311,7 @@ void Bot::newRound () {
|
||||||
m_aimFlags = 0;
|
m_aimFlags = 0;
|
||||||
m_liftState = 0;
|
m_liftState = 0;
|
||||||
|
|
||||||
m_aimLastError= nullptr;
|
m_aimLastError = nullptr;
|
||||||
m_position = nullptr;
|
m_position = nullptr;
|
||||||
m_liftTravelPos = nullptr;
|
m_liftTravelPos = nullptr;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -237,7 +237,7 @@ int Bot::findGoalPost (int tactic, IntArray *defensive, IntArray *offsensive) {
|
||||||
|
|
||||||
for (auto &choice : goalChoices) {
|
for (auto &choice : goalChoices) {
|
||||||
if (choice == kInvalidNodeIndex) {
|
if (choice == kInvalidNodeIndex) {
|
||||||
choice = graph.m_rescuePoints.random ();
|
choice = graph.m_rescuePoints.random ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -597,8 +597,7 @@ void Bot::checkTerrain (float movedDistance, const Vector &dirNormal) {
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (bits & CollisionProbe::Duck)
|
if (bits & CollisionProbe::Duck) {
|
||||||
{
|
|
||||||
state[i] = 0;
|
state[i] = 0;
|
||||||
|
|
||||||
if (canDuckUnder (dirNormal)) {
|
if (canDuckUnder (dirNormal)) {
|
||||||
|
|
@ -611,7 +610,7 @@ void Bot::checkTerrain (float movedDistance, const Vector &dirNormal) {
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
state[i] = 0;
|
state[i] = 0;
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
// weighted all possible moves, now sort them to start with most probable
|
// weighted all possible moves, now sort them to start with most probable
|
||||||
|
|
@ -729,7 +728,7 @@ bool Bot::updateNavigation () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(graph[m_previousNodes[0]].flags & NodeFlag::Ladder)) {
|
if (!(graph[m_previousNodes[0]].flags & NodeFlag::Ladder)) {
|
||||||
if (cr::abs (m_pathOrigin.z - pev->origin.z) > 5.0f) {
|
if (cr::abs (m_pathOrigin.z - pev->origin.z) > 5.0f) {
|
||||||
m_pathOrigin.z += pev->origin.z - m_pathOrigin.z;
|
m_pathOrigin.z += pev->origin.z - m_pathOrigin.z;
|
||||||
}
|
}
|
||||||
|
|
@ -1168,7 +1167,7 @@ bool Bot::updateLiftHandling () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!game.isNullEntity (m_liftEntity)) {
|
else if (!game.isNullEntity (m_liftEntity)) {
|
||||||
auto button = lookupButton (m_liftEntity->v.targetname.chars ());
|
auto button = lookupButton (m_liftEntity->v.targetname.chars ());
|
||||||
|
|
||||||
// if we got a valid button entity
|
// if we got a valid button entity
|
||||||
if (!game.isNullEntity (button)) {
|
if (!game.isNullEntity (button)) {
|
||||||
|
|
@ -1294,7 +1293,7 @@ bool Bot::updateLiftStates () {
|
||||||
void Bot::findShortestPath (int srcIndex, int destIndex) {
|
void Bot::findShortestPath (int srcIndex, int destIndex) {
|
||||||
// this function finds the shortest path from source index to destination index
|
// this function finds the shortest path from source index to destination index
|
||||||
|
|
||||||
if (!graph.exists (srcIndex)){
|
if (!graph.exists (srcIndex)) {
|
||||||
logger.error ("%s source path index not valid (%d).", __FUNCTION__, srcIndex);
|
logger.error ("%s source path index not valid (%d).", __FUNCTION__, srcIndex);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -1692,7 +1691,7 @@ bool Bot::findBestNearestNode () {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check we're have link to it
|
// check we're have link to it
|
||||||
if (m_currentNodeIndex != kInvalidNodeIndex && !graph.isConnected (m_currentNodeIndex, at)) {
|
if (m_currentNodeIndex != kInvalidNodeIndex && !graph.isConnected (m_currentNodeIndex, at)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -2036,7 +2035,7 @@ int Bot::findDefendNode (const Vector &origin) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nodeIndex[rg.get (0, (index -1) / 2)];
|
return nodeIndex[rg.get (0, (index - 1) / 2)];
|
||||||
}
|
}
|
||||||
|
|
||||||
int Bot::findCoverNode (float maxDistance) {
|
int Bot::findCoverNode (float maxDistance) {
|
||||||
|
|
|
||||||
|
|
@ -177,11 +177,11 @@ void BotSupport::traceDecals (entvars_t *pev, TraceResult *trace, int logotypeIn
|
||||||
MessageWriter msg;
|
MessageWriter msg;
|
||||||
|
|
||||||
msg.start (MSG_BROADCAST, SVC_TEMPENTITY)
|
msg.start (MSG_BROADCAST, SVC_TEMPENTITY)
|
||||||
.writeByte (message)
|
.writeByte (message)
|
||||||
.writeCoord (trace->vecEndPos.x)
|
.writeCoord (trace->vecEndPos.x)
|
||||||
.writeCoord (trace->vecEndPos.y)
|
.writeCoord (trace->vecEndPos.y)
|
||||||
.writeCoord (trace->vecEndPos.z)
|
.writeCoord (trace->vecEndPos.z)
|
||||||
.writeByte (decalIndex);
|
.writeByte (decalIndex);
|
||||||
|
|
||||||
if (entityIndex) {
|
if (entityIndex) {
|
||||||
msg.writeShort (entityIndex);
|
msg.writeShort (entityIndex);
|
||||||
|
|
@ -222,7 +222,7 @@ bool BotSupport::isMonster (edict_t *ent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BotSupport::isItem (edict_t *ent) {
|
bool BotSupport::isItem (edict_t *ent) {
|
||||||
return !!(strstr (ent->v.classname.chars(), "item_"));
|
return !!(strstr (ent->v.classname.chars (), "item_"));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BotSupport::isPlayerVIP (edict_t *ent) {
|
bool BotSupport::isPlayerVIP (edict_t *ent) {
|
||||||
|
|
@ -489,7 +489,7 @@ void BotSupport::simulateNoise (int playerIndex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// pressed reload button?
|
// pressed reload button?
|
||||||
else if (buttons & IN_RELOAD) {
|
else if (buttons & IN_RELOAD) {
|
||||||
noise.dist = 512.0f;
|
noise.dist = 512.0f;
|
||||||
noise.last = game.time () + 0.5f;
|
noise.last = game.time () + 0.5f;
|
||||||
}
|
}
|
||||||
|
|
@ -676,7 +676,7 @@ void BotSupport::installSendTo () {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BotSupport::isObjectInsidePlane (FrustumPlane &plane, const Vector ¢er, float height, float radius) {
|
bool BotSupport::isObjectInsidePlane (FrustumPlane &plane, const Vector ¢er, float height, float radius) {
|
||||||
auto isPointInsidePlane = [&](const Vector &point) -> bool {
|
auto isPointInsidePlane = [&] (const Vector &point) -> bool {
|
||||||
return plane.result + (plane.normal | point) >= 0.0f;
|
return plane.result + (plane.normal | point) >= 0.0f;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue