About Store Forum Documentation Contact



Post Reply 
how can be AI be created in the server
Author Message
1991mirec Offline
Member

Post: #16
RE: how can be AI be created in the server
well i have a capsule on them and even if i wouldn t have one it is sript in there to create one. and what i meant was that it creats ai in to the world only when it starts to do the moving part. it should creat them when it do create in client it doesnt create anything. in other words if i coment out all the moving part in client ai, it doesn t create Ai at all. sorry for my language i am slovakian
this is what i have in server ai for spawning:

::Client& client(Int i) {return (::Client&)Server.clients.lockedData(i);}
//Memc<ArtificialIntelligence> ai;
void ArtificialIntelligence::createAI(Int id, Str name, Vec pos, Flt radius, Game.ObjParamsPtr &object){
Creature_ID = id; //Set creature ID
Creature_Name = name; //Set Creature Name
Object = object; //Object path, example "Obj/Chr/Skeleton/0.obj"
Position = pos; //Start position
RadiusBall.r = radius; //Radius it can move in each move command.
}

bool ArtificialIntelligence::update()
{
REPA(active_clients)
{
if(!active_clients[i].inGame())active_clients.remove(i); // need to remove clients that have exited game/went back to login screen
}
REPA(Server.clients){
if(client(i).inGame()/*state == iGame*/)if(Dist(Position,client(i).pos())>50)foundtarget(i); // go to state of processing if you should spawn a monster for this or if it's already spawned
}
/* if(!target)
{
REPA(Server.clients)
{

if(client(i).inGame())
if(Dist(Position,client(i).pos())<30)
{

attack(i);
}
}
}*/
MovementTimer -= Time.d();
ActionTimer -= Time.d();
if(MovementTimer <= 0 && target == false)sendMovement();
//if(ActionTimer <= 0)sendAction();
return true;
}
void ArtificialIntelligence::spawn(Int i){
File f;
f.writeMem().putByte(CS_AI_SPAWN);
f.putStr(Creature_Name).
cmpIntV(Creature_ID ).
cmpFlt3cm(Position.x).
cmpFlt3cm(Position.z)
<<Object.id();
f.pos(0);
//Log(S+"Server Spawn " + Creature_ID);
client(i).connection.dataFull(f,f.left());
active_clients.New() = &client(i); //Directly after spawning the monster set the client into the monsters active list.
}

bool ArtificialIntelligence::foundtarget(Int a){
Int temp = 0;
REPA(active_clients){
if(active_clients[i] ==&client(a)){return false;} //If client is in monster list directly return false so that it is not spawned again.
if(active_clients[i] !=&client(a)){temp++;}
}
if(!active_clients.elms()){ //If there are no Active clients, add the first one
spawn(a);
return true;
}
if((temp-active_clients.elms())==0){ //If the client wasn't found in the active list spawn it.
spawn(a);
return true;
}
return false;
}


and then i have this in client
case CS_AI_SPAWN:
{
//CM.New("Recieved CS_AI_SPAWN");
Str name; Game.ObjParamsPtr obj; Int id; Vec Pos;
Server.data.getStr(name).decIntV(id).decFlt3cm(Pos.x).decFlt3cm(Pos.z); obj = Server.data.getUID();
ai.New().spawn(name, obj, id, Pos); //Vec(Pos.x, 0, Pos.z));
//File f = Server.data;
//Str name = Server.data.getStr(); Str obj = Server.data.getStr(); Int id = Server.data.decIntV(); Flt x = Server.data.decFlt3cm(); Flt z = Server.data.decFlt3cm();ai.New().spawn(name,obj,id,Vec(x,0,z));
} break;

and this is in ai client
void AI::spawn(Str name, Game.ObjParamsPtr &obj, Int id, Vec pos)
{

super.create(*Game.Objs(obj.id())); //Create the object.
// Log(S+"Create successful on " + id + "\n");
//if(OldLocation!=0 && (T.pos() - OldLocation).length() > 3.0/*T.pos() != OldLocation*/)T.pos(OldLocation);
Name = name; //Add specifics read from server.
ID = id;
Flt y = Game.World.hmHeight(pos.xz(),true)+50; //Add Y so that it doesn't spawn just under the map.
T.pos(pos+Vec(0,y,0)); //Add Y so that it doesn't spawn just under the map.
// ctrl.actor.group(AG_AI);//Set actor group to 1 so that we can disable collision (pushing of monsters)
}
06-20-2013 02:46 PM
Find all posts by this user Quote this message in a reply
TheElk Offline
Member

