本文整理汇总了C++中ADDMSG函数的典型用法代码示例。如果您正苦于以下问题:C++ ADDMSG函数的具体用法?C++ ADDMSG怎么用?C++ ADDMSG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ADDMSG函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
}
}
}
}
示例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));
}
}
示例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);
}
}
}
示例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);
}
}
}
}
示例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));
}
}
}
示例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.");
}
示例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));
}
示例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;
}
示例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;
}
示例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);
}