ID:1863489
 
Code:
mob
proc/HitPlayer(var/mob/player/M,var/mob/enemies/E)
var/damage = round(src.Str)-(M.End)
if(damage>=0)
Miss()
return
if(prob(90))
M.HP -= damage
M << "The [src] has attacked you for [damage] damage!"
checkdeadplayer(M,src)
else Miss()
proc/Miss(mob/player/M)
M << "The [src] has missed you!"

proc/checkdeadplayer(var/mob/player/M,var/mob/enemies/E)
if(M.HP <= 0)
usr << "You were killed by the [E]"
usr.loc = locate(/turf/teleports/storymap)
M.HP = M.MaxHP
M.MP = M.MaxMP
mob/enemies
Bump(atom/M)
if(istype(M,/mob/player)) // If they run into the player
HitPlayer()
icon = 'monsters.dmi'
layer = MOB_LAYER-1
slime
icon_state = "slime"
name = "Slime"
areaGroup = "Enemy"
HP = 10
MP = 0
Str = 3
End = 2
Spd = 2
Lck = 2
Int = 0
Exp = 3
Speed = 15
New()
..()
spawn(1)Wander(Speed)



Problem description:


The slime wanders, and attacks when a player is stumbled upon. That world all fine and well. The issue is that when the slime bumps the player I get a runtime error claiming it can't read a null.Str. I've tried adjusting notation (src, var/enemeies/E, etc)
Any tips? This is frustrating >.>


try changing HitPlayer to src.HitPlayer under the if check under bump.
No dice. This is the runtime I received this time as well as the last couple tries.


runtime error: Cannot read null.End
proc name: HitPlayer (/mob/proc/HitPlayer)
usr: Slime (/mob/enemies/slime)
src: Slime (/mob/enemies/slime)

"Cannot read null.End"

This refers to the 2nd line,

var/damage = round(src.Str)-(M.End)

M is null, because this proc is getting passed with no arguments.

HitPlayer() under mob/enemies/Bump() should be called with the mob and the enemy.

HitPlayer(M, src)

How ever, there is glowing methodology errors in this bit of code.

You treat HitPlayer like a class object proc, but you pass it arguments like it's a functional proc.

for HitPlayer, should src refer to the player getting hit, or the thing hitting the player, because one of those arguments aren't needed.

also, if(damage>=0)

"If damage is higher than or equal to 0, miss." Something tells me you might have that backworks
Additionally, you have usr abuse in your procs. A proc is not an appropriate place for usr; it's really only relevant to verbs and to pseudo-verbs (procs that are only ever called by verbs).

The checkdeadplayer() proc is built incorrectly. You should be calling it as M.checkdeadplayer(src), and the proc itself should look like this:

    proc/checkdeadplayer(var/mob/enemies/E)
if(HP <= 0)
src << "You were killed by the [E]"
loc = locate(/turf/teleports/storymap)
HP = MaxHP
MP = MaxMP

In a death check, src should always refer to the mob that's (potentially) dying, not to the attacker. The attacker should go in as an argument.
Thank you guys, I appreciate the input!