Game Development Community

Changing the AI Player

by D B · in Torque Game Engine · 09/10/2005 (4:55 pm) · 13 replies

I have managed to learn how to change the player character's mesh to whatever I wish it to be; however, I am still having problems with the AI mesh.

I've been looking in aiPlayer.cs, and I can't quite figure out how to change it.

I have tried changing the dataBlock from DemoPlayer to my new mesh's datablock, and have tried changing the PlayerBody in "datablock PlayerData(DemoPlayer : PlayerBody)", but I haven't been able to get the AI player to change.

What is it that I am doing wrong?

#1
09/10/2005 (6:38 pm)
Well, its quite simple, in your DemoPlayer datablock, you should be setting the shape with shapeFile = "...";
#2
09/10/2005 (7:59 pm)
Its in aiplayer.cs about line 62 ,,you will need to make a new player datablock and use it in place of the playerbody



function AIPlayer::spawn(%name,%spawnPoint){
// Create the demo player object
%player = new AiPlayer() {
dataBlock = PlayerBody;//replace playerbody with yourdatablock
path = "";
};
MissionCleanup.add(%player);
%player.setShapeName(%name);
%player.setTransform(%spawnPoint);
//%this.setAimObject($puc);
return %player;
#3
09/11/2005 (7:25 pm)
I have tried both of your ways, which really look like they should work, but for some reason, the orc keeps popping up! I even tried added an exec line, linking up my .cs file to the aiPlayer, but it didn't work.

Is there something I may be forgetting to add in?
#4
09/12/2005 (1:21 am)
Id say you must be spawning an orc from another location, put an echo in to see if function AIPlayer::spawn is being called at all.
Or
make sure you delete the aiplayer.cs.dso to make sure its compiling
What else did you change:)
#5
09/12/2005 (6:58 am)
Check for errors in Console...

Try deleting the DSO files and see if they Recompile...
If they don't you have created some Errors... Which is my guess...
#6
09/12/2005 (5:12 pm)
I deleted the .dso and tried to run the Torque Demo, but the AI Plsyer wasn't there!

Also, this error appeared in the console, which is probably the source of the problem:

Compiling starter.fps/server/scripts/aiPlayer.cs...
starter.fps/server/scripts/aiPlayer.cs Line: 26 - Syntax error.
>>> Advanced script error report. Line 51.
>>> Some error context, with ## on sides of error halt:
//-----------------------------------------------------------------------------

/*##
##
datablock PlayerData(DemoPlayer : PlayerBody)

{

shootingDelay = 2000;
>>> Error report complete.

Executing starter.fps/server/scripts/aiPlayer.cs.
starter.fps/server/scripts/aiPlayer.cs Line: 26 - Syntax error.
>>> Advanced script error report. Line 51.
>>> Some error context, with ## on sides of error halt:
//-----------------------------------------------------------------------------

/*##
##
datablock PlayerData(DemoPlayer : PlayerBody)

{

shootingDelay = 2000;
>>> Error report complete.


I'm not sure what I would do to fix this; what could I do to fix this (it's clearly a simple problem, but I'm unsure as to what to do)?
#7
09/12/2005 (5:22 pm)
Delete the /* and the corresponding */, and put // in the front of each line that you want commented out.

You cannot use blocked comments in TScript.
#8
09/12/2005 (5:41 pm)
In 1.4RC2 you can, though. New feature! :)
#9
09/13/2005 (1:56 pm)
Excellent Ben! Thats been one things about TScript thats been driving me crazy. If I have already made changes to my engine source, will I have to manually integrate the new release into my project?
#10
09/13/2005 (4:42 pm)
That was part of the problem; I got the orc to reappear and run around and such, but now the game crashes before loading up the map (or even starting to load up) whenever I try to put my model in. This line was in the console log:

Unable to find parent object ModelBody for PlayerData.

I'm not too sure what I did wrong, as the file containing ModelBody was a copy of the player.cs. What could I be forgetting here?
#11
09/13/2005 (7:22 pm)
@Peter: Your best bet is to just copy the console dir over entirely. If you're lucky things will Just Work. Otherwise you have a bit of troubleshooting ahead of you... :)

@Danny: Well, that line suggests that at the time the datablock was created, ModelBody did not exist. You can confirm this by calling ModelBody.dump(); right before you define the datablock. If it breaks, then that's the problem.
#12
09/14/2005 (4:47 pm)
I have managed to fix the problem; it was a very stupid error on my part, too (which a lot of my problems seem to consist of). >.<

In game.cs, I had my model.cs called AFTER aiPlayer.cs, so aiPlayer.cs, like Ben said, had no idea of ModelBody's existence.

Thank you for your help. :D
#13
09/17/2005 (6:08 pm)
Glad you got it taken care of!