Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions src/game/server/neo/bot/behavior/neo_bot_scenario_monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
#include "bot/behavior/nav_entities/neo_bot_nav_ent_destroy_entity.h"
#include "bot/behavior/nav_entities/neo_bot_nav_ent_move_to.h"
#include "bot/behavior/nav_entities/neo_bot_nav_ent_wait.h"
#include "bot/behavior/neo_bot_tactical_monitor.h"
#include "bot/behavior/neo_bot_retreat_to_cover.h"
#include "bot/behavior/neo_bot_get_health.h"
#include "bot/behavior/neo_bot_get_ammo.h"
#include "bot/behavior/neo_bot_attack.h"
#include "bot/behavior/neo_bot_command_follow.h"
#include "bot/behavior/neo_bot_get_ammo.h"
#include "bot/behavior/neo_bot_get_health.h"
#include "bot/behavior/neo_bot_pause.h"

#include "bot/behavior/neo_bot_attack.h"
#include "bot/behavior/neo_bot_retreat_to_cover.h"
#include "bot/behavior/neo_bot_seek_and_destroy.h"
#include "bot/behavior/neo_bot_tactical_monitor.h"
#include "bot/behavior/neo_bot_throw_weapon_at_user.h"

#include "bot/behavior/neo_bot_scenario_monitor.h"

Expand Down Expand Up @@ -85,6 +85,18 @@ ActionResult< CNEOBot > CNEOBotScenarioMonitor::Update( CNEOBot *me, float inter
return SuspendFor(new CNEOBotPause, "Paused by debug convar sv_neo_bot_cmdr_debug_pause_uncommanded");
}
}
else
{
if (me->m_hCommandingPlayer.Get())
{
CNEO_Player* pCommander = me->m_hCommandingPlayer.Get();

if (CNEOBotThrowWeaponAtUser::ReadyAimToThrowWeapon(me, pCommander))
{
return SuspendFor(new CNEOBotThrowWeaponAtUser(pCommander), "Throwing primary weapon to user");
}
}
}

return Continue();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,19 @@ ActionResult< CNEOBot > CNEOBotThrowWeaponAtPlayer::OnStart( CNEOBot *me, Action
return Done( "No target player to throw weapon at" );
}

m_expirationTimer.Start( 5.0f );

return Continue();
}

//---------------------------------------------------------------------------------------------
ActionResult< CNEOBot > CNEOBotThrowWeaponAtPlayer::Update( CNEOBot *me, float interval )
{
if ( m_expirationTimer.IsElapsed() )
{
return Done( "Expiration timer elapsed" );
}

CNEO_Player *pTarget = m_hTargetPlayer.Get();
if ( !pTarget || !pTarget->IsAlive() )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class CNEOBotThrowWeaponAtPlayer : public Action< CNEOBot >

virtual const char *GetName( void ) const override { return "ThrowWeaponAtPlayer"; };

protected:
CountdownTimer m_expirationTimer;

private:
CHandle<CNEO_Player> m_hTargetPlayer;
};
Expand Down
38 changes: 38 additions & 0 deletions src/game/server/neo/bot/behavior/neo_bot_throw_weapon_at_user.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#ifndef NEO_BOT_THROW_WEAPON_AT_USER_H
#define NEO_BOT_THROW_WEAPON_AT_USER_H
#pragma once

#include "bot/behavior/neo_bot_throw_weapon_at_player.h"
#include "bot/neo_bot.h"
#include "neo_player.h"

//-----------------------------------------------------------------------------------------
// If the bot command system is disabled, bots simply drop their weapon for the user
class CNEOBotThrowWeaponAtUser : public CNEOBotThrowWeaponAtPlayer
{
public:
CNEOBotThrowWeaponAtUser(CNEO_Player* pTargetPlayer) : CNEOBotThrowWeaponAtPlayer(pTargetPlayer) {}

virtual void OnEnd(CNEOBot* me, Action< CNEOBot >* nextAction) override
{
me->m_hCommandingPlayer = nullptr;
CNEOBotThrowWeaponAtPlayer::OnEnd(me, nextAction);
}

virtual const char* GetName(void) const override { return "ThrowWeaponAtUser"; };

static bool ReadyAimToThrowWeapon(CNEOBot* me, CNEO_Player* pCommander)
{
me->GetBodyInterface()->AimHeadTowards(pCommander->GetAbsOrigin(), IBody::MANDATORY, 0.2f, nullptr, "Aiming at user's feet to throw weapon");

Vector vecToUserFeet = pCommander->GetAbsOrigin() - me->EyePosition();
vecToUserFeet.NormalizeInPlace();

Vector vecBotFacing;
me->EyeVectors(&vecBotFacing);

return (vecBotFacing.Dot(vecToUserFeet) > 0.95f);
}
};

#endif // NEO_BOT_THROW_WEAPON_AT_USER_H
35 changes: 18 additions & 17 deletions src/game/server/neo/neo_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3280,16 +3280,13 @@ void CNEO_Player::SetTestMessageVisible(bool visible)

void CNEO_Player::ResetBotCommandState()
{
if (sv_neo_bot_cmdr_enable.GetBool())
m_hLeadingPlayer = nullptr;
m_hCommandingPlayer = nullptr;
m_tBotPlayerPingCooldown.Invalidate();
m_flBotDynamicFollowDistanceSq = 0.0f;
for (int i = 0; i < STAR__TOTAL; ++i)
{
m_hLeadingPlayer = nullptr;
m_hCommandingPlayer = nullptr;
m_tBotPlayerPingCooldown.Invalidate();
m_flBotDynamicFollowDistanceSq = 0.0f;
for (int i = 0; i < STAR__TOTAL; ++i)
{
m_vLastPingByStar.GetForModify(i) = VECTOR_INVALID_WAYPOINT;
}
m_vLastPingByStar.GetForModify(i) = VECTOR_INVALID_WAYPOINT;
}
}

Expand Down Expand Up @@ -3362,11 +3359,6 @@ void CNEO_Player::PlayerUse( void )
{
BaseClass::PlayerUse();

if (!sv_neo_bot_cmdr_enable.GetBool())
{
return;
}

if ( (m_afButtonPressed & IN_USE) && !FindUseEntity() )
{
// Select bot under cursor to follow/unfollow.
Expand All @@ -3384,9 +3376,18 @@ void CNEO_Player::PlayerUse( void )
CNEO_Player* pTargetPlayer = ToNEOPlayer(tr.m_pEnt);
if ( pTargetPlayer && pTargetPlayer->IsBot())
{
// The hit entity is a bot! Now, toggle its follow state.
pTargetPlayer->ToggleBotFollowCommander( this );
// TODO: Do we want to allow using players for some kind of communication?
if (sv_neo_bot_cmdr_enable.GetBool())
{
// The hit entity is a bot! Now, toggle its follow state.
pTargetPlayer->ToggleBotFollowCommander( this );
// TODO: Do we want to allow using players for some kind of communication?
}
else if (NEORules()->IsTeamplay() && pTargetPlayer->GetTeamNumber() == GetTeamNumber())
{
// Alt: Triggers throwing primary weapon to user
// see neo_bot_scenario_monitor for behavior transition
pTargetPlayer->m_hCommandingPlayer = this;
}
}
}
}
Expand Down