diff options
author | Paul Gilbert | 2017-12-29 04:59:34 -0500 |
---|---|---|
committer | Paul Gilbert | 2017-12-29 04:59:34 -0500 |
commit | 47d95c6bcd28e765486f8de7e79ea84120196bc5 (patch) | |
tree | 1a55cfc7f45b3a363f63c633900712ba1998f2c0 | |
parent | e28f2a75bcb1ba363a902d45a62e286979fb75f5 (diff) | |
download | scummvm-rg350-47d95c6bcd28e765486f8de7e79ea84120196bc5.tar.gz scummvm-rg350-47d95c6bcd28e765486f8de7e79ea84120196bc5.tar.bz2 scummvm-rg350-47d95c6bcd28e765486f8de7e79ea84120196bc5.zip |
XEEN: Implemented giveExt method
-rw-r--r-- | engines/xeen/party.cpp | 105 | ||||
-rw-r--r-- | engines/xeen/party.h | 4 | ||||
-rw-r--r-- | engines/xeen/resources.cpp | 4 | ||||
-rw-r--r-- | engines/xeen/resources.h | 2 | ||||
-rw-r--r-- | engines/xeen/scripts.cpp | 2 |
5 files changed, 111 insertions, 6 deletions
diff --git a/engines/xeen/party.cpp b/engines/xeen/party.cpp index f0d5816111..49369e74be 100644 --- a/engines/xeen/party.cpp +++ b/engines/xeen/party.cpp @@ -1391,9 +1391,108 @@ bool Party::giveTake(int takeMode, uint takeVal, int giveMode, uint giveVal, int return false; } -bool Party::giveTakeExt(int takeMode, uint takeVal, int giveMode, uint giveVal, int extMode, uint extVal, int charIdx) { - // TODO - return true; +bool Party::giveExt(int mode1, uint val1, int mode2, uint val2, int mode3, uint val3, int charId) { + Combat &combat = *g_vm->_combat; + FileManager &files = *g_vm->_files; + Interface &intf = *g_vm->_interface; + Map &map = *g_vm->_map; + Party &party = *g_vm->_party; + Scripts &scripts = *g_vm->_scripts; + Sound &sound = *g_vm->_sound; + Character &c = party._activeParty[charId]; + int var1 = 0; + bool retFlag = false; + + if (intf._objNumber && !scripts._animCounter) { + MazeObject &obj = map._mobData._objects[intf._objNumber - 1]; + switch (obj._spriteId) { + case 15: + if (!files._isDarkCc) + break; + // Intentional fall-through + + case 16: + case 58: + case 73: + obj._frame = 1; + + if (obj._position.x != 20) { + if (g_vm->getRandomNumber(1, 4) == 1) { + combat.giveCharDamage(map.mazeData()._trapDamage, + (DamageType)_vm->getRandomNumber(0, 6), charId); + } + + int unlockBox = map.mazeData()._difficulties._unlockBox; + if ((c.getThievery() + _vm->getRandomNumber(1, 20)) >= unlockBox) { + scripts._animCounter++; + g_vm->_mode = MODE_7; + c._experience += c.getCurrentLevel() * unlockBox * 10; + + intf.draw3d(true, false); + Common::String msg = Common::String::format(Res.PICKS_THE_LOCK, c._name.c_str()); + ErrorScroll::show(g_vm, msg); + } else { + sound.playFX(21); + + obj._frame = 0; + scripts._animCounter = 0; + Common::String msg = Common::String::format(Res.UNABLE_TO_PICK_LOCK, c._name.c_str()); + ErrorScroll::show(g_vm, msg); + + scripts._animCounter = 255; + return true; + } + } + } + } + + for (int paramCtr = 0; paramCtr < 3; ++paramCtr) { + int mode = (paramCtr == 0) ? mode1 : (paramCtr == 1 ? mode2 : mode3); + int val = (paramCtr == 0) ? val1 : (paramCtr == 1 ? val2 : val3); + + switch (mode) { + case 34: + party._treasure._gold += val; + break; + + case 35: + party._treasure._gems += val; + break; + + case 66: + c = _itemsCharacter; + c.clear(); + + if (giveTake(0, 0, mode, val, charId)) + return true; + break; + + case 100: + _treasure._gold += g_vm->getRandomNumber(1, val); + break; + + case 101: + _treasure._gems += g_vm->getRandomNumber(1, val); + break; + + case 106: + party._food += g_vm->getRandomNumber(1, val); + break; + + case 67: + retFlag = true; + // Intentional fall-through + + default: + if (giveTake(0, 0, mode, val, charId)) + return true; + else if (retFlag) + return false; + break; + } + } + + return false; } int Party::howMuch() { diff --git a/engines/xeen/party.h b/engines/xeen/party.h index feb470fa49..9262417a26 100644 --- a/engines/xeen/party.h +++ b/engines/xeen/party.h @@ -227,9 +227,9 @@ public: bool giveTake(int takeMode, uint takeVal, int giveMode, uint giveVal, int charIdx); /** - * Gives and/or takes amounts from various character and/or party properties + * Gives up to three different item/amounts to various character and/or party properties */ - bool giveTakeExt(int takeMode, uint takeVal, int giveMode, uint giveVal, int extMode, uint extVal, int charIdx); + bool giveExt(int mode1, uint val1, int mode2, uint val2, int mode3, uint val3, int charId); /** * Resets the inventory that Blacksmiths sell diff --git a/engines/xeen/resources.cpp b/engines/xeen/resources.cpp index cff4127c19..7edd920db0 100644 --- a/engines/xeen/resources.cpp +++ b/engines/xeen/resources.cpp @@ -1668,4 +1668,8 @@ const char *const Resources::WARZONE_LEVEL = "What level of monsters? (1-10)\n"; const char *const Resources::WARZONE_HOW_MANY = "How many monsters? (1-20)\n"; +const char *const Resources::PICKS_THE_LOCK = "\x3""c\xB""010%s picks the lock!\nPress any key."; + +const char *const Resources::UNABLE_TO_PICK_LOCK = "\x3""c\v010%s was unable to pick the lock!\nPress any key."; + } // End of namespace Xeen diff --git a/engines/xeen/resources.h b/engines/xeen/resources.h index dab3dffd8d..61581594e8 100644 --- a/engines/xeen/resources.h +++ b/engines/xeen/resources.h @@ -351,6 +351,8 @@ public: static const char *const WARZONE_MAXED; static const char *const WARZONE_LEVEL; static const char *const WARZONE_HOW_MANY; + static const char *const PICKS_THE_LOCK; + static const char *const UNABLE_TO_PICK_LOCK; public: /** * Initializes an instnace of the resources diff --git a/engines/xeen/scripts.cpp b/engines/xeen/scripts.cpp index 1307a88c25..fde53b0091 100644 --- a/engines/xeen/scripts.cpp +++ b/engines/xeen/scripts.cpp @@ -932,7 +932,7 @@ bool Scripts::cmdGiveExtended(ParamsIterator ¶ms) { } _scriptExecuted = true; - bool result = party.giveTakeExt(mode1, val1, mode2, val2, mode3, val3, + bool result = party.giveExt(mode1, val1, mode2, val2, mode3, val3, (_charIndex > 0) ? _charIndex - 1 : 0); if (result) { |