ID:154943
 
Again I have a problem here, sorry for the many questions. I have a code that makes bunshins, but it gives the same deathcheck to bunshins as for normal mobs, I want them to disappear instead of reviving, here follows the code of the attack I used, and the bunshins:

mob
proc
Createclones()
var/mob/clone = new(usr.loc)
clone.icon=usr.icon
clone.HP = 1
Deathcheck()
if (HP <= 0)
world << "[src] died!"
src.loc = locate (2,2,1)
src.HP = src.MaxHP
src.MP = src.MaxMP
verb
Bunshin()
Createclones()
Fire_Dragons_Iron_Fist()
set category = "Battle"
if (usr.MP >= 10)
var/obj/Firefist/F = new(usr)
walk(F,usr.dir,2)
usr.MP -= 10
usr.SlayerExp += 0.1
usr.Slayercheck()
sleep(30)
del F
else
usr << "You don't have enough Mana Points."
return


Can anyone help me out with this? I would really appreciate it :3.
mob
proc
Createclones()
var/mob/clone = new(usr.loc)
clone.icon=usr.icon
clone.HP=1
Deathcheck()
if(src.HP<=0)
if(istype(src, /mob/clone))
del(src)
else
world<<"[src] died!"
src.loc = locate(2,2,1)
src.HP=src.MaxHP
src.MP=src.MaxMP


I'm a bit tired, so I may have made an indentation error or something, but this should work.
Deathcheck() is attributed to /mob, meaning all things that are of the type /mob use the the base Deathcheck() unless overwritten.

Here's an example on how to deal with it:

mob
proc
die()
world << "dead"
loc = locate(1, 1, 1)

dude
die()
world << "dude died"

..() //Will call the parent afterwards, meaning it'll display "dead" to the world and move you to 1, 1, 1.

clone
die()
world << "clones have no souls"

del src
//Since we didn't use ..() to call the parent, this instance of die() applied to /mob/clone overwrites the default die() check for /mobs.
In response to Shaoni
Hmmm... Seeing the code it'll work, but it gives an error that /mob/clone doesn't exist =.=... Tried to solve it myself but then it went even more wrong then before, the one error after another xD. I guess I'm too inexperienced, but I want to learn it this way, I know the basics, only this... :s...
mob/verb/RangedAttack(mob/victim)
//do the attacky stuff
var/damage=usr.ninjutsu*1.2
victim.DeathCheck(usr,damage)

mob/proc/DeathCheck(mob/attacker, damage)
..()

mob/player/DeathCheck(mob/attacker, damage)
src.health-=damage
if(src.health<=0)
//kill, respawn, whatever
world<<"[attacker] killed [src]!"

mob/clone/DeathCheck(mob/attacker, damage)
src.health-=damage
if(src.health<=0)
del(src)
//note that its probably bad news to just delete src outright as the proc will crash as soon as you do.


Thats the basic version of my system; and it works quite well. Allows for custom death checks and is easy to manage.

But like shaoni's suggestion you'll get an error because player type and clone type dont exist.
To fix this you need to create bunshins as a clone type, and when players create their char, they need to be player type.
I cant remember how to do it for players, but basically, define and call bunshins like this:

mob/clone
Bunshin
icon='icon.dmi'
health=1

mob/verb/makebunshin()
var/mob/clone/Bunshin/B=new(usr.loc)
B.health=100
B.creator=usr
B.overlays=usr.overlays
In response to Kimmiehier
Since you're creating a mob/clone (The bunshin), then it should definitely be defined. o.+ If not, the problem may lie in that.
In response to Saucepan Man
It works :D. Thanks, now I can finally make it the way I like since I understand it now ^^.