ID:143071
 
Code:
mob/proc
Createclones()
var/mob/clone=new(src.loc)
clone.name = "[src.name]s Clone"
clone.icon=src.icon
clone.overlays=src.overlays
clone.father = "clone"
clone.mother = "[src.key]"
clone.owner = src
clone.Hpmax = src.Hpmax
clone.Hp = clone.Hpmax
clone.Str = src.Str
clone.Def = src.Def
clone.Sp = src.Sp
clone.Level = src.Level
clone.KO = 0
clone.move = 1
clone.CloneCycle()

mob/var
CControl = 150
Chakra = 100
follow
father
owner
mother
tmp/Clones


mob
verb
Copy()
set category = "Fighting"
if(usr.Chi <= 0)
usr << "Not enough Chi"
return
if(usr.CControl >= 101)
usr.Clones += 1
usr.Createclones()
if(usr.CControl <= 100)
usr.Chi -= 5
verb
DeleteSplitform()
set category = "Fighting"
for(var/mob/M in world)
if(M.father == "clone")
if(M.mother == "[usr.key]")
usr.Clones -= 1
del M
return
mob
proc
CloneCycle()
if (client || isDead())
return 1
spawn(lifecycle_dalay)
CloneCycle()

mob
var
lifecycle_dalay = 10
followblock = 0
mob
CloneCycle()
if (client || isDead())
return
var/action_taken
for (var/mob/other_mob in oview(9,src))
if(istype(other_mob, /mob/monsters/)||other_mob == follow)
step_towards(src, other_mob)
if(other_mob in oview(1,src))

Attack2(other_mob)
action_taken = 1
action_taken = 1
for (var/mob/other_mob in oview(15,src))
if(!action_taken&&!followblock&&!follow)
step_to(src, src.owner, 2)
if(action_taken)
spawn(lifecycle_dalay)
CloneCycle()
return
..()
mob
proc
Attack2(mob/M)
if(!M.KO)
if(src.KO==1)
return
var/damage = Str
M.TakeDamage2(src, damage)
else return
TakeDamage2(mob/attacker, damage)
if (attacker.client)
return
else
if(src.followblock == 0|1)
src.Hp -= damage
s_damage(src,damage,"red")
if(src.Hp <= 0)
src.DeathCheck(attacker)


Problem description:
I want to have it so this only attacks 1 person not a whole group at 1 time. like it does now...
hey do u need to icon too?
In response to Peteragent5
Stay on topic please, I still need help for this code and I don't need icons, I have an Iconer...
your problem is that you are looping through each mob in oview and taking a step twords each valid mob each loop.

What you need to do is add a "target" var to the clone, give the clone a valid target and have the clone chase/atack its target until it is either dead or out of range.

once this happens, find another valid target for the clone.

keep doing that untill the clone is dead or whatever else will stop it from going through its CloneCycle().
In response to LawkJaw
mob
CloneCycle()
if (client || isDead())
return
var/action_taken
if(src.target)
if(src.target in oview(1))
Attack2(src.target)
action_taken = 1
if(src.target in oview(9))
walk_towards(src,src.target,1)
action_taken = 1
for (var/mob/other_mob in oview(9,src))
if(istype(other_mob, /mob/monsters/))
if(!src.target)
src.target = other_mob
action_taken = 1
for (var/mob/other_mob in oview(100,src))
if(!action_taken&&!followblock&&!follow)
step_to(src, src.owner, 2)
action_taken = 1
if(action_taken)
spawn(lifecycle_dalay)
CloneCycle()
return
..()
mob
proc
Attack2(mob/M)
if(!M.KO)
if(src.KO==1)
return
var/damage = Str
M.TakeDamage2(src, damage)
else return
TakeDamage2(mob/attacker, damage)
if (attacker.client)
return
else
if(src.followblock == 0|1)
src.Hp -= damage
s_damage(src,damage,"red")
world << "attacked"
if(src.Hp <= 0)
attacker.target = null
src.DeathCheck(attacker)
else
src.Attack2(attacker)


I tested it like this, It works but only if I'm next to it...
In response to 666MadMike666
mob
CloneCycle()
if (client || isDead())
return
var/action_taken
if(src.target)
if(src.target in oview(1))
Attack2(src.target)
action_taken = 1
if(src.target in oview(9))
walk_towards(src,src.target,1)
action_taken = 1
else
for (var/mob/other_mob in oview(9,src))
if(istype(other_mob, /mob/monsters/))
src.target = other_mob
action_taken = 1
//you already found a target, stop the loop
break
//wth is this???? youre looping through all the mobs in oview(100) just to step_towards(owner)? no good
/*for (var/mob/other_mob in oview(100,src))
if(!action_taken&&!followblock&&!follow)
step_to(src, src.owner, 2)
action_taken = 1*/

//heres a fix
if(!src.target&&!followblock&&!follow)
walk_to(src,src.owner,1,2)
if(action_taken)
spawn(lifecycle_dalay)
CloneCycle()
return
..()
In response to LawkJaw
Thanks, That worked now I only have 1 small problem, Do you know a way to override a sleep in the deathcheck so that it will wait for the monsters to respawn but it doesn't wait to attack other monsters...

mob
proc
DeathCheck(mob/killer)
if(src.Hp <= 0)
if(src.father=="clone")
var/mob/D = src.owner
if(src.mother=="[D.key]")
D.Clones -= 1
D << "[killer] killed your Splitform"
del (src)
if(istype(src,/mob/NPC/))
killer << "You cant kill NPC's"
return
if(!src.client)
killer << "you killed [src]"
killer.Exp += src.ExpGive
killer.Gold += src.GoldGive
killer.levelcheck()
s_damage(killer,src.ExpGive,"green")
src.loc=locate(0,0,0)

sleep(100)

if(src.type == /mob/monsters/Slime/)
new /mob/monsters/Slime (locate(xwar,ywar,zwar))
del(src)


if(src.client)
src.Hp = src.Hpmax
src.loc=locate(25,8,1)
killer.Exp += src.Hpmax - src.Def -src.Sp
src.save = 1
world << "[killer] killed [src]"
killer.levelcheck()

Edited:Had a sentance that was strange..
In response to 666MadMike666
I dont see any problem there as to src not being able to attack during that sleep. As long as its attack instructions arent in DeathCheck below Sleep, it should attack just fine.
In response to LawkJaw
Found the problem, Its fixed. Thank you for your help.