Beispiel #1
0
void
guard_die_chopped (struct anim *g)
{
  if (fg (&g->p) != CHOPPER) {
    guard_die_properly (g);
    return;
  }

  g->oaction = g->action;
  g->action = guard_die_chopped;
  g->f.flip = (g->f.dir == RIGHT) ? ALLEGRO_FLIP_HORIZONTAL : 0;

  int dx, dy;

  if (g->type == SHADOW) {
    dx = (g->f.dir == LEFT) ? -8 : -7;
    dy = +47;
  } else {
    dx = (g->f.dir == LEFT) ? -10 : -13;
    dy = (g->type == SKELETON) ? +45 : +43;
  }

  ALLEGRO_BITMAP *bitmap = get_guard_die_chopped_bitmap (g->type);
  place_frame (&g->f, &g->f, bitmap, &g->p, dx, dy);

  if (g->oaction != guard_die_chopped
      && ! g->glory_sample) {
    play_audio (&glory_audio, NULL, g->id);
    g->glory_sample = true;
  }

  g->current_lives = 0;
  g->xf.b = NULL;
}
Beispiel #2
0
struct anim *
create_guard (struct anim *g0, struct anim *g1, struct pos *p, enum dir dir)
{
    if (! g0) {
        g1->f.b = get_guard_normal_bitmap (g1->type);
        g1->fo.b = g1->f.b;
        g1->action = guard_normal;
        g1->total_lives = 3;
        g1->current_lives = 3;
        g1->enemy_id = -1;
        g1->oenemy_id = -1;
        g1->fight = true;
        g1->has_sword = true;
        g1->skill.counter_attack_prob = -1;
        g1->skill.counter_defense_prob = -1;
        g1->glory_sample = false;

        if (g1->type == SHADOW) g1->shadow = true;

        place_frame (&g1->f, &g1->f, g1->f.b, p,
                     g1->f.dir == LEFT ? +16 : +22, +14);
        place_on_the_ground (&g1->f, &g1->f.c);

        update_depressible_floor (g1, -7, -26);
    }

    return g1;
}
Beispiel #3
0
static bool
flow (struct anim *k)
{
  struct pos hanged_pos;

  if (k->oaction != kid_unclimb) k->i = 14;
  if (k->oaction == kid_climb) k->i = 3;

  if (k->i == 0) {
    kid_hang (k);
    return false;
  }

  if (k->i == 14) {
    get_hanged_pos (&k->hang_pos, k->f.dir, &hanged_pos);
    place_frame (&k->f, &k->f, kid_climb_frameset[13].frame,
                 &hanged_pos, 18, 25);
  }

  k->i--;

  k->fo.b = kid_climb_frameset[k->i].frame;
  k->fo.dx = -kid_climb_frameset[k->i + 1].dx;
  k->fo.dy = -kid_climb_frameset[k->i + 1].dy;

  if (k->oaction == kid_climb) k->fo.dx += +2;
  if (k->i == 1) k->fo.dx += -3;

  return true;
}
Beispiel #4
0
static void
place_in_initial_fall (struct anim *g)
{
  struct coord nc;
  struct pos np, pmt, pmtf, pmtb;
  struct pos fall_pos;

  int dirf = (g->f.dir == LEFT) ? -1 : +1;
  int dirb = (g->f.dir == LEFT) ? +1 : -1;
  survey (_mt, pos, &g->f, &nc, &pmt, &np);
  prel (&pmt, &pmtf, +0, dirf);
  prel (&pmt, &pmtb, +0, dirb);

  fall_pos.room = -1;

  if (is_strictly_traversable (&pmt)) fall_pos = pmt;
  else if (is_strictly_traversable (&pmtf)) fall_pos = pmtf;
  else if (is_strictly_traversable (&pmtb)) fall_pos = pmtb;

  struct frameset *frameset = get_guard_fall_frameset (g->type);

  if (fall_pos.room != - 1)
    place_frame (&g->f, &g->f, frameset[0].frame,
                 &fall_pos,
                 (g->f.dir == LEFT) ? PLACE_WIDTH - 12 : +6,
                 (g->f.dir == LEFT) ? 23 : 27);
}
Beispiel #5
0
static bool
flow (struct anim *k)
{
  if (k->oaction != kid_turn)
    k->i = -1, k->misstep = k->hang = false;

  if (! k->turn)
    k->turn = ((k->f.dir == RIGHT) && k->key.left)
      || ((k->f.dir == LEFT) && k->key.right);
  bool run = ((k->f.dir == RIGHT) ? k->key.right : k->key.left)
    && ! k->key.shift;
  bool jump = ((k->f.dir == RIGHT) && k->key.right && k->key.up)
    || ((k->f.dir == LEFT) && k->key.left && k->key.up);
  bool couch = k->key.down;

  if (k->i == 3) {
    int dc = dist_collision (&k->f, false, &k->ci);
    int df = dist_fall (&k->f, false);

    if (k->hang) kid_hang (k);
    else if (k->turn) {
      k->i = -1; k->turn = false;
      k->action = kid_normal;
      kid_turn (k);
    }
    else if (couch) kid_couch (k);
    else if (jump) kid_jump (k);
    else if (run && dc > PLACE_WIDTH && df > PLACE_WIDTH)
      kid_start_run (k);
    else kid_stabilize (k);

    return false;
  }

  if (k->f.b == kid_keep_sword_frameset[9].frame) k->i = 2;

  /* hang */
  if (k->oaction == kid_fall
      || k->oaction == kid_jump
      || k->oaction == kid_run_jump
      || k->oaction == kid_hang_free
      || k->oaction == kid_hang_wall) {
    k->i = 2, k->hang = true;
    place_frame (&k->f, &k->f, kid_turn_frameset[2].frame,
                 &k->hang_pos, (k->f.dir == LEFT)
                 ? 7 : PLACE_WIDTH, +4);
  }

  select_frame (k, kid_turn_frameset, k->i + 1);

  if (k->f.b == kid_stabilize_frameset[0].frame) k->fo.dx = +6;
  if (k->f.b == kid_stabilize_frameset[1].frame) k->fo.dx = +10;
  if (k->f.b == kid_stabilize_frameset[2].frame) k->fo.dx = +8;
  if (k->f.b == kid_stabilize_frameset[3].frame) k->fo.dx = +4;
  if (k->f.b == kid_turn_frameset[3].frame) k->fo.dx = +3;
  if (k->f.b == kid_keep_sword_frameset[9].frame) k->fo.dx = -2;

  return true;
}
Beispiel #6
0
void
kid_couch_collision (struct anim *k)
{
  k->action = kid_couch_collision;
  place_frame (&k->f, &k->f, kid_couch_frameset[0].frame,
               &k->ci.p, (k->f.dir == LEFT)
               ? +PLACE_WIDTH + 24 : -PLACE_WIDTH + 18, +27);
  kid_couch (k);
  play_sample (hit_wall_sample, k->f.c.room);
}
Beispiel #7
0
void
kid_stabilize_back_collision (struct anim *k)
{
  k->action = kid_stabilize_back_collision;
  place_frame (&k->f, &k->f, kid_stabilize_frameset[0].frame,
               &k->ci.p, (k->f.dir == LEFT)
               ? -PLACE_WIDTH + 24 : PLACE_WIDTH + 18, +17);
  kid_stabilize (k);
  play_sample (hit_wall_sample, k->f.c.room);
}
Beispiel #8
0
void
kid_couch_suddenly (struct anim *k)
{
  k->action = kid_couch_suddenly;
  struct coord nc; struct pos np, pmt;
  survey (_mt, pos, &k->f, &nc, &pmt, &np);
  place_frame (&k->f, &k->f, kid_couch_frameset[0].frame,
               &pmt, (k->f.dir == LEFT)
               ? 24 : 18, +27);
  kid_couch (k);
}
Beispiel #9
0
void
guard_die_suddenly (struct anim *g)
{
  if (con (&g->p)->fg == SPIKES_FLOOR
      || con (&g->p)->fg == CHOPPER) {
    guard_die_properly (g);
    return;
  }

  g->oaction = g->action;
  g->action = guard_die_suddenly;
  g->f.flip = (g->f.dir == RIGHT) ? ALLEGRO_FLIP_HORIZONTAL : 0;

  struct frameset *frameset = get_guard_die_frameset (g->type);

  int dy = (g->type == SKELETON) ? +44 : +47;

  place_frame (&g->f, &g->f, frameset[5].frame,
               &g->p, (g->f.dir == LEFT)
               ? +9 : +4, dy);

  if (g->oaction != guard_die_suddenly) {
    struct anim *ke = get_anim_by_id (g->enemy_id);
    if (! ke) ke = get_anim_by_id (g->oenemy_id);
    if (ke && ke->id == current_kid_id
        && ! g->glory_sample
        && g->death_reason != SHADOW_FIGHT_DEATH) {
      play_sample (glory_sample, NULL, ke->id);
      g->glory_sample = true;
    }

    g->oenemy_id = -1;

    if (ke) upgrade_skill (&ke->skill, &g->skill);
  }

  g->current_lives = 0;
  g->xf.b = NULL;

  g->hit_by_loose_floor = false;

  /* fall */
  struct pos pm;
  survey (_m, pos, &g->f, NULL, &pm, NULL);
  if (is_strictly_traversable (&pm)) {
    guard_fall (g);
    return;
  }

  /* depressible floors */
  update_depressible_floor (g, -12, -28);
}
Beispiel #10
0
void
guard_die_spiked (struct anim *g)
{
  if (con (&g->p)->fg != SPIKES_FLOOR) {
    guard_die_properly (g);
    return;
  }

  g->oaction = g->action;
  g->action = guard_die_spiked;
  g->f.flip = (g->f.dir == RIGHT) ? ALLEGRO_FLIP_HORIZONTAL : 0;

  if (g->oaction != guard_die_spiked) {
    g->splash = true;
    g->death_reason = SPIKES_DEATH;

    assert (con (&g->p)->fg == SPIKES_FLOOR);
    struct spikes_floor *s = spikes_floor_at_pos (&g->p);
    s->i = 4;
    s->state = 5;
    s->inactive = true;
    s->murdered_anim = g->id;

    if (g->type == SKELETON)
      play_sample (skeleton_sample, NULL, g->id);
    else play_sample (spiked_sample, NULL, g->id);

    struct anim *ke = get_anim_by_id (g->enemy_id);
    if (! ke) ke = get_anim_by_id (g->oenemy_id);
    if (ke && ke->id == current_kid_id
        && ! g->glory_sample
        && g->death_reason != SHADOW_FIGHT_DEATH) {
      play_sample (glory_sample, NULL, ke->id);
      g->glory_sample = true;
    }
    g->oenemy_id = -1;

    if (ke) upgrade_skill (&ke->skill, &g->skill);
  }

  g->current_lives = 0;

  int dy;
  if (g->type == SKELETON) dy = +45;
  else dy = (g->f.dir == LEFT) ? +32 : +31;

  ALLEGRO_BITMAP *bitmap = get_guard_die_spiked_bitmap (g->type);
  place_frame (&g->f, &g->f, bitmap,
               &g->p, (g->f.dir == LEFT) ? +8 : +9, dy);

  g->xf.b = NULL;
}
Beispiel #11
0
void
guard_resurrect (struct anim *g)
{
  struct pos pm;
  survey (_m, pos, &g->f, NULL, &pm, NULL);
  g->current_lives = g->total_lives;
  g->death_reason = NO_DEATH;
  g->action = guard_normal;
  place_frame (&g->f, &g->f, get_guard_normal_bitmap (g->type),
               &pm, g->f.dir == LEFT ? +16 : +22, +14);
  place_on_the_ground (&g->f, &g->f.c);
  reset_murder_spikes_floor (g->id);
}
Beispiel #12
0
struct anim *
create_mouse (struct anim *m0, struct anim *m1, struct pos *p, enum dir dir)
{
  if (! m0) {
    m1->f.b = mouse_normal_00;
    m1->fo.b = mouse_normal_00;
    m1->fight = false;
    m1->action = mouse_normal;

    place_frame (&m1->f, &m1->f, mouse_normal_00, p,
                 m1->f.dir == LEFT ? +22 : +31, +48);
  }

  return m1;
}
Beispiel #13
0
void
guard_die_spiked (struct anim *g)
{
  if (fg (&g->p) != SPIKES_FLOOR) {
    guard_die_properly (g);
    return;
  }

  g->oaction = g->action;
  g->action = guard_die_spiked;
  g->f.flip = (g->f.dir == RIGHT) ? ALLEGRO_FLIP_HORIZONTAL : 0;

  assert (fg (&g->p) == SPIKES_FLOOR);
  struct spikes_floor *s = spikes_floor_at_pos (&g->p);

  if (s->i != 4 || s->state != 5 || ! s->inactive) {
    s->i = 4;
    s->state = 5;
    s->inactive = true;
    register_changed_pos (&g->p);
  }

  if (g->oaction != guard_die_spiked) {
    g->splash = true;
    g->death_reason = SPIKES_DEATH;

    if (g->type == SKELETON)
      play_audio (&skeleton_audio, NULL, g->id);
    else play_audio (&spiked_audio, NULL, g->id);

    if (! g->glory_sample) {
      play_audio (&glory_audio, NULL, g->id);
      g->glory_sample = true;
    }
  }

  g->current_lives = 0;

  int dy;
  if (g->type == SKELETON) dy = +45;
  else dy = (g->f.dir == LEFT) ? +32 : +31;

  ALLEGRO_BITMAP *bitmap = get_guard_die_spiked_bitmap (g->type);
  place_frame (&g->f, &g->f, bitmap,
               &g->p, (g->f.dir == LEFT) ? +8 : +9, dy);

  g->xf.b = NULL;
}
Beispiel #14
0
static bool
flow (struct anim *k)
{
  if (k->oaction != kid_misstep) k->i = -1, k->misstep = true;

  if (k->i == 10) {
    place_frame (&k->f, &k->f, kid_normal_00, &k->p,
                 (k->f.dir == LEFT) ? +11 : PLACE_WIDTH + 7, 15);
    kid_normal (k);
    return false;
  }

  select_frame (k, kid_misstep_frameset, k->i + 1);

  return true;
}
Beispiel #15
0
void
guard_resurrect (struct anim *g)
{
  g->splash = false;
  g->invisible = false;
  if (g->current_lives > 0) return;
  struct pos pm;
  survey (_m, pos, &g->f, NULL, &pm, NULL);
  g->current_lives = g->total_lives;
  g->death_reason = NO_DEATH;
  g->action = guard_normal;
  g->glory_sample = false;
  place_frame (&g->f, &g->f, get_guard_normal_bitmap (g->type),
               &pm, g->f.dir == LEFT ? +16 : +22, +14);
  place_on_the_ground (&g->f, &g->f.c);
  if (fg (&g->p) == SPIKES_FLOOR)
    spikes_floor_at_pos (&g->p)->inactive = false;
}
Beispiel #16
0
void
draw_start_guards (ALLEGRO_BITMAP *bitmap, enum vm vm)
{
    int i;
    for (i = 0; i < GUARDS; i++) {
        struct guard *g = &global_level.guard[i];
        if (g->type == NO_ANIM) continue;
        struct frame f;
        f.c.room = g->p.room;
        f.b = get_guard_normal_bitmap (g->type);
        f.b = apply_guard_palette (f.b, g->type, g->style, vm);
        f.b = apply_palette (f.b, start_anim_palette);
        f.flip = (g->dir == RIGHT) ? ALLEGRO_FLIP_HORIZONTAL : 0;
        place_frame (&f, &f, f.b, &g->p,
                     g->dir == LEFT ? +16 : +22, +14);
        place_on_the_ground (&f, &f.c);
        draw_frame (bitmap, &f);
    }
}
Beispiel #17
0
void
guard_die_suddenly (struct anim *g)
{
  enum confg f = fg (&g->p);
  if ( f == SPIKES_FLOOR || f == CHOPPER) {
    guard_die_properly (g);
    return;
  }

  g->oaction = g->action;
  g->action = guard_die_suddenly;
  g->f.flip = (g->f.dir == RIGHT) ? ALLEGRO_FLIP_HORIZONTAL : 0;

  struct frameset *frameset = get_guard_die_frameset (g->type);

  int dy = (g->type == SKELETON) ? +44 : +47;

  place_frame (&g->f, &g->f, frameset[5].frame,
               &g->p, (g->f.dir == LEFT)
               ? +9 : +4, dy);

  if (g->oaction != guard_die_suddenly
      && ! g->glory_sample) {
    play_audio (&glory_audio, NULL, g->id);
    g->glory_sample = true;
  }

  g->current_lives = 0;
  g->xf.b = NULL;

  g->hit_by_loose_floor = false;

  /* fall */
  struct pos pm;
  survey (_m, pos, &g->f, NULL, &pm, NULL);
  if (is_strictly_traversable (&pm)) {
    guard_fall (g);
    return;
  }

  /* depressible floors */
  update_depressible_floor (g, -12, -28);
}
Beispiel #18
0
void
guard_die_chopped (struct anim *g)
{
  if (con (&g->p)->fg != CHOPPER) {
    guard_die_properly (g);
    return;
  }

  g->oaction = g->action;
  g->action = guard_die_chopped;
  g->f.flip = (g->f.dir == RIGHT) ? ALLEGRO_FLIP_HORIZONTAL : 0;

  int dx, dy;

  if (g->type == SHADOW) {
    dx = (g->f.dir == LEFT) ? -8 : -7;
    dy = +47;
  } else {
    dx = (g->f.dir == LEFT) ? -10 : -13;
    dy = (g->type == SKELETON) ? +45 : +43;
  }

  ALLEGRO_BITMAP *bitmap = get_guard_die_chopped_bitmap (g->type);
  place_frame (&g->f, &g->f, bitmap, &g->p, dx, dy);

  if (g->oaction != guard_die_chopped) {
    struct anim *ke = get_anim_by_id (g->enemy_id);
    if (! ke) ke = get_anim_by_id (g->oenemy_id);
    if (ke && ke->id == current_kid_id
        && ! g->glory_sample
        && g->death_reason != SHADOW_FIGHT_DEATH) {
      play_sample (glory_sample, NULL, ke->id);
      g->glory_sample = true;
    }

    g->oenemy_id = -1;

    if (ke) upgrade_skill (&ke->skill, &g->skill);
  }

  g->current_lives = 0;
  g->xf.b = NULL;
}
Beispiel #19
0
static bool
flow (struct anim *g)
{
  if (g->oaction != guard_die) {
    place_frame (&g->f, &g->f, guard_die_frameset[0].frame,
                 &g->p, (g->f.dir == LEFT)
                 ? +13 : +21, (g->type == SHADOW) ? +18 : +17);
    g->i = -1, g->j = 0;
    if (g->type == SKELETON)
      play_sample (skeleton_sample, NULL, g->id);

    struct anim *ke = get_anim_by_id (g->enemy_id);
    if (! ke) ke = get_anim_by_id (g->oenemy_id);
    if (ke && ke->id == current_kid_id
        && ! g->glory_sample
        && g->death_reason != SHADOW_FIGHT_DEATH) {
      play_sample (glory_sample, NULL, ke->id);
      g->glory_sample = true;
    }

    g->oenemy_id = -1;

    if (ke) upgrade_skill (&ke->skill, &g->skill);

    g->xf.b = NULL;
  }

  g->current_lives = 0;

  g->i = g->i < 5 ? g->i + 1 : 5;

  struct frameset *frameset = get_guard_die_frameset (g->type);
  select_frame (g, frameset, g->i);

  if (g->j >= 1) g->fo.dx = g->fo.dy = 0;
  if (g->i == 5) g->j = 1;
  if (g->j == 1) g->j++;

  return true;
}
Beispiel #20
0
static bool
flow (struct anim *k)
{
  if (k->oaction != kid_stairs) {
    place_frame (&k->f, &k->f, kid_stairs_frameset[0].frame,
                 &k->p, +3, +16);
    k->i = k->j = -1;
  }

  if (k->i >= 9) if (k->f.c.l->end) k->f.c.l->end (&k->p);

  if (k->i == 11 && k->j < 17) {
    k->invisible = true;
    k->j++;
  } else if (k->i < 11) k->j = k->i + 1;

  int i = k->i <= 10 ? k->i + 1: 11;

  select_frame (k, kid_stairs_frameset, i);

  if (k->j > 11) k->fo.dx = k->fo.dy = 0;

  return true;
}
Beispiel #21
0
void
raise_skeleton (struct anim *s)
{
  s->oaction = s->action;
  s->action = raise_skeleton;
  s->f.flip = (s->f.dir == RIGHT) ? ALLEGRO_FLIP_HORIZONTAL : 0;

  if (s->oaction != raise_skeleton) {
    play_sample (skeleton_sample, NULL, s->id);
    place_frame (&s->f, &s->f, skeleton_die_frameset[2].frame,
                 &s->p, (s->f.dir == LEFT) ? +12 : +0, +43);
    s->i = 2;
  }

  if (s->i-- == 0) {
    guard_vigilant (s);
    return;
  }

  s->fo.b = skeleton_die_frameset[s->i].frame;
  s->fo.dx = -skeleton_die_frameset[s->i + 1].dx;
  s->fo.dy = -skeleton_die_frameset[s->i + 1].dy;
  next_frame (&s->f, &s->f, &s->fo);
}
Beispiel #22
0
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;
}
Beispiel #23
0
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;
}
Beispiel #24
0
static bool
flow (struct anim *k)
{
  struct pos pbf, pmt;
  survey (_bf, pos, &k->f, NULL, &pbf, NULL);

  k->collision = false;
  k->hit_by_loose_floor = false;

  bool turn = ((k->f.dir == RIGHT) && k->key.left)
    || ((k->f.dir == LEFT) && k->key.right);
  bool walk = ((k->f.dir == RIGHT) && k->key.right && k->key.shift)
    || ((k->f.dir == LEFT) && k->key.left && k->key.shift);
  bool run = (((k->f.dir == RIGHT) && k->key.right)
              || ((k->f.dir == LEFT) && k->key.left)) && ! walk;
  bool jump = ((k->f.dir == RIGHT) && k->key.right && k->key.up)
    || ((k->f.dir == LEFT) && k->key.left && k->key.up);
  bool couch = k->key.down;
  bool vjump = k->key.up;
  bool drink = is_potion (&pbf) && k->key.shift;
  bool raise_sword = is_sword (&pbf) && k->key.shift;
  bool take_sword = k->key.enter && k->has_sword;

  survey (_mt, pos, &k->f, NULL, &pmt, NULL);
  bool stairs = k->key.up && ! k->key.left && ! k->key.right
    && fg (&pmt) == LEVEL_DOOR
    && level_door_at_pos (&pmt)->i == 0
    && k == get_anim_by_id (0);

  if (k->oaction == kid_normal
      && k->current_lives <= 0) {
    survey (_mt, pos, &k->f, NULL, &pmt, NULL);
    k->p = pmt;
    kid_die (k);
    return false;
  }

  if (k->oaction == kid_normal) {
    if (stairs) {
      k->p = pmt;
      kid_stairs (k);
      return false;
    }

    if (couch) {
      kid_couch (k);
      return false;
    }

    if (jump) {
      kid_jump (k);
      return false;
    }

    if (turn) {
      kid_turn (k);
      return false;
    }

    if (vjump) {
      kid_vjump (k);
      return false;
    }
    if (walk) {
      kid_walk (k);
      return false;
    }

    if (run) {
      if (dist_collision (&k->f, _bf, -4, -4, &k->ci) < 29)
        kid_walk (k);
      else kid_start_run (k);
      return false;
    }

    if (drink) {
      k->item_pos = pbf;
      place_frame (&k->f, &k->f, kid_couch_frameset[0].frame,
                   &k->item_pos, (k->f.dir == LEFT)
                   ? PLACE_WIDTH + 3 : +9, +27);
      kid_couch (k);
      return false;
    }

    if (raise_sword) {
      k->item_pos = pbf;
      kid_couch (k);
      return false;
    }

    if (take_sword) {
      kid_take_sword (k);
      return false;
    }
  }

  k->fo.b = kid_normal_00;
  k->fo.dx = k->fo.dy = +0;

  if (k->f.b == kid_stabilize_frameset[3].frame) k->fo.dx = +2;
  if (k->f.b == kid_walk_frameset[11].frame) k->fo.dx = -1;
  if (k->f.b == kid_jump_frameset[17].frame) k->fo.dx = -2;
  if (k->f.b == kid_couch_frameset[12].frame) k->fo.dx = -2;
  if (k->f.b == kid_vjump_frameset[17].frame) k->fo.dx = +2;
  if (k->f.b == kid_drink_frameset[7].frame) k->fo.dx = +0;
  if (k->f.b == kid_keep_sword_frameset[9].frame) k->fo.dx = +2;

  k->xf.b = NULL;

  return true;
}