Exemplo n.º 1
0
int mon_can_go(object *monster, short row, short col)
{
    object *obj;
    short dr, dc;

    dr = monster->row - row;	/* check if move distance > 1 */
    if ((dr >= 2) || (dr <= -2))
    {
        return(0);
    }
    dc = monster->col - col;
    if ((dc >= 2) || (dc <= -2))
    {
        return(0);
    }
    if ((!dungeon[monster->row][col]) || (!dungeon[row][monster->col]))
    {
        return(0);
    }
    if ((!is_passable(row, col)) || (dungeon[row][col] & MONSTER))
    {
        return(0);
    }
    if ((monster->row!=row) && (monster->col!=col)
            && ((dungeon[row][col]&DOOR)
                || (dungeon[monster->row][monster->col]&DOOR)))
    {
        return(0);
    }
    if (!(monster->m_flags & (FLITS | CONFUSED | CAN_FLIT)) &&
            (monster->trow == NO_ROOM))
    {
        if ((monster->row < rogue.row) && (row < monster->row)) return(0);
        if ((monster->row > rogue.row) && (row > monster->row)) return(0);
        if ((monster->col < rogue.col) && (col < monster->col)) return(0);
        if ((monster->col > rogue.col) && (col > monster->col)) return(0);
    }
    if (dungeon[row][col] & OBJECT)
    {
        obj = object_at(&level_objects, row, col);
        if ((obj->what_is == SCROLL) && (obj->which_kind == SCARE_MONSTER))
        {
            return(0);
        }
    }
    return(1);
}
Exemplo n.º 2
0
void command_move_to(int player_id, int unit_id, int x, int y)
{
    if (!is_passable(x, y))
        return;

    Unit * unit = UNIT(unit_id);

    if (!astar_compute(unit->x, unit->y, x, y, unit->move_path, PATH_LENGTH))
        return;

    unit->command.type = COMMAND_MOVE_TO;
    unit->moving = true;
    unit->move_target_x = x;
    unit->move_target_y = y;
    unit->offset_x = 0;
    unit->offset_y = 0;

    issue_command(unit_id, unit);
}