ID:273552
 
obj/Fireball
icon='Fireball.dmi'
density=1
Bump(A)
if(ismob(A)||(isobj(A)&&istype(A,/obj/Destructable)))
var
damage; MagicDamage; FireDamage
if(isobj(A))
var/obj/M=A
FireDamage=src.Fire-(M.Water*0.7) //target's water element works as defense against fire
MagicDamage=src.MagicPower-(M.MagicPower*0.12) //target's own skills in magic act as defense, too
if(ismob(A))
var/mob/M=A
FireDamage=src.Fire-(M.Water*0.7)
MagicDamage=src.MagicPower-(M.MagicPower*0.12)
damage=round(MagicDamage+FireDamage)*1.9
if(damage<1) damage=1 //I don't believe in 0 damage for successful hits...
if(ismob(A))
var/mob
M=A; O=src.Caster
src.loc=M.loc //so it can keep travelling past the person
if(M.MagicShield) del(src)
if(O.FriendlyFireCheck(M)) viewers(6,M)<<"<i>[M] was hit by [O]'s Fireball for [round(damage)] damage!</i>"
M.Death(O,damage,src)
src.MagicDamage*=0.3; src.FireDamage*=0.4 //weaken the attack because it's used it's magic damaging the current target
if(src.MagicDamage<5||src.FireDamage<5) del(src) //delete it if it doesn't have much power left
else
var/obj/M=A
src.Destroy(damage); del(src)

if(istype(A,/turf/))
var/turf/T = A
if(T.density) del(src)
if(istype(A,/obj/))
if(isobj(A))
var/obj/o = A
if(istype(o,/obj/Jutsu)) JutsuClash_Water(src,o)
else if(istype(o,/obj/weapon)) del(o)
else del(src)


obj/Destructable
proc/Destroy(damage)
src.HEALTH-=damage
if(src.HEALTH<=0) del(src)


The above code works; and I do know how I would go about implementing this system into my project.
But it seems to be tragically inefficient. I've got the exact same damage calculation done once each for objects and mobs, and am checking twice to see what kind of atom it is (obj|mob).
It'd be nice to be able to just go:
        if(ismob(A)||(isobj(A)&&istype(A,/obj/Destructable)))
var
damage; MagicDamage; FireDamage
if(isobj(A)) var/obj/M=A
else if(ismob(A)) var/mob/M=A
FireDamage=src.Fire-(M.Water*0.7)
MagicDamage=src.MagicPower-(M.MagicPower*0.12)
damage=round(MagicDamage+FireDamage)*1.9
if(damage<1) damage=1

Esp. since I have to add this type of coding into about 40+ different objs' Bump() proc.
EDIT: Oh, I should try using var/atom or something.
Even then though, the whole system still seems overly clunky.
atom
area
turf
movable
obj
mob
In response to Garthor (#1)
Is this a solution or a reason why it won't work? o_o'
In response to Saucepan Man (#2)
It's a hint at a solution. As you can see, /atom/movable is the parent of both /mob and /obj. You can share stuff between mobs and objs by defining them under /atom/movable.