ID:171997
 
Well, as work continues on my super cheezy Rockman EXE game, I came across another thing I don't know how to do...

What I want to be able to do is control 2 mobs and be able to switch between them at almost any time. Preferably I'd like them to be able stay where they are when you switch to the other... But, as you have probably guess I have NO IDEA how to do this...

I made up some cheezy code to just switch between them by relocating, changing icon, changing name, ect on one mob... and that doesnt even work...

I'm gonna throw my current code out there just so you can fix it if you can't help me get something better...

mob/PC/verb
Switch_to_Operator()
usr.x = usr.navix
usr.y = usr.naviy
usr.z = usr.naviz
usr.name = usr.operatorname
usr.innet=0
if(usr.operatorgender=="Male")
usr.icon = 'operator.dmi'
usr.icon_state = "male"
else
usr.icon = 'operator.dmi'
usr.icon_state = "female"
usr.verbs += /mob/PC/verb/Switch_to_Navi
usr.verbs -= /mob/PC/verb/Switch_to_Operator
usr.verbs -= /mob/PC/verb/PlugOut
usr.verbs -= /mob/PC/verb/Buster
usr.loc = locate(usr.opx,usr.opy,usr.opz)
Switch_to_Navi()
usr.x = usr.opx
usr.y = usr.opy
usr.z = usr.opz
usr.name = usr.naviname
usr.innet=1
usr.icon = 'navi.dmi'
usr.verbs -= /mob/PC/verb/Switch_to_Navi
usr.verbs += /mob/PC/verb/Switch_to_Operator
usr.verbs += /mob/PC/verb/PlugOut
usr.verbs += /mob/PC/verb/Buster
usr.loc = locate(usr.opx,usr.opy,usr.opz)

Yes that's n00bish crap, but what do you expect from me.

Can someone please either fix that code or help me code what I REALLY wanted to have in the game???

Thanks in advance.
Firstly, use dm tags when showing code(i have no answer for why people like that, although it looks nicer)

Here's my attempt:

mob/PC/verb
Switch_to_Operator()
usr.navix = usr.x
usr.naviy = usr.y
usr.naviz = usr.z
usr.naviname = usr.name
usr.name = usr.operatorname
usr.innet=0
if(usr.operatorgender=="Male")
usr.icon = 'operator.dmi'
usr.icon_state = "male"
else
usr.icon = 'operator.dmi'
usr.icon_state = "female"
usr.verbs += /mob/PC/verb/Switch_to_Navi
usr.verbs -= /mob/PC/verb/Switch_to_Operator
usr.verbs -= /mob/PC/verb/PlugOut
usr.verbs -= /mob/PC/verb/Buster
usr.loc = locate(usr.opx,usr.opy,usr.opz)
Switch_to_Navi()
usr.opx = usr.x
usr.opy = usr.y
usr.opz = usr.z
usr.opname = usr.name
usr.name = usr.naviname
usr.innet=1
usr.icon = 'navi.dmi'
usr.verbs -= /mob/PC/verb/Switch_to_Navi
usr.verbs += /mob/PC/verb/Switch_to_Operator
usr.verbs += /mob/PC/verb/PlugOut
usr.verbs += /mob/PC/verb/Buster
usr.loc = locate(usr.navix,usr.naviy,usr.naviz)


Make sure that when you log in for your first ever time you're not going to be either an operater or a navigator. If you are then write in usr.navix/y/z and usr.opx/y/z and usr.operatorname and usr.naviname, so it doesn't locate you to a black screen and so you have a name.
In response to DeathAwaitsU
Yay! It works. I had some pretty stupid mistakes in there.

Thanks
In response to Newbreedofnerd
No problem, glad i could help.

Things only look stupid when you see the answer, so dont blame yourself.
Or, alternatively...instead of having all of those redundant variables and if/else blocks, you can always use references.

client
perspective=EYE_PERSPECTIVE //So we can see beyond client.mob
Move(New_Loc,Dir)
if(src.mob.Player)
src.mob.Player.Move(New_Loc,Dir)
return
return ..()
mob
var
list
mobs=list()
mob
Player //This is the main variable we'll be using to keep track of what mob we have selected
player
verb
Change_Player(mob/M in src.mobs|null)
if(M)
if(ismob(M))
if(src.Player&&src.Player!=M)
src.verbs.Remove(src.Player.verbs)
src.verbs.Add(src.Player.verbs)
src.Player=M
src.client.eye=M
Navigator
verb
Navigate()
src<<"<b>You navigate!</b>"
Operator
verb
Operate()
src<<"<b>You operate!</b>"