示例#1
0
文件: unit.c 项目: UweKopf/server
bool can_survive(const unit * u, const region * r)
{
  if ((fval(r->terrain, WALK_INTO) && (u_race(u)->flags & RCF_WALK))
    || (fval(r->terrain, SWIM_INTO) && (u_race(u)->flags & RCF_SWIM))
    || (fval(r->terrain, FLY_INTO) && (u_race(u)->flags & RCF_FLY))) {
    static const curse_type *ctype = NULL;

    if (has_horses(u) && !fval(r->terrain, WALK_INTO))
      return false;

    if (!ctype)
      ctype = ct_find("holyground");
    if (fval(u_race(u), RCF_UNDEAD) && curse_active(get_curse(r->attribs, ctype)))
      return false;

    return true;
  }
  return false;
}
示例#2
0
static int
use_museumticket(unit * u, const struct item_type *itype, int amount,
order * ord)
{
    attrib *a;
    region *r = u->region;
    plane *pl = rplane(r);

    unused_arg(amount);

    /* Pruefen ob in normaler Plane und nur eine Person */
    if (pl != get_homeplane()) {
        cmistake(u, ord, 265, MSG_MAGIC);
        return 0;
    }
    if (u->number != 1) {
        cmistake(u, ord, 267, MSG_MAGIC);
        return 0;
    }
    if (has_horses(u)) {
        cmistake(u, ord, 272, MSG_MAGIC);
        return 0;
    }

    /* In diesem Attribut merken wir uns, wohin die Einheit zurückgesetzt
     * wird, wenn sie das Museum verläßt. */

    a = a_add(&u->attribs, a_new(&at_museumexit));
    a->data.sa[0] = (short)r->x;
    a->data.sa[1] = (short)r->y;

    /* Benutzer in die Halle teleportieren */
    move_unit(u, findregion(9525, 9525), NULL);

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

    /* Benutzer ein Exitticket geben */
    i_change(&u->items, itype, 1);

    return 0;
}