verb
Fight(mob/M)
if(!M.client)
return
if(istype(M,/obj))
return
if(istype(M,/turf))
return
else
flick("punch",src)
var/damage = (src.str - M.def)
if(damage <= 0)
damage = 1
if(M.power == "Hawkins")
for(var/mob/B in M.basils)
if(!B)
M.hp -= damage
s_damage(M,damage,"red")
M.Health_Bar()
M.NDeath()
return
else
B.hp -= damage
s_damage(B,damage,"red")
B.Health_Bar()
B.NDeath()
return
Problem description:
First let me tell you what im trying to do:
EDIT: The fight(mob/M) is for NPC's.
Basically when someone attacks this player, i want it to check if there is any mob(s) in the list called basils. if there is, i want the damage to be redirected to one of the mobs in the list. Now this seems to be working fine, however, once the mob that the damage got redirected to is dead, he is removed from the list. and when there are no mobs in the list, i want the player himself to get the damage. however, the way i have set it up here, makes the player unhittable :P.
Probably because if(!B) is rubbish, what i want is for it to check for mobs, and if there are none, do damage to the player, if there are, redirect the damage.
so how do i check if it is empty if !B isn't the right way?
I also noticed that if you just want to tell if an object within a radius is a mob, you don't need to test if that object is an object or a turf, since your only interested in testing for other mobs.
Idk if any of that helps you any but it may be a start.