mirror of
https://github.com/Ragora/TribesReplay.git
synced 2026-01-19 17:44:45 +00:00
* Fixed a problem that could have caused texture leaking in the interiors * Fixed an AI problem in Training 2 * Chinese "simplified" keyboard supported * Korean keyboard supported * A bug where infinite ammo could be gained by tossing the ammo was prevented. * Fixed a problem in Training 2 where a waypoint wouldn't update properly. * Thundersword and Havoc hold steady now when players try to jump in so they don't invert and detonate. * CD is now required in the drive for on-line play. * Scoring has been fixed so that it isn't blanked any longer if the admin changes the time limit during a game. * Active server queries will be cancelled now when you join a game (loads game faster now). * If standing in an inventory station when it is destroyed you no longer permanently lose weapons. * Fixed two issues that *could* cause crashes. * Fixed a problem where the bombardier could create a permanent targeting laser. * Cleaned up Chat text to remove programming characters. * Fixed "highlight text with my nick" option so it saves preference to file correctly. * Made MPB able to climb hills more easily and reduced damage from impact with the ground. * Added button to stop server queries in progress on "JOIN" screen. * Observers can now only chat with other observers (no one else can hear them). * Made deployable inv stations have smaller trigger so they don't "suck you in" from so far away. * Bots will now claim switches in CnH more accurately. * Added a "max distance" ring for sensors on the commander map so players can more accurately assess how well they placed the sensor in relation to how much area it is actually sensing. * Added a "ding" sound when you have filled up a text buffer so that you know why your text isn't showing up. * Fixed Chat HUD so that page up/page down works better. * Fixed a situation where Heavies could end up being permanently cloaked. * The MPBs on the "Alcatraz" map now deploy correctly (Siege map). * The "edited post" date stamp now works correctly. * If you jump into a vehicle while zoomed in, the zoom will reset correctly therafter now. * The Score Screen (F2) is now available while in a vehicle. * You can now vote to kick observers, if desired. * The ELF turret is fixed so it no longer fires at players when destroyed (an intermittent bug) * Some console spam associated with the Wildcat has been removed. * There was a situation where a player could die twice if he fell out of bounds. That has been resolved. * Screen resolution information should update properly now when restarting the application. * The camera should no longer be able to dip below terrain when in third person mode.
449 lines
13 KiB
C#
449 lines
13 KiB
C#
//-----------------------------------------------
|
|
// AI functions for Hunters
|
|
//---------------------------------------------------------------------------
|
|
|
|
// globals
|
|
$AIHuntersFlagSearchRadius = 300;
|
|
$AIHuntersCloseFlagDist = 40;
|
|
$AIHuntersAttackClientFlagCount = 10;
|
|
$AIHuntersMinFlagsToCap = 3;
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
function HuntersGame::onAIRespawn(%game, %client)
|
|
{
|
|
//add the default task
|
|
if (! %client.defaultTasksAdded)
|
|
{
|
|
%client.defaultTasksAdded = true;
|
|
%client.addTask(AIEngageTask);
|
|
%client.addTask(AIPickupItemTask);
|
|
%client.addTask(AIUseInventoryTask);
|
|
%client.addTask(AITauntCorpseTask);
|
|
%client.addTask(AIEngageTurretTask);
|
|
%client.addtask(AIDetectMineTask);
|
|
%client.addTask(AIPatrolTask);
|
|
%client.huntersTask = %client.addTask(AIHuntersTask);
|
|
}
|
|
|
|
//set the inv flag
|
|
%client.spawnUseInv = true;
|
|
}
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
function HuntersGame::AIInit(%game)
|
|
{
|
|
//call the default AIInit() function
|
|
AIInit();
|
|
}
|
|
|
|
//---------------------------------------------------------------------------
|
|
//AIHuntersTask functions
|
|
//---------------------------------------------------------------------------
|
|
function AIHuntersTask::init(%task, %client)
|
|
{
|
|
}
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
function AIHuntersTask::assume(%task, %client)
|
|
{
|
|
%task.setWeightFreq(10);
|
|
%task.setMonitorFreq(10);
|
|
%task.pickupFlag = -1;
|
|
%task.engageTarget = -1;
|
|
%task.capFlags = false;
|
|
}
|
|
|
|
function AIHuntersTask::retire(%task, %client)
|
|
{
|
|
%task.pickupFlag = -1;
|
|
%task.engageTarget = -1;
|
|
%task.capFlags = false;
|
|
}
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
function AIHuntersTask::weight(%task, %client)
|
|
{
|
|
// init flag search vars
|
|
%player = %client.player;
|
|
if (!isObject(%player))
|
|
return;
|
|
|
|
%clientPos = %player.getWorldBoxCenter();
|
|
%task.pickupFlag = -1;
|
|
%task.engageTarget = -1;
|
|
%task.capFlags = false;
|
|
|
|
//find the closest flag
|
|
%flagVars = AIFindClosestFlag(%client, $AIHuntersFlagSearchRadius);
|
|
%closestFlag = getWord(%flagVars, 0);
|
|
%closestFlagDist = getWord(%flagVars, 1);
|
|
|
|
//find the dist to the nexus
|
|
%nexusPos = Game.Nexus.getId().getWorldBoxCenter();
|
|
%nexusDist = %client.getPathDistance(%nexusPos);
|
|
if (%nexusDist < 0)
|
|
%nexusDist = 32767;
|
|
|
|
//find the dist to the closest health
|
|
%healthDist = 32767;
|
|
%damage = %client.player.getDamagePercent();
|
|
if (%damage > 0.7)
|
|
{
|
|
//search for a health kit
|
|
%closestHealth = AIFindSafeItem(%client, "Health");
|
|
if (%closestHealth > 0)
|
|
{
|
|
%healthDist = %client.getPathDistance(%closestHealth);
|
|
if (%healthDist < 0)
|
|
%healthDist = 32767;
|
|
}
|
|
|
|
//else search for an inventory station
|
|
else
|
|
{
|
|
%result = AIFindClosestInventory(%client, false);
|
|
%closestInv = getWord(%result, 0);
|
|
%closestDist = getWord(%result, 1);
|
|
if (%closestInv > 0)
|
|
%healthDist = %closestDist;
|
|
}
|
|
}
|
|
|
|
//see if we need to cap - make sure we're actually able first
|
|
%mustCap = false;
|
|
%shouldCap = false;
|
|
%numToScore = %client.flagCount - 1;
|
|
%hoardModeOn = Game.hoardModeActive();
|
|
if ((!Game.greedMode || %numToScore >= Game.greedMinFlags) && !Game.hoardModeActive() && %numToScore >= $AIHuntersMinFlagsToCap)
|
|
{
|
|
//find out how many points would be scored
|
|
%potentialScore = (%numToScore * (%numToScore + 1)) / 2;
|
|
|
|
//find out how many flags we need to take the lead...
|
|
%needFlagsForLead = 0;
|
|
%highestScore = 0;
|
|
%clientIsInLead = false;
|
|
if (Game.teamMode)
|
|
{
|
|
%teamCount = Game.numTeams;
|
|
for (%i = 1; %i <= %teamCount; %i++)
|
|
{
|
|
if ($teamScore[%i] > %highestScore)
|
|
%highestScore = $teamScore[%i];
|
|
}
|
|
|
|
//see if we're in the lead...
|
|
if (%highestScore == $teamScore[%client.team])
|
|
%clientIsInLead = true;
|
|
else
|
|
{
|
|
%tempScore = $teamScore[%client.team] + %potentialScore;
|
|
%flagValue = %numToScore + 1;
|
|
while (%tempScore < %highestScore)
|
|
{
|
|
%tempScore += %flagValue;
|
|
%flagValue++;
|
|
%needFlagsForLead++;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
%clientCount = ClientGroup.getCount();
|
|
for (%i = 0; %i < %clientCount; %i++)
|
|
{
|
|
%cl = ClientGroup.getObject(%i);
|
|
if (%cl.score > %highestScore)
|
|
%highestScore = %cl.score;
|
|
}
|
|
|
|
//see if we're in the lead
|
|
if (%highestScore == %client.score)
|
|
%clientIsInLead = true;
|
|
else
|
|
{
|
|
%tempScore = %client.score + %potentialScore;
|
|
%flagValue = %numToScore + 1;
|
|
while (%tempScore < %highestScore)
|
|
{
|
|
%tempScore += %flagValue;
|
|
%flagValue++;
|
|
%needFlagsForLead++;
|
|
}
|
|
}
|
|
}
|
|
|
|
//the current target is more dangerous than the closest enemy
|
|
%currentTarget = %client.getEngageTarget();
|
|
if (AIClientIsAlive(%currentTarget))
|
|
{
|
|
%closestEnemy = %currentTarget;
|
|
%closestEnemydist = %client.getPathDistance(%currentTarget.player.position);
|
|
if (%closestEnemyDist < 0)
|
|
%closestEnemyDist = 32767;
|
|
}
|
|
else
|
|
{
|
|
%losTimeout = $AIClientMinLOSTime + ($AIClientLOSTimeout * %client.getSkillLevel());
|
|
%result = AIFindClosestEnemy(%client, $AIHuntersCloseFlagDist, %losTimeout);
|
|
%closestEnemy = getWord(%result, 0);
|
|
%closestEnemydist = getWord(%result, 1);
|
|
}
|
|
|
|
//find out how much time is left...
|
|
%curTimeLeftMS = ($Host::TimeLimit * 60 * 1000) + $missionStartTime - getSimTime();
|
|
|
|
//If there's a tough or equal enemy nearby, or no flags, think about capping
|
|
//ie. never cap if there are flags nearby and no enemies...
|
|
if ((AIClientIsAlive(%closestEnemy) && AIEngageWhoWillWin(%closestEnemy, %client) != %client) ||
|
|
(!isObject(%closestFlag) || %closestFlagDist > $AIHuntersCloseFlagDist))
|
|
{
|
|
//if we've got enough to take the lead, and there are no flags in the vicinity
|
|
if ((!%clientIsInLead && %needFlagsForLead == 0) || %highestScore == 0)
|
|
%mustCap = true;
|
|
|
|
//else if we're about to get our butt kicked and we're much closer to the nexus than to health...
|
|
else if ((AIClientIsAlive(%closestEnemy) && AIEngageWhoWillWin(%closestEnemy, %client) == %closestEnemy) &&
|
|
(%healthDist - %nexusDist > 100))
|
|
{
|
|
%mustCap = true;
|
|
}
|
|
|
|
//else if there's no time left in the mission, cap whatever we've got now...
|
|
else if (%curTimeLeftMS <= 30000)
|
|
%mustCap = true;
|
|
|
|
//else we don't need to cap - see if we should to play it smart
|
|
else
|
|
{
|
|
//if we'd need more than just a couple to take the lead...
|
|
%waitForFlagsTolerance = %client.getSkillLevel() * $AIHuntersMinFlagsToCap * 2;
|
|
if (%needFlagsForLead == 0 || (%needFlagsForLead > %waitForFlagsTolerance))
|
|
{
|
|
%numEnemyFlags = 0;
|
|
%clientCount = ClientGroup.getCount();
|
|
for (%i = 0; %i < %clientCount; %i++)
|
|
{
|
|
%cl = ClientGroup.getObject(%i);
|
|
if (%cl != %client && %cl.flagCount > %numEnemyFlags)
|
|
%numEnemyFlags = %cl.flagCount;
|
|
}
|
|
|
|
//if we're in the lead, or no one has the flags we need, or it's team mode,
|
|
//decide whether to cap based on skill level
|
|
if (%needFlagsForLead == 0 || %numEnemyFlags < %needFlagsForLead || Game.teamMode)
|
|
{
|
|
if (%numToScore >= $AIHuntersMinFlagsToCap + (%client.getSkillLevel() * %client.getSkillLevel() * 15))
|
|
%shouldCap = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//now that we've checked all the possibilities, see if we should or must cap
|
|
if (%mustCap || %shouldCap)
|
|
{
|
|
if (%mustCap)
|
|
%task.setWeight($AIHuntersWeightMustCap);
|
|
else
|
|
%task.setWeight($AIHuntersWeightShouldCap);
|
|
|
|
%task.capFlags = true;
|
|
return;
|
|
}
|
|
}
|
|
|
|
//if we've made it this far, we either can't cap, or there's no need to cap...
|
|
|
|
//if we're engaging someone that's going to kill us, return 0 and let the patrol take over...
|
|
%currentTarget = %client.getEngageTarget();
|
|
if ((AIClientIsAlive(%currentTarget) && AIEngageWhoWillWin(%currentTarget, %client) == %currentTarget) && %healthDist < 300)
|
|
{
|
|
%task.setWeight(0);
|
|
return;
|
|
}
|
|
|
|
//find the closest player with the most flags (that we have los to)
|
|
%losTimeout = $AIClientMinLOSTime + ($AIClientLOSTimeout * %client.getSkillLevel());
|
|
%bestClientToEngage = findClientWithMostFlags(%client, %losTimeout);
|
|
%bestClientDist = 32767;
|
|
if (AIClientIsAlive(%bestClientToEngage))
|
|
{
|
|
%bestClientDist = %client.getPathDistance(%bestClientToEngage.player.position);
|
|
if (%bestClientDist < 0)
|
|
%bestClientDist = 32767;
|
|
}
|
|
|
|
//see if there's a flag
|
|
if (isObject(%closestFlag))
|
|
{
|
|
//see if there's a client to shoot
|
|
if (AIClientIsAlive(%bestClientToEngage))
|
|
{
|
|
//calc weight base on closesness to the nearest flag vs. and number of flags the client has...
|
|
%engageDistFactor = 30 + %bestClientDist - (%bestClientToEngage.flagCount * 5);
|
|
if (%closestFlagDist < %engageDistFactor)
|
|
{
|
|
%task.pickupFlag = %closestFlag;
|
|
%task.engageTarget = %bestClientToEngage;
|
|
%task.setWeight($AIHuntersWeightPickupFlag);
|
|
}
|
|
|
|
//otherwise, ignore the flag, and go for the client
|
|
else
|
|
{
|
|
%task.pickupFlag = -1;
|
|
%task.engageTarget = %bestClientToEngage;
|
|
%task.setWeight($AIHuntersWeightMustEngage);
|
|
}
|
|
}
|
|
|
|
//else no one to attack
|
|
else
|
|
{
|
|
%task.pickupFlag = %closestFlag;
|
|
%task.engageTarget = -1;
|
|
%task.setWeight($AIHuntersWeightPickupFlag);
|
|
}
|
|
}
|
|
|
|
//else no flag, see if we have someone to attack
|
|
else if (AIClientIsAlive(%bestClientToEngage))
|
|
{
|
|
%task.pickupFlag = -1;
|
|
%task.engageTarget = %bestClientToEngage;
|
|
%task.setWeight($AIHuntersWeightShouldEngage);
|
|
}
|
|
|
|
//nothing hunter's related to do...
|
|
else
|
|
{
|
|
%task.pickupFlag = -1;
|
|
%task.engageTarget = -1;
|
|
%task.setWeight(0);
|
|
}
|
|
}
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
function AIHuntersTask::monitor(%task, %client)
|
|
{
|
|
//see if we should cap
|
|
if (%task.capFlags)
|
|
{
|
|
%nexusPos = Game.Nexus.getId().getWorldBoxCenter();
|
|
%client.stepMove(%nexusPos, 0.25);
|
|
}
|
|
|
|
//see if we've got a flag to pick up and/or someone to engage
|
|
else if (isObject(%task.pickupFlag))
|
|
{
|
|
%client.stepMove(%task.pickupFlag.getWorldBoxCenter(), 0.25);
|
|
|
|
if (AIClientIsAlive(%task.engageTarget))
|
|
%client.setEngageTarget(%task.engageTarget);
|
|
}
|
|
|
|
//else see if there's just someone to engage
|
|
else if (AIClientIsAlive(%task.engageTarget))
|
|
%client.stepEngage(%task.engageTarget);
|
|
|
|
//if we're not engaging someone related to the hunters task, engage whoever the AIEngageTask wants...
|
|
else
|
|
%client.setEngageTarget(%client.shouldEngage);
|
|
}
|
|
|
|
//---------------------------------------------------------------------------
|
|
// AIHunters utility functions
|
|
//---------------------------------------------------------------------------
|
|
|
|
function AIFindClosestFlag(%client, %radius)
|
|
{
|
|
%closestFlag = -1;
|
|
%closestDist = %radius;
|
|
%flagCount = $FlagGroup.getCount();
|
|
for (%i = 0; %i < %flagCount; %i++)
|
|
{
|
|
%flag = $FlagGroup.getObject(%i);
|
|
%flagPos = %flag.getWorldBoxCenter();
|
|
%dist = %client.getPathDistance(%flagPos);
|
|
|
|
if (%dist > 0 && %dist < %closestDist)
|
|
{
|
|
%closestDist = %dist;
|
|
%closestFlag = %flag;
|
|
}
|
|
}
|
|
return %closestFlag @ " " @ %closestDist;
|
|
}
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
function findClientWithMostFlags(%srcClient, %losTimeout)
|
|
{
|
|
%clientCount = 0;
|
|
%closestClient = -1;
|
|
%highestFlagFactor = -1; //take both distance and flag count into consideration
|
|
|
|
%count = ClientGroup.getCount();
|
|
for(%i = 0; %i < %count; %i++)
|
|
{
|
|
%cl = ClientGroup.getObject(%i);
|
|
|
|
//make sure we find someone who's alive, and on an opposing team
|
|
if (AIClientIsAlive(%cl) && %cl.team != %srcClient.team)
|
|
{
|
|
%clIsCloaked = false;
|
|
if (%cl.player.getInventory("CloakingPack") > 0 && %cl.player.getImageState($BackpackSlot) $= "activate")
|
|
%clIsCloaked = true;
|
|
|
|
//make sure the client can see the enemy
|
|
%hasLOS = %srcClient.hasLOSToClient(%cl);
|
|
%losTime = %srcClient.getClientLOSTime(%cl);
|
|
if (%hasLOS || (%losTime < %losTimeout && AIClientIsAlive(%cl, %losTime + 1000)))
|
|
{
|
|
%testPos = %cl.player.getWorldBoxCenter();
|
|
%distance = %srcClient.getPathDistance(%testPos);
|
|
if (%distance < 0)
|
|
%distance = 32767;
|
|
|
|
//calculate the flag factor
|
|
%flagFactor = (100 - %distance) + (%cl.flagCount * 5);
|
|
|
|
//see if it's the most suitable client...
|
|
if (%flagFactor > %highestFlagFactor && (!%clIsCloaked || %distance < 8))
|
|
{
|
|
%closestClient = %cl;
|
|
%highestFlagFactor = %flagFactor;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return %closestClient;
|
|
}
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
function aih()
|
|
{
|
|
exec("scripts/aiHunters.cs");
|
|
}
|
|
|
|
function aiHlist()
|
|
{
|
|
$timescale = 0.01;
|
|
%count = ClientGroup.getCount();
|
|
for (%i = 0; %i < %count; %i++)
|
|
{
|
|
%cl = ClientGroup.getObject(%i);
|
|
if (%cl.isAIControlled())
|
|
error(%cl SPC getTaggedString(%cl.name) SPC "score:" SPC %cl.score SPC "flags:" SPC %cl.flagCount - 1 SPC "capFlags:" SPC %cl.huntersTask.capFlags);
|
|
}
|
|
}
|
|
|