XEEN: Handle weapon elemental category like original does

This commit is contained in:
Paul Gilbert 2018-03-24 22:54:37 -04:00
parent edf19f5f0d
commit a613f4ff22
4 changed files with 19 additions and 4 deletions

View file

@ -114,6 +114,7 @@ Combat::Combat(XeenEngine *vm): _vm(vm), _missVoc("miss.voc") {
_monsterDamage = 0; _monsterDamage = 0;
_weaponDamage = 0; _weaponDamage = 0;
_weaponDie = _weaponDice = 0; _weaponDie = _weaponDice = 0;
_weaponElemMaterial = 0;
_attackWeapon = nullptr; _attackWeapon = nullptr;
_attackWeaponId = 0; _attackWeaponId = 0;
_hitChanceBonus = 0; _hitChanceBonus = 0;
@ -1433,7 +1434,7 @@ void Combat::attack2(int damage, RangeType rangeType) {
int monsterResist = getMonsterResistence(rangeType); int monsterResist = getMonsterResistence(rangeType);
damage += monsterResist; damage += monsterResist;
if (monsterResist > 0) { if (monsterResist > 0) {
_pow[_attackDurationCtr]._elemFrame = _attackWeapon->getElementalCategory(); _pow[_attackDurationCtr]._elemFrame = XeenItem::getElementalCategory(_weaponElemMaterial);
_pow[_attackDurationCtr]._elemScale = getDamageScale(monsterResist); _pow[_attackDurationCtr]._elemScale = getDamageScale(monsterResist);
} else if (rangeType != RT_HIT) { } else if (rangeType != RT_HIT) {
_pow[_attackDurationCtr]._elemFrame = 0; _pow[_attackDurationCtr]._elemFrame = 0;
@ -1679,6 +1680,7 @@ void Combat::getWeaponDamage(Character &c, RangeType rangeType) {
_weaponDie = _weaponDice = 0; _weaponDie = _weaponDice = 0;
_weaponDamage = 0; _weaponDamage = 0;
_hitChanceBonus = 0; _hitChanceBonus = 0;
_weaponElemMaterial = 0;
for (int idx = 0; idx < INV_ITEMS_TOTAL; ++idx) { for (int idx = 0; idx < INV_ITEMS_TOTAL; ++idx) {
XeenItem &weapon = c._weapons[idx]; XeenItem &weapon = c._weapons[idx];
@ -1693,7 +1695,9 @@ void Combat::getWeaponDamage(Character &c, RangeType rangeType) {
if (!(weapon._bonusFlags & (ITEMFLAG_BROKEN | ITEMFLAG_CURSED))) { if (!(weapon._bonusFlags & (ITEMFLAG_BROKEN | ITEMFLAG_CURSED))) {
_attackWeapon = &weapon; _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]; _hitChanceBonus = Res.METAL_DAMAGE_PERCENT[weapon._material - 37];
_weaponDamage = Res.METAL_DAMAGE[weapon._material - 37]; _weaponDamage = Res.METAL_DAMAGE[weapon._material - 37];
} }
@ -1764,7 +1768,7 @@ int Combat::getMonsterResistence(RangeType rangeType) {
break; break;
} }
} else { } else {
int material = !_attackWeapon ? 0 : _attackWeapon->_material; int material = _weaponElemMaterial;
damage = Res.ELEMENTAL_DAMAGE[material]; damage = Res.ELEMENTAL_DAMAGE[material];
if (material != 0) { if (material != 0) {

View file

@ -176,6 +176,7 @@ public:
int _monsterDamage; int _monsterDamage;
int _weaponDamage; int _weaponDamage;
int _weaponDie, _weaponDice; int _weaponDie, _weaponDice;
int _weaponElemMaterial;
XeenItem *_attackWeapon; XeenItem *_attackWeapon;
int _attackWeaponId; int _attackWeaponId;
File _missVoc; File _missVoc;

View file

@ -44,8 +44,13 @@ void XeenItem::synchronize(Common::Serializer &s) {
} }
ElementalCategory XeenItem::getElementalCategory() const { ElementalCategory XeenItem::getElementalCategory() const {
assert(_material < 36);
return getElementalCategory(_material);
}
ElementalCategory XeenItem::getElementalCategory(int material) {
int idx; int idx;
for (idx = 0; Res.ELEMENTAL_CATEGORIES[idx] < _material; ++idx) for (idx = 0; Res.ELEMENTAL_CATEGORIES[idx] < material; ++idx)
; ;
return (ElementalCategory)idx; return (ElementalCategory)idx;

View file

@ -86,6 +86,11 @@ public:
*/ */
ElementalCategory getElementalCategory() const; ElementalCategory getElementalCategory() const;
/**
* Gets the elemental category for a given material
*/
static ElementalCategory getElementalCategory(int material);
/** /**
* Gets the attribute category for the item * Gets the attribute category for the item
*/ */