示例#1
0
文件: gmcmd.c 项目: UweKopf/server
/**
 ** GM: TELEPORT <unit> <x> <y>
 ** requires: permission-key "gmtele"
 **/
static void gm_teleport(const void *tnext, struct unit *u, struct order *ord)
{
  const struct plane *p = rplane(u->region);
  unit *to = findunit(getid());
  int x = rel_to_abs(p, u->faction, getint(), 0);
  int y = rel_to_abs(p, u->faction, getint(), 1);
  region *r = findregion(x, y);

  if (r == NULL || p != rplane(r)) {
    mistake(u, ord, "region is in another plane.");
  } else if (to == NULL) {
    ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_unit_not_found",
        ""));
  } else if (rplane(to->region) != rplane(r) && !ucontact(to, u)) {
    ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_no_contact",
        "target", to));
  } else {
    /* checking permissions */
    attrib *permissions = a_find(u->faction->attribs, &at_permissions);
    if (!permissions || !has_permission(permissions, atoi36("gmtele"))) {
      mistake(u, ord, "permission denied.");
    } else
      move_unit(to, r, NULL);
  }
}
示例#2
0
文件: randenc.c 项目: hochl/server
void drown(region * r)
{
  if (fval(r->terrain, SEA_REGION)) {
    unit **up = up = &r->units;
    while (*up) {
      unit *u = *up;
      int amphibian_level = 0;
      if (u->ship || u_race(u) == get_race(RC_SPELL) || u->number == 0) {
        up = &u->next;
        continue;
      }

      if (amphibian_level) {
        int dead = damage_unit(u, "5d1", false, false);
        if (dead) {
          ADDMSG(&u->faction->msgs, msg_message("drown_amphibian_dead",
              "amount unit region", dead, u, r));
        } else {
          ADDMSG(&u->faction->msgs, msg_message("drown_amphibian_nodead",
              "unit region", u, r));
        }
      } else if (!(canswim(u) || canfly(u))) {
        scale_number(u, 0);
        ADDMSG(&u->faction->msgs, msg_message("drown", "unit region", u, r));
      }
      if (*up == u)
        up = &u->next;
    }
    remove_empty_units_in_region(r);
  }
}
示例#3
0
static int
use_speedsail(struct unit *u, const struct item_type *itype, int amount,
struct order *ord)
{
    struct plane *p = rplane(u->region);
    unused_arg(amount);
    unused_arg(itype);
    if (p != NULL) {
        ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "use_realworld_only", ""));
    }
    else {
        if (u->ship) {
            attrib *a = a_find(u->ship->attribs, &at_speedup);
            if (a == NULL) {
                a = a_add(&u->ship->attribs, a_new(&at_speedup));
                a->data.sa[0] = 50;     /* speed */
                a->data.sa[1] = 50;     /* decay */
                ADDMSG(&u->faction->msgs, msg_message("use_speedsail", "unit", u));
                /* Ticket abziehen */
                i_change(&u->items, itype, -1);
                return 0;
            }
            else {
                cmistake(u, ord, 211, MSG_EVENT);
            }
        }
        else {
            cmistake(u, ord, 144, MSG_EVENT);
        }
    }
    return EUNUSABLE;
}
示例#4
0
文件: arena.c 项目: UweKopf/server
static int age_hurting(attrib * a)
{
  building *b = (building *) a->data.v;
  unit *u;
  int active = 0;
  if (b == NULL)
    return AT_AGE_REMOVE;
  for (u = b->region->units; u; u = u->next) {
    if (u->building == b) {
      if (u->faction->magiegebiet == M_DRAIG) {
        active++;
        ADDMSG(&b->region->msgs, msg_message("praytoigjarjuk", "unit", u));
      }
    }
  }
  if (active)
    for (u = b->region->units; u; u = u->next)
      if (playerrace(u->faction->race)) {
        int i;
        if (u->faction->magiegebiet != M_DRAIG) {
          for (i = 0; i != active; ++i)
            u->hp = (u->hp + 1) / 2;    /* make them suffer, but not die */
          ADDMSG(&b->region->msgs, msg_message("cryinpain", "unit", u));
        }
      }
  return AT_AGE_KEEP;
}
示例#5
0
文件: randenc.c 项目: hochl/server
static void
volcano_destruction(region * volcano, region * r, region * rn,
  const char *damage)
{
  attrib *a;
  unit **up;
  int percent = 25, time = 6 + rng_int() % 12;

  rsettrees(r, 2, 0);
  rsettrees(r, 1, 0);
  rsettrees(r, 0, 0);

  a = a_find(r->attribs, &at_reduceproduction);
  if (!a) {
    a = make_reduceproduction(percent, time);
  } else {
    /* Produktion vierteln ... */
    a->data.sa[0] = (short)percent;
    /* Für 6-17 Runden */
    a->data.sa[1] = (short)(a->data.sa[1] + time);
  }

  /* Personen bekommen 4W10 Punkte Schaden. */

  for (up = &r->units; *up;) {
    unit *u = *up;
    if (u->number) {
      int dead = damage_unit(u, damage, true, false);
      if (dead) {
        ADDMSG(&u->faction->msgs, msg_message("volcano_dead",
            "unit region dead", u, volcano, dead));
      }
      if (r == volcano && !fval(u->faction, FFL_SELECT)) {
        fset(u->faction, FFL_SELECT);
        if (rn) {
          ADDMSG(&u->faction->msgs, msg_message("volcanooutbreak",
              "regionv regionn", r, rn));
        } else {
          ADDMSG(&u->faction->msgs, msg_message("volcanooutbreaknn",
              "region", r));
        }
      }
    }
    if (u == *up)
      up = &u->next;
  }

  remove_empty_units_in_region(r);
}
示例#6
0
文件: upkeep.c 项目: Xolgrim/server
static bool hunger(int number, unit * u)
{
    region *r = u->region;
    int dead = 0, hpsub = 0;
    int hp = u->hp / u->number;
    static const char *damage = 0;
    static const char *rcdamage = 0;
    static const race *rc = 0;

    if (!damage) {
        damage = get_param(global.parameters, "hunger.damage");
        if (damage == NULL)
            damage = "1d12+12";
    }
    if (rc != u_race(u)) {
        rcdamage = get_param(u_race(u)->parameters, "hunger.damage");
        rc = u_race(u);
    }

    while (number--) {
        int dam = dice_rand(rcdamage ? rcdamage : damage);
        if (dam >= hp) {
            ++dead;
        }
        else {
            hpsub += dam;
        }
    }

    if (dead) {
        /* Gestorbene aus der Einheit nehmen,
        * Sie bekommen keine Beerdingung. */
        ADDMSG(&u->faction->msgs, msg_message("starvation",
            "unit region dead live", u, r, dead, u->number - dead));

        scale_number(u, u->number - dead);
        deathcounts(r, dead);
    }
    if (hpsub > 0) {
        /* Jetzt die Schäden der nicht gestorbenen abziehen. */
        u->hp -= hpsub;
        /* Meldung nur, wenn noch keine für Tote generiert. */
        if (dead == 0) {
            /* Durch unzureichende Ernährung wird %s geschwächt */
            ADDMSG(&u->faction->msgs, msg_message("malnourish", "unit region", u, r));
        }
    }
    return (dead || hpsub);
}
示例#7
0
文件: randenc.c 项目: eressea/server
static void godcurse(void)
{
    region *r;

    for (r = regions; r; r = r->next) {
        if (is_cursed(r->attribs, C_CURSED_BY_THE_GODS, 0)) {
            unit *u;
            for (u = r->units; u; u = u->next) {
                skill *sv = u->skills;
                while (sv != u->skills + u->skill_size) {
                    int weeks = 1 + rng_int() % 3;
                    reduce_skill(u, sv, weeks);
                    ++sv;
                }
            }
            if (fval(r->terrain, SEA_REGION)) {
                ship *sh;
                for (sh = r->ships; sh;) {
                    ship *shn = sh->next;
                    double dmg = config_get_flt("rules.ship.damage.godcurse", 0.1);
                    damage_ship(sh, dmg);
                    if (sh->damage >= sh->size * DAMAGE_SCALE) {
                        unit *u = ship_owner(sh);
                        if (u)
                            ADDMSG(&u->faction->msgs,
                                   msg_message("godcurse_destroy_ship", "ship", sh));
                        remove_ship(&sh->region->ships, sh);
                    }
                    sh = shn;
                }
            }
        }
    }

}
示例#8
0
文件: gmcmd.c 项目: UweKopf/server
static void mistake(const unit * u, struct order *ord, const char *comment)
{
  if (!is_monsters(u->faction)) {
    ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "mistake",
        "error", comment));
  }
}
示例#9
0
文件: gmcmd.c 项目: UweKopf/server
/**
 ** GM: SKILL <unit> <skill> <tage>
 ** requires: permission-key "gmskil"
 **/
