static bool flow (struct anim *k) { struct coord nc; struct pos np, pm, ptf; if (k->oaction != kid_jump) k->i = -1, k->misstep = k->hang = false; bool hang_front = ((k->f.dir == LEFT) ? k->key.left : k->key.right) && ! k->key.up && k->key.shift; bool hang_back = ((k->f.dir == LEFT) ? k->key.right : k->key.left) && ! k->key.up && k->key.shift; int back_dir = (k->f.dir == LEFT) ? RIGHT : LEFT; /* hang front */ survey (_m, pos, &k->f, &nc, &pm, &np); survey (_tf, pos, &k->f, &nc, &ptf, &np); if (k->i >= 8 && k->i <= 10 && hang_front && (is_hangable_pos (&pm, k->f.dir) || is_hangable_pos (&ptf, k->f.dir))) { if (is_hangable_pos (&pm, k->f.dir)) k->hang_pos = pm; else if (is_hangable_pos (&ptf, k->f.dir)) k->hang_pos = ptf; pos2room (&k->hang_pos, k->f.c.room, &k->hang_pos); k->hang = true; play_sample (hang_on_fall_sample, k->f.c.room); kid_hang (k); return false; } /* hang back */ survey (_tf, pos, &k->f, &nc, &ptf, &np); if (k->i >= 8 && k->i <= 10 && hang_back && is_hangable_pos (&ptf, back_dir)) { k->hang_pos = ptf; pos2room (&k->hang_pos, k->f.c.room, &k->hang_pos); k->hang = true; play_sample (hang_on_fall_sample, k->f.c.room); kid_turn (k); return false; } if (k->i == 17) { kid_normal (k); return false; } select_frame (k, kid_jump_frameset, k->i + 1); if (k->f.b == kid_stabilize_frameset[0].frame) k->fo.dx = +2; if (k->f.b == kid_stabilize_frameset[1].frame) k->fo.dx = +6; if (k->f.b == kid_stabilize_frameset[2].frame) k->fo.dx = +4; if (k->f.b == kid_stabilize_frameset[3].frame) k->fo.dx = +0; return true; }
static bool flow (struct anim *k) { struct coord nc; struct pos np, ptf, pbf; enum confg ctf; if (k->oaction != kid_couch) { k->i = -1; k->fall = k->collision = k->misstep = false; k->wait = 0; } if (k->uncouch_slowly) { k->wait = 36; k->uncouch_slowly = false; } if (k->oaction == kid_climb) k->i = 10; if (k->oaction == kid_couch_collision) k->collision = true, k->inertia = k->cinertia = 0; if (k->oaction == kid_fall) { k->fall = true; k->inertia = k->cinertia = 0; } /* if (k->i > 2 && k->hit_by_loose_floor) */ /* k->i = -1; */ /* unclimb */ int dir = (k->f.dir == LEFT) ? +1 : -1; ctf = survey (_tf, pos, &k->f, &nc, &ptf, &np)->fg; survey (_bf, pos, &k->f, &nc, &pbf, &np); struct pos ph; prel (&pbf, &ph, +1, dir); if (k->i == -1 && ! k->collision && ! k->fall && ! k->hit_by_loose_floor && k->item_pos.room == -1 && is_hangable_pos (&ph, k->f.dir) && dist_next_place (&k->f, _tf, pos, 0, true) <= 27 && ! (ctf == DOOR && k->f.dir == LEFT && door_at_pos (&ptf)->i > DOOR_CLIMB_LIMIT)) { pos2room (&ph, k->f.c.room, &k->hang_pos); kid_unclimb (k); return false; } if (k->i == 12) { k->hit_by_loose_floor = false; kid_normal (k); return false; } if (k->i == 2 && k->item_pos.room != -1 && ! k->collision && ! k->fall) { if (is_potion (&k->item_pos)) kid_drink (k); else if (is_sword (&k->item_pos)) kid_raise_sword (k); else { k->item_pos.room = -1; goto no_item; } return false; } no_item: if (k->i == 2 && k->key.down && k->cinertia == 0 && k->wait-- <= 0 && ((k->f.dir == LEFT && k->key.left) || (k->f.dir == RIGHT && k->key.right))) { k->i = 0; select_frame (k, kid_couch_frameset, 0); return true; } if (k->i != 2 || (! k->key.down && k->wait-- <= 0)) k->i++; if (k->i == 1 && k->wait > 0 && ((k->fall == true && k->hurt) || k->hit_by_loose_floor)) k->i = 2; select_frame (k, kid_couch_frameset, k->i); if (k->oaction == kid_climb) k->fo.dx += 7; if (k->i > 0 && k->i < 3) k->fo.dx -= k->cinertia; if (k->cinertia > 0) k->cinertia--; return true; }
static bool flow (struct anim *k) { struct pos np; if (k->oaction != kid_hang_free) k->i = 5, k->j = -1, k->wait = 3, k->reverse = true; bool hang_back = ((k->f.dir == LEFT) ? k->key.right : k->key.left) && ! k->key.up && k->key.shift; int back_dir = (k->f.dir == LEFT) ? RIGHT : LEFT; /* hang back */ if (k->i >= 7 && hang_back && is_hangable_pos (&k->hang_pos, back_dir)) { play_audio (&hang_on_fall_audio, NULL, k->id); kid_turn (k); return false; } /* climb */ if ((k->i < 5 || k->j > -1 || k->hang_caller != kid_unclimb) && k->key.up && ! ((k->key.left || k->key.right) && k->hang_caller == kid_unclimb) && ! k->hang_limit) { kid_climb (k); return false; } /* release */ if ((! k->key.shift || k->hang_limit || get_hanged_con (&k->hang_pos, k->f.dir) == NO_FLOOR) && (k->i < 5 || k->j > -1)) { int dir = (k->f.dir == LEFT) ? -1 : +1; k->hang_limit = false; if (! is_strictly_traversable (&k->hang_pos) && k->i >= 4) { place_frame (&k->f, &k->f, kid_vjump_frameset[13].frame, &k->hang_pos, (k->f.dir == LEFT) ? +7 : PLACE_WIDTH + 9, -8); kid_vjump (k); return false; } if (! is_strictly_traversable (prel (&k->hang_pos, &np, +0, dir)) && k->i <= 4) { place_frame (&k->f, &k->f, kid_vjump_frameset[13].frame, &k->hang_pos, (k->f.dir == LEFT) ? +7 : PLACE_WIDTH + 5, -8); kid_vjump (k); return false; } if (is_strictly_traversable (&k->hang_pos) && k->i >= 4) { place_frame (&k->f, &k->f, kid_fall_frameset[0].frame, &k->hang_pos, (k->f.dir == LEFT) ? +10 : +22, +4); kid_fall (k); return false; } if (is_strictly_traversable (prel (&k->hang_pos, &np, +0, dir)) && k->i <= 4) { place_frame (&k->f, &k->f, kid_fall_frameset[0].frame, &k->hang_pos, (k->f.dir == LEFT) ? -10 : PLACE_WIDTH + 10, +12); kid_fall (k); return false; } } if (k->reverse && k->i > 0) { if (k->i == 4 && k->j++ > 0) k->hang_limit = true; k->i--; } else if (k->reverse && k->i == 0) { if (k->wait == 0) { k->reverse = false; k->i++; } else k->wait--; } else if (! k->reverse && ((k->j == 0 && k->i < 12) || (k->j > 0 && k->i < 9))) k->i++; else if (! k->reverse && ((k->j == 0 && k->i == 12) || (k->j > 0 && k->i == 9))) { k->reverse = true; k->i--; } k->fo.b = kid_hang_frameset[k->i].frame; k->fo.dx = (k->reverse) ? -kid_hang_frameset[k->i + 1].dx : kid_hang_frameset[k->i].dx; k->fo.dy = (k->reverse) ? -kid_hang_frameset[k->i + 1].dy : kid_hang_frameset[k->i].dy; if (k->f.b == kid_hang_13) k->fo.dx = +0, k->fo.dy = +1; if (k->reverse && k->j == 0 && k->i == 0 && k->wait < 3) k->fo.dy = 0; return true; }
static bool flow (struct anim *k) { if (k->oaction != kid_hang_wall) k->i = 3, k->wait = 0, k->reverse = false; bool hang_back = ((k->f.dir == LEFT) ? k->key.right : k->key.left) && ! k->key.up && k->key.shift; int back_dir = (k->f.dir == LEFT) ? RIGHT : LEFT; /* hang back */ if (k->i == 4 && k->reverse && hang_back && is_hangable_pos (&k->hang_pos, back_dir)) { play_audio (&hang_on_fall_audio, NULL, k->id); kid_turn (k); return false; } if ((! k->key.shift && (k->reverse || k->i > 3)) || k->hang_limit || get_hanged_con (&k->hang_pos, k->f.dir) == NO_FLOOR) { if (is_strictly_traversable (&k->hang_pos)) { place_frame (&k->f, &k->f, kid_fall_frameset[0].frame, &k->hang_pos, (k->f.dir == LEFT) ? +10 : +22, +4); kid_fall (k); k->hang_limit = false; return false; } place_frame (&k->f, &k->f, kid_vjump_frameset[13].frame, &k->hang_pos, (k->f.dir == LEFT) ? +12 : PLACE_WIDTH + 2, -8); kid_vjump (k); k->hang_limit = false; return false; } if (k->key.up && ! ((k->key.left || k->key.right) && k->hang_caller == kid_unclimb) && ! k->hang_limit) { kid_climb (k); return false; } if (! k->reverse && k->i < 6) k->i++; else if (! k->reverse && k->i == 6) k->reverse = true; else if (k->reverse && k->i > 4 && k->wait == 0) k->i--, k->wait = 1; else if (k->reverse && k->i >= 4 && k->wait > 0) k->wait--; k->fo.b = kid_hang_frameset[k->i].frame; k->fo.dx = (k->reverse) ? -kid_hang_frameset[k->i + 1].dx : kid_hang_frameset[k->i].dx; k->fo.dy = (k->reverse) ? -kid_hang_frameset[k->i + 1].dy : kid_hang_frameset[k->i].dy; if (k->f.b == kid_hang_13) k->fo.dx = +0, k->fo.dy = +1; if (k->reverse && k->wait == 0) { k->fo.dx = 0; k->fo.dy = 0; } return true; }