ID:156778
 
Hey, I've been messing around with clones and private testers have said it causes lag. Any suggestions on how to simplify/make it more efficient?

        Multiple_Shadow_Clone(mob/M)
set hidden = 1
if(!(M.isclone&&M.KO))
if(M.Clones<6)
if(M.Chakra>=M.MC*0.3-M.Control/2)
for(var/Jutsus/MultipleShadowCloneIcon/I in usr.Jutsus)
if(!(usr.Cooldown("Multiple Shadow Clone",I.Cooldown*10)))
M.Chakra-=M.MC*0.3-M.Control/2
M<<"Multple shadow clone jutsu!"
view()<<sound('Clones.wav')
M.Seals=""
M.icon_state=""
var/mob/NPC/Clone2/D=new(M.x,M.y,M.z)
var/mob/NPC/Clone2/E=new(M.x,M.y,M.z)
var/mob/NPC/Clone2/F=new(M.x,M.y,M.z)
D.owner=M
E.owner=M
F.owner=M
D.Move(locate(M.x+1,M.y,M.z))
E.Move(locate(M.x-1,M.y,M.z))
F.Move(locate(M.x,M.y+1,M.z))
new/obj/Smoke(M.loc)
for(var/mob/NPC/A in oview(M))
if(A.owner==M)
A.icon=M.icon
A.overlays+=M.overlays
A.isclone=1
A.Stamina=30
A.Chakra=M.MC*0.3
A.Strength=M.MSTR/0.75
A.owner=M
A.Frozen=0
A.Ally=M.Ally
:/

mob/proc/createClone()
var/mob/clone = new(src)
clone.loc = src.loc
In response to Vector2 (#1)
The first argument to new() is the location to create an object at.
In response to Garthor (#2)
When the created object is an atom, of course (although the statement isn't 100% accurate for non /atom/movable, but it's good enough).