I'm having trouble with high cpu usage with my monster AI. I decided to deactivate the ones on empty floors, ETC no players on the floor, but now, the ones on other floors don'
t even attack when a player enters the new floor. Can someone help me do this? I'd really appreiate it.
ID:175644
Mar 24 2003, 12:04 pm
|
|
In response to Kunark
|
|
The best way to reduce lag in an RPG is to make it so the proc that moves the mobs to attack the player does not loop, but is instead called within a looping proc on the player, such as Stat() but Stat() isn't good because the mobs would be moving like every 1/10 of a second. Say put it in like a regeneration proc that is looped every 1 second, and then if a mob is in oview(5), call that mob's Wander() proc (remember Wander doesn't loop in this scenario.). And so this system only uses mobs that are nearby. Also, to activate mobs within a larger radius, look up the block() proc if you are going to use this scenario. Better yet avoid infinite loops and just activate the monsters from the players Move() proc. Also instead of having a inifinite loop for player regeneration just make one tick() proc which is called from world/New() like this. var This way you can sync things up to a standard time interval and there is much less overhead since there are less things that are contantly running. Also you have a measure of game time in ticks since it is updated every second. |
In response to Theodis
|
|
what's the % operator do?
|
In response to Magnus VI
|
|
X%Y is the remainder of X / Y.
|
In response to Magnus VI
|
|
Magnus VI wrote:
what's the % operator do? Like Garthor said it returns the remainder of the division between the two parameters. This is good for checking if a number is a multiple of another because if the % operator returns 0 then there was no remainder and the first number is a multiple of the second. So if (ticks % 60) returns 0 then ticks is a multiple of 60 (ie: 60, 120, 180, 240, ...). |
In response to Garthor
|
|
i see..... ok.
|
Then, make 1 datum obj with a proc that loops. In this proc, check all the mobs in the world that are active, and then make a list of all the player's z levels. If the no player's z levels are equal to the mob's z level, set that variable that the mob had to 0, which returns it. Then, to re-activate them, if the mob's variable that returns it is 0, and there is a matching player z level with the mobs z level, then make that mob Wander().
But that should only be done if you had already made over 100 mobs and don't want to change your entire system...
The best way to reduce lag in an RPG is to make it so the proc that moves the mobs to attack the player does not loop, but is instead called within a looping proc on the player, such as Stat() but Stat() isn't good because the mobs would be moving like every 1/10 of a second. Say put it in like a regeneration proc that is looped every 1 second, and then if a mob is in oview(5), call that mob's Wander() proc (remember Wander doesn't loop in this scenario.). And so this system only uses mobs that are nearby. Also, to activate mobs within a larger radius, look up the block() proc if you are going to use this scenario.