ID:174960
 
When i mob locates itself to a location where there is another mob it gets black screen and it doesnt move. Is there a way around it?
M.loc = locate(x,y,z)
usr.loc = locate(M.x,M.y+1,M.z)

I use to have that problem =P

-Camaro-
In response to Camaro
unless youve defigned M those two locate procs are usless

src.loc=locate(x,y,z)
In response to Wanabe
well if he's using a teleport i'm sure he defined mob/M

-Camaro-
In response to Garthor
That is what im using

A.loc = locate(19,19,3)

I have a party battle system and when all the members die it send them to that, problem is that when one gets out the others wont teleport. It's a for proc.
In response to Tazor07
I think this is what he wants:
mob
verb
Teleport(mob/M in world)
var/newloc=Move(locate(M.x,M.y,M.z))
if(newloc)
usr.Move(locate(M.x,M.y,M.z))
return
usr<<"<b>You can't teleport there!</b>"
In response to Goku72
goku, it's a byond bug i think, I believe if a spot has something with density on it, locate will now teleport them to the spot. I'm currently trying to work a way around it.
In response to Tazor07
What I just gave you WILL work for your purposes. Just try it. All you have to do is change the x,y,z to your coords.
In response to Goku72
Goku, it is wrong on many levels. What you suggested was totally wrong, and would do nothign to fix the situation. However, directly modifying the loc, as in loc = locate(x,y,z), will work. Using Move() WON'T work.
In response to Garthor
Garthor, that is what I am doing, it will teleport one person and no on else.
In response to Tazor07
Tazor07 wrote:
That is what im using

A.loc = locate(19,19,3)

I have a party battle system and when all the members die it send them to that, problem is that when one gets out the others wont teleport. It's a for proc.

You're gonna have to show us the section of code this is in, because it's doing something wrong but we can't tell what without more information.

Setting loc to legitimate turf will work every time; there's no question of that. Using Move(), it will fail if the turf is blocked. So more is going on than what you're telling us.

Lummox JR
In response to Lummox JR
for(party_slots=1, party_slots<=party.len, party_slots++)
var/mob/Characters/A = src.party[party_slots]
A<<sound('Town.mid',1)
A.close_menu2()
if(1)A.loc = locate(19,19,3);
if(2)A.loc = locate(19,19,3);
if(3)A.loc = locate(19,19,3);
if(4)A.loc = locate(19,19,3);
if(5)A.loc = locate(19,19,3);
There is no errors, if there is a mob there it wont teleport the person
In response to Tazor07
Tazor07 wrote:
for(party_slots=1, party_slots<=party.len, party_slots++)
var/mob/Characters/A = src.party[party_slots]
A<<sound('Town.mid',1)
A.close_menu2()
if(1)A.loc = locate(19,19,3);
if(2)A.loc = locate(19,19,3);
if(3)A.loc = locate(19,19,3);
if(4)A.loc = locate(19,19,3);
if(5)A.loc = locate(19,19,3);
There is no errors, if there is a mob there it wont teleport the person

You mean there's no compiler errors. There are errors, even if you don't see them.

What's with the if(1), if(2), etc. crap? That kind of syntax would only be right inside a switch(), which you're not, and there's really no reason to put in any if() test at all here in what should be a simple teleport operation. Furthermore, you shouldn't be using semicolons there.

I'm also pretty sure that whatever A.close_menu2() does, you don't want to do it for every player in the party--just the one who initiated the teleport.

I really won't be able to tell more without seeing the whole proc, including the object it belongs to, because I have a hunch that close_menu2() is what's doing you in. If I'm right on this, you're running this proc from an obj that's part of your menu, and close_menu2() is deleting that menu and the objs with it. When that happens, the proc dies and nobody else teleports. But that's only a guess.

When you post code, it's really important to post the entire proc. I don't know why you're so reluctant to put up a few lines of code, but if you'd done so in the first place you could have saved us both a lot of grief.

Lummox JR
In response to Garthor
Sorry, I thought he wanted it to access the turfs Entered() proc, so I suggested Move() =p
In response to Lummox JR
I used that because I decided to change it, I'll change it back to a.loc = locate(19,19,3) if it is the proc called menu_close2 thats doing it I only have this for it

close_menu2()
for(var/obj/back2/O in client.screen)del O
for(var/obj/text2/O in client.screen)del O

It closes the message that appears on the map.
In response to Tazor07
Tazor07 wrote:
I used that because I decided to change it, I'll change it back to a.loc = locate(19,19,3) if it is the proc called menu_close2 thats doing it I only have this for it

close_menu2()
for(var/obj/back2/O in client.screen)del O
for(var/obj/text2/O in client.screen)del O

