コード例 #1
0
ファイル: messages.test.c プロジェクト: ennorehling/eressea
static void test_merge_split(CuTest *tc) {
    message_list *mlist = 0, *append = 0;
    struct mlist **split; /* TODO: why is this a double asterisk? */
    message_type *mtype;
    message *msg;

    test_setup();
    mtype = mt_create(mt_new("custom", NULL), NULL, 0);
    add_message(&mlist, msg = msg_message(mtype->name, ""));
    msg_release(msg);
    add_message(&append, msg = msg_message(mtype->name, ""));
    msg_release(msg);

    CuAssertPtrEquals(tc, NULL, mlist->begin->next);
    CuAssertPtrEquals(tc, &mlist->begin->next, mlist->end);
    split = merge_messages(mlist, append);
    CuAssertPtrNotNull(tc, split);
    CuAssertPtrEquals(tc, &mlist->begin->next, split);
    CuAssertPtrEquals(tc, append->end, mlist->end);
    CuAssertPtrNotNull(tc, mlist->begin->next);
    CuAssertPtrEquals(tc, append->begin, mlist->begin->next);
    split_messages(mlist, split);
    CuAssertPtrEquals(tc, NULL, mlist->begin->next);
    free_messagelist(*split);
    free_messagelist(mlist->begin);
    free(mlist);
    free_messagelist(append->begin);
    free(append);
    test_teardown();
}
コード例 #2
0
ファイル: give.test.c プロジェクト: ennorehling/eressea
static void test_give_men_magicians(CuTest * tc) {
    struct give env = { 0 };
    int p;
    message * msg;

    test_setup_ex(tc);
    mt_create_error(158);
    env.f2 = env.f1 = test_create_faction(NULL);
    setup_give(&env);
    set_level(env.src, SK_MAGIC, 1);
    CuAssertPtrNotNull(tc, msg = give_men(1, env.src, env.dst, NULL));
    CuAssertStrEquals(tc, "error158", test_get_messagetype(msg));
    CuAssertIntEquals(tc, 1, env.dst->number);
    CuAssertIntEquals(tc, 1, env.src->number);
    msg_release(msg);

    p = rpeasants(env.r);
    CuAssertPtrNotNull(tc, msg = disband_men(1, env.dst, NULL));
    CuAssertStrEquals(tc, "give_person_peasants", test_get_messagetype(msg));
    CuAssertIntEquals(tc, 0, env.dst->number);
    CuAssertIntEquals(tc, p+1, rpeasants(env.r));
    msg_release(msg);

    test_teardown();
}
コード例 #3
0
ファイル: give.test.c プロジェクト: ennorehling/eressea
static void test_give_men_limit(CuTest * tc) {
    struct give env = { 0 };
    message *msg;

    test_setup_ex(tc);
    env.f2 = test_create_faction(NULL);
    env.f1 = test_create_faction(NULL);
    setup_give(&env);
    config_set("rules.give.max_men", "1");

    /* below the limit, give men, increase newbies counter */
    contact_unit(env.dst, env.src);
    msg = give_men(1, env.src, env.dst, NULL);
    CuAssertStrEquals(tc, "give_person", test_get_messagetype(msg));
    CuAssertIntEquals(tc, 2, env.dst->number);
    CuAssertIntEquals(tc, 0, env.src->number);
    CuAssertIntEquals(tc, 1, env.f2->newbies);
    msg_release(msg);

    /* beyond the limit, do nothing */
    contact_unit(env.src, env.dst);
    msg = give_men(2, env.dst, env.src, NULL);
    CuAssertStrEquals(tc, "error129", test_get_messagetype(msg));
    CuAssertIntEquals(tc, 2, env.dst->number);
    CuAssertIntEquals(tc, 0, env.src->number);
    CuAssertIntEquals(tc, 0, env.f1->newbies);
    msg_release(msg);

    test_teardown();
}
コード例 #4
0
ファイル: combatspells.c プロジェクト: ennorehling/eressea
int sp_frighten(struct castorder * co)
{
    fighter * fi = co->magician.fig;
    int level = co->level;
    double power = co->force;
    const spell * sp = co->sp;
    battle *b = fi->side->battle;
    unit *mage = fi->unit;
    int at_malus = 0;
    int df_malus = 0;
    int force = 0;
    int enemies = 0;
    int targets = 0;
    message *m;

    at_malus = level - 4;
    if (at_malus < 1) at_malus = 1;
    df_malus = 2;
    force = (int)get_force(power, 2);

    enemies = count_enemies(b, fi, FIGHT_ROW, BEHIND_ROW - 1, SELECT_ADVANCE);
    if (!enemies) {
        m = msg_message("spell_out_of_range", "mage spell", fi->unit, sp);
        message_all(b, m);
        msg_release(m);
        return 0;
    }

    while (force && enemies) {
        troop dt = select_enemy(fi, FIGHT_ROW, BEHIND_ROW - 1, SELECT_ADVANCE);
        fighter *df = dt.fighter;
        --enemies;

        if (!df)
            break;

        assert(!helping(fi->side, df->side));

        if (df->person[dt.index].flags & FL_COURAGE) {
            df->person[dt.index].flags &= ~(FL_COURAGE);
        }
        if (!is_magic_resistant(mage, df->unit, 0)) {
            df->person[dt.index].attack -= at_malus;
            df->person[dt.index].defense -= df_malus;
            targets++;
        }
        --force;
    }

    m =
        msg_message("cast_frighten_effect", "mage spell amount", fi->unit, sp,
        targets);
    message_all(b, m);
    msg_release(m);
    return level;
}
コード例 #5
0
/* Feuersturm: Betrifft sehr viele Gegner (in der Regel alle),
 * macht nur vergleichsweise geringen Schaden */
