• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ ADDMSG函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中ADDMSG函数的典型用法代码示例。如果您正苦于以下问题:C++ ADDMSG函数的具体用法?C++ ADDMSG怎么用?C++ ADDMSG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ADDMSG函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: gm_teleport

/**
 ** 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);
  }
}
开发者ID:UweKopf,项目名称:server,代码行数:29,代码来源:gmcmd.c


示例2: drown

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);
  }
}
开发者ID:hochl,项目名称:server,代码行数:31,代码来源:randenc.c


示例3: age_hurting

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;
}
开发者ID:UweKopf,项目名称:server,代码行数:27,代码来源:arena.c


示例4: volcano_destruction

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);
}
开发者ID:hochl,项目名称:server,代码行数:49,代码来源:randenc.c


示例5: hunger

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);
}
开发者ID:Xolgrim,项目名称:server,代码行数:49,代码来源:upkeep.c


示例6: godcurse

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;
                }
            }
        }
    }

}
开发者ID:eressea,项目名称:server,代码行数:35,代码来源:randenc.c


示例7: mistake

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));
  }
}
开发者ID:UweKopf,项目名称:server,代码行数:7,代码来源:gmcmd.c


示例8: gm_skill

/**
 ** 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);
    }
  }
}
开发者ID:UweKopf,项目名称:server,代码行数:30,代码来源:gmcmd.c


示例9: gm_take

/**
 ** 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);
      }
    }
  }
}
开发者ID:UweKopf,项目名称:server,代码行数:33,代码来源:gmcmd.c


示例10: gm_messageunit

/**
 ** 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));
    }
  }
}
开发者ID:UweKopf,项目名称:server,代码行数:32,代码来源:gmcmd.c


示例11: gm_killfaction

/**
 ** 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.");
}
开发者ID:UweKopf,项目名称:server,代码行数:32,代码来源:gmcmd.c


示例12: build_ship

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));
}
开发者ID:Xolgrim,项目名称:server,代码行数:31,代码来源:build.c


示例13: wormhole_age

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;
}
开发者ID:Xolgrim,项目名称:server,代码行数:32,代码来源:wormhole.c


示例14: give_igjarjuk

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;
}
开发者ID:TomBraun,项目名称:server,代码行数:7,代码来源:demonseye.c


示例15: melt_iceberg

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);
}
开发者ID:hochl,项目名称:server,代码行数:30,代码来源:randenc.c


示例16: scared_by_monster

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));
            }
        }
    }
}
开发者ID:hochl,项目名称:server,代码行数:30,代码来源:monster.c


示例17: cb_msg_teach

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;
}
开发者ID:ennorehling,项目名称:eressea,代码行数:17,代码来源:study.c


示例18: make_wormhole

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));
}
开发者ID:Xolgrim,项目名称:server,代码行数:18,代码来源:wormhole.c


示例19: end_potion

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));
}
开发者ID:hochl,项目名称:server,代码行数:9,代码来源:alchemy.c


示例20: eaten_by_monster

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));
  }
}
开发者ID:UweKopf,项目名称:server,代码行数:44,代码来源:monster.c



注:本文中的ADDMSG函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ADDR函数代码示例发布时间:2022-05-30
下一篇:
C++ ADD函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap