mob
proc
Deathcheck()
if(src.Hp <= 0)
if(istype(src.client))
src << "You have died, [usr] killed you!"
usr << "You killed [src]"
src.loc = locate(1,1,2)
mob
verb/Attack(mob/M in oview(1))
set category = "Battle"
var/damage = src.Str - M.Rfx
if(M.client)
M.Hp -= damage
src <<"You attack [M] for [damage]!"
M <<"You are being attacked by [src]!"
src.Levelup()
M.Deathcheck(src)
else
M.Hp -= damage
src <<"You attack [M] for [damage]!"
M <<"You are being attacked by [src]!"
var/random = rand(1,3)
if(random == 1)
src.Exp += 4
if(random == 2)
src.Exp += 3
if(random == 3)
src.Exp ++
src.Levelup()
M.Deathcheck()
obj
Fireball
icon='fireball.dmi'
mob/verb
StraightAttack()
var/obj/Fireball/A=new(src.loc)
A.dir=src.dir
var/dmg=usr.Str-src.Rfx//Set damage equations here
var/mob/M=Projectile(src,A,5,dmg,2,0,0,0,0,0)
if(M==1)
//You could show stop animation here, this means that it ran out of distance.
del(A)
else if(M)//If hit
world<<"[src.name] hit [M.name] for [dmg]!"//Set damage procs here.
del(A)
M.Deathcheck()
HomingAttack()
var/list/L=list()
for(var/mob/M in oview(6,src))
L+=M
var/mob/H=input(src,"Who?") in L//If homing, who to hit? XD
var/obj/Fireball/A=new(src.loc)
A.dir=src.dir
var/dmg=usr.Str-src.Rfx
var/mob/M=Projectile(src,A,5,dmg,2,1,0,H,0,0)
if(M==1)
del(A)
else if(M)
world<<"[src.name] hit [M.name] for [dmg]!"
del(A)
M.Deathcheck()
//I'll explain the first one, the rest should be self explanitory.
proc/Projectile(mob/M,obj/O,distance,dmg,delay,Homing,Area,mob/H,duration,radious)//Set all your values here, M=usr, O=obj called upon, distance=distance in tiles, delay=delay between movements, homing/area=if homing/area 1 on true 0 on false, H = hommed upon, duration if area in seconds, radious in tiles if area.
if(Homing&&H)//If its homing, and someone to home apon
while(distance>0&&O&&M&&H)//whiole there is someone to home, its not travled distance, obj still here, and usr is.
var/mob/target//Set a target if hit
O.dir=get_dir(O,H)//sets the obj dir to face H
for(var/mob/A in get_step(O,O.dir)) //for every mob in 1 step in front of you
if(A&&A!=M&&ismob(A))//if there is one, and if its not you and its a mob
target=A//target it for attacking
step_towards(O,H)//step towards the H(Being homed)
sleep(delay)//wait the delay
distance--//take away a distance in tiles travled
if(target) return target//If a target was hit, return and set the target attack to him
if(M&&O&&H)//If everything here
return 1//return 1, which means stopped.
else if(!H&&M&&O)//If everyone but H is here
Homing=0//Attack isnt homing
Projectile(M,O,distance,dmg,delay,0,0,0,0,0)//and continues to move forward
else if(Area)//If an area attack
while(duration>0&&O&&M)
duration-=1
var/list/mob/targets=list()
for(var/mob/S in oview(radious,O))
if(S!=M)
targets+=S//sets mobs in the target list to attack
sleep(10)
if(targets) return targets
else
while(distance>0&&O&&M)
var/mob/target
for(var/mob/A in get_step(O,O.dir))
if(A&&A!=M&&ismob(A))
target=A
step(O,O.dir)
sleep(delay)
distance--
if(target) return target
if(M&&O)
return 1
mob
human
icon='human.dmi'
src.Deathcheck()
Problem description:
ok well im trying to make a guy in my game die when his hp hits 0. ok i got death check so when he hits 0 he dies. so i made a mob just to try it out. now whenever i hit him withmore then 100 damage he still doesnt die..even tho his mob/var/Hp=100 .. heres a code
if(istype(src.client))
Which should be:
if(src.client)
With the ultimate code being:
Ugh thanks to DoS for pointing out an embarrassing mistake. ;P