ID:1628172
 
(See the best response by Ter13.)
Code:


Problem description:
Can someone explain me how to make Diagonal Movment for mob/PC(3 character)

when i have mob/Player for main user who logs and creating 3 chars
Best response
How I usually handle diagonal movement, is that I override the default movement behavior, and set up a single verb for all movement keys to use. Then, I set up a loop do do movement for me:

#define get_opposite(x) __opposite_dirs[(x)]

var
list/__opposite_dirs = list(2,1,null,8,null,null,null,4) //used internally to assist with movement input keys

client
var/tmp
move_dir = 0
input_dir = 0
verb
MoveKey(key as num,state as num)
set hidden = 1
set instant = 1
. = input_dir==0
//update the INPUT_DPAD status
var/opposite = get_opposite(key)
if(state)
//if this is a keypress, turn on the key bit
input_dir |= key
move_dir |= key
//turn off the opposite key bit
if(opposite & input_dir)
move_dir &= ~opposite
else
//if this is a keyrelease, turn off the key bit
input_dir &= ~key
move_dir &= ~key
//turn on the opposite key bit if it's being held
if(opposite & input_dir)
move_dir |= opposite
if(.&&input_dir!=0)
MoveLoop()
proc
MoveLoop()
while(input_dir)
if(move_dir)
src.Move(src.mob.loc,move_dir)
sleep(world.tick_lag)


Last, you need to set up macros in your interface:

NORTH        MoveKey 1 1
NORTH+UP MoveKey 1 0
SOUTH MoveKey 2 1
SOUTH+UP MoveKey 2 0
EAST MoveKey 4 1
EAST+UP MoveKey 4 0
WEST MoveKey 8 1
WEST+UP MoveKey 8 0
the mcaro setup i neet to do it here ?

or at the skin macro ?
setMacros()

var/macros=params2list(winget(src,null,"macro"))
for(var/m in macros)
/*
winset(src,"W","parent=[m];name=W;command=north")
winset(src,"W+UP","parent=[m];name=W+UP;command=north-up")
winset(src,"A","parent=[m];name=A;command=west")
winset(src,"A+UP","parent=[m];name=A+UP;command=west-up")
winset(src,"S","parent=[m];name=S;command=south")
winset(src,"S+UP","parent=[m];name=S+UP;command=south-up")
winset(src,"D","parent=[m];name=D;command=east")
winset(src,"D+UP","parent=[m];name=D+UP;command=east-up")

*/


// Arrow keys
winset(src,"NORTH","parent=[m];name=NORTH;command=MoveKey-1-1")
winset(src,"NORTH+UP","parent=[m];name=NORTH+UP;command=MoveKey-1-0")
winset(src,"WEST","parent=[m];name=WEST;command=MoveKey-8-1")
winset(src,"WEST+UP","parent=[m];name=WEST+UP;command=MoveKey-8-1")
winset(src,"SOUTH","parent=[m];name=SOUTH;command=MoveKey-2-1")
winset(src,"SOUTH+UP","parent=[m];name=SOUTH+UP;command=MoveKey-2-0")
winset(src,"EAST","parent=[m];name=EAST;command=MoveKey-4-1")
winset(src,"EAST+UP","parent=[m];name=EAST+UP;command=MoveKey-4-0")



mob/PC

// This will initiate movement whenever a client logs into a /mob/player.
/* Login()
..()
spawn()
MovementLoop()*/


// These are the actual commands players will be using for movement.
// They're set to instant so player inputs react as quickly, as possible.
// Having them hidden isn't required, it just prevents them from filling
// up a statpanel.
verb
north()
set
hidden=1
instant=1
src.keySet(NORTH)
north_up()
set
hidden=1
instant=1
src.keyDel(NORTH)
south()
set
hidden=1
instant=1
src.keySet(SOUTH)
south_up()
set
hidden=1
instant=1
src.keyDel(SOUTH)
east()
set
hidden=1
instant=1
src.keySet(EAST)
east_up()
set
hidden=1
instant=1
src.keyDel(EAST)
west()
set
hidden=1
instant=1
src.keySet(WEST)
west_up()
set
hidden=1
instant=1
src.keyDel(WEST)
That big thing of code you just linked, throw it away.

Replace your entire macro setup in the interface with what I just showed you. You'll be happier for it, I guarantee it.

...Also slap the person that designed what you just linked. Please?
lol if i coald i woald do it let me find heim firs xD

and for setting it in the interface you meen the skin macro ?

like inplace of .north .west and so on?
and for setting it in the interface you meen the skin macro ?

Yes.
ok got it thx will do it now
Unrecognized or inaccessible verb: MoveKey-1-1
for some reasen this is what it says to me

and when i do MoveKey 1 1 it dsnt move
Small mistake in move_loop:

proc
MoveLoop()
while(input_dir)
if(move_dir)
step(src.mob,move_dir)
sleep(world.tick_lag)
Unrecognized or inaccessible verb: MoveKey-2-0
and with MoveKey 2 0 dsnt move
do i need to put between ","?
like MoveKey(2,0)?
Hang on, somehow, my indentation got messed up on the MoveKey verb too... Lemme fix it...

#define get_opposite(x) __opposite_dirs[(x)]

var
list/__opposite_dirs = list(2,1,null,8,null,null,null,4) //used internally to assist with movement input keys

client
var/tmp
move_dir = 0
input_dir = 0
verb
MoveKey(key as num,state as num)
set hidden = 1
set instant = 1
. = input_dir==0
//update the INPUT_DPAD status
var/opposite = get_opposite(key)
if(state)
//if this is a keypress, turn on the key bit
input_dir |= key
move_dir |= key
//turn off the opposite key bit
if(opposite & input_dir)
move_dir &= ~opposite
else
//if this is a keyrelease, turn off the key bit
input_dir &= ~key
move_dir &= ~key
//turn on the opposite key bit if it's being held
if(opposite & input_dir)
move_dir |= opposite
if(.&&input_dir!=0)
MoveLoop()
proc
MoveLoop()
while(input_dir)
if(move_dir)
step(src.mob,move_dir)
sleep(world.tick_lag)
its turns around but not walk xD
nvm thx alot missed the fix you did in step()
and not src.move


thx alot