Projectile
parent_type = /obj
density = 0
Grabbable = 0
Attackable = 0
// copy stats
var
BP = 0
Strength = 0
Force = 0
Accuracy = 0
Agility = 0
dmgMulti = 0
mob/maker
New(mob/ref)
if(!ismob(ref)) del src
..(ref)
position(ref)
set_vars(ref)
spawn() life()
proc
position(atom/movable/m, s = 16)
loc = m.loc
dir = m.dir
var x = m.step_x, y = m.step_y
if(m.dir & NORTH) y += s
if(m.dir & SOUTH) y -= s
if(m.dir & WEST) x -= s
if(m.dir & EAST) x += s
step_x = x
step_y = y
collide(atom/a)
var mob/m = a
if(ismob(m))
if(m.blasted(src))
return
del src
set_vars(mob/c)
BP = c.BP
Strength = c.Strength
Force = c.Force
Accuracy = c.Accuracy
Agility = c.Agility
maker = c.real_name
life()
for()
sleep(1)
step(src, src.dir)
Cross(atom/a)
var Projectile/b = a
if(istype(b))
if(b.maker != maker)
return 0
return 1
return ..(a)
Move()
. = ..()
if(dir & NORTH) if(y == world.maxy) del src
if(dir & SOUTH) if(y == 1) del src
if(dir & WEST) if(x == 1) del src
if(dir & EAST) if(x == world.maxx) del src
Bump(atom/a)
. = ..(a)
collide(a)
Blast
dmgMulti = 0.5
step_size = 32
Standing = 1
bound_x = 11
bound_y = 12
bound_width = 11
bound_height = 7
density = 1
icon = 'Blast1.dmi'
Beam
step_size = 32
icon = 'Beam1.dmi'
icon_state = "Tail"
density = 1
New(l, obj/Skills/Beam/s)
..(l)
var mob/m = s.loc
dir = m.dir
maker = m.key
if(ismob(m)) position(m, 32)
set_vars(m)
spawn() life()
spawn() pickState()
collide(atom/a)
// insert damage instructions
del src
life()
spawn() walk(src, dir, 1)
proc
pickState()
while(src)
var Projectile/Beam/headTest = locate(/Projectile/Beam) in get_step(src, dir)
var Projectile/Beam/tailTest = locate(/Projectile/Beam) in get_step(src, oppositeDir(dir))
if(istype(headTest)) if(headTest.maker != maker) headTest = null
if(istype(tailTest)) if(tailTest.maker != maker) tailTest = null
if(!istype(headTest)) icon_state = "Head"
else if(!istype(tailTest)) icon_state = "Tail"
else icon_state = "Body"
sleep(1)
Problem description:
Hey guys, I've been working on a projectile system, and I'm running into a bit of an issue..
When beams are being shot, in some cases the pickState() proc isn't applying the proper icon_state to the projectile. This seems to ONLY be happening when shooting a beam to the north, or to the east. When shooting it south or west, it always does just fine. In some rare positions, or instances, I haven't isolated it.. shooting it north or east works momentarily, but then it quits after moving.
Tail is at the back of the beam, Body is anything not at the front or back, and Head is the leading beam object.
Anyone have a clue what's wrong with the logic here?
Edit: Here's oppositeDir()
proc
oppositeDir(d) // d == dir
if(d == NORTH) return SOUTH
if(d == SOUTH) return NORTH
if(d == EAST) return WEST
if(d == WEST) return EAST
if(d == NORTHWEST) return SOUTHEAST
if(d == NORTHEAST) return SOUTHWEST
if(d == SOUTHWEST) return NORTHEAST
if(d == SOUTHEAST) return NORTHWEST