mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-24 00:53:47 +00:00
AI related bug fixes and improvements.
Removed references to AIObjective and aiAvoidThis which are not used. Made minor improvements to the spawning system in the aiPlayer.cs file.
This commit is contained in:
parent
9afd794913
commit
f922bc4fd0
10 changed files with 30 additions and 44 deletions
|
|
@ -126,7 +126,7 @@ function WorldEditor::onSelectionCentroidChanged( %this )
|
|||
function WorldEditor::init(%this)
|
||||
{
|
||||
// add objclasses which we do not want to collide with
|
||||
%this.ignoreObjClass(Sky, AIObjective);
|
||||
%this.ignoreObjClass(Sky);
|
||||
|
||||
// editing modes
|
||||
%this.numEditModes = 3;
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ function WorldEditor::onSelectionCentroidChanged( %this )
|
|||
function WorldEditor::init(%this)
|
||||
{
|
||||
// add objclasses which we do not want to collide with
|
||||
%this.ignoreObjClass(Sky, AIObjective);
|
||||
%this.ignoreObjClass(Sky);
|
||||
|
||||
// editing modes
|
||||
%this.numEditModes = 3;
|
||||
|
|
|
|||
|
|
@ -504,8 +504,6 @@ datablock PlayerData(DefaultPlayerData)
|
|||
|
||||
throwForce = 30;
|
||||
|
||||
aiAvoidThis = 1;
|
||||
|
||||
minLookAngle = "-1.4";
|
||||
maxLookAngle = "0.9";
|
||||
maxFreelookAngle = 3.0;
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ function DemoPlayer::onEndSequence(%this,%obj,%slot)
|
|||
// AIPlayer static functions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function AIPlayer::spawn(%name,%spawnPoint)
|
||||
function AIPlayer::create(%name,%spawnPoint)
|
||||
{
|
||||
// Create the demo player object
|
||||
%player = new AiPlayer()
|
||||
|
|
@ -107,7 +107,7 @@ function AIPlayer::spawnOnPath(%name,%path)
|
|||
if (!isObject(%path))
|
||||
return 0;
|
||||
%node = %path.getObject(0);
|
||||
%player = AIPlayer::spawn(%name, %node.getTransform());
|
||||
%player = AIPlayer::create(%name, %node.getTransform());
|
||||
return %player;
|
||||
}
|
||||
|
||||
|
|
@ -118,7 +118,6 @@ function AIPlayer::spawnOnPath(%name,%path)
|
|||
function AIPlayer::followPath(%this,%path,%node)
|
||||
{
|
||||
// Start the player following a path
|
||||
%this.stopThread(0);
|
||||
if (!isObject(%path))
|
||||
{
|
||||
%this.path = "";
|
||||
|
|
@ -160,7 +159,7 @@ function AIPlayer::moveToNode(%this,%index)
|
|||
// Move to the given path node index
|
||||
%this.currentNode = %index;
|
||||
%node = %this.path.getObject(%index);
|
||||
%this.setMoveDestination(%node.getTransform(), %index == %this.targetNode);
|
||||
%this.setMoveDestination(%node.getTransform());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -298,28 +297,26 @@ function AIPlayer::getNearestPlayerTarget(%this)
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function AIManager::think(%this)
|
||||
function AIPlayer::think(%player)
|
||||
{
|
||||
// We could hook into the player's onDestroyed state instead of having to
|
||||
// "think", but thinking allows us to consider other things...
|
||||
if (!isObject(%this.player))
|
||||
%this.player = %this.spawn();
|
||||
%this.schedule(500, think);
|
||||
// Thinking allows us to consider other things...
|
||||
%player.schedule(500, think);
|
||||
}
|
||||
|
||||
function AIManager::spawn(%this)
|
||||
function AIPlayer::spawn(%path)
|
||||
{
|
||||
%player = AIPlayer::spawnOnPath("Shootme", "MissionGroup/Paths/Path1");
|
||||
%player = AIPlayer::spawnOnPath("Shootme", %path);
|
||||
|
||||
if (isObject(%player))
|
||||
{
|
||||
%player.followPath("MissionGroup/Paths/Path1", -1);
|
||||
%player.followPath(%path, -1);
|
||||
|
||||
// slow this sucker down, I'm tired of chasing him!
|
||||
%player.setMoveSpeed(0.5);
|
||||
|
||||
//%player.mountImage(xxxImage, 0);
|
||||
//%player.setInventory(xxxAmmo, 1000);
|
||||
//%player.think();
|
||||
|
||||
return %player;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -405,10 +405,8 @@ function GameCore::startGame(%game)
|
|||
$Game::Schedule = %game.schedule($Game::Duration * 1000, "onGameDurationEnd");
|
||||
$Game::Running = true;
|
||||
|
||||
// // Start the AIManager
|
||||
// new ScriptObject(AIManager) {};
|
||||
// MissionCleanup.add(AIManager);
|
||||
// AIManager.think();
|
||||
// // Start the AI on the specified path
|
||||
// AIPlayer::spawn("Path1");
|
||||
}
|
||||
|
||||
function GameCore::endGame(%game, %client)
|
||||
|
|
@ -699,7 +697,7 @@ function GameCore::onDeath(%game, %client, %sourceObject, %sourceClient, %damage
|
|||
call( %sendMsgFunction, 'MsgClientKilled', %client, %sourceClient, %damLoc );
|
||||
|
||||
// Dole out points and check for win
|
||||
if ( %damageType $= "Suicide" || %sourceClient == %client )
|
||||
if (( %damageType $= "Suicide" || %sourceClient == %client ) && isObject(%sourceClient))
|
||||
{
|
||||
%game.incDeaths( %client, 1, true );
|
||||
%game.incScore( %client, -1, false );
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ function WorldEditor::onSelectionCentroidChanged( %this )
|
|||
function WorldEditor::init(%this)
|
||||
{
|
||||
// add objclasses which we do not want to collide with
|
||||
%this.ignoreObjClass(Sky, AIObjective);
|
||||
%this.ignoreObjClass(Sky);
|
||||
|
||||
// editing modes
|
||||
%this.numEditModes = 3;
|
||||
|
|
|
|||
|
|
@ -504,8 +504,6 @@ datablock PlayerData(DefaultPlayerData)
|
|||
|
||||
throwForce = 30;
|
||||
|
||||
aiAvoidThis = 1;
|
||||
|
||||
minLookAngle = "-1.4";
|
||||
maxLookAngle = "0.9";
|
||||
maxFreelookAngle = 3.0;
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ function DemoPlayer::onEndSequence(%this,%obj,%slot)
|
|||
// AIPlayer static functions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function AIPlayer::spawn(%name,%spawnPoint)
|
||||
function AIPlayer::create(%name,%spawnPoint)
|
||||
{
|
||||
// Create the demo player object
|
||||
%player = new AiPlayer()
|
||||
|
|
@ -107,7 +107,7 @@ function AIPlayer::spawnOnPath(%name,%path)
|
|||
if (!isObject(%path))
|
||||
return 0;
|
||||
%node = %path.getObject(0);
|
||||
%player = AIPlayer::spawn(%name, %node.getTransform());
|
||||
%player = AIPlayer::create(%name, %node.getTransform());
|
||||
return %player;
|
||||
}
|
||||
|
||||
|
|
@ -118,7 +118,6 @@ function AIPlayer::spawnOnPath(%name,%path)
|
|||
function AIPlayer::followPath(%this,%path,%node)
|
||||
{
|
||||
// Start the player following a path
|
||||
%this.stopThread(0);
|
||||
if (!isObject(%path))
|
||||
{
|
||||
%this.path = "";
|
||||
|
|
@ -160,7 +159,7 @@ function AIPlayer::moveToNode(%this,%index)
|
|||
// Move to the given path node index
|
||||
%this.currentNode = %index;
|
||||
%node = %this.path.getObject(%index);
|
||||
%this.setMoveDestination(%node.getTransform(), %index == %this.targetNode);
|
||||
%this.setMoveDestination(%node.getTransform());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -298,28 +297,26 @@ function AIPlayer::getNearestPlayerTarget(%this)
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
function AIManager::think(%this)
|
||||
function AIPlayer::think(%player)
|
||||
{
|
||||
// We could hook into the player's onDestroyed state instead of having to
|
||||
// "think", but thinking allows us to consider other things...
|
||||
if (!isObject(%this.player))
|
||||
%this.player = %this.spawn();
|
||||
%this.schedule(500, think);
|
||||
// Thinking allows us to consider other things...
|
||||
%player.schedule(500, think);
|
||||
}
|
||||
|
||||
function AIManager::spawn(%this)
|
||||
function AIPlayer::spawn(%path)
|
||||
{
|
||||
%player = AIPlayer::spawnOnPath("Shootme", "MissionGroup/Paths/Path1");
|
||||
%player = AIPlayer::spawnOnPath("Shootme", %path);
|
||||
|
||||
if (isObject(%player))
|
||||
{
|
||||
%player.followPath("MissionGroup/Paths/Path1", -1);
|
||||
%player.followPath(%path, -1);
|
||||
|
||||
// slow this sucker down, I'm tired of chasing him!
|
||||
%player.setMoveSpeed(0.5);
|
||||
|
||||
//%player.mountImage(xxxImage, 0);
|
||||
//%player.setInventory(xxxAmmo, 1000);
|
||||
//%player.think();
|
||||
|
||||
return %player;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -405,10 +405,8 @@ function GameCore::startGame(%game)
|
|||
$Game::Schedule = %game.schedule($Game::Duration * 1000, "onGameDurationEnd");
|
||||
$Game::Running = true;
|
||||
|
||||
// // Start the AIManager
|
||||
// new ScriptObject(AIManager) {};
|
||||
// MissionCleanup.add(AIManager);
|
||||
// AIManager.think();
|
||||
// // Start the AI on the specified path
|
||||
// AIPlayer::spawn("Path1");
|
||||
}
|
||||
|
||||
function GameCore::endGame(%game, %client)
|
||||
|
|
@ -699,7 +697,7 @@ function GameCore::onDeath(%game, %client, %sourceObject, %sourceClient, %damage
|
|||
call( %sendMsgFunction, 'MsgClientKilled', %client, %sourceClient, %damLoc );
|
||||
|
||||
// Dole out points and check for win
|
||||
if ( %damageType $= "Suicide" || %sourceClient == %client )
|
||||
if (( %damageType $= "Suicide" || %sourceClient == %client ) && isObject(%sourceClient))
|
||||
{
|
||||
%game.incDeaths( %client, 1, true );
|
||||
%game.incScore( %client, -1, false );
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ function WorldEditor::onSelectionCentroidChanged( %this )
|
|||
function WorldEditor::init(%this)
|
||||
{
|
||||
// add objclasses which we do not want to collide with
|
||||
%this.ignoreObjClass(Sky, AIObjective);
|
||||
%this.ignoreObjClass(Sky);
|
||||
|
||||
// editing modes
|
||||
%this.numEditModes = 3;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue