ID:269256
 
Hello I am trying to make an additon to my beam system.
I want to make a beam struggle code so when two beams clloide they will determine whos beam is stronger and then after that the stronger persons beam will break through the other person that shot his beam and do dmg to him

something like this

Image Hosted by ImageShack.us

After the beams clloide they struggle back and forth to determain which one is stronger and when the it does the stronger one wins and does the damage


Image Hosted by ImageShack.us

I hope that is enoufe imformation to help me with my problem and my post isnt too big that you wont help me


heres my beam system i am working with

obj
SBC
icon = 'SBC.dmi'
density = 1
Head
icon_state = "head"
New()
spawn(1)
Start()
Check()
..()
proc
Start()
walk(src,usr.dir,1)
Check()
while(src)
var/turf/T = get_step(src,src.dir)
if(!T)
owner.firing = 0
owner.icon_state = ""
owner.move1 = 1
if(src)
for(var/obj/O in src.Beam)
del(O)
del(src)
sleep(1)
Bump(atom/M)
if(isturf(M))
owner.firing = 0
owner.icon_state = ""
owner.move1 = 1
for(var/obj/O in src.Beam)
del(O)
del(src)
else if(ismob(M))
var/mob/Target = M
view(src.owner) << "[src.owner]'s beam hits [M] for [owner.damage]!"
Target.HitPoints -= owner.damage
Target.PowerlevelCheck()
owner << "Target's HitPoints are [Target.HitPoints]."
owner.firing = 0
src.owner.icon_state = ""
owner.move1 = 1
for(var/obj/O in src.Beam)
del(O)
del(src)
else
if(!ismob(M) && !isturf(M) && !isobj(M) && !isarea(M))
owner.firing = 0
owner.icon_state = ""
owner.move1 = 1
for(var/obj/O in src.Beam)
del(O)
del(src)


Body
icon_state = "body"
density = 1
Move()
if(istype(src,/obj/SBC/Head))
var/obj/Body = new/obj/SBC/Body(src.loc)
Body.owner = src
src.Beam.Add(Body)
Body.dir = src.dir
moved++
if(moved == total)
owner.firing = 0
owner.icon_state = ""
owner.move1 = 1
if(src)
for(var/obj/O in src.Beam)
del(O)
del(src)
..()

mob
proc
SBeamC()
var/obj/Head = new/obj/SBC/Head()
if(usr.dir == NORTH)
Head.loc = locate(usr.x,usr.y+1,usr.z)
if(usr.dir == SOUTH)
Head.loc = locate(usr.x,usr.y-1,usr.z)
if(usr.dir == WEST)
Head.loc = locate(usr.x-1,usr.y,usr.z)
if(usr.dir == EAST)
Head.loc = locate(usr.x+1,usr.y,usr.z)
Head.total = 6
Head.dir = usr.dir
Head.owner = usr



Dave^^
Bumpity Bump
Here's something untested:

obj
SBC
icon = 'SBC.dmi'
density = 1
var/restricted = 0
Head
icon_state = "head"
New()
spawn(1)
Start()
Check()
..()
proc
Start()
walk(src,owner.dir,1) //notice I took usr out here.
Check()
while(src)
var/turf/T = get_step(src,src.dir)
if(!T)
owner.firing = 0
owner.icon_state = ""
owner.move1 = 1
if(src)
for(var/obj/O in src.Beam)
del(O)
del(src)
sleep(1)
Bump(atom/M)
if(isturf(M))
owner.firing = 0
owner.icon_state = ""
owner.move1 = 1
for(var/obj/O in src.Beam)
del(O)
del(src)
else if(ismob(M))
var/mob/Target = M
view(src.owner) << "[src.owner]'s beam hits [M] for [owner.damage]!"
Target.HitPoints -= owner.damage
owner << "Target's HitPoints are [Target.HitPoints]."
owner.firing = 0
src.owner.icon_state = ""
owner.move1 = 1
for(var/obj/X in src.Beam)
del(X)
del(src)
else if(isobj(M))
if(istype(M,/obj/SBC/Head))
var/obj/O = M
src.restricted = 1
src.Struggle(O) //Get the struggle effect
if(src.owner.damage>O.owner.damage)
var/mob/loser = O.owner
for(var/obj/X in O.Beam)
del(X)
del(O)
walk_towards(src,loser,3)
else
if(!ismob(M) && !isturf(M) && !isobj(M) && !isarea(M))
owner.firing = 0
owner.icon_state = ""
owner.move1 = 1
for(var/obj/O in src.Beam)
del(O)
del(src)


Body
icon_state = "body"
density = 1
Move()
if(restricted) return
if(istype(src,/obj/SBC/Head))
var/obj/Body = new/obj/SBC/Body(src.loc)
Body.owner = src
src.Beam.Add(Body)
Body.dir = src.dir
moved++
if(moved == total)
owner.firing = 0
owner.icon_state = ""
owner.move1 = 1
if(src)
for(var/obj/O in src.Beam)
del(O)
del(src)

..()
obj/proc/Struggle(obj/M)
src.restricted = 1
var/a = 3 //Adjust this to how many times you want the struggle "effect" to happen.
while(a)
a--
var/obj/O = src.Beam[src.Beam.len]
del(O)
sleep(2)
src.x --
sleep(2)
step(M,M.dir)
var/obj/B = M.Beam[M.Beam.len]
del(B)
sleep(2)
M.x++
src.restricted = 0
step(src,src.dir)

obj/var/restricted = 0
In response to DeathAwaitsU
thanks its a start, now i can tweak it to how its gotta be just one problem thou


it keeps giving me the error

pages\Beams.dm:260:error:O :duplicate definition
pages\Beams.dm:255:error:O :previous definition
pages\Beams.dm:299:error:src.restricted:undefined var
pages\Beams.dm:313:error:src.restricted:undefined va


no matter what i have tried...weird
In response to Dranzer_Solo
Ok I edited my post. I'm suprised you couldn't figure out the problem considering the complexity of the beam system.
In response to DeathAwaitsU
DeathAwaitsU wrote:
Ok I edited my post. I'm suprised you couldn't figure out the problem considering the complexity of the beam system.

It's quite difficult when you copy and paste from a demo and don't really understand what anything does.
In response to Nick231
Notice he calls it his own...

Wow, i've never used a demo or library in any of my new games....