ID:147009
 
Lets see if I remember how to make this look right...
obj/Almighty
icon = 'warp.dmi'
New()
Almightypick()
var/obj/Almighty/A = new /obj/Almighty()
A.loc = locate(7,20,1)
del(usr)
obj/proc
Almightypick()
sleep(600)
var/list/pickfrom = list()
var/mob/M
for(M in world)
if(M.key)
pickfrom += M
var/mob/choice = pick(pickfrom)
world << "The Gods have chosen [choice] to gain a level!"
choice.exp += choice.exp_req
choice.levelup()


Okay. I think there is a problem with an object calling a proc on a mob... This all works until it gets to "choice.levelup()" and then it stops.

runtime error: Cannot read null.exp
proc name: levelup (/mob/proc/levelup)
usr: null
src: Cowdude (/mob/sage)
call stack:
Cowdude (/mob/sage): levelup()

But the levelup() proc works just fine whenever else I call it.
I'd change this:

var/mob/M
for(M in world)


to this:

for(var/mob/M in world)


With the original, even though you're creating M as a var/mob, when you just do an (M in world), it will grab everything, and I'm guessing not everything has an exp var. :) Hopefully this helps!
In response to Igmolicious
everything should have an exp var (because I wouldn't wanna type it out for every class) but I'll try that anyway
In response to Cowdude
Not quite. Its cut down the runtime proc to:

runtime error: Cannot read null.exp
proc name: levelup (/mob/proc/levelup)

All I changed was the above suggestion and I changed "+=" to "=" in the line where it used to say "choice.exp += choice.exp_req"

hmm

edit: Wait no I think Dream Seeker just decided to not post the rest of it because of all the runtime errors =P
In response to Cowdude
Hrm, sounds like the runtime error is coming from the levelup proc, which isn't listed here. Post the code for that, and we'll see if we can fix it up :)

[edit]

Oh yeah, also, make sure you're using src instead of usr, since by the error message, usr is null.
In response to Igmolicious
I'm going to try it with all the src's but, as you see, it takes a minute to call the proc so I'll post the level up proc if it doesn't work

Edit: Nope that fixed it right up =)