ID:271102
 
If you've played Fire Emblem, then you know that on the GBA games, they cannot move diagonally and it shows where you can move your character as well as your other characters, based on who and what they are.

What I want to know how to do is to keep the character from moving diagonally, show a blue grid that your character can move to with the range you give it (for the sake of argument let's just make it 3), a red grid after each blue square showing that is where they can attack, and when you click a blue square, that is where they move.

If you can't do it all, then just pick a piece you can do and show me what you got, I'd love to see what you guys can do and what I can use! Thanks in advance, I appreciate it!
proc/generateMoveSquares(mob/m,mrange)
var/list/inrange=list(m.loc)
for(var/k=1, k<=mrange, k++) for(var/turf/t in inrange) for(var/turf/poss in cardinal(t)) if(m.Enter(poss)) inrange+=poss
return inrange

proc/cardinal(turf/t)
return list(get_step(t,NORTH), get_step(t,SOUTH), get_step(t,EAST), get_step(t,WEST))


Calling generateMoveSquares() with the mob you want to generate the movement range for and the distance they're allowed to move returns a list of squares that they can reach, only moving in non-diagonal directions, in that many moves.

I think. It's not tested.
In response to Jp
The only thing that is confusing me is the order of the code...or the way ti was written, like 4 "for's" in one line; can you make it so that it goes vertical?
In response to Arcanedragon_2004
Grrr...I keep on fiddling with the code but it doesn't seem to be doing anything.
In response to Arcanedragon_2004
Okay then....just tell me how to get it so that a mob cannot move diagonally, in this case, a non-client mob.
In response to Arcanedragon_2004
mob
Northwest()
return
Northeast()
return
Southeast()
return
Southwest()
return


Untested, should work.
In response to King of Slimes
Wow...that's kinda simple. ^_^ Thanks! I feel like I suck now, lol.
In response to Arcanedragon_2004
No problem, like I said I don't know for sure if it works, but it SHOULD.
In response to King of Slimes
Actually, it doesn't work; they are all noticed as undefined procs.
In response to Arcanedragon_2004
Dunno, sorry that it don't work though.
In response to King of Slimes
Yay, back to square one. Nice try though, I appreciate it.

Listen everyone, I'm not the most intelligent programmer out there and I don't think you guys know exactly what I'm trying to get at, so here is what I need:

http://i145.photobucket.com/albums/r211/arcanedragon_2004/ scrnshot1-1.png

As you can see (hypothically speaking, I haven't actually done it yet, it's just to show what I need it to do), when you click on him, a grid of where can move should show up. Click a spot and he moves to that spot by moving only north, south, east, and west, and not diagonally. After he's done moving, he cannot move anymore during the end of his turn and the others get to move (if there are others).

EDIT: Dense objects should show up red also...obviously, you cannot move into dense spaces.

Hopefully this helps. And please, everyone needs to help me out. Credits all around to those who can help me out! Thanks in advance, hope this clears up a couple things.
In response to Arcanedragon_2004
Well, for the turns part, I'd break the diagonal direction into all directions included(northeast=north&east), and simply subtract that much from the turns.

e.g.
mob
var
turns = 0

// the battle they're currently at
// if no battle is occuring, players
// can move freely
battle/battle = 0

Move(location,direction)
if(!direction)
return ..(location)

var/list/steps = new

// setup steps list
if(direction & NORTH)
steps += NORTH

else if(direction & SOUTH)
steps += SOUTH

if(direction & EAST)
steps += EAST

else if(direction & WEST)
steps += WEST

// turns you'll (probably) have after moving
var/updated_turns = (turns - steps.len)

// if none
if(updated_turns < 0)

// don't allow mob to move
return

// move the mob...
for(var/step in steps)
var/nextLoc = get_step(src,step)

// ... if he can move in that direction
if(..(nextLoc,step))
turns -= 1

return 1


As for the battle grid, that's a bit more complicated. How will the grid look like? What form will it have? How will you determine where you are able to move in battle?
In response to DivineO'peanut
For that mob/Northwest() thing above, just change mob to client.
In response to Deathstar175
That's not quite what he wants. He wants all mobs to be incapable of moving diagonally - not just players.
In response to Jp
What he said.

If you've played Castle, then you know exactly what I mean. You are basically the controller of the game and you get to determine where things go and how they should do things. You aren't actually a player in the game, but you are the strategist that controls numerous amounts of people. You move around from one character to another controlling thier movements, what they should attack, items they use, etc. The only thing I want to keep from moving diagonally are these characters that you get to move. You, however, get to move freely because you aren't a character yourself.