void get_nearest_navigable_point_for_thing(struct Thing *thing, struct Coord3d *pos1, struct Coord3d *pos2, NaviRouteFlags flags)
{
    long nav_sizexy;
    long px, py;
    nav_thing_can_travel_over_lava = creature_can_travel_over_lava(thing);
    if ((flags & AridRtF_NoOwner) != 0)
        owner_player_navigating = -1;
    else
        owner_player_navigating = thing->owner;
    nav_sizexy = thing_nav_block_sizexy(thing);
    if (nav_sizexy > 0) nav_sizexy--;
    nearest_search(nav_sizexy, thing->mappos.x.val, thing->mappos.y.val,
      pos1->x.val, pos1->y.val, &px, &py);
    pos2->x.val = px;
    pos2->y.val = py;
    pos2->z.val = get_thing_height_at(thing, pos2);
    if (thing_in_wall_at(thing, pos2))
        get_nearest_valid_position_for_creature_at(thing, pos2);
    nav_thing_can_travel_over_lava = 0;
}
示例#2
0
TbBool jonty_creature_can_see_thing_including_lava_check(const struct Thing *creatng, const struct Thing *thing)
{
    struct CreatureStats *crstat;
    const struct Coord3d *srcpos;
    struct Coord3d pos1;
    struct Coord3d pos2;
    //return _DK_jonty_creature_can_see_thing_including_lava_check(creatng, thing);
    crstat = creature_stats_get_from_thing(creatng);
    srcpos = &creatng->mappos;
    pos1.x.val = srcpos->x.val;
    pos1.y.val = srcpos->y.val;
    pos1.z.val = srcpos->z.val;
    pos2.x.val = thing->mappos.x.val;
    pos2.y.val = thing->mappos.y.val;
    pos2.z.val = thing->mappos.z.val;
    pos1.z.val += crstat->eye_height;
    if (thing->class_id == TCls_Door)
    {
        // If we're immune to lava, or we're already on it - don't care, travel over it
        if (lava_at_position(srcpos) || creature_can_travel_over_lava(creatng))
        {
            SYNCDBG(17, "The %s index %d owned by player %d checks w/o lava %s index %d",
                thing_model_name(creatng),(int)creatng->index,(int)creatng->owner,thing_model_name(thing),(int)thing->index);
            // Check bottom of the thing
            if (line_of_sight_3d_ignoring_specific_door(&pos1, &pos2, thing))
                return true;
            // Check top of the thing
            pos2.z.val += thing->field_58;
            if (line_of_sight_3d_ignoring_specific_door(&pos1, &pos2, thing))
                return true;
            return false;
        } else
        {
            SYNCDBG(17, "The %s index %d owned by player %d checks with lava %s index %d",
                thing_model_name(creatng),(int)creatng->index,(int)creatng->owner,thing_model_name(thing),(int)thing->index);
            // Check bottom of the thing
            if (jonty_line_of_sight_3d_including_lava_check_ignoring_specific_door(&pos1, &pos2, thing))
                return true;
            // Check top of the thing
            pos2.z.val += thing->field_58;
            if (jonty_line_of_sight_3d_including_lava_check_ignoring_specific_door(&pos1, &pos2, thing))
                return true;
            return false;
        }
    } else
    {
        // If we're immune to lava, or we're already on it - don't care, travel over it
        if (lava_at_position(srcpos) || creature_can_travel_over_lava(creatng))
        {
            SYNCDBG(17, "The %s index %d owned by player %d checks w/o lava %s index %d",
                thing_model_name(creatng),(int)creatng->index,(int)creatng->owner,thing_model_name(thing),(int)thing->index);
            // Check bottom of the thing
            if (line_of_sight_3d(&pos1, &pos2))
                return true;
            // Check top of the thing
            pos2.z.val += thing->field_58;
            if (line_of_sight_3d(&pos1, &pos2))
                return true;
            return false;
        } else
        {
            SYNCDBG(17, "The %s index %d owned by player %d checks with lava %s index %d",
                thing_model_name(creatng),(int)creatng->index,(int)creatng->owner,thing_model_name(thing),(int)thing->index);
            // Check bottom of the thing
            if (jonty_line_of_sight_3d_including_lava_check_ignoring_own_door(&pos1, &pos2, creatng->owner))
                return true;
            // Check top of the thing
            pos2.z.val += thing->field_58;
            if (jonty_line_of_sight_3d_including_lava_check_ignoring_own_door(&pos1, &pos2, creatng->owner))
                return true;
            return false;
        }
    }
}