Game Development Community

AIPlayers that for the most part do no exist?

by Cinder Games · in Torque Game Engine · 04/14/2006 (6:12 pm) · 6 replies

I'd like some way to basically shutdown an AIplayer so that they are not rendered, not animated, not affected by gravity, no collision, etc. A function like sethidden would be exactly what i would want.. however that's not something torque likes you to do :p

Basically i want to not to exist. Is it simply easier to write a method to save current stats on that AIP and delete it, and respawn it when needed again, or perhaps someone has a another idea?

#1
04/16/2006 (3:31 pm)
*bump* any clues? I'm sure someone had to have needed something simliar.
#2
04/16/2006 (3:42 pm)
If I understand you correctly you want a spawned AIPlayer to no longer be processed while out of view for performance reasons? I would suggest creating a new class to store your in-game characters, and when one appears in the field of view, use Torquescript to generate a new AIPlayer and fill the relavent details in AIplayer from the values stored in your new class. This way, a non-rendering, non-thinking class remembers the details of the characters without hitting the cpu until the character is visible.
#3
04/16/2006 (3:50 pm)
I guess i'll just delete them and respawn as needed :) i can't delve into C++ very well.
#4
04/16/2006 (4:50 pm)
I don't know the answer,
but you might try letting the thread simmer for a couple more days before doing a lot of development;
there may be something easier than storing/deleting/restoring the bots..
#5
04/16/2006 (5:04 pm)
You wouldn't need to do the class in C++ - just do it in TorqueScript like...(pseudocode only - may not compile)

in an new file called "myPlayerClass.cs"

function PlayerClass(%obj)
{
        posx = 0;
        posy = 0;
        posz = 0;
        datablock myAIPlayerPointer = %obj; // store incoming AIPlayer pointer if required.
        intel = 100;
        skill = 15;  // etc...
}

then in game.cs

exec("./myPlayerClass.cs");

then when you want to create a new one in memory...

PlayerClass myNewPlayer(currAIPlayer);  // currAIPlayer can be nothing.

Let it move around and pass the pos to myNewPlayer as required...

// pass data to player 
// assume currAIPlayer is of type AIPlayer 
myNewPlayer.posx = currAIPlayer.getPositionx();
myNewPlayer.posz = currAIPlayer.getPositiony();

etc...

and when it's out of range...
// kill off AIPlayer
delete myNewPlayer.getAIPlayer(); // returns pointer to instance of AIPlayer

that sort of thing. If you want a working example I can code something up for you.
#6
04/16/2006 (5:06 pm)
Nah, i don't need the script. that's pretty much how i was going to go. i was just hoping there was a simple console command to just hide them like other objects.