Post: #17
RE: how can be AI be created in the server
ok we finally have the AI loading in the game but there is a problem and I am sure it is on our end in the code.

They are falling through the world.

1. we have capsules around all of the AI
2. we have them I think spawning above the Y
3. we are using the code provide here http://www.esenthel.com/community/showth...826&page=2

4. here is the spawning code we are using
Code:
///////////////////////////// AIs creation + cords ///////////////////////////////////////
void cords()
{
/****************************************added AI*******************************/
//   REP(20)ai.New().createAI(i,"Warrior","Obj/Chr/Warrior/0.obj",Vec(RandomF(0,20),RandomF(0,20),RandomF(0,20)),10);
     ai.New().createAI(1,"Humanoid Frog",      Vec(174.854, 0.076, 371.738), 20,Game.ObjParamsPtr(UID(580970731, 1326487568, 2947128993, 3190242514))); // golden bottom
     ai.New().createAI(2,"Devil Dog",          Vec(174.854, 0.076, 371.738), 20,Game.ObjParamsPtr(UID(1140589682, 1106314060, 196614794, 1110478770)));
     ai.New().createAI(3,"Turtle",             Vec(174.854, 0.076, 371.738), 20,Game.ObjParamsPtr(UID(2752342664, 1312554894, 71334039, 3460648182)));
     ai.New().createAI(4,"Plant Virus 1",      Vec(174.854, 0.076, 371.738), 20,Game.ObjParamsPtr(UID(82839537, 1119860709, 2824813964, 2054309091)));
     ai.New().createAI(5,"Plant Virus 2",      Vec(174.854, 0.076, 371.738), 20,Game.ObjParamsPtr(UID(2186206496, 1205353631, 2847269529, 552705637)));
     ai.New().createAI(6,"Plant Virus 3",      Vec(174.854, 0.076, 371.738), 20,Game.ObjParamsPtr(UID(2829953599, 1104981271, 1212022666, 4248729307)));
     ai.New().createAI(7,"Crystal Giant",      Vec(174.854, 0.076, 371.738), 20,Game.ObjParamsPtr(UID(389730099, 1322434367, 1415856292, 3927078188)));
     ai.New().createAI(8,"Hornasp",            Vec(174.854, 0.076, 371.738), 20,Game.ObjParamsPtr(UID(2419864610, 1296744610, 123809955, 3471000968)));
     ai.New().createAI(9,"Primitar",           Vec(174.854, 0.076, 371.738), 20,Game.ObjParamsPtr(UID(3122158211, 1308508637, 4131915682, 1394021604)));
    
     ai.New().createAI(10,"Humanoid Frog",     Vec(-345.525, 59.315, -707.698), 10,Game.ObjParamsPtr(UID(580970731, 1326487568, 2947128993, 3190242514)));  //golden top
     ai.New().createAI(11,"Devil Dog",         Vec(-345.525, 59.315, -707.698), 10,Game.ObjParamsPtr(UID(1140589682, 1106314060, 196614794, 1110478770)));
     ai.New().createAI(12,"Turtle",            Vec(-345.525, 59.315, -707.698), 10,Game.ObjParamsPtr(UID(2752342664, 1312554894, 71334039, 3460648182)));
     ai.New().createAI(13,"Plant Virus 1",     Vec(-345.525, 59.315, -707.698), 10,Game.ObjParamsPtr(UID(82839537, 1119860709, 2824813964, 2054309091)));
     ai.New().createAI(14,"Plant Virus 2",     Vec(-345.525, 59.315, -707.698), 10,Game.ObjParamsPtr(UID(2186206496, 1205353631, 2847269529, 552705637)));
     ai.New().createAI(15,"Plant Virus 3",     Vec(-345.525, 59.315, -707.698), 10,Game.ObjParamsPtr(UID(2829953599, 1104981271, 1212022666, 4248729307)));
     ai.New().createAI(16,"Crystal Giant",     Vec(-345.525, 59.315, -707.698), 10,Game.ObjParamsPtr(UID(389730099, 1322434367, 1415856292, 3927078188)));
     ai.New().createAI(17,"Hornasp",           Vec(-345.525, 59.315, -707.698), 10,Game.ObjParamsPtr(UID(2419864610, 1296744610, 123809955, 3471000968)));
     ai.New().createAI(18,"Primitar",          Vec(-345.525, 59.315, -707.698), 10,Game.ObjParamsPtr(UID(3122158211, 1308508637, 4131915682, 1394021604)));
    
     ai.New().createAI(19,"Humanoid Frog",     Vec(-5048.199, 26.475, -2337.284), 10,Game.ObjParamsPtr(UID(580970731, 1326487568, 2947128993, 3190242514))); // jungle
     ai.New().createAI(20,"Devil Dog",         Vec(-5048.199, 26.475, -2337.284), 10,Game.ObjParamsPtr(UID(1140589682, 1106314060, 196614794, 1110478770)));
     ai.New().createAI(21,"Turtle",            Vec(-5048.199, 26.475, -2337.284), 10,Game.ObjParamsPtr(UID(2752342664, 1312554894, 71334039, 3460648182)));
     ai.New().createAI(22,"Plant Virus 1",     Vec(-5048.199, 26.475, -2337.284), 10,Game.ObjParamsPtr(UID(82839537, 1119860709, 2824813964, 2054309091)));
     ai.New().createAI(23,"Plant Virus 2",     Vec(-5048.199, 26.475, -2337.284), 10,Game.ObjParamsPtr(UID(2186206496, 1205353631, 2847269529, 552705637)));
     ai.New().createAI(24,"Plant Virus 3",     Vec(-5048.199, 26.475, -2337.284), 10,Game.ObjParamsPtr(UID(2829953599, 1104981271, 1212022666, 4248729307)));
     ai.New().createAI(25,"Crystal Giant",     Vec(-5048.199, 26.475, -2337.284), 10,Game.ObjParamsPtr(UID(389730099, 1322434367, 1415856292, 3927078188)));
     ai.New().createAI(26,"Hornasp",           Vec(-5048.199, 26.475, -2337.284), 10,Game.ObjParamsPtr(UID(2419864610, 1296744610, 123809955, 3471000968)));
     ai.New().createAI(27,"Primitar",          Vec(-5048.199, 26.475, -2337.284), 10,Game.ObjParamsPtr(UID(3122158211, 1308508637, 4131915682, 1394021604)));
    
     ai.New().createAI(28,"Humanoid Frog",     Vec(-324.572, 0.000, -1857.457), 10,Game.ObjParamsPtr(UID(580970731, 1326487568, 2947128993, 3190242514)));  // desert
     ai.New().createAI(29,"Devil Dog",         Vec(-324.572, 0.000, -1857.457), 10,Game.ObjParamsPtr(UID(1140589682, 1106314060, 196614794, 1110478770)));
     ai.New().createAI(30,"Turtle",            Vec(-324.572, 0.000, -1857.457), 10,Game.ObjParamsPtr(UID(2752342664, 1312554894, 71334039, 3460648182)));
     ai.New().createAI(31,"Plant Virus 1",     Vec(-324.572, 0.000, -1857.457), 10,Game.ObjParamsPtr(UID(82839537, 1119860709, 2824813964, 2054309091)));
     ai.New().createAI(32,"Plant Virus 2",     Vec(-324.572, 0.000, -1857.457), 10,Game.ObjParamsPtr(UID(2186206496, 1205353631, 2847269529, 552705637)));
     ai.New().createAI(33,"Plant Virus 3",     Vec(-324.572, 0.000, -1857.457), 10,Game.ObjParamsPtr(UID(2829953599, 1104981271, 1212022666, 4248729307)));
     ai.New().createAI(34,"Crystal Giant",     Vec(-324.572, 0.000, -1857.457), 10,Game.ObjParamsPtr(UID(389730099, 1322434367, 1415856292, 3927078188)));
     ai.New().createAI(35,"Hornasp",           Vec(-324.572, 0.000, -1857.457), 10,Game.ObjParamsPtr(UID(2419864610, 1296744610, 123809955, 3471000968)));
     ai.New().createAI(36,"Primitar",          Vec(-324.572, 0.000, -1857.457), 10,Game.ObjParamsPtr(UID(3122158211, 1308508637, 4131915682, 1394021604)));
    
   /*  ai.New().createAI(4, Vec(-234.629, 74.016, -807.554), 10,Game.ObjParamsPtr(UID(82839537, 1119860709, 2824813964, 2054309091)));
     ai.New().createAI(2, Vec(-327.646, 81.795, -855.096), 10,Game.ObjParamsPtr(UID(1140589682, 1106314060, 196614794, 1110478770)));
     ai.New().createAI(3,Vec(-281.220, 59.876, -727.211), 10,Game.ObjParamsPtr(UID(2752342664, 1312554894, 71334039, 3460648182)));
     ai.New().createAI(4, Vec(-234.629, 74.016, -807.554), 10,Game.ObjParamsPtr(UID(82839537, 1119860709, 2824813964, 2054309091)));
     ai.New().createAI(5, Vec(-395.057, 56.661, -767.750), 10,Game.ObjParamsPtr(UID(2186206496, 1205353631, 2847269529, 552705637)));
     ai.New().createAI(6,Vec(-383.653, 99.263, -930.416), 10,Game.ObjParamsPtr(UID(2829953599, 1104981271, 1212022666, 4248729307)));
     ai.New().createAI(7, Vec(-593.235, 90.012, -794.407), 10,Game.ObjParamsPtr(UID(389730099, 1322434367, 1415856292, 3927078188)));
     ai.New().createAI(8,Vec(-275.205, 76.508, -891.099), 20,Game.ObjParamsPtr(UID(2419864610, 1296744610, 123809955, 3471000968)));
     ai.New().createAI(9, Vec(-290.401, 76.486, -1085.180), 20,Game.ObjParamsPtr(UID(3122158211, 1308508637, 4131915682, 1394021604))); */
/*******************************************************************************/
}

well now here is the video showing the problem we are experiencing if
anyone can lend us a hand we would appreciate it.





Thank you
TheElk
(This post was last modified: 06-24-2013 08:59 AM by TheElk.)
06-23-2013 07:29 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Ozmodian Offline
Member

Post: #18
RE: how can be AI be created in the server
Hi Elk,

I am sure we can figure this out. I am a little confused with your code though. Are you basically always spawning in all three places? is that what that code is? I am just trying to understand what I am reading.

Here is my first thought (which is probably wrong). Can you confirm that all your characters have their base at the bottom like the warrior shown below?

[Image: 309re5i.png]
06-24-2013 03:26 AM
Find all posts by this user Quote this message in a reply
TheElk Offline
Member

Post: #19
RE: how can be AI be created in the server
Hi Ozmodian

1.Yes they are all like your picture.
2. there are 4 test areas, they will be spawning all over the place once we figure this out.

Like I say in the video if I scale them all as big as the giant they all will spawn no matter what.

Thank you for replying we to hope we can figure this out and move on.

TheElk
06-24-2013 04:17 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Ozmodian Offline
Member

Post: #20
RE: how can be AI be created in the server
ok, more ideas.
1) you don't have any of the HM overlapping on these two levels you are talking about do you?

2)have you tried adding like 5 to each of the Y spawn heights and seeing if that fixes it?
06-24-2013 05:30 AM
Find all posts by this user Quote this message in a reply
TheElk Offline
Member

