|
@@ -87,7 +87,7 @@ function DemoPlayer::onEndSequence(%this,%obj,%slot)
|
|
// AIPlayer static functions
|
|
// AIPlayer static functions
|
|
//-----------------------------------------------------------------------------
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
-function AIPlayer::spawn(%name,%spawnPoint)
|
|
|
|
|
|
+function AIPlayer::produce(%name,%spawnPoint)
|
|
{
|
|
{
|
|
// Create the demo player object
|
|
// Create the demo player object
|
|
%player = new AiPlayer()
|
|
%player = new AiPlayer()
|
|
@@ -107,7 +107,7 @@ function AIPlayer::spawnOnPath(%name,%path)
|
|
if (!isObject(%path))
|
|
if (!isObject(%path))
|
|
return 0;
|
|
return 0;
|
|
%node = %path.getObject(0);
|
|
%node = %path.getObject(0);
|
|
- %player = AIPlayer::spawn(%name, %node.getTransform());
|
|
|
|
|
|
+ %player = AIPlayer::produce(%name, %node.getTransform());
|
|
return %player;
|
|
return %player;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -118,7 +118,6 @@ function AIPlayer::spawnOnPath(%name,%path)
|
|
function AIPlayer::followPath(%this,%path,%node)
|
|
function AIPlayer::followPath(%this,%path,%node)
|
|
{
|
|
{
|
|
// Start the player following a path
|
|
// Start the player following a path
|
|
- %this.stopThread(0);
|
|
|
|
if (!isObject(%path))
|
|
if (!isObject(%path))
|
|
{
|
|
{
|
|
%this.path = "";
|
|
%this.path = "";
|
|
@@ -160,7 +159,7 @@ function AIPlayer::moveToNode(%this,%index)
|
|
// Move to the given path node index
|
|
// Move to the given path node index
|
|
%this.currentNode = %index;
|
|
%this.currentNode = %index;
|
|
%node = %this.path.getObject(%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))
|
|
if (isObject(%player))
|
|
{
|
|
{
|
|
- %player.followPath("MissionGroup/Paths/Path1", -1);
|
|
|
|
|
|
+ %player.followPath(%path, -1);
|
|
|
|
|
|
// slow this sucker down, I'm tired of chasing him!
|
|
// slow this sucker down, I'm tired of chasing him!
|
|
%player.setMoveSpeed(0.5);
|
|
%player.setMoveSpeed(0.5);
|
|
|
|
|
|
//%player.mountImage(xxxImage, 0);
|
|
//%player.mountImage(xxxImage, 0);
|
|
//%player.setInventory(xxxAmmo, 1000);
|
|
//%player.setInventory(xxxAmmo, 1000);
|
|
|
|
+ //%player.think();
|
|
|
|
|
|
return %player;
|
|
return %player;
|
|
}
|
|
}
|