ID:174275
 
Hello!
I have used a Beam demo by someone called something like Radditz.
But when I fire, it works quite well, but the tail is not deleted after the head is deleted.
Also, it is meant to say "(Whoever's) beam has hit (whoever)" in view 6, but it doesn't say anything!

Here is my code:

obj
SBC
icon = 'kame.dmi'
icon_state = "sbchead"
density = 1
Head
icon_state = "sbchead"
New()
spawn(1) // Delay is abit...
Start() // Calls the Start() proc
Check()
..()
proc
Start()
walk(src,usr.dir,1) // Makes the Kame's head move
Check() // This is the proc used to delete the Kame when its at the map's edge
while(src)
var/turf/T = get_step(src,src.dir)
if(!T)
owner.kame = 0
owner.icon_state = ""
owner.move = 1
if(src)
for(var/obj/O in src.SBC)
del(O)
del(src)
sleep(1)
Bump(atom/M)
if(isturf(M)) // If whatever the head bumps is a turf..
owner.kame = 0 // Allow the owner to fire another Kame
owner.icon_state = "" // Give them their default icon_state
owner.move = 1 // Allow them to move
for(var/obj/O in src.SBC) // Checks for objects in the Head's Kame 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 Special Beam Attack hits [M]!" // For all in the owner's view, gives a message
owner.kame = 0 // Allows the owner to fire another Kame
src.owner.icon_state = "" // Sets them to their default icon_state
owner.move = 1 // Allows them to move
for(var/obj/O in src.SBC) //For all objects in the Head's Kame list...
del(O) //Delete any objects found
del(src) // Delete the head
else
if(!ismob(M) && !isturf(M) && !isobj(M) && !isarea(M))
owner.kame = 0 // Allow the owner to fire another Kame
owner.icon_state = "" // Give them their default icon_state
owner.move = 1 // Allow them to move
for(var/obj/O in src.SBC) // Checks for objects in the Head's Kame list...
del(O) // Deletes any objects found
del(src) // Deletes the head

Tail // The Kame's body
icon_state = "tail"
Move()
if(istype(src,/obj/SBC/Head)) //If the obj trying to move is The Kame's Head...
var/obj/Tail = new/obj/SBC/Tail(src.loc) // Create a new body at the current location
Tail.owner = src //Set the owner of the body to the Head
src.SBC.Add(Tail) // Adds the Body to the Head's Kame list, for later tracking and deletion of it
Tail.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.kame = 0 // Allows the owner to fire another Kame
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.SBC) // Checks for the objects in the Head's Kame list
del(O) // Delete any objects found
del(src) // Deletes the Head
..() // Continues with the Move() procs norm


obj
Sbc
verb
Sbc()
set name = "Special Kame Cannon"
set category = "Fighting"
if(usr.safe != 1)
usr.kame = 1
usr.move = 0
view(6) << "[usr] : Special..."
sleep(2)
view(6) << "[usr] : Kame..."
sleep(2)
view(6) << "[usr] : CANNON!!!"
sleep(2)
FireSpecialBeamAttack()// Calls the Beam() proc
usr.kame = 0
usr.move = 1
else
usr<<"Not in a safe zone!"
proc
FireSpecialBeamAttack()
var/obj/Head = new/obj/SBC/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 = 8 // 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


Any help would be greatly appreciated!

~GokuSS4Neo~
No put usr in proc. Ungh.

Lummox JR
In response to Lummox JR
You mean, instead of FireSpecialBeam() I should put usr.FireSpecialBeam() ??
Because I tried that first and got the error:
skills.dm:840:error:usr.FireSpecialBeamAttack:undefined proc

~GokuSS4Neo~
In response to Gokuss4neo
Gokuss4neo wrote:
You mean, instead of FireSpecialBeam() I should put usr.FireSpecialBeam() ??

Common sense would dictate that when told "No put usr in proc", you should apply usr less, not more.

Lummox JR
In response to Lummox JR
So you meant "Don't put usr in proc" ? Because it read it as "No, put usr in proc" which to me tells me I was doing something wrong (No), and I should put usr in the proc! Sorry!

And which proc are you talking about?
If it is FireSpecialBeam, then I think you may be wrong, because the place the beam starts is dependant on the USR's direction! If I was to change it, the only way I think I could do it would be to delete all of the "if usr.dir" section.

Thank you for your time!

~GokuSS4Neo~
In response to Gokuss4neo
GoKuSS4Neo

usr doesn't belong in procs, use src or define somthing else instead.
In response to Wanabe
Okay, but why doesn't the beams tail delete itself. Surely a usr instead of a src, would hardly affect that? And if it does, could anyone tell me what to replace usr with?

~GokuSS4Neo~
In response to Gokuss4neo
Gokuss4neo wrote:
Okay, but why doesn't the beams tail delete itself. Surely a usr instead of a src, would hardly affect that? And if it does, could anyone tell me what to replace usr with?

That depends on where you're replacing it. In that last proc from your first post, it should be src.

And yes, putting a usr instead of src can affect all kinds of things in strange ways. That's why it's the first piece of advice: Always fix that before moving on.

Lummox JR