aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2018-03-17 18:35:21 -0400
committerPaul Gilbert2018-03-17 18:35:21 -0400
commit46dc048c38cc11ec1c093ed402adfce7b6242366 (patch)
tree8657ceaad0477f68d81af2206b896a60f44a7c2e
parent48dae64267f5909941432211a08a27a40561e907 (diff)
downloadscummvm-rg350-46dc048c38cc11ec1c093ed402adfce7b6242366.tar.gz
scummvm-rg350-46dc048c38cc11ec1c093ed402adfce7b6242366.tar.bz2
scummvm-rg350-46dc048c38cc11ec1c093ed402adfce7b6242366.zip
XEEN: Fix damaging characters from poisoned well
-rw-r--r--engines/xeen/combat.cpp28
-rw-r--r--engines/xeen/scripts.cpp4
2 files changed, 15 insertions, 17 deletions
diff --git a/engines/xeen/combat.cpp b/engines/xeen/combat.cpp
index 6422b7284f..1d61d8f0fd 100644
--- a/engines/xeen/combat.cpp
+++ b/engines/xeen/combat.cpp
@@ -141,9 +141,8 @@ void Combat::giveCharDamage(int damage, DamageType attackType, int charIndex) {
Party &party = *_vm->_party;
Sound &sound = *_vm->_sound;
Windows &windows = *_vm->_windows;
- int charIndex1 = charIndex + 1;
- int selectedIndex1 = 0;
- int selectedIndex2 = 0;
+ int endIndex = charIndex + 1;
+ int selectedIndex = 0;
bool breakFlag = false;
windows.closeAll();
@@ -155,11 +154,11 @@ void Combat::giveCharDamage(int damage, DamageType attackType, int charIndex) {
Condition condition = c.worstCondition();
if (!(condition >= UNCONSCIOUS && condition <= ERADICATED)) {
- if (!selectedIndex1) {
- selectedIndex1 = idx + 1;
+ if (!charIndex) {
+ charIndex = idx + 1;
} else {
- selectedIndex2 = idx + 1;
- --selectedIndex1;
+ selectedIndex = idx + 1;
+ --charIndex;
break;
}
}
@@ -167,12 +166,12 @@ void Combat::giveCharDamage(int damage, DamageType attackType, int charIndex) {
}
if (idx == (int)party._activeParty.size()) {
if (!_combatTarget)
- selectedIndex1 = 0;
+ charIndex = 0;
}
for (;;) {
- for (; selectedIndex1 < (_combatTarget ? charIndex1 : (int)party._activeParty.size()); ++selectedIndex1) {
- Character &c = party._activeParty[selectedIndex1];
+ for (; charIndex < (_combatTarget ? endIndex : (int)party._activeParty.size()); ++charIndex) {
+ Character &c = party._activeParty[charIndex];
c._conditions[ASLEEP] = 0; // Force attacked character to be awake
int frame = 0, fx = 0;
@@ -224,7 +223,7 @@ void Combat::giveCharDamage(int damage, DamageType attackType, int charIndex) {
// Draw the attack effect on the character sprite
sound.playFX(fx);
- intf._charPowSprites.draw(0, frame, Common::Point(Res.CHAR_FACES_X[selectedIndex1], 150));
+ intf._charPowSprites.draw(0, frame, Common::Point(Res.CHAR_FACES_X[charIndex], 150));
windows[33].update();
// Reduce damage if power shield active, and set it zero
@@ -235,7 +234,6 @@ void Combat::giveCharDamage(int damage, DamageType attackType, int charIndex) {
if (damage < 0)
damage = 0;
- // Attacked characters which are asleep are killed
if (attackType == DT_SLEEP) {
damage = c._currentHp;
c._conditions[DEAD] = 1;
@@ -243,15 +241,15 @@ void Combat::giveCharDamage(int damage, DamageType attackType, int charIndex) {
// Subtract the hit points from the character
c.subtractHitPoints(damage);
- if (selectedIndex2)
+ if (selectedIndex)
break;
}
// Break check and if not, move to other index
- if (!selectedIndex2 || breakFlag)
+ if (!selectedIndex || breakFlag)
break;
- selectedIndex1 = selectedIndex2 - 1;
+ charIndex = selectedIndex - 1;
breakFlag = true;
}
diff --git a/engines/xeen/scripts.cpp b/engines/xeen/scripts.cpp
index 8777cdc6e0..8bcc3bf035 100644
--- a/engines/xeen/scripts.cpp
+++ b/engines/xeen/scripts.cpp
@@ -990,7 +990,7 @@ bool Scripts::cmdDamage(ParamsIterator &params) {
int damage = params.readUint16LE();
DamageType damageType = (DamageType)params.readByte();
- combat.giveCharDamage(damage, damageType, _charIndex);
+ combat.giveCharDamage(damage, damageType, _charIndex - 1);
return true;
}
@@ -1114,7 +1114,7 @@ bool Scripts::cmdRndDamage(ParamsIterator &params) {
DamageType dmgType = (DamageType)params.readByte();
int max = params.readByte();
- combat.giveCharDamage(_vm->getRandomNumber(1, max), dmgType, _charIndex);
+ combat.giveCharDamage(_vm->getRandomNumber(1, max), dmgType, _charIndex - 1);
return true;
}