From afdd20c4dd3ba5bd13a642666019c63bf3c06888 Mon Sep 17 00:00:00 2001 From: Steffen Mecke Date: Sun, 12 Jun 2016 21:54:42 +0200 Subject: [PATCH] healing potion works once per battle with 100% --- res/core/messages.xml | 4 ++-- src/battle.c | 33 +++++++++------------------------ src/battle.h | 1 + 3 files changed, 12 insertions(+), 26 deletions(-) diff --git a/res/core/messages.xml b/res/core/messages.xml index 99cf4d145..bb57fd32d 100644 --- a/res/core/messages.xml +++ b/res/core/messages.xml @@ -7293,8 +7293,8 @@ - "$unit($unit) konnte durch einen Heiltrank überleben." - "$unit($unit) was saved by a healing potion." + "Eine Person von $unit($unit) konnte durch einen Heiltrank überleben." + "A fighter of $unit($unit) was saved by a healing potion." diff --git a/src/battle.c b/src/battle.c index 88dc89ff6..003fffdbd 100644 --- a/src/battle.c +++ b/src/battle.c @@ -1156,7 +1156,6 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile) unit *au = af->unit; unit *du = df->unit; battle *b = df->side->battle; - int heiltrank = 0; /* Schild */ side *ds = df->side; @@ -1289,7 +1288,7 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile) } } - assert(dt.index < du->number); + assert(dt.index >= 0 && dt.index < du->number); if (rda>0) { df->person[dt.index].hp -= rda; if (u_race(au) == get_race(RC_DAEMON)) { @@ -1314,38 +1313,24 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile) df->person[dt.index].defence--; } } - df->person[dt.index].flags = (df->person[dt.index].flags & ~FL_SLEEPING); return false; } /* Sieben Leben */ if (u_race(du) == get_race(RC_CAT) && (chance(1.0 / 7))) { - assert(dt.index >= 0 && dt.index < du->number); df->person[dt.index].hp = unit_max_hp(du); return false; } /* Heiltrank schluerfen und hoffen */ - if (oldpotiontype[P_HEAL]) { - if (get_effect(du, oldpotiontype[P_HEAL]) > 0) { - change_effect(du, oldpotiontype[P_HEAL], -1); - heiltrank = 1; - } - else if (i_get(du->items, oldpotiontype[P_HEAL]->itype) > 0) { - i_change(&du->items, oldpotiontype[P_HEAL]->itype, -1); - change_effect(du, oldpotiontype[P_HEAL], 3); - heiltrank = 1; - } - if (heiltrank && (chance(0.50))) { - { - message *m = msg_message("battle::potionsave", "unit", du); - message_faction(b, du->faction, m); - msg_release(m); - } - assert(dt.index >= 0 && dt.index < du->number); - df->person[dt.index].hp = u_race(du)->hitpoints; - return false; - } + if (oldpotiontype[P_HEAL] && i_get(du->items, oldpotiontype[P_HEAL]->itype) > 0 && !fval(&df->person[dt.index], FL_HEALING_USED)) { + i_change(&du->items, oldpotiontype[P_HEAL]->itype, -1); + message *m = msg_message("battle::potionsave", "unit", du); + message_faction(b, du->faction, m); + msg_release(m); + fset(&df->person[dt.index], FL_HEALING_USED); + df->person[dt.index].hp = u_race(du)->hitpoints*5; + return false; } ++at.fighter->kills; diff --git a/src/battle.h b/src/battle.h index 4ea3834d9..3e156070d 100644 --- a/src/battle.h +++ b/src/battle.h @@ -137,6 +137,7 @@ extern "C" { #define FL_SLEEPING 16 #define FL_STUNNED 32 /* eine Runde keinen Angriff */ #define FL_HIT 64 /* the person at attacked */ +#define FL_HEALING_USED 128 /* has used a healing potion */ typedef struct troop { struct fighter *fighter;