ID:261691
 
I know the attack verb doesn't work from my other post, but i get a runtime error when i attack the potions, which i don't want to effect. Heres the attacking verb...

obj
battling

icon= 'SpellIcons.dmi'
Axe
icon_state = "Soldier1"
New(Loc)
for(var/mob/M in Loc)
M.HP-= rand(10)
M.overlays += 'OwOverlay.dmi'
sleep(2)
M.overlays -= 'OwOverlay.dmi'
M.DeathCheck()

Heres the Runtime Error...

runtime error: Cannot read 0.HP
proc name: Entered (/turf/items/HP_Potion/Entered)
usr: 0
src: HP Potion (19,27,1) (/turf/items/HP_Potion)
call stack:
HP Potion (19,27,1) (/turf/items/HP_Potion): Entered(Axe (/obj/battling/Axe), Unknown Person (/mob))

Heres the verb...

mob
Soldier
verb
Action1()
if(src.Ammo <= 5)
src << "Not enough ammo to throw the Axe..."
else
view() << sound('AttackSword.wav')
src.Ammo -= 5
var/A = new /obj/battling/Axe (src)
walk(A,dir,0.1)
sleep(30)
walk(A,0)
del(A)

Can anybody tell me how to fix this problem?
Unknown Person wrote:
runtime error: Cannot read 0.HP
proc name: Entered (/turf/items/HP_Potion/Entered)
usr: 0
src: HP Potion (19,27,1) (/turf/items/HP_Potion)
call stack:
HP Potion (19,27,1) (/turf/items/HP_Potion): Entered(Axe (/obj/battling/Axe), Unknown Person (/mob))

Heres the verb...

The verb you showed is not turf/items/HP_Potion/Entered(), which is where your crash is happening. And it's obvious from the message that since usr is 0 and you're trying to read 0.HP, that you've got usr.HP in there and are therefore trying to use usr in Entered()--where it doesn't belong.

I very much wonder why you implemented potions as turfs instead of objs; there's no sensible reason I can think of to do that. Instead, you should simply override turf/Entered() to pick up such things automatically:
turf
Entered(atom/movable/A)
if(ismob(A))
var/mob/M=A
if(M.client) // a player
for(var/obj/O in src)
if(O.walkover) O.WalkOver(M)

obj
var/walkover // set to 1 for items you can walk on to get or trigger

proc/WalkOver(mob/M)
// do nothing by default

obj/HP_Potion
walkover=1
WalkOver(mob/M)
if(M.HP>=M.maxHP) return
M.HP=min(M.HP+10,maxHP)
M << sound('hppotion.wav')
del(src)

Lummox JR