ID:169641
 
Okay, I want this skill to kill clones not players.It will kill any clone in a 5 tile radius.I just want an example not the whole darn code, I want to learn how to it msyelf you know XD.
Pseudo code then.
mob/proc/killclone()
for(mob in view 5)
if(mob doesn't have a client and is a clone)
kill mob
else
continue the loop
In response to Hell Ramen
Before I start trying on my own,explain the code please so I can understand.
In response to Broly103
Broly103 wrote:
Before I start trying on my own,explain the code please so I can understand.
mob/proc/killclone()
for(mob in view 5) //Checking to see if a mob is in view.
if(mob doesn''t have a client and is a clone) //If the mob doesn't have a client and is a clone
kill mob //Delete them
else //If they don't...
continue the loop //Self explanitory
In response to Hell Ramen
obj/illuminate
verb
Illuminate()
set category = "Dojutsu"
for(mob in view 5)
if(M)
del(M)
else
continue

Am I close XD?
In response to Broly103
Broly103 wrote:
> obj/illuminate
> verb
> Illuminate()
> set category = "Dojutsu"
> for(mob in view 5)
> if(M)
> del(M)
> else
> continue
>

Am I close XD?

Not even.
obj/illuminate
verb
Illuminate()
set category = "Dojutsu"
for(var/mob/M in view())
if(!M.client&&M.clone)
del(M)
else
continue
In response to Hell Ramen
That else is completely useless. It's a common mistake to try and hang an else off of every if(). Remember, if it doesn't do anything, then chances are, it doesn't belong there.

obj/illuminate/verb/Illuminate()
set category = "Dojutsu"
for(var/mob/M in view())
if(!M.client && M.clone) del(M)
In response to Wizkidd0123
In addition to the above, if a 5-tile radius is actually desired (as in, a circular region), then you'd need some additional math in there to be sure this falls within a circle. Otherwise, the effect will be an 11×11 square if you just use view(5). To make it a circle, you'd need this:

for(var/mob/M in oview(5))
var/dx = M.x - x
var/dy = M.y - y
/*
Find distance**2 which is dx*dx+dy*dy. If it is more than
(radius+0.5)**2, it is outside the circle. A good approximation
of (radius+0.5)**2 is radius*(radius+1), which here is 5*6=30.
*/

if(dx*dx + dy*dy > 30) continue
if(!M.client && M.clone)
// kill M; tell it who killed them
M.Die(usr)


That will produce a nice circular effect.

Lummox JR