From 2dc454a5fda2b66df595f7fa32bbc1084c4897da Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 6 Mar 2005 13:17:22 +0000 Subject: [PATCH] =?UTF-8?q?http://www.pbem-spiele.de/index.php=3Fname=3DPN?= =?UTF-8?q?phpBB2&file=3Dviewtopic&p=3D16720#16720=20Exploit,=20Magier=20h?= =?UTF-8?q?eilen=20Truppen=20h=C3=B6her=20als=20ihre=20HP=20vor=20dem=20Ka?= =?UTF-8?q?mpf=20waren.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/kernel/combatspells.c | 98 ++++++++++++++------------------ src/common/kernel/movement.c | 2 +- src/common/kernel/race.c | 10 +--- 3 files changed, 46 insertions(+), 64 deletions(-) diff --git a/src/common/kernel/combatspells.c b/src/common/kernel/combatspells.c index e9b7fd3fc..a027bc740 100644 --- a/src/common/kernel/combatspells.c +++ b/src/common/kernel/combatspells.c @@ -1599,6 +1599,46 @@ sp_keeploot(fighter * fi, int level, double power, spell * sp) return level; } +static int +heal_fighters(cvector *fgs, int * power, boolean heal_monsters) +{ + int healhp = *power; + int healed = 0; + void **fig; + + for (fig = fgs->begin; fig != fgs->end; ++fig) { + fighter *df = *fig; + + if (healhp<=0) break; + + /* Untote kann man nicht heilen */ + if (fval(df->unit->race, RCF_NOHEAL)) continue; + + /* wir heilen erstmal keine Monster */ + if (heal_monsters || playerrace(df->unit->race)) { + 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; + if (rest>n) ++wound; + + if (wound > 0 && wound < hp) { + int heal = min(healhp, wound); + assert(heal>=0); + df->person[n].hp += heal; + healhp = max(0, healhp - heal); + ++healed; + if (healhp<=0) break; + } + } + } + } + + *power = healhp; + return healed; +} + int sp_healing(fighter * fi, int level, double power, spell * sp) { @@ -1606,11 +1646,9 @@ sp_healing(fighter * fi, int level, double power, spell * sp) unit *mage = fi->unit; int minrow = FIGHT_ROW; int maxrow = AVOID_ROW; - int healhp; - int hp, wound; - int n, j = 0; + int j = 0; + int healhp = (int)power; cvector *fgs; - void **fig; sprintf(buf, "%s kümmert sich um die Verletzten", unitname(mage)); @@ -1630,58 +1668,10 @@ sp_healing(fighter * fi, int level, double power, spell * sp) fgs = fighters(b, fi, minrow, maxrow, FS_HELP); v_scramble(fgs->begin, fgs->end); - - healhp = (int)power; - for (fig = fgs->begin; fig != fgs->end; ++fig) { - fighter *df = *fig; - - if (healhp<=0) break; - - /* wir heilen erstmal keine Monster */ - if (!playerrace(df->unit->race)) - continue; - - hp = unit_max_hp(df->unit); - for (n = 0; n < df->unit->number; n++) { - if (!healhp) - break; - wound = hp - df->person[n].hp; - if ( wound > 0 && wound < hp) { - int heal = min(healhp, wound); - assert(heal>=0); - df->person[n].hp += heal; - healhp = max(0, healhp - heal); - j++; - } - } - } - /* haben wir noch HP übrig, so heilen wir nun auch Monster */ - for (fig = fgs->begin; fig != fgs->end; ++fig) { - fighter *df = *fig; - - if (healhp<=0) break; - - /* Untote kann man nicht heilen */ - if (fval(df->unit->race, RCF_NOHEAL)) - continue; - - hp = unit_max_hp(df->unit); - for (n = 0; n < df->unit->number; n++) { - if (healhp<=0) break; - - wound = hp - df->person[n].hp; - if ( wound > 0 && wound < hp) { - int heal = min(healhp, wound); - assert(heal>=0); - df->person[n].hp += heal; - healhp = max(0, healhp - heal); - j++; - } - } - } + j += heal_fighters(fgs, &healhp, false); + j += heal_fighters(fgs, &healhp, true); cv_kill(fgs); - if (j == 0) { scat(", doch niemand mußte magisch geheilt werden."); level = 0; diff --git a/src/common/kernel/movement.c b/src/common/kernel/movement.c index ceb8cc73e..1f69feab9 100644 --- a/src/common/kernel/movement.c +++ b/src/common/kernel/movement.c @@ -1277,7 +1277,7 @@ travel_route(unit * u, region_list * route_begin, region_list * route_end, order /* effect of borders */ while (b!=NULL) { if (b->type->move) { - b->type->move(b, u, current, next, false); + b->type->move(b, u, current, next, false); } b = b->next; } diff --git a/src/common/kernel/race.c b/src/common/kernel/race.c index da4f56f8e..e777d733d 100644 --- a/src/common/kernel/race.c +++ b/src/common/kernel/race.c @@ -291,15 +291,7 @@ unit_max_hp(const unit * u) return h; } -/* -boolean is_undead(const unit *u) -{ - return u->race == RC_UNDEAD || u->race == RC_SKELETON - || u->race == RC_SKELETON_LORD || u->race == RC_ZOMBIE - || u->race == RC_ZOMBIE_LORD || u->race == RC_GHOUL - || u->race == RC_GHOUL_LORD; -} -*/ + boolean r_insectstalled(const region * r) {