mirror of
https://github.com/Ragora/T2-DXAI.git
synced 2026-07-16 00:24:38 +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.
|
// 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
|
// This ideally is supposed to trigger some search logic instead of instantly knowing
|
||||||
// where the shooter is like the original AI did.
|
// where the shooter is like the original AI did.
|
||||||
|
//
|
||||||
// NOTE: This is automatically called by the main system and therefore should not be called
|
// NOTE: This is automatically called by the main system and therefore should not be called
|
||||||
// directly.
|
// directly.
|
||||||
//------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------
|
||||||
|
|
@ -88,6 +89,7 @@ function AIConnection::reset(%this)
|
||||||
// plot a path and attempt to navigate there.
|
// plot a path and attempt to navigate there.
|
||||||
// Param %position: The target location to move to. If this is simply -1, then all current
|
// Param %position: The target location to move to. If this is simply -1, then all current
|
||||||
// moves will be cancelled.
|
// moves will be cancelled.
|
||||||
|
//
|
||||||
// NOTE: This should only be called by the bot's current active task. If this is called
|
// 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
|
// 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.
|
// 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 %maxDistance: The maximum following dinstance that the bot should enforce.
|
||||||
// Param %hostile: A boolean representing whether or not the bot should perform evasion
|
// Param %hostile: A boolean representing whether or not the bot should perform evasion
|
||||||
// while maintaining a follow distance between %minDistance and %maxDistance.
|
// 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
|
// 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
|
// 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.
|
// 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)
|
function AIConnection::setFollowTarget(%this, %target, %minDistance, %maxDistance, %hostile)
|
||||||
{
|
{
|
||||||
|
|
@ -142,9 +148,6 @@ function AIConnection::setFollowTarget(%this, %target, %minDistance, %maxDistanc
|
||||||
%this.followMaxDistance = %maxDistance;
|
%this.followMaxDistance = %maxDistance;
|
||||||
%this.followHostile = %hostile;
|
%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);
|
%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
|
// 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
|
// 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.
|
// between calls, then the bot is marked as stuck.
|
||||||
|
//
|
||||||
// NOTE: This is called automatically on its own scheduled tick and shouldn't be called
|
// NOTE: This is called automatically on its own scheduled tick and shouldn't be called
|
||||||
// directly.
|
// directly.
|
||||||
//------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------
|
||||||
|
|
@ -183,6 +187,7 @@ function AIConnection::stuckCheck(%this)
|
||||||
// Description: A function called by the ::update function of the AIConnection that is
|
// 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
|
// called once every 32ms by the commander AI logic to update the bot's current move
|
||||||
// logic.
|
// logic.
|
||||||
|
//
|
||||||
// NOTE: This is automatically called by the commander AI and therefore should not be
|
// NOTE: This is automatically called by the commander AI and therefore should not be
|
||||||
// called directly.
|
// called directly.
|
||||||
//------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------
|
||||||
|
|
@ -214,6 +219,7 @@ function AIConnection::updateLegs(%this)
|
||||||
// Description: A function called by the ::update function of the AIConnection that is
|
// 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 &
|
// called once every 32ms by the commander AI logic to update the bot's current aiming &
|
||||||
// engagement logic.
|
// engagement logic.
|
||||||
|
//
|
||||||
// NOTE: This is automatically called by the commander AI and therefore should not be
|
// NOTE: This is automatically called by the commander AI and therefore should not be
|
||||||
// called directly.
|
// called directly.
|
||||||
//------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------
|
||||||
|
|
@ -248,6 +254,7 @@ function AIConnection::updateWeapons(%this)
|
||||||
// enable or disable the visual debug feature. This feature, when enabled, will draw the
|
// 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
|
// bot's view cone using waypoints placed at the individual points of the view cone and is
|
||||||
// updated once per tick of this function.
|
// updated once per tick of this function.
|
||||||
|
//
|
||||||
// NOTE: This is called automatically using its own scheduled ticks and therefore should
|
// NOTE: This is called automatically using its own scheduled ticks and therefore should
|
||||||
// not be called directly.
|
// not be called directly.
|
||||||
//------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -19,14 +19,16 @@ function sameSide(%p1, %p2, %a, %b)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function SimSet::contains(%this, %contained)
|
//------------------------------------------------------------------------------------------
|
||||||
{
|
// Description: Returns whether or not the given point resides inside of the triangle
|
||||||
for (%iteration = 0; %iteration < %this.getCount(); %iteration++)
|
// denoted by points %a, %b and %c.
|
||||||
if (%this.getObject(%iteration) == %contained)
|
// Param %point: The point to test.
|
||||||
return true;
|
// Param %a: One point of the triangle.
|
||||||
return false;
|
// 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)
|
function pointInTriangle(%point, %a, %b, %c)
|
||||||
{
|
{
|
||||||
if (sameSide(%point, %a, %b, %c) && sameSide(%point, %b, %a, %c) && sameSide(%point, %c, %a, %b))
|
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;
|
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
|
// 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
|
// as the game's scripting environment for the gameplay is single threaded
|
||||||
// and it probably does a hash to store the values.
|
// 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?
|
// reliable way of getting a player's X facing?
|
||||||
|
//------------------------------------------------------------------------------------------
|
||||||
function GameConnection::calculateViewCone(%this, %distance)
|
function GameConnection::calculateViewCone(%this, %distance)
|
||||||
{
|
{
|
||||||
|
if (!isObject(%this.player) || %this.player.getState() !$= "Move")
|
||||||
|
return -1;
|
||||||
|
|
||||||
//%xFacing = %this.player.getXFacing();
|
//%xFacing = %this.player.getXFacing();
|
||||||
%halfView = %this.fieldOfView / 2;
|
%halfView = %this.fieldOfView / 2;
|
||||||
%coneOrigin = %this.player.getMuzzlePoint($WeaponSlot);
|
%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,
|
// Description: Returns a SimSet of all contained object ID's inside of the given SimSet,
|
||||||
// including those in child SimGroup and SimSet instances.
|
// including those in child SimGroup and SimSet instances.
|
||||||
// TODO: Use the nav graph to estimate an actual distance?
|
// Return: The ID of the SimSet that contains all child objects that are not containers
|
||||||
// FIXME: Return *working* stations only.
|
// themselves.
|
||||||
//------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------
|
||||||
function SimSet::recurse(%this, %result)
|
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.
|
// 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
|
// Return: The object ID of the inventory station determined to be the closest to this
|
||||||
// client.
|
// client.
|
||||||
|
//
|
||||||
// TODO: Use the nav graph to estimate an actual distance?
|
// TODO: Use the nav graph to estimate an actual distance?
|
||||||
// FIXME: Return *working* stations only.
|
// FIXME: Return *working* stations only.
|
||||||
//------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------
|
||||||
|
|
@ -224,6 +239,9 @@ function GameConnection::getObjectsInViewcone(%this, %typeMask, %distance, %perf
|
||||||
return %result;
|
return %result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------------------
|
||||||
|
// Description: Gets a random position somewhere within %distance of the given position.
|
||||||
|
//------------------------------------------------------------------------------------------
|
||||||
function getRandomPosition(%position, %distance, %raycast)
|
function getRandomPosition(%position, %distance, %raycast)
|
||||||
{
|
{
|
||||||
// First, we determine a random direction vector
|
// First, we determine a random direction vector
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue