ID:146670
 
Code:
Victory()
var/mm=0
for(var/mob/monsters/M in oview(5))
if(M!=null)
if (M.HP > 0)
mm++
if(mm==0)
var/Gained_Exp
for(var/mob/monsters/M in oview(5))
Gained_Exp+=M.cexp
del M
src<<"Victory is at hand"
src<<"You Gained [Gained_Exp] Experience!"
src.close_menu()
src.cexp+=Gained_Exp
src.texp+=Gained_Exp
src.inbattle=0
src.client.lazy_eye = 0
src.Bnum = 0
src.Move(locate(35,6,1))


Problem description: Well the problem is that the Move proc isnt returning the src back to start any ideas why.

You can either cop out and try using "usr" instead of "src", or try this:

src.loc = locate(35,6,1)
In response to Mizumon
Mizumon wrote:
You can either cop out and try using "usr" instead of "src"

That won't help anything.
Well, for one, there are some issues with your code.

First of all, you shouldn't be using if(myVar == 1) and if(myVar == 0) checks, but instead, should be using if(myVar), and if(!myVar), respectively. Much more robust.

You see, in DM, null, 0, and "" are actually considered to be different values. Therefore, if myVar is equal to null, and you check for if(myVar == 0), you won't get the expected result.

To solve this issue, you could do something like this:

if(myVar == 0 || myVar == null ||myVar == "")


However, that's exactly what the ! operator does, so we can just use that instead!

if(!myVar)


Now, there are some problems with both of your for() lists. First of all, in both, you're abusing usr:

for(var/mob/monsters/M in oview(5))


In oview(), view(), orange(), and range(), the default center argument is equal to usr not src. If you don't understand what's wrong with using usr here, then you should read the usr lecture. When I say that you're abusing usr, I'm assuming that Victory() is a proc. If it is a verb, and usr and src are synonymous, then you're fine here.

Now, in the first for() list, you're checking for if(M != null). Although it should be if(M) instead, the entire if() check is unneccessary. In a for() list, if the object being checked for is non-existant, it won't continue the loop.

        for(var/mob/monsters/M in oview(5,src))
if(M.HP > 0)
mm++


You have badly named variables, Sleinth. A variable should be a comment in itself. An outsider, like me, has no idea what "mm" means. You should clear this up; give it a better, more informative name.

Now, on to your movement issue. You say that the following line isn't working:

src.Move(locate(35,6,1))


If atom/movable/Move() doesn't work, then the location that you're trying to move the atom/movable has an Enter() proc that is returning 0. Perhaps it's dense.

Anyway, the newloc's Enter() proc isn't called if you move the atom/movable by manually setting its loc:

src.loc = locate(35,6,1)


Try that!