ID:143396
 
Code:
area
bat_loc
var/inuse=0
New()
bat_loc_list+=src
mob
var
ox
oy
oz
trys=0
gauge=0
is_turn=0
defending=0
in_bat=0
var/bat_loc_list=list()
turf
bat_area_one
Entered()
if(usr.in_bat==0)
if(prob(25))
start:
for(var/area/bat_loc/BL in bat_loc_list)
if(BL.inuse==1)
bat_loc_list-=BL
if(bat_loc_list==null)
return
else
goto start
else
usr.ox=usr.x
usr.oy=usr.y
usr.oz=usr.z
usr.loc=BL
BL.inuse=1
usr.locked=1
usr.dir=WEST
var/mob/Monster
Monster=new/mob/Enemy/Sage
Monster.loc=locate(usr.x-4,usr.y,usr.z)
Monster.dir=EAST
usr.in_bat=1
usr.Initiate_Battle(Monster)
return
if(usr.in_bat==1)
return

mob
proc
Initiate_Battle(mob/Monster)
if(src.Agi>=Monster.Agi+1)
src<<"You Start"
src.Person_Battle(Monster)
if(Monster.Agi>=src.Agi+1)
src<<"Enemy Start"
Monster.Enemy_Battle(src)
return
Person_Battle(mob/Monster)
if(src.defending==1)
src.Def-=src.Def
src.Mdef-=src.Mdef
src.defending=0
src.x-=1
src.choice=input("What would you like to do?","Battle")in list("Attack","Defend","Run")
if(src.choice=="Attack")
src.x-=1
sleep(5)
src.x+=1
var/damage
damage = src.Atk-Monster.Def
src<<"You attack [Monster] for [damage]!"
Monster.Hp-=damage
if(Monster.Hp<=0)
src<<"Monster has been killed!"
del(Monster)
for(var/area/bat_loc/BL in view())
BL.inuse=0
src.x=src.ox
src.y=src.oy
src.z=src.oz
src.locked=0
src.in_bat=0
return
else
sleep(10)
Monster.Enemy_Battle(src)
return
if(src.choice=="Defend")
src.Def+=src.Def
src.Mdef+=src.Mdef
src.defending=1
src.x+=1
src<<"You are Defending for a turn."
sleep(10)
Monster.Enemy_Battle(src)
return
if(src.choice=="Run")
src.dir=EAST
src.x+=1
sleep(5)
src.dir=WEST
src.x-=1
src<<"Run Command Isnt In, You Just Gave Up Your Turn."
sleep(10)
Monster.Enemy_Battle(src)
return
else
src.choice=input("What would you like to do?","Battle")in list("Attack","Defend","Run")
if(src.choice=="Attack")
src.x-=1
sleep(5)
src.x+=1
var/damage
damage = src.Atk-Monster.Def
src<<"You attack [Monster] for [damage]!"
Monster.Hp-=damage
if(Monster.Hp<=0)
src<<"Monster has been killed!"
del(Monster)
for(var/area/bat_loc/BL in view())
BL.inuse=0
src.x=src.ox
src.y=src.oy
src.z=src.oz
src.locked=0
return
else
sleep(10)
Monster.Enemy_Battle(src)
return
if(src.choice=="Defend")
src.Def+=src.Def
src.Mdef+=src.Mdef
src.defending=1
src.x+=1
src<<"You are Defending for a turn."
sleep(10)
Monster.Enemy_Battle(src)
return
if(src.choice=="Run")
src.dir=EAST
src.x+=1
sleep(5)
src.dir=WEST
src.x-=1
src<<"Run Command Isnt In, You Just Gave Up Your Turn."
sleep(10)
Monster.Enemy_Battle(src)
return
Enemy_Battle(mob/Monster)
if(src.M_Type=="Magic")
src.x+=1
sleep(5)
src.x-=1
var/damage
damage = src.Matk - Monster.Mdef
Monster<<"[src] [src.M_S_Desc] for [damage]!"
Monster.Hp-=damage
if(Monster.Hp<=0)
Monster<<"You have been killed!"
del(src)
Monster.locked=0
Monster.x=Monster.ox
Monster.y=Monster.oy
Monster.z=Monster.oz
Monster.in_bat=0
return
else
sleep(10)
Monster.Person_Battle(src)
return
if(src.M_Type=="Attack")
sleep(10)
Monster.Person_Battle(src)
return


Problem description: okay my problem is that the code above will let me kill the monster that is put in the battle and it'll put me where im supposed to be, but if i get killed inbattle (im running the new byond) a error thing pops up and im not ejected from battle

the error is this:

runtime error: Cannot read null.Agi
proc name: Initiate Battle (/mob/proc/Initiate_Battle)
usr: V (/mob)
src: V (/mob)
call stack:
V (/mob): Initiate Battle(null)
the bat area one (2,5,1) (/turf/bat_area_one): Entered(V (/mob), the bat area one (2,6,1) (/turf/bat_area_one))

if anyone is able to help me out thank you, but if not ill probably have to tear through my battle system and rip everything out untill it works properly.


Sufferin' catfish, mate, ye be throwin' usr around in procs like a half-pence harlot an' riggin' yer lines wit' bad gotos. Fix yer gotos and then rig up yer procs with proper args. Check the ref'rence fer Entered() and lookup while() an' continue, lad.

Cap'n Lummox JR
In response to Lummox JR
in... english please?
In response to VolksBlade
Lummox JR wrote:
Sufferin' catfish, mate, ye be throwin' usr around in procs like a half-pence harlot an' riggin' yer lines wit' bad gotos. Fix yer gotos and then rig up yer procs with proper args. Check the ref'rence fer Entered() and lookup while() an' continue, lad.

