healing potion works once per battle with 100%

This commit is contained in:
Steffen Mecke 2016-06-12 21:54:42 +02:00
parent 61d93b7931
commit afdd20c4dd
3 changed files with 12 additions and 26 deletions

View File

@ -7293,8 +7293,8 @@
<type> <type>
<arg name="unit" type="unit"/> <arg name="unit" type="unit"/>
</type> </type>
<text locale="de">"$unit($unit) konnte durch einen Heiltrank überleben."</text> <text locale="de">"Eine Person von $unit($unit) konnte durch einen Heiltrank überleben."</text>
<text locale="en">"$unit($unit) was saved by a healing potion."</text> <text locale="en">"A fighter of $unit($unit) was saved by a healing potion."</text>
</message> </message>
<message name="battle::tactics_lost" section="battle"> <message name="battle::tactics_lost" section="battle">
<type> <type>

View File

@ -1156,7 +1156,6 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile)
unit *au = af->unit; unit *au = af->unit;
unit *du = df->unit; unit *du = df->unit;
battle *b = df->side->battle; battle *b = df->side->battle;
int heiltrank = 0;
/* Schild */ /* Schild */
side *ds = df->side; 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) { if (rda>0) {
df->person[dt.index].hp -= rda; df->person[dt.index].hp -= rda;
if (u_race(au) == get_race(RC_DAEMON)) { if (u_race(au) == get_race(RC_DAEMON)) {
@ -1314,39 +1313,25 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile)
df->person[dt.index].defence--; df->person[dt.index].defence--;
} }
} }
df->person[dt.index].flags = (df->person[dt.index].flags & ~FL_SLEEPING);
return false; return false;
} }
/* Sieben Leben */ /* Sieben Leben */
if (u_race(du) == get_race(RC_CAT) && (chance(1.0 / 7))) { 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); df->person[dt.index].hp = unit_max_hp(du);
return false; return false;
} }
/* Heiltrank schluerfen und hoffen */ /* Heiltrank schluerfen und hoffen */
if (oldpotiontype[P_HEAL]) { if (oldpotiontype[P_HEAL] && i_get(du->items, oldpotiontype[P_HEAL]->itype) > 0 && !fval(&df->person[dt.index], FL_HEALING_USED)) {
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); 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 *m = msg_message("battle::potionsave", "unit", du);
message_faction(b, du->faction, m); message_faction(b, du->faction, m);
msg_release(m); msg_release(m);
} fset(&df->person[dt.index], FL_HEALING_USED);
assert(dt.index >= 0 && dt.index < du->number); df->person[dt.index].hp = u_race(du)->hitpoints*5;
df->person[dt.index].hp = u_race(du)->hitpoints;
return false; return false;
} }
}
++at.fighter->kills; ++at.fighter->kills;
if (bdebug) { if (bdebug) {

View File

@ -137,6 +137,7 @@ extern "C" {
#define FL_SLEEPING 16 #define FL_SLEEPING 16
#define FL_STUNNED 32 /* eine Runde keinen Angriff */ #define FL_STUNNED 32 /* eine Runde keinen Angriff */
#define FL_HIT 64 /* the person at attacked */ #define FL_HIT 64 /* the person at attacked */
#define FL_HEALING_USED 128 /* has used a healing potion */
typedef struct troop { typedef struct troop {
struct fighter *fighter; struct fighter *fighter;