mob
var
firing = 0 // This var determines whether the mob is firing a beam, or not.
move = 1
Move() // Move proc
if(move) // If the move var is 1...
..() // Continue process
else // If its not 1...
return // Stop movement
obj
var
mob/owner = null // This var will be set as the owner of the beam being fired.
total = 0 // The total number of spaces the beam's head is allowed to move
moved = 0 // The number of spaces the beam's head has moved
list/Beam = list() // A simple list to keep track of the beam's body
Beams
icon = 'Beam.dmi'
density = 1
Head
icon_state = "head"
New()
spawn(1) // Delay is abit...
Start() // Calls the Start() proc
Check()
..()
proc
Start()
walk(src,usr.dir,1) // Makes the beam's head move
Check() // This is the proc used to delete the beam when its at the map's edge
while(src)
var/turf/T = get_step(src,src.dir)
if(!T)
owner.firing = 0
owner.icon_state = ""
owner.move = 1
if(src)
for(var/obj/O in src.Beam)
del(O)
del(src)
sleep(1)
Bump(atom/M)
if(isturf(M)) // If whatever the head bumps is a turf..
owner.firing = 0 // Allow the owner to fire another beam
owner.icon_state = "" // Give them their default icon_state
owner.move = 1 // Allow them to move
for(var/obj/O in src.Beam) // Checks for objects in the Head's Beam list...
del(O) // Deletes any objects found
del(src) // Deletes the head
else if(ismob(M)) // If whatever the head bumps is a mob...
view(src.owner) << "[src.owner]'s beam hits [M]!" // For all in the owner's view, gives a message
owner.firing = 0 // Allows the owner to fire another beam
src.owner.icon_state = "" // Sets them to their default icon_state
owner.move = 1 // Allows them to move
for(var/obj/O in src.Beam) //For all objects in the Head's Beam list...
del(O) //Delete any objects found
del(src) // Delete the head
else
if(!ismob(M) && !isturf(M) && !isobj(M) && !isarea(M))
owner.firing = 0 // Allow the owner to fire another beam
owner.icon_state = "" // Give them their default icon_state
owner.move = 1 // Allow them to move
for(var/obj/O in src.Beam) // Checks for objects in the Head's Beam list...
del(O) // Deletes any objects found
del(src) // Deletes the head
Body // The Beam's body
icon_state = "body"
density = 1
Move()
if(istype(src,/obj/Beams/Head)) //If the obj trying to move is The Beam's Head...
var/obj/Body = new/obj/Beams/Body(src.loc) // Create a new body at the current location
Body.owner = src //Set the owner of the body to the Head
src.Beam.Add(Body) // Adds the Body to the Head's Beam list, for later tracking and deletion of it
Body.dir = src.dir // Set its direction
moved++ // Adds 1 to the Head's moved var
if(moved == total) // Checks to see if the spaces moved(the moved var) is equal to the spaces its allowed to move(the total var)
owner.firing = 0 // Allows the owner to fire another beam
owner.icon_state = "" // Sets the owner to its default icon_state
owner.move = 1 // Allows the owner to move
if(src) // Just incase...checking to make sure the object is still there, we dont want any runetime errors, do we? =p
for(var/obj/O in src.Beam) // Checks for the objects in the Head's Beam list
del(O) // Delete any objects found
del(src) // Deletes the Head
..() // Continues with the Move() procs norm
mob
verb
Fire() // Verb used for firing the beam
if(usr.firing) // If the mob's firing var is one...
usr << "This cannot be done."
return
else // If the firing var isn't 1...
usr.firing = 1 // Sets the firing var to 1, so he cant fire another beam
usr.move = 0 // Disables the mob's movement
usr.icon_state = "shoot" // Sets the mob's icon_state
usr.Beam() // Calls the Beam() proc
proc
Beam()
var/obj/Head = new/obj/Beams/Head() // Creates the Beam's Head
if(usr.dir == NORTH) // If the mob's dir is NORTH...
Head.loc = locate(usr.x,usr.y+1,usr.z)
if(usr.dir == SOUTH) // If SOUTH...
Head.loc = locate(usr.x,usr.y-1,usr.z)
if(usr.dir == WEST) // If WEST...
Head.loc = locate(usr.x-1,usr.y,usr.z)
if(usr.dir == EAST) // If EAST...
Head.loc = locate(usr.x+1,usr.y,usr.z)
Head.total = 60 // Sets the total to 6, that means the beam's head can move 6 spaces before deletion
Head.dir = usr.dir // Sets the Head's dir to the mob's dir
Head.owner = usr // Sets the Head's owner to the mob
turf
grass
icon = 'turf.dmi'
icon_state = "grass"
wall
icon = 'turf.dmi'
icon_state = "wall"
density = 1
mob
Target
icon = 'npc.dmi'
name = "Bob"
New()
Talk()
..()
proc
Talk()
var/list/sayings = list("Hey! Shoot me already!","Come on! Ya wimp!","*cough*Hey...over here...SHOOT ME!","Dum dum dummmm SHOOT...ME!","Please...Shoot...ME!")
var/say = pick(sayings)
view() << "[src] say, \"[say]\""
spawn(50)
Talk()
Problem description:
This is the adzact code from SSJRADITS beam code, and it was working fine for a while, i changed it around abit, the idea i tried didn't work so i put it all back and i get this error ALL the time and its really annoying!!!!!!!!!!! because it makes no sense, it works in the demo of it, but not in my game
This is the error i keep getting:
runtime error: Cannot modify null.firing.
proc name: Check (/obj/Beams/Head/proc/Check)
source file: Beam Demo.dm,50
usr: Ichi (/mob/Player)
src: Head (/obj/Beams/Head)
call stack:
Head (/obj/Beams/Head): Check()
Head (/obj/Beams/Head): New()