static void gm_skill(const void *tnext, struct unit *u, struct order *ord)
{
  unit *to = findunit(getid());
  skill_t skill = findskill(getstrtoken(), u->faction->locale);
  int num = getint();

  if (to == NULL || rplane(to->region) != rplane(u->region)) {
    /* unknown or in another plane */
    ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_unit_not_found",
        ""));
  } else if (skill == NOSKILL || skill == SK_MAGIC || skill == SK_ALCHEMY) {
    /* unknown or not enough */
    mistake(u, ord, "unknown skill, or skill cannot be raised.");
  } else if (num < 0 || num > 30) {
    /* sanity check failed */
    mistake(u, ord, "invalid value.");
  } else {
    /* checking permissions */
    attrib *permissions = a_find(u->faction->attribs, &at_permissions);
    if (!permissions || !has_permission(permissions, atoi36("gmskil"))) {
      mistake(u, ord, "permission denied.");
    } else {
      set_level(to, skill, num);
    }
  }
}
示例#10
0
文件: gmcmd.c 项目: UweKopf/server
/**
 ** GM: TAKE <unit> <int> <itemtype>
 ** requires: permission-key "gmtake"
 **/
static void gm_take(const void *tnext, struct unit *u, struct order *ord)
{
  unit *to = findunit(getid());
  int num = getint();
  const item_type *itype = finditemtype(getstrtoken(), u->faction->locale);

  if (to == NULL || rplane(to->region) != rplane(u->region)) {
    /* unknown or in another plane */
    ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_unit_not_found",
        ""));
  } else if (itype == NULL || i_get(to->items, itype) == 0) {
    /* unknown or not enough */
    mistake(u, ord, "invalid item or item not found.");
  } else {
    /* checking permissions */
    attrib *permissions = a_find(u->faction->attribs, &at_permissions);
    if (!permissions || !has_permission(permissions, atoi36("gmtake"))) {
      mistake(u, ord, "permission denied.");
    } else {
      int i = i_get(to->items, itype);
      if (i < num)
        num = i;
      if (num) {
        i_change(&to->items, itype, -num);
        i_change(&u->items, itype, num);
      }
    }
  }
}
示例#11
0
文件: gmcmd.c 项目: UweKopf/server
/**
 ** GM: TELL <unit> <string>
 ** requires: permission-key "gmmsgr"
 **/
