[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: 03 Feb 2008, 10:17
Location: Ohio, USA
Contact:

[RESOLVED] tmwserv Bizzar Mob Movement Trend

Post by leeor_net » 20 Feb 2008, 01:32

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 22 Feb 2008, 01:56, 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: 13 Apr 2004, 20:11
Location: Italy
Contact:

Re: tmwserv Bizzar Mob Movement Trend

Post by ElvenProgrammer » 20 Feb 2008, 10:22

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: 25 Aug 2005, 17:08
Location: Germany

Re: tmwserv Bizzar Mob Movement Trend

Post by Crush » 20 Feb 2008, 14:22

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: 25 Aug 2005, 17:08
Location: Germany

Re: tmwserv Bizzar Mob Movement Trend

Post by Crush » 20 Feb 2008, 14:42

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: 03 Feb 2008, 10:17
Location: Ohio, USA
Contact:

Re: tmwserv Bizzar Mob Movement Trend

Post by leeor_net » 21 Feb 2008, 01:11

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: 25 Aug 2005, 17:08
Location: Germany

Re: tmwserv Bizzar Mob Movement Trend

Post by Crush » 21 Feb 2008, 01:22

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: 03 Feb 2008, 10:17
Location: Ohio, USA
Contact:

Re: tmwserv Bizzar Mob Movement Trend

Post by leeor_net » 22 Feb 2008, 01:55

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