ID:144081
 
Code:
obj/Arrow
icon = 'weapons.dmi'
icon_state="Arrow_Moving"
density = 1
Bump(atom/a)
if(ismob(a))
if(a.icon=='ENEMIES.dmi')
a.hp-=25
del(src) else
del(src)


Problem description:

For some reason, when I try to compile my code, it gives me this error:

Weapons.dm:154:error:a.hp:undefined var

I'm not completely sure why it does this, if you can help me, I'd appreciate it.
Read about typecasting. hp (I assume) is a mob/var - a variable that mobs have. However, you've told the compiler that a contains an /atom, which doesn't have the hp var. You need to typecast a as a /mob, not an /atom, so the compiler will let you use a mob var.
In response to Kaioken
I see what you mean. I tried to edit my code:

obj/Arrow
icon = 'weapons.dmi'
icon_state="Arrow_Moving"
density = 1 //This object must be dense for this to work!
Bump(atom/a) //If the object hits anything.
del(src) //Deletes the object.
Bump(mob/b)
if(b.isplayer==0)
b.hp-=25
del(src) //Deletes the object.
else
del(src)


But when I hit a wall, I get this runtime error:

runtime error: undefined variable /turf/Wall/var/isplayer
proc name: Bump (/obj/Arrow/Bump)
source file: Weapons.dm,154
usr: 0
src: Arrow (/obj/Arrow)
call stack:
Arrow (/obj/Arrow): Bump(Wall (8,292,1) (/turf/Wall))
Arrow (/obj/Arrow): Fire(Arrow (/obj/Arrow))
{OWNER} Mikal (/mob/character): Fire()

I didn't think it would question isplayer because the Bump(mob/a) should only apply to collisions with mobs correct?
In response to Michael3131
Typecasting (var/mob/m, var/turf/t, etc) doesn't force an argument to be that type, so don't assume so. Make sure you put safety checks in to make sure it's the type you're looking for (for this particular safety check, look up istype(), in the ref, or F1 in Dream Maker).
In response to Michael3131
You've a leftover override there. Also, the check 'Pop is talking about is actually done fine in the code in your first post (with ismob(x), which is basically istype(x,/mob)), all you needed to do was change the var (argument) definition.

And look up all of the procs/operators you've been told that you don't know or not sure how they work in the DM Ref. Also make sure you've looked things up before using them at any case.
In response to Popisfizzy
Ah, it works now! (Thanks for the argument info!) ^_^
In response to Michael3131
Hey, um, I have a small problem. After it checks if it's not a player, and subtracts health, I tried to call a proc, death_check(). The problem is, death_check() is a mob proc. Is there a way I can call this proc from my arrow? Here's the new code:

obj/Arrow
icon = 'weapons.dmi'
icon_state="Arrow_Moving"
density = 1 //This object must be dense for this to work!

Bump(mob/b)
if(ismob(b))
if(b.isplayer==0)
b.hp -= 25
death_check()//The Proc
del(src) //Deletes the object.
else
del(src)
else
del(src)
In response to Michael3131
It's as easy as b.deathcheck.
In response to Speedro
Ah I see. Thanks!
In response to Michael3131
Ok! One last problem! I'll show the code first:

obj/Arrow
icon = 'weapons.dmi'
icon_state="Arrow_Moving"
density = 1
Bump(mob/b)
if(ismob(b))
if(b.isplayer==0)
b.hp -= 25
b.death_check()
else
del(src)
else
del(src)


obj/proc/Fire(var/obj/O
var/L
var/PL
start
PL = L
step(O,O:dir
L = O:loc
sleep(10)
if(PL == L)
del(O)
else
goto start

mob/verb/Fire()
var/obj/O = new /obj/Arrow(usr.loc)
O:dir = usr.dir
O:owner=usr.key
O:Fire(O)

Arrow Coding

    proc/death_check(mob/M as mob)//handles death
if(src.hp <= 0)
M <<"You killed [src]!"
if(src.client)
src <<"[M] killed you!"
src.loc = locate(7,290,1)
src.hp = src.maxhp
src.canbuild = 0
else
src <<"You have been killed by [M]!"
//var /obj/Crowns/A=new
var/YIN=rand(10,50)
src.loc=locate(0,0,0)
if(ismob(M))
M.crowns+=YIN
if(src.GOOGLEPLEX==1)
M.contents+=new/Items/Frog_Head
M<<"Congratulations! You got the Frog Head from the Evil Frog!!"
world<<"[M] has killed the Evil Frog!"
sleep(1200)
src.loc=locate(src.sx,src.sy,src.sz)
else
usr=M.owner
usr.crowns+=YIN
if(src.GOOGLEPLEX==1)
usr.contents+=new/Items/Frog_Head
usr<<"Congratulations! You got the Frog Head from the Evil Frog!!"
world<<"[M] has killed the Evil Frog!"
del(M)
sleep(1200)
src.loc=locate(src.sx,src.sy,src.sz)


I tried to edit the death_check proc to read the arrows variable owner, which would specify your key. When I kill an enemy, I get this runtime error:

runtime error: Cannot read null.owner
proc name: death check (/mob/proc/death_check)
source file: KingdomBuild.dm,1511
usr: 0
src: Frog (/Frogs/Normal)
call stack:
Frog (/Frogs/Normal): death check(null)
Arrow (/obj/Arrow): Bump(Frog (/Frogs/Normal))
Arrow (/obj/Arrow): Fire(Arrow (/obj/Arrow))
{OWNER} Mikal (/mob/character): Fire()

I believe it's because the arrow is deleted before it reads it. I don't see how as the del(M) code is at the very end!