Page 1 of 1

MMO Enemy spawning....?

Posted: 08 Sep 2010, 18:25
by Robbilie
hi im developing a mmorpg and i want to know how to spawn enemys in my game....

I have spawnpoints ...

Spawnpoint1 for orc
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

Robert ;)

Posted: 09 Sep 2010, 08:53
by ThomasLund
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


Posted: 09 Sep 2010, 16:14
by Robbilie
hello thanks but...


pls help :D

Posted: 11 Sep 2010, 18:20
by CameronB

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);
case "f": // "f" - means force our local player to send his transform
case "a": // "a" - for animation message received
SendAnimationMessageToRemotePlayerObject(data, fromUser);

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);

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.

Posted: 11 Sep 2010, 18:23
by Robbilie
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 :)