Cap'n Lummox JR

"ye be throwin' usr around in procs like a half-pence harlot" = Don't use usr in procs.

"riggin' yer lines wit' bad gotos" = goto is usually bad coding practice.

"Fix yer gotos and then rig up yer procs with proper args" = Fix the gotos and then complete your procs with the proper arguments.

"Check the ref'rence fer Entered() and lookup while() an' continue, lad" = Search the Ref for Entered() and while() to understand their proper usage.

C'mon, it just be pirate speak, mate.
In response to Body
i dont see no usr in my procs, unless you mean in the Entered() and in that case i changed it to Entered(mob/M) and changed all the usr's to M's

here is my updated version:

area
bat_loc
var/inuse=0
New()
bat_loc_list+=src
mob
var
ox
oy
oz
trys=0
gauge=0
is_turn=0
defending=0
in_bat=0
var/bat_loc_list=list()
turf
bat_area_one
Entered(mob/M)
if(M.in_bat==0)
if(prob(25))
for(var/area/bat_loc/BL in bat_loc_list)
if(BL.inuse==1)
bat_loc_list-=BL
if(bat_loc_list==null)
return
else
M.ox=usr.x
M.oy=usr.y
M.oz=usr.z
M.loc=BL
BL.inuse=1
M.locked=1
M.dir=WEST
var/mob/Monster
Monster=new/mob/Enemy/Sage
Monster.loc=locate(M.x-4,M.y,M.z)
Monster.dir=EAST
M.in_bat=1
M.Initiate_Battle(Monster)
while(M.in_bat)
BL.inuse=1
if(M.in_bat==1)
return

mob
proc
Initiate_Battle(mob/Monster)
if(src.Agi>=Monster.Agi+1)
src<<"You Start"
src.Person_Battle(Monster)
if(Monster.Agi>=src.Agi+1)
src<<"Enemy Start"
Monster.Enemy_Battle(src)
return
Person_Battle(mob/Monster)
if(src.defending==1)
src.Def-=src.Def
src.Mdef-=src.Mdef
src.defending=0
src.x-=1
src.choice=input("What would you like to do?","Battle")in list("Attack","Defend","Run")
if(src.choice=="Attack")
src.x-=1
sleep(5)
src.x+=1
var/damage
damage = src.Atk-Monster.Def
src<<"You attack [Monster] for [damage]!"
Monster.Hp-=damage
if(Monster.Hp<=0)
src<<"Monster has been killed!"
del(Monster)
for(var/area/bat_loc/BL in view())
BL.inuse=0
src.x=src.ox
src.y=src.oy
src.z=src.oz
src.locked=0
src.in_bat=0
return
else
sleep(10)
Monster.Enemy_Battle(src)
return
if(src.choice=="Defend")
src.Def+=src.Def
src.Mdef+=src.Mdef
src.defending=1
src.x+=1
src<<"You are Defending for a turn."
sleep(10)
Monster.Enemy_Battle(src)
return
if(src.choice=="Run")
src.dir=EAST
src.x+=1
sleep(5)
src.dir=WEST
src.x-=1
src<<"Run Command Isnt In, You Just Gave Up Your Turn."
sleep(10)
Monster.Enemy_Battle(src)
return
else
src.choice=input("What would you like to do?","Battle")in list("Attack","Defend","Run")
if(src.choice=="Attack")
src.x-=1
sleep(5)
src.x+=1
var/damage
damage = src.Atk-Monster.Def
src<<"You attack [Monster] for [damage]!"
Monster.Hp-=damage
if(Monster.Hp<=0)
src<<"Monster has been killed!"
del(Monster)
for(var/area/bat_loc/BL in view())
BL.inuse=0
src.x=src.ox
src.y=src.oy
src.z=src.oz
src.locked=0
return
else
sleep(10)
Monster.Enemy_Battle(src)
return
if(src.choice=="Defend")
src.Def+=src.Def
src.Mdef+=src.Mdef
src.defending=1
src.x+=1
src<<"You are Defending for a turn."
sleep(10)
Monster.Enemy_Battle(src)
return
if(src.choice=="Run")
src.dir=EAST
src.x+=1
sleep(5)
src.dir=WEST
src.x-=1
src<<"Run Command Isnt In, You Just Gave Up Your Turn."
sleep(10)
Monster.Enemy_Battle(src)
return
Enemy_Battle(mob/Monster)
if(src.M_Type=="Magic")
src.x+=1
sleep(5)
src.x-=1
var/damage
damage = src.Matk - Monster.Mdef
Monster<<"[src] [src.M_S_Desc] for [damage]!"
Monster.Hp-=damage
if(Monster.Hp<=0)
Monster<<"You have been killed!"
del(src)
Monster.locked=0
Monster.x=Monster.ox
Monster.y=Monster.oy
Monster.z=Monster.oz
Monster.in_bat=0
return
else
sleep(10)
Monster.Person_Battle(src)
return
if(src.M_Type=="Attack")
sleep(10)
Monster.Person_Battle(src)
return


i know you guys are probably saying "this kid sucks at coding..." but ive gotten better since last year.. oh boy last year i was on this forum around 15/7 of the week
In response to Lummox JR
Lummox JR wrote:
Sufferin' catfish, mate, ye be throwin' usr around in procs like a half-pence harlot an' riggin' yer lines wit' bad gotos. Fix yer gotos and then rig up yer procs with proper args. Check the ref'rence fer Entered() and lookup while() an' continue, lad.

Cap'n Lummox JR

@_@ the scary thing I understood every word. Arrrrr good work ye land lubber.
In response to VolksBlade
i need someone to tell me exactly where im going wrong and how to fix it