Ejemplo n.º 1
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);
}
Ejemplo n.º 2
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;
}
Ejemplo n.º 3
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;
}
Ejemplo n.º 4
0
void
fight_hit (struct anim *k, struct anim *ke)
{
  if (k->immortal || k->sword_immune) return;
  if (k->current_lives <= 0) return;
  if (is_anim_fall (&k->f) || is_kid_stairs (&k->f))
    return;

  place_on_the_ground (&k->f, &k->f.c);
  k->xf.b = NULL;

  if (! is_in_fight_mode (k)) k->current_lives = 0;
  else k->current_lives--;

  if (! is_guard (ke))
    upgrade_skill (&ke->skill, &k->skill, k->total_lives);

  int d = (k->f.dir == LEFT) ? +1 : -1;
  struct pos pb;
  survey (_m, pos, &k->f, NULL, &k->p, NULL);
  prel (&k->p, &pb, 0, d);

  if (k->current_lives <= 0 && ! is_strictly_traversable (&pb)) {
    k->current_lives = 0;
    k->death_reason = FIGHT_DEATH;
    ke->alert_cycle = anim_cycle;
    anim_die (k);
  } else anim_sword_hit (k);

  if (is_in_fight_mode (k)) {
    backoff_from_range (ke, k, ATTACK_RANGE - 20, true, false);
    get_in_range (ke, k, ATTACK_RANGE - 10, false, false);
  }

  k->splash = true;

  if (k->id == current_kid_id) {
    mr.flicker = 2;
    mr.color = get_flicker_blood_color ();
    play_audio (&harm_audio, NULL, k->id);
  } else play_audio (&guard_hit_audio, NULL, k->id);
}
Ejemplo n.º 5
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;
}