From 1ae44db7ca819c3c1e1eb8a98c4d86c3a942089b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 13 Dec 2014 20:16:25 +0100 Subject: [PATCH] Bugfix: Untote Helden bekamen keine Beute. https://bugs.eressea.de/view.php?id=1962 --- src/battle.c | 2 +- src/randenc.c | 2 +- src/spells/combatspells.c | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/battle.c b/src/battle.c index c3729e6a0..7065ad11b 100644 --- a/src/battle.c +++ b/src/battle.c @@ -2719,7 +2719,7 @@ static void aftermath(battle * b) fset(sh, SF_DAMAGED); } - if (df->alive == du->number) { + if (df->alive && df->alive == du->number) { du->hp = sum_hp; continue; /* nichts passiert */ } diff --git a/src/randenc.c b/src/randenc.c index f611ba9ee..0c024bd6c 100644 --- a/src/randenc.c +++ b/src/randenc.c @@ -459,7 +459,7 @@ damage_unit(unit * u, const char *dam, bool physical, bool magic) return 0; } - assert(u->number > u->hp); + assert(u->number <= u->hp); h = u->hp / u->number; /* HP verteilen */ for (i = 0; i < u->number; i++) diff --git a/src/spells/combatspells.c b/src/spells/combatspells.c index cb17fac85..bd4bc2313 100644 --- a/src/spells/combatspells.c +++ b/src/spells/combatspells.c @@ -1737,6 +1737,7 @@ int sp_undeadhero(struct castorder * co) } if (j > 0) { + item **ilist; unit *u = create_unit(r, mage->faction, 0, get_race(RC_UNDEAD), 0, du->name, du); @@ -1750,6 +1751,21 @@ int sp_undeadhero(struct castorder * co) } setstatus(u, du->status); setguard(u, GUARD_NONE); + for (ilist = &du->items; *ilist;) { + item *itm = *ilist; + int loot = itm->number * j / du->number; + if (loot != itm->number) { + int split = itm->number * j % du->number; + if (split > 0 && (rng_int() % du->number) < split) { + ++loot; + } + } + i_change(&u->items, itm->type, loot); + i_change(ilist, itm->type, -loot); + if (*ilist == itm) { + ilist = &itm->next; + } + } /* inherit stealth from magician */ if (fval(mage, UFL_ANON_FACTION)) {