static void gm_messageunit(const void *tnext, struct unit *u, struct order *ord)
{
  const struct plane *p = rplane(u->region);
  unit *target = findunit(getid());
  const char *msg = getstrtoken();
  region *r;

  if (target == NULL) {
    ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_unit_not_found",
        ""));
    return;
  }

  r = target->region;

  if (r == NULL || p != rplane(r)) {
    mistake(u, ord, "region is in another plane.");
  } else {
    /* checking permissions */
    attrib *permissions = a_find(u->faction->attribs, &at_permissions);
    if (!permissions || !has_permission(permissions, atoi36("gmmsgu"))) {
      mistake(u, ord, "permission denied.");
    } else {
      add_message(&target->faction->msgs,
        msg_message("regionmessage", "region sender string", r, u, msg));
    }
  }
}
示例#12
0
文件: gmcmd.c 项目: UweKopf/server
/**
 ** GM: KILL FACTION <id> <string>
 ** requires: permission-key "gmmsgr"
 **/
static void gm_killfaction(const void *tnext, struct unit *u, struct order *ord)
{
  int n = getid();
  faction *f = findfaction(n);
  const char *msg = getstrtoken();
  plane *p = rplane(u->region);
  attrib *permissions = a_find(u->faction->attribs, &at_permissions);
  if (!permissions || !has_permission(permissions, atoi36("gmkill"))) {
    mistake(u, ord, "permission denied.");
    return;
  }
  if (f != NULL) {
    region *r;
    for (r = regions; r; r = r->next)
      if (rplane(r) == p) {
        unit *target;
        for (target = r->units; target; target = target->next) {
          if (target->faction == f) {
            scale_number(target, 0);
            ADDMSG(&target->faction->msgs, msg_message("killedbygm",
                "region unit string", r, target, msg));
            return;
          }
        }
      }
  }
  mistake(u, ord, "cannot remove a unit from this faction.");
}
示例#13
0
文件: build.c 项目: Xolgrim/server
static void build_ship(unit * u, ship * sh, int want)
{
    const construction *construction = sh->type->construction;
    int size = (sh->size * DAMAGE_SCALE - sh->damage) / DAMAGE_SCALE;
    int n;
    int can = build(u, construction, size, want);

    if ((n = construction->maxsize - sh->size) > 0 && can > 0) {
        if (can >= n) {
            sh->size += n;
            can -= n;
        }
        else {
            sh->size += can;
            n = can;
            can = 0;
        }
    }

    if (sh->damage && can) {
        int repair = _min(sh->damage, can * DAMAGE_SCALE);
        n += repair / DAMAGE_SCALE;
        if (repair % DAMAGE_SCALE)
            ++n;
        sh->damage = sh->damage - repair;
    }

    if (n)
        ADDMSG(&u->faction->msgs,
        msg_message("buildship", "ship unit size", sh, u, n));
}
示例#14
0
static int
useonother_trappedairelemental(struct unit *u, int shipId,
const struct item_type *itype, int amount, struct order *ord)
{
    curse *c;
    ship *sh;

    if (shipId <= 0) {
        cmistake(u, ord, 20, MSG_MOVE);
        return -1;
    }

    sh = findshipr(u->region, shipId);
    if (!sh) {
        cmistake(u, ord, 20, MSG_MOVE);
        return -1;
    }

    c =
        create_curse(u, &sh->attribs, ct_find("shipspeedup"), 20, INT_MAX, SPEEDUP,
        0);
    c_setflag(c, CURSE_NOAGE);

    ADDMSG(&u->faction->msgs, msg_message("trappedairelemental_success",
        "unit region command ship", u, u->region, ord, sh));

    use_pooled(u, itype->rtype, GET_DEFAULT, 1);

    return 0;
}
示例#15
0
文件: wormhole.c 项目: Xolgrim/server
static int wormhole_age(struct attrib *a)
{
    wormhole_data *data = (wormhole_data *)a->data.v;
    int maxtransport = data->entry->size;
    region *r = data->entry->region;
    unit *u = r->units;

    for (; u != NULL && maxtransport != 0; u = u->next) {
        if (u->building == data->entry) {
            message *m = NULL;
            if (u->number > maxtransport || has_limited_skills(u)) {
                m = msg_message("wormhole_requirements", "unit region", u, u->region);
            }
            else if (data->exit != NULL) {
                move_unit(u, data->exit, NULL);
                maxtransport -= u->number;
                m = msg_message("wormhole_exit", "unit region", u, data->exit);
                add_message(&data->exit->msgs, m);
            }
            if (m != NULL) {
                add_message(&u->faction->msgs, m);
                msg_release(m);
            }
        }
    }

    remove_building(&r->buildings, data->entry);
    ADDMSG(&r->msgs, msg_message("wormhole_dissolve", "region", r));

    /* age returns 0 if the attribute needs to be removed, !=0 otherwise */
    return AT_AGE_KEEP;
}
示例#16
0
static int
give_igjarjuk(struct unit *src, struct unit *d, const struct item_type *itype,
  int n, struct order *ord)
{
  ADDMSG(&src->faction->msgs, msg_feedback(src, ord, "error_giveeye", ""));
  return 0;
}
示例#17
0
文件: randenc.c 项目: hochl/server
static void melt_iceberg(region * r)
{
  attrib *a;
  unit *u;

  for (u = r->units; u; u = u->next)
    freset(u->faction, FFL_SELECT);
  for (u = r->units; u; u = u->next)
    if (!fval(u->faction, FFL_SELECT)) {
      fset(u->faction, FFL_SELECT);
      ADDMSG(&u->faction->msgs, msg_message("iceberg_melt", "region", r));
    }

  /* driftrichtung löschen */
  a = a_find(r->attribs, &at_iceberg);
  if (a)
    a_remove(&r->attribs, a);

  /* Gebäude löschen */
  while (r->buildings) {
    remove_building(&r->buildings, r->buildings);
  }

  /* in Ozean wandeln */
  terraform_region(r, newterrain(T_OCEAN));

  /* Einheiten, die nicht schwimmen können oder in Schiffen sind,
   * ertrinken */
  drown(r);
}
示例#18
0
文件: monster.c 项目: hochl/server
static void scared_by_monster(unit * u)
{
    int n;

    switch (old_race(u_race(u))) {
    case RC_FIREDRAGON:
        n = rng_int() % 160 * u->number;
        break;
    case RC_DRAGON:
        n = rng_int() % 400 * u->number;
        break;
    case RC_WYRM:
        n = rng_int() % 1000 * u->number;
        break;
    default:
        n = rng_int() % (u->number / 4 + 1);
    }

    if (n > 0) {
        n = lovar(n);
        n = _min(rpeasants(u->region), n);
        if (n > 0) {
            n = scareaway(u->region, n);
            if (n > 0) {
                ADDMSG(&u->region->msgs, msg_message("fleescared",
                                                     "amount unit", n, u));
            }
        }
    }
}
示例#19
0
static bool cb_msg_teach(void *el, void *arg) {
    struct teach_data *td = (struct teach_data *)arg;
    unit *ut = (unit *)el;
    unit * u = td->u;
    skill_t sk = td->sk;
    if (ut->faction != u->faction) {
        bool feedback = alliedunit(u, ut->faction, HELP_GUARD);
        if (feedback) {
            ADDMSG(&ut->faction->msgs, msg_message("teach_teacher",
                "teacher student skill level", ut, u, sk,
                effskill(u, sk, NULL)));
        }
        ADDMSG(&u->faction->msgs, msg_message("teach_student",
            "teacher student skill", ut, u, sk));
    }
    return true;
}
示例#20
0
文件: wormhole.c 项目: Xolgrim/server
static void
make_wormhole(const building_type * bt_wormhole, region * r1, region * r2)
{
    building *b1 = new_building(bt_wormhole, r1, default_locale);
    building *b2 = new_building(bt_wormhole, r2, default_locale);
    attrib *a1 = a_add(&b1->attribs, a_new(&at_wormhole));
    attrib *a2 = a_add(&b2->attribs, a_new(&at_wormhole));
    wormhole_data *d1 = (wormhole_data *)a1->data.v;
    wormhole_data *d2 = (wormhole_data *)a2->data.v;
    d1->entry = b1;
    d2->entry = b2;
    d1->exit = b2->region;
    d2->exit = b1->region;
    b1->size = bt_wormhole->maxsize;
    b2->size = bt_wormhole->maxsize;
    ADDMSG(&r1->msgs, msg_message("wormhole_appear", "region", r1));
    ADDMSG(&r2->msgs, msg_message("wormhole_appear", "region", r2));
}
示例#21
0
static void use_key2(connection *b, void *data) {
    unit * u = (unit *)data;
    if (b->type == &bt_questportal) {
        const struct item_type *itype = it_find("questkey2");
        ADDMSG(&u->faction->msgs,
            msg_message("use_item", "unit item", u, itype->rtype));
        b->data.i &= 0xFD;
    }
}
示例#22
0
文件: alchemy.c 项目: hochl/server
static void end_potion(unit * u, const potion_type * ptype, int amount)
{
  use_pooled(u, ptype->itype->rtype, GET_SLACK | GET_RESERVE | GET_POOLED_SLACK,
    amount);
  usetpotionuse(u, ptype);

  ADDMSG(&u->faction->msgs, msg_message("usepotion",
      "unit potion", u, ptype->itype->rtype));
}
示例#23
0
文件: monster.c 项目: UweKopf/server
static void eaten_by_monster(unit * u)
{
  /* adjustment for smaller worlds */
  static double multi = 0.0;
  int n = 0;
  int horse = 0;

  if (multi == 0.0) {
    multi = RESOURCE_QUANTITY * newterrain(T_PLAIN)->size / 10000.0;
  }

  switch (old_race(u_race(u))) {
    case RC_FIREDRAGON:
      n = rng_int() % 80 * u->number;
      horse = get_item(u, I_HORSE);
      break;
    case RC_DRAGON:
      n = rng_int() % 200 * u->number;
      horse = get_item(u, I_HORSE);
      break;
    case RC_WYRM:
      n = rng_int() % 500 * u->number;
      horse = get_item(u, I_HORSE);
      break;
    default:
      n = rng_int() % (u->number / 20 + 1);
  }

  n = (int)(n * multi);
  if (n > 0) {
    n = lovar(n);
    n = MIN(rpeasants(u->region), n);

    if (n > 0) {
      deathcounts(u->region, n);
      rsetpeasants(u->region, rpeasants(u->region) - n);
      ADDMSG(&u->region->msgs, msg_message("eatpeasants", "unit amount", u, n));
    }
  }
  if (horse > 0) {
    set_item(u, I_HORSE, 0);
    ADDMSG(&u->region->msgs, msg_message("eathorse", "unit amount", u, horse));
  }
}
示例#24
0
static int
use_museumexitticket(unit * u, const struct item_type *itype, int amount,
order * ord)
{
    attrib *a;
    region *r;
    unit *warden = findunit(atoi36("mwar"));
    int unit_cookie;

    unused_arg(amount);

    /* Prüfen ob in Eingangshalle */
    if (u->region->x != 9525 || u->region->y != 9525) {
        cmistake(u, ord, 266, MSG_MAGIC);
        return 0;
    }

    a = a_find(u->attribs, &at_museumexit);
    assert(a);
    r = findregion(a->data.sa[0], a->data.sa[1]);
    assert(r);
    a_remove(&u->attribs, a);
    /* Übergebene Gegenstände zurückgeben */

    a = a_find(u->attribs, &at_museumgivebackcookie);
    if (a) {
        unit_cookie = a->data.i;
        a_remove(&u->attribs, a);

        for (a = a_find(warden->attribs, &at_museumgiveback);
            a && a->type == &at_museumgiveback; a = a->next) {
            if (((museumgiveback *)(a->data.v))->cookie == unit_cookie)
                break;
        }
        if (a && a->type == &at_museumgiveback) {
            museumgiveback *gb = (museumgiveback *)(a->data.v);
            item *it;

            for (it = gb->items; it; it = it->next) {
                i_change(&u->items, it->type, it->number);
            }
            ADDMSG(&u->faction->msgs, msg_message("museumgiveback",
                "region unit sender items", r, u, warden, gb->items));
            a_remove(&warden->attribs, a);
        }
    }

    /* Benutzer zurück teleportieren */
    move_unit(u, r, NULL);

    /* Exitticket abziehen */
    i_change(&u->items, itype, -1);

    return 0;
}
示例#25
0
文件: arena.c 项目: UweKopf/server
static int
enter_arena(unit * u, const item_type * itype, int amount, order * ord)
{
  skill_t sk;
  region *r = u->region;
  unit *u2;
  int fee = u->faction->score / 5;
  unused(ord);
  unused(amount);
  unused(itype);
  if (fee > 2000)
    fee = 2000;
  if (getplane(r) == arena)
    return -1;
  if (u->number != 1 && enter_fail(u))
    return -1;
  if (get_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, fee) < fee
    && enter_fail(u))
    return -1;
  for (sk = 0; sk != MAXSKILLS; ++sk) {
    if (get_level(u, sk) > 1 && enter_fail(u))
      return -1;
  }
  for (u2 = r->units; u2; u2 = u2->next)
    if (u2->faction == u->faction)
      break;

  assert(!"not implemented");
