Ejemplo n.º 1
0
// CheckMovement checks if a creature can move to this tile
func (t *Tile) CheckMovement(_creature pul.ICreature, _dir int) int {
	movement := _creature.GetMovement()
	blocking := t.Blocking

	if blocking != TILEBLOCK_WALK {
		if blocking == TILEBLOCK_BLOCK ||
			(blocking == TILEBLOCK_SURF && movement != MOVEMENT_SURF) ||
			(blocking == TILEBLOCK_TOP && _dir == DIR_SOUTH) ||
			(blocking == TILEBLOCK_BOTTOM && _dir == DIR_NORTH) ||
			(blocking == TILEBLOCK_LEFT && _dir == DIR_EAST) ||
			(blocking == TILEBLOCK_RIGHT && _dir == DIR_WEST) ||
			(blocking == TILEBLOCK_TOPLEFT && (_dir == DIR_EAST || _dir == DIR_SOUTH)) ||
			(blocking == TILEBLOCK_TOPRIGHT && (_dir == DIR_WEST || _dir == DIR_SOUTH)) ||
			(blocking == TILEBLOCK_BOTTOMLEFT && (_dir == DIR_EAST || _dir == DIR_NORTH)) ||
			(blocking == TILEBLOCK_BOTTOMRIGHT && (_dir == DIR_WEST || _dir == DIR_NORTH)) {
			return RET_NOTPOSSIBLE
		}
	}

	return RET_NOERROR
}