mirror of
https://github.com/Ragora/TribesReplay.git
synced 2026-01-20 01:54:47 +00:00
- Fixed buddy filter. You can now use the Filter option on the JOIN screen to find games that have players in them that are listed on your buddy list. (Use the Email or Warrior Browser functions to add/remove people from your buddy list.) - You can now add a player to your server admin lists (so that server admins can auto-admin players when they join a server, if desired). How this is done: If you are a SuperAdmin (owner of the server), you can go into the lobby and right-click on a player's name. You will then have the ability to add them to your Admin or SuperAdmin lists. - "Vote Spamming" has been prevented in-game. - Added "quickbuy" keyboard shortcuts to use at vehicle station. (Default keys are the 1-6 number keys. 1 is Wildcat, 6 is Havoc). (NOTE: These key bindings are not currently editable. However, since you are on the vehicle purchase pad when they are in effect, they cannot interfere with any custom keys you've created, so you should have no problems.) - Moved some of the CD check from script into code, where it should be. - Missile reticle is improved aesthetically. This is part 1 of 2 of the missile reticle changes. The second part will be in the next patch. - Team Damage ON/OFF can be changed by Admins/SuperAdmins as well as being voted on by players. If you are an Admin or SuperAdmin, then just go to Lobby and look up where the "Vote" options are listed. There are options there to toggle the Team Damage flag. Regular players can also Vote to Enable/Disable Team Damage in the same spot. - Default server prefs have been changed so that the default time limit is now 30 minutes (instead of 20) and Team Damage is OFF. - The "sticking" mouse button problem is now fixed. - Deployables are now easier to place on walls and other surfaces. There were some inconsistencies on which surfaces could be placed upon and those are now resolved. - (gameplay change) Flag captures are now worth 100 points, instead of 1 point. Additionally, each time someone grabs the flag *from the enemy flag stand* they will gain 1 point, regardless of whether they actually capture it or not. You will ONLY get this single point if the flag was actually on the flagstand. You will NOT get the point by touching the flag anywhere else on the field. This change will help prevent tie situations and will reward aggressive offensive play. NOTE: The "touch" point can only be gained once every 20 seconds...so a "scrum" around the flag base will not result in a large group of points being gained. - (gameplay change) Deployable inventory stations can no longer be deployed directly next to each other. They must be at least 20 meters apart in order to be deployed properly. - (gameplay change) Many team damage fixes occurred. When Team Damage is OFF the following are now true: Friendly teammates are no longer prevented from destroying deployables. The ELF will no longer drain energy from friendly players. If a friendly player blinds another friendly player with Whiteout grenades, then a message is displayed in the Chat HUD so that the blinded person knows who did it. (There are more Team Damage changes coming in the next patch.) - (gameplay change) Medium now has a standard loadout of 12 grenades in the grenade launcher instead of 10. Light: 10; Medium: 12; Heavy: 15. - (gameplay change) Deployable pulse sensors now have a range of 150m instead of 120m to make them a more attractive option to deploy. - (gameplay change) Ejection speed increased slightly to more easily accomodate jumping out of moving vehicles. - (gameplay change) Siege: Alcatraz. The generators have been moved around a bit. There are two entrances to that base. One is the "front door" and the other is the "back door". (The back door is the one that has a team-pass-only force field blocking enemies from the switch room.) There is now an upper generator down the chute from the "front door" that powers the "back door" force field. Additionally, there is a solar panel outside that powers the base turrets and sentry turrets. None of these generators have to be destroyed to get to the switch, but their destruction makes it MUCH easier to do so. There are four generators total on this map (all are waypointed now), and the destruction of all four is necessary before the base power will go down. - (gameplay change) Siege: Caldera. The generator has been moved out of the switch room and into the very big main room that has the inventory stations in it. It is no longer necessary to destroy the generators in a particular sequence. Destroying the two main generators (Primary and Secondary) will drop the force field that protects the switch. Both gens must be down in order for the switch force field to drop.
525 lines
15 KiB
C#
525 lines
15 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.getHealth = -1;
|
|
%task.capFlags = false;
|
|
}
|
|
|
|
function AIHuntersTask::retire(%task, %client)
|
|
{
|
|
%task.pickupFlag = -1;
|
|
%task.engageTarget = -1;
|
|
%task.getHealth = -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;
|
|
|
|
//validate the health item
|
|
if (isObject(%task.getHealth))
|
|
{
|
|
if (%task.getHealth.isHidden())
|
|
%task.getHealth = -1;
|
|
else if ((%task.getHealth.getDataBlock().getName() $= "DeployedStationInventory") ||
|
|
(%task.getHealth.getDataBlock().getName() $= "StationInventory"))
|
|
{
|
|
if (%task.getHealth.isDisabled() && !%task.getHealth.isPowered())
|
|
%task.getHealth = -1;
|
|
}
|
|
}
|
|
|
|
//find the dist to the closest health
|
|
%healthDist = 32767;
|
|
%damage = %client.player.getDamagePercent();
|
|
if (%client.flagCount < 5)
|
|
%damageTolerance = 0.7;
|
|
else
|
|
%damageTolerance = 0.25 + ((%client.getSkillLevel() * %client.getSkillLevel()) * 0.35);
|
|
if (%damage > %damageTolerance)
|
|
{
|
|
if (!isObject(%task.getHealth))
|
|
{
|
|
//search for a health kit
|
|
%closestHealth = AIFindSafeItem(%client, "Health");
|
|
if (isObject(%closestHealth))
|
|
{
|
|
%healthDist = %client.getPathDistance(%closestHealth.getWorldBoxCenter());
|
|
if (%healthDist < 0)
|
|
%healthDist = 32767;
|
|
else
|
|
%healthItem = %closestHealth;
|
|
}
|
|
|
|
//else search for an inventory station
|
|
else
|
|
{
|
|
%result = AIFindClosestInventory(%client, false);
|
|
%closestInv = getWord(%result, 0);
|
|
%closestDist = getWord(%result, 1);
|
|
if (isObject(%closestInv))
|
|
{
|
|
%healthDist = %closestDist;
|
|
%healthItem = %closestInv;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
%healthDist = %client.getPathDistance(%task.getHealth.getWorldBoxCenter());
|
|
if (%healthDist < 0)
|
|
{
|
|
%healthDist = 32767;
|
|
%task.getHealth = -1;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
%task.getHealth = -1;
|
|
|
|
//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 ((AICheckEnemyDanger(%client, 35) >= 3 && %damage > %damageTolerance) ||
|
|
(!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...
|
|
else if (AIClientIsAlive(%closestEnemy) && AIEngageWhoWillWin(%closestEnemy, %client) == %closestEnemy)
|
|
{
|
|
%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... //
|
|
////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//see if we need health
|
|
if (%damage > %damageTolerance && (isObject(%healthItem) || isObject(%task.getHealth)))
|
|
{
|
|
if (!isObject(%task.getHealth))
|
|
%task.getHealth = %healthItem;
|
|
|
|
%task.setWeight($AIHuntersWeightNeedHealth);
|
|
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);
|
|
}
|
|
|
|
//see if we've should go for health...
|
|
else if (isObject(%task.getHealth))
|
|
{
|
|
%client.stepMove(%task.getHealth.getWorldBoxCenter(), 1);
|
|
|
|
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
|
|
//---------------------------------------------------------------------------
|
|
|
|
//this function checks to make sure a bot isn't in a mosh pit of enemies
|
|
//notice it cheats by not using LOS... )
|
|
function AICheckEnemyDanger(%client, %radius)
|
|
{
|
|
%numEnemies = 0;
|
|
for (%i = 0; %i < ClientGroup.getCount(); %i++)
|
|
{
|
|
%cl = ClientGroup.getObject(%i);
|
|
if (AIClientIsAlive(%cl) && %cl.team != %client.team)
|
|
{
|
|
%dist = %client.getPathDistance(%cl.player.position);
|
|
if (%dist < %radius)
|
|
{
|
|
%winner = AIEngageWhoWillWin(%cl, %client);
|
|
if (%winner == %cl)
|
|
%numEnemies += 3;
|
|
else if (%winner != %client)
|
|
%numEnemies++;
|
|
}
|
|
}
|
|
}
|
|
|
|
return %numEnemies;
|
|
}
|
|
|
|
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()
|
|
{
|
|
%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);
|
|
}
|
|
}
|
|
|