mirror of
https://github.com/Ragora/T2-DXAI.git
synced 2026-03-09 07:20:28 +00:00
Added more documentation
This commit is contained in:
parent
32fda6de67
commit
94675c5380
2 changed files with 39 additions and 14 deletions
|
|
@ -37,6 +37,7 @@ function AIConnection::update(%this)
|
|||
// Description: Called by the main system when a hostile projectile impacts near the bot.
|
||||
// This ideally is supposed to trigger some search logic instead of instantly knowing
|
||||
// where the shooter is like the original AI did.
|
||||
//
|
||||
// NOTE: This is automatically called by the main system and therefore should not be called
|
||||
// directly.
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
|
@ -88,6 +89,7 @@ function AIConnection::reset(%this)
|
|||
// plot a path and attempt to navigate there.
|
||||
// Param %position: The target location to move to. If this is simply -1, then all current
|
||||
// moves will be cancelled.
|
||||
//
|
||||
// NOTE: This should only be called by the bot's current active task. If this is called
|
||||
// outside of the AI task system, then the move order is very liable to be overwritten by
|
||||
// the current running task in it's next monitor call.
|
||||
|
|
@ -120,9 +122,13 @@ function AIConnection::setMoveTarget(%this, %position)
|
|||
// Param %maxDistance: The maximum following dinstance that the bot should enforce.
|
||||
// Param %hostile: A boolean representing whether or not the bot should perform evasion
|
||||
// while maintaining a follow distance between %minDistance and %maxDistance.
|
||||
//
|
||||
// NOTE: This should only be called by the bot's current active task. If this is called
|
||||
// outside of the AI task system, then the move order is very liable to be overwritten by
|
||||
// the current running task in it's next monitor call.
|
||||
// TODO: Implement custom follow logic to respect %minDistance, %maxDistance and %hostile.
|
||||
// Perhaps a specific combination of these values will trigger the default escort logic:
|
||||
// A min distance of 10 or less, a max distance of 20 or less and not hostile?
|
||||
//------------------------------------------------------------------------------------------
|
||||
function AIConnection::setFollowTarget(%this, %target, %minDistance, %maxDistance, %hostile)
|
||||
{
|
||||
|
|
@ -142,9 +148,6 @@ function AIConnection::setFollowTarget(%this, %target, %minDistance, %maxDistanc
|
|||
%this.followMaxDistance = %maxDistance;
|
||||
%this.followHostile = %hostile;
|
||||
|
||||
// TODO: Implement custom follow logic to respect %minDistance, %maxDistance and %hostile.
|
||||
// Perhaps a specific combination of these values will trigger the default escort logic:
|
||||
// A min distance of 10 or less, a max distance of 20 or less and not hostile?
|
||||
%this.stepEscort(%target);
|
||||
}
|
||||
|
||||
|
|
@ -153,6 +156,7 @@ function AIConnection::setFollowTarget(%this, %target, %minDistance, %maxDistanc
|
|||
// appears to be stuck somewhere. Currently, it works by tracking how far along the current
|
||||
// path a given bot is once every 5 seconds. If there appears to have been no good progress
|
||||
// between calls, then the bot is marked as stuck.
|
||||
//
|
||||
// NOTE: This is called automatically on its own scheduled tick and shouldn't be called
|
||||
// directly.
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
|
@ -183,6 +187,7 @@ function AIConnection::stuckCheck(%this)
|
|||
// Description: A function called by the ::update function of the AIConnection that is
|
||||
// called once every 32ms by the commander AI logic to update the bot's current move
|
||||
// logic.
|
||||
//
|
||||
// NOTE: This is automatically called by the commander AI and therefore should not be
|
||||
// called directly.
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
|
@ -214,6 +219,7 @@ function AIConnection::updateLegs(%this)
|
|||
// Description: A function called by the ::update function of the AIConnection that is
|
||||
// called once every 32ms by the commander AI logic to update the bot's current aiming &
|
||||
// engagement logic.
|
||||
//
|
||||
// NOTE: This is automatically called by the commander AI and therefore should not be
|
||||
// called directly.
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
|
@ -248,6 +254,7 @@ function AIConnection::updateWeapons(%this)
|
|||
// enable or disable the visual debug feature. This feature, when enabled, will draw the
|
||||
// bot's view cone using waypoints placed at the individual points of the view cone and is
|
||||
// updated once per tick of this function.
|
||||
//
|
||||
// NOTE: This is called automatically using its own scheduled ticks and therefore should
|
||||
// not be called directly.
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -19,14 +19,16 @@ function sameSide(%p1, %p2, %a, %b)
|
|||
return false;
|
||||
}
|
||||
|
||||
function SimSet::contains(%this, %contained)
|
||||
{
|
||||
for (%iteration = 0; %iteration < %this.getCount(); %iteration++)
|
||||
if (%this.getObject(%iteration) == %contained)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
// Description: Returns whether or not the given point resides inside of the triangle
|
||||
// denoted by points %a, %b and %c.
|
||||
// Param %point: The point to test.
|
||||
// Param %a: One point of the triangle.
|
||||
// Param %b: One point of the triangle.
|
||||
// Param %c: One point of the triangle.
|
||||
// Return: A boolean representing whether or not the given point resides inside of the
|
||||
// triangle.
|
||||
//------------------------------------------------------------------------------------------
|
||||
function pointInTriangle(%point, %a, %b, %c)
|
||||
{
|
||||
if (sameSide(%point, %a, %b, %c) && sameSide(%point, %b, %a, %c) && sameSide(%point, %c, %a, %b))
|
||||
|
|
@ -35,13 +37,25 @@ function pointInTriangle(%point, %a, %b, %c)
|
|||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
// Description: Calculates all the points of the given client's view cone given a maximum
|
||||
// view distance and returns them in a long string.
|
||||
// Param %distance: The distance of their view cone.
|
||||
// Return: A string in the following format:
|
||||
// "OriginX OriginY OriginZ Outer1X Outer1Y Outer1Z Outer2X Outer2Y Outer2Z UpperX UpperY UpperZ
|
||||
// LowerX LowerY LowerZ"
|
||||
//
|
||||
// TODO: Return in a faster-to-read format: Could try as static GVar names
|
||||
// as the game's scripting environment for the gameplay is single threaded
|
||||
// and it probably does a hash to store the values.
|
||||
// TODO: Mathematical optimizations, right now it's a hack because of no
|
||||
// FIXME: Mathematical optimizations, right now it's a hack because of no
|
||||
// reliable way of getting a player's X facing?
|
||||
//------------------------------------------------------------------------------------------
|
||||
function GameConnection::calculateViewCone(%this, %distance)
|
||||
{
|
||||
if (!isObject(%this.player) || %this.player.getState() !$= "Move")
|
||||
return -1;
|
||||
|
||||
//%xFacing = %this.player.getXFacing();
|
||||
%halfView = %this.fieldOfView / 2;
|
||||
%coneOrigin = %this.player.getMuzzlePoint($WeaponSlot);
|
||||
|
|
@ -93,8 +107,8 @@ function GameConnection::calculateViewCone(%this, %distance)
|
|||
//------------------------------------------------------------------------------------------
|
||||
// Description: Returns a SimSet of all contained object ID's inside of the given SimSet,
|
||||
// including those in child SimGroup and SimSet instances.
|
||||
// TODO: Use the nav graph to estimate an actual distance?
|
||||
// FIXME: Return *working* stations only.
|
||||
// Return: The ID of the SimSet that contains all child objects that are not containers
|
||||
// themselves.
|
||||
//------------------------------------------------------------------------------------------
|
||||
function SimSet::recurse(%this, %result)
|
||||
{
|
||||
|
|
@ -118,6 +132,7 @@ function SimSet::recurse(%this, %result)
|
|||
// Description: Returns the closest friendly inventory station to the given client.
|
||||
// Return: The object ID of the inventory station determined to be the closest to this
|
||||
// client.
|
||||
//
|
||||
// TODO: Use the nav graph to estimate an actual distance?
|
||||
// FIXME: Return *working* stations only.
|
||||
//------------------------------------------------------------------------------------------
|
||||
|
|
@ -224,6 +239,9 @@ function GameConnection::getObjectsInViewcone(%this, %typeMask, %distance, %perf
|
|||
return %result;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------
|
||||
// Description: Gets a random position somewhere within %distance of the given position.
|
||||
//------------------------------------------------------------------------------------------
|
||||
function getRandomPosition(%position, %distance, %raycast)
|
||||
{
|
||||
// First, we determine a random direction vector
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue