MMO Enemy spawning....?

Post here all your questions related with SmartFoxServer .Net/Unity3D API

Moderators: Lapo, Bax

Robbilie
Posts: 190
Joined: 04 Sep 2010, 19:48
Location: Ratingen, Germany
Contact:

MMO Enemy spawning....?

Postby Robbilie » 08 Sep 2010, 18:25

hi im developing a mmorpg and i want to know how to spawn enemys in my game....

I have spawnpoints ...

Spawnpoint1 for orc
And
Spawnpoint2 for ogre..

Or so..only example

How can i manage that? I want to manage it serverside...with an extension?

Im totally noob so pls explain it that i can understand ;D

Thanks
Robert ;)
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 09 Sep 2010, 08:53

When you spawn a "orc" object on the server, simply attach a "unit type" to the object. You can then read that on the client and determine which spawn point to use

/T
Robbilie
Posts: 190
Joined: 04 Sep 2010, 19:48
Location: Ratingen, Germany
Contact:

Postby Robbilie » 09 Sep 2010, 16:14

hello thanks but...

I = BIGGEST NOOB EVER XD

pls help :D
CameronB
Posts: 7
Joined: 11 Sep 2010, 17:47

Postby CameronB » 11 Sep 2010, 18:20

Hey,

I'm a noob (newb, n00b, nubs) too -- but I think what he's saying is, have the server push an SFSObject or something to the client, and in that object set a parameter (you could call it _mobType). Then, on your client's network controller, when it received an object check if there is an _mobType set, and if there is then instantiate a preFab for that type on a particular spawn point. You could even pass WHICH spawn point as a different parameter.

If you look at the NetworkController script in the island demo, you will see this function:

// Here we process incoming SFS objects
private void OnObjectReceived(SFSObject data, User fromUser) {
//First determine the type of this object - what it contains ?
String _cmd = data.GetString("_cmd");
switch (_cmd) {
case "t": // "t" - means transform sync data
SendTransformToRemotePlayerObject(data, fromUser);
break;
case "f": // "f" - means force our local player to send his transform
ForceSendTransform(data);
break;
case "a": // "a" - for animation message received
SendAnimationMessageToRemotePlayerObject(data, fromUser);
break;
}
}

Notice that the only thing they are doing is receiving the SFSObject (which is called data) and then checking if it has an _cmd parameter. If it does, it looks at that command. If its a "t", it sends a transform. If its an "f", it forces a transform, if it's an "a", it sends an animation.

You can look at the AnimationSynchronizer script, and you will see how they instantiate the SFSObject and put the data inside of it:

void SendAnimationMessage(int animType)
{
SmartFoxClient client = NetworkController.GetClient();
SFSObject data = new SFSObject();
data.Put("_cmd", "a"); //We put _cmd = "a" here to know that this object contains animation message
data.Put("typ", animType);
client.SendObject(data);
}


In the above example, you will see where I added another parameter called "type", and put an integer into it.

Now, I haven't instantiated an SFSObject in java on my server side extensions yet, but basically it's probably very similar. I'm sure you can find examples of how to create an SFSObject and send it in the smartfoxserver examples.

So, in summary:

1) On the server, instantiate an SFSObject, stuff a few parameters into it, like _mobType and _spawnLocation

2) On the client, read those parameters and do stuff with them, ie:
String newMobType = data.GetString("_mobType");
String spawnLocation = data.GetString("_spawnLocation");


... but I'm just a noob, so don't take my word for it. All of this is assuming you can instantiate an SFSObject in a java extension :) If you can't, well.. Then Boo.
Robbilie
Posts: 190
Joined: 04 Sep 2010, 19:48
Location: Ratingen, Germany
Contact:

Postby Robbilie » 11 Sep 2010, 18:23

thanks :) i will have a look at it but now i have the problem with the js snippet that i want in c#

search for my other threads...

thanks again :)

Return to “.Net / Unity3D API”

Who is online

Users browsing this forum: No registered users and 3 guests