Exemplo n.º 1
0
TbBool action_point_is_creature_from_list_within(const struct ActionPoint *apt, long first_thing_idx)
{
    unsigned long k;
    int i;
    SYNCDBG(8,"Starting");
    k = 0;
    i = first_thing_idx;
    while (i != 0)
    {
        struct Thing *thing;
        thing = thing_get(i);
        TRACE_THING(thing);
        struct CreatureControl *cctrl;
        cctrl = creature_control_get_from_thing(thing);
        if (thing_is_invalid(thing) || creature_control_invalid(cctrl))
        {
            ERRORLOG("Jump to invalid creature detected");
            break;
        }
        i = cctrl->players_next_creature_idx;
        // Thing list loop body
        // Range of 0 means activate when on the same subtile
        if (apt->range <= 0)
        {
            if ((apt->mappos.x.stl.num == thing->mappos.x.stl.num)
             && (apt->mappos.y.stl.num == thing->mappos.y.stl.num)) {
                return true;
            }
        } else
        {
            long dist;
            dist = get_distance_xy(thing->mappos.x.val, thing->mappos.y.val, apt->mappos.x.val, apt->mappos.y.val);
            if (apt->range > dist) {
                return true;
            }
        }
        // Thing list loop body ends
        k++;
        if (k > CREATURES_COUNT)
        {
            ERRORLOG("Infinite loop detected when sweeping creatures list");
            break;
        }
    }
    return false;
}
Exemplo n.º 2
0
static int get_distance_proc( INSTANCE * a, INSTANCE * b )
{
    if ( a && b ) return ( get_distance_xy( a, LOCINT32( mod_grproc, b, COORDX ), LOCINT32( mod_grproc, b, COORDY ), LOCINT32( mod_grproc, b, RESOLUTION ) ) ) ;
    return -1 ;
}