int sp_immolation(struct castorder * co)
{
    fighter * fi = co->magician.fig;
    int level = co->level;
    const spell * sp = co->sp;
    battle *b = fi->side->battle;
    troop at;
    int force, qi, killed = 0;
    const char *damage;
    quicklist *fgs, *ql;
    message *m;

    /* 2d4 HP */
    damage = spell_damage(5);
    /* Betrifft alle Gegner */
    force = 99999;

    if (!count_enemies(b, fi, FIGHT_ROW, AVOID_ROW, SELECT_ADVANCE | SELECT_FIND)) {
        message *m =
            msg_message("battle::out_of_range", "mage spell", fi->unit, sp);
        message_all(b, m);
        msg_release(m);
        return 0;
    }

    at.fighter = fi;
    at.index = 0;

    fgs = fighters(b, fi->side, FIGHT_ROW, AVOID_ROW, FS_ENEMY);
    for (qi = 0, ql = fgs; ql; ql_advance(&ql, &qi, 1)) {
        fighter *df = (fighter *)ql_get(ql, qi);
        int n = df->alive - df->removed;
        troop dt;

        dt.fighter = df;
        while (n != 0) {
            dt.index = --n;
            killed += terminate(dt, at, AT_COMBATSPELL, damage, false);
            if (--force == 0)
                break;
        }
        if (force == 0)
            break;
    }
    ql_free(fgs);

    m =
        msg_message("battle::combatspell", "mage spell killed", fi->unit, sp,
        killed);
    message_all(b, m);
    msg_release(m);
    return level;
}
コード例 #6
0
/* Benommenheit: eine Runde kein Angriff */
int sp_stun(struct castorder * co)
{
    fighter * fi = co->magician.fig;
    int level = co->level;
    double power = co->force;
    const spell * sp = co->sp;
    battle *b = fi->side->battle;
    unit *mage = fi->unit;
    message *m;
    /* Aus beiden Reihen nehmen */
    int force = 0, enemies;
    int stunned;

    if (power <= 0)
        return 0;

    switch (sp->id) {
    case SPL_SHOCKWAVE:
        force = lovar(get_force(power, 1));
        break;
    default:
        assert(0);
    }

    enemies = count_enemies(b, fi, FIGHT_ROW, BEHIND_ROW, SELECT_ADVANCE);
    if (!enemies) {
        message *m =
            msg_message("battle::out_of_range", "mage spell", fi->unit, sp);
        message_all(b, m);
        msg_release(m);
        return 0;
    }

    stunned = 0;
    while (force && stunned < enemies) {
        troop dt = select_enemy(fi, FIGHT_ROW, BEHIND_ROW, SELECT_ADVANCE);
        fighter *df = dt.fighter;
        unit *du = df->unit;

        --force;
        if (!is_magic_resistant(mage, du, 0)) {
            df->person[dt.index].flags |= FL_STUNNED;
            ++stunned;
        }
    }

    m = msg_message("cast_stun_effect", "mage spell amount", fi->unit, sp, stunned);
    message_all(b, m);
    msg_release(m);
    return level;
}
コード例 #7
0
ファイル: combatspells.c プロジェクト: ennorehling/eressea
/* Panik (Praekampfzauber) */
int flee_spell(struct castorder * co, int strength)
{
    fighter * fi = co->magician.fig;
    int level = co->level;
    const spell * sp = co->sp;
    battle *b = fi->side->battle;
    unit *mage = fi->unit;
    selist *fgs, *ql;
    int n, qi, panik = 0;
    message *msg;
    double power = co->force;
    int force;

    force = (int)get_force(power, strength);
    if (force<=0 || !count_enemies(b, fi, FIGHT_ROW, AVOID_ROW, SELECT_ADVANCE | SELECT_FIND)) {
        msg = msg_message("sp_flee_effect_0", "mage spell", mage, sp);
        message_all(b, msg);
        msg_release(msg);
        return 0;
    }

    fgs = select_fighters(b, fi->side, FS_ENEMY, select_afraid, NULL);
    scramble_fighters(fgs);

    for (qi = 0, ql = fgs; force > 0 && ql; selist_advance(&ql, &qi, 1)) {
        fighter *df = (fighter *)selist_get(ql, qi);

        for (n = 0; force > 0 && n != df->alive; ++n) {
            if (df->person[n].flags & FL_PANICED) {   /* bei SPL_SONG_OF_FEAR moeglich */
                df->person[n].attack -= 1;
                --force;
                ++panik;
            }
            else if (!(df->person[n].flags & FL_COURAGE)
                || !(u_race(df->unit)->flags & RCF_UNDEAD)) {
                if (!is_magic_resistant(mage, df->unit, 0)) {
                    df->person[n].flags |= FL_PANICED;
                    ++panik;
                }
                --force;
            }
        }
    }
    selist_free(fgs);

    msg = msg_message("sp_flee_effect_1", "mage spell amount", mage, sp, panik);
    message_all(b, msg);
    msg_release(msg);

    return level;
}
コード例 #8
0
int sp_windshield(struct castorder * co)
{
    fighter * fi = co->magician.fig;
    int level = co->level;
    double power = co->force;
    const spell * sp = co->sp;
    battle *b = fi->side->battle;
    int force, at_malus;
    int enemies;
    message *m;

    switch (sp->id) {
    case SPL_WINDSHIELD:
        force = (int)get_force(power, 4);
        at_malus = level / 4;
        break;

    default:
        force = (int)power;
        at_malus = 2;
    }
    enemies = count_enemies(b, fi, BEHIND_ROW, BEHIND_ROW, SELECT_ADVANCE);
    if (!enemies) {
        m = msg_message("battle::out_of_range", "mage spell", fi->unit, sp);
        message_all(b, m);
        msg_release(m);
        return 0;
    }

    while (force && enemies) {
        troop dt = select_enemy(fi, BEHIND_ROW, BEHIND_ROW, SELECT_ADVANCE);
        fighter *df = dt.fighter;
        --enemies;

        if (!df)
            break;
        assert(!helping(fi->side, df->side));

        if (df->person[dt.index].missile) {
            /* this suxx... affects your melee weapon as well. */
            df->person[dt.index].attack -= at_malus;
            --force;
        }
    }

    m = msg_message("cast_storm_effect", "mage spell", fi->unit, sp);
    message_all(b, m);
    msg_release(m);
    return level;
}
コード例 #9
0
ファイル: combatspells.c プロジェクト: ennorehling/eressea
int sp_dragonodem(struct castorder * co)
{
    fighter * fi = co->magician.fig;
    int level = co->level;
    double power = co->force;
    const spell * sp = co->sp;
    battle *b = fi->side->battle;
    troop dt;
    troop at;
    int force, enemies;
    const char *damage;

    /* 11-26 HP */
    damage = spell_damage(4);
    /* Jungdrache 3->54, Drache 6->216, Wyrm 12->864 Treffer */
    force = lovar(get_force(power, 6));

    enemies = count_enemies(b, fi, FIGHT_ROW, BEHIND_ROW - 1, SELECT_ADVANCE);

    if (!enemies) {
        struct message *m =
            msg_message("spell_out_of_range", "mage spell", fi->unit, sp);
        message_all(b, m);
        msg_release(m);
        return 0;
    }
    else {
        struct message *m;
        int killed = 0;

        at.fighter = fi;
        at.index = 0;

        while (force && killed < enemies) {
            dt = select_enemy(fi, FIGHT_ROW, BEHIND_ROW - 1, SELECT_ADVANCE);
            assert(dt.fighter);
            --force;
            killed += terminate(dt, at, AT_COMBATSPELL, damage, false);
        }

        m =
            msg_message("cast_combatspell", "mage spell dead", fi->unit, sp,
            killed);
        message_all(b, m);
        msg_release(m);
    }
    return level;
}
コード例 #10
0
ファイル: gmcmd.c プロジェクト: UweKopf/server
/**
 ** GM: TELL PLANE <string>
 ** requires: permission-key "gmmsgr"
 **/
