diff options
author | Paul Gilbert | 2015-02-28 20:43:07 -0500 |
---|---|---|
committer | Paul Gilbert | 2015-02-28 20:43:07 -0500 |
commit | 9789962605a30e8a993370d3de3c1a30582f3964 (patch) | |
tree | 7ff0a1750bfd15b9232e9448344790d747f52304 /engines/xeen | |
parent | b414ff26f2319e4d88c60f1b0fb58880926da5f0 (diff) | |
download | scummvm-rg350-9789962605a30e8a993370d3de3c1a30582f3964.tar.gz scummvm-rg350-9789962605a30e8a993370d3de3c1a30582f3964.tar.bz2 scummvm-rg350-9789962605a30e8a993370d3de3c1a30582f3964.zip |
XEEN: Implemented protection from elements spell
Diffstat (limited to 'engines/xeen')
-rw-r--r-- | engines/xeen/dialogs_spells.cpp | 83 | ||||
-rw-r--r-- | engines/xeen/dialogs_spells.h | 14 | ||||
-rw-r--r-- | engines/xeen/resources.cpp | 10 | ||||
-rw-r--r-- | engines/xeen/resources.h | 3 | ||||
-rw-r--r-- | engines/xeen/spells.cpp | 30 |
5 files changed, 139 insertions, 1 deletions
diff --git a/engines/xeen/dialogs_spells.cpp b/engines/xeen/dialogs_spells.cpp index 70668e2ea5..3aa0cfa4ad 100644 --- a/engines/xeen/dialogs_spells.cpp +++ b/engines/xeen/dialogs_spells.cpp @@ -644,4 +644,87 @@ int SpellOnWho::execute(int spellId) { return result; } +/*------------------------------------------------------------------------*/ + +int SelectElement::show(XeenEngine *vm, int spellId) { + SelectElement *dlg = new SelectElement(vm); + int result = dlg->execute(spellId); + delete dlg; + + return result; +} + +int SelectElement::execute(int spellId) { + Combat &combat = *_vm->_combat; + EventsManager &events = *_vm->_events; + Interface &intf = *_vm->_interface; + Party &party = *_vm->_party; + Screen &screen = *_vm->_screen; + Spells &spells = *_vm->_spells; + Window &w = screen._windows[15]; + Mode oldMode = _vm->_mode; + _vm->_mode = MODE_3; + int result = 999; + + loadButtons(); + + w.open(); + w.writeString(WHICH_ELEMENT1); + drawButtons(&screen); + w.update(); + + while (result == 999) { + do { + events.updateGameCounter(); + intf.draw3d(true); + w.frame(); + w.writeString(WHICH_ELEMENT2); + drawButtons(&screen); + w.update(); + + do { + events.pollEventsAndWait(); + if (_vm->shouldQuit()) + return -1; + + checkEvents(_vm); + } while (!_buttonValue && events.timeElapsed() < 1); + } while (!_buttonValue); + + switch (_buttonValue) { + case Common::KEYCODE_ESCAPE: + result = -1; + spells.addSpellCost(*combat._oldCharacter, spellId); + break; + + case Common::KEYCODE_a: + result = DT_POISON; + break; + case Common::KEYCODE_c: + result = DT_COLD; + break; + case Common::KEYCODE_e: + result = DT_ELECTRICAL; + break; + case Common::KEYCODE_f: + result = DT_FIRE; + break; + default: + break; + } + } + + w.close(); + _vm->_mode = oldMode; + return result; +} + +void SelectElement::loadButtons() { + _iconSprites.load("element.icn"); + addButton(Common::Rect(60, 92, 84, 112), Common::KEYCODE_f, &_iconSprites); + addButton(Common::Rect(90, 92, 114, 112), Common::KEYCODE_e, &_iconSprites); + addButton(Common::Rect(120, 92, 144, 112), Common::KEYCODE_c, &_iconSprites); + addButton(Common::Rect(150, 92, 174, 112), Common::KEYCODE_a, &_iconSprites); +} + } // End of namespace Xeen diff --git a/engines/xeen/dialogs_spells.h b/engines/xeen/dialogs_spells.h index 660f2ef1de..6bbdb3cddc 100644 --- a/engines/xeen/dialogs_spells.h +++ b/engines/xeen/dialogs_spells.h @@ -84,6 +84,20 @@ public: static int show(XeenEngine *vm, int spellId); }; +class SelectElement : public ButtonContainer { +private: + XeenEngine *_vm; + SpriteResource _iconSprites; + + SelectElement(XeenEngine *vm) : ButtonContainer(), _vm(vm) {} + + int execute(int spellId); + + void loadButtons(); +public: + static int show(XeenEngine *vm, int spellId); +}; + } // End of namespace Xeen #endif /* XEEN_DIALOGS_SPELLS_H */ diff --git a/engines/xeen/resources.cpp b/engines/xeen/resources.cpp index 5893403ebd..3a751b7ad9 100644 --- a/engines/xeen/resources.cpp +++ b/engines/xeen/resources.cpp @@ -1530,4 +1530,14 @@ const char *const X_FOUND_Y = "\v060\t000\x03c%s found: %s"; const char *const ON_WHO = "\x3""c\v009On Who?"; +const char *const WHICH_ELEMENT = ""; + +const char *const WHICH_ELEMENT1 = + "\r\x3""c\x1Which Element?\x2\v034\t014\f15F\fdire\t044" + "\f15E\fdlec\t074\f15C\fdold\t104\f15A\fdcid\x1"; + +const char *const WHICH_ELEMENT2 = + "\r\x3""cWhich Element?', 2, 0Bh, '034\t014\f15F\fdire\t044" + "\f15E\fdlec\t074\f15C\fdold\t104\f15A\fdcid\x1"; + } // End of namespace Xeen diff --git a/engines/xeen/resources.h b/engines/xeen/resources.h index b908d91cf9..fed249108d 100644 --- a/engines/xeen/resources.h +++ b/engines/xeen/resources.h @@ -541,6 +541,9 @@ extern const char *const X_FOUND_Y; extern const char *const ON_WHO; +extern const char *const WHICH_ELEMENT1; +extern const char *const WHICH_ELEMENT2; + } // End of namespace Xeen #endif /* XEEN_RESOURCES_H */ diff --git a/engines/xeen/spells.cpp b/engines/xeen/spells.cpp index 1e883e7dda..b2b477e54d 100644 --- a/engines/xeen/spells.cpp +++ b/engines/xeen/spells.cpp @@ -388,7 +388,35 @@ void Spells::suppressPoison() { } void Spells::protectionFromElements() { - error("TODO: spell"); + Combat &combat = *_vm->_combat; + Interface &intf = *_vm->_interface; + Party &party = *_vm->_party; + SoundManager &sound = *_vm->_sound; + Character &c = *combat._oldCharacter; + int resist = MIN(c.getCurrentLevel() * 2 + 5, (uint)200); + + int elementType = SelectElement::show(_vm, MS_ProtFromElements); + if (elementType != -1) { + switch (elementType) { + case DT_FIRE: + party._fireResistence = resist; + break; + case DT_ELECTRICAL: + party._fireResistence = resist; + break; + case DT_COLD: + party._coldResistence = resist; + break; + case DT_POISON: + party._poisonResistence = resist; + break; + default: + break; + } + + sound.playFX(20); + intf.drawParty(true); + } } void Spells::pain() { |