ID:148000
 
i want to make the sword face away from the player and appear around him in a circle, as if he is spinning around.
But the sword faces wierd directions.

here is my coding

verb
Slash(mob/M as mob)
set category = "Combat"
var/obj/A = new/obj/combat/sword(get_step(usr,EAST))
A.dir = EAST
sleep(1)
del(A)
var/obj/B = new/obj/combat/sword(get_step(usr,NORTHEAST))
B.dir = NORTHEAST
sleep(1)
del(B)
var/obj/C = new/obj/combat/sword(get_step(usr,NORTH))
C.dir = NORTH
sleep(1)
del(C)
var/obj/D = new/obj/combat/sword(get_step(usr,NORTHWEST))
D.dir = NORTHWEST
sleep(1)
del(D)
var/obj/E = new/obj/combat/sword(get_step(usr,WEST))
E.dir = WEST
sleep(1)
del(E)
var/obj/F = new/obj/combat/sword(get_step(usr,SOUTHWEST))
F.dir = SOUTHWEST
sleep(1)
del(F)
var/obj/G = new/obj/combat/sword(get_step(usr,SOUTH))
G.dir = SOUTH
sleep(1)
del(G)
var/obj/H = new/obj/combat/sword(get_step(usr,SOUTHEAST))
H.dir = SOUTHEAST
sleep(1)
del(H)
var/obj/I = new/obj/combat/sword(get_step(usr,EAST))
I.dir = EAST
sleep(1)
del(I)
1. <dm> tags are helpful
2. instead of sleep(1);delwhatever, do this:
spawn(1) del(whatever)

3. what is it doing wrong?
Xallius wrote:
verb
Slash(mob/M as mob)
set category = "Combat"
var/obj/A = new/obj/combat/sword(get_step(usr,EAST))
A.dir = EAST
sleep(1)
del(A)

Well I think i might of found the problem in here,
when you say : <code>

var/obj/A = new/obj/combat/sword(get_step(usr,EAST))</code> , you are just making any object A make it something like ,<code>

var/obj/combat/sword/A = new/obj/combat/sword(get_step(usr,EAST))</code>, I think that might work if it doesn't page me and i'll work on it.

In response to FinalFantasyFreak
Shouldn't make any difference, FFF.

Xallius, what's the actual problem? What do you mean by "weird directions"?
Well, you're using too many vars, and you've got a big chunk of repeated code that could be done easier in a loop. Those aren't the problem, though; the problem is you never set the sword's dir var.

But instead, try this:
verb
Slash() // this does not need an M argument; get rid of it
set category = "Combat"
var/obj/effect/sword/S = new(get_step(usr, usr.dir))
var/firstdir = usr.dir
S.dir = firstdir
usr.lock_movement = 1
sleep(1)
// it is *vital* to check that usr still exists
// because a player may log out during the swipe
while(usr && S && usr.dir != firstdir)
usr.dir = turn(usr.dir, -45)
S.loc = get_step(usr, usr.dir)
S.dir = usr.dir
// deliver damage
for(var/mob/M in S.loc)
M.DoDamage(usr, 1)
sleep(1)
if(usr)
usr.dir = firstdir // go back (if not in the right place)
usr.lock_movement = 0

Lummox JR
In response to The mothball
the swords are facing different angles, some out, some in, some down... etc.