ID:2184969
 
(See the best response by Cheesy pants.)
Code:
mob/verb/Beam()
Beamizing += 0.5
while(Beamizing == 0.5)
BeamCharge()
sleep(3)
while(Beamizing == 1)
new /obj/Beam
loc = usr.loc
if(Beamizing > 1)
Beamizing = 0
obj/Beam
density = FALSE
icon = 'Beam.dmi'
var/tmp/mob/owner
New()
src.loc = usr.loc
src.loc = src.loc
src.dir = usr.dir
src.dir = usr.dir
dir = dir
while(loc != null)
walk(src,dir)
Steps += 1
sleep(3)
if(Steps > 25)
del src


Problem description: I'm trying to make a beam, similar to something you'd see in a shonen anime like Dragon Ball. I've tried a lot of different ways to make them work, this is just the most recent one. The issue I'm having with this is that it just creates two pieces of the beam, and nothing happens beyond that. It just stops.

Best response
mob/verb/Beam()
while(usr.beamizing<=1)
usr.BeamCharge()
sleep(3)
new/obj/Beam(usr.loc,usr,1)//pass 1 into the new proc if you want this piece of the beam to be mobile
usr.beamizing=0

mob/var/list/beamparts=list()//create a list so that it will be easier to locate the beam
obj
var
tmp
mob/owner
list/parts=list()

obj/Beam
density=TRUE//a beam is no good if it will never bump into anything, unless it's not for attacking
icon='Beam.dmi'

New(loc,o,moving=0)//arguments passed to the new proc can be used to apply changes to the atom created before you start to manipulate it in ways that affect the world
//moving=0 simply means that when no value is passed into this proc as this argument, it will be set to 0 automatically
if(!o) del src//delete the beam if there is no owner present, as this will result in you having a real bad time with a terrible thing called errors, when you try to locate or manipulate the beam later
if(o) owner=o//assign the mob to the owner status
owner.beamparts+=src//add the freshly created part into the list for easy access
dir=owner.dir
if(moving) walk(src,owner.dir)//if it is a mobile piece send the little yipper on its way, walk(ref,dir) makes the ref walk continuously in the direction specified

Move()
if(steps<25)
steps++//increment the steps variable, increment(++) means to add one to the value, and subcrement(--) means to subtract one
var/obj/B=new/obj/Beam(loc,owner)
..()//call the parent version for this built-in proc(moving in the atom's direction)
parts+=B//add this into the beam's parts list
else
walk(src,0)//stop movement
for(var/obj/Beam/B in parts)
del B
del src

/*************
BONUS
**************/

Bump(O)
..()
if(ismob(O)
var/mob/M=O//let the compiler know exactly what it's hitting, because it's dumb as a brick and won't catch on unless you say it outright
M.HP=max(0,M.HP-10)//let the struck entity take damage or whatever you want to happen
for(var/obj/Beam/B in parts)
del B
del src


I tried to be pretty clear in the comments, but if you don't understand, press f1 while in the dreammaker application, make sure you're on the topic tab, and type in the phrase you don't seem to get. You should get really familiar with this, it's something never provided in any other compiler I used and it's VERY important for self-improvement.
Ah, also, I used spaces instead of tabs,meaning you'll have to type it out instead of copy pasting, its something I used to hate people for doing, but it'll prevent you from simply copy pasting this into your code, and even if you don't understand everything you type, you should at least understand some
Thanks! I've been trying to get this to work for months, and I would always run into a huge bug. I'll need to mess around with it to optimize it a bit, but it's working fine now.
No problemo, glad it's working cause I didn't test it myself (sorry about that). Good luck with your game mate.