Skip to content

Commit

Permalink
Final 1.2 Tweaks
Browse files Browse the repository at this point in the history
* Commander will not drop weapons requested by players that already have them, or if one is already on the ground near them
* Commander will research catalysts now so they can be dropped on request
  • Loading branch information
RGreenlees committed Sep 3, 2023
1 parent 2cff092 commit d9378a6
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 3 deletions.
50 changes: 48 additions & 2 deletions evobot/src/bot_commander.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,26 @@ void CommanderReceiveAlert(bot_t* pBot, const Vector Location, const PlayerAlert

void CommanderReceiveWeaponRequest(bot_t* pBot, edict_t* Requestor, NSStructureType ItemToDrop)
{
NSWeapon WeaponType = UTIL_DeployableItemToWeaponType(ItemToDrop);

if (PlayerHasWeapon(Requestor, WeaponType))
{
char buf[512];
sprintf(buf, "You already have one, %s", STRING(Requestor->v.netname));
BotTeamSay(pBot, 2.0f, buf);
return;
}

edict_t* NearbyWeapon = UTIL_GetNearestItemIndexOfType(ItemToDrop, Requestor->v.origin, UTIL_MetresToGoldSrcUnits(5.0f));

if (!FNullEnt(NearbyWeapon))
{
char buf[512];
sprintf(buf, "There's already one on the ground for you, %s", STRING(Requestor->v.netname));
BotTeamSay(pBot, 2.0f, buf);
return;
}

edict_t* Armoury = nullptr;

bool bNeedsAdvancedArmoury = false;
Expand Down Expand Up @@ -430,8 +450,7 @@ void CommanderReceiveWeaponRequest(bot_t* pBot, edict_t* Requestor, NSStructureT
sprintf(buf, "Get near an armoury, %s", STRING(Requestor->v.netname));
}

BotTeamSay(pBot, 2.0f, buf);
return;

}

pBot->SupportAction.ActionType = ACTION_DEPLOY;
Expand Down Expand Up @@ -470,6 +489,17 @@ void CommanderReceiveCatalystRequest(bot_t* pBot, edict_t* Requestor)
{
if (FNullEnt(Requestor) || !IsPlayerActiveInGame(Requestor)) { return; }

edict_t* NearbyCats = UTIL_GetNearestItemIndexOfType(DEPLOYABLE_ITEM_MARINE_CATALYSTS, Requestor->v.origin, UTIL_MetresToGoldSrcUnits(5.0f));

if (!FNullEnt(NearbyCats))
{
char buf[512];
sprintf(buf, "There's a cat pack already on the ground for you, %s", STRING(Requestor->v.netname));
BotTeamSay(pBot, 2.0f, buf);
return;
}


if (!UTIL_ResearchIsComplete(RESEARCH_ARMSLAB_CATALYSTS))
{
char buf[512];
Expand Down Expand Up @@ -2844,6 +2874,22 @@ void COMM_SetNextResearchAction(commander_action* Action)
}
}

if (UTIL_ArmsLabResearchIsAvailable(RESEARCH_ARMSLAB_CATALYSTS))
{
if (Action->ActionType == ACTION_RESEARCH && Action->ResearchId == RESEARCH_ARMSLAB_CATALYSTS) { return; }

edict_t* ArmsLab = UTIL_GetFirstIdleStructureOfType(STRUCTURE_MARINE_ARMSLAB);

if (!FNullEnt(ArmsLab))
{
Action->ActionType = ACTION_RESEARCH;
Action->ActionTarget = ArmsLab;
Action->ResearchId = RESEARCH_ARMSLAB_CATALYSTS;

return;
}
}

if (UTIL_GetFirstPlacedStructureOfType(STRUCTURE_MARINE_PROTOTYPELAB) == nullptr) { return; }

if (UTIL_PrototypeLabResearchIsAvailable(RESEARCH_PROTOTYPELAB_HEAVYARMOUR))
Expand Down
19 changes: 19 additions & 0 deletions evobot/src/bot_tactical.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4820,7 +4820,26 @@ NSStructureType UTIL_WeaponTypeToDeployableItem(const NSWeapon WeaponType)
return STRUCTURE_NONE;
}

NSWeapon UTIL_DeployableItemToWeaponType(const NSStructureType DeployableItem)
{
switch (DeployableItem)
{
case DEPLOYABLE_ITEM_MARINE_SHOTGUN:
return WEAPON_MARINE_SHOTGUN;
case DEPLOYABLE_ITEM_MARINE_GRENADELAUNCHER:
return WEAPON_MARINE_GL;
case DEPLOYABLE_ITEM_MARINE_HMG:
return WEAPON_MARINE_HMG;
case DEPLOYABLE_ITEM_MARINE_WELDER:
return WEAPON_MARINE_WELDER;
case DEPLOYABLE_ITEM_MARINE_MINES:
return WEAPON_MARINE_MINES;
default:
return WEAPON_NONE;
}

return WEAPON_NONE;
}

AvHUpgradeMask UTIL_GetResearchMask(const NSResearch Research)
{
Expand Down
1 change: 1 addition & 0 deletions evobot/src/bot_tactical.h
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ bool UTIL_StructureIsResearching(const edict_t* Structure, const NSResearch Rese
bool UTIL_IsStructureElectrified(const edict_t* Structure);

NSStructureType UTIL_WeaponTypeToDeployableItem(const NSWeapon WeaponType);
NSWeapon UTIL_DeployableItemToWeaponType(const NSStructureType DeployableItem);

AvHUpgradeMask UTIL_GetResearchMask(const NSResearch Research);

Expand Down
2 changes: 1 addition & 1 deletion evobot/src/dllapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void ClientCommand(edict_t* pEntity)
return;
}

if (FStrEq(arg1, "catalyst") || FStrEq(arg1, "catpack") || FStrEq(arg1, "cat"))
if (FStrEq(arg1, "catalyst") || FStrEq(arg1, "catpack") || FStrEq(arg1, "cat") || FStrEq(arg1, "cats"))
{
for (int i = 0; i < 32; i++)
{
Expand Down

0 comments on commit d9378a6

Please sign in to comment.