[RESOLVED] tmwserv Bizzar Mob Movement Trend

Content and general development discussion, including maps, quests, and server code from the development team.
Post Reply
User avatar
leeor_net
Novice
Novice
Posts: 180
Joined: Sun Feb 03, 2008 10:17 am
Location: Ohio, USA
Contact:

[RESOLVED] tmwserv Bizzar Mob Movement Trend

Post by leeor_net » Wed Feb 20, 2008 1:32 am

Well, I've been running the Game Server with few problems (minus the problem if it periodically crashing but that's a different issue). I've begun to notice a bizzar trend: All of the mobs seem to want to migrate toward the top left corner of the map.

Now, the game server has been running overnight and most of the day without anybody signing on and killing mobs so they've been free to roam wherever they please... yet, they still all seem to be moving over to that one section of the map.

Any thoughts on what is causing this phenomena (and perhaps suggestions on how to change it)?
Last edited by leeor_net on Fri Feb 22, 2008 1:56 am, edited 1 time in total.
- Leeor

"Oh, no thanks. I ate a boulder on the way in." - Shrek
User avatar
ElvenProgrammer
TMW Adviser
TMW Adviser
Posts: 2526
Joined: Tue Apr 13, 2004 8:11 pm
Location: Italy
Contact:

Re: tmwserv Bizzar Mob Movement Trend

Post by ElvenProgrammer » Wed Feb 20, 2008 10:22 am

Did you notice this behaviour on all the maps and for all monsters?

My guess is that they can't go too far from their spawning point (but I don't really remember how it works), and maggot spawning point should be located NW.
User avatar
Crush
TMW Adviser
TMW Adviser
Posts: 8046
Joined: Thu Aug 25, 2005 5:08 pm
Location: Germany

Re: tmwserv Bizzar Mob Movement Trend

Post by Crush » Wed Feb 20, 2008 2:22 pm

No, Elven, you are wrong. A monster which has nothing to do searches for a new location to go to using the following lines of code (game-server/monster.cpp lines 246 and 247)

Code: Select all

Point randomPos(rand() % (range * 2) - range + getPosition().x,
                rand() % (range * 2) - range + getPosition().y);
where "range" is the stroll range of the monster in pixels and getPosition() is the current position of the monster. The spawn location doesn't matter for a monster (it doesn't even know it). This code might indeed favor negative over positive values. I'll check that.

Thanks for reporting, leeor_net
  • former Manasource Programmer
  • former TMW Pixel artist
  • NOT a game master

Please do not send me any inquiries regarding player accounts on TMW.


You might have heard a certain rumor about me. This rumor is completely false. You might also have heard the other rumor about me. This rumor is 100% accurate.
User avatar
Crush
TMW Adviser
TMW Adviser
Posts: 8046
Joined: Thu Aug 25, 2005 5:08 pm
Location: Germany

Re: tmwserv Bizzar Mob Movement Trend

Post by Crush » Wed Feb 20, 2008 2:42 pm

Yes, leeor, you were right. The code above does indeed favor negative directions over positive.

rand()%X does not return a number between 0 and X but between 0 and X-1. So rand()%6 - 3 would not return numbers between -3 and +3 but between -3 and +2. I committed a bugfix which should and seems to fix the problem. But it's hard to say without a real long-time test.
  • former Manasource Programmer
  • former TMW Pixel artist
  • NOT a game master

Please do not send me any inquiries regarding player accounts on TMW.


You might have heard a certain rumor about me. This rumor is completely false. You might also have heard the other rumor about me. This rumor is 100% accurate.
User avatar
leeor_net
Novice
Novice
Posts: 180
Joined: Sun Feb 03, 2008 10:17 am
Location: Ohio, USA
Contact:

Re: tmwserv Bizzar Mob Movement Trend

Post by leeor_net » Thu Feb 21, 2008 1:11 am

I'm just glad I'm not crazy! :)

Thanks for the update, Crush. I was actually considering completely replacing the 'rand' function with a truelly random number generator. But that's something to toss into a TODO.

I'll keep the gameserver running for awhile and see if the problem is corrected.
- Leeor

"Oh, no thanks. I ate a boulder on the way in." - Shrek
User avatar
Crush
TMW Adviser
TMW Adviser
Posts: 8046
Joined: Thu Aug 25, 2005 5:08 pm
Location: Germany

Re: tmwserv Bizzar Mob Movement Trend

Post by Crush » Thu Feb 21, 2008 1:22 am

Replacing rand() would be quite unnecessary. The rand implementation of the average C standard library is already random enough for games. Better random number generators are only needed for scientific or cryptographical purposes.
  • former Manasource Programmer
  • former TMW Pixel artist
  • NOT a game master

Please do not send me any inquiries regarding player accounts on TMW.


You might have heard a certain rumor about me. This rumor is completely false. You might also have heard the other rumor about me. This rumor is 100% accurate.
User avatar
leeor_net
Novice
Novice
Posts: 180
Joined: Sun Feb 03, 2008 10:17 am
Location: Ohio, USA
Contact:

Re: tmwserv Bizzar Mob Movement Trend

Post by leeor_net » Fri Feb 22, 2008 1:55 am

I suppose you're right. I never really thought of it that way.
- Leeor

"Oh, no thanks. I ate a boulder on the way in." - Shrek
Post Reply