ID:159512
 
How do I make the user spectate his mob (like removing him from the control of his mob but still follow him with the client eye,while AI takes over for a while).

And how do I change users control of mob (Like switching control from his mob to another one).
Destrojer wrote:
How do I make the user spectate his mob (like removing him from the control of his mob but still follow him with the client eye,while AI takes over for a while).

And how do I change users control of mob (Like switching control from his mob to another one).

To make a players mob act like you want, change src.client.mob to null and make src.client.eye be the mob of the client that is watching. I never actually tested if setting the mob to null works or not though.

To gain control of another mob, you must simply change src.client.mob to the mob you wish to control.
In response to Satans Spawn
Satans Spawn wrote:
I never actually tested if setting the mob to null works or not though.

Not possible. If it worked it could well just kick the player off, but like many built-in vars the mob var rejects values deemed invalid for it, so trying to set it to null (or, say, an /obj) doesn't change its value.

So, he'd have to create a dummy mob for it. Still a rather easy matter, it doesn't even have to be on the map <small>(though you could choose to make it invisible and nondense and follow the mob you're watching on the map instead of using client.eye since it has some benefits (and disadvantages too))</small>, and if you use a mob class you haven't defined lots of stuff and verbs on (won't work if you just went ahead and defined stuff on the base /mob type...) it'd be especially suitable, though you can also clear the verbs of the new mob manually.
Destrojer wrote:
How do I make the user spectate his mob (like removing him from the control of his mob but still follow him with the client eye,while AI takes over for a while).

As for not letting a the player control their mob, I would prefer to make client/Move() return 0 in the situation you speak of.
client
Move()
if(mob.posessed)
return 0
. = ..()

mob
var/posessed = 0
proc/posess()
posessed = 1
spawn(10)
posessed = 0
while(posessed)
// posessed AI routine
In response to Loduwijk
You'd need to also manually disable all possible control through verbs, clicking etc manually though, just client/Move() isn't likely to be enough. Obviously though this method wouldn't work as wanted if a player is to take control of another player's mob.