diff options
author | Paul Gilbert | 2018-03-24 22:54:37 -0400 |
---|---|---|
committer | Paul Gilbert | 2018-03-24 22:54:37 -0400 |
commit | a613f4ff2209675e134e90c8ea66cfda47d6119f (patch) | |
tree | 2309cc54321a17eb298a5e2465dd0e8bf6476e8f /engines/xeen | |
parent | edf19f5f0d4d23d11008a9b59163527caf3f1369 (diff) | |
download | scummvm-rg350-a613f4ff2209675e134e90c8ea66cfda47d6119f.tar.gz scummvm-rg350-a613f4ff2209675e134e90c8ea66cfda47d6119f.tar.bz2 scummvm-rg350-a613f4ff2209675e134e90c8ea66cfda47d6119f.zip |
XEEN: Handle weapon elemental category like original does
Diffstat (limited to 'engines/xeen')
-rw-r--r-- | engines/xeen/combat.cpp | 10 | ||||
-rw-r--r-- | engines/xeen/combat.h | 1 | ||||
-rw-r--r-- | engines/xeen/item.cpp | 7 | ||||
-rw-r--r-- | engines/xeen/item.h | 5 |
4 files changed, 19 insertions, 4 deletions
diff --git a/engines/xeen/combat.cpp b/engines/xeen/combat.cpp index d2857a99c5..30ea94ee88 100644 --- a/engines/xeen/combat.cpp +++ b/engines/xeen/combat.cpp @@ -114,6 +114,7 @@ Combat::Combat(XeenEngine *vm): _vm(vm), _missVoc("miss.voc") { _monsterDamage = 0; _weaponDamage = 0; _weaponDie = _weaponDice = 0; + _weaponElemMaterial = 0; _attackWeapon = nullptr; _attackWeaponId = 0; _hitChanceBonus = 0; @@ -1433,7 +1434,7 @@ void Combat::attack2(int damage, RangeType rangeType) { int monsterResist = getMonsterResistence(rangeType); damage += monsterResist; if (monsterResist > 0) { - _pow[_attackDurationCtr]._elemFrame = _attackWeapon->getElementalCategory(); + _pow[_attackDurationCtr]._elemFrame = XeenItem::getElementalCategory(_weaponElemMaterial); _pow[_attackDurationCtr]._elemScale = getDamageScale(monsterResist); } else if (rangeType != RT_HIT) { _pow[_attackDurationCtr]._elemFrame = 0; @@ -1679,6 +1680,7 @@ void Combat::getWeaponDamage(Character &c, RangeType rangeType) { _weaponDie = _weaponDice = 0; _weaponDamage = 0; _hitChanceBonus = 0; + _weaponElemMaterial = 0; for (int idx = 0; idx < INV_ITEMS_TOTAL; ++idx) { XeenItem &weapon = c._weapons[idx]; @@ -1693,7 +1695,9 @@ void Combat::getWeaponDamage(Character &c, RangeType rangeType) { if (!(weapon._bonusFlags & (ITEMFLAG_BROKEN | ITEMFLAG_CURSED))) { _attackWeapon = &weapon; - if (weapon._material >= 37 && weapon._material < 59) { + if (weapon._material < 37) { + _weaponElemMaterial = weapon._material; + } else if (weapon._material < 59) { _hitChanceBonus = Res.METAL_DAMAGE_PERCENT[weapon._material - 37]; _weaponDamage = Res.METAL_DAMAGE[weapon._material - 37]; } @@ -1764,7 +1768,7 @@ int Combat::getMonsterResistence(RangeType rangeType) { break; } } else { - int material = !_attackWeapon ? 0 : _attackWeapon->_material; + int material = _weaponElemMaterial; damage = Res.ELEMENTAL_DAMAGE[material]; if (material != 0) { diff --git a/engines/xeen/combat.h b/engines/xeen/combat.h index 938845b022..6dc20a01fb 100644 --- a/engines/xeen/combat.h +++ b/engines/xeen/combat.h @@ -176,6 +176,7 @@ public: int _monsterDamage; int _weaponDamage; int _weaponDie, _weaponDice; + int _weaponElemMaterial; XeenItem *_attackWeapon; int _attackWeaponId; File _missVoc; diff --git a/engines/xeen/item.cpp b/engines/xeen/item.cpp index cd3ba80b4e..66607039a3 100644 --- a/engines/xeen/item.cpp +++ b/engines/xeen/item.cpp @@ -44,8 +44,13 @@ void XeenItem::synchronize(Common::Serializer &s) { } ElementalCategory XeenItem::getElementalCategory() const { + assert(_material < 36); + return getElementalCategory(_material); +} + +ElementalCategory XeenItem::getElementalCategory(int material) { int idx; - for (idx = 0; Res.ELEMENTAL_CATEGORIES[idx] < _material; ++idx) + for (idx = 0; Res.ELEMENTAL_CATEGORIES[idx] < material; ++idx) ; return (ElementalCategory)idx; diff --git a/engines/xeen/item.h b/engines/xeen/item.h index 044d73e368..b9c29af13d 100644 --- a/engines/xeen/item.h +++ b/engines/xeen/item.h @@ -87,6 +87,11 @@ public: ElementalCategory getElementalCategory() const; /** + * Gets the elemental category for a given material + */ + static ElementalCategory getElementalCategory(int material); + + /** * Gets the attribute category for the item */ AttributeCategory getAttributeCategory() const; |