2010-08-08 09:40:42 +02:00
|
|
|
|
/* vi: set ts=2:
|
|
|
|
|
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
|
|
|
|
| | Enno Rehling <enno@eressea.de>
|
|
|
|
|
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
|
|
|
|
| (c) 1998 - 2003 | Henning Peters <faroul@beyond.kn-bremen.de>
|
|
|
|
|
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
|
|
|
|
+-------------------+ Stefan Reich <reich@halbling.de>
|
|
|
|
|
|
|
|
|
|
This program may not be used, modified or distributed
|
|
|
|
|
without prior permission by the authors of Eressea.
|
|
|
|
|
*/
|
|
|
|
|
#include <platform.h>
|
|
|
|
|
#include <kernel/config.h>
|
2012-06-05 06:45:25 +02:00
|
|
|
|
#include <kernel/types.h>
|
2010-08-08 09:40:42 +02:00
|
|
|
|
#include "combatspells.h"
|
|
|
|
|
|
|
|
|
|
/* kernel includes */
|
|
|
|
|
#include <kernel/battle.h>
|
|
|
|
|
#include <kernel/build.h>
|
|
|
|
|
#include <kernel/building.h>
|
2012-06-05 06:45:25 +02:00
|
|
|
|
#include <kernel/curse.h>
|
2010-08-08 09:40:42 +02:00
|
|
|
|
#include <kernel/faction.h>
|
|
|
|
|
#include <kernel/item.h>
|
|
|
|
|
#include <kernel/magic.h>
|
2014-06-09 18:54:48 +02:00
|
|
|
|
#include <kernel/messages.h>
|
2010-08-08 09:40:42 +02:00
|
|
|
|
#include <kernel/order.h>
|
2012-06-05 06:45:25 +02:00
|
|
|
|
#include <kernel/race.h>
|
2010-08-08 09:40:42 +02:00
|
|
|
|
#include <kernel/region.h>
|
|
|
|
|
#include <kernel/unit.h>
|
|
|
|
|
#include <kernel/move.h>
|
|
|
|
|
#include <kernel/spell.h>
|
|
|
|
|
#include <kernel/spellid.h>
|
|
|
|
|
#include <kernel/race.h>
|
|
|
|
|
#include <kernel/terrain.h>
|
|
|
|
|
|
|
|
|
|
/* util includes */
|
|
|
|
|
#include <util/attrib.h>
|
|
|
|
|
#include <util/base36.h>
|
|
|
|
|
#include <util/rand.h>
|
|
|
|
|
#include <util/rng.h>
|
|
|
|
|
|
2012-06-05 06:45:25 +02:00
|
|
|
|
#include <quicklist.h>
|
|
|
|
|
|
2010-08-08 09:40:42 +02:00
|
|
|
|
/* libc includes */
|
|
|
|
|
#include <assert.h>
|
2014-03-15 19:29:11 +01:00
|
|
|
|
#include <stdlib.h>
|
2010-08-08 09:40:42 +02:00
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
#define EFFECT_HEALING_SPELL 5
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------ */
|
|
|
|
|
/* Kampfzauberfunktionen */
|
|
|
|
|
|
|
|
|
|
/* COMBAT */
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
static const char *spell_damage(int sp)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
|
|
|
|
switch (sp) {
|
|
|
|
|
case 0:
|
|
|
|
|
/* meist t<>dlich 20-65 HP */
|
|
|
|
|
return "5d10+15";
|
|
|
|
|
case 1:
|
|
|
|
|
/* sehr variabel 4-48 HP */
|
|
|
|
|
return "4d12";
|
|
|
|
|
case 2:
|
|
|
|
|
/* leicht verwundet 4-18 HP */
|
|
|
|
|
return "2d8+2";
|
|
|
|
|
case 3:
|
|
|
|
|
/* fast immer t<>dlich 30-50 HP */
|
|
|
|
|
return "5d5+25";
|
|
|
|
|
case 4:
|
|
|
|
|
/* verwundet 11-26 HP */
|
|
|
|
|
return "3d6+8";
|
|
|
|
|
case 5:
|
|
|
|
|
/* leichter Schaden */
|
|
|
|
|
return "2d4";
|
|
|
|
|
default:
|
|
|
|
|
/* schwer verwundet 14-34 HP */
|
|
|
|
|
return "4d6+10";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
static double get_force(double power, int formel)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
|
|
|
|
switch (formel) {
|
|
|
|
|
case 0:
|
2011-03-07 08:03:10 +01:00
|
|
|
|
/* (4,8,12,16,20,24,28,32,36,40,44,..) */
|
2010-08-08 09:40:42 +02:00
|
|
|
|
return (power * 4);
|
|
|
|
|
case 1:
|
|
|
|
|
/* (15,30,45,60,75,90,105,120,135,150,165,..) */
|
2011-03-07 08:03:10 +01:00
|
|
|
|
return (power * 15);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
case 2:
|
2011-03-07 08:03:10 +01:00
|
|
|
|
/* (40,80,120,160,200,240,280,320,360,400,440,..) */
|
|
|
|
|
return (power * 40);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
case 3:
|
2011-03-07 08:03:10 +01:00
|
|
|
|
/* (2,8,18,32,50,72,98,128,162,200,242,..) */
|
|
|
|
|
return (power * power * 2);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
case 4:
|
2011-03-07 08:03:10 +01:00
|
|
|
|
/* (4,16,36,64,100,144,196,256,324,400,484,..) */
|
|
|
|
|
return (power * power * 4);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
case 5:
|
2011-03-07 08:03:10 +01:00
|
|
|
|
/* (10,40,90,160,250,360,490,640,810,1000,1210,1440,..) */
|
|
|
|
|
return (power * power * 10);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
case 6:
|
2011-03-07 08:03:10 +01:00
|
|
|
|
/* (6,24,54,96,150,216,294,384,486,600,726,864) */
|
|
|
|
|
return (power * power * 6);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
default:
|
|
|
|
|
return power;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Generischer Kampfzauber */
|
2012-05-10 03:28:03 +02:00
|
|
|
|
int sp_kampfzauber(struct castorder * co)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2012-05-10 03:28:03 +02:00
|
|
|
|
fighter * fi = co->magician.fig;
|
|
|
|
|
int level = co->level;
|
|
|
|
|
double power = co->force;
|
|
|
|
|
const spell * sp = co->sp;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
battle *b = fi->side->battle;
|
|
|
|
|
troop at, dt;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
message *m;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
/* Immer aus der ersten Reihe nehmen */
|
|
|
|
|
int force, enemies;
|
|
|
|
|
int killed = 0;
|
|
|
|
|
const char *damage;
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
if (power <= 0)
|
|
|
|
|
return 0;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
at.fighter = fi;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
at.index = 0;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
switch (sp->id) {
|
|
|
|
|
/* lovar halbiert im Schnitt! */
|
2010-08-08 09:40:42 +02:00
|
|
|
|
case SPL_FIREBALL:
|
|
|
|
|
damage = spell_damage(0);
|
2011-03-07 08:03:10 +01:00
|
|
|
|
force = lovar(get_force(power, 0));
|
2010-08-08 09:40:42 +02:00
|
|
|
|
break;
|
|
|
|
|
case SPL_HAGEL:
|
|
|
|
|
damage = spell_damage(2);
|
2011-03-07 08:03:10 +01:00
|
|
|
|
force = lovar(get_force(power, 4));
|
2010-08-08 09:40:42 +02:00
|
|
|
|
break;
|
|
|
|
|
case SPL_METEORRAIN:
|
|
|
|
|
damage = spell_damage(1);
|
2011-03-07 08:03:10 +01:00
|
|
|
|
force = lovar(get_force(power, 1));
|
2010-08-08 09:40:42 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
damage = spell_damage(10);
|
2011-03-07 08:03:10 +01:00
|
|
|
|
force = lovar(get_force(power, 10));
|
2010-08-08 09:40:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
enemies = count_enemies(b, fi, FIGHT_ROW, BEHIND_ROW - 1, SELECT_ADVANCE);
|
|
|
|
|
if (enemies == 0) {
|
|
|
|
|
message *m =
|
|
|
|
|
msg_message("battle::out_of_range", "mage spell", fi->unit, sp);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
message_all(b, m);
|
|
|
|
|
msg_release(m);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
while (force > 0 && killed < enemies) {
|
|
|
|
|
dt = select_enemy(fi, FIGHT_ROW, BEHIND_ROW - 1, SELECT_ADVANCE);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
assert(dt.fighter);
|
|
|
|
|
--force;
|
|
|
|
|
killed += terminate(dt, at, AT_COMBATSPELL, damage, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m = msg_message("battle::combatspell", "mage spell dead",
|
|
|
|
|
fi->unit, sp, killed);
|
|
|
|
|
message_all(b, m);
|
|
|
|
|
msg_release(m);
|
|
|
|
|
|
|
|
|
|
return level;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Versteinern */
|
2012-05-10 03:28:03 +02:00
|
|
|
|
int sp_petrify(struct castorder * co)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2012-05-10 03:28:03 +02:00
|
|
|
|
fighter * fi = co->magician.fig;
|
|
|
|
|
int level = co->level;
|
|
|
|
|
double power = co->force;
|
|
|
|
|
const spell * sp = co->sp;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
battle *b = fi->side->battle;
|
|
|
|
|
unit *mage = fi->unit;
|
|
|
|
|
/* Wirkt auf erste und zweite Reihe */
|
|
|
|
|
int force, enemies;
|
|
|
|
|
int stoned = 0;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
message *m;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
|
|
|
|
force = lovar(get_force(power, 0));
|
|
|
|
|
|
|
|
|
|
enemies = count_enemies(b, fi, FIGHT_ROW, BEHIND_ROW, SELECT_ADVANCE);
|
|
|
|
|
if (!enemies) {
|
2011-03-07 08:03:10 +01:00
|
|
|
|
message *m =
|
|
|
|
|
msg_message("battle::out_of_range", "mage spell", fi->unit, sp);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
message_all(b, m);
|
|
|
|
|
msg_release(m);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (force && stoned < enemies) {
|
|
|
|
|
troop dt = select_enemy(fi, FIGHT_ROW, BEHIND_ROW, SELECT_ADVANCE);
|
2011-03-07 08:03:10 +01:00
|
|
|
|
unit *du = dt.fighter->unit;
|
2012-05-24 07:23:32 +02:00
|
|
|
|
if (!is_magic_resistant(mage, du, 0)) {
|
2010-08-08 09:40:42 +02:00
|
|
|
|
/* person ans ende hinter die lebenden schieben */
|
|
|
|
|
remove_troop(dt);
|
|
|
|
|
++stoned;
|
|
|
|
|
}
|
|
|
|
|
--force;
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
m =
|
|
|
|
|
msg_message("cast_petrify_effect", "mage spell amount", fi->unit, sp,
|
|
|
|
|
stoned);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
message_all(b, m);
|
|
|
|
|
msg_release(m);
|
|
|
|
|
return level;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Benommenheit: eine Runde kein Angriff */
|
2012-05-10 03:28:03 +02:00
|
|
|
|
int sp_stun(struct castorder * co)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2012-05-10 03:28:03 +02:00
|
|
|
|
fighter * fi = co->magician.fig;
|
|
|
|
|
int level = co->level;
|
|
|
|
|
double power = co->force;
|
|
|
|
|
const spell * sp = co->sp;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
battle *b = fi->side->battle;
|
|
|
|
|
unit *mage = fi->unit;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
message *m;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
/* Aus beiden Reihen nehmen */
|
2011-03-07 08:03:10 +01:00
|
|
|
|
int force = 0, enemies;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
int stunned;
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
if (power <= 0)
|
|
|
|
|
return 0;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
switch (sp->id) {
|
2010-08-08 09:40:42 +02:00
|
|
|
|
case SPL_SHOCKWAVE:
|
2011-03-07 08:03:10 +01:00
|
|
|
|
force = lovar(get_force(power, 1));
|
2010-08-08 09:40:42 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
assert(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
enemies = count_enemies(b, fi, FIGHT_ROW, BEHIND_ROW, SELECT_ADVANCE);
|
|
|
|
|
if (!enemies) {
|
2011-03-07 08:03:10 +01:00
|
|
|
|
message *m =
|
|
|
|
|
msg_message("battle::out_of_range", "mage spell", fi->unit, sp);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
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);
|
2011-03-07 08:03:10 +01:00
|
|
|
|
fighter *df = dt.fighter;
|
|
|
|
|
unit *du = df->unit;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
|
|
|
|
--force;
|
2012-05-24 07:23:32 +02:00
|
|
|
|
if (!is_magic_resistant(mage, du, 0)) {
|
2011-03-07 08:03:10 +01:00
|
|
|
|
df->person[dt.index].flags |= FL_STUNNED;
|
|
|
|
|
++stunned;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-19 06:25:21 +02:00
|
|
|
|
m = msg_message("cast_stun_effect", "mage spell amount", fi->unit, sp, stunned);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
message_all(b, m);
|
|
|
|
|
msg_release(m);
|
|
|
|
|
return level;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-27 21:04:29 +01:00
|
|
|
|
/** randomly shuffle an array
|
|
|
|
|
* for correctness, see Donald E. Knuth, The Art of Computer Programming
|
|
|
|
|
*/
|
2011-03-07 08:03:10 +01:00
|
|
|
|
static void scramble_fighters(quicklist * ql)
|
2011-02-27 21:04:29 +01:00
|
|
|
|
{
|
|
|
|
|
int qi, qlen = ql_length(ql);
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
for (qi = 0; qi != qlen; ++qi) {
|
|
|
|
|
int qj = qi + (rng_int() % (qlen - qi));
|
|
|
|
|
void *a = ql_get(ql, qi);
|
|
|
|
|
void *b = ql_replace(ql, qj, a);
|
2011-02-27 21:04:29 +01:00
|
|
|
|
ql_replace(ql, qi, b);
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
|
|
|
|
/* Rosthauch */
|
2012-05-10 03:28:03 +02:00
|
|
|
|
int sp_combatrosthauch(struct castorder * co)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2012-05-10 03:28:03 +02:00
|
|
|
|
fighter * fi = co->magician.fig;
|
|
|
|
|
int level = co->level;
|
|
|
|
|
double power = co->force;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
battle *b = fi->side->battle;
|
2011-02-27 21:04:29 +01:00
|
|
|
|
quicklist *ql, *fgs;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
int force = lovar(power * 15);
|
2011-02-27 21:04:29 +01:00
|
|
|
|
int qi, k = 0;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
if (!count_enemies(b, fi, FIGHT_ROW, BEHIND_ROW - 1,
|
|
|
|
|
SELECT_ADVANCE | SELECT_FIND)) {
|
|
|
|
|
message *msg = msg_message("rust_effect_0", "mage", fi->unit);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
message_all(b, msg);
|
|
|
|
|
msg_release(msg);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
fgs = fighters(b, fi->side, FIGHT_ROW, BEHIND_ROW - 1, FS_ENEMY);
|
2011-02-27 21:04:29 +01:00
|
|
|
|
scramble_fighters(fgs);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
for (qi = 0, ql = fgs; ql; ql_advance(&ql, &qi, 1)) {
|
|
|
|
|
fighter *df = (fighter *) ql_get(ql, qi);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
if (df->alive == 0)
|
|
|
|
|
continue;
|
|
|
|
|
if (force <= 0)
|
|
|
|
|
break;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
2014-03-16 05:03:17 +01:00
|
|
|
|
/* da n _min(force, x), sollte force maximal auf 0 sinken */
|
2010-08-08 09:40:42 +02:00
|
|
|
|
assert(force >= 0);
|
|
|
|
|
|
|
|
|
|
if (df->weapons) {
|
|
|
|
|
int w;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
for (w = 0; df->weapons[w].type != NULL; ++w) {
|
|
|
|
|
weapon *wp = df->weapons;
|
2014-03-16 05:03:17 +01:00
|
|
|
|
int n = _min(force, wp->used);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
if (n) {
|
2011-03-07 08:03:10 +01:00
|
|
|
|
requirement *mat = wp->type->itype->construction->materials;
|
2012-07-09 02:51:48 +02:00
|
|
|
|
bool iron = false;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
while (mat && mat->number > 0) {
|
2014-06-22 16:55:14 +02:00
|
|
|
|
if (mat->rtype == get_resourcetype(R_IRON)) {
|
2010-08-08 09:40:42 +02:00
|
|
|
|
iron = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
mat++;
|
|
|
|
|
}
|
|
|
|
|
if (iron) {
|
|
|
|
|
int p;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
force -= n;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
wp->used -= n;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
k += n;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
i_change(&df->unit->items, wp->type->itype, -n);
|
2011-03-07 08:03:10 +01:00
|
|
|
|
for (p = 0; n && p != df->unit->number; ++p) {
|
|
|
|
|
if (df->person[p].missile == wp) {
|
2010-08-08 09:40:42 +02:00
|
|
|
|
df->person[p].missile = NULL;
|
|
|
|
|
--n;
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-03-07 08:03:10 +01:00
|
|
|
|
for (p = 0; n && p != df->unit->number; ++p) {
|
|
|
|
|
if (df->person[p].melee == wp) {
|
2010-08-08 09:40:42 +02:00
|
|
|
|
df->person[p].melee = NULL;
|
|
|
|
|
--n;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-02-27 21:04:29 +01:00
|
|
|
|
ql_free(fgs);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
|
|
|
|
if (k == 0) {
|
|
|
|
|
/* keine Waffen mehr da, die zerst<73>rt werden k<>nnten */
|
2011-03-07 08:03:10 +01:00
|
|
|
|
message *msg = msg_message("rust_effect_1", "mage", fi->unit);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
message_all(b, msg);
|
|
|
|
|
msg_release(msg);
|
2011-03-07 08:03:10 +01:00
|
|
|
|
fi->magic = 0; /* k<>mpft nichtmagisch weiter */
|
2010-08-08 09:40:42 +02:00
|
|
|
|
level = 0;
|
|
|
|
|
} else {
|
2011-03-07 08:03:10 +01:00
|
|
|
|
message *msg = msg_message("rust_effect_2", "mage", fi->unit);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
message_all(b, msg);
|
|
|
|
|
msg_release(msg);
|
|
|
|
|
}
|
|
|
|
|
return level;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-10 03:28:03 +02:00
|
|
|
|
int sp_sleep(struct castorder * co)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2012-05-10 03:28:03 +02:00
|
|
|
|
fighter * fi = co->magician.fig;
|
|
|
|
|
int level = co->level;
|
|
|
|
|
const spell * sp = co->sp;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
battle *b = fi->side->battle;
|
|
|
|
|
unit *mage = fi->unit;
|
|
|
|
|
unit *du;
|
|
|
|
|
troop dt;
|
|
|
|
|
int force, enemies;
|
|
|
|
|
int k = 0;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
message *m;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
/* Immer aus der ersten Reihe nehmen */
|
|
|
|
|
|
2012-05-10 03:34:48 +02:00
|
|
|
|
force = lovar(co->force * 25);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
enemies = count_enemies(b, fi, FIGHT_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) {
|
|
|
|
|
dt = select_enemy(fi, FIGHT_ROW, BEHIND_ROW, SELECT_ADVANCE);
|
|
|
|
|
assert(dt.fighter);
|
|
|
|
|
du = dt.fighter->unit;
|
|
|
|
|
if (!is_magic_resistant(mage, du, 0)) {
|
|
|
|
|
dt.fighter->person[dt.index].flags |= FL_SLEEPING;
|
|
|
|
|
++k;
|
|
|
|
|
--enemies;
|
|
|
|
|
}
|
|
|
|
|
--force;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m = msg_message("cast_sleep_effect", "mage spell amount", fi->unit, sp, k);
|
|
|
|
|
message_all(b, m);
|
|
|
|
|
msg_release(m);
|
|
|
|
|
return level;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-10 03:28:03 +02:00
|
|
|
|
int sp_speed(struct castorder * co)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2012-05-10 03:28:03 +02:00
|
|
|
|
fighter * fi = co->magician.fig;
|
|
|
|
|
double power = co->force;
|
|
|
|
|
const spell * sp = co->sp;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
battle *b = fi->side->battle;
|
|
|
|
|
int force;
|
|
|
|
|
int allies;
|
|
|
|
|
int targets = 0;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
message *m;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
|
|
|
|
force = lovar(power * power * 5);
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
allies =
|
|
|
|
|
count_allies(fi->side, FIGHT_ROW, BEHIND_ROW, SELECT_ADVANCE, ALLY_ANY);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
/* maximal 2*allies Versuche ein Opfer zu finden, ansonsten best<73>nde
|
|
|
|
|
* die Gefahr eine Endlosschleife*/
|
|
|
|
|
allies *= 2;
|
|
|
|
|
|
|
|
|
|
while (force && allies) {
|
|
|
|
|
troop dt = select_ally(fi, FIGHT_ROW, BEHIND_ROW, ALLY_ANY);
|
|
|
|
|
fighter *df = dt.fighter;
|
|
|
|
|
--allies;
|
|
|
|
|
|
|
|
|
|
if (df) {
|
|
|
|
|
if (df->person[dt.index].speed == 1) {
|
|
|
|
|
df->person[dt.index].speed++;
|
|
|
|
|
targets++;
|
|
|
|
|
--force;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
m =
|
|
|
|
|
msg_message("cast_speed_effect", "mage spell amount", fi->unit, sp,
|
|
|
|
|
targets);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
message_all(b, m);
|
|
|
|
|
msg_release(m);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-09 02:51:48 +02:00
|
|
|
|
static skill_t random_skill(unit * u, bool weighted)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
|
|
|
|
int n = 0;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
skill *sv;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
|
|
|
|
for (sv = u->skills; sv != u->skills + u->skill_size; ++sv) {
|
2011-03-07 08:03:10 +01:00
|
|
|
|
if (sv->level > 0) {
|
|
|
|
|
if (weighted)
|
|
|
|
|
n += sv->level;
|
|
|
|
|
else
|
|
|
|
|
++n;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (n == 0)
|
|
|
|
|
return NOSKILL;
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
n = rng_int() % n;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
|
|
|
|
for (sv = u->skills; sv != u->skills + u->skill_size; ++sv) {
|
2011-03-07 08:03:10 +01:00
|
|
|
|
if (sv->level > 0) {
|
2010-08-08 09:40:42 +02:00
|
|
|
|
if (weighted) {
|
2011-03-07 08:03:10 +01:00
|
|
|
|
if (n < (int)sv->level)
|
|
|
|
|
return sv->id;
|
|
|
|
|
n -= sv->level;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
} else {
|
2011-03-07 08:03:10 +01:00
|
|
|
|
if (n == 0)
|
|
|
|
|
return sv->id;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
--n;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
assert(0 == 1); /* Hier sollte er niemals ankommen. */
|
2010-08-08 09:40:42 +02:00
|
|
|
|
return NOSKILL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** The mind blast spell for regular folks.
|
|
|
|
|
* This spell temporarily reduces the skill of the victims
|
|
|
|
|
*/
|
2012-05-10 03:28:03 +02:00
|
|
|
|
int sp_mindblast_temp(struct castorder * co)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2012-05-10 03:28:03 +02:00
|
|
|
|
fighter * fi = co->magician.fig;
|
|
|
|
|
int level = co->level;
|
|
|
|
|
double power = co->force;
|
|
|
|
|
const spell * sp = co->sp;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
battle *b = fi->side->battle;
|
|
|
|
|
unit *mage = fi->unit;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
int k = 0, reset = 0, maxloss = (level + 2) / 3;
|
|
|
|
|
message *m;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
int force = lovar(power * 25);
|
|
|
|
|
int enemies = count_enemies(b, fi, FIGHT_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;
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
while (force > 0 && enemies > 0) {
|
2010-08-08 09:40:42 +02:00
|
|
|
|
unit *du;
|
|
|
|
|
troop dt = select_enemy(fi, FIGHT_ROW, BEHIND_ROW, SELECT_ADVANCE);
|
|
|
|
|
|
|
|
|
|
assert(dt.fighter);
|
|
|
|
|
du = dt.fighter->unit;
|
|
|
|
|
if (fval(du, UFL_MARK)) {
|
|
|
|
|
/* not this one again */
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-02 03:50:24 +02:00
|
|
|
|
if (humanoidrace(u_race(du)) && force >= du->number) {
|
2010-08-08 09:40:42 +02:00
|
|
|
|
if (!is_magic_resistant(mage, du, 0)) {
|
|
|
|
|
skill_t sk = random_skill(du, true);
|
|
|
|
|
if (sk != NOSKILL) {
|
|
|
|
|
int n = 1 + rng_int() % maxloss;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
attrib *a = make_skillmod(sk, SMF_ALWAYS, NULL, 0.0, n);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
/* neat: you can add a whole lot of these to a unit, they stack */
|
|
|
|
|
a_add(&du->attribs, a);
|
|
|
|
|
}
|
|
|
|
|
k += du->number;
|
|
|
|
|
}
|
|
|
|
|
force -= du->number;
|
|
|
|
|
}
|
|
|
|
|
fset(du, UFL_MARK);
|
|
|
|
|
reset = 1;
|
|
|
|
|
enemies -= du->number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (reset) {
|
2011-03-07 08:03:10 +01:00
|
|
|
|
unit *u;
|
|
|
|
|
for (u = b->region->units; u; u = u->next) {
|
2010-08-08 09:40:42 +02:00
|
|
|
|
freset(u, UFL_MARK);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m = msg_message("sp_mindblast_temp_effect", "mage spell amount", mage, sp, k);
|
|
|
|
|
message_all(b, m);
|
|
|
|
|
msg_release(m);
|
|
|
|
|
return level;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** A mind blast spell for monsters.
|
|
|
|
|
* This spell PERMANENTLY reduces the skill of the victims or kills them
|
|
|
|
|
* when they have no skills left. Not currently in use.
|
|
|
|
|
*/
|
2012-05-10 03:28:03 +02:00
|
|
|
|
int sp_mindblast(struct castorder * co)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2012-05-10 03:28:03 +02:00
|
|
|
|
fighter * fi = co->magician.fig;
|
|
|
|
|
int level = co->level;
|
|
|
|
|
double power = co->force;
|
|
|
|
|
const spell * sp = co->sp;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
battle *b = fi->side->battle;
|
|
|
|
|
unit *mage = fi->unit;
|
|
|
|
|
int killed = 0, k = 0, reset = 0;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
message *m;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
int force = lovar(power * 25);
|
|
|
|
|
int enemies = count_enemies(b, fi, FIGHT_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;
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
while (enemies > 0 && force > 0) {
|
2010-08-08 09:40:42 +02:00
|
|
|
|
unit *du;
|
|
|
|
|
troop dt = select_enemy(fi, FIGHT_ROW, BEHIND_ROW, SELECT_ADVANCE);
|
|
|
|
|
|
|
|
|
|
assert(dt.fighter);
|
|
|
|
|
du = dt.fighter->unit;
|
|
|
|
|
if (fval(du, UFL_MARK)) {
|
|
|
|
|
/* not this one again */
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-02 03:50:24 +02:00
|
|
|
|
if (humanoidrace(u_race(du)) && force >= du->number) {
|
2010-08-08 09:40:42 +02:00
|
|
|
|
if (!is_magic_resistant(mage, du, 0)) {
|
|
|
|
|
skill_t sk = random_skill(du, false);
|
|
|
|
|
if (sk != NOSKILL) {
|
2014-06-21 08:59:04 +02:00
|
|
|
|
skill *sv = unit_skill(du, sk);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
int n = 1 + rng_int() % 3;
|
|
|
|
|
|
|
|
|
|
reduce_skill(du, sv, n);
|
2011-03-07 08:03:10 +01:00
|
|
|
|
k += du->number;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
} else {
|
|
|
|
|
/* unit has no skill. kill it. */
|
|
|
|
|
kill_troop(dt);
|
|
|
|
|
++killed;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
force -= du->number;
|
|
|
|
|
} else {
|
|
|
|
|
/* only works against humanoids, don't try others. but do remove them
|
|
|
|
|
* from 'force' once or we may never terminate. */
|
|
|
|
|
fset(du, UFL_MARK);
|
|
|
|
|
reset = 1;
|
|
|
|
|
}
|
|
|
|
|
enemies -= du->number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (reset) {
|
2011-03-07 08:03:10 +01:00
|
|
|
|
unit *u;
|
|
|
|
|
for (u = b->region->units; u; u = u->next) {
|
2010-08-08 09:40:42 +02:00
|
|
|
|
freset(u, UFL_MARK);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
m =
|
|
|
|
|
msg_message("sp_mindblast_effect", "mage spell amount dead", mage, sp, k,
|
|
|
|
|
killed);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
message_all(b, m);
|
|
|
|
|
msg_release(m);
|
|
|
|
|
return level;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-10 03:28:03 +02:00
|
|
|
|
int sp_dragonodem(struct castorder * co)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2012-05-10 03:28:03 +02:00
|
|
|
|
fighter * fi = co->magician.fig;
|
|
|
|
|
int level = co->level;
|
|
|
|
|
double power = co->force;
|
|
|
|
|
const spell * sp = co->sp;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
battle *b = fi->side->battle;
|
|
|
|
|
troop dt;
|
|
|
|
|
troop at;
|
|
|
|
|
int force, enemies;
|
|
|
|
|
int killed = 0;
|
|
|
|
|
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));
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
enemies = count_enemies(b, fi, FIGHT_ROW, BEHIND_ROW - 1, SELECT_ADVANCE);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
|
|
|
|
if (!enemies) {
|
2011-03-07 08:03:10 +01:00
|
|
|
|
struct message *m =
|
|
|
|
|
msg_message("battle::out_of_range", "mage spell", fi->unit, sp);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
message_all(b, m);
|
|
|
|
|
msg_release(m);
|
|
|
|
|
return 0;
|
|
|
|
|
} else {
|
2011-03-07 08:03:10 +01:00
|
|
|
|
struct message *m;
|
|
|
|
|
|
2010-08-08 09:40:42 +02:00
|
|
|
|
at.fighter = fi;
|
|
|
|
|
at.index = 0;
|
|
|
|
|
|
|
|
|
|
while (force && killed < enemies) {
|
2011-03-07 08:03:10 +01:00
|
|
|
|
dt = select_enemy(fi, FIGHT_ROW, BEHIND_ROW - 1, SELECT_ADVANCE);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
assert(dt.fighter);
|
|
|
|
|
--force;
|
|
|
|
|
killed += terminate(dt, at, AT_COMBATSPELL, damage, false);
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
m =
|
|
|
|
|
msg_message("battle::combatspell", "mage spell dead", fi->unit, sp,
|
|
|
|
|
killed);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
message_all(b, m);
|
|
|
|
|
msg_release(m);
|
|
|
|
|
}
|
|
|
|
|
return level;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Feuersturm: Betrifft sehr viele Gegner (in der Regel alle),
|
|
|
|
|
* macht nur vergleichsweise geringen Schaden */
|
2012-05-10 03:28:03 +02:00
|
|
|
|
int sp_immolation(struct castorder * co)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2012-05-10 03:28:03 +02:00
|
|
|
|
fighter * fi = co->magician.fig;
|
|
|
|
|
int level = co->level;
|
|
|
|
|
const spell * sp = co->sp;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
battle *b = fi->side->battle;
|
|
|
|
|
troop at;
|
2011-02-27 21:04:29 +01:00
|
|
|
|
int force, qi, killed = 0;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
const char *damage;
|
2011-02-27 21:04:29 +01:00
|
|
|
|
quicklist *fgs, *ql;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
message *m;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
|
|
|
|
/* 2d4 HP */
|
|
|
|
|
damage = spell_damage(5);
|
|
|
|
|
/* Betrifft alle Gegner */
|
|
|
|
|
force = 99999;
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
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);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
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);
|
2011-03-07 08:03:10 +01:00
|
|
|
|
for (qi = 0, ql = fgs; ql; ql_advance(&ql, &qi, 1)) {
|
|
|
|
|
fighter *df = (fighter *) ql_get(ql, qi);
|
|
|
|
|
int n = df->alive - df->removed;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
troop dt;
|
|
|
|
|
|
|
|
|
|
dt.fighter = df;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
while (n != 0) {
|
2010-08-08 09:40:42 +02:00
|
|
|
|
dt.index = --n;
|
|
|
|
|
killed += terminate(dt, at, AT_COMBATSPELL, damage, false);
|
2011-03-07 08:03:10 +01:00
|
|
|
|
if (--force == 0)
|
|
|
|
|
break;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
}
|
2011-03-07 08:03:10 +01:00
|
|
|
|
if (force == 0)
|
|
|
|
|
break;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
}
|
2011-02-27 21:04:29 +01:00
|
|
|
|
ql_free(fgs);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
m =
|
|
|
|
|
msg_message("battle::combatspell", "mage spell killed", fi->unit, sp,
|
|
|
|
|
killed);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
message_all(b, m);
|
|
|
|
|
msg_release(m);
|
|
|
|
|
return level;
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
int sp_drainodem(fighter * fi, int level, double power, spell * sp)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
|
|
|
|
battle *b = fi->side->battle;
|
|
|
|
|
troop dt;
|
|
|
|
|
troop at;
|
|
|
|
|
int force, enemies;
|
|
|
|
|
int drained = 0;
|
|
|
|
|
int killed = 0;
|
|
|
|
|
const char *damage;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
message *m;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
|
|
|
|
/* 11-26 HP */
|
|
|
|
|
damage = spell_damage(4);
|
|
|
|
|
/* Jungdrache 3->54, Drache 6->216, Wyrm 12->864 Treffer */
|
|
|
|
|
force = lovar(get_force(power, 6));
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
enemies = count_enemies(b, fi, FIGHT_ROW, BEHIND_ROW - 1, SELECT_ADVANCE);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
|
|
|
|
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) {
|
2011-03-07 08:03:10 +01:00
|
|
|
|
dt = select_enemy(fi, FIGHT_ROW, BEHIND_ROW - 1, SELECT_ADVANCE);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
assert(dt.fighter);
|
|
|
|
|
if (hits(at, dt, NULL)) {
|
|
|
|
|
drain_exp(dt.fighter->unit, 90);
|
|
|
|
|
++drained;
|
|
|
|
|
killed += terminate(dt, at, AT_COMBATSPELL, damage, false);
|
|
|
|
|
}
|
|
|
|
|
--force;
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
m =
|
|
|
|
|
msg_message("cast_drainlife_effect", "mage spell amount", fi->unit, sp,
|
|
|
|
|
drained);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
message_all(b, m);
|
|
|
|
|
msg_release(m);
|
|
|
|
|
return level;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------- */
|
|
|
|
|
/* PRECOMBAT */
|
|
|
|
|
|
2012-05-10 03:28:03 +02:00
|
|
|
|
int sp_shadowcall(struct castorder * co)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2012-05-10 03:28:03 +02:00
|
|
|
|
fighter * fi = co->magician.fig;
|
|
|
|
|
int level = co->level;
|
|
|
|
|
double power = co->force;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
battle *b = fi->side->battle;
|
|
|
|
|
region *r = b->region;
|
|
|
|
|
unit *mage = fi->unit;
|
|
|
|
|
attrib *a;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
int force = (int)(get_force(power, 3) / 2);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
unit *u;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
const char *races[3] = { "shadowbat", "nightmare", "vampunicorn" };
|
|
|
|
|
const race *rc = rc_find(races[rng_int() % 3]);
|
|
|
|
|
message *msg;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
|
|
|
|
u = create_unit(r, mage->faction, force, rc, 0, NULL, mage);
|
|
|
|
|
setstatus(u, ST_FIGHT);
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
set_level(u, SK_WEAPONLESS, (int)(power / 2));
|
|
|
|
|
set_level(u, SK_STAMINA, (int)(power / 2));
|
2010-08-08 09:40:42 +02:00
|
|
|
|
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));
|
2011-03-07 08:03:10 +01:00
|
|
|
|
msg =
|
|
|
|
|
msg_message("sp_shadowcall_effect", "mage amount race", mage, u->number,
|
2013-05-02 03:50:24 +02:00
|
|
|
|
u_race(u));
|
2010-08-08 09:40:42 +02:00
|
|
|
|
message_all(b, msg);
|
|
|
|
|
msg_release(msg);
|
|
|
|
|
return level;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-10 03:28:03 +02:00
|
|
|
|
int sp_wolfhowl(struct castorder * co)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2012-05-10 03:28:03 +02:00
|
|
|
|
fighter * fi = co->magician.fig;
|
|
|
|
|
int level = co->level;
|
|
|
|
|
double power = co->force;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
battle *b = fi->side->battle;
|
|
|
|
|
region *r = b->region;
|
|
|
|
|
unit *mage = fi->unit;
|
|
|
|
|
attrib *a;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
message *msg;
|
|
|
|
|
int force = (int)(get_force(power, 3) / 2);
|
2014-06-30 03:10:02 +02:00
|
|
|
|
const race * rc = get_race(RC_WOLF);
|
2012-04-16 06:58:03 +02:00
|
|
|
|
if (force>0) {
|
|
|
|
|
unit *u =
|
|
|
|
|
create_unit(r, mage->faction, force, rc, 0, NULL, mage);
|
|
|
|
|
leave(u, true);
|
|
|
|
|
setstatus(u, ST_FIGHT);
|
|
|
|
|
|
|
|
|
|
set_level(u, SK_WEAPONLESS, (int)(power / 3));
|
|
|
|
|
set_level(u, SK_STAMINA, (int)(power / 3));
|
|
|
|
|
u->hp = u->number * unit_max_hp(u);
|
|
|
|
|
|
|
|
|
|
if (fval(mage, UFL_ANON_FACTION)) {
|
|
|
|
|
fset(u, UFL_ANON_FACTION);
|
|
|
|
|
}
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
2012-04-16 06:58:03 +02:00
|
|
|
|
a = a_new(&at_unitdissolve);
|
|
|
|
|
a->data.ca[0] = 0;
|
|
|
|
|
a->data.ca[1] = 100;
|
|
|
|
|
a_add(&u->attribs, a);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
2012-04-16 06:58:03 +02:00
|
|
|
|
make_fighter(b, u, fi->side, is_attacker(fi));
|
2010-08-08 09:40:42 +02:00
|
|
|
|
}
|
2011-03-07 08:03:10 +01:00
|
|
|
|
msg =
|
2012-04-16 06:58:03 +02:00
|
|
|
|
msg_message("sp_wolfhowl_effect", "mage amount race", mage, force, rc);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
message_all(b, msg);
|
|
|
|
|
msg_release(msg);
|
|
|
|
|
|
|
|
|
|
return level;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-10 03:28:03 +02:00
|
|
|
|
int sp_shadowknights(struct castorder * co)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2012-05-10 03:28:03 +02:00
|
|
|
|
fighter * fi = co->magician.fig;
|
|
|
|
|
int level = co->level;
|
|
|
|
|
double power = co->force;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
unit *u;
|
|
|
|
|
battle *b = fi->side->battle;
|
|
|
|
|
region *r = b->region;
|
|
|
|
|
unit *mage = fi->unit;
|
|
|
|
|
attrib *a;
|
2014-03-16 05:03:17 +01:00
|
|
|
|
int force = _max(1, (int)get_force(power, 3));
|
2011-03-07 08:03:10 +01:00
|
|
|
|
message *msg;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
u =
|
2014-06-30 03:10:02 +02:00
|
|
|
|
create_unit(r, mage->faction, force, get_race(RC_SHADOWKNIGHT), 0, NULL,
|
2011-03-07 08:03:10 +01:00
|
|
|
|
mage);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
setstatus(u, ST_FIGHT);
|
|
|
|
|
|
|
|
|
|
u->hp = u->number * unit_max_hp(u);
|
|
|
|
|
|
|
|
|
|
if (fval(mage, UFL_ANON_FACTION)) {
|
|
|
|
|
fset(u, UFL_ANON_FACTION);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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_shadowknights_effect", "mage", mage);
|
|
|
|
|
message_all(b, msg);
|
|
|
|
|
msg_release(msg);
|
|
|
|
|
|
|
|
|
|
return level;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-10 03:28:03 +02:00
|
|
|
|
int sp_strong_wall(struct castorder * co)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2012-05-10 03:28:03 +02:00
|
|
|
|
fighter * fi = co->magician.fig;
|
|
|
|
|
int level = co->level;
|
2013-12-31 10:06:28 +01:00
|
|
|
|
float power = co->force;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
battle *b = fi->side->battle;
|
|
|
|
|
unit *mage = fi->unit;
|
|
|
|
|
building *burg;
|
2013-12-31 10:06:28 +01:00
|
|
|
|
float effect;
|
2012-07-09 02:51:48 +02:00
|
|
|
|
static bool init = false;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
message *msg;
|
|
|
|
|
static const curse_type *strongwall_ct;
|
|
|
|
|
if (!init) {
|
|
|
|
|
init = true;
|
|
|
|
|
strongwall_ct = ct_find("strongwall");
|
|
|
|
|
}
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
|
|
|
|
if (!mage->building) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
burg = mage->building;
|
|
|
|
|
|
2013-12-31 10:06:28 +01:00
|
|
|
|
effect = power / 4;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
create_curse(mage, &burg->attribs, strongwall_ct, power, 1, effect, 0);
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
msg =
|
|
|
|
|
msg_message("sp_strongwalls_effect", "mage building", mage, mage->building);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
message_all(b, msg);
|
|
|
|
|
msg_release(msg);
|
|
|
|
|
|
|
|
|
|
return level;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Spells: chaosrow / song of confusion.
|
|
|
|
|
* German Title: 'Gesang der Verwirrung'
|
|
|
|
|
*/
|
2012-05-10 03:28:03 +02:00
|
|
|
|
int sp_chaosrow(struct castorder * co)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2012-05-10 03:28:03 +02:00
|
|
|
|
fighter * fi = co->magician.fig;
|
|
|
|
|
int level = co->level;
|
|
|
|
|
double power = co->force;
|
|
|
|
|
const spell * sp = co->sp;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
battle *b = fi->side->battle;
|
|
|
|
|
unit *mage = fi->unit;
|
2011-02-27 21:04:29 +01:00
|
|
|
|
quicklist *fgs, *ql;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
message *m;
|
|
|
|
|
const char *mtype;
|
2011-02-27 21:04:29 +01:00
|
|
|
|
int qi, k = 0;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
if (!count_enemies(b, fi, FIGHT_ROW, NUMROWS, SELECT_ADVANCE | SELECT_FIND)) {
|
2010-08-08 09:40:42 +02:00
|
|
|
|
m = msg_message("battle::out_of_range", "mage spell", fi->unit, sp);
|
|
|
|
|
message_all(b, m);
|
|
|
|
|
msg_release(m);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
if (sp->id == SPL_CHAOSROW)
|
|
|
|
|
power *= 40;
|
|
|
|
|
else
|
|
|
|
|
power = get_force(power, 5);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
|
|
|
|
fgs = fighters(b, fi->side, FIGHT_ROW, NUMROWS, FS_ENEMY);
|
2011-02-27 21:04:29 +01:00
|
|
|
|
scramble_fighters(fgs);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
for (qi = 0, ql = fgs; ql; ql_advance(&ql, &qi, 1)) {
|
|
|
|
|
fighter *df = (fighter *) ql_get(ql, qi);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
int n = df->unit->number;
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
if (df->alive == 0)
|
|
|
|
|
continue;
|
|
|
|
|
if (power <= 0.0)
|
|
|
|
|
break;
|
2014-03-16 05:03:17 +01:00
|
|
|
|
/* force sollte wegen des _max(0,x) nicht unter 0 fallen k<>nnen */
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
if (is_magic_resistant(mage, df->unit, 0))
|
|
|
|
|
continue;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
if (chance(power / n)) {
|
2010-08-08 09:40:42 +02:00
|
|
|
|
int row = statusrow(df->status);
|
|
|
|
|
df->side->size[row] -= df->alive;
|
2013-05-02 03:50:24 +02:00
|
|
|
|
if (u_race(df->unit)->battle_flags & BF_NOBLOCK) {
|
2010-08-08 09:40:42 +02:00
|
|
|
|
df->side->nonblockers[row] -= df->alive;
|
|
|
|
|
}
|
2011-03-07 08:03:10 +01:00
|
|
|
|
row = FIRST_ROW + (rng_int() % (LAST_ROW - FIRST_ROW));
|
2010-08-08 09:40:42 +02:00
|
|
|
|
switch (row) {
|
|
|
|
|
case FIGHT_ROW:
|
|
|
|
|
df->status = ST_FIGHT;
|
|
|
|
|
break;
|
|
|
|
|
case BEHIND_ROW:
|
|
|
|
|
df->status = ST_CHICKEN;
|
|
|
|
|
break;
|
|
|
|
|
case AVOID_ROW:
|
|
|
|
|
df->status = ST_AVOID;
|
|
|
|
|
break;
|
|
|
|
|
case FLEE_ROW:
|
|
|
|
|
df->status = ST_FLEE;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
assert(!"unknown combatrow");
|
|
|
|
|
}
|
2011-03-07 08:03:10 +01:00
|
|
|
|
assert(statusrow(df->status) == row);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
df->side->size[row] += df->alive;
|
2013-05-02 03:50:24 +02:00
|
|
|
|
if (u_race(df->unit)->battle_flags & BF_NOBLOCK) {
|
2010-08-08 09:40:42 +02:00
|
|
|
|
df->side->nonblockers[row] += df->alive;
|
|
|
|
|
}
|
2011-03-07 08:03:10 +01:00
|
|
|
|
k += df->alive;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
}
|
2014-03-16 05:03:17 +01:00
|
|
|
|
power = _max(0, power - n);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
}
|
2011-02-27 21:04:29 +01:00
|
|
|
|
ql_free(fgs);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
if (sp->id == SPL_CHAOSROW) {
|
|
|
|
|
mtype = (k > 0) ? "sp_chaosrow_effect_1" : "sp_chaosrow_effect_0";
|
2010-08-08 09:40:42 +02:00
|
|
|
|
} else {
|
2011-03-07 08:03:10 +01:00
|
|
|
|
mtype = (k > 0) ? "sp_confusion_effect_1" : "sp_confusion_effect_0";
|
2010-08-08 09:40:42 +02:00
|
|
|
|
}
|
|
|
|
|
m = msg_message(mtype, "mage", mage);
|
|
|
|
|
message_all(b, m);
|
|
|
|
|
msg_release(m);
|
|
|
|
|
return level;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Gesang der Furcht (Kampfzauber) */
|
|
|
|
|
/* Panik (Pr<50>kampfzauber) */
|
|
|
|
|
|
2012-05-10 03:28:03 +02:00
|
|
|
|
int sp_flee(struct castorder * co)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2012-05-10 03:28:03 +02:00
|
|
|
|
fighter * fi = co->magician.fig;
|
|
|
|
|
int level = co->level;
|
|
|
|
|
double power = co->force;
|
|
|
|
|
const spell * sp = co->sp;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
battle *b = fi->side->battle;
|
|
|
|
|
unit *mage = fi->unit;
|
2011-02-27 21:04:29 +01:00
|
|
|
|
quicklist *fgs, *ql;
|
|
|
|
|
int force, n, qi;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
int panik = 0;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
message *msg;
|
|
|
|
|
|
|
|
|
|
switch (sp->id) {
|
2010-08-08 09:40:42 +02:00
|
|
|
|
case SPL_FLEE:
|
2011-03-07 08:03:10 +01:00
|
|
|
|
force = (int)get_force(power, 4);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
break;
|
|
|
|
|
case SPL_SONG_OF_FEAR:
|
2011-03-07 08:03:10 +01:00
|
|
|
|
force = (int)get_force(power, 3);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
break;
|
|
|
|
|
case SPL_AURA_OF_FEAR:
|
2011-03-07 08:03:10 +01:00
|
|
|
|
force = (int)get_force(power, 5);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2011-03-07 08:03:10 +01:00
|
|
|
|
force = (int)get_force(power, 10);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
if (!count_enemies(b, fi, FIGHT_ROW, AVOID_ROW, SELECT_ADVANCE | SELECT_FIND)) {
|
2010-08-08 09:40:42 +02:00
|
|
|
|
msg = msg_message("sp_flee_effect_0", "mage spell", mage, sp);
|
|
|
|
|
message_all(b, msg);
|
|
|
|
|
msg_release(msg);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fgs = fighters(b, fi->side, FIGHT_ROW, AVOID_ROW, FS_ENEMY);
|
2011-02-27 21:04:29 +01:00
|
|
|
|
scramble_fighters(fgs);
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
for (qi = 0, ql = fgs; ql; ql_advance(&ql, &qi, 1)) {
|
|
|
|
|
fighter *df = (fighter *) ql_get(ql, qi);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
for (n = 0; n != df->alive; ++n) {
|
2010-08-08 09:40:42 +02:00
|
|
|
|
if (force < 0)
|
|
|
|
|
break;
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
if (df->person[n].flags & FL_PANICED) { /* bei SPL_SONG_OF_FEAR m<>glich */
|
2010-08-08 09:40:42 +02:00
|
|
|
|
df->person[n].attack -= 1;
|
|
|
|
|
--force;
|
|
|
|
|
++panik;
|
|
|
|
|
} else if (!(df->person[n].flags & FL_COURAGE)
|
2013-05-02 03:50:24 +02:00
|
|
|
|
|| !fval(u_race(df->unit), RCF_UNDEAD)) {
|
2012-05-24 07:23:32 +02:00
|
|
|
|
if (!is_magic_resistant(mage, df->unit, 0)) {
|
2010-08-08 09:40:42 +02:00
|
|
|
|
df->person[n].flags |= FL_PANICED;
|
|
|
|
|
++panik;
|
|
|
|
|
}
|
|
|
|
|
--force;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-02-27 21:04:29 +01:00
|
|
|
|
ql_free(fgs);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
|
|
|
|
msg = msg_message("sp_flee_effect_1", "mage spell amount", mage, sp, panik);
|
|
|
|
|
message_all(b, msg);
|
|
|
|
|
msg_release(msg);
|
|
|
|
|
|
|
|
|
|
return level;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Heldenmut */
|
2012-05-10 03:28:03 +02:00
|
|
|
|
int sp_hero(struct castorder * co)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2012-05-10 03:28:03 +02:00
|
|
|
|
fighter * fi = co->magician.fig;
|
|
|
|
|
int level = co->level;
|
|
|
|
|
double power = co->force;
|
|
|
|
|
const spell * sp = co->sp;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
battle *b = fi->side->battle;
|
|
|
|
|
int df_bonus = 0;
|
|
|
|
|
int force = 0;
|
|
|
|
|
int allies;
|
|
|
|
|
int targets = 0;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
message *m;
|
|
|
|
|
|
|
|
|
|
switch (sp->id) {
|
2010-08-08 09:40:42 +02:00
|
|
|
|
case SPL_HERO:
|
2011-03-07 08:03:10 +01:00
|
|
|
|
df_bonus = (int)(power / 5);
|
2014-03-16 05:03:17 +01:00
|
|
|
|
force = _max(1, lovar(get_force(power, 4)));
|
2010-08-08 09:40:42 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
df_bonus = 1;
|
2014-03-16 05:03:17 +01:00
|
|
|
|
force = _max(1, (int)power);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
allies =
|
|
|
|
|
count_allies(fi->side, FIGHT_ROW, BEHIND_ROW, SELECT_ADVANCE, ALLY_ANY);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
/* maximal 2*allies Versuche ein Opfer zu finden, ansonsten best<73>nde
|
|
|
|
|
* die Gefahr eine Endlosschleife*/
|
|
|
|
|
allies *= 2;
|
|
|
|
|
|
|
|
|
|
while (force && allies) {
|
|
|
|
|
troop dt = select_ally(fi, FIGHT_ROW, BEHIND_ROW, ALLY_ANY);
|
|
|
|
|
fighter *df = dt.fighter;
|
|
|
|
|
--allies;
|
|
|
|
|
|
|
|
|
|
if (df) {
|
|
|
|
|
if (!(df->person[dt.index].flags & FL_COURAGE)) {
|
|
|
|
|
df->person[dt.index].defence += df_bonus;
|
|
|
|
|
df->person[dt.index].flags = df->person[dt.index].flags | FL_COURAGE;
|
|
|
|
|
targets++;
|
|
|
|
|
--force;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
m =
|
|
|
|
|
msg_message("cast_hero_effect", "mage spell amount", fi->unit, sp, targets);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
message_all(b, m);
|
|
|
|
|
msg_release(m);
|
|
|
|
|
|
|
|
|
|
return level;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-10 03:28:03 +02:00
|
|
|
|
int sp_berserk(struct castorder * co)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2012-05-10 03:28:03 +02:00
|
|
|
|
fighter * fi = co->magician.fig;
|
|
|
|
|
int level = co->level;
|
|
|
|
|
double power = co->force;
|
|
|
|
|
const spell * sp = co->sp;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
battle *b = fi->side->battle;
|
|
|
|
|
int at_bonus = 0;
|
|
|
|
|
int df_malus = 0;
|
|
|
|
|
int force = 0;
|
|
|
|
|
int allies = 0;
|
|
|
|
|
int targets = 0;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
message *m;
|
|
|
|
|
|
|
|
|
|
switch (sp->id) {
|
2010-08-08 09:40:42 +02:00
|
|
|
|
case SPL_BERSERK:
|
|
|
|
|
case SPL_BLOODTHIRST:
|
2014-03-16 05:03:17 +01:00
|
|
|
|
at_bonus = _max(1, level / 3);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
df_malus = 2;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
force = (int)get_force(power, 2);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
at_bonus = 1;
|
|
|
|
|
df_malus = 0;
|
|
|
|
|
force = (int)power;
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
allies =
|
|
|
|
|
count_allies(fi->side, FIGHT_ROW, BEHIND_ROW - 1, SELECT_ADVANCE, ALLY_ANY);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
/* maximal 2*allies Versuche ein Opfer zu finden, ansonsten best<73>nde
|
|
|
|
|
* die Gefahr eine Endlosschleife*/
|
|
|
|
|
allies *= 2;
|
|
|
|
|
|
|
|
|
|
while (force && allies) {
|
2011-03-07 08:03:10 +01:00
|
|
|
|
troop dt = select_ally(fi, FIGHT_ROW, BEHIND_ROW - 1, ALLY_ANY);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
m =
|
|
|
|
|
msg_message("cast_berserk_effect", "mage spell amount", fi->unit, sp,
|
|
|
|
|
targets);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
message_all(b, m);
|
|
|
|
|
msg_release(m);
|
|
|
|
|
return level;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-10 03:28:03 +02:00
|
|
|
|
int sp_frighten(struct castorder * co)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2012-05-10 03:28:03 +02:00
|
|
|
|
fighter * fi = co->magician.fig;
|
|
|
|
|
int level = co->level;
|
|
|
|
|
double power = co->force;
|
|
|
|
|
const spell * sp = co->sp;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
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;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
message *m;
|
|
|
|
|
|
2014-03-16 05:03:17 +01:00
|
|
|
|
at_malus = _max(1, level - 4);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
df_malus = 2;
|
|
|
|
|
force = (int)get_force(power, 2);
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
enemies = count_enemies(b, fi, FIGHT_ROW, BEHIND_ROW - 1, SELECT_ADVANCE);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
if (!enemies) {
|
2011-03-07 08:03:10 +01:00
|
|
|
|
message *m =
|
|
|
|
|
msg_message("battle::out_of_range", "mage spell", fi->unit, sp);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
message_all(b, m);
|
|
|
|
|
msg_release(m);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (force && enemies) {
|
2011-03-07 08:03:10 +01:00
|
|
|
|
troop dt = select_enemy(fi, FIGHT_ROW, BEHIND_ROW - 1, SELECT_ADVANCE);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
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);
|
|
|
|
|
}
|
2012-05-24 07:23:32 +02:00
|
|
|
|
if (!is_magic_resistant(mage, df->unit, 0)) {
|
2010-08-08 09:40:42 +02:00
|
|
|
|
df->person[dt.index].attack -= at_malus;
|
|
|
|
|
df->person[dt.index].defence -= df_malus;
|
|
|
|
|
targets++;
|
|
|
|
|
}
|
|
|
|
|
--force;
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
m =
|
|
|
|
|
msg_message("cast_frighten_effect", "mage spell amount", fi->unit, sp,
|
|
|
|
|
targets);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
message_all(b, m);
|
|
|
|
|
msg_release(m);
|
|
|
|
|
return level;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-10 03:28:03 +02:00
|
|
|
|
int sp_tiredsoldiers(struct castorder * co)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2012-05-10 03:28:03 +02:00
|
|
|
|
fighter * fi = co->magician.fig;
|
|
|
|
|
int level = co->level;
|
|
|
|
|
double power = co->force;
|
|
|
|
|
const spell * sp = co->sp;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
battle *b = fi->side->battle;
|
|
|
|
|
unit *mage = fi->unit;
|
|
|
|
|
int n = 0;
|
|
|
|
|
int force = (int)(power * power * 4);
|
2011-03-07 08:03:10 +01:00
|
|
|
|
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);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
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)) {
|
2012-05-24 07:23:32 +02:00
|
|
|
|
if (!is_magic_resistant(mage, df->unit, 0)) {
|
2010-08-08 09:40:42 +02:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-10 03:28:03 +02:00
|
|
|
|
int sp_windshield(struct castorder * co)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2012-05-10 03:28:03 +02:00
|
|
|
|
fighter * fi = co->magician.fig;
|
|
|
|
|
int level = co->level;
|
|
|
|
|
double power = co->force;
|
|
|
|
|
const spell * sp = co->sp;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
battle *b = fi->side->battle;
|
|
|
|
|
int force, at_malus;
|
|
|
|
|
int enemies;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
message *m;
|
|
|
|
|
|
|
|
|
|
switch (sp->id) {
|
2010-08-08 09:40:42 +02:00
|
|
|
|
case SPL_WINDSHIELD:
|
2011-03-07 08:03:10 +01:00
|
|
|
|
force = (int)get_force(power, 4);
|
|
|
|
|
at_malus = level / 4;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-10 03:28:03 +02:00
|
|
|
|
int sp_reeling_arrows(struct castorder * co)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2012-05-10 03:28:03 +02:00
|
|
|
|
fighter * fi = co->magician.fig;
|
|
|
|
|
int level = co->level;
|
|
|
|
|
const spell * sp = co->sp;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
battle *b = fi->side->battle;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
message *m;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
|
|
|
|
b->reelarrow = true;
|
|
|
|
|
m = msg_message("cast_spell_effect", "mage spell", fi->unit, sp);
|
|
|
|
|
message_all(b, m);
|
|
|
|
|
msg_release(m);
|
|
|
|
|
return level;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Magier weicht dem Kampf aus. Wenn er sich bewegen kann, zieht er in
|
|
|
|
|
* eine Nachbarregion, wobei ein NACH ber<EFBFBD>cksichtigt wird. Ansonsten
|
|
|
|
|
* bleibt er stehen und nimmt nicht weiter am Kampf teil. */
|
2012-05-10 03:28:03 +02:00
|
|
|
|
int sp_denyattack(struct castorder * co)
|
|
|
|
|
{
|
|
|
|
|
fighter * fi = co->magician.fig;
|
|
|
|
|
int level = co->level;
|
2012-05-10 03:34:48 +02:00
|
|
|
|
|
2012-05-10 03:28:03 +02:00
|
|
|
|
const spell * sp = co->sp;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
battle *b = fi->side->battle;
|
|
|
|
|
unit *mage = fi->unit;
|
|
|
|
|
region *r = b->region;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
message *m;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
|
|
|
|
/* Fliehende Einheiten verlassen auf jeden Fall Geb<65>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;
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
static void do_meffect(fighter * af, int typ, int effect, int duration)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
|
|
|
|
battle *b = af->side->battle;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
meffect *me = (meffect *) malloc(sizeof(struct meffect));
|
2011-02-28 05:53:19 +01:00
|
|
|
|
ql_push(&b->meffects, me);
|
|
|
|
|
me->magician = af;
|
|
|
|
|
me->typ = typ;
|
|
|
|
|
me->effect = effect;
|
|
|
|
|
me->duration = duration;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
2012-05-10 03:28:03 +02:00
|
|
|
|
int sp_armorshield(struct castorder * co)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2012-05-10 03:28:03 +02:00
|
|
|
|
fighter * fi = co->magician.fig;
|
|
|
|
|
int level = co->level;
|
|
|
|
|
double power = co->force;
|
|
|
|
|
const spell * sp = co->sp;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
int effect;
|
|
|
|
|
int duration;
|
|
|
|
|
battle *b = fi->side->battle;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
message *m = msg_message("cast_spell_effect", "mage spell", fi->unit, sp);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
|
|
|
|
message_all(b, m);
|
|
|
|
|
msg_release(m);
|
|
|
|
|
|
|
|
|
|
/* gibt R<>stung +effect f<>r duration Treffer */
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
switch (sp->id) {
|
2010-08-08 09:40:42 +02:00
|
|
|
|
case SPL_ARMORSHIELD:
|
2011-03-07 08:03:10 +01:00
|
|
|
|
effect = level / 3;
|
|
|
|
|
duration = (int)(20 * power * power);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
2011-03-07 08:03:10 +01:00
|
|
|
|
effect = level / 4;
|
|
|
|
|
duration = (int)(power * power);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
}
|
|
|
|
|
do_meffect(fi, SHIELD_ARMOR, effect, duration);
|
|
|
|
|
return level;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-10 03:28:03 +02:00
|
|
|
|
int sp_reduceshield(struct castorder * co)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2012-05-10 03:28:03 +02:00
|
|
|
|
fighter * fi = co->magician.fig;
|
|
|
|
|
int level = co->level;
|
|
|
|
|
double power = co->force;
|
|
|
|
|
const spell * sp = co->sp;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
int effect;
|
|
|
|
|
int duration;
|
|
|
|
|
battle *b = fi->side->battle;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
message *m = msg_message("cast_spell_effect", "mage spell", fi->unit, sp);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
message_all(b, m);
|
|
|
|
|
msg_release(m);
|
|
|
|
|
|
|
|
|
|
/* jeder Schaden wird um effect% reduziert bis der Schild duration
|
|
|
|
|
* Trefferpunkte aufgefangen hat */
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
switch (sp->id) {
|
2010-08-08 09:40:42 +02:00
|
|
|
|
case SPL_REDUCESHIELD:
|
|
|
|
|
effect = 50;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
duration = (int)(50 * power * power);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
2011-03-07 08:03:10 +01:00
|
|
|
|
effect = level * 3;
|
|
|
|
|
duration = (int)get_force(power, 5);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
}
|
|
|
|
|
do_meffect(fi, SHIELD_REDUCE, effect, duration);
|
|
|
|
|
return level;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-10 03:28:03 +02:00
|
|
|
|
int sp_fumbleshield(struct castorder * co)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2012-05-10 03:28:03 +02:00
|
|
|
|
fighter * fi = co->magician.fig;
|
|
|
|
|
int level = co->level;
|
|
|
|
|
const spell * sp = co->sp;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
int effect;
|
|
|
|
|
int duration;
|
|
|
|
|
battle *b = fi->side->battle;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
message *m = msg_message("cast_spell_effect", "mage spell", fi->unit, sp);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
|
|
|
|
message_all(b, m);
|
|
|
|
|
msg_release(m);
|
|
|
|
|
|
|
|
|
|
/* der erste Zauber schl<68>gt mit 100% fehl */
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
switch (sp->id) {
|
2010-08-08 09:40:42 +02:00
|
|
|
|
case SPL_DRAIG_FUMBLESHIELD:
|
|
|
|
|
case SPL_GWYRRD_FUMBLESHIELD:
|
|
|
|
|
case SPL_CERRDOR_FUMBLESHIELD:
|
|
|
|
|
case SPL_TYBIED_FUMBLESHIELD:
|
|
|
|
|
duration = 100;
|
2014-03-16 05:03:17 +01:00
|
|
|
|
effect = _max(1, 25 - level);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
duration = 100;
|
|
|
|
|
effect = 10;
|
|
|
|
|
}
|
|
|
|
|
do_meffect(fi, SHIELD_BLOCK, effect, duration);
|
|
|
|
|
return level;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------- */
|
|
|
|
|
/* POSTCOMBAT */
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
static int count_healable(battle * b, fighter * df)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
|
|
|
|
side *s;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
int healable = 0;
|
|
|
|
|
|
|
|
|
|
for (s = b->sides; s != b->sides + b->nsides; ++s) {
|
2010-08-08 09:40:42 +02:00
|
|
|
|
if (helping(df->side, s)) {
|
|
|
|
|
healable += s->casualties;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return healable;
|
|
|
|
|
}
|
2014-06-23 16:28:10 +02:00
|
|
|
|
static bool has_ao_healing(const unit *u) {
|
|
|
|
|
item *const* iter = i_findc(&u->items, it_find("ao_healing"));
|
|
|
|
|
return (*iter && (*iter)->number>0);
|
|
|
|
|
}
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
|
|
|
|
/* wiederbeleben */
|
2012-05-10 03:28:03 +02:00
|
|
|
|
int sp_reanimate(struct castorder * co)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2012-05-10 03:28:03 +02:00
|
|
|
|
fighter * fi = co->magician.fig;
|
|
|
|
|
int level = co->level;
|
|
|
|
|
double power = co->force;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
battle *b = fi->side->battle;
|
|
|
|
|
unit *mage = fi->unit;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
int healable, j = 0;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
double c = 0.50 + 0.02 * power;
|
|
|
|
|
double k = EFFECT_HEALING_SPELL * power;
|
2014-06-23 16:28:10 +02:00
|
|
|
|
bool use_item = has_ao_healing(mage);
|
2011-03-07 08:03:10 +01:00
|
|
|
|
message *msg;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
|
|
|
|
if (use_item) {
|
|
|
|
|
k *= 2;
|
|
|
|
|
c += 0.10;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
healable = count_healable(b, fi);
|
2014-03-16 05:03:17 +01:00
|
|
|
|
healable = (int)_min(k, healable);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
while (healable--) {
|
2011-03-07 08:03:10 +01:00
|
|
|
|
fighter *tf = select_corpse(b, fi);
|
|
|
|
|
if (tf != NULL && tf->side->casualties > 0
|
2014-06-30 03:10:02 +02:00
|
|
|
|
&& u_race(tf->unit) != get_race(RC_DAEMON)
|
2011-03-07 08:03:10 +01:00
|
|
|
|
&& (chance(c))) {
|
2010-08-08 09:40:42 +02:00
|
|
|
|
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;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
assert(tf->side->casualties >= 0);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
--tf->side->dead;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
assert(tf->side->dead >= 0);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
++j;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (j <= 0) {
|
|
|
|
|
level = j;
|
|
|
|
|
}
|
|
|
|
|
if (use_item) {
|
2011-03-07 08:03:10 +01:00
|
|
|
|
msg =
|
|
|
|
|
msg_message("reanimate_effect_1", "mage amount item", mage, j,
|
2014-06-22 16:55:14 +02:00
|
|
|
|
get_resourcetype(R_AMULET_OF_HEALING));
|
2010-08-08 09:40:42 +02:00
|
|
|
|
} else {
|
|
|
|
|
msg = msg_message("reanimate_effect_0", "mage amount", mage, j);
|
|
|
|
|
}
|
|
|
|
|
message_all(b, msg);
|
|
|
|
|
msg_release(msg);
|
|
|
|
|
|
|
|
|
|
return level;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-10 03:28:03 +02:00
|
|
|
|
int sp_keeploot(struct castorder * co)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2012-05-10 03:28:03 +02:00
|
|
|
|
fighter * fi = co->magician.fig;
|
|
|
|
|
int level = co->level;
|
|
|
|
|
double power = co->force;
|
|
|
|
|
const spell * sp = co->sp;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
battle *b = fi->side->battle;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
message *m = msg_message("cast_spell_effect", "mage spell", fi->unit, sp);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
|
|
|
|
message_all(b, m);
|
|
|
|
|
msg_release(m);
|
|
|
|
|
|
2014-03-16 05:03:17 +01:00
|
|
|
|
b->keeploot = (int)_max(25, b->keeploot + 5 * power);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
|
|
|
|
return level;
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-09 02:51:48 +02:00
|
|
|
|
static int heal_fighters(quicklist * fgs, int *power, bool heal_monsters)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2011-02-27 21:04:29 +01:00
|
|
|
|
int healhp = *power, healed = 0, qi;
|
|
|
|
|
quicklist *ql;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
for (qi = 0, ql = fgs; ql; ql_advance(&ql, &qi, 1)) {
|
|
|
|
|
fighter *df = (fighter *) ql_get(ql, qi);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
if (healhp <= 0)
|
|
|
|
|
break;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
|
|
|
|
/* Untote kann man nicht heilen */
|
2013-05-02 03:50:24 +02:00
|
|
|
|
if (df->unit->number == 0 || fval(u_race(df->unit), RCF_NOHEAL))
|
2011-03-07 08:03:10 +01:00
|
|
|
|
continue;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
|
|
|
|
/* wir heilen erstmal keine Monster */
|
2013-05-02 03:50:24 +02:00
|
|
|
|
if (heal_monsters || playerrace(u_race(df->unit))) {
|
2010-08-08 09:40:42 +02:00
|
|
|
|
int n, hp = df->unit->hp / df->unit->number;
|
|
|
|
|
int rest = df->unit->hp % df->unit->number;
|
|
|
|
|
|
|
|
|
|
for (n = 0; n < df->unit->number; n++) {
|
|
|
|
|
int wound = hp - df->person[n].hp;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
if (rest > n)
|
|
|
|
|
++wound;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
|
|
|
|
if (wound > 0 && wound < hp) {
|
2014-03-16 05:03:17 +01:00
|
|
|
|
int heal = _min(healhp, wound);
|
2011-03-07 08:03:10 +01:00
|
|
|
|
assert(heal >= 0);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
df->person[n].hp += heal;
|
2014-03-16 05:03:17 +01:00
|
|
|
|
healhp = _max(0, healhp - heal);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
++healed;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
if (healhp <= 0)
|
|
|
|
|
break;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*power = healhp;
|
|
|
|
|
return healed;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-10 03:28:03 +02:00
|
|
|
|
int sp_healing(struct castorder * co)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2012-05-10 03:28:03 +02:00
|
|
|
|
fighter * fi = co->magician.fig;
|
|
|
|
|
int level = co->level;
|
|
|
|
|
double power = co->force;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
battle *b = fi->side->battle;
|
|
|
|
|
unit *mage = fi->unit;
|
|
|
|
|
int j = 0;
|
|
|
|
|
int healhp = (int)power * 200;
|
2011-02-27 21:04:29 +01:00
|
|
|
|
quicklist *fgs;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
message *msg;
|
2014-06-23 16:28:10 +02:00
|
|
|
|
bool use_item = has_ao_healing(mage);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
|
|
|
|
/* bis zu 11 Personen pro Stufe (einen HP m<>ssen sie ja noch
|
|
|
|
|
* haben, sonst w<EFBFBD>ren sie tot) k<EFBFBD>nnen geheilt werden */
|
|
|
|
|
|
|
|
|
|
if (use_item) {
|
|
|
|
|
healhp *= 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* gehe alle denen wir helfen der reihe nach durch, heile verwundete,
|
2011-03-07 08:03:10 +01:00
|
|
|
|
* bis zu verteilende HP aufgebraucht sind */
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
|
|
|
|
fgs = fighters(b, fi->side, FIGHT_ROW, AVOID_ROW, FS_HELP);
|
2011-02-27 21:04:29 +01:00
|
|
|
|
scramble_fighters(fgs);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
j += heal_fighters(fgs, &healhp, false);
|
|
|
|
|
j += heal_fighters(fgs, &healhp, true);
|
2011-02-27 21:04:29 +01:00
|
|
|
|
ql_free(fgs);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
|
|
|
|
if (j <= 0) {
|
|
|
|
|
level = j;
|
|
|
|
|
}
|
|
|
|
|
if (use_item) {
|
2011-03-07 08:03:10 +01:00
|
|
|
|
msg =
|
|
|
|
|
msg_message("healing_effect_1", "mage amount item", mage, j,
|
2014-06-22 16:55:14 +02:00
|
|
|
|
get_resourcetype(R_AMULET_OF_HEALING));
|
2010-08-08 09:40:42 +02:00
|
|
|
|
} else {
|
|
|
|
|
msg = msg_message("healing_effect_0", "mage amount", mage, j);
|
|
|
|
|
}
|
|
|
|
|
message_all(b, msg);
|
|
|
|
|
msg_release(msg);
|
|
|
|
|
|
|
|
|
|
return level;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-10 03:28:03 +02:00
|
|
|
|
int sp_undeadhero(struct castorder * co)
|
2010-08-08 09:40:42 +02:00
|
|
|
|
{
|
2012-05-10 03:28:03 +02:00
|
|
|
|
fighter * fi = co->magician.fig;
|
|
|
|
|
int level = co->level;
|
|
|
|
|
double power = co->force;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
battle *b = fi->side->battle;
|
|
|
|
|
unit *mage = fi->unit;
|
|
|
|
|
region *r = b->region;
|
2011-02-27 21:04:29 +01:00
|
|
|
|
quicklist *fgs, *ql;
|
|
|
|
|
int qi, n, undead = 0;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
message *msg;
|
|
|
|
|
int force = (int)get_force(power, 0);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
double c = 0.50 + 0.02 * power;
|
|
|
|
|
|
|
|
|
|
/* Liste aus allen K<>mpfern */
|
2011-03-07 08:03:10 +01:00
|
|
|
|
fgs = fighters(b, fi->side, FIGHT_ROW, AVOID_ROW, FS_ENEMY | FS_HELP);
|
2011-02-27 21:04:29 +01:00
|
|
|
|
scramble_fighters(fgs);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
for (qi = 0, ql = fgs; ql; ql_advance(&ql, &qi, 1)) {
|
|
|
|
|
fighter *df = (fighter *) ql_get(ql, qi);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
unit *du = df->unit;
|
|
|
|
|
|
2011-03-07 08:03:10 +01:00
|
|
|
|
if (force <= 0)
|
|
|
|
|
break;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
|
|
|
|
/* keine Monster */
|
2013-05-02 03:50:24 +02:00
|
|
|
|
if (!playerrace(u_race(du)))
|
2011-03-07 08:03:10 +01:00
|
|
|
|
continue;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
|
|
|
|
if (df->alive + df->run.number < du->number) {
|
|
|
|
|
int j = 0;
|
|
|
|
|
|
|
|
|
|
/* Wieviele Untote k<>nnen wir aus dieser Einheit wecken? */
|
|
|
|
|
for (n = df->alive + df->run.number; n != du->number; n++) {
|
|
|
|
|
if (chance(c)) {
|
|
|
|
|
++j;
|
2011-03-07 08:03:10 +01:00
|
|
|
|
if (--force <= 0)
|
|
|
|
|
break;
|
2010-08-08 09:40:42 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (j > 0) {
|
2011-03-07 08:03:10 +01:00
|
|
|
|
unit *u =
|
2014-06-30 03:10:02 +02:00
|
|
|
|
create_unit(r, mage->faction, 0, get_race(RC_UNDEAD), 0, du->name,
|
2011-03-07 08:03:10 +01:00
|
|
|
|
du);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
|
|
|
|
/* new units gets some stats from old unit */
|
2011-03-07 08:03:10 +01:00
|
|
|
|
|
2010-08-08 09:40:42 +02:00
|
|
|
|
if (du->display) {
|
|
|
|
|
unit_setinfo(u, du->display);
|
|
|
|
|
} else {
|
|
|
|
|
unit_setinfo(u, NULL);
|
|
|
|
|
}
|
|
|
|
|
setstatus(u, du->status);
|
|
|
|
|
setguard(u, GUARD_NONE);
|
|
|
|
|
|
|
|
|
|
/* inherit stealth from magician */
|
|
|
|
|
if (fval(mage, UFL_ANON_FACTION)) {
|
|
|
|
|
fset(u, UFL_ANON_FACTION);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* transfer dead people to new unit, set hitpoints to those of old unit */
|
|
|
|
|
transfermen(du, u, j);
|
|
|
|
|
u->hp = u->number * unit_max_hp(du);
|
2011-03-07 08:03:10 +01:00
|
|
|
|
assert(j <= df->side->casualties);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
df->side->casualties -= j;
|
|
|
|
|
df->side->dead -= j;
|
|
|
|
|
|
|
|
|
|
/* counting total number of undead */
|
|
|
|
|
undead += j;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-02-27 21:04:29 +01:00
|
|
|
|
ql_free(fgs);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
|
2014-03-16 05:03:17 +01:00
|
|
|
|
level = _min(level, undead);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
if (undead == 0) {
|
2011-03-07 08:03:10 +01:00
|
|
|
|
msg =
|
|
|
|
|
msg_message("summonundead_effect_0", "mage region", mage, mage->region);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
} else {
|
2011-03-07 08:03:10 +01:00
|
|
|
|
msg =
|
|
|
|
|
msg_message("summonundead_effect_1", "mage region amount", mage,
|
|
|
|
|
mage->region, undead);
|
2010-08-08 09:40:42 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
message_all(b, msg);
|
|
|
|
|
msg_release(msg);
|
|
|
|
|
return level;
|
|
|
|
|
}
|