viewing paste Unknown #17363 | C

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
int unit_set_walkdelay(struct block_list *bl, int64 tick, int delay, int type) {
    struct unit_data *ud = unit->bl2ud(bl);
    if (delay <= 0 || !ud) return 0;
 
    if (type) {
        if (DIFF_TICK(ud->canmove_tick, tick+delay) > 0)
            return 0;
    } else {
        //Don't set walk delays when already trapped.
        if (!unit->can_move(bl))
            return 0;
        //Immune to being stopped for double the flinch time
        if (DIFF_TICK(ud->canmove_tick, tick-delay) > 0)
            return 0;
    }
    ud->canmove_tick = tick + delay;
    if (ud->walktimer != INVALID_TIMER) {
        //Stop walking, if chasing, readjust timers.
        if (delay == 1) {
            //Minimal delay (walk-delay) disabled. Just stop walking.
            unit->stop_walking(bl,4);
        } else {
            //Resume running after can move again [Kevin]
            if(ud->state.running)
            {
                timer->add(ud->canmove_tick, unit->resume_running, bl->id, (intptr_t)ud);
            }
            else
            {
                unit->stop_walking(bl,2|4);
                if(ud->target)
                    timer->add(ud->canmove_tick+1, unit->walktobl_sub, bl->id, ud->target);
            }
        }
    }
    return 1;
}
Viewed 896 times, submitted by milk.