ID:161284
 
Ok, so I'm making a MUD and I want to know how I would make a clone of myself, my stats anyway and make it follow me around?
To make a copy of an object, you'd basically create a new object of the same type, and set all its variables to the value of the original's variables. You can do this with the type variable and the vars variable. Look them up and have a go at it.
In response to Kaioken
I got the whole creating part, now I need help with the following part, in a MUD its kinda different for me, then if it were on turf..
In response to Lundex
I am unsure as to whether this would work but from looking at the refrence (which you should do as suggested) I came up with this rather crude way:
var/mob/clone = new src.type(src.loc)
for(V in src.vars) clone.vars[V] = src.vars[V]
In response to Lyndonarmitage1
That I already know, I'm just looking for how to make them follow me from room to room, since I don't have any turf....
In response to Lundex
Each time your player 'moves' have the clone move. You could do this by adding a check proc to your default ways of movement.
E.G.
mob/proc/Clone_Move()
if(src.clone)
src.clone.loc = src.loc
mob/Move()
..()
src.Clone_Move()
// or
area/verb
North()
..() // move if you can
src.Clone_Move()
In response to Lyndonarmitage1
Uhh, wow that just lost me..
In response to Lundex
You could override the rooms' Entered() and make it so whenever a player enters a room, so does his clone, or something to that extent. But you should use the Move() proc instead of setting loc directly.
area/room
Entered(mob/M)
if(ismob(M)) //verify that the entering object is a mob
M.clone.Move(src) //if it is, move its clone to the save location as well
In response to Kaioken
Hmm, only one question. what would M.clone.Move() be the normal Move() proc or a made one?
In response to Lundex
You wouldn't be able to make a new one, since mobs already have a proc named Move, eh. And there isn't a reason to make a new one, since Move() does what you need here... it moves the object to the new location.
In response to Kaioken
Well, its coming up as undefined...
In response to Lundex
You haven't defined the clone variable's type properly, then. It should be defined as a mob (or perhaps something more specific as appropriate, such as mob/person or mob/character).
In response to Kaioken
Just send me to the helpfiles...Cause I'm not getting it.
In response to Lundex
Right, the "help files" about this would be the reference's entry(ies) about variables and the DM Guide's chapter about variables. You're indeed welcome to try and solve your problem on your own by reading them. Although, you may have been confused or mislead by example (which is just an example, by the way, intended to demonstrate, not to be used), which assumes there is a variable called clone on mobs that references their clone. If your game doesn't have this, then you need to add this or something similar to it; the mob needs to keep track of its clone so we can work with it later.
In response to Kaioken
Well, I have a variable clone, just I don't think I'm using it right. For the examples..
In response to Lundex
Again, make sure the variable's type is defined as /mob. Look up 'vars' in the DM Reference to see how to define variables and their type. If the variable isn't defined as /mob, the compiler won't know that it has mob variables and procs (such as atom/movable/Move()).
In response to Kaioken
Ok, I have my clones set under mob/others, so it is a mob type....it still doesn't work..
In response to Lundex
Well, post all the relevant code so we can do more than just guess what the problem is, then. Others will help you then (I'm off for today).
In response to Kaioken
mob/verb
bunshin(message as text|null)
set hidden = 1
set name = "Bunshin"
if(message)
switch(message)
if("1")
if(!busy)
src.busy = 1
src << "You perform the hand seals..."
oview(0) << "[src] performs the hand seals..."
sleep(20)
src << "Tiger.."
oview(0) << "[src] does the Tiger seal."
sleep(20)
src << "Boar.."
oview(0) << "[src] does the Boar seal."
sleep(20)
src << "Ox.."
oview(0) << "[src] does the Ox seal."
sleep(20)
src << "Dog.."
oview(0) << "[src] does the Dog seal."
sleep(20)
src << "\"Ninja Art: Clone Jutsu.\""
oview(0) << "[src] yells out,\"Ninja Art: Clone Jutsu.\""
sleep(20)
src << "Your bunshin appears out of smoke."
oview(0) << "A bunshin appears next to [src] out of smoke."
var/clone = new/mob/other/clone(src.loc)
clone:name = "<font color = '#2352FF'><B>(Clone)</B></font color>[src.name]"
clone:health = 1
clone:chakra = 0
clone:owner = src
src.busy = 0
else return
This is my Bunshin(Code) code....
In response to Lundex
No, you need to declare the variable pointing to the clone to be of type mob.
Page: 1 2