static void gm_messageplane(const void *tnext, struct unit *gm, struct order *ord)
{
  const struct plane *p = rplane(gm->region);
  const char *zmsg = getstrtoken();
  if (p == NULL) {
    mistake(gm, ord, "In diese Ebene kann keine Nachricht gesandt werden.");
  } else {
    /* checking permissions */
    attrib *permissions = a_find(gm->faction->attribs, &at_permissions);
    if (!permissions || !has_permission(permissions, atoi36("gmmsgr"))) {
      mistake(gm, ord, "permission denied.");
    } else {
      message *msg = msg_message("msg_event", "string", zmsg);
      faction *f;
      region *r;
      for (f = factions; f; f = f->next) {
        freset(f, FFL_SELECT);
      }
      for (r = regions; r; r = r->next) {
        unit *u;
        if (rplane(r) != p)
          continue;
        for (u = r->units; u; u = u->next)
          if (!fval(u->faction, FFL_SELECT)) {
            f = u->faction;
            fset(f, FFL_SELECT);
            add_message(&f->msgs, msg);
          }
      }
      msg_release(msg);
    }
  }
}
コード例 #11
0
int sp_shadowcall(struct castorder * co)
{
    fighter * fi = co->magician.fig;
    int level = co->level;
    double power = co->force;
    battle *b = fi->side->battle;
    region *r = b->region;
    unit *mage = fi->unit;
    attrib *a;
    int force = (int)(get_force(power, 3) / 2);
    unit *u;
    const char *races[3] = { "shadowbat", "nightmare", "vampunicorn" };
    const race *rc = rc_find(races[rng_int() % 3]);
    message *msg;

    u = create_unit(r, mage->faction, force, rc, 0, NULL, mage);
    setstatus(u, ST_FIGHT);

    set_level(u, SK_WEAPONLESS, (int)(power / 2));
    set_level(u, SK_STAMINA, (int)(power / 2));
    u->hp = u->number * unit_max_hp(u);

    a = a_new(&at_unitdissolve);
    a->data.ca[0] = 0;
    a->data.ca[1] = 100;
    a_add(&u->attribs, a);

    make_fighter(b, u, fi->side, is_attacker(fi));
    msg =
        msg_message("sp_shadowcall_effect", "mage amount race", mage, u->number,
        u_race(u));
    message_all(b, msg);
    msg_release(msg);
    return level;
}
コード例 #12
0
int sp_fumbleshield(struct castorder * co)
{
    fighter * fi = co->magician.fig;
    int level = co->level;
    const spell * sp = co->sp;
    int effect;
    int duration;
    battle *b = fi->side->battle;
    message *m = msg_message("cast_spell_effect", "mage spell", fi->unit, sp);

    message_all(b, m);
    msg_release(m);

    /* der erste Zauber schl�gt mit 100% fehl  */

    switch (sp->id) {
    case SPL_DRAIG_FUMBLESHIELD:
    case SPL_GWYRRD_FUMBLESHIELD:
    case SPL_CERDDOR_FUMBLESHIELD:
    case SPL_TYBIED_FUMBLESHIELD:
        duration = 100;
        effect = _max(1, 25 - level);
        break;

    default:
        duration = 100;
        effect = 10;
    }
    do_meffect(fi, SHIELD_BLOCK, effect, duration);
    return level;
}
コード例 #13
0
int sp_reduceshield(struct castorder * co)
{
    fighter * fi = co->magician.fig;
    int level = co->level;
    double power = co->force;
    const spell * sp = co->sp;
    int effect;
    int duration;
    battle *b = fi->side->battle;
    message *m = msg_message("cast_spell_effect", "mage spell", fi->unit, sp);
    message_all(b, m);
    msg_release(m);

    /* jeder Schaden wird um effect% reduziert bis der Schild duration
     * Trefferpunkte aufgefangen hat */

    switch (sp->id) {
    case SPL_REDUCESHIELD:
        effect = 50;
        duration = (int)(50 * power * power);
        break;

    default:
        effect = level * 3;
        duration = (int)get_force(power, 5);
    }
    do_meffect(fi, SHIELD_REDUCE, effect, duration);
    return level;
}
コード例 #14
0
int sp_armorshield(struct castorder * co)
{
    fighter * fi = co->magician.fig;
    int level = co->level;
    double power = co->force;
    const spell * sp = co->sp;
    int effect;
    int duration;
    battle *b = fi->side->battle;
    message *m = msg_message("cast_spell_effect", "mage spell", fi->unit, sp);

    message_all(b, m);
    msg_release(m);

    /* gibt R�stung +effect f�r duration Treffer */

    switch (sp->id) {
    case SPL_ARMORSHIELD:
        effect = level / 3;
        duration = (int)(20 * power * power);
        break;

    default:
        effect = level / 4;
        duration = (int)(power * power);
    }
    do_meffect(fi, SHIELD_ARMOR, effect, duration);
    return level;
}
コード例 #15
0
ファイル: combatspells.c プロジェクト: mideg/server
int sp_strong_wall(struct castorder * co)
{
  fighter * fi = co->magician.fig;
  int level = co->level;
  float power = co->force;
  battle *b = fi->side->battle;
  unit *mage = fi->unit;
  building *burg;
  float effect;
  static bool init = false;
  message *msg;
  static const curse_type *strongwall_ct;
  if (!init) {
    init = true;
    strongwall_ct = ct_find("strongwall");
  }

  if (!mage->building) {
    return 0;
  }
  burg = mage->building;

  effect = power / 4;
  create_curse(mage, &burg->attribs, strongwall_ct, power, 1, effect, 0);

  msg =
    msg_message("sp_strongwalls_effect", "mage building", mage, mage->building);
  message_all(b, msg);
  msg_release(msg);

  return level;
}
コード例 #16
0
static void report_transfer(faction *f1, faction *f2, region *r, int amount) {
    struct message *msg = msg_message("donation",
        "from to amount", f1, f2, amount);
    r_addmessage(r, f1, msg);
    r_addmessage(r, f2, msg);
    msg_release(msg);
}
コード例 #17
0
ファイル: combatspells.c プロジェクト: mideg/server
/* Magier weicht dem Kampf aus. Wenn er sich bewegen kann, zieht er in
 * eine Nachbarregion, wobei ein NACH berücksichtigt wird. Ansonsten
 * bleibt er stehen und nimmt nicht weiter am Kampf teil. */
