forked from github/server
Made sp_undeadheroes a bit simpler. Maybe bug will be easier to find that way
This commit is contained in:
parent
b93f1f5880
commit
2fed638074
|
@ -158,13 +158,13 @@ validate_sides(battle * b)
|
||||||
{
|
{
|
||||||
side* s;
|
side* s;
|
||||||
cv_foreach(s, b->sides) {
|
cv_foreach(s, b->sides) {
|
||||||
int snumber = 0;
|
int snumber = 0;
|
||||||
fighter *df;
|
fighter *df;
|
||||||
cv_foreach(df, s->fighters) {
|
cv_foreach(df, s->fighters) {
|
||||||
unit *du = df->unit;
|
unit *du = df->unit;
|
||||||
snumber += du->number;
|
snumber += du->number;
|
||||||
} cv_next(df);
|
} cv_next(df);
|
||||||
assert(snumber==s->flee+s->healed+s->alive+s->dead);
|
assert(snumber==s->flee+s->healed+s->alive+s->dead);
|
||||||
} cv_next(s);
|
} cv_next(s);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -904,29 +904,29 @@ meffect_blocked(battle *b, meffect *s, side *as)
|
||||||
void
|
void
|
||||||
rmfighter(fighter *df, int i)
|
rmfighter(fighter *df, int i)
|
||||||
{
|
{
|
||||||
side *ds = df->side;
|
side *ds = df->side;
|
||||||
|
|
||||||
/* nicht mehr personen abziehen, als in der Einheit am Leben sind */
|
/* nicht mehr personen abziehen, als in der Einheit am Leben sind */
|
||||||
assert(df->alive >= i);
|
assert(df->alive >= i);
|
||||||
assert(df->alive <= df->unit->number);
|
assert(df->alive <= df->unit->number);
|
||||||
|
|
||||||
/* erst ziehen wir die Anzahl der Personen von den Kämpfern in der
|
/* erst ziehen wir die Anzahl der Personen von den Kämpfern in der
|
||||||
* Schlacht, dann von denen auf dieser Seite ab*/
|
* Schlacht, dann von denen auf dieser Seite ab*/
|
||||||
df->side->alive -= i;
|
df->side->alive -= i;
|
||||||
df->side->battle->alive -= i;
|
df->side->battle->alive -= i;
|
||||||
|
|
||||||
/* Dann die Kampfreihen aktualisieren */
|
/* Dann die Kampfreihen aktualisieren */
|
||||||
ds->size[SUM_ROW] -= i;
|
ds->size[SUM_ROW] -= i;
|
||||||
ds->size[statusrow(df->status)] -= i;
|
ds->size[statusrow(df->status)] -= i;
|
||||||
|
|
||||||
/* Spezialwirkungen, z.B. Schattenritter */
|
/* Spezialwirkungen, z.B. Schattenritter */
|
||||||
if (df->unit->race->battle_flags & BF_NOBLOCK) {
|
if (df->unit->race->battle_flags & BF_NOBLOCK) {
|
||||||
ds->nonblockers[SUM_ROW] -= i;
|
ds->nonblockers[SUM_ROW] -= i;
|
||||||
ds->nonblockers[statusrow(df->status)] -= i;
|
ds->nonblockers[statusrow(df->status)] -= i;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* und die Einheit selbst aktualisieren */
|
/* und die Einheit selbst aktualisieren */
|
||||||
df->alive -= i;
|
df->alive -= i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -898,89 +898,89 @@ sp_strong_wall(fighter * fi, int level, double power, spell * sp)
|
||||||
int
|
int
|
||||||
sp_chaosrow(fighter * fi, int level, double power, spell * sp)
|
sp_chaosrow(fighter * fi, int level, double power, spell * sp)
|
||||||
{
|
{
|
||||||
battle *b = fi->side->battle;
|
battle *b = fi->side->battle;
|
||||||
unit *mage = fi->unit;
|
unit *mage = fi->unit;
|
||||||
cvector *fgs;
|
cvector *fgs;
|
||||||
void **fig;
|
void **fig;
|
||||||
int n, enemies, row;
|
int enemies;
|
||||||
int k = 0;
|
int k = 0;
|
||||||
int minrow = FIGHT_ROW;
|
int minrow = FIGHT_ROW;
|
||||||
int maxrow = NUMROWS;
|
int maxrow = NUMROWS;
|
||||||
|
|
||||||
switch (sp->id) {
|
switch (sp->id) {
|
||||||
case SPL_CHAOSROW:
|
case SPL_CHAOSROW:
|
||||||
sprintf(buf, "%s murmelt eine düster klingende Formel", unitname(mage));
|
sprintf(buf, "%s murmelt eine düster klingende Formel", unitname(mage));
|
||||||
power *= 40;
|
power *= 40;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SPL_SONG_OF_CONFUSION:
|
case SPL_SONG_OF_CONFUSION:
|
||||||
sprintf(buf, "%s stimmt einen seltsamen Gesang an", unitname(mage));
|
sprintf(buf, "%s stimmt einen seltsamen Gesang an", unitname(mage));
|
||||||
power = get_force(power, 5);
|
power = get_force(power, 5);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
enemies = count_enemies(b, fi->side, minrow, maxrow);
|
enemies = count_enemies(b, fi->side, minrow, maxrow);
|
||||||
if (!enemies) {
|
if (!enemies) {
|
||||||
scat(", aber niemand war in Reichweite.");
|
scat(", aber niemand war in Reichweite.");
|
||||||
battlerecord(b, buf);
|
battlerecord(b, buf);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
scat(". ");
|
scat(". ");
|
||||||
|
|
||||||
fgs = fighters(b, fi, minrow, maxrow, FS_ENEMY);
|
fgs = fighters(b, fi, minrow, maxrow, FS_ENEMY);
|
||||||
v_scramble(fgs->begin, fgs->end);
|
v_scramble(fgs->begin, fgs->end);
|
||||||
|
|
||||||
for (fig = fgs->begin; fig != fgs->end; ++fig) {
|
for (fig = fgs->begin; fig != fgs->end; ++fig) {
|
||||||
fighter *df = *fig;
|
fighter *df = *fig;
|
||||||
|
int n = df->unit->number;
|
||||||
|
|
||||||
|
if (power<=0.0) break;
|
||||||
|
/* force sollte wegen des max(0,x) nicht unter 0 fallen können */
|
||||||
|
|
||||||
if (power<=0.0) break;
|
if (is_magic_resistant(mage, df->unit, 0)) continue;
|
||||||
/* force sollte wegen des max(0,x) nicht unter 0 fallen können */
|
|
||||||
|
|
||||||
if (is_magic_resistant(mage, df->unit, 0)) continue;
|
if (chance(power/n)) {
|
||||||
|
int row = statusrow(df->status);
|
||||||
|
df->side->size[row] -= df->alive;
|
||||||
|
if (df->unit->race->battle_flags & BF_NOBLOCK) {
|
||||||
|
df->side->nonblockers[row] -= df->alive;
|
||||||
|
}
|
||||||
|
row = FIRST_ROW + (rand()%(LAST_ROW-FIRST_ROW));
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
assert(statusrow(df->status)==row);
|
||||||
|
df->side->size[row] += df->alive;
|
||||||
|
if (df->unit->race->battle_flags & BF_NOBLOCK) {
|
||||||
|
df->side->nonblockers[row] += df->alive;
|
||||||
|
}
|
||||||
|
k+=df->alive;
|
||||||
|
}
|
||||||
|
power = max(0, power-n);
|
||||||
|
}
|
||||||
|
cv_kill(fgs);
|
||||||
|
|
||||||
n = df->unit->number;
|
scat("Ein plötzlicher Tumult entsteht");
|
||||||
|
if (k > 0) {
|
||||||
if (chance(power/n)) {
|
scat(" und bringt die Kampfaufstellung durcheinander.");
|
||||||
row = statusrow(df->status);
|
} else {
|
||||||
df->side->size[row] -= df->alive;
|
scat(", der sich jedoch schnell wieder legt.");
|
||||||
if (df->unit->race->battle_flags & BF_NOBLOCK) {
|
}
|
||||||
df->side->nonblockers[row] -= df->alive;
|
battlerecord(b, buf);
|
||||||
}
|
return level;
|
||||||
row = FIRST_ROW + (rand()%(LAST_ROW-FIRST_ROW));
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
df->side->size[row] += df->alive;
|
|
||||||
if (df->unit->race->battle_flags & BF_NOBLOCK) {
|
|
||||||
df->side->nonblockers[row] += df->alive;
|
|
||||||
}
|
|
||||||
k+=df->alive;
|
|
||||||
}
|
|
||||||
power = max(0, power-n);
|
|
||||||
}
|
|
||||||
cv_kill(fgs);
|
|
||||||
|
|
||||||
scat("Ein plötzlicher Tumult entsteht");
|
|
||||||
if (k > 0) {
|
|
||||||
scat(" und bringt die Kampfaufstellung durcheinander.");
|
|
||||||
} else {
|
|
||||||
scat(", der sich jedoch schnell wieder legt.");
|
|
||||||
}
|
|
||||||
battlerecord(b, buf);
|
|
||||||
return level;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Gesang der Furcht (Kampfzauber) */
|
/* Gesang der Furcht (Kampfzauber) */
|
||||||
|
@ -1718,6 +1718,13 @@ sp_undeadhero(fighter * fi, int level, double power, spell * sp)
|
||||||
int n, undead = 0;
|
int n, undead = 0;
|
||||||
int force = (int)get_force(power,0);
|
int force = (int)get_force(power,0);
|
||||||
double c = 0.50 + 0.02 * power;
|
double c = 0.50 + 0.02 * power;
|
||||||
|
side * s;
|
||||||
|
|
||||||
|
cv_foreach(s, b->sides) {
|
||||||
|
while (s->casualties) {
|
||||||
|
|
||||||
|
}
|
||||||
|
} cv_next(s);
|
||||||
|
|
||||||
/* Liste aus allen Kämpfern */
|
/* Liste aus allen Kämpfern */
|
||||||
fgs = fighters(b, fi, minrow, maxrow, FS_ENEMY | FS_HELP );
|
fgs = fighters(b, fi, minrow, maxrow, FS_ENEMY | FS_HELP );
|
||||||
|
@ -1744,51 +1751,34 @@ sp_undeadhero(fighter * fi, int level, double power, spell * sp)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (j > 0) {
|
if (j > 0) {
|
||||||
int hp = unit_max_hp(du);
|
unit * u = createunit(r, mage->faction, 0, new_race[RC_UNDEAD]);
|
||||||
undead += j;
|
|
||||||
df->side->casualties -= j;
|
|
||||||
df->side->dead -= j;
|
|
||||||
if (j == du->number) {
|
|
||||||
/* Einheit war vollständig tot und konnte vollständig zu
|
|
||||||
* Untoten gemacht werden */
|
|
||||||
int nr;
|
|
||||||
|
|
||||||
df->side->alive += j;
|
/* new units gets some stats from old unit */
|
||||||
du->race = new_race[RC_UNDEAD];
|
set_string(&u->name, du->name);
|
||||||
setguard(du, GUARD_NONE);
|
set_string(&u->display, du->display);
|
||||||
u_setfaction(du,mage->faction);
|
u->status = du->status;
|
||||||
if (fval(mage, UFL_PARTEITARNUNG))
|
setguard(u, GUARD_NONE);
|
||||||
fset(du, UFL_PARTEITARNUNG);
|
|
||||||
/* den Toten wieder volle Hitpoints geben */
|
/* inherit stealth from magician */
|
||||||
for (nr = 0; nr != df->alive; ++nr) {
|
if (fval(mage, UFL_PARTEITARNUNG)) {
|
||||||
df->person[nr].hp = hp;
|
fset(u, UFL_PARTEITARNUNG);
|
||||||
}
|
|
||||||
/* vereinfachtes loot */
|
|
||||||
change_money(mage, get_money(du));
|
|
||||||
set_money(du, 0);
|
|
||||||
} else {
|
|
||||||
unit *u;
|
|
||||||
u = createunit(r, mage->faction, 0, new_race[RC_UNDEAD]);
|
|
||||||
transfermen(du, u, j);
|
|
||||||
sprintf(buf, "%s", du->name);
|
|
||||||
set_string(&u->name, buf);
|
|
||||||
sprintf(buf, "%s", du->display);
|
|
||||||
set_string(&u->display, buf);
|
|
||||||
u->status = du->status;
|
|
||||||
setguard(u, GUARD_NONE);
|
|
||||||
if (fval(mage, UFL_PARTEITARNUNG))
|
|
||||||
fset(u, UFL_PARTEITARNUNG);
|
|
||||||
set_string(&u->lastorder, du->lastorder);
|
|
||||||
/* den Toten volle Hitpoints geben */
|
|
||||||
u->hp = u->number * unit_max_hp(u);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 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);
|
||||||
|
df->side->casualties -= j;
|
||||||
|
df->side->dead -= j;
|
||||||
|
|
||||||
|
/* counting total number of undead */
|
||||||
|
undead += j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cv_kill(fgs);
|
cv_kill(fgs);
|
||||||
|
|
||||||
if (undead == 0) {
|
if (undead == 0) {
|
||||||
sprintf(buf, "%s kann keinen Untoten rufen.", unitname(mage));
|
sprintf(buf, "%s kann keine Untoten rufen.", unitname(mage));
|
||||||
level = 0;
|
level = 0;
|
||||||
} else if (undead == 1) {
|
} else if (undead == 1) {
|
||||||
sprintf(buf, "%s erweckt einen Untoten.", unitname(mage));
|
sprintf(buf, "%s erweckt einen Untoten.", unitname(mage));
|
||||||
|
|
|
@ -987,38 +987,38 @@ cancast(unit * u, spell * sp, int level, int range, char * cmd)
|
||||||
double
|
double
|
||||||
spellpower(region * r, unit * u, spell * sp, int cast_level)
|
spellpower(region * r, unit * u, spell * sp, int cast_level)
|
||||||
{
|
{
|
||||||
curse * c;
|
curse * c;
|
||||||
double force = cast_level;
|
double force = cast_level;
|
||||||
if (sp==NULL) {
|
if (sp==NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
/* Bonus durch Magieturm und gesegneten Steinkreis */
|
/* Bonus durch Magieturm und gesegneten Steinkreis */
|
||||||
struct building * b = inside_building(u);
|
struct building * b = inside_building(u);
|
||||||
const struct building_type * btype = b?b->type:NULL;
|
const struct building_type * btype = b?b->type:NULL;
|
||||||
if (btype && btype->flags & BTF_MAGIC) ++force;
|
if (btype && btype->flags & BTF_MAGIC) ++force;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (get_item(u, I_RING_OF_POWER) > 0) ++force;
|
if (get_item(u, I_RING_OF_POWER) > 0) ++force;
|
||||||
|
|
||||||
/* Antimagie in der Zielregion */
|
/* Antimagie in der Zielregion */
|
||||||
c = get_curse(r->attribs, ct_find("antimagiczone"));
|
c = get_curse(r->attribs, ct_find("antimagiczone"));
|
||||||
if (curse_active(c)) {
|
if (curse_active(c)) {
|
||||||
force -= curse_geteffect(c);
|
force -= curse_geteffect(c);
|
||||||
curse_changevigour(&r->attribs, c, -cast_level);
|
curse_changevigour(&r->attribs, c, -cast_level);
|
||||||
cmistake(u, findorder(u, u->thisorder), 185, MSG_MAGIC);
|
cmistake(u, findorder(u, u->thisorder), 185, MSG_MAGIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Patzerfluch-Effekt: */
|
/* Patzerfluch-Effekt: */
|
||||||
c = get_curse(r->attribs, ct_find("fumble"));
|
c = get_curse(r->attribs, ct_find("fumble"));
|
||||||
if (curse_active(c)) {
|
if (curse_active(c)) {
|
||||||
force -= curse_geteffect(c);
|
force -= curse_geteffect(c);
|
||||||
curse_changevigour(&u->attribs, c, -1);
|
curse_changevigour(&u->attribs, c, -1);
|
||||||
cmistake(u, findorder(u, u->thisorder), 185, MSG_MAGIC);
|
cmistake(u, findorder(u, u->thisorder), 185, MSG_MAGIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
force = force * MagicPower();
|
force = force * MagicPower();
|
||||||
|
|
||||||
return max(force, 0);
|
return max(force, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------- */
|
/* ------------------------------------------------------------- */
|
||||||
|
|
Loading…
Reference in New Issue