Post: #21
RE: how can be AI be created in the server
Hello Ozmodian

1. nope all train is made in EE

2.yes

3. we will only be spawning 1 AI per spawn point & and I have all ready try it and still the same thing.

The main thing that has me confused is if I scale all of the AI the same size as the giant they all load no matter where I have them spawn. Now that has me scratching my head.

By the way thank you for the assistants

TheElk
06-24-2013 08:40 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Ozmodian Offline
Member

Post: #22
RE: how can be AI be created in the server
Have you checked what the value of Game.World.hmHeight(pos.xz(),true) is returning each time as compared to what you think the height of the location is? is Game.World.hmHeight(pos.xz(),true) + 50 enough? Does the Smooth boolean have any affect?

Are you sure you don't have some extreme scaling on? Once you get it to where you want, you should set that to 1 like below.

[Image: 2ur2zh3.png]
06-24-2013 09:14 AM
Find all posts by this user Quote this message in a reply
TheElk Offline
Member

Post: #23
RE: how can be AI be created in the server
Hi Ozmodian

1. Flt y = Game.World.hmHeight(pos.xz(),true)+0.6f; <----Should be all we need correct
T.pos(pos+Vec(0,y,0));

2. Does the Smooth boolean have any affect? Not sure what you mean by this. ?