int sp_denyattack(struct castorder * co)
{
  fighter * fi = co->magician.fig;
  int level = co->level;

  const spell * sp = co->sp;
  battle *b = fi->side->battle;
  unit *mage = fi->unit;
  region *r = b->region;
  message *m;

  /* Fliehende Einheiten verlassen auf jeden Fall Gebäude und Schiffe. */
  if (!fval(r->terrain, SEA_REGION)) {
    leave(mage, false);
  }
  /* und bewachen nicht */
  setguard(mage, GUARD_NONE);
  /* irgendwie den langen befehl sperren */
  /* fset(fi, FIG_ATTACKED); */

  /* wir tun so, als wäre die Person geflohen */
  fset(fi, FIG_NOLOOT);
  fi->run.hp = mage->hp;
  fi->run.number = mage->number;
  /* fighter leeren */
  rmfighter(fi, mage->number);

  m = msg_message("cast_escape_effect", "mage spell", fi->unit, sp);
  message_all(b, m);
  msg_release(m);

  return level;
}
コード例 #18
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;
}
コード例 #19
0
ファイル: combatspells.c プロジェクト: ennorehling/eressea
int sp_strong_wall(struct castorder * co)
{
    fighter * fi = co->magician.fig;
    int level = co->level;
    double power = co->force;
    battle *b = fi->side->battle;
    unit *mage = fi->unit;
    building *burg;
    double effect;
    message *msg;

    if (!mage->building) {
        return 0;
    }
    burg = mage->building;

    effect = power / 4;
    create_curse(mage, &burg->attribs, &ct_strongwall, power, 1, effect, 0);

    msg =
        msg_message("sp_strongwalls_effect", "mage building", mage, mage->building);
    message_all(b, msg);
    msg_release(msg);

    return level;
}
コード例 #20
0
ファイル: combatspells.c プロジェクト: ennorehling/eressea
static fighter *summon_allies(const fighter *fi, const race *rc, int number) {
    attrib *a;
    unit *mage = fi->unit;
    side *si = fi->side;
    battle *b = si->battle;
    region *r = b->region;
    message *msg;
    unit *u =
        create_unit(r, mage->faction, number, rc, 0, NULL, mage);
    leave(u, true);
    unit_setstatus(u, ST_FIGHT);
    
    u->hp = u->number * unit_max_hp(u);
    
    if (mage->flags & UFL_ANON_FACTION) {
        u->flags |= UFL_ANON_FACTION;
    }
    
    a = a_new(&at_unitdissolve);
    a->data.ca[0] = 0;
    a->data.ca[1] = 100;
    a_add(&u->attribs, a);
    
    msg = msg_message("sp_wolfhowl_effect", "mage amount race", mage, u->number, rc);
    message_all(b, msg);
    msg_release(msg);

    return make_fighter(b, u, si, is_attacker(fi));
}
コード例 #21
0
ファイル: combatspells.c プロジェクト: ennorehling/eressea
/* Magier weicht dem Kampf aus. Wenn er sich bewegen kann, zieht er in
 * eine Nachbarregion, wobei ein NACH beruecksichtigt wird. Ansonsten
 * bleibt er stehen und nimmt nicht weiter am Kampf teil. */
