Sign in to follow this  
Artur Litau

How do MMORPG Developers create the monster system?

Recommended Posts

Currently Im working on the monster system (hide/unhide/spawn/respawn) etc and I would like to know how the pro do this?

 

Currently I have so much code that I dont even know what I did nor do I have an overview anymore. And of course it is not working correctly.

 

Now I was wondering how the pro do this?

 

A game with 5000+ monsters per map.. A player log in but of course he should only load the monsters which are in a certain radius.

While running the server will check if near the characters are monsters -> true = unhide and false = do nothing.

And a second check for if monsters are too far -> true = unhide and false = do nothing.

 

Of course there is 1 big list with all the monster data and 1 list per player which contain the data which monsters are shown and which not.

 

But now what about the monsters which are dead? A third timer for them ? If the death time from a monster finished then he will respawn and everyone in the monster radius will get an input into his list that the monster is there?

 

 

If anyone could tell me "step-by-step" how the monster system should work? Like

- Player log in and only unhide the monster in his area.

-Timer to check players current position and unhide monsters if there are some in his area..

 

 

The more I work on this the more my brain starts to think different and I make everything more complex than it actually is...

Share this post


Link to post
Share on other sites

Actually I already have client-side everything ready and I got the source from the client. Currently Im just building the server-side for this. I got all packets and everything I need. 

I only need to write the functions like spawn monsters/items/damage etc

Share this post


Link to post
Share on other sites

In Java I create a 2D arraylist as the map, and than only render what is around the player

 I do not know how complex your game is, but here is some code that shows how I did the rendering offsets.

The rendering is done else were in another class - this method just builds what will be later rendered.

( Warning: Not The Best Written Code In The World )

public void outputMap(Player p){ // Build 'player areaa' to be rendered elsewhere
		
		String [] temp = new String[2];
		output = "|";
		int poX1 = p.getPlayerX() - offsetX; // Define rendering area around player
		int poY1 = p.getPlayerY() - offsetY;
		int poX2 = p.getPlayerX() + offsetX;
		int poY2 = p.getPlayerY() + offsetY;
		objects = new ArrayList<String>(); // Create dumps
		xlist = new ArrayList<Integer>();
		ylist = new ArrayList<Integer>();
		clist = new ArrayList<Color>();
		if (poX1 < 0){poX1 = 0;} // If player is near an edge ... 
		if (poY1 < 0){poY1 = 0;}
		if (poX2 > mapX){poX2 = mapX;}
		if (poY2 > mapY){poY2 = mapY;}
		
		for (cordX = poX1 ; cordX < poX2; cordX ++){     // Build arraylist that will be rendered later
			for (cordY = poY1; cordY < poY2 ; cordY ++){
				if (p.getPlayerX() == cordX && p.getPlayerY() == cordY ){
					objects.add(p.getPlayerSprite() ) ;
					xlist.add( ((cordX - p.getPlayerX() ) + offsetX ) * tile_size  ); // Offsets
					ylist.add( ((cordY - p.getPlayerY() ) + offsetY ) * tile_size );
					clist.add(Color.BLACK );
					
				}
			
				else{
					if (iomap[cordX][cordY] != null){ //iomap is one of the main map files for objects
						temp = iomap[cordX][cordY].getStates(); // Find out all the states the item has
						objects.add(temp[iomap[cordX][cordY].getCurrentState()]) ; // Dump the map object states
						xlist.add( ((cordX - p.getPlayerX() ) + offsetX ) * tile_size  ); // Offsets
						ylist.add( ((cordY - p.getPlayerY() ) + offsetY ) * tile_size );
						clist.add(iomap[cordX][cordY].getColor() ); // Mic info add
						
					}
				}
			}
		}
		scr.run(); // Start 2D rendering process 
 }
Edited by Shippou

Share this post


Link to post
Share on other sites


Dead monsters don't exist. There's no reason to spend any time processing dead monsters, to keep them in lists, or otherwise do stuff with them. It's dead. Passed on. No more. Ceased to be. It is an ex-monster.

 

It could be semantics, but a dead monster should still be accounted for a certain time, to loot it's body, and to show it dead on the ground.  After a certain time, it will be removed, and it's death would have triggered another monster's spawn timer.

 

So, what you're calling an "ex-monster" could, in some frameworks, still be a monster, just in the dead state.  While I might make a new "deadmonster" entity, that might not be everyone's solution.

Share this post


Link to post
Share on other sites

Actually I already have client-side everything ready and I got the source from the client. Currently Im just building the server-side for this. I got all packets and everything I need. 

I only need to write the functions like spawn monsters/items/damage etc

 

That seems quite backwards to me.  For a multiplayer game, the server should be the core of the system.  It's the brains and heart.  It does all the heavy lifting.  The client really should be little more than a window into what's happening on the server.  So... how exactly do you install windows into a house that hasn't been built yet?

Share this post


Link to post
Share on other sites

 


Dead monsters don't exist. There's no reason to spend any time processing dead monsters, to keep them in lists, or otherwise do stuff with them. It's dead. Passed on. No more. Ceased to be. It is an ex-monster.

 

It could be semantics, but a dead monster should still be accounted for a certain time, to loot it's body, and to show it dead on the ground.  After a certain time, it will be removed, and it's death would have triggered another monster's spawn timer.

 

So, what you're calling an "ex-monster" could, in some frameworks, still be a monster, just in the dead state.  While I might make a new "deadmonster" entity, that might not be everyone's solution.

 

 

I would argue that this is non-ideal design. There's so many differences between a living monster and a monster corpse that they really should be separate objects. Especially in a component-based engine. There's data and run-time state a living monster needs that a dead one doesn't (like AI) and likewise state and data a corpse needs that a living module doesn't. The physics states are different, graphics may be different depending on the graphics style, and the events the object must listen to are different. Some designs call for extremely radically different setups, too, like per-player loot in some games.

 

Ultimately, while a single monster object with two states works, and I do recommend going for the simplest design that works, I've never found having one object with two radically different states to be all that simple.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this