mirror of
https://github.com/ENSL/NS.git
synced 2024-11-15 01:11:43 +00:00
58358d0927
* Initial bot commit * Added server commands and cvars for adding AI players to the game. * Added auto modes for automating the adding and removal of bots * Bots connect to the server and join teams correctly * Added round restart and new map detection for AI system Push before new project added for detour * Initial bot integration * Integrated all basic bot code for navigation and task performing * Added support for multi_managers to better understand how buttons and triggers affect doors * Improved bot understanding of door triggers and weldables * Reworked nav profiles Nav profiles for bots are now dynamically updated to take into account changing capabilities, such as picking up a welder * Improved bot door usage * Added weldable obstacles back into navigation Bots now understand how to get around weldable barriers * Replaced fixed arrays with vectors * Resource node and hive lists are now vectors. * Further improved bot weld behaviour * Added dynamic reachability calculations When barriers and doors are open/closed, new reachability calculations are done for structures and items so bots understand when items/structures become reachable or unreachable as the match progresses. * Added team-based reachability calculations Reachabilities for structures and items are now based on the team, so bots understand when they can't reach a structure from their spawn point. * Implemented long-range off-mesh connections and dynamic off-mesh connections * Implemented fully dynamic off-mesh connections Phase gates now use connections rather than custom path finding. Much more performant. * Replaced arrays with vectors for simpler code * Started Bot Swimming * Bots understand trigger_changetarget Bots can now navigate doors operated with a trigger_changetarget so they understand the sequence in which triggers must be activated to make it work * Push before trying to fix long-range connections * Implement new off-mesh connection system * Redid population of door triggers * Fixed trigger types and links to doors * Added lift and moving platform support * Lift improvements * Bots avoid getting crushed under a lift when summoning it * Bots are better at judging which stop a platform needs to be at * Tweak lift and welder usage * Fixed bug with multiple off-mesh connections close together * Finish lift movement * Fixed dodgy path finding * Improved skulk ladder usage and lerk lift usage * Fix crash with path finding * Re-implement commander AI * Commander improvements * Improve commander sieging * Commander scanning tweak * Reimplemented regular marine AI * Start reimplementing alien AI * Implement gorge building behaviours * Start alien tactical decisioning * Continuing alien building and other non-combat logic * More alien role work * Adjusted base node definitions * Iterate Capper Logic * Alien assault AI * Alien Combat * Fix grenade throwing, better combat * Marine combat AI improvements * Commander improvements * Commander + nav improvements * Drop mines * Improved bot stuck detection * Commander supply improvements * Bot fill timing config * Added nsbots.cfg to configure internal bots * Changed bot config file to "nsbots.cfg" * Bug fixing with navigation * Fix skulk movement on ladders * Improved commander placement and tactical refresh * Fixed bug with ladder climbing * Doors block off-mesh connections * Finished doors blocking connections * Marine and alien tactical bug fixes * Add commander beacon back in * Start combat mode stuff * First pass at combat mode * Bots attack turrets * Fix ladder and wall climbing * Commander chat request * Improved skulk ladders * Added nav meshes for new bot code * Added bot configuration to listen server menu * Added bot config file * Added default bot config to listenserver.cfg * Added default bot settings to server.cfg * Include VS filter for bot files * Crash fixes * Bot improvements * Bot stability and mine placement improvements * Fixed crash on new map start with bots * Reverted Svencoop fix * Fixed crash, added more cvars * Performance improvement * Commander building improvements * Stop bot spasming when waiting to take command * Fixed doors not blocking connections * Added bot disabled guard to round start * Commander improvements, movement improvements * Tweaked level load sequence * Performance improvements * Bot load spread * Fixed commander update * Refactor bot frame handling * Bug fixes + Pierow's dynamic load spread * Minor bug fixes * Fix door detection, prep for test * Fixed commander siege spam * linux compile test * fix hardcoded inlcudes * O1 compile flag for detour - fix linux server crash * Revert detour compile flags to original for windows * linux build update * remove x64 build configs * update bot nav meshes and configs * fix bot physics at high server fps, update navmeshes. from @RGreenlees --------- Co-authored-by: RGreenlees <RGreenlees@users.noreply.github.com> Co-authored-by: RichardGreenlees <richard.greenlees@forecast.global>
309 lines
7.4 KiB
C++
309 lines
7.4 KiB
C++
//======== (C) Copyright 2002 Charles G. Cleveland All rights reserved. =========
|
|
//
|
|
// The copyright to the contents herein is the property of Charles G. Cleveland.
|
|
// The contents may be used and/or copied only with the written permission of
|
|
// Charles G. Cleveland, or in accordance with the terms and conditions stipulated in
|
|
// the agreement/contract under which the contents have been supplied.
|
|
//
|
|
// Purpose:
|
|
//
|
|
// $Workfile: AvHAlienWeapon.cpp $
|
|
// $Date: 2002/10/03 18:37:32 $
|
|
//
|
|
//-------------------------------------------------------------------------------
|
|
// $Log: AvHAlienWeapon.cpp,v $
|
|
// Revision 1.9 2002/10/03 18:37:32 Flayra
|
|
// - Moved alien energy to fuser3
|
|
//
|
|
// Revision 1.8 2002/09/23 22:08:59 Flayra
|
|
// - Updates to allow marine weapons stick around
|
|
//
|
|
// Revision 1.7 2002/08/31 18:01:00 Flayra
|
|
// - Work at VALVe
|
|
//
|
|
// Revision 1.6 2002/08/16 02:32:09 Flayra
|
|
// - Added damage types
|
|
// - Swapped umbra and bile bomb
|
|
//
|
|
// Revision 1.5 2002/07/08 16:43:26 Flayra
|
|
// - Web change?
|
|
//
|
|
// Revision 1.4 2002/06/25 17:29:56 Flayra
|
|
// - Better default behavior
|
|
//
|
|
// Revision 1.3 2002/06/03 16:25:10 Flayra
|
|
// - Switch alien weapons quickly, renamed CheckValidAttack()
|
|
//
|
|
// Revision 1.2 2002/05/28 17:37:14 Flayra
|
|
// - Reduced times where alien weapons are dropped and picked up again (but didn't eliminate, they are still being instantiated somewhere)
|
|
//
|
|
// Revision 1.1 2002/05/23 02:34:00 Flayra
|
|
// - Post-crash checkin. Restored @Backup from around 4/16. Contains changes for last four weeks of development.
|
|
//
|
|
//===============================================================================
|
|
#include "AvHAlienWeapon.h"
|
|
#include "AvHMovementUtil.h"
|
|
#include "AvHSpecials.h"
|
|
|
|
#ifdef AVH_CLIENT
|
|
#include "cl_dll/wrect.h"
|
|
#include "cl_dll/cl_dll.h"
|
|
#include "cl_dll/hud.h"
|
|
#include "cl_dll/cl_util.h"
|
|
extern int g_runfuncs;
|
|
#include "cl_dll/com_weapons.h"
|
|
|
|
#include "../common/net_api.h"
|
|
|
|
#include "../pm_shared/pm_defs.h"
|
|
#include "../pm_shared/pm_shared.h"
|
|
#include "../pm_shared/pm_movevars.h"
|
|
extern playermove_t *pmove;
|
|
#endif
|
|
|
|
#include "AvHSharedUtil.h"
|
|
#include "../util/Balance.h"
|
|
|
|
AvHAlienWeapon::AvHAlienWeapon()
|
|
{
|
|
#ifdef AVH_SERVER
|
|
this->SetGroundLifetime(0);
|
|
#endif
|
|
}
|
|
|
|
bool AvHAlienWeapon::ProcessValidAttack(void)
|
|
{
|
|
bool theCanAttack = false;
|
|
|
|
if(AvHBasePlayerWeapon::ProcessValidAttack())
|
|
{
|
|
if(this->IsUseable())
|
|
{
|
|
theCanAttack = true;
|
|
}
|
|
}
|
|
|
|
return theCanAttack;
|
|
}
|
|
|
|
void AvHAlienWeapon::DeductCostForShot(void)
|
|
{
|
|
if(this->GetTakesEnergy())
|
|
{
|
|
AvHBasePlayerWeapon::DeductCostForShot();
|
|
|
|
float theEnergyCost = this->GetEnergyForAttack();
|
|
float& theFuser = this->GetEnergyLevel();
|
|
AvHMUDeductAlienEnergy(theFuser, theEnergyCost);
|
|
}
|
|
}
|
|
|
|
// Cannot ever drop alien weapons
|
|
void AvHAlienWeapon::Drop(void)
|
|
{
|
|
}
|
|
|
|
bool AvHAlienWeapon::GetAllowedForUser3(AvHUser3 inUser3)
|
|
{
|
|
bool theAllowed = false;
|
|
|
|
// Alien weapons for aliens. Don't take into account exact roles until needed (and until weapons have stabilized)
|
|
switch(inUser3)
|
|
{
|
|
case AVH_USER3_ALIEN_PLAYER1:
|
|
case AVH_USER3_ALIEN_PLAYER2:
|
|
case AVH_USER3_ALIEN_PLAYER3:
|
|
case AVH_USER3_ALIEN_PLAYER4:
|
|
case AVH_USER3_ALIEN_PLAYER5:
|
|
theAllowed = true;
|
|
break;
|
|
}
|
|
|
|
return theAllowed;
|
|
}
|
|
|
|
int AvHAlienWeapon::GetDamageType() const
|
|
{
|
|
// Assume melee attack, piercing
|
|
//return NS_DMG_PIERCING;
|
|
return NS_DMG_NORMAL;
|
|
}
|
|
|
|
float AvHAlienWeapon::GetDeployTime() const
|
|
{
|
|
// Aliens are Quake-style/arcadey, make weapon switch fast
|
|
return .1f;
|
|
}
|
|
|
|
float AvHAlienWeapon::GetEnergyForAttack() const
|
|
{
|
|
float theEnergy = 0.0f;
|
|
|
|
AvHMUGetEnergyCost((AvHWeaponID)(this->m_iId), theEnergy);
|
|
|
|
return theEnergy;
|
|
}
|
|
|
|
bool AvHAlienWeapon::GetFiresUnderwater() const
|
|
{
|
|
return true;
|
|
}
|
|
|
|
// Never live on ground
|
|
int AvHAlienWeapon::GetGroundLifetime() const
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
float& AvHAlienWeapon::GetEnergyLevel()
|
|
{
|
|
#ifdef AVH_CLIENT
|
|
float& theFuser = pmove->fuser3;
|
|
#endif
|
|
|
|
#ifdef AVH_SERVER
|
|
float& theFuser = this->m_pPlayer->pev->fuser3;
|
|
#endif
|
|
|
|
return theFuser;
|
|
}
|
|
|
|
bool AvHAlienWeapon::GetIsDroppable() const
|
|
{
|
|
return false;
|
|
}
|
|
|
|
bool AvHAlienWeapon::GetIsGunPositionValid() const
|
|
{
|
|
// Check to make sure our gun barrel isn't coming out on the other side of a wall.
|
|
|
|
vec3_t theBarrelOrigin;
|
|
vec3_t theBarrelEnd;
|
|
|
|
#ifdef AVH_CLIENT
|
|
|
|
extern vec3_t v_view_ofs; // In view.cpp
|
|
extern vec3_t v_cl_angles;
|
|
|
|
cl_entity_s* thePlayer = gHUD.GetVisiblePlayer();
|
|
|
|
VectorAdd(thePlayer->curstate.origin, v_view_ofs, theBarrelOrigin);
|
|
|
|
vec3_t theBarrelDirection;
|
|
AngleVectors(v_angles, theBarrelDirection, NULL, NULL);
|
|
|
|
VectorMA(theBarrelOrigin, GetBarrelLength(), theBarrelDirection, theBarrelEnd);
|
|
|
|
#endif
|
|
|
|
#ifdef AVH_SERVER
|
|
|
|
VectorCopy(m_pPlayer->GetGunPosition(), theBarrelOrigin);
|
|
VectorCopy(GetWorldBarrelPoint(), theBarrelEnd);
|
|
|
|
#endif
|
|
|
|
return AvHTraceLineAgainstWorld(theBarrelOrigin, theBarrelEnd) == 1;
|
|
}
|
|
|
|
float AvHAlienWeapon::ComputeAttackInterval() const
|
|
{
|
|
float theROF = this->GetRateOfFire();
|
|
|
|
int theUser4 = this->m_pPlayer->pev->iuser4;
|
|
|
|
#ifdef AVH_CLIENT
|
|
cl_entity_t* theLocalPlayer = gEngfuncs.GetLocalPlayer();
|
|
if(theLocalPlayer)
|
|
{
|
|
theUser4 = theLocalPlayer->curstate.iuser4;
|
|
}
|
|
#endif
|
|
|
|
// Speed attack if in range of primal scream
|
|
if(GetHasUpgrade(theUser4, MASK_BUFFED))
|
|
{
|
|
float thePrimalScreamROFFactor = 1.0f + BALANCE_VAR(kPrimalScreamROFFactor);
|
|
theROF /= thePrimalScreamROFFactor;
|
|
}
|
|
|
|
// Check for focus
|
|
if(AvHSHUGetIsWeaponFocusable(AvHWeaponID(this->m_iId)))
|
|
{
|
|
int theFocusLevel = AvHGetAlienUpgradeLevel(theUser4, MASK_UPGRADE_8);
|
|
if(theFocusLevel > 0)
|
|
{
|
|
// Slow down ROF by x% for each level
|
|
const float theFocusROFPercentSlowdownPerLevel = BALANCE_VAR(kFocusROFPercentSlowdownPerLevel);
|
|
float theSlowDownPercentage = 1.0f + theFocusLevel*theFocusROFPercentSlowdownPerLevel;
|
|
|
|
theROF *= theSlowDownPercentage;
|
|
}
|
|
}
|
|
|
|
return theROF;
|
|
}
|
|
|
|
void AvHAlienWeapon::Precache(void)
|
|
{
|
|
AvHBasePlayerWeapon::Precache();
|
|
}
|
|
|
|
void AvHAlienWeapon::Spawn()
|
|
{
|
|
AvHBasePlayerWeapon::Spawn();
|
|
|
|
this->pev->iuser3 = AVH_USER3_NONE;
|
|
|
|
#ifdef AVH_SERVER
|
|
this->SetGroundLifetime(0);
|
|
#endif
|
|
}
|
|
|
|
|
|
BOOL AvHAlienWeapon::IsUseable(void)
|
|
{
|
|
BOOL theIsUseable = FALSE;
|
|
|
|
// Make sure we have enough energy for this attack
|
|
float theEnergyCost = this->GetEnergyForAttack();
|
|
float& theFuser = this->GetEnergyLevel();
|
|
float theLatency = 0.0f;
|
|
#ifdef AVH_CLIENT
|
|
// : 991 -- added latency-based prediction for the ammount of energy available to the alien
|
|
net_status_s current_status;
|
|
gEngfuncs.pNetAPI->Status(¤t_status);
|
|
|
|
/* svencoop compatibility change. Commented out to avoid conflicts with SDK TOS
|
|
net_status_s current_status;
|
|
char TestStruct[256]; // Allocate lots of memory to anticipate Svengine's larger size
|
|
gEngfuncs.pNetAPI->Status((net_status_s*)&TestStruct);
|
|
|
|
memcpy(¤t_status, TestStruct, sizeof(net_status_s)); // Now copy back the original struct size. This only works if Svengine added to the struct rather than changed it completely
|
|
*/
|
|
|
|
theLatency = max(0.0f, current_status.latency);
|
|
|
|
int theNumLevels = AvHGetAlienUpgradeLevel(this->m_pPlayer->pev->iuser4, MASK_UPGRADE_5);
|
|
if(theNumLevels > 0)
|
|
theLatency *= (1.0 + theNumLevels * BALANCE_VAR(kAdrenalineEnergyPercentPerLevel));
|
|
#endif
|
|
|
|
if(AvHMUHasEnoughAlienEnergy(theFuser, theEnergyCost, theLatency) && this->GetEnabledState())
|
|
{
|
|
theIsUseable = TRUE;
|
|
}
|
|
|
|
return theIsUseable;
|
|
}
|
|
|
|
bool AvHAlienWeapon::UsesAmmo(void) const
|
|
{
|
|
return false;
|
|
}
|
|
|
|
BOOL AvHAlienWeapon::UseDecrement(void)
|
|
{
|
|
return true;
|
|
}
|
|
|