예제 #1
0
static bool
flow (struct anim *g)
{
  struct pos pmt;

  bool vigilant = g->key.enter;

  if (g->oaction == guard_normal
      && g->current_lives <= 0
      && anim_cycle > 0) {
    survey (_mt, pos, &g->f, NULL, &pmt, NULL);
    g->p = pmt;
    guard_die (g);
    return false;
  }

  if (g->oaction == guard_normal
      && vigilant
      && anim_cycle > 0) {
    guard_vigilant (g);
    return false;
  }

  g->fo.b = get_guard_normal_bitmap (g->type);
  g->fo.dx = g->fo.dy = +0;

  select_xframe (&g->xf, sword_frameset, 30);

  if (g->type == VIZIER) g->xf.dy += +4;
  if (g->type == SKELETON) g->xf.dx += -5, g->xf.dy += -6;

  return true;
}
예제 #2
0
static bool
flow (struct anim *g)
{
  if (g->oaction != guard_walkb) g->i = -1;

  if (g->i == 1) {
    guard_vigilant (g);
    return false;
  }

  struct frameset *frameset = get_guard_walkb_frameset (g->type);
  select_frame (g, frameset, g->i + 1);

  if (g->i == 0) g->j = 10;
  if (g->i == 1) g->j = 3;

  select_xframe (&g->xf, sword_frameset, g->j);

  if (g->j == 10) g->xf.dx = -10, g->xf.dy = +16;

  if (g->type == SKELETON) g->xf.dy += -3;
  if (g->type == SHADOW) g->xf.dy += -2;

  return true;
}
예제 #3
0
static bool
flow (struct anim *g)
{
  if (g->oaction != guard_defense) g->i = -1;

  struct anim *ke = get_anim_by_id (g->enemy_id);
  if (g->i == 1) {
    guard_attack (g);
    return false;
  } else if (g->i == 0 && ke && ke->attack_defended == 2
           && ke->counter_attacked != 2) {
    guard_walkb (g);
    return false;
  } else if (g->i == 0 && ! (ke && ke->attack_defended == 2)) {
    guard_vigilant (g);
    return false;
  }

  struct frameset *frameset = get_guard_defense_frameset (g->type);
  select_frame (g, frameset, g->i + 1);

  if (g->i == 0) g->j = 11;

  select_xframe (&g->xf, sword_frameset, g->j);

  if (g->i == 1) g->xf.b = NULL;

  if (g->oaction == guard_attack) g->fo.dx += +2;

  if (g->type == SKELETON) g->xf.dy += -3;
  if (g->type == SHADOW) g->xf.dy += -2;

  /* if (g->id == 0) */
  /*   printf ("guard_defense: g->i = %i, g->fo.dx = %i\n", */
  /*           g->i, g->fo.dx); */

  return true;
}
예제 #4
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);
}
예제 #5
0
static bool
flow (struct anim *g)
{
  if (g->oaction != guard_attack) {
    /* if (g->id == 0) */
    /*   printf ("guard_attack: dx = %i, g->i = %i, g->f.b = %p\n", */
    /*           g->f.c.x - g->of.c.x, g->i, g->f.b); */

    g->i = -1;
    g->of = g->f;
  }

  if (g->oaction == guard_defense) g->i = 1;

  if (g->i < 7 && g->i_counter_defended == 2) {
    g->i = 7;
    /* g->f = g->of; */
  }

  if (g->i == 9) {
    guard_defense (g);
    return false;
  } else if (g->i == 7
             && g->i_counter_defended != 2) {
    guard_vigilant (g);
    return false;
  }

  if (g->i == 4 && g->enemy_defended_my_attack)
    g->f.c.x += (g->f.dir == LEFT) ? +9 : -9;

  if (g->i == 3 && g->enemy_defended_my_attack)
    g->i = 4;

  struct frameset *frameset = get_guard_attack_frameset (g->type);
  select_frame (g, frameset, g->i + 1);

  if (g->i == 0) g->j = 12;
  if (g->i == 1) g->j = 0;
  if (g->i == 2) g->j = 5;
  if (g->i == 3) g->j = 1;
  if (g->i == 4) g->j = 2;
  if (g->i == 5) g->j = 6;
  if (g->i == 6) g->j = 7;
  if (g->i == 7) g->j = 3;
  if (g->i == 8) g->j = 9;
  if (g->i == 9) g->j = 10;

  select_xframe (&g->xf, sword_frameset, g->j);

  if (g->j == 1) g->xf.dy = +9;
  if (g->j == 7) g->xf.dx = +0, g->xf.dy = +23;
  if (g->j == 10) g->xf.dx = -10, g->xf.dy = +16;

  if (g->i == 5 && g->enemy_defended_my_attack) g->fo.dx = -2;

  if (g->type == SKELETON) g->xf.dy += -3;
  if (g->type == SHADOW) g->xf.dy += -2;

  return true;
}
예제 #6
0
static bool
physics_in (struct anim *g)
{
  struct coord nc;
  struct pos np, pbf, pmt, pmtf, pmtb,
    npmbo, npmbo_nf;
  struct frame nf;
  struct frame_offset fo;

  if (g->i == 0) {
    next_frame (&g->f, &g->f, &g->fo);

    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);

    if (! is_strictly_traversable (&pmt)
        || ! is_strictly_traversable (&pmtf)
        || ! is_strictly_traversable (&pmtb))
      place_in_initial_fall (g);
  }

  /* fall speed */
  if (g->i > 0)
    g->fo.dx = -g->inertia;
  if (g->i > 4) {
    int speed = +21 + 3 * (g->i - 5);
    g->fo.dy = (speed > 33) ? 33 : speed;
  }

  /* land on ground */
  struct frameset *frameset = get_guard_fall_frameset (g->type);
  fo.b = frameset[g->i > 2 ? 2 : g->i].frame;
  fo.dx = frameset[g->i > 2 ? 2 : g->i].dx;
  fo.dy = frameset[g->i > 2 ? 2 : g->i].dy;

  if (g->i > 0) g->fo.dx = -g->inertia;
  if (g->i > 2) {
    int speed = +21 + 3 * (g->i - 5);
    fo.dy = (speed > 33) ? 33 : speed;
  }
  fo.dy += 8;

  survey (_mbo, pos, &g->f, &nc, &np, &npmbo);
  next_frame (&g->f, &nf, &fo);
  survey (_mbo, pos, &nf, &nc, &np, &npmbo_nf);

  if (g->i > 2
      && ! is_strictly_traversable (&npmbo)
      && npmbo.floor != npmbo_nf.floor) {
    g->inertia = g->cinertia = 0;

    if (is_colliding (&g->f, &g->fo, +16, false, &g->ci)) {
      if (g->ci.t != WALL)
        g->f.c.x += (g->f.dir == LEFT) ? +16 : -16;
      else
        g->f.c.x += (g->f.dir == LEFT) ? +8 : -8;
    }

    survey (_bf, pos, &g->f, &nc, &pbf, &np);
    /* pos2view (&pbf, &pbf); */
    frameset = get_guard_vigilant_frameset (g->type);
    g->f.b = frameset[0].frame;
    place_on_the_ground (&g->f, &g->f.c);

    shake_loose_floor_row (&pbf);

    if (g->i >= 8 && ! g->immortal
        && ! g->fall_immune) {
      g->hurt = true;
      g->splash = true;
      g->current_lives--;

      if (g->i >= 10) g->current_lives = 0;

      if (g->current_lives > 0) g->uncouch_slowly = true;
    } else if (g->i > 3) {
      play_sample (hit_ground_sample, g->f.c.room);
      g->hurt = false;
    } else g->hurt = false;

    stop_sample (g->sample, scream_sample);

    survey (_mt, pos, &g->f, &nc, &pmt, &np);
    g->p = pmt;

    if (con (&pmt)->fg == SPIKES_FLOOR
        && ! spikes_floor_at_pos (&pmt)->inactive)
      guard_die_spiked (g);
    else if (g->current_lives <= 0) {
      play_sample (hit_ground_fatal_sample, g->f.c.room);
      guard_die_suddenly (g);
      g->death_reason = FALL_DEATH;
    } else {
      place_on_the_ground (&g->f, &g->f.c);
      g->f.c.y++;
      guard_vigilant (g);
    }

    return false;
  }

  return true;
}