Exemple #1
0
/** handles the "orcish" curse that makes units grow like old orks
 * This would probably be better handled in an age-function for the curse,
 * but it's now being called by randomevents()
 */
static void orc_growth(void)
{
  region *r;
  for (r = regions; r; r = r->next) {
    unit *u;
    for (u = r->units; u; u = u->next) {
      static bool init = false;
      static const curse_type *ct_orcish = 0;
      curse *c = 0;
      if (!init) {
        init = true;
        ct_orcish = ct_find("orcish");
      }
      if (ct_orcish)
        c = get_curse(u->attribs, ct_orcish);

      if (c && !has_skill(u, SK_MAGIC) && !has_skill(u, SK_ALCHEMY)
        && !fval(u, UFL_HERO)) {
        int n;
        int increase = 0;
        int num = get_cursedmen(u, c);
        double prob = curse_geteffect(c);
        const item_type * it_chastity = it_find("ao_chastity");

        if (it_chastity) {
            num -= i_get(u->items, it_chastity); 
        }
        for (n = num; n > 0; n--) {
          if (chance(prob)) {
            ++increase;
          }
        }
        if (increase) {
          unit *u2 = create_unit(r, u->faction, increase, u_race(u), 0, NULL, u);
          transfermen(u2, u, u2->number);

          ADDMSG(&u->faction->msgs, msg_message("orcgrowth",
              "unit amount race", u, increase, u_race(u)));
        }
      }
    }
  }
}
Exemple #2
0
void age_undead(unit * u)
{
  region *r = u->region;
  int n = 0;

  /* untote, die einer partei angehoeren, koennen sich
   * absplitten, anstatt sich zu vermehren. monster
   * untote vermehren sich nur noch */

  if (u->number > UNDEAD_MIN && !is_monsters(u->faction)
    && rng_int() % 100 < UNDEAD_BREAKUP) {
    int m;
    unit *u2;

    n = 0;
    for (m = u->number; m; m--) {
      if (rng_int() % 100 < UNDEAD_BREAKUP_FRACTION)
        ++n;
    }
    u2 = create_unit(r, get_monsters(), 0, get_race(RC_UNDEAD), 0, NULL, u);
    make_undead_unit(u2);
    transfermen(u, u2, u->number - n);
  }
}
Exemple #3
0
int sp_undeadhero(struct castorder * co)
{
    fighter * fi = co->magician.fig;
    int level = co->level;
    double power = co->force;
    battle *b = fi->side->battle;
    unit *mage = fi->unit;
    region *r = b->region;
    selist *fgs, *ql;
    int qi, n, undead = 0;
    message *msg;
    int force = (int)get_force(power, 0);
    double c = 0.50 + 0.02 * power;

    /* Liste aus allen Kaempfern */
    fgs = select_fighters(b, fi->side, FS_ENEMY | FS_HELP, select_hero, NULL);
    scramble_fighters(fgs);

    for (qi = 0, ql = fgs; ql && force>0; selist_advance(&ql, &qi, 1)) {
        fighter *df = (fighter *)selist_get(ql, qi);
        unit *du = df->unit;
        int j = 0;

        /* Wieviele Untote koennen wir aus dieser Einheit wecken? */
        for (n = df->alive + df->run.number; force>0 && n != du->number; n++) {
            if (chance(c)) {
                ++j;
                --force;
            }
        }

        if (j > 0) {
            item **ilist;
            unit *u =
                create_unit(r, mage->faction, 0, get_race(RC_UNDEAD), 0, unit_getname(du),
                du);

            /* new units gets some stats from old unit */

            unit_setinfo(u, unit_getinfo(du));
            unit_setstatus(u, du->status);
            setguard(u, false);
            for (ilist = &du->items; *ilist;) {
                item *itm = *ilist;
                int loot = itm->number * j / du->number;
                if (loot != itm->number) {
                    int split = itm->number * j % du->number;
                    if (split > 0 && (rng_int() % du->number) < split) {
                        ++loot;
                    }
                }
                i_change(&u->items, itm->type, loot);
                i_change(ilist, itm->type, -loot);
                if (*ilist == itm) {
                    ilist = &itm->next;
                }
            }

            /* inherit stealth from magician */
            if (mage->flags & UFL_ANON_FACTION) {
                u->flags |= UFL_ANON_FACTION;
            }

            /* transfer dead people to new unit, set hitpoints to those of old unit */
            transfermen(du, u, j);
            u->hp = u->number * unit_max_hp(du);
            assert(j <= df->side->casualties);
            df->side->casualties -= j;
            df->side->dead -= j;

            /* counting total number of undead */
            undead += j;
        }
    }
    selist_free(fgs);

    if (level > undead) {
        level = undead;
    }
    if (undead == 0) {
        msg =
            msg_message("summonundead_effect_0", "mage region", mage, mage->region);
    }
    else {
        msg =
            msg_message("summonundead_effect_1", "mage region amount", mage,
            mage->region, undead);
    }

    message_all(b, msg);
    msg_release(msg);
    return level;
}
Exemple #4
0
int sp_undeadhero(struct castorder * co)
{
  fighter * fi = co->magician.fig;
  int level = co->level;
  double power = co->force;
  battle *b = fi->side->battle;
  unit *mage = fi->unit;
  region *r = b->region;
  quicklist *fgs, *ql;
  int qi, n, undead = 0;
  message *msg;
  int force = (int)get_force(power, 0);
  double c = 0.50 + 0.02 * power;

  /* Liste aus allen Kämpfern */
  fgs = fighters(b, fi->side, FIGHT_ROW, AVOID_ROW, FS_ENEMY | FS_HELP);
  scramble_fighters(fgs);

  for (qi = 0, ql = fgs; ql; ql_advance(&ql, &qi, 1)) {
    fighter *df = (fighter *) ql_get(ql, qi);
    unit *du = df->unit;

    if (force <= 0)
      break;

    /* keine Monster */
    if (!playerrace(u_race(du)))
      continue;

    if (df->alive + df->run.number < du->number) {
      int j = 0;

      /* Wieviele Untote können wir aus dieser Einheit wecken? */
      for (n = df->alive + df->run.number; n != du->number; n++) {
        if (chance(c)) {
          ++j;
          if (--force <= 0)
            break;
        }
      }

      if (j > 0) {
        unit *u =
          create_unit(r, mage->faction, 0, new_race[RC_UNDEAD], 0, du->name,
          du);

        /* new units gets some stats from old unit */

        if (du->display) {
          unit_setinfo(u, du->display);
        } else {
          unit_setinfo(u, NULL);
        }
        setstatus(u, du->status);
        setguard(u, GUARD_NONE);

        /* inherit stealth from magician */
        if (fval(mage, UFL_ANON_FACTION)) {
          fset(u, UFL_ANON_FACTION);
        }

        /* transfer dead people to new unit, set hitpoints to those of old unit */
        transfermen(du, u, j);
        u->hp = u->number * unit_max_hp(du);
        assert(j <= df->side->casualties);
        df->side->casualties -= j;
        df->side->dead -= j;

        /* counting total number of undead */
        undead += j;
      }
    }
  }
  ql_free(fgs);

  level = _min(level, undead);
  if (undead == 0) {
    msg =
      msg_message("summonundead_effect_0", "mage region", mage, mage->region);
  } else {
    msg =
      msg_message("summonundead_effect_1", "mage region amount", mage,
      mage->region, undead);
  }

  message_all(b, msg);
  msg_release(msg);
  return level;
}