var/target = ref
if(ismob(ref) || isobj(ref)) target = ref:loc
if(first) first.loc = target
if(second) second.loc = target
if(third) third.loc = target
if(fourth) fourth.loc = target
Problem description:
hi, how would i make this code loc onto the mob which it is fighting? at the moment whenever i fight someone the numbers float above my head, which is really innoying because i dont know if thats my hit. how can i make it so that my damage goes on the enemys head not mine
Something else you should change in your code is:
if(ismob(ref) || isobj(ref))
Both objs and mobs happen to belong to (be under, are a "child" of, etc) a node type called /atom/movable (which is in turn a child of /atom, of course). So you can replace that check with a single one (look up istype() as well if you're unaware of it):
if(istype(X,/atom/movable))