/*
	for (res=0;res!=MAXRESOURCES;++res) if (res!=R_SILVER && res!=R_ARENA_GATE && (is_item(res) || is_herb(res) || is_potion(res))) {
		int x = get_resource(u, res);
		if (x) {
			if (u2) {
				change_resource(u2, res, x);
				change_resource(u, res, -x);
			}
			else if (enter_fail(u)) return -1;
		}
	}
*/
  if (get_money(u) > fee) {
    if (u2)
      change_money(u2, get_money(u) - fee);
    else if (enter_fail(u))
      return -1;
  }
  ADDMSG(&u->faction->msgs, msg_message("arena_enter_fail", "region unit",
      u->region, u));
  use_pooled(u, itype->rtype, GET_SLACK | GET_RESERVE, 1);
  use_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, fee);
  set_money(u, 109);
  fset(u, UFL_ANON_FACTION);
  move_unit(u, start_region[rng_int() % 6], NULL);
  return 0;
}
示例#26
0
文件: alchemy.c 项目: hochl/server
static int do_potion(unit * u, region *r, const potion_type * ptype, int amount)
{
  if (ptype == oldpotiontype[P_LIFE]) {
    int holz = 0;
    static int tree_type = -1;
    static int tree_count = -1;
    if (tree_type < 0) {
      tree_type = get_param_int(global.parameters, "rules.magic.wol_type", 1);
      tree_count =
        get_param_int(global.parameters, "rules.magic.wol_effect", 10);
    }
    /* mallorn is required to make mallorn forests, wood for regular ones */
    if (fval(r, RF_MALLORN)) {
      holz = use_pooled(u, rt_find("mallorn"),
        GET_SLACK | GET_RESERVE | GET_POOLED_SLACK, tree_count * amount);
    } else {
      holz = use_pooled(u, rt_find("log"),
        GET_SLACK | GET_RESERVE | GET_POOLED_SLACK, tree_count * amount);
    }
    if (r->land == 0)
      holz = 0;
    if (holz < tree_count * amount) {
      int x = holz / tree_count;
      if (holz % tree_count)
        ++x;
      if (x < amount)
        amount = x;
    }
    rsettrees(r, tree_type, rtrees(r, tree_type) + holz);
    ADDMSG(&u->faction->msgs, msg_message("growtree_effect",
        "mage amount", u, holz));
  } else if (ptype == oldpotiontype[P_HEILWASSER]) {
    u->hp = _min(unit_max_hp(u) * u->number, u->hp + 400 * amount);
  } else if (ptype == oldpotiontype[P_PEOPLE]) {
    attrib *a = (attrib *) a_find(r->attribs, &at_peasantluck);
    if (!a)
      a = a_add(&r->attribs, a_new(&at_peasantluck));
    a->data.i += amount;
  } else if (ptype == oldpotiontype[P_HORSE]) {
    attrib *a = (attrib *) a_find(r->attribs, &at_horseluck);
    if (!a)
      a = a_add(&r->attribs, a_new(&at_horseluck));
    a->data.i += amount;
  } else if (ptype == oldpotiontype[P_WAHRHEIT]) {
    fset(u, UFL_DISBELIEVES);
    amount = 1;
  } else if (ptype == oldpotiontype[P_MACHT]) {
    /* Verfünffacht die HP von max. 10 Personen in der Einheit */
    u->hp += _min(u->number, 10 * amount) * unit_max_hp(u) * 4;
  } else {
    change_effect(u, ptype, 10 * amount);
  }
  return amount;
}
示例#27
0
文件: randenc.c 项目: eressea/server
void randomevents(void)
{
    region *r;
    faction *monsters = get_monsters();

    icebergs();
    godcurse();
    orc_growth();
    demon_skillchanges();
    volcano_update();
    /* Monumente zerfallen, Schiffe verfaulen */

    for (r = regions; r; r = r->next) {
        building **blist = &r->buildings;
        while (*blist) {
            building *b = *blist;
            if (fval(b->type, BTF_DECAY) && !building_owner(b)) {
                b->size -= _max(1, (b->size * 20) / 100);
                if (b->size == 0) {
                    remove_building(blist, r->buildings);
                }
            }
            if (*blist == b)
                blist = &b->next;
        }
    }

    /* monster-einheiten desertieren */
    if (monsters) {
        for (r = regions; r; r = r->next) {
            unit *u;

            for (u = r->units; u; u = u->next) {
                if (u->faction && !is_monsters(u->faction)
                        && (u_race(u)->flags & RCF_DESERT)) {
                    if (fval(u, UFL_ISNEW))
                        continue;
                    if (rng_int() % 100 < 5) {
                        ADDMSG(&u->faction->msgs, msg_message("desertion",
                                                              "unit region", u, r));
                        u_setfaction(u, monsters);
                    }
                }
            }
        }
    }

    chaos_update();
#ifdef HERBS_ROT
    rotting_herbs();
#endif

    dissolve_units();
}
示例#28
0
static int
use_hornofdancing(struct unit *u, const struct item_type *itype,
int amount, struct order *ord)
{
    region *r;
    int regionsPacified = 0;

    for (r = regions; r; r = r->next) {
        if (distance(u->region, r) < HORNRANGE) {
            if (a_find(r->attribs, &at_peaceimmune) == NULL) {
                attrib *a;

                create_curse(u, &r->attribs, ct_find("peacezone"),
                    20, HORNDURATION, 1.0, 0);

                a = a_add(&r->attribs, a_new(&at_peaceimmune));
                a->data.i = HORNIMMUNITY;

                ADDMSG(&r->msgs, msg_message("hornofpeace_r_success",
                    "unit region", u, u->region));

                regionsPacified++;
            }
            else {
                ADDMSG(&r->msgs, msg_message("hornofpeace_r_nosuccess",
                    "unit region", u, u->region));
            }
        }
    }

    if (regionsPacified > 0) {
        ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "hornofpeace_u_success",
            "pacified", regionsPacified));
    }
    else {
        ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "hornofpeace_u_nosuccess",
            ""));
    }

    return 0;
}
示例#29
0
文件: borders.c 项目: TomBraun/server
static region *wall_move(const connection * b, struct unit *u,
  struct region *from, struct region *to, bool routing)
{
  wall_data *fd = (wall_data *) b->data.v;
  if (!routing && fd->active) {
    int hp = dice(3, fd->force) * u->number;
    hp = _min(u->hp, hp);
    u->hp -= hp;
    if (u->hp) {
      ADDMSG(&u->faction->msgs, msg_message("firewall_damage",
          "region unit", from, u));
    } else
      ADDMSG(&u->faction->msgs, msg_message("firewall_death", "region unit",
          from, u));
    if (u->number > u->hp) {
      scale_number(u, u->hp);
      u->hp = u->number;
    }
  }
  return to;
}
示例#30
0
文件: alchemy.c 项目: hochl/server
void herbsearch(region * r, unit * u, int max)
{
  int herbsfound;
  const item_type *whichherb;

  if (eff_skill(u, SK_HERBALISM, r) == 0) {
    cmistake(u, u->thisorder, 59, MSG_PRODUCE);
    return;
  }

  if (is_guarded(r, u, GUARD_PRODUCE)) {
    cmistake(u, u->thisorder, 70, MSG_EVENT);
    return;
  }

  whichherb = rherbtype(r);
  if (whichherb == NULL) {
    cmistake(u, u->thisorder, 108, MSG_PRODUCE);
    return;
  }

  if (max)
    max = _min(max, rherbs(r));
  else
    max = rherbs(r);
  herbsfound = ntimespprob(eff_skill(u, SK_HERBALISM, r) * u->number,
    (double)rherbs(r) / 100.0F, -0.01F);
  herbsfound = _min(herbsfound, max);
  rsetherbs(r, rherbs(r) - herbsfound);

  if (herbsfound) {
    produceexp(u, SK_HERBALISM, u->number);
    i_change(&u->items, whichherb, herbsfound);
    ADDMSG(&u->faction->msgs, msg_message("herbfound",
        "unit region amount herb", u, r, herbsfound, whichherb->rtype));
  } else {
    ADDMSG(&u->faction->msgs, msg_message("researchherb_none",
        "unit region", u, u->region));
  }
}