int sp_appeasement(struct castorder * co)
{
    fighter * fi = co->magician.fig;
    int level = co->level;

    const spell * sp = co->sp;
    battle *b = fi->side->battle;
    unit *mage = fi->unit;
    region *r = b->region;
    message *m;

    /* Fliehende Einheiten verlassen auf jeden Fall Gebaeude und Schiffe. */
    if (!(r->terrain->flags & SEA_REGION)) {
        leave(mage, false);
    }
    /* und bewachen nicht */
    setguard(mage, false);
    unit_setstatus(mage, ST_FLEE);

    /* wir tun so, als waere die Person geflohen */
    fi->flags |= FIG_NOLOOT;
    fi->run.hp = mage->hp;
    fi->run.number = mage->number;
    /* fighter leeren */
    rmfighter(fi, mage->number);

    m = msg_message("cast_escape_effect", "mage spell", fi->unit, sp);
    message_all(b, m);
    msg_release(m);

    return level;
}
コード例 #22
0
/* wiederbeleben */
int sp_reanimate(struct castorder * co)
{
    fighter * fi = co->magician.fig;
    int level = co->level;
    double power = co->force;
    battle *b = fi->side->battle;
    unit *mage = fi->unit;
    int healable, j = 0;
    double c = 0.50 + 0.02 * power;
    double k = EFFECT_HEALING_SPELL * power;
    bool use_item = has_ao_healing(mage);
    message *msg;

    if (use_item) {
        k *= 2;
        c += 0.10;
    }

    healable = count_healable(b, fi);
    healable = (int)_min(k, healable);
    while (healable--) {
        fighter *tf = select_corpse(b, fi);
        if (tf != NULL && tf->side->casualties > 0
            && u_race(tf->unit) != get_race(RC_DAEMON)
            && (chance(c))) {
            assert(tf->alive < tf->unit->number);
            /* t.fighter->person[].hp beginnt mit t.index = 0 zu z�hlen,
             * t.fighter->alive ist jedoch die Anzahl lebender in der Einheit,
             * also sind die hp von t.fighter->alive
             * t.fighter->hitpoints[t.fighter->alive-1] und der erste Tote
             * oder weggelaufene ist t.fighter->hitpoints[tf->alive] */
            tf->person[tf->alive].hp = 2;
            ++tf->alive;
            ++tf->side->size[SUM_ROW];
            ++tf->side->size[tf->unit->status + 1];
            ++tf->side->healed;
            --tf->side->casualties;
            assert(tf->side->casualties >= 0);
            --tf->side->dead;
            assert(tf->side->dead >= 0);
            ++j;
        }
    }
    if (j <= 0) {
        level = j;
    }
    if (use_item) {
        msg =
            msg_message("reanimate_effect_1", "mage amount item", mage, j,
            get_resourcetype(R_AMULET_OF_HEALING));
    }
    else {
        msg = msg_message("reanimate_effect_0", "mage amount", mage, j);
    }
    message_all(b, msg);
    msg_release(msg);

    return level;
}
コード例 #23
0
int sp_drainodem(fighter * fi, int level, double power, spell * sp)
{
    battle *b = fi->side->battle;
    troop dt;
    troop at;
    int force, enemies;
    int drained = 0;
    int killed = 0;
    const char *damage;
    message *m;

    /* 11-26 HP */
    damage = spell_damage(4);
    /* Jungdrache 3->54, Drache 6->216, Wyrm 12->864 Treffer */
    force = lovar(get_force(power, 6));

    enemies = count_enemies(b, fi, FIGHT_ROW, BEHIND_ROW - 1, SELECT_ADVANCE);

    if (!enemies) {
        m = msg_message("battle::out_of_range", "mage spell", fi->unit, sp);
        message_all(b, m);
        msg_release(m);
        return 0;
    }

    at.fighter = fi;
    at.index = 0;

    while (force && drained < enemies) {
        dt = select_enemy(fi, FIGHT_ROW, BEHIND_ROW - 1, SELECT_ADVANCE);
        assert(dt.fighter);
        if (hits(at, dt, NULL)) {
            drain_exp(dt.fighter->unit, 90);
            ++drained;
            killed += terminate(dt, at, AT_COMBATSPELL, damage, false);
        }
        --force;
    }

    m =
        msg_message("cast_drainlife_effect", "mage spell amount", fi->unit, sp,
        drained);
    message_all(b, m);
    msg_release(m);
    return level;
}
コード例 #24
0
int sp_berserk(struct castorder * co)
{
    fighter * fi = co->magician.fig;
    int level = co->level;
    double power = co->force;
    const spell * sp = co->sp;
    battle *b = fi->side->battle;
    int at_bonus = 0;
    int df_malus = 0;
    int force = 0;
    int allies = 0;
    int targets = 0;
    message *m;

    switch (sp->id) {
    case SPL_BERSERK:
    case SPL_BLOODTHIRST:
        at_bonus = _max(1, level / 3);
        df_malus = 2;
        force = (int)get_force(power, 2);
        break;

    default:
        at_bonus = 1;
        df_malus = 0;
        force = (int)power;
    }

    allies =
        count_allies(fi->side, FIGHT_ROW, BEHIND_ROW - 1, SELECT_ADVANCE, ALLY_ANY);
    /* maximal 2*allies Versuche ein Opfer zu finden, ansonsten best�nde
     * die Gefahr eine Endlosschleife*/
    allies *= 2;

    while (force && allies) {
        troop dt = select_ally(fi, FIGHT_ROW, BEHIND_ROW - 1, ALLY_ANY);
        fighter *df = dt.fighter;
        --allies;

        if (df) {
            if (!(df->person[dt.index].flags & FL_COURAGE)) {
                df->person[dt.index].attack += at_bonus;
                df->person[dt.index].defence -= df_malus;
                df->person[dt.index].flags = df->person[dt.index].flags | FL_COURAGE;
                targets++;
                --force;
            }
        }
    }

    m =
        msg_message("cast_berserk_effect", "mage spell amount", fi->unit, sp,
        targets);
    message_all(b, m);
    msg_release(m);
    return level;
}
コード例 #25
0
int sp_tiredsoldiers(struct castorder * co)
{
    fighter * fi = co->magician.fig;
    int level = co->level;
    double power = co->force;
    const spell * sp = co->sp;
    battle *b = fi->side->battle;
    unit *mage = fi->unit;
    int n = 0;
    int force = (int)(power * power * 4);
    message *m;

    if (!count_enemies(b, fi, FIGHT_ROW, BEHIND_ROW,
        SELECT_ADVANCE | SELECT_FIND)) {
        message *m =
            msg_message("battle::out_of_range", "mage spell", fi->unit, sp);
        message_all(b, m);
        msg_release(m);
        return 0;
    }

    while (force) {
        troop t = select_enemy(fi, FIGHT_ROW, BEHIND_ROW, SELECT_ADVANCE);
        fighter *df = t.fighter;

        if (!df)
            break;

        assert(!helping(fi->side, df->side));
        if (!(df->person[t.index].flags & FL_TIRED)) {
            if (!is_magic_resistant(mage, df->unit, 0)) {
                df->person[t.index].flags = df->person[t.index].flags | FL_TIRED;
                df->person[t.index].defence -= 2;
                ++n;
            }
        }
        --force;
    }

    m = msg_message("cast_tired_effect", "mage spell amount", fi->unit, sp, n);
    message_all(b, m);
    msg_release(m);
    return level;
}
コード例 #26
0
ファイル: curse.test.c プロジェクト: philbooth/server
static void test_bad_dreams(CuTest *tc) {
    curse_fixture fix;
    message *msg;
    setup_curse(&fix, "gbdream");
    fix.c->effect = -1;
    msg = fix.c->type->curseinfo(fix.r, TYP_REGION, fix.c, 0);
    CuAssertStrEquals(tc, "curseinfo::baddream", test_get_messagetype(msg));
    msg_release(msg);
    test_cleanup();
}
コード例 #27
0
ファイル: curse.test.c プロジェクト: philbooth/server
static void test_magicstreet_warning(CuTest *tc) {
    curse_fixture fix;
    message *msg;
    setup_curse(&fix, "magicstreet");
    fix.c->duration = 1;
    msg = fix.c->type->curseinfo(fix.r, TYP_REGION, fix.c, 0);
    CuAssertStrEquals(tc, "curseinfo::magicstreetwarn", test_get_messagetype(msg));
    msg_release(msg);
    test_cleanup();
}
コード例 #28
0
ファイル: donations.c プロジェクト: ennorehling/eressea
static void report_transfer(void *data) {
    transfer *tf = (transfer *)data;
    if (tf->amount > 0) {
        struct message *msg = msg_message("donation",
             "from to amount", tf->f1, tf->f2, tf->amount);
        r_addmessage(tf->r, tf->f1, msg);
        r_addmessage(tf->r, tf->f2, msg);
        msg_release(msg);
    }
}
コード例 #29
0
/* Versteinern */
int sp_petrify(struct castorder * co)
{
    fighter * fi = co->magician.fig;
    int level = co->level;
    double power = co->force;
    const spell * sp = co->sp;
    battle *b = fi->side->battle;
    unit *mage = fi->unit;
    /* Wirkt auf erste und zweite Reihe */
    int force, enemies;
    int stoned = 0;
    message *m;

    force = lovar(get_force(power, 0));

    enemies = count_enemies(b, fi, FIGHT_ROW, BEHIND_ROW, SELECT_ADVANCE);
    if (!enemies) {
        message *m =
            msg_message("battle::out_of_range", "mage spell", fi->unit, sp);
        message_all(b, m);
        msg_release(m);
        return 0;
    }

    while (force && stoned < enemies) {
        troop dt = select_enemy(fi, FIGHT_ROW, BEHIND_ROW, SELECT_ADVANCE);
        unit *du = dt.fighter->unit;
        if (!is_magic_resistant(mage, du, 0)) {
            /* person ans ende hinter die lebenden schieben */
            remove_troop(dt);
            ++stoned;
        }
        --force;
    }

    m =
        msg_message("cast_petrify_effect", "mage spell amount", fi->unit, sp,
        stoned);
    message_all(b, m);
    msg_release(m);
    return level;
}
コード例 #30
0
static void receive_get_message_reply(ngx_int_t sender, getmessage_data_t *d) {
  
  assert(d->shm_chid->len>1);
  assert(d->shm_chid->data!=NULL);
  DBG("IPC: received get_message reply for channel %V msg %p privdata %p", d->shm_chid, d->d.resp.shm_msg, d->privdata);
  nchan_memstore_handle_get_message_reply(d->d.resp.shm_msg, d->d.resp.getmsg_code, d->privdata);
  if(d->d.resp.shm_msg) {
    msg_release(d->d.resp.shm_msg, "get_message_reply");
  }
  str_shm_free(d->shm_chid);
}