forked from github/server
- untote helden wwurden nicht aus total vernichteten einheiten genommen
This commit is contained in:
parent
051c705809
commit
6e5da8ac25
2 changed files with 108 additions and 109 deletions
|
@ -1403,37 +1403,35 @@ select_enemy(battle * b, fighter * af, int minrow, int maxrow)
|
||||||
cvector *
|
cvector *
|
||||||
fighters(battle *b, fighter *af, int minrow, int maxrow, int mask)
|
fighters(battle *b, fighter *af, int minrow, int maxrow, int mask)
|
||||||
{
|
{
|
||||||
fighter *fig;
|
fighter *fig;
|
||||||
cvector *fightervp;
|
cvector *fightervp;
|
||||||
int row;
|
int row;
|
||||||
|
|
||||||
fightervp = malloc(sizeof(cvector));
|
fightervp = malloc(sizeof(cvector));
|
||||||
cv_init(fightervp);
|
cv_init(fightervp);
|
||||||
|
|
||||||
cv_foreach(fig, b->fighters) {
|
cv_foreach(fig, b->fighters) {
|
||||||
if (!fig->alive) continue;
|
row = get_unitrow(fig);
|
||||||
|
if (row >= minrow && row <= maxrow) {
|
||||||
|
switch (mask) {
|
||||||
|
case FS_ENEMY:
|
||||||
|
if (enemy(fig->side, af->side)) cv_pushback(fightervp, fig);
|
||||||
|
break;
|
||||||
|
case FS_HELP:
|
||||||
|
if (!enemy(fig->side, af->side) && allysf(fig->side, af->side->bf->faction))
|
||||||
|
cv_pushback(fightervp, fig);
|
||||||
|
break;
|
||||||
|
case FS_HELP|FS_ENEMY:
|
||||||
|
cv_pushback(fightervp, fig);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert(0 || !"Ungültiger Allianzstatus in fighters()");
|
||||||
|
}
|
||||||
|
|
||||||
row = get_unitrow(fig);
|
}
|
||||||
if (row >= minrow && row <= maxrow) {
|
} cv_next(fig);
|
||||||
switch (mask) {
|
|
||||||
case FS_ENEMY:
|
|
||||||
if (enemy(fig->side, af->side)) cv_pushback(fightervp, fig);
|
|
||||||
break;
|
|
||||||
case FS_HELP:
|
|
||||||
if (!enemy(fig->side, af->side) && allysf(fig->side, af->side->bf->faction))
|
|
||||||
cv_pushback(fightervp, fig);
|
|
||||||
break;
|
|
||||||
case FS_HELP|FS_ENEMY:
|
|
||||||
cv_pushback(fightervp, fig);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
assert(0 || !"Ungültiger Allianzstatus in fighters()");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
return fightervp;
|
||||||
} cv_next(fig);
|
|
||||||
|
|
||||||
return fightervp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -306,8 +306,9 @@ sp_combatrosthauch(fighter * fi, int level, double power, spell * sp)
|
||||||
|
|
||||||
for (fig = fgs->begin; fig != fgs->end; ++fig) {
|
for (fig = fgs->begin; fig != fgs->end; ++fig) {
|
||||||
fighter *df = *fig;
|
fighter *df = *fig;
|
||||||
if (!force)
|
|
||||||
break;
|
if (df->alive==0) continue;
|
||||||
|
if (force<=0) break;
|
||||||
|
|
||||||
/* da n min(force, x), sollte force maximal auf 0 sinken */
|
/* da n min(force, x), sollte force maximal auf 0 sinken */
|
||||||
assert(force >= 0);
|
assert(force >= 0);
|
||||||
|
@ -934,6 +935,7 @@ sp_chaosrow(fighter * fi, int level, double power, spell * sp)
|
||||||
fighter *df = *fig;
|
fighter *df = *fig;
|
||||||
int n = df->unit->number;
|
int n = df->unit->number;
|
||||||
|
|
||||||
|
if (df->alive==0) continue;
|
||||||
if (power<=0.0) break;
|
if (power<=0.0) break;
|
||||||
/* force sollte wegen des max(0,x) nicht unter 0 fallen können */
|
/* force sollte wegen des max(0,x) nicht unter 0 fallen können */
|
||||||
|
|
||||||
|
@ -1029,7 +1031,7 @@ sp_flee(fighter * fi, int level, double power, spell * sp)
|
||||||
|
|
||||||
for (fig = fgs->begin; fig != fgs->end; ++fig) {
|
for (fig = fgs->begin; fig != fgs->end; ++fig) {
|
||||||
fighter *df = *fig;
|
fighter *df = *fig;
|
||||||
for (n = 0; n < df->alive; n++) {
|
for (n=0; n!=df->alive; ++n) {
|
||||||
if (force < 0)
|
if (force < 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1608,101 +1610,100 @@ sp_keeploot(fighter * fi, int level, double power, spell * sp)
|
||||||
int
|
int
|
||||||
sp_healing(fighter * fi, int level, double power, spell * sp)
|
sp_healing(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;
|
||||||
int minrow = FIGHT_ROW;
|
int minrow = FIGHT_ROW;
|
||||||
int maxrow = AVOID_ROW;
|
int maxrow = AVOID_ROW;
|
||||||
int healhp;
|
int healhp;
|
||||||
int hp, wound;
|
int hp, wound;
|
||||||
int n, j = 0;
|
int n, j = 0;
|
||||||
cvector *fgs;
|
cvector *fgs;
|
||||||
void **fig;
|
void **fig;
|
||||||
|
|
||||||
sprintf(buf, "%s kümmert sich um die Verletzten", unitname(mage));
|
sprintf(buf, "%s kümmert sich um die Verletzten", unitname(mage));
|
||||||
|
|
||||||
/* bis zu 11 Personen pro Stufe (einen HP müssen sie ja noch
|
/* bis zu 11 Personen pro Stufe (einen HP müssen sie ja noch
|
||||||
* haben, sonst wären sie tot) können geheilt werden */
|
* haben, sonst wären sie tot) können geheilt werden */
|
||||||
power *= 200;
|
power *= 200;
|
||||||
|
|
||||||
if (get_item(mage, I_AMULET_OF_HEALING) > 0) {
|
if (get_item(mage, I_AMULET_OF_HEALING) > 0) {
|
||||||
scat(" und benutzt das ");
|
scat(" und benutzt das ");
|
||||||
scat(locale_string(default_locale, resourcename(oldresourcetype[R_AMULET_OF_HEALING], 0)));
|
scat(locale_string(default_locale, resourcename(oldresourcetype[R_AMULET_OF_HEALING], 0)));
|
||||||
scat(", um die Heilzauber zu verstärken");
|
scat(", um die Heilzauber zu verstärken");
|
||||||
power *= 2;
|
power *= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* gehe alle denen wir helfen der reihe nach durch, heile verwundete,
|
/* gehe alle denen wir helfen der reihe nach durch, heile verwundete,
|
||||||
* bis zu verteilende HP aufgebraucht sind */
|
* bis zu verteilende HP aufgebraucht sind */
|
||||||
|
|
||||||
fgs = fighters(b, fi, minrow, maxrow, FS_HELP);
|
fgs = fighters(b, fi, minrow, maxrow, FS_HELP);
|
||||||
v_scramble(fgs->begin, fgs->end);
|
v_scramble(fgs->begin, fgs->end);
|
||||||
|
|
||||||
healhp = (int)power;
|
healhp = (int)power;
|
||||||
for (fig = fgs->begin; fig != fgs->end; ++fig) {
|
for (fig = fgs->begin; fig != fgs->end; ++fig) {
|
||||||
fighter *df = *fig;
|
fighter *df = *fig;
|
||||||
|
|
||||||
if (healhp<=0) break;
|
if (healhp<=0) break;
|
||||||
|
|
||||||
/* wir heilen erstmal keine Monster */
|
/* wir heilen erstmal keine Monster */
|
||||||
if (!playerrace(df->unit->race))
|
if (!playerrace(df->unit->race))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
hp = unit_max_hp(df->unit);
|
hp = unit_max_hp(df->unit);
|
||||||
for (n = 0; n < df->unit->number; n++) {
|
for (n = 0; n < df->unit->number; n++) {
|
||||||
if (!healhp)
|
if (!healhp)
|
||||||
break;
|
break;
|
||||||
wound = hp - df->person[n].hp;
|
wound = hp - df->person[n].hp;
|
||||||
if ( wound > 0 && wound < hp) {
|
if ( wound > 0 && wound < hp) {
|
||||||
int heal = min(healhp, wound);
|
int heal = min(healhp, wound);
|
||||||
assert(heal>=0);
|
assert(heal>=0);
|
||||||
df->person[n].hp += heal;
|
df->person[n].hp += heal;
|
||||||
healhp = max(0, healhp - heal);
|
healhp = max(0, healhp - heal);
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* haben wir noch HP übrig, so heilen wir nun auch Monster */
|
/* haben wir noch HP übrig, so heilen wir nun auch Monster */
|
||||||
for (fig = fgs->begin; fig != fgs->end; ++fig) {
|
for (fig = fgs->begin; fig != fgs->end; ++fig) {
|
||||||
fighter *df = *fig;
|
fighter *df = *fig;
|
||||||
|
|
||||||
if (!healhp)
|
if (healhp<=0) break;
|
||||||
break;
|
|
||||||
|
|
||||||
/* Untote kann man nicht heilen */
|
/* Untote kann man nicht heilen */
|
||||||
if (fval(df->unit->race, RCF_NOHEAL))
|
if (fval(df->unit->race, RCF_NOHEAL))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
hp = unit_max_hp(df->unit);
|
hp = unit_max_hp(df->unit);
|
||||||
for (n = 0; n < df->unit->number; n++) {
|
for (n = 0; n < df->unit->number; n++) {
|
||||||
if (!healhp)
|
if (healhp<=0) break;
|
||||||
break;
|
|
||||||
wound = hp - df->person[n].hp;
|
wound = hp - df->person[n].hp;
|
||||||
if ( wound > 0 && wound < hp) {
|
if ( wound > 0 && wound < hp) {
|
||||||
int heal = min(healhp, wound);
|
int heal = min(healhp, wound);
|
||||||
assert(heal>=0);
|
assert(heal>=0);
|
||||||
df->person[n].hp += heal;
|
df->person[n].hp += heal;
|
||||||
healhp = max(0, healhp - heal);
|
healhp = max(0, healhp - heal);
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cv_kill(fgs);
|
cv_kill(fgs);
|
||||||
|
|
||||||
|
|
||||||
if (j == 0) {
|
if (j == 0) {
|
||||||
scat(", doch niemand mußte magisch geheilt werden.");
|
scat(", doch niemand mußte magisch geheilt werden.");
|
||||||
level = 0;
|
level = 0;
|
||||||
} else if (j == 1) {
|
} else if (j == 1) {
|
||||||
scat(" und heilt einen Verwundeten.");
|
scat(" und heilt einen Verwundeten.");
|
||||||
level = 1;
|
level = 1;
|
||||||
} else {
|
} else {
|
||||||
scat(" und heilt ");
|
scat(" und heilt ");
|
||||||
icat(j);
|
icat(j);
|
||||||
scat(" Verwundete.");
|
scat(" Verwundete.");
|
||||||
}
|
}
|
||||||
battlerecord(b, buf);
|
battlerecord(b, buf);
|
||||||
|
|
||||||
return level;
|
return level;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
Loading…
Reference in a new issue