Adding Computer Enemies for Single Player Mission.
by Rutger Van Dijk · in RTS Starter Kit · 08/08/2005 (6:20 am) · 27 replies
Hi,
another question. where and how should i add computer controlled enemies for a single player mission? i tried to search the forums; but couldn't find any clear help. should be out there somewhere right? =)
cheers,
Rutger
another question. where and how should i add computer controlled enemies for a single player mission? i tried to search the forums; but couldn't find any clear help. should be out there somewhere right? =)
cheers,
Rutger
#23
at least I spawn AI units on my maps and they even attack me....HAHA
I will post it here if anyone asks me...(really to remind me)
www.enchantedrealmsllc.com
05/12/2007 (12:41 am)
Hit me up if your looking for this...I know I found a post on a computer controlled AI and DO have it working in my VKIT Code...at least I spawn AI units on my maps and they even attack me....HAHA
I will post it here if anyone asks me...(really to remind me)
www.enchantedrealmsllc.com
#24
THank you
05/12/2007 (6:11 am)
I would be very interested in whatever you may have. I looked at your webiste and could not order you VKIT kit. If you could post whatever resources you may have, I am sure everyone will profit.THank you
#25
class AIRTSConnection : public RTSConnection
{
typedef RTSConnection Parent;
};
RTSConnection.cc
ConsoleFunction( addAI, S32 , 2, 3, "addAI( 'playerName'[, 'AIClassType'] );" )
{
// Create the player
AIRTSConnection *aiPlayer = new AIRTSConnection();
aiPlayer->registerObject();
aiPlayer->setGhostFrom(false);
aiPlayer->setGhostTo(false);
aiPlayer->setSendingEvents(false);
aiPlayer->setTranslatesStrings(true);
aiPlayer->setEstablished();
// Add the client to the AI group
SimGroup *g = Sim::getClientGroup();
g->addObject( aiPlayer );
return aiPlayer->getId();
}
In Script
$AI=addAI("bob");
$AI.onCliententergame();
Works liike a charm :-)
05/12/2007 (10:38 am)
RTSConnection.hclass AIRTSConnection : public RTSConnection
{
typedef RTSConnection Parent;
};
RTSConnection.cc
ConsoleFunction( addAI, S32 , 2, 3, "addAI( 'playerName'[, 'AIClassType'] );" )
{
// Create the player
AIRTSConnection *aiPlayer = new AIRTSConnection();
aiPlayer->registerObject();
aiPlayer->setGhostFrom(false);
aiPlayer->setGhostTo(false);
aiPlayer->setSendingEvents(false);
aiPlayer->setTranslatesStrings(true);
aiPlayer->setEstablished();
// Add the client to the AI group
SimGroup *g = Sim::getClientGroup();
g->addObject( aiPlayer );
return aiPlayer->getId();
}
In Script
$AI=addAI("bob");
$AI.onCliententergame();
Works liike a charm :-)
#26
I will see what else I can post..otherwise the VKit (Beta) will be up soon...
05/12/2007 (11:42 am)
Yep that looks like the code :)I will see what else I can post..otherwise the VKit (Beta) will be up soon...
#27
I used scripting to control the the spawned enemy RTS units and no new AIRTSConnection required at all.
Kevin
07/21/2007 (2:24 pm)
Well, an easy way which I did was to use the same code to spawn the existing player units. I did this a long time a ago, donno if I still remember it right. I set it to different player player groups in the dataBlock so the engine thinks it belongs to another player and the "Single player" can't control it. I used scripting to control the the spawned enemy RTS units and no new AIRTSConnection required at all.
Kevin
Torque Owner Benjamin Buco
Then when you add the AIplayer you can access all units and buildings from the two sets. :-)