Game Development Community

Copying Kork

by Mat Durrant · in Torque Game Engine Advanced · 08/07/2008 (5:11 am) · 6 replies

Hi

I've been trying to copy Kork from the stronghold demo into my own project with little success. I've been trying to use http://tdn.garagegames.com/wiki/TGEA/CompleteBeginnerBlog as an example but what it suggests doesn't work.

This is what I've done so far....

I copied the file aiPlayer.cs across from the stronghold directory.

I added the line exec("aiPlayer.cs"); to Game.cs under onServerCreated().

I added the following lines to startGame():

// Start the AIManager
new ScriptObject(AIManager) {};
MissionCleanup.add(AIManager);
AIManager.think();

I copied the file player from stronghold and place in the same location in my new project.

In the editor I created a new sim group called paths

created a new path called path1

and then created path markers exactly how it is all set up in the stronghold example.

Now if I try to run the mission, it crashes and doesn't work, the only way the mission will run with aiPlayer.cs script present is to comment out the line shootingDelay = 2000; as demonstrated below:

datablock PlayerData(DemoPlayer : PlayerBody)
{
//shootingDelay = 2000;
};

This will allow the mission to load but results in no kork running round. I'm now lost and have tried everything I can think of. Can anyone help please?

#1
08/07/2008 (5:38 am)
Do you have crossbow.cs in your server folder? Kork uses the crossbow, so if you don't have the crossbow script, and it's assets, he will crash torque. If you look at your console.log, it will most likely tell you this same thing. :-)
#2
08/07/2008 (6:44 am)
I did copy the crossbow across but it still didn't work, I don't think it is that. I tried looking at the console log like you said. If I run the program with the line commented out like about I get the following error in the console log...

>>> Some error context, with ## on sides of error halt:
//-----------------------------------------------------------------------------

// Demo Pathed AIPlayer.

//-----------------------------------------------------------------------------



datablock PlayerData(DemoPlayer : PlayerBody)

{

// shootingDelay = 2000;

};

##
##
function DemoPlayer::onReachDestination(%this,%obj)

{

// Moves to the next node on the path.

// Override for all player. Normally we'd override this for only

// a specific player datablock or class of players.

if (%obj.path !$= "") {

if (%obj.currentNode == %obj.targetNode)
>>> Error report complete.

If I uncomment that line the program crashes as soon as I try and load the mission and doesn't give anything in the console log, it just cuts off :-s
#3
08/07/2008 (12:04 pm)
I've now established that this crash occurs when I try to create any data block, I'm not sure whether it's a bug in the engine, the only thread I could find mentioning the same problem was written in 2003 and the problem with the engine was resolved. So now I'm lost :-s
#4
08/07/2008 (4:15 pm)
Does your function look like this??

function DemoPlayer::onReachDestination(%this,%obj)
{
   // Moves to the next node on the path.
   // Override for all player. Normally we'd override this for only
   // a specific player datablock or class of players.
   if (%obj.path !$= "") {
      if (%obj.currentNode == %obj.targetNode)
         %this.onEndOfPath(%obj,%obj.path);
      else
         %obj.moveToNextNode();
   }
}
That error is really cryptic. There should be more to the error message.
#5
08/08/2008 (1:30 am)
The code comes directly from the stronghold example, I actually copied the text file across. The error is actually with the data block not the function below it. Because I've tried deleting all of the code so that it is just a blank file, which runs fine, then I tried just creating a simple datablock and that is when it crashes?!
#6
08/08/2008 (3:31 am)
I've resolved the problem, it was just my own misunderstanding of how to use a datablock.

For anyone following this post or wanting to know how to copy kork from the stronghold example to a new project created via the new project generator, this is how I managed it.

copy the file aiPlayer.cs from the stronghold directoy ....server/scripts/ to the file ....server/scripts/players/ of your new project.

Open the file and under the section near the top where it says:

datablock PlayerData(DemoPlayer : PlayerBody)

delete the word PlayerBody and replace with DefaultPlayerData so that it looks like this....

datablock PlayerData(DemoPlayer : DefaultPlayerData)

this is because the player.cs in stronghold is different to the one created by the project generator.

next open game.cs and add the following lines:

exec("./players/aiPlayer.cs"); - just under where player.cs is executed

// Start the AIManager - at the bottom of the function startGame()
new ScriptObject(AIManager) {};
MissionCleanup.add(AIManager);
AIManager.think();

All that need to be done now is open up the mission editor and create a new simgroup called paths, add a new path to that simgroup called path1 and add the appropriate markers.

this should result in a little ork running around when you load the mission.