ID:178860
 
I'm having trouble with my death locator. Sometimes it works, sometimes it doesn't. Any suggestions???

------
mob/proc
playerdeathcheck(mob/P, mob/M)
var
tempgold
if (P.hp <=0)
usr << "You have been killed!"
usr << "You lose half your gold"
tempgold = P.gold % 2
P.gold = P.gold - tempgold
P.gold -= (P.gold / 2)
var/turf/battlearea/T = P.battlearea
T.occupied = 0
P.battlearea = null
P.onbattlefield = null
P.oldbattlefield = null
P.hp = P.maxhp
P.mp = P.maxmp
P.battlestart = 0
usr<<"[P.savex] [P.savey] [P.savez]"
usr:loc = locate(P.savex,P.savey,P.savez)
P.invisibility = 0
del (M)
//Player is still alive, so go back to main combat menu
else
maincombat(P, M)
I hate to bump, but there hasn't been one response. Any ideas why this won't work all the time?
The trouble you seem to be having is that you're using usr instead of P. A good rule of thumb is to never use usr outside of a verb.

One thing that may help you (though it has nothing to do with the bug) is that you can save some space in that half-gold section:
P.gold = round(P.gold/2)

The round() proc will cut off everything after the decimal point if you don't specify a second argument. Otherwise, round(x,n) will round everything to the nearest n.

And thank you for waiting a day to bump the post. That's an entirely responsible and reasonable way to do so.

Lummox JR
In response to Lummox JR
I tried putting a P instead of the usr, and leaving it blank. I also tried hard coding coordinates in and it still doesn't work. Any other ideas??? I appreciate any help what-so-ever.

P.S. --- I will be changing the gold in half code, since it is a lot cleaner like that. Thanks!
In response to Rubius
Rubius wrote:
I tried putting a P instead of the usr, and leaving it blank. I also tried hard coding coordinates in and it still doesn't work. Any other ideas??? I appreciate any help what-so-ever.

It would probably help if you could describe exactly what does and doesn't happen when this doesn't work. Having an idea where and how it fails is very important to debugging.

Lummox JR
In response to Lummox JR
When I die, sometimes it will take me to the coordinates that I want to go to (the save coordinates). But, mostly, it will send me to the world map coordinates that I was at when I started the battle. It's not going into any other proc after thedeath one, since I have messages come up to say which proc it's in. No rush in geting back to me, I won't be back for a couple of hours. I get to go tutor. Thanks!
In response to Rubius
Rubius wrote:
When I die, sometimes it will take me to the coordinates that I want to go to (the save coordinates). But, mostly, it will send me to the world map coordinates that I was at when I started the battle. It's not going into any other proc after thedeath one, since I have messages come up to say which proc it's in.

Question: Are the values of savex, savey, and savez the correct values? They're output to the text window, so you should be able to see if they're right or wrong.

It sounds to me as if they're being set wrong, or something is resetting them.

Lummox JR
In response to Lummox JR
Yeah, they are the right values.