ID:140151
 
Code:
    Move()
if(!istype(loc,/turf/Routes/Water)) if(icon_state == "Swim" || icon_state == "Fly") icon_state = null

if(HP <= 0|| icon_state == "Faint" || icon_state == "Harden" || icon_state == "Withdraw" || icon_state == "Sleep") return 0
if(Speeding == 0)
Speeding = 1
..()
if(!NoRunDelay)
sleep(GetSpeed())

Speeding = 0


Problem description:

This is for a Pokemon game, and right now my mob/Pokemon/Move() has a runtime that keeps increasing rapidly. After about 5 minutes of just having a Pokemon follow you, realtime (in the Profile) has reached about 1000. It won't stop increasing, does that mean something is wrong with the game?

You said the pokemon is following you? Can you show the Code that makes it follow you? I can't seem to get a runtime from the code you've shown, I might be doing it wrong but I don't know.
I don't understand you.

If you're getting a runtime error, you will need to supply us with both it, and the line of code it relates to.


If you have a problem with something called "Realtime" you will need to show us where you've defined and used it.
In response to Nonya
    proc/Auto_Battle()
set background = 1
var/mob/Pokemon/Opponent //This is the Opponents Pokemon.
var/mob/Pokemon/P //This is the Pokemon the NPC is currently using
var/mob/Pokemon/Switchout //This is the Pokemon that is switching..in
var/turf/Turf //The area they are going to be attacking from.

while(Court && Court.Battle && Battling)
Opponent = Battling.ControlingPokemon
P = ControlingPokemon
if(Switchout)
if(P)
//Recall the Pokemon
P.ReturntoBall()
//Find The Location
var/atom/T = get_step(src.Watcher,src.Watcher.dir)
Get_Steps(T, src.Watcher.dir, rand(2,6))
//Send it Out
P = Switchout
Switchout = null
var/obj/FAKE = new //Creates a fake object for the missile
FAKE.icon = 'Pokeballs.dmi'
FAKE.icon_state = "throw [P.Ball.icon_state]"

if(T) T = locate(T.x,T.y + rand(3,3), T.z)
missile(FAKE, src.Watcher, T)
del FAKE
sleep(max(0,get_dist(T,src.Watcher)-1)) //Sleep the distance from the player to the place the pokeball was thrown (so it doesn't just pop there..)
P.loc = T
P.dir = 2
P.AddMeter()
flick("Send",P)
ControlingPokemon = P
P.Meter.overlays += /obj/HUD/Owned

if(!P)
while(!Switchout)
sleep(1)
Switchout = Party[rand(1,6)]
if(Switchout && Switchout.HP <= 0) Switchout = null
continue
else if(P)
Opponent = Battling.ControlingPokemon
P.Target = Opponent
if(!Opponent)
var/atom/T = Get_Steps(src.Watcher, src.Watcher.dir, 5)
if(P.loc != T && !T.density)
if(get_dist(P,Opponent) <=4) P.Step_To(T)
else P.dir = get_dir(P, Opponent)
else P.dir = get_dir(P,Battling.Watcher)
else
if(Turf)

P.Step_To(Turf)
if(P.loc == Turf) //Has it reached its destionation?
var/obj/Moves/M = P.AbleAttack()
if(M)
M.Check(P,Opponent)
Turf = null
continue
else if(!Turf)

while(!Turf)
Opponent = Battling.ControlingPokemon
var/l = pick("x","y")
if(Opponent)
switch(l)
if("x")
Turf = locate(Opponent.x + rand(-4,4),Opponent.y,Opponent.z)
if("y")
Turf = locate(Opponent.x,Opponent.y + rand(-4,4),Opponent.z)
if(Turf)
if(!istype(Turf.loc,/area/BattleCourt)) Turf = null
for(var/atom/movable/M in Turf)
if(M.density)
Turf = null
sleep(1)
sleep(max(1,P.GetSpeed() + 2))


This is the code I used to test it, its an NPC battle that makes the Pokemon walk towards the player and attack etc etc.

The reason I'm asking this is because the server is crashing after 2-6 hours. I don't know what it is, there are no runtime errors, and I'm wondering if something with an incredibly long realtime could cause a crash if it built up like the mob/Pokemon/Move() is.
In response to Valen45
Is there a runtime? How is it crashing? Is there an error? Does the window lock up? The more specific you are the easier it will be to fix.
In response to Valen45
You are not using Move(). You are directly setting the location which does not call the Move().It might not be a runtime error.It must be some overlapping overlooping stuff.Some variables and procs here are unknown, so can't say.BTW I was curious about Get_Steps()+Step_To(). Do you use Move in those?
By using move I mean using Move(),walk() and such related procs. or lets say not doing loc=a.

+ Is the Auto_Battle() a global proc? or some atom proc().

if(P)
while(!switchout)
sleep(1)
Switchout = Party[rand(1,6)]
if(Switchout && Switchout.HP <= 0)
Switchout = null
continue // make sure u have the switchout in this loop itself or u ll have to loop about again (the whole thing from the beginning)
continue

Though I can't really get you.
You can : Profile the proc. and check what can be the trouble.

The "realtime" value in the profiler tells you the total amount of (real) time from when the proc is called to when the proc finishes. sleep() statements obviously are counted in this, and so because your procedure sleeps, it causes the realtime to count up.

Also note that you are looking at the total realtime, so it's going to keep on increasing. If you changed it to show the average, it would remain relatively stable.