ID:1004009
 
I've profiled my server and the results were islava and is water and NPCregeneration is staggering. Islava is called 16k times in a few secs and growing and so is NPCregeneration all growing non stop. Now heres my 2 questions 1 are those suppose to keep going like that and if not is there a way to stop em from doing that.



 proc
Islava(dx,dy,dz)
var/result=0
var/turf/lava/L1 = istype(/turf/lava, locate(dx, dy, dz))
if(L1)
result=1
if(!result)
var/turf/Qt = locate(dx,dy,dz)
if(Qt)
if(Qt.underlays.Find('icons/lava.dmi'))
result=1
for(var/Uu in Qt.underlays)
var/t="[Uu:icon]"
if(t=="icons/lava.dmi")
result=1

return result


If u can see something i dont(im not a coder) thx for the help.
P.S. Thats the Islava code and it calls 32k times in a second as soon as someone logs in

You need to show where Islava() is being called.
        lavalogged=0

for(var/turf/Terrain/x in loc)
lavalogged=1

if(!lavalogged)
lavalogged=Islava(x, y, z)


if(lavalogged&&!protected)
if(curstamina<100)
curstamina=0
This is what u needed
I did ctrl+H and typed Islava and those the 2 codes are the ones that came up were those 1 in FX and the other in regeneration handling
Rather than using code which loops constantly on each turf, just check whether the player has stepped into lava by overriding the Enter() proc like so.

mob
proc
LoseStamina()
var/turf/T=src.loc//get current turf
while(istype(T,/turf/lava/))//check current turf.
src.stamina-=5
var/turf/c=src.loc//get current turf again
if(istype(c,/turf/lava/))
sleep(10)
continue
else
break

turf
lava
Enter(O)//where O is the atom entering
if(istype(O,/mob/))
var/mob/C=O
C.LoseStamina()
//here trigger a proc that will make the player lose stamina
else
..()//normal function


This way the player will lose stamina when they are stepping in lava, and each turf isn't looping through waiting on the player, which should significantly reduce the number of calls you see.

*had to make a few edits*
Thank you, because the code I showed in the previous post the lava did work at all so thanks for that also
Also would u be able to do the same for iswater
I ask because iswater is in fx,combat handling,and water.dm
    waterlogged=0

for(var/obj/Water/x in loc)
waterlogged=1
for(var/turf/water/x in loc)
waterlogged=1

if(!waterlogged)
waterlogged=Iswater(x, y, z)

if(waterlogged)
var/obj/haku_ice/ice = locate(/obj/haku_ice) in loc
if(ice)
waterlogged = 0
chakraregen *= 0.75

if(waterlogged&&!protected)
if(curchakra<15)
curstamina=0

Rather than making your own "IsWater" proc, you could use the istype() proc, which accepts two variables, the atom in question and the type path you want compare it to.
istype() returns 1 or true if the comparison is accurate.


From what it seems like you want water to be able to be stepped on by the player and they get waterlogged right?

It might be helpful to come up with a list of status ailments that your character can have, that way it will help you keep track of status ailments in one place.

for instance:

var/list/Ailments=list("Waterlogged"=0,"Poisoned"=0)


Then based on the effect of being water logged check for water log elsewhere. For instance if water-logged affects movement you would check in the Move() proc of the mob if it affects the attack power, add a line in damage calculations that affects the power.

Ok we want 3 types of turfs Land,Water,Lava. Land nothing happens, water drains chakra and lava drains stamina
In response to Snyperwolf
Snyperwolf wrote:
Ok we want 3 types of turfs Land,Water,Lava. Land nothing happens, water drains chakra and lava drains stamina

It would be the same answer as before, just edit each turf's Enter () proc and create a proc for the mob to do what you want done.
In response to Dariuc
You want Entered() not Enter().
In response to NNAAAAHH
Either one would work in this case.
Ok thanks for advice guys I appreciate it