mirror of
https://github.com/ENSL/NS.git
synced 2024-11-30 00:10:57 +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>
431 lines
12 KiB
C++
431 lines
12 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: AvHResearchManager.cpp $
|
|
// $Date: 2002/10/24 21:41:15 $
|
|
//
|
|
//-------------------------------------------------------------------------------
|
|
// $Log: AvHResearchManager.cpp,v $
|
|
// Revision 1.11 2002/10/24 21:41:15 Flayra
|
|
// - Attempt to fix progress bars not showing up in release, or when playing online (can't quite figure out when). Never safe to compare floats anyways.
|
|
//
|
|
// Revision 1.10 2002/09/23 22:28:33 Flayra
|
|
// - Added GetIsResearching method, so automatic armory resupply could be added
|
|
//
|
|
// Revision 1.9 2002/08/02 21:50:37 Flayra
|
|
// - New research system
|
|
//
|
|
// Revision 1.8 2002/07/24 19:09:17 Flayra
|
|
// - Linux issues
|
|
//
|
|
// Revision 1.7 2002/07/24 18:45:42 Flayra
|
|
// - Linux and scripting changes
|
|
//
|
|
// Revision 1.6 2002/07/23 17:20:13 Flayra
|
|
// - Added hooks for research starting, for distress beacon sound effects
|
|
//
|
|
// Revision 1.5 2002/05/23 02:33:20 Flayra
|
|
// - Post-crash checkin. Restored @Backup from around 4/16. Contains changes for last four weeks of development.
|
|
//
|
|
//===============================================================================
|
|
#include "AvHResearchManager.h"
|
|
|
|
#include "AvHAlienWeapons.h"
|
|
#include "AvHPlayer.h"
|
|
|
|
#ifdef AVH_CLIENT
|
|
#include "cl_dll/eventscripts.h"
|
|
#include "cl_dll/in_defs.h"
|
|
#include "cl_dll/wrect.h"
|
|
#include "cl_dll/cl_dll.h"
|
|
#endif
|
|
|
|
#include "../common/hldm.h"
|
|
#include "../common/event_api.h"
|
|
#include "../common/event_args.h"
|
|
#include "../common/vector_util.h"
|
|
#include "AvHAlienWeaponConstants.h"
|
|
#include "AvHPlayerUpgrade.h"
|
|
#include "AvHServerUtil.h"
|
|
#include "AvHSharedUtil.h"
|
|
#include "AvHGamerules.h"
|
|
|
|
AvHResearchNode::AvHResearchNode(AvHMessageID inMessageID, int inEntityIndex)
|
|
{
|
|
this->mResearch = inMessageID;
|
|
this->mEntityIndex = inEntityIndex;
|
|
this->mTimeResearchDone = -1;
|
|
this->mTimeResearchStarted = -1;
|
|
}
|
|
|
|
bool AvHResearchNode::GetCanEntityContinueResearch() const
|
|
{
|
|
bool theCanContinueResearch = true;
|
|
|
|
CBaseEntity* theResearchEntity = AvHSUGetEntityFromIndex(this->mEntityIndex);
|
|
if(!theResearchEntity || !theResearchEntity->IsAlive())
|
|
{
|
|
theCanContinueResearch = false;
|
|
}
|
|
|
|
return theCanContinueResearch;
|
|
}
|
|
|
|
int AvHResearchNode::GetEntityIndex() const
|
|
{
|
|
return this->mEntityIndex;
|
|
}
|
|
|
|
AvHMessageID AvHResearchNode::GetResearching() const
|
|
{
|
|
return this->mResearch;
|
|
}
|
|
|
|
float AvHResearchNode::GetTimeResearchDone() const
|
|
{
|
|
return this->mTimeResearchDone;
|
|
}
|
|
|
|
float AvHResearchNode::GetTimeResearchStarted() const
|
|
{
|
|
return this->mTimeResearchStarted;
|
|
}
|
|
|
|
bool AvHResearchNode::UpdateResearch()
|
|
{
|
|
bool theResearchDone = false;
|
|
|
|
AvHMessageID theResearchingTech = this->GetResearching();
|
|
if(theResearchingTech != MESSAGE_NULL)
|
|
{
|
|
CBaseEntity* theResearchEntity = AvHSUGetEntityFromIndex(this->mEntityIndex);
|
|
ASSERT(theResearchEntity);
|
|
|
|
float theTimeResearchDone = this->GetTimeResearchDone();
|
|
|
|
// Set time during the first update
|
|
if(theTimeResearchDone < 0)
|
|
{
|
|
this->mTimeResearchStarted = gpGlobals->time;
|
|
theTimeResearchDone = this->mTimeResearchStarted + GetGameRules()->GetBuildTimeForMessageID(theResearchingTech);
|
|
this->mTimeResearchDone = theTimeResearchDone;
|
|
theResearchEntity->pev->iuser2 = (int)this->mResearch;
|
|
}
|
|
|
|
if((gpGlobals->time >= theTimeResearchDone) || GetGameRules()->GetIsTesting())
|
|
{
|
|
theResearchDone = true;
|
|
//AvHSHUSetBuildResearchState(theResearchEntity->pev->iuser3, theResearchEntity->pev->iuser4, theResearchEntity->pev->fuser1, false, 0.0f);
|
|
// theResearchEntity->pev->fuser1 = 0.0f;
|
|
// theResearchEntity->pev->iuser2 = 0;
|
|
}
|
|
else
|
|
{
|
|
float theNormalizedResearchFactor = (gpGlobals->time - this->mTimeResearchStarted)/(this->mTimeResearchDone - this->mTimeResearchStarted);
|
|
theNormalizedResearchFactor = min(max(theNormalizedResearchFactor, 0.0f), 1.0f);
|
|
|
|
//theResearchEntity->pev->fuser1 = (kResearchFuser1Base + theNormalizedResearchFactor)*kNormalizationNetworkFactor;
|
|
AvHSHUSetBuildResearchState(theResearchEntity->pev->iuser3, theResearchEntity->pev->iuser4, theResearchEntity->pev->fuser1, false, theNormalizedResearchFactor);
|
|
}
|
|
}
|
|
|
|
return theResearchDone;
|
|
}
|
|
|
|
|
|
|
|
|
|
// Research manager
|
|
void AvHResearchManager::AddTechNode(AvHMessageID inMessageID, AvHTechID inTechID, AvHTechID inPrereq1, AvHTechID inPrereq2, int inPointCost, int inBuildTime, bool inResearched, bool inAllowMultiples)
|
|
{
|
|
AvHTechNode theTechNode(inMessageID, inTechID, inPrereq1, inPrereq2, inPointCost, inBuildTime, inResearched);
|
|
if(inAllowMultiples)
|
|
{
|
|
theTechNode.setAllowMultiples();
|
|
}
|
|
|
|
this->mTechNodes.InsertNode(&theTechNode);
|
|
}
|
|
|
|
bool AvHResearchManager::GetResearchInfo(AvHMessageID inTech, bool& outIsResearchable, int& outCost, float& outTime) const
|
|
{
|
|
bool theFoundIt = false;
|
|
|
|
// Check each tech nodes
|
|
if(this->mTechNodes.GetResearchInfo(inTech, outIsResearchable, outCost, outTime))
|
|
{
|
|
theFoundIt = true;
|
|
}
|
|
|
|
return theFoundIt;
|
|
}
|
|
|
|
ResearchListType& AvHResearchManager::GetResearchingTech()
|
|
{
|
|
return this->mResearchingTech;
|
|
}
|
|
|
|
const AvHTechTree& AvHResearchManager::GetTechNodes() const
|
|
{
|
|
return this->mTechNodes;
|
|
}
|
|
|
|
AvHTechTree& AvHResearchManager::GetTechNodes()
|
|
{
|
|
return this->mTechNodes;
|
|
}
|
|
|
|
void AvHResearchManager::TriggerAddTech(AvHTechID inTechID)
|
|
{
|
|
this->mTechNodes.TriggerAddTech(inTechID);
|
|
}
|
|
|
|
void AvHResearchManager::TriggerRemoveTech(AvHTechID inTechID)
|
|
{
|
|
this->mTechNodes.TriggerRemoveTech(inTechID);
|
|
}
|
|
|
|
void AvHResearchManager::SetTeamNumber(AvHTeamNumber inTeamNumber)
|
|
{
|
|
this->mTeamNumber = inTeamNumber;
|
|
}
|
|
|
|
bool AvHResearchManager::GetResearchDone(AvHTechID inTech)
|
|
{
|
|
return this->mTechNodes.GetIsTechResearched(inTech);
|
|
}
|
|
|
|
bool AvHResearchManager::SetResearchDone(AvHMessageID inTech, int inEntityIndex)
|
|
{
|
|
bool theFoundIt = false;
|
|
|
|
if(this->mTechNodes.SetResearchDone(inTech))
|
|
{
|
|
edict_t* theEdict = g_engfuncs.pfnPEntityOfEntIndex(inEntityIndex);
|
|
ASSERT(!theEdict->free);
|
|
CBaseEntity* theEntity = CBaseEntity::Instance(theEdict);
|
|
ASSERT(theEntity);
|
|
|
|
// Potentially inform all entities and team of upgrade
|
|
GetGameRules()->ProcessTeamUpgrade(inTech, this->mTeamNumber, inEntityIndex, true);
|
|
|
|
// Hook research complete
|
|
AvHSUResearchComplete(theEntity, inTech);
|
|
|
|
// No longer researching
|
|
//theEntity->pev->fuser1 = kResearchFuser1Base*kNormalizationNetworkFactor;
|
|
AvHSHUSetBuildResearchState(theEntity->pev->iuser3, theEntity->pev->iuser4, theEntity->pev->fuser1, true, 0.0f);
|
|
|
|
// Tell entity that it's no longer researching
|
|
AvHBuildable* theBuildable = dynamic_cast<AvHBuildable*>(theEntity);
|
|
if(theBuildable)
|
|
{
|
|
theBuildable->SetResearching(false);
|
|
}
|
|
|
|
// Send message indicating research is done
|
|
GetGameRules()->TriggerAlert(this->mTeamNumber, ALERT_RESEARCH_COMPLETE, inEntityIndex);
|
|
|
|
theFoundIt = true;
|
|
}
|
|
|
|
return theFoundIt;
|
|
}
|
|
|
|
void AvHResearchManager::Reset()
|
|
{
|
|
// Clear out everything
|
|
this->mResearchingTech.clear();
|
|
this->mTechNodes.Clear();
|
|
}
|
|
|
|
bool AvHResearchManager::CancelResearch(int inEntityIndex, float& outResearchPercentage, AvHMessageID& outMessageID)
|
|
{
|
|
bool theSuccess = false;
|
|
|
|
// Search through researching tech and make sure we're researching this
|
|
for(ResearchListType::iterator theIter = this->mResearchingTech.begin(); theIter != this->mResearchingTech.end(); theIter++)
|
|
{
|
|
if(theIter->GetEntityIndex() == inEntityIndex)
|
|
{
|
|
float theEndTime = theIter->GetTimeResearchDone();
|
|
float theStartTime = theIter->GetTimeResearchStarted();
|
|
outResearchPercentage = (gpGlobals->time - theStartTime)/(theEndTime - theStartTime);
|
|
|
|
outMessageID = theIter->GetResearching();
|
|
|
|
this->mResearchingTech.erase(theIter);
|
|
|
|
// Look up entity and reset research progress
|
|
CBaseEntity* theResearchEntity = AvHSUGetEntityFromIndex(inEntityIndex);
|
|
ASSERT(theResearchEntity);
|
|
//theResearchEntity->pev->fuser1 = kResearchFuser1Base*kNormalizationNetworkFactor;
|
|
AvHSHUSetBuildResearchState(theResearchEntity->pev->iuser3, theResearchEntity->pev->iuser4, theResearchEntity->pev->fuser1, false, 0.0f);
|
|
|
|
AvHBuildable* theBuildable = dynamic_cast<AvHBuildable*>(theResearchEntity);
|
|
if(theBuildable)
|
|
{
|
|
theBuildable->SetResearching(false);
|
|
}
|
|
|
|
theSuccess = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
return theSuccess;
|
|
}
|
|
|
|
bool AvHResearchManager::SetResearching(AvHMessageID inMessageID, int inEntityIndex)
|
|
{
|
|
bool theCouldStart = true;
|
|
|
|
// Search through researching tech and make sure this entity isn't already researching something
|
|
for(ResearchListType::iterator theIter = this->mResearchingTech.begin(); theIter != this->mResearchingTech.end(); theIter++)
|
|
{
|
|
if(theIter->GetEntityIndex() == inEntityIndex)
|
|
{
|
|
theCouldStart = false;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if(theCouldStart)
|
|
{
|
|
bool theIsResearchable = false;
|
|
int theCost;
|
|
float theTime;
|
|
// : 0000199
|
|
// Look up entity and check that research is valid for this entity.
|
|
CBaseEntity* theResearchEntity = AvHSUGetEntityFromIndex(inEntityIndex);
|
|
ASSERT(theResearchEntity);
|
|
|
|
if (!AvHSUGetIsResearchApplicable(theResearchEntity,inMessageID)) {
|
|
theCouldStart = false;
|
|
}
|
|
// :
|
|
|
|
if(!this->GetResearchInfo(inMessageID, theIsResearchable, theCost, theTime) || !theIsResearchable)
|
|
{
|
|
theCouldStart = false;
|
|
}
|
|
}
|
|
|
|
if(theCouldStart)
|
|
{
|
|
this->mResearchingTech.push_back(AvHResearchNode(inMessageID, inEntityIndex));
|
|
|
|
// Tell entity that it's researching
|
|
edict_t* theEdict = g_engfuncs.pfnPEntityOfEntIndex(inEntityIndex);
|
|
ASSERT(!theEdict->free);
|
|
CBaseEntity* theEntity = CBaseEntity::Instance(theEdict);
|
|
ASSERT(theEntity);
|
|
|
|
AvHBuildable* theBuildable = dynamic_cast<AvHBuildable*>(theEntity);
|
|
if(theBuildable)
|
|
{
|
|
theBuildable->SetResearching(true);
|
|
AvHSUResearchStarted(theEntity, inMessageID);
|
|
}
|
|
}
|
|
|
|
return theCouldStart;
|
|
}
|
|
|
|
bool AvHResearchManager::GetIsMessageAvailable(AvHMessageID& inMessageID) const
|
|
{
|
|
bool theIsAvailable = false;
|
|
|
|
if(this->mTechNodes.GetIsMessageAvailable(inMessageID))
|
|
{
|
|
// Make sure it's not a one time research that we're currently researching
|
|
if(this->GetIsResearchingTech(inMessageID) && !this->mTechNodes.GetAllowMultiples(inMessageID))
|
|
{
|
|
theIsAvailable = false;
|
|
}
|
|
else
|
|
{
|
|
theIsAvailable = true;
|
|
}
|
|
}
|
|
|
|
return theIsAvailable;
|
|
}
|
|
|
|
TechNodeMap AvHResearchManager::GetResearchNodesDependentOn(AvHTechID inTechID) const
|
|
{
|
|
TechNodeMap theTechNodes;
|
|
|
|
this->mTechNodes.GetResearchNodesDependentOn(inTechID, theTechNodes);
|
|
|
|
return theTechNodes;
|
|
}
|
|
|
|
bool AvHResearchManager::GetIsResearchingTech(AvHMessageID inMessageID) const
|
|
{
|
|
bool theIsResearchingTech = false;
|
|
|
|
for(ResearchListType::const_iterator theIter = this->mResearchingTech.begin(); theIter != this->mResearchingTech.end(); theIter++)
|
|
{
|
|
if(theIter->GetResearching() == inMessageID)
|
|
{
|
|
theIsResearchingTech = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
return theIsResearchingTech;
|
|
}
|
|
|
|
|
|
bool AvHResearchManager::GetIsResearching(int inEntityIndex) const
|
|
{
|
|
bool theIsResearching = false;
|
|
|
|
// Run through every item in the list and update research, marking any done
|
|
for(ResearchListType::const_iterator theIter = this->mResearchingTech.begin(); theIter != this->mResearchingTech.end(); theIter++)
|
|
{
|
|
if(theIter->GetEntityIndex() == inEntityIndex)
|
|
{
|
|
theIsResearching = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
return theIsResearching;
|
|
}
|
|
|
|
void AvHResearchManager::UpdateResearch()
|
|
{
|
|
// Run through every item in the list and update research, marking any done
|
|
for(ResearchListType::iterator theIter = this->mResearchingTech.begin(); theIter != this->mResearchingTech.end(); )
|
|
{
|
|
if(theIter->GetCanEntityContinueResearch())
|
|
{
|
|
bool theHighTechCheat = GetGameRules()->GetIsCheatEnabled(kcHighTech);
|
|
if(theIter->UpdateResearch() || theHighTechCheat)
|
|
{
|
|
AvHMessageID theResearchingTech = theIter->GetResearching();
|
|
int theEntityIndex = theIter->GetEntityIndex();
|
|
|
|
this->SetResearchDone(theResearchingTech, theEntityIndex);
|
|
|
|
theIter = this->mResearchingTech.erase(theIter);
|
|
}
|
|
else
|
|
{
|
|
theIter++;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
theIter = this->mResearchingTech.erase(theIter);
|
|
}
|
|
}
|
|
}
|