ID:155334
 
I was curious about makeing a damage proc for my game the way I have it set up now is really not working out so well becuse the Die proc is called after the attack is finished so no matter what the enemy hp they die after the attack verb is finished
mob
verb
Attack()
set name = "Attack"
for(var/mob/M in get_step(src,src.dir))
if(!src.canattack) return
src.canattack = 0
canattack = 1
flick("attack",usr)
var/damage = round(usr.tai*1.5)
damage+=rand(1,damage)
if(damage <= 0) view(src.client.view,src) << "<i>[src] misses [M]!"
else
M.health -= damage
view() << "<i>[src] attacked [M] for [damage] damage!"
M.Die(src)//calls the die proc
if(random == 5||random==1)
usr.strxp+= rand(1,3)
usr.strlu()
usr.exp += rand(20,30)
usr.LevelUp()
sleep(2)
usr.canattack=1

not to mention that the attack always hits no matter what when its clearly showing it should miss sometimes but I think that could be fixed by a probability unless there is a better way
Make sure your death proc checks if their stamina is below 1.
You should check for random hits before doing any actual damage.

switch(rand(1,5))
if(1) //hit, the rand() can be based off accuracy.


Also, make sure that the die() proc checks the health before doing anything, or better yet, check the health before the proc is called.

if(M.health<=0) M.Die(src)


This way you won't call the proc until it's necessary. Hopefully this helps.
In response to Bravo1
That random stuff is for randomly gaining strength experience to level up his strength stat, not random hits.
In response to Neimo
thanx for the info hopefully this helps ill try it out this evening