-
Notifications
You must be signed in to change notification settings - Fork 20
Bots can trade/donate their primary weapon with their commander #1629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sunzenshen
wants to merge
1
commit into
NeotokyoRebuild:master
Choose a base branch
from
sunzenshen:bot-cmd-trade-weapon
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,6 @@ | |
| #include "bot/behavior/neo_bot_tactical_monitor.h" | ||
| #include "bot/behavior/neo_bot_scenario_monitor.h" | ||
|
|
||
| #include "bot/behavior/neo_bot_command_follow.h" | ||
| #include "bot/behavior/neo_bot_seek_and_destroy.h" | ||
| #include "bot/behavior/neo_bot_seek_weapon.h" | ||
| #include "bot/behavior/neo_bot_retreat_to_cover.h" | ||
|
|
@@ -26,8 +25,6 @@ | |
|
|
||
| ConVar neo_bot_force_jump( "neo_bot_force_jump", "0", FCVAR_CHEAT, "Force bots to continuously jump" ); | ||
| ConVar neo_bot_grenade_check_radius( "neo_bot_grenade_check_radius", "500", FCVAR_CHEAT ); | ||
| extern ConVar sv_neo_bot_cmdr_enable; | ||
| extern ConVar sv_neo_bot_cmdr_debug_pause_uncommanded; | ||
|
|
||
| //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
|
|
||
|
|
@@ -279,19 +276,6 @@ ActionResult< CNEOBot > CNEOBotTacticalMonitor::Update( CNEOBot *me, float inter | |
| return result; | ||
| } | ||
|
|
||
| if (sv_neo_bot_cmdr_enable.GetBool()) | ||
| { | ||
| if (me->m_hLeadingPlayer.Get() || me->m_hCommandingPlayer.Get()) | ||
| { | ||
| return SuspendFor(new CNEOBotCommandFollow, "Following commander"); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It turns out that launching into the bot commander following behavior was blocking other tactical monitor behaviors, so I moved this behavior launch point into neo_bot_scenario_monitor. |
||
| } | ||
|
|
||
| if (sv_neo_bot_cmdr_debug_pause_uncommanded.GetBool()) | ||
| { | ||
| return SuspendFor( new CNEOBotPause, "Paused by debug convar sv_neo_bot_cmdr_debug_pause_uncommanded" ); | ||
| } | ||
| } | ||
|
|
||
| const CKnownEntity *threat = me->GetVisionInterface()->GetPrimaryKnownThreat(); | ||
|
|
||
| // check if we need to get to cover | ||
|
|
@@ -370,7 +354,7 @@ ActionResult< CNEOBot > CNEOBotTacticalMonitor::ScavengeForPrimaryWeapon( CNEOBo | |
| { | ||
| return Continue(); | ||
| } | ||
| m_maintainTimer.Start( RandomFloat( 1.0f, 3.0f ) ); | ||
| m_maintainTimer.Start( 1.0f ); | ||
|
|
||
| // Look for any one valid primary weapon, then dispatch into behavior for more optimal search | ||
| // true parameter: short-circuit the search if any valid primary weapon is found | ||
|
|
||
63 changes: 63 additions & 0 deletions
63
src/game/server/neo/bot/behavior/neo_bot_throw_weapon_at_player.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| #include "cbase.h" | ||
| #include "bot/neo_bot.h" | ||
| #include "neo_player.h" | ||
| #include "bot/behavior/neo_bot_throw_weapon_at_player.h" | ||
|
|
||
| // memdbgon must be the last include file in a .cpp file!!! | ||
| #include "tier0/memdbgon.h" | ||
|
|
||
| //--------------------------------------------------------------------------------------------- | ||
| CNEOBotThrowWeaponAtPlayer::CNEOBotThrowWeaponAtPlayer( CNEO_Player *pTargetPlayer ) | ||
| { | ||
| m_hTargetPlayer = pTargetPlayer; | ||
| } | ||
|
|
||
| //--------------------------------------------------------------------------------------------- | ||
| ActionResult< CNEOBot > CNEOBotThrowWeaponAtPlayer::OnStart( CNEOBot *me, Action< CNEOBot > *priorAction ) | ||
| { | ||
| if ( !m_hTargetPlayer ) | ||
| { | ||
| return Done( "No target player to throw weapon at" ); | ||
| } | ||
|
|
||
| return Continue(); | ||
| } | ||
|
|
||
| //--------------------------------------------------------------------------------------------- | ||
| ActionResult< CNEOBot > CNEOBotThrowWeaponAtPlayer::Update( CNEOBot *me, float interval ) | ||
| { | ||
| CNEO_Player *pTarget = m_hTargetPlayer.Get(); | ||
| if ( !pTarget || !pTarget->IsAlive() ) | ||
| { | ||
| return Done( "Target player lost or died" ); | ||
| } | ||
|
|
||
| me->GetBodyInterface()->AimHeadTowards( pTarget->EyePosition(), IBody::CRITICAL, 0.2f, NULL, "Aiming at player to throw weapon" ); | ||
|
|
||
| CBaseCombatWeapon *pPrimary = me->Weapon_GetSlot( 0 ); | ||
| if ( pPrimary ) | ||
| { | ||
| if ( me->GetActiveWeapon() != pPrimary ) | ||
| { | ||
| me->Weapon_Switch( pPrimary ); | ||
| return Continue(); // Wait for switch | ||
| } | ||
| } | ||
| else | ||
| { | ||
| return Done( "No primary weapon to throw" ); | ||
| } | ||
|
|
||
| if ( me->GetBodyInterface()->IsHeadAimingOnTarget() ) | ||
| { | ||
| me->PressDropButton(); | ||
| return Done("Weapon dropped"); | ||
| } | ||
|
|
||
| return Continue(); | ||
| } | ||
|
|
||
| //--------------------------------------------------------------------------------------------- | ||
| void CNEOBotThrowWeaponAtPlayer::OnEnd( CNEOBot *me, Action< CNEOBot > *nextAction ) | ||
| { | ||
| } |
26 changes: 26 additions & 0 deletions
26
src/game/server/neo/bot/behavior/neo_bot_throw_weapon_at_player.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| #ifndef NEO_BOT_THROW_WEAPON_AT_PLAYER_H | ||
| #define NEO_BOT_THROW_WEAPON_AT_PLAYER_H | ||
| #ifdef _WIN32 | ||
| #pragma once | ||
| #endif | ||
|
|
||
| #include "NextBotBehavior.h" | ||
|
|
||
| class CNEO_Player; | ||
|
|
||
| class CNEOBotThrowWeaponAtPlayer : public Action< CNEOBot > | ||
| { | ||
| public: | ||
| CNEOBotThrowWeaponAtPlayer( CNEO_Player *pTargetPlayer ); | ||
|
|
||
| virtual ActionResult< CNEOBot > OnStart( CNEOBot *me, Action< CNEOBot > *priorAction ) override; | ||
| virtual ActionResult< CNEOBot > Update( CNEOBot *me, float interval ) override; | ||
| virtual void OnEnd( CNEOBot *me, Action< CNEOBot > *nextAction ) override; | ||
|
|
||
| virtual const char *GetName( void ) const override { return "ThrowWeaponAtPlayer"; }; | ||
|
|
||
| private: | ||
| CHandle<CNEO_Player> m_hTargetPlayer; | ||
| }; | ||
|
|
||
| #endif // NEO_BOT_THROW_WEAPON_AT_PLAYER_H |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved from neo_bot_tactical_monitor, to unblock other tactical monitor behaviors.