MMORPGs and computer controlled enemies

Started by
8 comments, last by rmtew 15 years, 2 months ago
Hi everyone ! I've got a basic mmorpg, but it's lacking something very important: monsters for the players to fight against. In theory how do I make computer controlled monsters in a mmorpg so that every player on the server can see them ?
Advertisement
Quote:Original post by MikeDee've got a basic mmorpg, but it's lacking something very important:

Quote:so that every player on the server can see them ?


How do you make players see other players and other in-world items?

It's done exactly the same.

One of many methods:

- NOTE: All example code is C++, and this is assuming a 2D view on the client side. Obviously if these are not correct, you can change them to your liking. The basic data will be interchangeable between methods.

Have the server keep a list of monsters and their positions, as well as any other information you need.

// Something like thisclass Monster{public:  unsigned int Area;  unsigned int X;  unsigned int Y;  unsigned int TargetX;  unsigned int TargetY;  unsigned int Health;  unsigned int TargetPlayerIndex;};std::vector<Monster> MonsterList;


Then update the list every X seconds, looking for a player in the same "Area" to target. A list of Areas, or rooms, is assumed, with each player class on the server keeping track of what area they are in as well as their X and Y, and other information. Also, you can alter the monster's TargetX and TargetY in this area to move them.

When updating every frame, alter the monster's X and Y based on the timeslice and their target position. New players coming into the rooms should be updated of the monster's current position, their target position, and their target player (if it is attacking a player, or perhaps following him as a pet?).


Basically, whenever a player sends a message to the server saying that they are entering a new area, you would loop through the list of monsters and send them data on all monsters in that room. The Target positions will allow the monsters to move without being constantly updated every step by the server. You only need to send the updated positions when a player has just entered the area.



This is difficult to explain without an example.. but that's a bit much to write just for your purposes. Theory should be good enough if you have the skill to produce an online RPG in the first place.



EDIT:
To put it more simply, just make the server control them. The server knows the position of everything else, so it should have no problem controlling some AI and updating the players with what they need to know to render the monsters.
This man made my day: http://www.gamedev.net/community/forums/topic.asp?topic_id=523021
thanks a lot !
I'll try the way you said and I'll let you know if it worked or not, but either way that was really helpful.
Quote:Original post by MikeDee
thanks a lot !
I'll try the way you said and I'll let you know if it worked or not, but either way that was really helpful.


generaly you dont want something as important as monsters to be managed on the client side
Quote:Original post by Bru
Quote:Original post by MikeDee
thanks a lot !
I'll try the way you said and I'll let you know if it worked or not, but either way that was really helpful.


generaly you dont want something as important as monsters to be managed on the client side


mmmmh... so what's the alternative ?
Handling it on the server side. When writing your client, assume that some players will be able to modify it in any way they please, send false packets imitating the ones your client sends, edit values in memory that your client uses, and a number of other nasty methods of cheating. So anything potentially abusable should be handled on the server side.
Uh oh, I dont think thats a very GOOD idea, You would wanna make those Variables private I believe.


The server does the bookkeeping for actions done by players 'avatars' and events are sent to all players within sight (all players in the 'room' if you want it simple). The monsters can be similar 'avatars' on the server, just that they get their action orders from a 'intelligence' process running on the server (or possibly a second server machine if theres a CPU capacity limitation).
--------------------------------------------[size="1"]Ratings are Opinion, not Fact
Quote:Original post by wodinoneeyeThe server does the bookkeeping for actions done by players 'avatars' and events are sent to all players within sight (all players in the 'room' if you want it simple). The monsters can be similar 'avatars' on the server, just that they get their action orders from a 'intelligence' process running on the server (or possibly a second server machine if theres a CPU capacity limitation).


Spot on cobber.

MikeDee, if this is an angle you are interested in, check out this
">Google Tech Talk presentation from Keith Fulton. He describes the Planeshift NPC architecture which is pretty well thought out, but goes for an offloading NPC management to clients.

The NPC AI in EVE Online was originally somewhat similar. Game clients were modified to allow multiple NPC controllers to log in as normal players from within them, and they would connect and use the same API as players, as well as a special API their accounts had rights to which normal player accounts were not given. These were used to specifically load test.

As the game development progressed and proper NPCs were needed, the core of the load test client logic was simply shifted into the server, to go for a client-less approach.

The fact is that as long as you keep wodinoneeye's concise summary in mind, it doesn't matter how you do them, as long as you are aware of the standard good design decisions like "don't make game decisions for anything other than the player in that player's client", as others have mentioned.

This topic is closed to new replies.

Advertisement