diff options
| -rw-r--r-- | engines/xeen/dialogs_items.cpp | 78 | ||||
| -rw-r--r-- | engines/xeen/dialogs_items.h | 6 | ||||
| -rw-r--r-- | engines/xeen/items.h | 4 | ||||
| -rw-r--r-- | engines/xeen/party.cpp | 13 | ||||
| -rw-r--r-- | engines/xeen/party.h | 2 | ||||
| -rw-r--r-- | engines/xeen/resources.cpp | 13 | ||||
| -rw-r--r-- | engines/xeen/resources.h | 5 | 
7 files changed, 99 insertions, 22 deletions
| diff --git a/engines/xeen/dialogs_items.cpp b/engines/xeen/dialogs_items.cpp index 67778777eb..511c27db5b 100644 --- a/engines/xeen/dialogs_items.cpp +++ b/engines/xeen/dialogs_items.cpp @@ -41,7 +41,8 @@ Character *ItemsDialog::execute(Character *c, ItemsMode mode) {  	Screen &screen = *_vm->_screen;  	Character *tempChar = c; -	int typeNum = mode == ITEMMODE_4 || mode == ITEMMODE_COMBAT ? 3 : 0; +	ItemCategory category = mode == ITEMMODE_4 || mode == ITEMMODE_COMBAT ?  +		CATEGORY_MISC : CATEGORY_WEAPON;  	int varA = mode == ITEMMODE_COMBAT ? 1 : 0;  	if (varA != 0)  		mode = ITEMMODE_CHAR_INFO; @@ -56,7 +57,7 @@ Character *ItemsDialog::execute(Character *c, ItemsMode mode) {  	bool redrawFlag = true;  	while (!_vm->shouldQuit()) {  		if (redrawFlag) { -			if ((mode != ITEMMODE_CHAR_INFO || typeNum != 3) && mode != ITEMMODE_6 +			if ((mode != ITEMMODE_CHAR_INFO || category != CATEGORY_MISC) && mode != ITEMMODE_6  					&& mode != ITEMMODE_4 && mode != ITEMMODE_TO_GOLD) {  				_buttons[8]._bounds.moveTo(148, _buttons[8]._bounds.top);  				_buttons[9]._draw = false; @@ -80,7 +81,7 @@ Character *ItemsDialog::execute(Character *c, ItemsMode mode) {  					BTN_SELL, BTN_IDENTIFY, BTN_FIX);  			} else if (mode != ITEMMODE_6  && mode != ITEMMODE_4 && mode != ITEMMODE_TO_GOLD) {  				msg = Common::String::format(ITEMS_DIALOG_TEXT1, -					typeNum == 3 ? BTN_USE : BTN_EQUIP,  +					category == 3 ? BTN_USE : BTN_EQUIP,   					BTN_REMOVE, BTN_DISCARD, BTN_QUEST);  			} else if (mode == ITEMMODE_6) {  				msg = Common::String::format(ITEMS_DIALOG_TEXT2, BTN_ENCHANT); @@ -99,7 +100,7 @@ Character *ItemsDialog::execute(Character *c, ItemsMode mode) {  		Common::fill(&arr[0], &arr[40], 0);  		int var2 = -1; -		if (mode == ITEMMODE_CHAR_INFO || typeNum != 3) { +		if (mode == ITEMMODE_CHAR_INFO || category != 3) {  			_iconSprites.draw(screen, 8, Common::Point(148, 109));  		}  		if (mode != ITEMMODE_6 && mode != ITEMMODE_4 && mode != ITEMMODE_TO_GOLD) { @@ -128,21 +129,21 @@ Character *ItemsDialog::execute(Character *c, ItemsMode mode) {  		for (int idx = 0; idx < 9; ++idx) {  			_itemsDrawList[idx]._y = 10 + idx * 9; -			switch (typeNum) { -			case 0: +			switch (category) { +			case CATEGORY_WEAPON:  				if (c->_weapons[idx]._id) {  					if (mode == ITEMMODE_CHAR_INFO || mode == ITEMMODE_8  							|| mode == ITEMMODE_6 || mode == ITEMMODE_4) {  						lines.push_back(Common::String::format(ITEMS_DIALOG_LINE1,   							arr[idx], idx + 1, -							c->assembleItemName(idx, arr[idx], typeNum))); +							c->assembleItemName(idx, arr[idx], category)));  					} else {  						lines.push_back(Common::String::format(ITEMS_DIALOG_LINE2,  							arr[idx], idx + 1, -							c->assembleItemName(idx, arr[idx], typeNum), +							c->assembleItemName(idx, arr[idx], category),  							calcItemCost(c, idx, mode,  								mode == ITEMMODE_TO_GOLD ? 1 : c->_skills[MERCHANT], -								typeNum) +								category)  						));  					} @@ -306,7 +307,7 @@ void ItemsDialog::setEquipmentIcons() {   * Calculate the cost of an item   */  int ItemsDialog::calcItemCost(Character *c, int itemIndex, int mode, -		int skillLevel, int typeNum) { +		int skillLevel, ItemCategory category) {  	int amount1 = 0, amount2 = 0, amount3 = 0, amount4 = 0;  	int result = 0;  	int level = skillLevel & 0x7f; @@ -329,10 +330,10 @@ int ItemsDialog::calcItemCost(Character *c, int itemIndex, int mode,  		break;  	} -	switch (typeNum) { -	case 0: -	case 1: -	case 2: { +	switch (category) { +	case CATEGORY_WEAPON: +	case CATEGORY_ARMOR: +	case CATEGORY_ACCESSORY: {  		// 0=Weapons, 1=Armor, 2=Accessories  		XeenItem &i = (mode == 0) ? c->_weapons[itemIndex] :  			(mode == 1 ? c->_armor[itemIndex] : c->_accessories[itemIndex]); @@ -409,5 +410,54 @@ int ItemsDialog::calcItemCost(Character *c, int itemIndex, int mode,  	return (mode == ITEMMODE_CHAR_INFO) ? 0 : result;  } +bool ItemsDialog::passRestrictions(CharacterClass charClass, int itemId,  +		bool showError, ItemCategory category) const { +	switch (charClass) { +	case CLASS_KNIGHT: +	case CLASS_PALADIN: +		return true; + +	case CLASS_ARCHER: +	case CLASS_CLERIC: +	case CLASS_SORCERER: +	case CLASS_ROBBER: +	case CLASS_NINJA: +	case CLASS_BARBARIAN: +	case CLASS_DRUID: +	case CLASS_RANGER: { +		if (!(ITEM_RESTRICTIONS[itemId + RESTRICTION_OFFSETS[category]] & +				(1 << (charClass - CLASS_ARCHER)))) +			return true; +		break; +	} + +	default: +		break; +	} +	 +	Common::String name; +	switch (category) { +	case CATEGORY_WEAPON: +		name = WEAPON_NAMES[itemId]; +		break; +	case CATEGORY_ARMOR: +		name = ARMOR_NAMES[itemId]; +		break; +	case CATEGORY_ACCESSORY: +		name = ACCESSORY_NAMES[itemId]; +		break; +	case CATEGORY_MISC: +		name = MISC_NAMES[itemId]; +		break; +	} + +	if (showError) { +		Common::String msg = Common::String::format(NOT_PROFICIENT,  +			CLASS_NAMES[charClass], name.c_str()); +		ErrorScroll::show(_vm, msg, WT_FREEZE_WAIT); +	} + +	return false; +}  } // End of namespace Xeen diff --git a/engines/xeen/dialogs_items.h b/engines/xeen/dialogs_items.h index 1259b2524f..74be9215ce 100644 --- a/engines/xeen/dialogs_items.h +++ b/engines/xeen/dialogs_items.h @@ -55,7 +55,11 @@ private:  	void setEquipmentIcons(); -	int calcItemCost(Character *c, int itemIndex, int mode, int skillLevel, int typeNum); +	int calcItemCost(Character *c, int itemIndex, int mode, int skillLevel,  +		ItemCategory category); + +	bool passRestrictions(CharacterClass charClass, int itemId, +		bool showError, ItemCategory category) const;  public:  	static Character *show(XeenEngine *vm, Character *c, ItemsMode mode);  }; diff --git a/engines/xeen/items.h b/engines/xeen/items.h index 943b1876c2..bfc76084c7 100644 --- a/engines/xeen/items.h +++ b/engines/xeen/items.h @@ -34,6 +34,10 @@ enum BonusFlags {  	ITEMFLAG_BONUS_MASK = 0xBF,  ITEMFLAG_CURSED = 0x40, ITEMFLAG_BROKEN = 0x80   }; +enum ItemCategory { +	CATEGORY_WEAPON = 0, CATEGORY_ARMOR = 1, CATEGORY_ACCESSORY = 2, CATEGORY_MISC = 3 +}; +  class XeenItem {  public:  	int _material; diff --git a/engines/xeen/party.cpp b/engines/xeen/party.cpp index 210852686a..2590abcf13 100644 --- a/engines/xeen/party.cpp +++ b/engines/xeen/party.cpp @@ -859,11 +859,12 @@ int Character::getNumAwards() const {   * Assembles a full lines description for a specified item for use in   * the Items dialog   */ -Common::String Character::assembleItemName(int itemIndex, int displayNum, int typeNum) { +Common::String Character::assembleItemName(int itemIndex, int displayNum,  +		ItemCategory category) {  	Spells &spells = *Party::_vm->_spells; -	switch (typeNum) { -	case 0: { +	switch (category) { +	case CATEGORY_WEAPON: {  		// Weapons  		XeenItem &i = _weapons[itemIndex];  		return Common::String::format("\f%02u%s%s%s\f%02u%s%s%s", displayNum, @@ -877,7 +878,7 @@ Common::String Character::assembleItemName(int itemIndex, int displayNum, int ty  		);  	} -	case 1: { +	case CATEGORY_ARMOR: {  		// Armor  		XeenItem &i = _armor[itemIndex];  		return Common::String::format("\f%02u%s%s%s\f%02u%s%s", displayNum, @@ -890,7 +891,7 @@ Common::String Character::assembleItemName(int itemIndex, int displayNum, int ty  		);  	} -	case 2: { +	case CATEGORY_ACCESSORY: {  		// Accessories  		XeenItem &i = _accessories[itemIndex];  		return Common::String::format("\f%02u%s%s%s\f%02u%s%s", displayNum, @@ -903,7 +904,7 @@ Common::String Character::assembleItemName(int itemIndex, int displayNum, int ty  		);  	} -	case 3: { +	case CATEGORY_MISC: {  		// Misc  		XeenItem &i = _misc[itemIndex];  		return Common::String::format("\f%02u%s%s%s\f%02u%s%s", displayNum, diff --git a/engines/xeen/party.h b/engines/xeen/party.h index d719320766..6f70c4b49c 100644 --- a/engines/xeen/party.h +++ b/engines/xeen/party.h @@ -183,7 +183,7 @@ public:  	int getNumAwards() const; -	Common::String assembleItemName(int itemIndex, int displayNum, int typeNum); +	Common::String assembleItemName(int itemIndex, int displayNum, ItemCategory category);  };  class Roster: public Common::Array<Character> { diff --git a/engines/xeen/resources.cpp b/engines/xeen/resources.cpp index b856baab47..3935104e1d 100644 --- a/engines/xeen/resources.cpp +++ b/engines/xeen/resources.cpp @@ -1072,4 +1072,17 @@ const int METAL_BASE_MULTIPLIERS[22] = {  };  const int ITEM_SKILL_DIVISORS[4] = { 1, 2, 100, 10 }; +const int RESTRICTION_OFFSETS[4] = { 0, 35, 49, 60 }; + +const int ITEM_RESTRICTIONS[86] = { +	0, 86, 86, 86, 86, 86, 86, 0, 6, 239, 239, 239, 2, 4, 4, 4, 4,  +	6, 70, 70, 70, 70, 94, 70, 0, 4, 239, 86, 86, 86, 70, 70, 70, 70,  +	0, 0, 0, 68, 100, 116, 125, 255, 255, 85, 0, 0, 0, 0, 0, 0, 0, 0,  +	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  +	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +const char *const NOT_PROFICIENT = +	"\t000\v007\x3""c%ss are not proficient with a %s!"; +  } // End of namespace Xeen diff --git a/engines/xeen/resources.h b/engines/xeen/resources.h index 4dae93e355..bcd4daeabf 100644 --- a/engines/xeen/resources.h +++ b/engines/xeen/resources.h @@ -364,6 +364,11 @@ extern const int MISC_BASE_COSTS[76];  extern const int METAL_BASE_MULTIPLIERS[22];  extern const int ITEM_SKILL_DIVISORS[4]; +extern const int RESTRICTION_OFFSETS[4]; +extern const int ITEM_RESTRICTIONS[86]; + +extern const char *const NOT_PROFICIENT; +  } // End of namespace Xeen  #endif	/* XEEN_RESOURCES_H */ | 
