ID:162947
 
I would like to know if there is a way to make a verb to switch two players mobs. So that means they literly switch bodies I guess, including stats, items, and what not. Would it be through client or something..Please tell me if you know anything. Thanks
client.mob
In response to GhostAnime
Wouldn't that be just the screen? I thought it would be more like

mob/verb/switch_bodies(mob/M in get_step(src,src.dir))
var/savefile/F = new("players/[src.ckey].sav")
F["X"] << src.x
F["Y"] << src.y
F["Z"] << src.z
F["icon"] << src.icon
F["icon_state"] << src.icon_state
F["Mob"] << usr.client.mob
F["verbs"] << src.verbs
//and the switch part goes here, otherwise this would just be a save verb...


Like a savefile of some sort...
In response to Jman9901
Maybe you should experiment, or at the very least, read upon the entry in the DM Ref.

And savefiles is for storing data, how would that do anything for what Valen wants?
In response to GhostAnime
Just the variables for saving it, Switching the variables. I just used savefiles as an example.
In response to Jman9901
You could loop through the vars list of each mob and then store them in a list. After that, loop through the lists that stored the vars and swap.
In response to Kakashi24142
No point since the save directly having "usr.client.mob" (though it really should be usr, or really src from the main uses of src in that verb... after all, the client.mob is referring back to the same src) should have all (non-temp.) variables and objects saved.
You need 3 mobs: the two switching and one as a placeholder. Call the first player mob A and the second mob B and the placeholder mob C.

First switch mob A to the empty mob C by setting C's key to A.
Then switch mob B to the now empty mob A by setting A's key to B.
Finally switch mob A to mob B by setting B's key to A and delete C.

~X
In response to GhostAnime
well if his is talking just stats and icons

mob
verb
Switch_Bodies(mob/M as mob in world)
var/b=input(M,"[usr] wants to switch stats with you for a few minutes, accept?")in list("Yes","No")
switch(b)
if("Yes")
usr.health = M.mhealth
usr.attack = M.mattack
usr.defence = M.mdefence
usr<<"Don't rest or else you will loose stats!"
M.health = usr.mhealth
M.attack = usr.mattack
M.defence = usr.mdefence
M<<"Don't rest or else you will loose stats!"
sleep(1000)
M.health = M.mhealth
M.attack = M.mattack
M.defence = M.mdefence
M<<"Your stats have returned to normal"
usr.health = usr.mhealth
usr.attack = usr.mattack
usr.defence = usr.mdefence
usr<<"Your stats have returned to normal"
else
return



~~~Marcmacman~~~
mob/verb/Switch_Bodies()
var/mob/m = usr.target2
var/c = m.client
m.client = usr.client
usr.client = c


So would this work?
If it does, would they revert back after they relog?
Would it only work on players, not NPCs?
In response to Valen45
No, that won't work. Read my post above. You need to set mob.key to log a client into a mob, not the client variable. Also, if you only switch between two mobs, and they both have clients, the fist one to have his key set will be kicked from the game. The only way to do this is to use 3 mobs. Read my post above and it should be clear.

~X
In response to Xooxer
Here:

proc // The proc can't be one of the mob's procs
// or else it will stop the moment that the mob
// switches, so everything must be done by
// a global proc of some sort.
Switch(mob/A, mob/B) // Pass the two players to switch
if(!ismob(A) || !ismob(B)) return // if one isn't a mob, do nothing
var/mob/C = new() // create a temporary mob to hold mob A
C.key = A.key // Switch mob A to mob C by setting it's key
A.key = B.key // Switch mob B to the now empty mob A
B.key = C.key // And switch mob C to mob B to complete the switch
del(C) // Just delete the temporary mob, and we're done


~X
In response to Xooxer
You can avoid creating a new mob like this:

proc/SwitchMobs(mob/A,mob/B)
var/client/C1 = A.client
var/client/C2 = B.client
C2.mob = null // I'm not sure this is necessary.
C1.mob = B
C2.mob = A