fix: problems with picking up grenades on the ground (ref #529)
fix: picking up m249 ammo from the ground fix: make bots respect camping_time_min/max when guarding bomb/hostages nav: make normal and rusher bots less defensive on hostage maps (ref #528)
This commit is contained in:
parent
fe1bca4fcc
commit
67eb6334f6
7 changed files with 37 additions and 23 deletions
|
|
@ -104,6 +104,8 @@ public:
|
||||||
return m_sendToDetour.restore ();
|
return m_sendToDetour.restore ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
static int32_t CR_STDCALL sendTo (int socket, const void *message, size_t length, int flags, const struct sockaddr *dest, int destLength);
|
||||||
};
|
};
|
||||||
|
|
||||||
// used for transit calls between game dll and engine without all needed functions on bot side
|
// used for transit calls between game dll and engine without all needed functions on bot side
|
||||||
|
|
|
||||||
|
|
@ -126,9 +126,6 @@ public:
|
||||||
bool isInViewCone (const Vector &pos, edict_t *ent) {
|
bool isInViewCone (const Vector &pos, edict_t *ent) {
|
||||||
return getShootingCone (ent, pos) >= cr::cosf (cr::deg2rad ((ent->v.fov > 0 ? ent->v.fov : 90.0f) * 0.5f));
|
return getShootingCone (ent, pos) >= cr::cosf (cr::deg2rad ((ent->v.fov > 0 ? ent->v.fov : 90.0f) * 0.5f));
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
|
||||||
static int32_t CR_STDCALL sendTo (int socket, const void *message, size_t length, int flags, const struct sockaddr *dest, int destLength);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// expose global
|
// expose global
|
||||||
|
|
|
||||||
|
|
@ -871,6 +871,8 @@ extern ConVar cv_spraypaints;
|
||||||
extern ConVar cv_whose_your_daddy;
|
extern ConVar cv_whose_your_daddy;
|
||||||
extern ConVar cv_grenadier_mode;
|
extern ConVar cv_grenadier_mode;
|
||||||
extern ConVar cv_ignore_enemies_after_spawn_time;
|
extern ConVar cv_ignore_enemies_after_spawn_time;
|
||||||
|
extern ConVar cv_camping_time_min;
|
||||||
|
extern ConVar cv_camping_time_max;
|
||||||
|
|
||||||
extern ConVar mp_freezetime;
|
extern ConVar mp_freezetime;
|
||||||
extern ConVar mp_roundtime;
|
extern ConVar mp_roundtime;
|
||||||
|
|
|
||||||
|
|
@ -449,6 +449,7 @@ void Bot::updatePickups () {
|
||||||
const bool isSubmachine = weaponType == WeaponType::SMG;
|
const bool isSubmachine = weaponType == WeaponType::SMG;
|
||||||
const bool isShotgun = weaponType == WeaponType::Shotgun;
|
const bool isShotgun = weaponType == WeaponType::Shotgun;
|
||||||
const bool isRifle = weaponType == WeaponType::Rifle || weaponType == WeaponType::ZoomRifle;
|
const bool isRifle = weaponType == WeaponType::Rifle || weaponType == WeaponType::ZoomRifle;
|
||||||
|
const bool isHeavy = weaponType == WeaponType::Heavy;
|
||||||
|
|
||||||
if (!isRifle && model == "9mmarclip.mdl") {
|
if (!isRifle && model == "9mmarclip.mdl") {
|
||||||
allowPickup = false;
|
allowPickup = false;
|
||||||
|
|
@ -462,7 +463,7 @@ void Bot::updatePickups () {
|
||||||
else if (!isSniperRifle && model == "crossbow_clip.mdl") {
|
else if (!isSniperRifle && model == "crossbow_clip.mdl") {
|
||||||
allowPickup = false;
|
allowPickup = false;
|
||||||
}
|
}
|
||||||
else if (primaryWeaponCarried != Weapon::M249 && model == "chainammo.mdl") {
|
else if (!isHeavy && model == "chainammo.mdl") {
|
||||||
allowPickup = false;
|
allowPickup = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -472,6 +473,15 @@ void Bot::updatePickups () {
|
||||||
else if (pev->armorvalue >= 100.0f && (model == "kevlar.mdl"|| model == "battery.mdl" || model == "assault.mdl")) {
|
else if (pev->armorvalue >= 100.0f && (model == "kevlar.mdl"|| model == "battery.mdl" || model == "assault.mdl")) {
|
||||||
allowPickup = false;
|
allowPickup = false;
|
||||||
}
|
}
|
||||||
|
else if ((pev->weapons & cr::bit (Weapon::Flashbang)) && model == kFlashbangModelName) {
|
||||||
|
allowPickup = false;
|
||||||
|
}
|
||||||
|
else if ((pev->weapons & cr::bit (Weapon::Explosive)) && model == kExplosiveModelName) {
|
||||||
|
allowPickup = false;
|
||||||
|
}
|
||||||
|
else if ((pev->weapons & cr::bit (Weapon::Smoke)) && model == kSmokeModelName) {
|
||||||
|
allowPickup = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (allowPickup) {
|
if (allowPickup) {
|
||||||
pickupType = Pickup::AmmoAndKits;
|
pickupType = Pickup::AmmoAndKits;
|
||||||
|
|
@ -533,15 +543,6 @@ void Bot::updatePickups () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((pev->weapons & cr::bit (Weapon::Flashbang)) && model == kFlashbangModelName) {
|
|
||||||
allowPickup = false;
|
|
||||||
}
|
|
||||||
else if ((pev->weapons & cr::bit (Weapon::Explosive)) && model == kExplosiveModelName) {
|
|
||||||
allowPickup = false;
|
|
||||||
}
|
|
||||||
else if ((pev->weapons & cr::bit (Weapon::Smoke)) && model == kSmokeModelName) {
|
|
||||||
allowPickup = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// found a shield on ground?
|
// found a shield on ground?
|
||||||
|
|
@ -566,11 +567,12 @@ void Bot::updatePickups () {
|
||||||
if (!m_defendHostage && m_personality
|
if (!m_defendHostage && m_personality
|
||||||
!= Personality::Rusher && m_difficulty >= Difficulty::Normal
|
!= Personality::Rusher && m_difficulty >= Difficulty::Normal
|
||||||
&& rg.chance (15)
|
&& rg.chance (15)
|
||||||
&& m_timeCamping + 15.0f < game.time ()) {
|
&& m_timeCamping + 15.0f < game.time ()
|
||||||
|
&& numFriendsNear (pev->origin, 384.0f) < 3) {
|
||||||
|
|
||||||
const int index = findDefendNode (origin);
|
const int index = findDefendNode (origin);
|
||||||
|
|
||||||
startTask (Task::Camp, TaskPri::Camp, kInvalidNodeIndex, game.time () + rg.get (30.0f, 60.0f), true); // push camp task on to stack
|
startTask (Task::Camp, TaskPri::Camp, kInvalidNodeIndex, game.time () + rg.get (cv_camping_time_min.float_ (), cv_camping_time_max.float_ ()), true); // push camp task on to stack
|
||||||
startTask (Task::MoveToPosition, TaskPri::MoveToPosition, index, game.time () + rg.get (3.0f, 6.0f), true); // push move command
|
startTask (Task::MoveToPosition, TaskPri::MoveToPosition, index, game.time () + rg.get (3.0f, 6.0f), true); // push move command
|
||||||
|
|
||||||
// decide to duck or not to duck
|
// decide to duck or not to duck
|
||||||
|
|
@ -693,7 +695,7 @@ void Bot::updatePickups () {
|
||||||
if (!m_defendedBomb && m_difficulty >= Difficulty::Normal && rg.chance (75) && m_healthValue < 60) {
|
if (!m_defendedBomb && m_difficulty >= Difficulty::Normal && rg.chance (75) && m_healthValue < 60) {
|
||||||
const int index = findDefendNode (origin);
|
const int index = findDefendNode (origin);
|
||||||
|
|
||||||
startTask (Task::Camp, TaskPri::Camp, kInvalidNodeIndex, game.time () + rg.get (30.0f, 70.0f), true); // push camp task on to stack
|
startTask (Task::Camp, TaskPri::Camp, kInvalidNodeIndex, game.time () + rg.get (cv_camping_time_min.float_ (), cv_camping_time_max.float_ ()), true); // push camp task on to stack
|
||||||
startTask (Task::MoveToPosition, TaskPri::MoveToPosition, index, game.time () + rg.get (10.0f, 30.0f), true); // push move command
|
startTask (Task::MoveToPosition, TaskPri::MoveToPosition, index, game.time () + rg.get (10.0f, 30.0f), true); // push move command
|
||||||
|
|
||||||
// decide to duck or not to duck
|
// decide to duck or not to duck
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
#include <yapb.h>
|
#include <yapb.h>
|
||||||
|
|
||||||
int32_t BotSupport::sendTo (int socket, const void *message, size_t length, int flags, const sockaddr *dest, int destLength) {
|
int32_t ServerQueryHook::sendTo (int socket, const void *message, size_t length, int flags, const sockaddr *dest, int destLength) {
|
||||||
const auto send = [&] (const Twin <const uint8_t *, size_t> &msg) -> int32_t {
|
const auto send = [&] (const Twin <const uint8_t *, size_t> &msg) -> int32_t {
|
||||||
return Socket::sendto (socket, msg.first, msg.second, flags, dest, destLength);
|
return Socket::sendto (socket, msg.first, msg.second, flags, dest, destLength);
|
||||||
};
|
};
|
||||||
|
|
@ -94,10 +94,10 @@ void ServerQueryHook::init () {
|
||||||
|
|
||||||
// enable only on modern games
|
// enable only on modern games
|
||||||
if (!game.is (GameFlags::Legacy) && (plat.nix || plat.win) && !plat.isNonX86 () && !m_sendToDetour.detoured ()) {
|
if (!game.is (GameFlags::Legacy) && (plat.nix || plat.win) && !plat.isNonX86 () && !m_sendToDetour.detoured ()) {
|
||||||
m_sendToDetour.install (reinterpret_cast <void *> (BotSupport::sendTo), true);
|
m_sendToDetour.install (reinterpret_cast <void *> (ServerQueryHook::sendTo), true);
|
||||||
|
|
||||||
if (!m_sendToDetourSys.detoured ()) {
|
if (!m_sendToDetourSys.detoured ()) {
|
||||||
m_sendToDetourSys.install (reinterpret_cast <void *> (BotSupport::sendTo), true);
|
m_sendToDetourSys.install (reinterpret_cast <void *> (ServerQueryHook::sendTo), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -105,9 +105,19 @@ int Bot::findBestGoal () {
|
||||||
|
|
||||||
if (game.mapIs (MapFlags::Assassination | MapFlags::HostageRescue)) {
|
if (game.mapIs (MapFlags::Assassination | MapFlags::HostageRescue)) {
|
||||||
if (m_team == Team::Terrorist) {
|
if (m_team == Team::Terrorist) {
|
||||||
|
if (m_personality == Personality::Rusher) {
|
||||||
|
defensive -= 25.0f - difficulty * 0.5f;
|
||||||
|
offensive += 25.0f + difficulty * 5.0f;
|
||||||
|
}
|
||||||
|
else if (m_personality == Personality::Normal && rg.chance (40)) {
|
||||||
|
defensive -= 25.0f;
|
||||||
|
offensive += 25.0f;
|
||||||
|
}
|
||||||
|
else {
|
||||||
defensive += 25.0f;
|
defensive += 25.0f;
|
||||||
offensive -= 25.0f;
|
offensive -= 25.0f;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (m_team == Team::CT) {
|
else if (m_team == Team::CT) {
|
||||||
// on hostage maps force more bots to save hostages
|
// on hostage maps force more bots to save hostages
|
||||||
if (game.mapIs (MapFlags::HostageRescue)) {
|
if (game.mapIs (MapFlags::HostageRescue)) {
|
||||||
|
|
@ -156,6 +166,7 @@ int Bot::findBestGoal () {
|
||||||
const float goalDesire = rg.get (0.0f, 100.0f) + offensive;
|
const float goalDesire = rg.get (0.0f, 100.0f) + offensive;
|
||||||
const float forwardDesire = rg.get (0.0f, 100.0f) + offensive;
|
const float forwardDesire = rg.get (0.0f, 100.0f) + offensive;
|
||||||
const float backoffDesire = rg.get (0.0f, 100.0f) + defensive;
|
const float backoffDesire = rg.get (0.0f, 100.0f) + defensive;
|
||||||
|
|
||||||
float campDesire = rg.get (0.0f, 100.0f) + defensive;
|
float campDesire = rg.get (0.0f, 100.0f) + defensive;
|
||||||
|
|
||||||
if (!usesCampGun ()) {
|
if (!usesCampGun ()) {
|
||||||
|
|
@ -1067,7 +1078,7 @@ bool Bot::updateNavigation () {
|
||||||
}
|
}
|
||||||
|
|
||||||
float desiredDistanceSq = cr::sqrf (8.0f);
|
float desiredDistanceSq = cr::sqrf (8.0f);
|
||||||
const float nodeDistanceSq = pev->origin.distanceSq (m_pathOrigin);
|
const float nodeDistanceSq = pev->origin.distanceSq2d (m_pathOrigin);
|
||||||
|
|
||||||
// initialize the radius for a special node type, where the node is considered to be reached
|
// initialize the radius for a special node type, where the node is considered to be reached
|
||||||
if (m_pathFlags & NodeFlag::Lift) {
|
if (m_pathFlags & NodeFlag::Lift) {
|
||||||
|
|
|
||||||
|
|
@ -226,7 +226,7 @@ void Bot::setAimDirection () {
|
||||||
if (onLadder && m_pathWalk.hasNext ()) {
|
if (onLadder && m_pathWalk.hasNext ()) {
|
||||||
const auto &nextPath = graph[m_pathWalk.next ()];
|
const auto &nextPath = graph[m_pathWalk.next ()];
|
||||||
|
|
||||||
if ((nextPath.flags & NodeFlag::Ladder) && m_destOrigin.distanceSq (pev->origin) < cr::sqrf (120.0f) && nextPath.origin.z > m_pathOrigin.z + 45.0f) {
|
if ((nextPath.flags & NodeFlag::Ladder) && m_destOrigin.distanceSq (pev->origin) < cr::sqrf (120.0f) && nextPath.origin.z > m_pathOrigin.z + 30.0f) {
|
||||||
m_lookAt = nextPath.origin;
|
m_lookAt = nextPath.origin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue