-
Notifications
You must be signed in to change notification settings - Fork 21
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
Merged
sunzenshen
merged 2 commits into
NeotokyoRebuild:master
from
sunzenshen:bot-cmd-trade-weapon
Feb 22, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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->GetAbsOrigin(), IBody::MANDATORY, 0.1f, NULL, "Aiming at player's feet 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"); | ||
| } | ||
Rainyan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| 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.
Uh oh!
There was an error while loading. Please reload this page.