示例#1
0
文件: fight.c 项目: oitofelix/mininim
bool
is_hearing (struct anim *k0, struct anim *k1)
{
  struct pos p0, p1;
  survey (_m, pos, &k0->f, NULL, &p0, NULL);
  survey ((k0->f.dir == LEFT) ? _mr : _ml,
          pos, &k1->f, NULL, &p1, NULL);

  pos2room (&p1, p0.room, &p1);

  return p1.room == p0.room
    && (is_kid_run (&k1->f)
        || is_kid_stop_run (&k1->f)
        || is_kid_jump_landing (&k1->f)
        || is_kid_run_jump_running (&k1->f)
        || is_kid_run_jump_landing (&k1->f)
        || (is_kid_couch (&k1->f)
            && k1->fall)
        || k1->action == kid_take_sword);
}
示例#2
0
void
compute_spikes_floors (void)
{
  size_t i, j;
  struct pos pm;

  for (i = 0; i < spikes_floor_nmemb; i++) {
    struct spikes_floor *s = &spikes_floor[i];

    if (s->inactive) continue;

    int state = s->state;

    switch (s->i) {
    case 0: if (should_spikes_raise (&s->p) || s->activate) {
        alert_guards (&s->p);
        play_sample (spikes_sample, &s->p, -1);
        s->i++;
        s->wait = 12;
        s->state = 1;
      } else if (s->state != 0) s->state = 0;
      break;
    case 1:
      s->i++;
      s->state = 2;
      break;
    case 2:
      s->i++;
      s->state = 3;
      break;
    case 3:
      s->i++;
      s->state = 4;
      break;
    case 4: if (! should_spikes_raise (&s->p)) {
        if (s->wait-- == 0) {
          s->i++;
          s->state = 3;
        } else s->state = 5;
      } else {
        s->state = 5;
      }
      break;
    case 5:
      s->i++;
      s->state = 2;
      break;
    case 6:
      s->i = 0;
      s->state = 1;
      s->activate = false;
      break;
    }

    if (state != s->state)
      register_changed_pos (&s->p, CHPOS_SPIKES);

    /* spike kid */
    for (j = 0; j < anima_nmemb; j++) {
      struct anim *a = &anima[j];
      if (is_kid_dead (&a->f)
          || a->immortal
          || a->spikes_immune) continue;
      survey (_m, pos, &a->f, NULL, &pm, NULL);
      if (peq (&pm, &s->p)
          && (((s->state >= 2 && s->state <= 4)
               && (is_kid_start_run (&a->f)
                   || is_kid_run (&a->f)
                   || is_kid_run_jump_running (&a->f)))
              || (is_kid_couch (&a->f) && a->fall && a->i < 3
                  && ! a->float_timer)
              || (is_kid_jump_landing (&a->f) && a->i <= 13)
              || is_kid_run_jump_landing (&a->f))) {
        a->p = s->p;
        anim_die_spiked (a);
      }
    }
  }
}