It closes the message that appears on the map.

You have to stop giving me partial information. I said I need to see the whole proc you were running that code in, and what it belongs to. You haven't even shown that for close_menu2() here; I can only surmise it's a mob proc, but you need to show that.

So far however you've partially confirmed my theory about why only one mob is teleporting. Now you need to post the rest of that code, like the entire proc that a.loc=locate(...) line went with and what it belongs to. And it won't hurt to show more on close_menu2() either.

If you only give out a line or two of code at a time, don't expect help debugging it. No one can help you if you're not going to give them all of the relevant information.

Lummox JR
In response to Lummox JR
mob/proc/Dead()
var/party_slots
for(party_slots=1, party_slots<=party.len, party_slots++)
var/mob/Characters/A = src.party[party_slots]
A.close_menu()
A<<sound('Dead.mid',1)
A.textonscreenbackground2(1,1,11,4)
A.textonscreenTEXT2(1.5,11.5,4,1.5,"Your party has perished.")
sleep(50)
for(party_slots=1, party_slots<=party.len, party_slots++)
var/mob/Characters/A = src.party[party_slots]
A<<sound('Town.mid',1)
A.close_menu2()
if(1)A.loc = locate(19,19,3);
if(2)A.loc = locate(19,19,3);
if(3)A.loc = locate(19,19,3);
if(4)A.loc = locate(19,19,3);
if(5)A.loc = locate(19,19,3);
A.client.lazy_eye=0
A.Pick = 0
A.icon_state = "normal"
A.inbattle=0
A.isturn=0
A.HP = A.MaxHP
A.Gold -= A.Gold/2
A.Gold = round(A.Gold)
A.close_menu()
A.close_menu2()
A.textonscreenbackground2(1,1,11,4)
A.textonscreenTEXT2(1.5,11.5,4,1.5,"You need to be more careful next time.")
A.Talking = 1
return


Also, that is all there is for the menu close proc, its only 2 lines.
In response to Tazor07
Okay, quite a bit has been revealed now and I can solve your problem. This is why you can't post partial code snippets; the whole proc and where it comes from actually matter.

When you showed me that party loop, you never showed me the whole loop. You skipped a whole section of stuff below it, and that's where the problem is.

mob/proc/Dead()
var/party_slots
for(party_slots=1, party_slots<=party.len, party_slots++)
var/mob/Characters/A = src.party[party_slots]
A.close_menu()
A<<sound('Dead.mid',1)
A.textonscreenbackground2(1,1,11,4)
A.textonscreenTEXT2(1.5,11.5,4,1.5,"Your party has perished.")
sleep(50)

So far so good.

for(party_slots=1, party_slots<=party.len, party_slots++)
var/mob/Characters/A = src.party[party_slots]
A<<sound('Town.mid',1)
A.close_menu2()
if(1)A.loc = locate(19,19,3);
if(2)A.loc = locate(19,19,3);
if(3)A.loc = locate(19,19,3);
if(4)A.loc = locate(19,19,3);
if(5)A.loc = locate(19,19,3);

That whole slew of if() calls is still totally wrong. I don't know what the if(1), if(2), if(3) crap is supposed to do, but they'll always be interpreted as true because you're not in a switch() or anything. Essentially you're running A.loc=locate(19,19,3) five times.

And lose those semicolons. This is not C.

A.client.lazy_eye=0

Bad move! You forgot to check if A.client is valid anymore. Unless mob/Logout() is careful to remove src from the party list before it disappears, there's a chance A.client could have become null during the sleep(50). If however the mob does remove itself from the list, this should be sort of safe. I'd still put in an if(A.client) just in case. For that matter, an "if(!A) continue" line near the beginning of the loop is a good error trap.

You should also be careful in close_menu() and close_menu2() that src.client exists.

A.Pick = 0
A.icon_state = "normal"
A.inbattle=0
A.isturn=0
A.HP = A.MaxHP
A.Gold -= A.Gold/2
A.Gold = round(A.Gold)
A.close_menu()
A.close_menu2()
A.textonscreenbackground2(1,1,11,4)
A.textonscreenTEXT2(1.5,11.5,4,1.5,"You need to be more careful next time.")
A.Talking = 1
return

And there's the problem. After the first pass through the loop, you're returning from the entire proc, and not continuing on through the loop at all. If you unindent the return line, it will be correct; but it's safer just to remove it anyway, since this comes at the very end of the proc.

Lummox JR
In response to Lummox JR
Alright thanks Lummox, sorry about the hassle, I just though that the error was in those lines I posted. Thanks alot.
Page: 1 2