3. are you saying when I bring in a model that I have to hit the Rescale Height To 1 botton. so all model are scaled to 1

Thank you again for the assistants

TheElk
06-24-2013 09:37 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Pixel Perfect Offline
Member

Post: #24
RE: how can be AI be created in the server
Usually the reason for spawned models falling through the world would be because the spawn point puts the bottom of the physics body below the actual terrain.

So always spawning them 0.5m or so above the expected target height is probably a wise move to take care of any inaccuracies. I take it your capsules do align with the bottom of the models.

The smooth boolean applies some interpolation based on surrounding points giving more of an average or smoothed result for the height of the selected point. So could be slightly lower than the actual height without smoothing if the surrounding points are lower.
I think the height is normally returned from a lookup on the respective area height map and not on the smoothed mesh of the terrain itself so smoothing these values is probably closer to the in game terrain!
Not 100% sure on this though.[/i]
06-24-2013 12:46 PM
Find all posts by this user Quote this message in a reply
TheElk Offline
Member

Post: #25
RE: how can be AI be created in the server
ok I try ed something I added in the warrior and scaled him to 1 he doesn't spawn in any area's when at that scale but if I scale him up to 10 he spawns. I think there is a bug in scale size.

or Like I have said we are missing something in our code

Thank you
TheElk
06-24-2013 03:00 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Ozmodian Offline
Member

Post: #26
RE: how can be AI be created in the server
Hi Elk,

It is not an Engine bug I don't think. I have guys spawning at all heights without a problem. In my last question 1, I suggested that you capture the output of Game.World.hmHeight(). Can you do that too see what value it is returning? Also, like pixel said, it is likely because your physics body is spawning below the HM and it would be helpful to know this value when the character spawns.
06-24-2013 03:42 PM
Find all posts by this user Quote this message in a reply
TheElk Offline
Member

Post: #27
RE: how can be AI be created in the server
Hi Ozmodian

1. Can I ask you a question are all of you AI models the same scale.

2. suggested that you capture the output of Game.World.hmHeight()

will have Mir check it out.

Thank you
TheElk
(This post was last modified: 06-24-2013 04:34 PM by TheElk.)
06-24-2013 04:33 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Ozmodian Offline
Member

Post: #28
RE: how can be AI be created in the server
Hi TheElk,

Yes they currently are, i can try changing them when i get home but I would not think that would be an issue. Also, if I remember correctly, after you scale your model and press "OK" it sets that value as the scale 1 value. I always do that when scaling my models.
06-24-2013 05:06 PM
Find all posts by this user Quote this message in a reply
TheElk Offline
Member

Post: #29
RE: how can be AI be created in the server
Hello Ozmodian

well we made one of the areas -170.0 on the Y and still fall through the ground and yes we made the warrior scale 1 value and he went through but not the giant....lol

We say a BUG.....

TheElk
06-24-2013 06:36 PM
Visit this user's website Find all posts by this user Quote this message in a reply
TheElk Offline
Member

Post: #30
RE: how can be AI be created in the server
Ozmodian

did you try to scale your AI different size'es and did it work.


TheElk
06-26-2013 02:32 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply