ID:267588
 
here's my code:
mob
AI
icon = 'mob.dmi'
proc
checkspeed(obj/weapon/O in oview(1))
O.sleep = O.speed - O.delay
if(O.sleep < 0)
O.sleep = 0
sleep(O.sleep)
kill()
kill(mob/M in oview(),obj/weapon/O in oview(1))
M.health -= O.damage
checkdead(M)
checkdead(mob/M)
if(M.health < 1)
M << "BANG! You're dead!"
usr << "BANG! You kill [M]!"
usr.kills ++
else
..()

and here's my error:
 
runtime error: Cannot read null.speed
proc name: checkspeed (/proc/checkspeed)
usr: Dragon of Ice (/mob)
src: null
call stack:
checkspeed(null)
Machine Gun (/obj/weapon/gun/Machine_Gun): shoot()

so what is the problem?
Since Lummox JR doesn't seem to be here.....
No put usr in procs. Ungh.
The problem is that you are using usr in procs. Oh, and you are quite obviously giving us the wrong snippet of code.
It can't read null.speed, and the only time you reference speed is when you refer to O.speed, so I am guessing that O is null. So, you probably never passed an object as a parameter to checkspeed().
In response to Garthor
Whoops...I thought that src might refer to O being an obj...I'll post the obj code and change the usr to src...
In response to Dragon of Ice
Since this code really isn't that long, or important, I'll just put up everything. I'm sure it won't matter.
runtime error: Cannot read null.speed
proc name: checkspeed (/proc/checkspeed)
usr: Dragon of Ice (/mob)
src: null
call stack:
checkspeed(null)
Machine Gun (/obj/weapon/gun/Machine_Gun): shoot()


obj/weapon
verb
shoot()
set src in oview(1)
checkspeed()
var
delay as num
speed as num
damage as num
sleep as num


obj/weapon/gun
Rifle
icon = 'rifle.dmi'
delay = 20
speed = 40
damage = 7
obj/weapon/gun
Revolver
icon = 'revolver.dmi'
delay = 30
speed = 20
damage = 5
obj/weapon/gun
Machine_Gun
icon = 'machine gun.dmi'
delay = 1
speed = 20
damage = 12


proc
checkspeed(obj/weapon/O in oview(1))
O.sleep = O.speed - O.delay
if(O.sleep < 0)
O.sleep = 0
sleep(O.sleep)
kill()
kill(mob/AI/M in oview(),obj/weapon/O in oview(1))
M.mealth -= O.damage
checkdead(M)
checkdead(mob/AI/M, mob/A)
A = src
if(M.mealth < 0)
M << "BANG! You're dead!"
A << "BANG! You kill [M]!"
A.kills ++
else
..()

mob
icon = 'mob.dmi'
var
health
constant
kills = 0
Login()
..()
src.constant = rand(100,200)
src.health = src.constant
mob
Stat()
statpanel("Info")
stat("Kills:",src.kills)
stat("Health:","[src.health]/[src.constant]")


mob
AI
icon = 'mob.dmi'
var/mealth
In response to Dragon of Ice
Dragon of Ice wrote:
> runtime error: Cannot read null.speed
> proc name: checkspeed (/proc/checkspeed)
> usr: Dragon of Ice (/mob)
> src: null
> call stack:
> checkspeed(null)
> Machine Gun (/obj/weapon/gun/Machine_Gun): shoot()

Just by looking at that, from the shoot() proc you are calling checkspeed(), but checkspeed has a parameter that you are not passing it. The parameter is O, but you you don't send it anything, so O is null, and it cannot read null.speed.
In response to Dragon of Ice
You haven't actually yet divested your procs of usr; you're still using things like view(1) instead of view(1,src). Since usr is the default point of reference for view() and such, you're still using it.

But I highly question why you're doing things like this:
proc
checkspeed(obj/weapon/O in oview(1))
Unless this is going to be assigned to players as a verb, the "in oview(1)" clause is pointless. Get rid of it. The same goes for your kill() proc.

Lummox JR