ID:158138
 
Is there a way to switch between mobs on the map? I know a basic way to do it, but it's extremely glitch and sloppy.

I should rephrase the above; what is the BEST way to do as such? Please help.
You should rephrase it so it actually describes what you mean by "switching between mobs on the map". That implies simply swapping their locations, but the topic title implies swapping or transferring control over a mob between players.
Always describe what you want to do in detail, and be specific while doing so.
In response to Kaioken
Aye, aye. I had a moment of implication... -doh- and I fuss at people for doing what I just did.

I meant switch control, so that for example, the DM could take control of any NPC's they can see on the map.
In response to Kaioken
I find that replying with "functional" code such as
client/verb/Demonic_Possession(mob/M)
mob = M

which technically fits their request to the letter to make more of an impact than asking for more information. It's not rude, but it makes them actually see that the answer to the question they asked might not be the answer to the question they should have asked. Not only do I think it helps them learn the art of forum-questioning better (which is just as important as knowing how to program in the first place! And I'm not exaggerating), but it's also more fun.
In response to Delra
Loduwijskdfjo9uiwae5tnl's example is entirely sufficient, then. Simply change the mob variable of the client. Note that this does have some (potentially unintended) consequences, such as Logout() and Login() being called. Though, you can use that to your advantage (stop any AI procedures on Login(), for example) rather than it being an issue. client/New() and client/Del() can be used for when somebody connects to / disconnects from the server.
In response to Delra
Technically, the
client/verb/Demonic_Possession(mob/M)mob=M

route still accomplishes exactly what you're asking for. You said you had a way to do what you wanted that doesn't work as well; it would help if you explained why it doesn't work as well. That is, what is the full extent of what you're trying to accomplish, and what isn't accomplished by what you have.

I'll take a stab in the near-dark here and try to hit what you're trying to get at. You can add all kinds of extra functionality in there too to extend it however you want.
(edit)
Oh, and you have to call the client's posess() to make it posess something. posess(object) posesses object, and posess(null) "unposesses" it.
(/edit)
client
var/virtualController/controller

New()
. = ..()
controller = new(src)

proc/posess(atom/movable/M)
if(M == null && istype(controller, /virtualController/remoteController))
controller = new(src)
return
virtualController = new /virtualController/remoteController(M)

North() controller.North()
South() controller.South()
East() controller.East()
West() controller.West()
Northeast() controller.Northeast()
Northwest() controller.Northwest()
Southeast() controller.Southeast()
Southwest() controller.Southwest()

virtualController
var/client/owner

New(client/C)
owner = C

proc
North()
var/turf/newLoc = get_step(owner.mob.loc, NORTH)
return owner.Move(newLoc, NORTH)
South()
var/turf/newLoc = get_step(owner.mob.loc, SOUTH)
return owner.Move(newLoc, SOUTH)
East()
var/turf/newLoc = get_step(owner.mob.loc, EAST)
return owner.Move(newLoc, EAST)
West()
var/turf/newLoc = get_step(owner.mob.loc, WEST)
return owner.Move(newLoc, WEST)
Northeast()
var/turf/newLoc = get_step(owner.mob.loc, NORTHEAST)
return owner.Move(newLoc, NORTHEAST)
Northwest()
var/turf/newLoc = get_step(owner.mob.loc, NORTHWEST)
return owner.Move(newLoc, NORTHWEST)
Southeast()
var/turf/newLoc = get_step(owner.mob.loc, SOUTHEAST)
return owner.Move(newLoc, SOUTHEAST)
Southwest()
var/turf/newLoc = get_step(owner.mob.loc, SOUTHWEST)
return owner.Move(newLoc, SOUTHWEST)

virtualController/remoteController
var/mob/M
North()
var/turf/newLoc = get_step(M, NORTH)
return M.Move(newLoc, NORTH)
South()
var/turf/newLoc = get_step(M, SOUTH)
return M.Move(newLoc, SOUTH)
East()
var/turf/newLoc = get_step(M, EAST)
return M.Move(newLoc, EAST)
West()
var/turf/newLoc = get_step(M, WEST)
return M.Move(newLoc, WEST)
Northeast()
var/turf/newLoc = get_step(M, NORTHEAST)
return M.Move(newLoc, NORTHEAST)
Northwest()
var/turf/newLoc = get_step(M, NORTHWEST)
return M.Move(newLoc, NORTHWEST)
Southeast()
var/turf/newLoc = get_step(M, SOUTHEAST)
return M.Move(newLoc, SOUTHEAST)
Southwest()
var/turf/newLoc = get_step(M, SOUTHWEST)
return M.Move(newLoc, SOUTHWEST)

If you want your field of view to follow the other object, you'll need to set client.perspective too.
In response to Loduwijk
That works, but that was the very same thing I was doing; it pulls a major error. I should ask, what is the BEST way to do as such?
In response to Delra
Delra wrote:
That works, but that was the very same thing I was doing; it pulls a major error. I should ask, what is the BEST way to do as such?

Take your pick.

Loduwijk wrote:
You said you had a way to do what you wanted that doesn't work as well; it would help if you explained why it doesn't work as well. That is, what is the full extent of what you're trying to accomplish, and what isn't accomplished by what you have.

Loduwijk also wrote:
I'll take a stab in the near-dark here and try to hit what you're trying to get at. You can add all kinds of extra functionality in there too to extend it however you want.
(excessive code snippet here)

If you aren't going to explain more, then the only other thing I can say is just do "mob = M" as I said before, but add in the advice that you should modify Login() and Logout() to avoid odd side effects like Garthor talked about. This would mean that you don't want Login() to relocate mobs, I would assume (You can't use ..() in Login()), and any other special stuff you have happening in Login()/Logout() has to take remote control into account and not treat controlled mobs as though you just logged into the game with a fresh mob, and Logout() can't assume that you're leaving the game.