The problem comes when i add to the world ( map ) a quantity of mobs, more mobs i add more time takes the game to load and higher is the laggg.
If i delete the Clothes list the game loads really fast and free of lag.
Any idea about how can i fix it?
An example:Without the Clothes Run the game from DM takes me 2s, With 20s. Without, move my player takes me 0.1s with 0.5s +/-
Enemi Code:
mob
NPC
Enemies/Humans
henge = 0
Marines
Marine
name = "Lv80 Marine"
Health = 1000
Max_Health = 1000
IsEnemy = 1
Race = "Human"
gender = "male"
//------ Stats ------
Will_Power_Lvl = 10
Stamina_Lvl = 15
Endurance_Lvl = 29
Strength_Lvl = 30
Speed_Lvl = 6
//------ Combat -------
Attack = 45
Armor = 25
//------ Drops -------
Exp_Drop = 2000
Berry_Drop = 2000
Bounty_Drop = 1200
//-----------------------///// Items Invenorty /////-----------------------//
Clothes = list(new/obj/Items/Clothes/MarineSet/Marine_Shirt,new/obj/Items/Clothes/MarineSet/Marine_Pants,new/obj/Items/Clothes/MarineSet/Marine_Cap,new/obj/Items/Clothes/MarineSet/Marine_Boot/Left,new/obj/Items/Clothes/MarineSet/Marine_Boot/Right)
New()
..()
xxx=src.x
yyy=src.y
zzz=src.z
src.spawnloc = src.loc
overlays = initial(overlays)
Display()
MarineMove()
Bump(mob/M)
..()
LookforPirate(M)
Cant the problem be every new called on Clothes list cuz of creating 7 new items per mob every time that the mob is created? cant the list have constant values or its just me imagining rare things? :))) well i think on that cuz if i have 30 mobs on the map and every mob will create 7 new items on theyr clothes on every respawn that can make lag, or no?
Sry for bad eng pls if you dont understand just tell me pls
However, even better is if you don't init the list until you need it. If these marines just have the equipment for show, why not just set their overlays instead?
However, I don't think the code as it stands now is likely to create lag on the magnitude you're seeing, unless each of those items also has a New() or init proc--in which case yeah, you're adding a lot more proc runs to the game at startup. It seems more likely that something else in your code is causing the slowdown, particularly the one you mentioned that happens when moving. In order to find that, I recommend using the built-in profiler so you can see which procs are taking the most time to operate while you move around.