Esempio n. 1
0
/*
 * C_KAELTESCHUTZ
 */
static message *cinfo_kaelteschutz(const void *obj, objtype_t typ, const curse * c,
    int self)
{
    unused_arg(typ);
    assert(typ == TYP_UNIT);

    if (self != 0) {
        unit *u = (unit *)obj;
        return msg_message("curseinfo::warmth_1", "unit number id", u,
            get_cursedmen(u, c), c->no);
    }
    return NULL;
}
Esempio n. 2
0
static void do_transfer_curse(curse * c, unit * u, unit * u2, int n)
{
  int cursedmen = 0;
  int men = get_cursedmen(u, c);
  bool dogive = false;
  const curse_type *ct = c->type;

  switch ((ct->flags | c->flags) & CURSE_SPREADMASK) {
    case CURSE_SPREADALWAYS:
      dogive = true;
      men = u2->number + n;
      break;

    case CURSE_SPREADMODULO:
    {
      int i;
      int u_number = u->number;
      for (i = 0; i < n + 1 && u_number > 0; i++) {
        if (rng_int() % u_number < cursedmen) {
          ++men;
          --cursedmen;
          dogive = true;
        }
        --u_number;
      }
      break;
    }
    case CURSE_SPREADCHANCE:
      if (chance(u2->number / (double)(u2->number + n))) {
        men = u2->number + n;
        dogive = true;
      }
      break;
    case CURSE_SPREADNEVER:
      break;
  }

  if (dogive) {
    curse *cnew = make_curse(c->magician, &u2->attribs, c->type, c->vigour,
      c->duration, c->effect, men);
    cnew->flags = c->flags;

    if (ct->typ == CURSETYP_UNIT)
      set_cursedmen(cnew, men);
  }
}
Esempio n. 3
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)));
        }
      }
    }
  }
}