I recently implemented 8D movement in my game which is great, however Game_CharacterBase is one of the classes I've studied the least and I'm finding it difficult to navigate because the tile/x,y disparity.
What I want to do is prevent diagonal movement if the character would clip through a non-passable tile. I imagine I'd need to run a check on if the orthogonal tiles of each diagonal direction are passable, but I have absolutely no idea how to do this.
In short, I'm just trying to prevent roof clipping by stopping all forward diagonal movement when a character would otherwise pass over a non-passable (X-marked) tile. I understand that the method which would alter this is found in Game_CharacterBase line 199: def diagonal_passable?(x, y), so I'm assuming I don't need to link any scripts (it's Victor's, which is pretty non-invasive and does not rewrite this method). Any idea on how to do this?
Edit: F**k it, I'll link the relevant bits. Here's another method which I imagine could be altered to prevent diagonal input:
Even a "return if" at the beginning would probably suffice, what comes after that "if" however is what gets me.
What I want to do is prevent diagonal movement if the character would clip through a non-passable tile. I imagine I'd need to run a check on if the orthogonal tiles of each diagonal direction are passable, but I have absolutely no idea how to do this.
In short, I'm just trying to prevent roof clipping by stopping all forward diagonal movement when a character would otherwise pass over a non-passable (X-marked) tile. I understand that the method which would alter this is found in Game_CharacterBase line 199: def diagonal_passable?(x, y), so I'm assuming I don't need to link any scripts (it's Victor's, which is pretty non-invasive and does not rewrite this method). Any idea on how to do this?
Edit: F**k it, I'll link the relevant bits. Here's another method which I imagine could be altered to prevent diagonal input:
Code:
alias :move_diagonal_ve_diagonal_move :move_diagonal
def move_diagonal(horz, vert)
@diagonal = 1 if diagonal_enabled? && horz == 4 && vert == 2
@diagonal = 3 if diagonal_enabled? && horz == 6 && vert == 2
@diagonal = 7 if diagonal_enabled? && horz == 4 && vert == 8
@diagonal = 9 if diagonal_enabled? && horz == 6 && vert == 8
move_diagonal_ve_diagonal_move(horz, vert)
diagonal_direction if diagonal_enabled?
end