obj/projectile
var/damage=0
var/owner
var/odir
var/delay=3
proc/Effect(mob/A)
A.hp -= damage
A.mhp += damage/2
viewers(A) << "[A] has been hit by [src.owner]'s spell!"
A.Deathcheck()
Incendio
icon='attacks.dmi'
icon_state = "fireball"
oicon='attacks.dmi'
oiconstate="fireball"
density=1
damage=15
luminosity=3
Bump(A)
if(ismob(A))
Effect(A)
if(A.cfire==1)
src.damage=0
if(A.hice==1)
src.damage=30
..()
del src
else
viewers(A) << "[A] has been hit by a poorly aimed spell!"
del src
mob/var
cfire=0
hice=0
Problem description: Okay, when I compile I get the following error:
Programming\Objects-Turf.dm:369:error:A.cfire:undefined var
Programming\Objects-Turf.dm:371:error:A.hice:undefined var
Around the:
if(A.cfire==1)
src.damage=0
if(A.hice==1)
src.damage=30
And am not completely sure why. Can somebody please tell me what I'm doing wrong?
So in your case, var/A is a variable of no particular type. ismob(A) returns true because it does contain a /mob, but you can only use A as the type it is (un-typed). You can get around this by type-casting:
Basically, we're not changing that actual 'thing' at all by doing this, we're just changing the way we look at it. It was a /mob all along (hence ismob(A) returns true), the code just never looked at it as a /mob until we type-casted it.