[Scummvm-git-logs] scummvm master -> f4e448990d7b86d3f14f12237ac9a1f97c5dd5c8

dreammaster noreply at scummvm.org
Tue Dec 14 04:20:00 UTC 2021


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
f4e448990d XEEN: Fix monster item drop probability checking


Commit: f4e448990d7b86d3f14f12237ac9a1f97c5dd5c8
    https://github.com/scummvm/scummvm/commit/f4e448990d7b86d3f14f12237ac9a1f97c5dd5c8
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-12-13T20:19:45-08:00

Commit Message:
XEEN: Fix monster item drop probability checking

Changed paths:
    NEWS.md
    engines/xeen/combat.cpp
    engines/xeen/map.cpp


diff --git a/NEWS.md b/NEWS.md
index 4734db79b8..616851ed2c 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -55,6 +55,7 @@ For a more comprehensive changelog of the latest experimental code, see:
    - Fix spell selection aborting when characters were switched.
    - Fixed some bad memory accesses.
    - Various sound fixes.
+   - Fix the monster item drop probabilities.
 
  macOS port:
    - Added support for displaying OSD messages on the Touch Bar.
diff --git a/engines/xeen/combat.cpp b/engines/xeen/combat.cpp
index 4a65ef6914..5b4ae8b9fc 100644
--- a/engines/xeen/combat.cpp
+++ b/engines/xeen/combat.cpp
@@ -102,7 +102,7 @@ static const int POW_WEAPON_VOCS[35] = {
 	5, 5, 5, 1, 3, 2, 5, 1, 1, 1, 0, 0, 0, 2, 2
 };
 
-static const int MONSTER_ITEM_RANGES[6] = { 10, 20, 50, 100, 100, 100 };
+static const int MONSTER_ITEM_RANGES[7] = { 10, 20, 50, 100, 100, 100, 0 };
 
 #define monsterSavingThrow(MONINDEX) (_vm->getRandomNumber(1, 50 + (MONINDEX)) <= (MONINDEX))
 
@@ -1526,7 +1526,7 @@ void Combat::attack2(int damage, RangeType rangeType) {
 
 			int itemDrop = monsterData._itemDrop;
 			if (itemDrop) {
-				if (MONSTER_ITEM_RANGES[itemDrop] >= _vm->getRandomNumber(1, 100)) {
+				if (MONSTER_ITEM_RANGES[itemDrop - 1] >= _vm->getRandomNumber(1, 100)) {
 					Character tempChar;
 					int category = tempChar.makeItem(itemDrop, 0, 0);
 
diff --git a/engines/xeen/map.cpp b/engines/xeen/map.cpp
index c623e994a5..02bac5a532 100644
--- a/engines/xeen/map.cpp
+++ b/engines/xeen/map.cpp
@@ -124,6 +124,7 @@ void MonsterStruct::synchronize(Common::SeekableReadStream &s) {
 	_gold = s.readUint16LE();
 	_gems = s.readByte();
 	_itemDrop = s.readByte();
+	assert(_itemDrop >= 0 && _itemDrop <= 7);
 	_flying = s.readByte() != 0;
 	_imageNumber = s.readByte();
 	_loopAnimation = s.readByte();




More information about the Scummvm-git-logs mailing list