English About my RPG tibia

6 replies
Goto Page
To the start Previous 1 Next To the start
15.01.20 09:16:52 am
Up
haha1955
User
Offline Off
Hi guys,

Have a Problem with my Monster.lua

My Problem is if im adding 100 Monsters in the server then its start lagging, but if im add just 50 Monster then its half lagging.

So what need i do to fix this Problem? I want 100 Monsters in my server.

And why its start lagging if im add 100 Monsters?

Im happy if any help.
15.01.20 09:42:43 am
Up
There's no solution, remake the Lua in a more efficient way.
15.01.20 09:57:01 am
Up
haha1955
User
Offline Off
what u exactly mean with "more efficient way?"
edited 1×, last 15.01.20 10:22:20 am
15.01.20 11:47:19 am
Up
Gaios
Security Supporter
Offline Off
Write new Tibia MMORPG from stratch with new CS2D features.

This file file cs2d CS2DTibia - RPG (310) and its versions are so much outdated.

You can also try to animate those monsters that are close to players only. cs2d lua cmd hascloseplayers
15.01.20 02:45:06 pm
Up
MikuAuahDark
User
Offline Off
That means the server is too slow, which can be caused by
1. Slow script, and/or
2. Slow network bandwidth

To fix point 2, try increasing your server cs2d cmd transfer_speed. However fixing point 1 is not easy. You don't have any choice but to make the script faster, as others mentioned.
file cs2d LuaJIT for Dedicated Server (9) JIT POWER! | Know your Lua errors! | don't use PM for scripting help!
15.01.20 04:05:11 pm
Up
TrialAndError
User
Offline Off
It all boils down to the loops used in tibia and similiar projects. The more monsters = the more stuff to loop through = the slower it becomes.

I fixed most of my "slow-script" by using Quadtree and as @user Gaios: said about animating and showing only the monsters that are close to a player.

I decided to go with the Quadtree solution because I added in Guard Towers which along with the players also looped through all the monsters and did some calculations which slowed down the script even more. I had to sacrifice a bit of memory for a decent amount of improvement and it was worth it.

You can imagine with 100 monsters for every player.
100 Loops per Player per 1/10 of a second. With, if you use some kind of collision system between the monsters themselves can become 100 squared added.

Quadtree pretty much recursively divides the map into quadrants where you can store information in each quadrant or sub-quadrant with different kinds of information and query through the quadrant you are in or the neighboring quadrants to loop for targets and/or whatever you need.

It's also good to constrain the monsters in some kind of way so they don't go all over the map and instead stay in some kind of "mob area" where they and/or similiar mobs can hang out.

Along with "mob area", it would also be useful to add passiveness and agressiveness for the monsters into the mix. What I mean by that is, as long as you don't hit a monster, they will not aggro onto you and when they don't aggro they are not checking for any players to attack. You could of course have aggro on for some mobs.

TL;TR Make your loops do more work for less computation and keep down the amount of times stuff has to loop
15.01.20 07:29:19 pm
Up
haha1955
User
Offline Off
okay, i will try it @user TrialAndError:

thanks for the answers guys.

i tell here if any problems or if it solved^^

have a nice day
To the start Previous 1 Next To the start