Move(newLoc, moveDir)
switch(state)
if(STRUGGLE)
if(dir == src.dir && src.struggle)
src.struggle.push(src)
..()
Now if I were to try "spawn() src.struggle.push(src)". I would get "runtime error: Cannot execute null.push()."
Below is part of a sword struggle datum. In struggle mode player movement changes to push/pull movement. It used to work when I had a macro called "tapdir(dir as num)". But i removed this macro due to a recent movement system change.
Struggle
var
mob/player
one = null
two = null
proc
Break(var/mob/player/winner,var/mob/player/loser,var/distance) //had to use Break() since break is reserved
step(winner, turn(winner.dir,180) )
winner.endStruggle()
loser.endStruggle()
loser.knock_back(winner,0+distance,5)
push(var/mob/player/m)
if(m == one)
var/turf/t = get_step(get_step(m, m.dir), m.dir)
if(t)
if(!t.density)
for(var/mob/player/o in t)
Break(m, two)
o.knock_back(m, 1, 5)
return
for(var/obj/dense_object/d in t)
Break(m,two)
return
//Object should take damage!
flick("push_struggle",one)
flick("pushed_struggle",two)
step(two, m.dir)
step(m, m.dir)
else
Break(m,two)
else
world << output("BREAK","output2")
Break(m,two)
else
var/turf/t = get_step(get_step(m,m.dir),m.dir)
if(t)
if(!t.density)
for(var/mob/player/o in t)
Break(m, one)
o.knock_back(m, 1, 5)
return
for(var/obj/dense_object/d in t)
Break(m, one)
return
//Object should take damage!
flick("pushed_struggle",one)
flick("push_struggle",two)
step(one, m.dir)
step(m, m.dir)
else
Break(m, one)
else
Break(m, one)
I don't see how using spawn will remove a problem with infinite recursion. That's usually an issue with logic, which spawning wouldn't prevent.
Anyways, I don't see why this is in Design Philosophy and not somewhere else, like Code Problems.
And it would help if you explained what you were trying to accomplish. Like, instead of posting code, just explain what the push proc does.
I don't think people want to examine your code to figure out what it does. It's much faster if you just tell us.
I don't even know what you mean by "sword struggle." And what is moving (Move proc) even supposed to mean in that case?