ID:139250
 
Code:
mob                                         //This and the following proc should work
NPCs //as far as I know, with my limited knowledge...
Number_1 //but I get a runtime error with it.
icon='Enemies.dmi' //runtime error: Cannot read null.x
icon_state="#1" //proc name: BossFight1 (/mob/proc/BossFight1)
name="#1" // usr: JS173 (/mob/DM)
verb // src: #1 (/mob/NPCs/Number_1)
Challenge() // call stack:
set src in oview(1) //#1 (/mob/NPCs/Number_1): BossFight1(null, 1)
usr<<"Challenging me?! Insolent Fool! Prepeare to die!" //#1 (/mob/NPCs/Number_1): Challenge()
spawn(10)
BossFight1()
return



proc
BossFight1(var/mob/M,s as num)
switch(input("Will you fight?","BOSS") in list("Yes","No"))
if("Yes")
var/boss=0
var/turfs=list()
s=1
M.OldX=M.x
M.OldY=M.y
M.OldZ=M.z
M.loc=locate(rand(75,76),rand(235,236),30)
M.kp+=s
for(var/turf/arena_turf/boss/T in orange(30,M))
turfs+=T
for(boss = 0, boss !=s, boss++)
var/turf/T=pick(turfs)
new/mob/Monsters/bosses/Number_1(T)
else if("No")
usr<<"Get out of here then!"
..()




BurnProc(mob/P)                         //following the example of my other skill
for(var/mob/M as mob in oview(3))
var/b
var/s
var/n
var/t=round(P.wis*0.25)
var/damage
if(usr.mp>=250 && usr.angerused==3)
n=250
b=rand(330,450)
s=rand(25,38)
damage=round(P.totalwis-(M.totalwis+(M.totaldex/2))*0.75+rand((usr.hateful*0.2),(usr.hateful*0.5)))
if(P.emotion1=="Anger")
var/mob/S=new/mob/skills
P.mp-=n
S.icon_state="burn"
S.loc=M.loc
if(damage<1)
damage=1
P<<"You hit [M] for [damage] damage!"
M.hp-=damage
M.Deathcheck()
del S
spawn()
P.ClearEmotions()
for(b != 0) //this doesn't count the use of the vars in the compiling for some reason (b,s,and t)
spawn(s) //it always says they're defined but not used.
b-=s //but obviously, I'm using them, I tried with an if() instead of for(),
if(b<0) //but that actually gave errors, not just warnings.
b=0 //can you see what's wrong? is it the for() because it's already in a for() loop?
M.hp-=t //or is there something else wrong? I appreciate the help.
M.Deathcheck()
break
else
P<<"You couldn't use that skill."
..()
break

Problem description:

I look, and I look, and I, as unexperienced at coding as I am, can't see the problems with the codes.

while the code has notes I made, I will spell the problems out here as well.

the first code, is for a boss fight, it uses code almost exactly like my random encounter procedure(which works, until multiple people call it, then it traps one of the players there), but it gives a run-time error(in the notes of the code) when you talk to the boss to start the fight.

and the second code, is for a skill, it once again uses code similar to another thing of code, the problem is that when I have both skills active, they only do 1 damage when they should be doing around the 20-100 range, and the burn effect(basically poison) isn't working at all.

I appreciate help, I had help before, which is mostly how I made the skill code, though the encounter code was all me(and a few references), but I lost contact with my 'mentor' as it were.

my requests are, simply, point out what the problems are, and if you'd be so kind, perhaps a fix, pointing them out and explaining the problem would probably be sufficient though.I'd also like to pose a purely selfish request, that is in no way necessary, perhaps tell me where in the code for the boss fight it messes up the return for multiple players.
Thank You
In your first instance, the error is because your proc takes an argument, M, and then attempts to access M.x. However, no argument is passed, so M is null, and so you get a null.x error. You need to pass appropriate arguments.

For the second error, it's because you are never ASSIGNING a value to b, so any attempt to actually use it is somewhat meaningless. s and t might trigger the warning because they are behind unreachable code: the code inside the for(b != 0) block cannot ever execute, as b will always be null (evaluating to 0 for numerical operations).

Speaking of which: you should not be using a for() loop there at all. Look up what they are actually used for in the Reference.
In response to Garthor
so, in the first one, it's more or less a simple missing argument?
    proc
RandomEncounter1(var/mob/M,s as num)
if(prob(rand(2,5)))
var/enemies=0
var/turfs=list()
s=rand(1,5)
M.OldX=M.x
M.OldY=M.y
M.OldZ=M.z
M.loc=locate(rand(10,11),rand(240,241),30)
M.kp+=s
for(var/turf/arena_turf/arena1/T in orange(20,M))
turfs+=T
for(enemies = 0, enemies !=s, enemies++)
var/turf/T=pick(turfs)
new/mob/Monsters/Werewolf(T)


this is my regular Random encounter, it works fine-ish so I added a thing or to to try and make it called by a verb(basically, I used the bad habit of copy/paste, with a few changes) would the problem with the other code, the missing argument, be because it's called through the verb, instead of just the procedure? or am I completely off?

b=rand(330,450) <-- is this not defining b?

I'll look through the resources about the for() loop(and maybe even revise a little on the blue book as well).
In response to JS173
My mistake: the error is entirely in your use of for(). The way you have it written is totally incorrect, and the compiler is kinda-halfway catching that.
In response to Garthor
so, my for loop in the skill is the problem? or are you talking about the boss fight code? you aren't entirely clear there.

if it's the skill, I'm not surprised, since I made that bit of code myself, very low quality stuff, seeing as how low my experience is...but the same goes for the encounter, since I did that myself too...:/ getting past these code problems would complete 3 objectives for me, 1) getting them fixed(obviously), 2) allowing me a couple examples of how to do something to help keep me from making the same mistake(experience, always good ^.^), and 3) allow me to attempt to add some other things in, after having sat on these things for so long xD

all this help is appreciated, it'll definitely help me achieve my goals, however slowly I progress.