Jump to content
  • Advertisement
Sign in to follow this  
Kenster

MMORPG Movement

This topic is 3658 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, Has anyone here spent time programming the movement or have a suggestion on how movement of NPCs in an MMORPG should go about. What I mean, is, we want an NPC to move to a player, and attack smoothly, but the NPC must be in range. Currently, I have it do every .1 second, the NPC calculates where the Player is, sets the destination with a formula, then moves to that location. But the problem is, you can see the NPC stop/start at that .1 second. Plus if the Player moves the NPC goes to that location, only to say move again. Is there a smooth way to do it? Does anyone have a suggestion on maybe how to get a good value of the location to attack within X Range? Thanks. (A web site with a how-to, or some information is good enough, im not looking for a hang out, just a suggestion on some information).

Share this post


Link to post
Share on other sites
Advertisement
Try checking the decision only once. Once the NPC decides to attack, have him continue to do so until he is WAY out of range.

Share this post


Link to post
Share on other sites
You would want to use an interception algorithm. Base it off the players movement, you have a velocity vector. Using that vector, the distance between the player and the NPC, and the known speed of the NPC you can determine the intersection point where the NPC should run to.

What if the player changes their path?
You should make the check every now and then to see if the vectors have changed, if so, all you need to change is the facing for the NPC, maintain the animation for running, maintain the speed, and change the direction only. Since there should only be minor changes at a distance, the change in facing will be negligible, up close it may be more drastic and may affect the animation since you're running the changes at 10fps. once you're finally in range, start attacking :)

This website may be complex, i haven't really read it over, but simple velocity vectors are your solution.
http://www.realtimerendering.com/int/



[Edited by - nightech on June 12, 2008 5:15:42 PM]

Share this post


Link to post
Share on other sites
An alternative approach, which saves computation of a distance (which can be expensive) is to use spatial partitioning and a lookup. When a player moves into a node of the partitioned space it notifies the node that it is there (or the external movement system does this). NPCs query their nodes and ask if there is anything nearby (within a given threshold distance). The nodes know of their neighbouring nodes via the partition scheme and can simply query surrounding nodes as to their occupancy status. A node responding with an occupied result can then be used as a movement target for the NPC. When both the NPC and player are within the same node the NPC can switch to a smooth tracking method to move to the player character.

Cheers,

Timkin

Share this post


Link to post
Share on other sites
I tried even calling my teacher, but I don't think I can come up with this formula. I have read your site supplied, but WOW. Complex. I don't know if what I am asking is complex, but anyone else have some ideas or maybe a sample of code I can look over.

Share this post


Link to post
Share on other sites
Didn't notice one of your later problems about the NPC moving to an old location. Why would you save the location of where the player is at that time and continue to use it? The location didn't piss off the NPC, the player did. Therefore, you need a way of continually tracking the player's location. One obvious method of doing this would be for each NPC, once annoyed, to continually check the location of the player and use that as the target.

Another method, in case there are more than one player or allied NPC that could be targets, is to hold a pointer to the current target object and retrieve the location via the pointer.

Share this post


Link to post
Share on other sites
Quote:
Original post by Kensterbut anyone else have some ideas or maybe a sample of code I can look over.


If you want simple, you don't want comprehensive. I'll do my best.

.
.
.

What if you have an animation that does three things: gets the attacker into range, guarantees the player will be in hit-range, and gives the NPC enough time to receive the next update (position, etc) and start the real attack. In other words, what I'm suggesting is a sort of entry-attack that uses a wider attack animation, thus guarantying a hit, and takes long enough to execute that the next update occurs and lets the NPC know what to do next. To help guarantee the player will stay still, this animation could stun the player.

Share this post


Link to post
Share on other sites
I am not worried about Client side animation. I am using an offical Client release from a major MMORPG.

Just worried about the server side.

Share this post


Link to post
Share on other sites
So, what exactly is the problem? Is it that recalculating the path takes time? If so, don't recalculate so often, just do it when the target has moved a significant distance from the position you last planned a path to. Is it because you always lag behind the target? If so, estimate where the target will be and aim for there instead.

Share this post


Link to post
Share on other sites
Kylo,

That is what I am asking. For the server side, the NPC calculates where the Player is. It moves to that location, during that time to move, the player moves, then the NPC recalculates, then moves, and its a loop. But I need to calculate where the player will be, not this, where he is stuff.

Thanks,

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!