From 540d081a6fd4daa31f746ddf30ccc91fb88ea04b Mon Sep 17 00:00:00 2001 From: athrxx Date: Sun, 11 Dec 2011 01:57:03 +0100 Subject: KYRA: (EOB) - initial code base commit --- engines/kyra/magic_eob.cpp | 780 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 780 insertions(+) create mode 100644 engines/kyra/magic_eob.cpp (limited to 'engines/kyra/magic_eob.cpp') diff --git a/engines/kyra/magic_eob.cpp b/engines/kyra/magic_eob.cpp new file mode 100644 index 0000000000..aefe20c06a --- /dev/null +++ b/engines/kyra/magic_eob.cpp @@ -0,0 +1,780 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifdef ENABLE_EOB + +#include "kyra/eobcommon.h" +#include "kyra/resource.h" + +namespace Kyra { + +void EobCoreEngine::useMagicBookOrSymbol(int charIndex, int type) { + EobCharacter *c = &_characters[charIndex]; + _openBookSpellLevel = c->slotStatus[3]; + _openBookSpellSelectedItem = c->slotStatus[2]; + _openBookSpellListOffset = c->slotStatus[4]; + _openBookChar = charIndex; + _openBookType = type; + _openBookSpellList = (type == 1) ? _clericSpellList : _mageSpellList; + _openBookAvailableSpells = (type == 1) ? c->clericSpells : c->mageSpells; + int8 *tmp = _openBookAvailableSpells + _openBookSpellLevel * 10 + _openBookSpellListOffset + _openBookSpellSelectedItem; + + if (*tmp <= 0) { + for (bool loop = true; loop && _openBookSpellSelectedItem < 10; ) { + tmp = _openBookAvailableSpells + _openBookSpellLevel * 10 + _openBookSpellListOffset + _openBookSpellSelectedItem; + if (*tmp > 0) { + if (_openBookSpellSelectedItem > 5) { + _openBookSpellListOffset = 6; + _openBookSpellSelectedItem -= 6; + } + loop = false; + } else { + _openBookSpellSelectedItem++; + } + } + + if (_openBookSpellSelectedItem == 10) { + _openBookSpellListOffset = 0; + _openBookSpellSelectedItem = 6; + } + } + + if (!_updateFlags) + _screen->copyRegion(64, 121, 0, 0, 112, 56, 0, 10, Screen::CR_NO_P_CHECK); + _updateFlags = 1; + gui_setPlayFieldButtons(); + gui_drawSpellbook(); +} + +void EobCoreEngine::useMagicScroll(int charIndex, int type, int weaponSlot) { + _openBookCharBackup = _openBookChar; + _openBookTypeBackup = _openBookType; + _castScrollSlot = weaponSlot + 1; + _openBookChar = charIndex; + _openBookType = type <= _clericSpellOffset ? 0 : 1; + castSpell(type, weaponSlot); +} + +void EobCoreEngine::usePotion(int charIndex, int weaponSlot) { + EobCharacter *c = &_characters[_openBookChar]; + int offset = (_flags.gameID == GI_EOB1) ? 13 : (_flags.lang == Common::DE_DEU ? 19 : 15); + + int val = deleteInventoryItem(charIndex, weaponSlot); + snd_playSoundEffect(10); + + switch (val) { + case 0: + sparkEffectDefensive(charIndex); + c->strengthCur = 22; + c->strengthExtCur = 0; + setCharEventTimer(charIndex, 546 * rollDice(1, 4, 4), 7, 1); + break; + + case 1: + sparkEffectDefensive(charIndex); + modifyCharacterHitpoints(charIndex, rollDice(2, 4, 2)); + break; + + case 2: + sparkEffectDefensive(charIndex); + modifyCharacterHitpoints(charIndex, rollDice(3, 8, 3)); + break; + + case 3: + statusAttack(charIndex, 2, _itemExtraStrings[offset], 0, 1, 8, 1); + c->effectFlags &= ~0x2000; + if (c->flags & 2) + return; + break; + + case 4: + sparkEffectDefensive(charIndex); + c->food = 100; + if (_currentControlMode) + gui_drawCharPortraitWithStats(charIndex); + break; + + case 5: + sparkEffectDefensive(charIndex); + c->effectFlags |= 0x10000; + setCharEventTimer(charIndex, 546 * rollDice(1, 4, 4), 12, 1); + snd_playSoundEffect(100); + gui_drawCharPortraitWithStats(charIndex); + break; + + case 6: + sparkEffectDefensive(charIndex); + c->effectFlags |= 0x40; + gui_drawCharPortraitWithStats(charIndex); + break; + + case 7: + sparkEffectDefensive(charIndex); + neutralizePoison(charIndex); + break; + + default: + break; + } + + _txt->printMessage(_itemExtraStrings[offset + 1], -1, c->name, _potionEffectStrings[val]); +} + +void EobCoreEngine::castSpell(int spell, int weaponSlot) { + EobSpell *s = &_spells[spell]; + EobCharacter *c = &_characters[_openBookChar]; + _activeSpell = spell; + + if ((s->flags & 0x100) && (c->effectFlags & 0x40)) + // remove invisibility effect + removeCharacterEffect(10, _openBookChar, 1); + + int ci = _openBookChar; + if (ci > 3) + ci -= 2; + + _activeSpellCasterPos = _dropItemDirIndex[(_currentDirection << 2) + ci]; + + if (s->flags & 0x400) { + if (c->inventory[0] && c->inventory[1]) { + _txt->printMessage(_magicStrings1[2]); + snd_playSoundEffect(79); + return; + } + + if (isMagicWeapon(c->inventory[0]) || isMagicWeapon(c->inventory[1])) { + _txt->printMessage(_magicStrings1[3]); + snd_playSoundEffect(79); + return; + } + } + + if (!(_flags.gameID == GI_EOB2 && _activeSpell == 62)) { + if (!_castScrollSlot) { + int8 tmp = _openBookAvailableSpells[_openBookSpellLevel * 10 + _openBookSpellListOffset + _openBookSpellSelectedItem]; + if (_openBookSpellListOffset + _openBookSpellSelectedItem < 8) + memmove(&_openBookAvailableSpells[_openBookSpellLevel * 10 + _openBookSpellListOffset + _openBookSpellSelectedItem], &_openBookAvailableSpells[_openBookSpellLevel * 10 + _openBookSpellListOffset + _openBookSpellSelectedItem + 1], 8 - (_openBookSpellListOffset + _openBookSpellSelectedItem)); + _openBookAvailableSpells[_openBookSpellLevel * 10 + 8] = -tmp; + if (_openBookAvailableSpells[_openBookSpellLevel * 10 + _openBookSpellListOffset + _openBookSpellSelectedItem] < 0) { + if (--_openBookSpellSelectedItem == -1) + if (_openBookSpellListOffset) { + _openBookSpellListOffset = 0; + _openBookSpellSelectedItem = 5; + } else { + _openBookSpellSelectedItem = 6; + } + } + } else if (weaponSlot != -1) { + updateUsedCharacterHandItem(_openBookChar, weaponSlot); + } + } + + _txt->printMessage(_magicStrings1[4], -1, c->name, s->name); + + if (s->flags & 0x20) { + castOnWhomDialogue(); + return; + } + + _activeSpellCaster = _openBookChar; + startSpell(spell); +} + +void EobCoreEngine::removeCharacterEffect(int spell, int charIndex, int showWarning) { + EobCharacter *c = &_characters[charIndex]; + EobSpell *s = &_spells[spell]; + + if (showWarning) { + _txt->printMessage(_magicStrings3[2], -1, c->name, s->name); + snd_playSoundEffect(79); + } + + if (s->endCallback) + (this->*s->endCallback)(0); + + if (s->flags & 1) + c->effectFlags &= ~s->effectFlags; + + if (s->flags & 4) + _partyEffectFlags &= ~s->effectFlags; + + if (s->flags & 0x200) { + for (int i = 0; i < 6; i++) { + if (!testCharacter(i, 1)) + continue; + if (!testCharacter(i, 2) && !(s->flags & 0x800)) + continue; + _characters[i].effectFlags &= ~s->effectFlags; + } + } + + if (s->flags & 0x2) + recalcArmorClass(_activeSpellCaster); + + if (showWarning) { + if (s->flags & 0x20A0) + gui_drawCharPortraitWithStats(charIndex); + else if (s->flags & 0x20A0) + gui_drawAllCharPortraitsWithStats(); + } +} + +void EobCoreEngine::removeAllCharacterEffects(int charIndex) { + EobCharacter *c = &_characters[charIndex]; + memset(c->effectsRemainder, 0, 4); + + for (int i = 0; i < 10; i++) { + if (c->events[i] < 0) + removeCharacterEffect(-c->events[i], charIndex, 0); + c->timers[i] = 0; + c->events[i] = 0; + } + + setupCharacterTimers(); + recalcArmorClass(charIndex); + c->disabledSlots = 0; + c->slotStatus[0] = c->slotStatus[1] = 0; + c->damageTaken = 0; + c->strengthCur = c->strengthMax; + c->strengthExtCur = c->strengthExtMax; + gui_drawAllCharPortraitsWithStats(); +} + +void EobCoreEngine::castOnWhomDialogue() { + _txt->printMessage(_magicStrings3[0]); + snd_playSoundEffect(79); + gui_setCastOnWhomButtons(); +} + +void EobCoreEngine::startSpell(int spell) { + EobSpell *s = &_spells[spell]; + EobCharacter *c = &_characters[_activeSpellCaster]; + snd_playSoundEffect(s->sound); + + if (s->flags & 0xa0) + sparkEffectDefensive(_activeSpellCaster); + else if (s->flags & 0x40) + sparkEffectDefensive(-1); + else if (s->flags & 0x1000) + sparkEffectOffensive(); + + if (s->flags & 0x20) { + _txt->printMessage(c->name); + _txt->printMessage(_magicStrings1[5]); + } + + if ((s->flags & 0x30) && (s->effectFlags & c->effectFlags)) { + _txt->printMessage(_magicStrings7[0], -1, c->name, s->name); + snd_playSoundEffect(79); + } else if ((s->flags & 0x50) && (s->effectFlags & _partyEffectFlags)) { + _txt->printMessage(_magicStrings7[1], -1, s->name); + snd_playSoundEffect(79); + } else { + if (s->flags & 8) + setSpellEventTimer(spell, s->timingPara[0], s->timingPara[1], s->timingPara[2], s->timingPara[3]); + + _returnAfterSpellCallback = false; + if (s->startCallback) + (this->*s->startCallback)(); + if (_returnAfterSpellCallback) + return; + + if (s->flags & 1) + c->effectFlags |= s->effectFlags; + if (s->flags & 4) + _partyEffectFlags |= s->effectFlags; + + if (s->flags & 0x200) { + for (int i = 0; i < 6; i++) { + if (!testCharacter(i, 1)) + continue; + if (!testCharacter(i, 2) && !(s->flags & 0x800)) + continue; + _characters[i].effectFlags |= s->effectFlags; + } + } + + if (s->flags & 2) + recalcArmorClass(_activeSpellCaster); + + if (s->flags & 0x20A0) + gui_drawCharPortraitWithStats(_activeSpellCaster); + if (s->flags & 0x40) + gui_drawAllCharPortraitsWithStats(); + } + + if (_castScrollSlot) { + gui_updateSlotAfterScrollUse(); + } else { + c->disabledSlots |= 4; + setCharEventTimer(_openBookChar, 72, 11, 1); + gui_toggleButtons(); + gui_drawSpellbook(); + } + + if (_flags.gameID == GI_EOB2) { + //_castSpellWd1 = spell; + runLevelScript(_currentBlock, 0x800); + //_castSpellWd1 = 0; + } +} + +void EobCoreEngine::sparkEffectDefensive(int charIndex) { + int first = charIndex; + int last = charIndex; + if (charIndex == -1) { + first = 0; + last = 5; + } + + for (int i = 0; i < 8; i++) { + for (int ii = first; ii <= last; ii++) { + if (!testCharacter(ii, 1) || (_currentControlMode && ii != _updateCharNum)) + continue; + + gui_drawCharPortraitWithStats(ii); + + for (int iii = 0; iii < 4; iii++) { + int shpIndex = ((_sparkEffectDefSteps[i] & _sparkEffectDefSubSteps[iii]) >> _sparkEffectDefShift[iii]); + if (!shpIndex) + continue; + int x = _sparkEffectDefAdd[iii * 2] - 8; + int y = _sparkEffectDefAdd[iii * 2 + 1]; + if (_currentControlMode) { + x += 181; + y += 3; + } else { + x += (_sparkEffectDefX[ii] << 3); + y += _sparkEffectDefY[ii]; + } + _screen->drawShape(0, _sparkShapes[shpIndex - 1], x, y, 0); + _screen->updateScreen(); + } + } + resetSkipFlag(); + delay(2 * _tickLength); + } + + for (int i = first; i < last; i++) + gui_drawCharPortraitWithStats(i); +} + +void EobCoreEngine::sparkEffectOffensive() { + disableSysTimer(2); + _screen->copyRegion(0, 0, 0, 0, 176, 120, 0, 2, Screen::CR_NO_P_CHECK); + + for (int i = 0; i < 16; i++) + _screen->copyRegionToBuffer(0, _sparkEffectOfX[i], _sparkEffectOfY[i], 16, 16, &_spellAnimBuffer[i << 8]); + _screen->updateScreen(); + + for (int i = 0; i < 11; i++) { + for (int ii = 0; ii < 16; ii++) + _screen->copyBlockToPage(2, _sparkEffectOfX[ii], _sparkEffectOfY[ii], 16, 16, &_spellAnimBuffer[ii << 8]); + + for (int ii = 0; ii < 16; ii++) { + int shpIndex = (_sparkEffectOfFlags1[i] & _sparkEffectOfFlags2[ii]) >> _sparkEffectOfShift[ii]; + if (shpIndex) + _screen->drawShape(2, _sparkShapes[shpIndex - 1], _sparkEffectOfX[ii], _sparkEffectOfY[ii], 0); + } + resetSkipFlag(); + delay(2 * _tickLength); + _screen->copyRegion(0, 0, 0, 0, 176, 120, 2, 0, Screen::CR_NO_P_CHECK); + _screen->updateScreen(); + } + + for (int i = 0; i < 16; i++) + _screen->copyBlockToPage(0, _sparkEffectOfX[i], _sparkEffectOfY[i], 16, 16, &_spellAnimBuffer[i << 8]); + + _screen->updateScreen(); + enableSysTimer(2); +} + +void EobCoreEngine::setSpellEventTimer(int spell, int timerBaseFactor, int timerLength, int timerLevelFactor, int updateExistingTimer) { + int l = _openBookType == 1 ? getCharacterClericPaladinLevel(_openBookChar) : getCharacterMageLevel(_openBookChar); + uint32 countdown = timerLength * timerBaseFactor + timerLength * l * timerLevelFactor; + setCharEventTimer(_activeSpellCaster, countdown, -spell, updateExistingTimer); +} + +bool EobCoreEngine::magicObjectHit(EobFlyingObject *fo, int dcTimes, int dcPips, int dcOffs, int level) { + int ignoreAttackerId = fo->flags & 0x10; + int singleTargetCheckAdjacent = fo->flags & 1; + int blockDamage = fo->flags & 2; + int hitTest = fo->flags & 4; + + int s = 5; + int dmgType = 3; + if (fo->flags & 8) { + s = 4; + dmgType = 0; + } + + int dmgFlag = _spells[fo->callBackIndex].damageFlags; + if (fo->attackerId >= 0) + dmgFlag |= 0x800; + + bool res = false; + if (!level) + level = 1; + + if ((_levelBlockProperties[fo->curBlock].flags & 7) && (fo->attackerId >= 0 || ignoreAttackerId)) { + _inflictMonsterDamageUnk = 1; + + for (const int16 *m = findBlockMonsters(fo->curBlock, fo->curPos, fo->direction, blockDamage, singleTargetCheckAdjacent); *m != -1; m++) { + int dmg = rollDice(dcTimes, dcPips, dcOffs) * level; + + if (hitTest) { + if (!characterAttackHitTest(fo->attackerId, *m, 0, 0)) + continue; + } + + calcAndInflictMonsterDamage(&_monsters[*m], 0, 0, dmg, dmgFlag, s, dmgType); + res = true; + } + updateAllMonsterShapes(); + + } else if (fo->curBlock == _currentBlock && (fo->attackerId < 0 || ignoreAttackerId)) { + if (blockDamage) { + for (int i = 0; i < 6; i++) { + if (!testCharacter(i, 1)) + continue; + if (hitTest && !monsterAttackHitTest(&_monsters[0], i)) + continue; + + int dmg = rollDice(dcTimes, dcPips, dcOffs) * level; + res = true; + + calcAndInflictCharacterDamage(i, 0, 0, dmg, dmgFlag, s, dmgType); + } + } else { + int c = _dscItemPosIndex[(_currentDirection << 2) + (fo->curPos & 3)]; + if ((c > 2) && (testCharacter(5, 1) || testCharacter(6, 1)) && rollDice(1, 2, -1)) + c += 2; + + if (!fo->item && (_characters[c].effectFlags & 8)) { + res = true; + } else { + if ((_characters[c].flags & 1) && hitTest && !monsterAttackHitTest(&_monsters[0], c)) { + int dmg = rollDice(dcTimes, dcPips, dcOffs) * level; + res = true; + calcAndInflictCharacterDamage(c, 0, 0, dmg, dmgFlag, s, dmgType); + } + } + } + } + + if (res && (fo->flags & 0x40)) + updateFlyingObject_s3(fo); + else if ((_flags.gameID == GI_EOB1 && fo->item == 5) || (_flags.gameID == GI_EOB2 && fo->item == 4)) + res = false; + + return res; +} + +void EobCoreEngine::spellCallback_start_armor() { + +} + +void EobCoreEngine::spellCallback_start_burningHands() { + +} + +void EobCoreEngine::spellCallback_start_detectMagic() { + +} + +bool EobCoreEngine::spellCallback_end_detectMagic(EobFlyingObject*) { + return true; +} + +void EobCoreEngine::spellCallback_start_magicMissile() { + launchMagicObject(_openBookChar, 0, _currentBlock, _activeSpellCasterPos, _currentDirection); +} + +bool EobCoreEngine::spellCallback_end_magicMissile(EobFlyingObject *fo) { + return magicObjectHit(fo, 1, 4, 1, (getCharacterMageLevel(fo->attackerId) - 1) >> 1); +} + +void EobCoreEngine::spellCallback_start_shockingGrasp() { + +} + +bool EobCoreEngine::spellCallback_end_shockingGraspFlameBlade(EobFlyingObject*) { + return true; +} + +void EobCoreEngine::spellCallback_start_improvedIdentify() { + +} + +void EobCoreEngine::spellCallback_start_melfsAcidArrow() { + launchMagicObject(_openBookChar, 1, _currentBlock, _activeSpellCasterPos, _currentDirection); +} + +bool EobCoreEngine::spellCallback_end_melfsAcidArrow(EobFlyingObject *fo) { + return magicObjectHit(fo, 2, 4, 0, getCharacterMageLevel(fo->attackerId) / 3); +} + +void EobCoreEngine::spellCallback_start_dispelMagic() { + +} + +void EobCoreEngine::spellCallback_start_fireball() { + launchMagicObject(_openBookChar, 2, _currentBlock, _activeSpellCasterPos, _currentDirection); +} + +bool EobCoreEngine::spellCallback_end_fireball(EobFlyingObject *fo) { + return magicObjectHit(fo, 1, 6, 0, getCharacterMageLevel(fo->attackerId)); +} + +void EobCoreEngine::spellCallback_start_flameArrow() { + launchMagicObject(_openBookChar, 3, _currentBlock, _activeSpellCasterPos, _currentDirection); +} + +bool EobCoreEngine::spellCallback_end_flameArrow(EobFlyingObject *fo) { + return magicObjectHit(fo, 5, 6, 0, getCharacterMageLevel(fo->attackerId)); +} + +void EobCoreEngine::spellCallback_start_holdPerson() { + launchMagicObject(_openBookChar, _flags.gameID == GI_EOB1 ? 4 : 3, _currentBlock, _activeSpellCasterPos, _currentDirection); +} + +bool EobCoreEngine::spellCallback_end_holdPerson(EobFlyingObject *fo) { + return true; +} + +void EobCoreEngine::spellCallback_start_lightningBolt() { + launchMagicObject(_openBookChar, _flags.gameID == GI_EOB1 ? 5 : 4, _currentBlock, _activeSpellCasterPos, _currentDirection); +} + +bool EobCoreEngine::spellCallback_end_lightningBolt(EobFlyingObject *fo) { + return magicObjectHit(fo, 1, 6, 0, getCharacterMageLevel(fo->attackerId)); +} + +void EobCoreEngine::spellCallback_start_vampiricTouch() { + +} + +bool EobCoreEngine::spellCallback_end_vampiricTouch(EobFlyingObject*) { + return true; +} + +void EobCoreEngine::spellCallback_start_fear() { + +} + +void EobCoreEngine::spellCallback_start_iceStorm() { + launchMagicObject(_openBookChar, _flags.gameID == GI_EOB1 ? 6 : 5, _currentBlock, _activeSpellCasterPos, _currentDirection); +} + +bool EobCoreEngine::spellCallback_end_iceStorm(EobFlyingObject *fo) { + static int8 blockAdv[] = { -32, 32, 1, -1 }; + bool res = magicObjectHit(fo, 1, 6, 0, getCharacterMageLevel(fo->attackerId)); + if (res) { + for (int i = 0; i < 4; i++) { + uint16 bl = fo->curBlock; + fo->curBlock = (fo->curBlock + blockAdv[i]) & 0x3ff; + magicObjectHit(fo, 1, 6, 0, getCharacterMageLevel(fo->attackerId)); + fo->curBlock = bl; + } + } + return res; +} + +void EobCoreEngine::spellCallback_start_removeCurse() { + +} + +void EobCoreEngine::spellCallback_start_coneOfCold() { + +} + +void EobCoreEngine::spellCallback_start_holdMonster() { + +} + +bool EobCoreEngine::spellCallback_end_holdMonster(EobFlyingObject *fo) { + return true; +} + +void EobCoreEngine::spellCallback_start_wallOfForce() { + +} + +void EobCoreEngine::spellCallback_start_disintegrate() { + +} + +void EobCoreEngine::spellCallback_start_fleshToStone() { + +} + +void EobCoreEngine::spellCallback_start_stoneToFlesh() { + +} + +void EobCoreEngine::spellCallback_start_trueSeeing() { + +} + +bool EobCoreEngine::spellCallback_end_trueSeeing(EobFlyingObject*) { + return true; +} + +void EobCoreEngine::spellCallback_start_slayLiving() { + +} + +void EobCoreEngine::spellCallback_start_powerWordStun() { + +} + +void EobCoreEngine::spellCallback_start_causeLightWounds() { + +} + +void EobCoreEngine::spellCallback_start_cureLightWounds() { + modifyCharacterHitpoints(_activeSpellCaster, rollDice(1, 8)); +} + +void EobCoreEngine::spellCallback_start_aid() { + +} + +bool EobCoreEngine::spellCallback_end_aid(EobFlyingObject*) { + return true; +} + +void EobCoreEngine::spellCallback_start_flameBlade() { + +} + +void EobCoreEngine::spellCallback_start_slowPoison() { + +} + +bool EobCoreEngine::spellCallback_end_slowPoison(EobFlyingObject*) { + return true; +} + +void EobCoreEngine::spellCallback_start_createFood() { + for (int i = 0; i < 6; i++) { + if (!testCharacter(i, 3)) + continue; + _characters[_activeSpellCaster].food = 100; + } +} + +void EobCoreEngine::spellCallback_start_removeParalysis() { + +} + +void EobCoreEngine::spellCallback_start_causeSeriousWounds() { + modifyCharacterHitpoints(_activeSpellCaster, rollDice(2, 8, 1)); +} + +void EobCoreEngine::spellCallback_start_cureSeriousWounds() { + +} + +void EobCoreEngine::spellCallback_start_neutralizePoison() { + +} + +void EobCoreEngine::spellCallback_start_causeCriticalWounds() { + +} + +void EobCoreEngine::spellCallback_start_cureCriticalWounds() { + modifyCharacterHitpoints(_activeSpellCaster, rollDice(3, 8, 3)); +} + +void EobCoreEngine::spellCallback_start_flameStrike() { + launchMagicObject(_openBookChar, _flags.gameID == GI_EOB1 ? 8 : 7, _currentBlock, _activeSpellCasterPos, _currentDirection); +} + +bool EobCoreEngine::spellCallback_end_flameStrike(EobFlyingObject *fo) { + return magicObjectHit(fo, 6, 8, 0, 0); +} + +void EobCoreEngine::spellCallback_start_raiseDead() { + +} + +void EobCoreEngine::spellCallback_start_harm() { + +} + +void EobCoreEngine::spellCallback_start_heal() { + EobCharacter *c = &_characters[_activeSpellCaster]; + if (c->hitPointsMax <= c->hitPointsCur) { + _txt->printMessage(_magicStrings4[0]); + snd_playSoundEffect(79); + } else { + modifyCharacterHitpoints(_activeSpellCaster, c->hitPointsMax - c->hitPointsCur); + } +} + +void EobCoreEngine::spellCallback_start_layOnHands() { + +} + +void EobCoreEngine::spellCallback_start_turnUndead() { + +} + +bool EobCoreEngine::spellCallback_end_unk1Passive(EobFlyingObject *fo) { + bool res = false; + if (_partyEffectFlags & 0x20000) { + res = magicObjectHit(fo, 4, 10, 6, 0); + if (res) { + gui_drawAllCharPortraitsWithStats(); + _partyEffectFlags &= ~0x20000; + } + } else { + res = magicObjectHit(fo, 12, 10, 6, 0); + } + return res; +} + +bool EobCoreEngine::spellCallback_end_unk2Passive(EobFlyingObject *fo) { + return magicObjectHit(fo, 0, 0, 18, 0); +} + +bool EobCoreEngine::spellCallback_end_deathSpellPassive(EobFlyingObject *fo) { + return true; +} + +bool EobCoreEngine::spellCallback_end_disintegratePassive(EobFlyingObject *fo) { + return true; +} + +bool EobCoreEngine::spellCallback_end_causeCriticalWoundsPassive(EobFlyingObject *fo) { + return true; +} + +bool EobCoreEngine::spellCallback_end_fleshToStonePassive(EobFlyingObject *fo) { + return true; +} + +} // End of namespace Kyra + +#endif // ENABLE_EOB -- cgit v1.2.3 From 9a6be57afd843b0cae09633b3745b104034100fa Mon Sep 17 00:00:00 2001 From: athrxx Date: Sun, 6 Nov 2011 17:02:52 +0100 Subject: KYRA: (EOB) - implement explodeObject() --- engines/kyra/magic_eob.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/kyra/magic_eob.cpp') diff --git a/engines/kyra/magic_eob.cpp b/engines/kyra/magic_eob.cpp index aefe20c06a..16e8996340 100644 --- a/engines/kyra/magic_eob.cpp +++ b/engines/kyra/magic_eob.cpp @@ -482,7 +482,7 @@ bool EobCoreEngine::magicObjectHit(EobFlyingObject *fo, int dcTimes, int dcPips, } if (res && (fo->flags & 0x40)) - updateFlyingObject_s3(fo); + explodeObject(fo, fo->curBlock, fo->item); else if ((_flags.gameID == GI_EOB1 && fo->item == 5) || (_flags.gameID == GI_EOB2 && fo->item == 4)) res = false; -- cgit v1.2.3 From c8665d06bc59b695cb6c444b1e3c24104b69dec4 Mon Sep 17 00:00:00 2001 From: athrxx Date: Thu, 16 Jun 2011 18:51:47 +0200 Subject: KYRA: (EOB) - fix some warnings and add some menu code --- engines/kyra/magic_eob.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines/kyra/magic_eob.cpp') diff --git a/engines/kyra/magic_eob.cpp b/engines/kyra/magic_eob.cpp index 16e8996340..2c83c26b83 100644 --- a/engines/kyra/magic_eob.cpp +++ b/engines/kyra/magic_eob.cpp @@ -175,13 +175,14 @@ void EobCoreEngine::castSpell(int spell, int weaponSlot) { memmove(&_openBookAvailableSpells[_openBookSpellLevel * 10 + _openBookSpellListOffset + _openBookSpellSelectedItem], &_openBookAvailableSpells[_openBookSpellLevel * 10 + _openBookSpellListOffset + _openBookSpellSelectedItem + 1], 8 - (_openBookSpellListOffset + _openBookSpellSelectedItem)); _openBookAvailableSpells[_openBookSpellLevel * 10 + 8] = -tmp; if (_openBookAvailableSpells[_openBookSpellLevel * 10 + _openBookSpellListOffset + _openBookSpellSelectedItem] < 0) { - if (--_openBookSpellSelectedItem == -1) + if (--_openBookSpellSelectedItem == -1) { if (_openBookSpellListOffset) { _openBookSpellListOffset = 0; _openBookSpellSelectedItem = 5; } else { _openBookSpellSelectedItem = 6; } + } } } else if (weaponSlot != -1) { updateUsedCharacterHandItem(_openBookChar, weaponSlot); -- cgit v1.2.3 From 045d08986d3accc3fc7d55d76eb550db01ad7fc7 Mon Sep 17 00:00:00 2001 From: athrxx Date: Wed, 22 Jun 2011 01:08:28 +0200 Subject: KYRA: (EOB) - start implementing camp menu --- engines/kyra/magic_eob.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'engines/kyra/magic_eob.cpp') diff --git a/engines/kyra/magic_eob.cpp b/engines/kyra/magic_eob.cpp index 2c83c26b83..8b6de927bf 100644 --- a/engines/kyra/magic_eob.cpp +++ b/engines/kyra/magic_eob.cpp @@ -415,6 +415,10 @@ void EobCoreEngine::setSpellEventTimer(int spell, int timerBaseFactor, int timer setCharEventTimer(_activeSpellCaster, countdown, -spell, updateExistingTimer); } +void EobCoreEngine::cleanupCharacterSpellList(int charIndex) { + +} + bool EobCoreEngine::magicObjectHit(EobFlyingObject *fo, int dcTimes, int dcPips, int dcOffs, int level) { int ignoreAttackerId = fo->flags & 0x10; int singleTargetCheckAdjacent = fo->flags & 1; -- cgit v1.2.3 From b7f7635876d3621b11d66cddca9babc1b5f1a1c6 Mon Sep 17 00:00:00 2001 From: athrxx Date: Sun, 6 Nov 2011 17:35:27 +0100 Subject: KYRA: (EOB) - implement memorize/pray spells menu --- engines/kyra/magic_eob.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/kyra/magic_eob.cpp') diff --git a/engines/kyra/magic_eob.cpp b/engines/kyra/magic_eob.cpp index 8b6de927bf..77971da441 100644 --- a/engines/kyra/magic_eob.cpp +++ b/engines/kyra/magic_eob.cpp @@ -201,6 +201,7 @@ void EobCoreEngine::castSpell(int spell, int weaponSlot) { } void EobCoreEngine::removeCharacterEffect(int spell, int charIndex, int showWarning) { + assert(spell >= 0); EobCharacter *c = &_characters[charIndex]; EobSpell *s = &_spells[spell]; -- cgit v1.2.3 From 5baabf037df661e4730500ecebca6347031aa295 Mon Sep 17 00:00:00 2001 From: athrxx Date: Sat, 2 Jul 2011 03:19:46 +0200 Subject: KYRA: (EOB) - implement save menu --- engines/kyra/magic_eob.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/kyra/magic_eob.cpp') diff --git a/engines/kyra/magic_eob.cpp b/engines/kyra/magic_eob.cpp index 77971da441..7a9750fb69 100644 --- a/engines/kyra/magic_eob.cpp +++ b/engines/kyra/magic_eob.cpp @@ -694,11 +694,11 @@ void EobCoreEngine::spellCallback_start_removeParalysis() { } void EobCoreEngine::spellCallback_start_causeSeriousWounds() { - modifyCharacterHitpoints(_activeSpellCaster, rollDice(2, 8, 1)); + } void EobCoreEngine::spellCallback_start_cureSeriousWounds() { - + modifyCharacterHitpoints(_activeSpellCaster, rollDice(2, 8, 1)); } void EobCoreEngine::spellCallback_start_neutralizePoison() { -- cgit v1.2.3 From 9140fd8e91882250e23e2e4b44bf3088f3da827a Mon Sep 17 00:00:00 2001 From: athrxx Date: Mon, 18 Jul 2011 01:22:58 +0200 Subject: KYRA: (EOB) - implement party resting --- engines/kyra/magic_eob.cpp | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) (limited to 'engines/kyra/magic_eob.cpp') diff --git a/engines/kyra/magic_eob.cpp b/engines/kyra/magic_eob.cpp index 7a9750fb69..fe770d465e 100644 --- a/engines/kyra/magic_eob.cpp +++ b/engines/kyra/magic_eob.cpp @@ -235,7 +235,7 @@ void EobCoreEngine::removeCharacterEffect(int spell, int charIndex, int showWarn if (showWarning) { if (s->flags & 0x20A0) gui_drawCharPortraitWithStats(charIndex); - else if (s->flags & 0x20A0) + else if (s->flags & 0x40) gui_drawAllCharPortraitsWithStats(); } } @@ -416,8 +416,40 @@ void EobCoreEngine::setSpellEventTimer(int spell, int timerBaseFactor, int timer setCharEventTimer(_activeSpellCaster, countdown, -spell, updateExistingTimer); } -void EobCoreEngine::cleanupCharacterSpellList(int charIndex) { +void EobCoreEngine::sortCharacterSpellList(int charIndex) { + int8 *list = _characters[charIndex].mageSpells; + for (int i = 0; i < 16; ) { + bool p = false; + for (int ii = 0; ii < 9; ii++) { + int8 *pos = &list[ii]; + + int s1 = pos[0]; + int s2 = pos[1]; + + if (s1 == 0) + s1 = 80; + else if (s1 < 0) + s1 = s1 * -1 + 40; + + if (s2 == 0) + s2 = 80; + else if (s2 < 0) + s2 = s2 * -1 + 40; + + if (s1 > s2) { + SWAP(pos[0], pos[1]); + p = true; + } + } + + if (p) + continue; + + list += 10; + if (++i == 8) + list = _characters[charIndex].clericSpells; + } } bool EobCoreEngine::magicObjectHit(EobFlyingObject *fo, int dcTimes, int dcPips, int dcOffs, int level) { @@ -685,7 +717,7 @@ void EobCoreEngine::spellCallback_start_createFood() { for (int i = 0; i < 6; i++) { if (!testCharacter(i, 3)) continue; - _characters[_activeSpellCaster].food = 100; + _characters[i].food = 100; } } -- cgit v1.2.3 From c302b3e43b1d8cfe1eae669e01d3a0775d1f7b51 Mon Sep 17 00:00:00 2001 From: athrxx Date: Thu, 21 Jul 2011 00:28:57 +0200 Subject: KYRA: (EOB) - fix various bugs and implement some spells --- engines/kyra/magic_eob.cpp | 177 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 138 insertions(+), 39 deletions(-) (limited to 'engines/kyra/magic_eob.cpp') diff --git a/engines/kyra/magic_eob.cpp b/engines/kyra/magic_eob.cpp index fe770d465e..2275bd53a4 100644 --- a/engines/kyra/magic_eob.cpp +++ b/engines/kyra/magic_eob.cpp @@ -156,14 +156,12 @@ void EobCoreEngine::castSpell(int spell, int weaponSlot) { if (s->flags & 0x400) { if (c->inventory[0] && c->inventory[1]) { - _txt->printMessage(_magicStrings1[2]); - snd_playSoundEffect(79); + printWarning(_magicStrings1[2]); return; } if (isMagicWeapon(c->inventory[0]) || isMagicWeapon(c->inventory[1])) { - _txt->printMessage(_magicStrings1[3]); - snd_playSoundEffect(79); + printWarning(_magicStrings1[3]); return; } } @@ -205,10 +203,8 @@ void EobCoreEngine::removeCharacterEffect(int spell, int charIndex, int showWarn EobCharacter *c = &_characters[charIndex]; EobSpell *s = &_spells[spell]; - if (showWarning) { - _txt->printMessage(_magicStrings3[2], -1, c->name, s->name); - snd_playSoundEffect(79); - } + if (showWarning) + printWarning(Common::String::format(_magicStrings3[_flags.gameID == GI_EOB1 ? 3 : 2], c->name, s->name).c_str()); if (s->endCallback) (this->*s->endCallback)(0); @@ -262,8 +258,7 @@ void EobCoreEngine::removeAllCharacterEffects(int charIndex) { } void EobCoreEngine::castOnWhomDialogue() { - _txt->printMessage(_magicStrings3[0]); - snd_playSoundEffect(79); + printWarning(_magicStrings3[0]); gui_setCastOnWhomButtons(); } @@ -281,15 +276,13 @@ void EobCoreEngine::startSpell(int spell) { if (s->flags & 0x20) { _txt->printMessage(c->name); - _txt->printMessage(_magicStrings1[5]); + _txt->printMessage(_flags.gameID == GI_EOB1 ? _magicStrings3[1] : _magicStrings1[5]); } if ((s->flags & 0x30) && (s->effectFlags & c->effectFlags)) { - _txt->printMessage(_magicStrings7[0], -1, c->name, s->name); - snd_playSoundEffect(79); + printWarning(Common::String::format(_magicStrings7[0], c->name, s->name).c_str()); } else if ((s->flags & 0x50) && (s->effectFlags & _partyEffectFlags)) { - _txt->printMessage(_magicStrings7[1], -1, s->name); - snd_playSoundEffect(79); + printWarning(Common::String::format(_magicStrings7[1], s->name).c_str()); } else { if (s->flags & 8) setSpellEventTimer(spell, s->timingPara[0], s->timingPara[1], s->timingPara[2], s->timingPara[3]); @@ -452,7 +445,7 @@ void EobCoreEngine::sortCharacterSpellList(int charIndex) { } } -bool EobCoreEngine::magicObjectHit(EobFlyingObject *fo, int dcTimes, int dcPips, int dcOffs, int level) { +bool EobCoreEngine::magicObjectDamageHit(EobFlyingObject *fo, int dcTimes, int dcPips, int dcOffs, int level) { int ignoreAttackerId = fo->flags & 0x10; int singleTargetCheckAdjacent = fo->flags & 1; int blockDamage = fo->flags & 2; @@ -527,6 +520,70 @@ bool EobCoreEngine::magicObjectHit(EobFlyingObject *fo, int dcTimes, int dcPips, return res; } +bool EobCoreEngine::magicObjectStatusHit(EobMonsterInPlay *m, int type, bool tryEvade, int mod) { + EobMonsterProperty *p = &_monsterProps[m->type]; + if (tryEvade) { + if (tryMonsterAttackEvasion(m) || (p->capsFlags & 0x10)) + return true; + } + + if (checkUnkConstModifiers(m, 0, p->level, mod, 6)) + return false; + + int para = 0; + + switch (type) { + case 0: + case 1: + case 2: + para = (type == 0) ? ((p->typeFlags & 1) ? 1 : 0) : ((type == 1) ? ((p->typeFlags & 2) ? 1 : 0) : 1); + if (para && !(p->statusFlags & 2)) { + m->mode = 10; + m->spellStatusLeft = 15; + } + + break; + + case 3: + if (!(p->statusFlags & 8)) + inflictMonsterDamage(m, 1000, true); + break; + + case 4: + inflictMonsterDamage(m, 1000, true); + break; + + case 5: + m->flags |= 0x20; + _sceneUpdateRequired = true; + break; + + case 6: + if (!(p->statusFlags & 4) && m->mode != 7 && m->mode != 8 && m->mode != 10) { + m->mode = 0; + m->spellStatusLeft = 20; + para = (getNextMonsterDirection(m->block, _currentBlock) ^ 4) >> 1; + m->flags |= 8; + walkMonsterNextStep(m, -1, para); + } + break; + + default: + break; + } + + return true; +} + +void EobCoreEngine::printWarning(const char* str) { + _txt->printMessage(str); + snd_playSoundEffect(79); +} + +void EobCoreEngine::printNoEffectWarning() { + printWarning(_magicStrings4[0]); +} + void EobCoreEngine::spellCallback_start_armor() { } @@ -548,7 +605,7 @@ void EobCoreEngine::spellCallback_start_magicMissile() { } bool EobCoreEngine::spellCallback_end_magicMissile(EobFlyingObject *fo) { - return magicObjectHit(fo, 1, 4, 1, (getCharacterMageLevel(fo->attackerId) - 1) >> 1); + return magicObjectDamageHit(fo, 1, 4, 1, (getCharacterMageLevel(fo->attackerId) - 1) >> 1); } void EobCoreEngine::spellCallback_start_shockingGrasp() { @@ -568,7 +625,7 @@ void EobCoreEngine::spellCallback_start_melfsAcidArrow() { } bool EobCoreEngine::spellCallback_end_melfsAcidArrow(EobFlyingObject *fo) { - return magicObjectHit(fo, 2, 4, 0, getCharacterMageLevel(fo->attackerId) / 3); + return magicObjectDamageHit(fo, 2, 4, 0, getCharacterMageLevel(fo->attackerId) / 3); } void EobCoreEngine::spellCallback_start_dispelMagic() { @@ -580,7 +637,7 @@ void EobCoreEngine::spellCallback_start_fireball() { } bool EobCoreEngine::spellCallback_end_fireball(EobFlyingObject *fo) { - return magicObjectHit(fo, 1, 6, 0, getCharacterMageLevel(fo->attackerId)); + return magicObjectDamageHit(fo, 1, 6, 0, getCharacterMageLevel(fo->attackerId)); } void EobCoreEngine::spellCallback_start_flameArrow() { @@ -588,7 +645,7 @@ void EobCoreEngine::spellCallback_start_flameArrow() { } bool EobCoreEngine::spellCallback_end_flameArrow(EobFlyingObject *fo) { - return magicObjectHit(fo, 5, 6, 0, getCharacterMageLevel(fo->attackerId)); + return magicObjectDamageHit(fo, 5, 6, 0, getCharacterMageLevel(fo->attackerId)); } void EobCoreEngine::spellCallback_start_holdPerson() { @@ -596,7 +653,28 @@ void EobCoreEngine::spellCallback_start_holdPerson() { } bool EobCoreEngine::spellCallback_end_holdPerson(EobFlyingObject *fo) { - return true; + bool res = false; + + if (_flags.gameID == GI_EOB2 && fo->curBlock == _currentBlock) { + // party hit + int numChar = rollDice(1, 4, 0); + int charIndex = rollDice(1, 6, 0); + for (int i = 0; i < 6 && numChar; i++) { + if (testCharacter(charIndex, 3)) { + statusAttack(charIndex, 4, _magicStrings8[1], 4, 5, 9, 1); + numChar--; + } + charIndex = (charIndex + 1) % 6; + } + res = true; + + } else { + // monster hit + for (const int16 *m = findBlockMonsters(fo->curBlock, fo->curPos, fo->direction, 1, 1); *m != -1; m++) + res |= magicObjectStatusHit(&_monsters[*m], 0, true, 4); + } + + return res; } void EobCoreEngine::spellCallback_start_lightningBolt() { @@ -604,7 +682,7 @@ void EobCoreEngine::spellCallback_start_lightningBolt() { } bool EobCoreEngine::spellCallback_end_lightningBolt(EobFlyingObject *fo) { - return magicObjectHit(fo, 1, 6, 0, getCharacterMageLevel(fo->attackerId)); + return magicObjectDamageHit(fo, 1, 6, 0, getCharacterMageLevel(fo->attackerId)); } void EobCoreEngine::spellCallback_start_vampiricTouch() { @@ -616,7 +694,12 @@ bool EobCoreEngine::spellCallback_end_vampiricTouch(EobFlyingObject*) { } void EobCoreEngine::spellCallback_start_fear() { - + sparkEffectOffensive(); + uint16 bl = calcNewBlockPosition(_currentBlock, _currentDirection); + for (int i = 0; i < 30; i++) { + if (_monsters[i].block == bl) + magicObjectStatusHit(&_monsters[i], 6, true, 4); + } } void EobCoreEngine::spellCallback_start_iceStorm() { @@ -625,12 +708,12 @@ void EobCoreEngine::spellCallback_start_iceStorm() { bool EobCoreEngine::spellCallback_end_iceStorm(EobFlyingObject *fo) { static int8 blockAdv[] = { -32, 32, 1, -1 }; - bool res = magicObjectHit(fo, 1, 6, 0, getCharacterMageLevel(fo->attackerId)); + bool res = magicObjectDamageHit(fo, 1, 6, 0, getCharacterMageLevel(fo->attackerId)); if (res) { for (int i = 0; i < 4; i++) { uint16 bl = fo->curBlock; fo->curBlock = (fo->curBlock + blockAdv[i]) & 0x3ff; - magicObjectHit(fo, 1, 6, 0, getCharacterMageLevel(fo->attackerId)); + magicObjectDamageHit(fo, 1, 6, 0, getCharacterMageLevel(fo->attackerId)); fo->curBlock = bl; } } @@ -650,7 +733,10 @@ void EobCoreEngine::spellCallback_start_holdMonster() { } bool EobCoreEngine::spellCallback_end_holdMonster(EobFlyingObject *fo) { - return true; + bool res = false; + for (const int16 *m = findBlockMonsters(fo->curBlock, fo->curPos, fo->direction, 1, 1); *m != -1; m++) + res |= magicObjectStatusHit(&_monsters[*m], 1, true, 4); + return res; } void EobCoreEngine::spellCallback_start_wallOfForce() { @@ -662,18 +748,27 @@ void EobCoreEngine::spellCallback_start_disintegrate() { } void EobCoreEngine::spellCallback_start_fleshToStone() { - + sparkEffectOffensive(); + int t = getClosestMonsterPos(_openBookChar, calcNewBlockPosition(_currentBlock, _currentDirection)); + if (t != -1) + magicObjectStatusHit(&_monsters[t], 5, true, 4); + else + printWarning(_magicStrings8[4]); } void EobCoreEngine::spellCallback_start_stoneToFlesh() { - + if (_characters[_activeSpellCaster].flags & 8) + _characters[_activeSpellCaster].flags &= ~8; + else + printNoEffectWarning(); } void EobCoreEngine::spellCallback_start_trueSeeing() { - + _wllVmpMap[46] = 0; } bool EobCoreEngine::spellCallback_end_trueSeeing(EobFlyingObject*) { + _wllVmpMap[46] = 1; return true; } @@ -722,7 +817,13 @@ void EobCoreEngine::spellCallback_start_createFood() { } void EobCoreEngine::spellCallback_start_removeParalysis() { - + int numChar = 4; + for (int i = 0; i < 6; i++) { + if (!(_characters[i].flags & 4) || !numChar) + continue; + _characters[i].flags &= ~4; + numChar--; + } } void EobCoreEngine::spellCallback_start_causeSeriousWounds() { @@ -750,7 +851,7 @@ void EobCoreEngine::spellCallback_start_flameStrike() { } bool EobCoreEngine::spellCallback_end_flameStrike(EobFlyingObject *fo) { - return magicObjectHit(fo, 6, 8, 0, 0); + return magicObjectDamageHit(fo, 6, 8, 0, 0); } void EobCoreEngine::spellCallback_start_raiseDead() { @@ -763,12 +864,10 @@ void EobCoreEngine::spellCallback_start_harm() { void EobCoreEngine::spellCallback_start_heal() { EobCharacter *c = &_characters[_activeSpellCaster]; - if (c->hitPointsMax <= c->hitPointsCur) { - _txt->printMessage(_magicStrings4[0]); - snd_playSoundEffect(79); - } else { + if (c->hitPointsMax <= c->hitPointsCur) + printWarning(_magicStrings4[0]); + else modifyCharacterHitpoints(_activeSpellCaster, c->hitPointsMax - c->hitPointsCur); - } } void EobCoreEngine::spellCallback_start_layOnHands() { @@ -782,19 +881,19 @@ void EobCoreEngine::spellCallback_start_turnUndead() { bool EobCoreEngine::spellCallback_end_unk1Passive(EobFlyingObject *fo) { bool res = false; if (_partyEffectFlags & 0x20000) { - res = magicObjectHit(fo, 4, 10, 6, 0); + res = magicObjectDamageHit(fo, 4, 10, 6, 0); if (res) { gui_drawAllCharPortraitsWithStats(); _partyEffectFlags &= ~0x20000; } } else { - res = magicObjectHit(fo, 12, 10, 6, 0); + res = magicObjectDamageHit(fo, 12, 10, 6, 0); } return res; } bool EobCoreEngine::spellCallback_end_unk2Passive(EobFlyingObject *fo) { - return magicObjectHit(fo, 0, 0, 18, 0); + return magicObjectDamageHit(fo, 0, 0, 18, 0); } bool EobCoreEngine::spellCallback_end_deathSpellPassive(EobFlyingObject *fo) { -- cgit v1.2.3 From 0e4c184e285c9b20b90536eb485a7f8a50833da3 Mon Sep 17 00:00:00 2001 From: athrxx Date: Thu, 28 Jul 2011 17:56:59 +0200 Subject: KYRA: (EOB) - implement some gui functionality, some bug fixes, etc. --- engines/kyra/magic_eob.cpp | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) (limited to 'engines/kyra/magic_eob.cpp') diff --git a/engines/kyra/magic_eob.cpp b/engines/kyra/magic_eob.cpp index 2275bd53a4..593ef63544 100644 --- a/engines/kyra/magic_eob.cpp +++ b/engines/kyra/magic_eob.cpp @@ -76,7 +76,6 @@ void EobCoreEngine::useMagicScroll(int charIndex, int type, int weaponSlot) { void EobCoreEngine::usePotion(int charIndex, int weaponSlot) { EobCharacter *c = &_characters[_openBookChar]; - int offset = (_flags.gameID == GI_EOB1) ? 13 : (_flags.lang == Common::DE_DEU ? 19 : 15); int val = deleteInventoryItem(charIndex, weaponSlot); snd_playSoundEffect(10); @@ -100,7 +99,7 @@ void EobCoreEngine::usePotion(int charIndex, int weaponSlot) { break; case 3: - statusAttack(charIndex, 2, _itemExtraStrings[offset], 0, 1, 8, 1); + statusAttack(charIndex, 2, _potionStrings[0], 0, 1, 8, 1); c->effectFlags &= ~0x2000; if (c->flags & 2) return; @@ -136,7 +135,37 @@ void EobCoreEngine::usePotion(int charIndex, int weaponSlot) { break; } - _txt->printMessage(_itemExtraStrings[offset + 1], -1, c->name, _potionEffectStrings[val]); + _txt->printMessage(_potionStrings[1], -1, c->name, _potionEffectStrings[val]); +} + +void EobCoreEngine::useWand(int charIndex, int weaponSlot) { + int v = _items[_characters[charIndex].inventory[weaponSlot]].value - 1; + if (!v) { + _txt->printMessage(_wandStrings[0]); + return; + } + + if (v != 5) + useMagicScroll(charIndex, _wandTypes[v], weaponSlot); + else if (_flags.gameID == GI_EOB2) + useMagicScroll(charIndex, 64, weaponSlot); + else { + uint16 bl1 = calcNewBlockPosition(_currentBlock, _currentDirection); + uint16 bl2 = calcNewBlockPosition(bl1, _currentDirection); + snd_playSoundEffect(98); + sparkEffectOffensive(); + + if ((_wllWallFlags[_levelBlockProperties[bl2].walls[_currentDirection ^ 2]] & 4) && !(_levelBlockProperties[bl2].flags & 7) && (_levelBlockProperties[bl1].flags & 7)) { + for (int i = 0; i < 30; i++) { + if (_monsters[i].block != bl1) + continue; + placeMonster(&_monsters[i], bl2, -1); + _sceneUpdateRequired = true; + } + } else { + _txt->printMessage(_wandStrings[1]); + } + } } void EobCoreEngine::castSpell(int spell, int weaponSlot) { -- cgit v1.2.3 From 84900e8e50df8490fbdebc3acb25a338949f2de9 Mon Sep 17 00:00:00 2001 From: athrxx Date: Fri, 29 Jul 2011 15:57:02 +0200 Subject: KYRA: (EOB) - add turn undead spell, add some screen fades, fix some bugs --- engines/kyra/magic_eob.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) (limited to 'engines/kyra/magic_eob.cpp') diff --git a/engines/kyra/magic_eob.cpp b/engines/kyra/magic_eob.cpp index 593ef63544..f828625dbb 100644 --- a/engines/kyra/magic_eob.cpp +++ b/engines/kyra/magic_eob.cpp @@ -80,6 +80,9 @@ void EobCoreEngine::usePotion(int charIndex, int weaponSlot) { int val = deleteInventoryItem(charIndex, weaponSlot); snd_playSoundEffect(10); + if (_flags.gameID == GI_EOB1) + val--; + switch (val) { case 0: sparkEffectDefensive(charIndex); @@ -496,7 +499,7 @@ bool EobCoreEngine::magicObjectDamageHit(EobFlyingObject *fo, int dcTimes, int d level = 1; if ((_levelBlockProperties[fo->curBlock].flags & 7) && (fo->attackerId >= 0 || ignoreAttackerId)) { - _inflictMonsterDamageUnk = 1; + _preventMonsterFlash = true; for (const int16 *m = findBlockMonsters(fo->curBlock, fo->curPos, fo->direction, blockDamage, singleTargetCheckAdjacent); *m != -1; m++) { int dmg = rollDice(dcTimes, dcPips, dcOffs) * level; @@ -604,6 +607,23 @@ bool EobCoreEngine::magicObjectStatusHit(EobMonsterInPlay *m, int type, bool try return true; } +bool EobCoreEngine::turnUndeadHit(EobMonsterInPlay *m, int hitChance, int casterLevel) { + uint8 e = _turnUndeadEffect[_monsterProps[m->type].tuResist * 14 + MIN(casterLevel, 14)]; + + if (e == 0xff) { + calcAndInflictMonsterDamage(m, 0, 0, 500, 0x200, 5, 3); + } else if (hitChance < e) { + return false; + } else { + m->mode = 0; + m->flags |= 8; + m->spellStatusLeft = 40; + m->dir = (getNextMonsterDirection(m->block, _currentBlock) ^ 4) >> 1; + } + + return true; +} + void EobCoreEngine::printWarning(const char* str) { _txt->printMessage(str); snd_playSoundEffect(79); @@ -900,11 +920,33 @@ void EobCoreEngine::spellCallback_start_heal() { } void EobCoreEngine::spellCallback_start_layOnHands() { - + modifyCharacterHitpoints(_activeSpellCaster, _characters[_openBookChar].level[0] << 1); } void EobCoreEngine::spellCallback_start_turnUndead() { + uint16 bl = calcNewBlockPosition(_currentBlock, _currentDirection); + if (!(_levelBlockProperties[bl].flags & 7)) + return; + + int cl = _openBookCasterLevel ? _openBookCasterLevel : getCharacterClericPaladinLevel(_openBookChar); + int r = rollDice(1, 20); + bool hit = false; + + for (const int16 *m = findBlockMonsters(bl, 4, 4, 1, 1); *m != -1; m++) { + if ((_monsterProps[_monsters[*m].type].typeFlags & 4) && !(_monsters[*m].flags & 0x10)) { + _preventMonsterFlash = true; + _monsters[*m].flags |= 0x10; + hit |= turnUndeadHit(&_monsters[*m], r, cl); + } + } + + if (hit) { + turnUndeadAutoHit(); + snd_playSoundEffect(95); + updateAllMonsterShapes(); + } + _preventMonsterFlash = false; } bool EobCoreEngine::spellCallback_end_unk1Passive(EobFlyingObject *fo) { -- cgit v1.2.3 From 48f83b7bb48a1625f6c195e396f8d40047f50915 Mon Sep 17 00:00:00 2001 From: athrxx Date: Mon, 1 Aug 2011 22:50:51 +0200 Subject: KYRA: (EOB) - implement npc sequences and fix some bugs --- engines/kyra/magic_eob.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'engines/kyra/magic_eob.cpp') diff --git a/engines/kyra/magic_eob.cpp b/engines/kyra/magic_eob.cpp index f828625dbb..70e4892342 100644 --- a/engines/kyra/magic_eob.cpp +++ b/engines/kyra/magic_eob.cpp @@ -555,11 +555,11 @@ bool EobCoreEngine::magicObjectDamageHit(EobFlyingObject *fo, int dcTimes, int d bool EobCoreEngine::magicObjectStatusHit(EobMonsterInPlay *m, int type, bool tryEvade, int mod) { EobMonsterProperty *p = &_monsterProps[m->type]; if (tryEvade) { - if (tryMonsterAttackEvasion(m) || (p->capsFlags & 0x10)) + if (tryMonsterAttackEvasion(m) || (p->immunityFlags & 0x10)) return true; } - if (checkUnkConstModifiers(m, 0, p->level, mod, 6)) + if (checkMonsterLevelConstModifiers(m, 0, p->level, mod, 6)) return false; int para = 0; @@ -569,7 +569,7 @@ bool EobCoreEngine::magicObjectStatusHit(EobMonsterInPlay *m, int type, bool try case 1: case 2: para = (type == 0) ? ((p->typeFlags & 1) ? 1 : 0) : ((type == 1) ? ((p->typeFlags & 2) ? 1 : 0) : 1); - if (para && !(p->statusFlags & 2)) { + if (para && !(p->immunityFlags & 2)) { m->mode = 10; m->spellStatusLeft = 15; } @@ -577,7 +577,7 @@ bool EobCoreEngine::magicObjectStatusHit(EobMonsterInPlay *m, int type, bool try break; case 3: - if (!(p->statusFlags & 8)) + if (!(p->immunityFlags & 8)) inflictMonsterDamage(m, 1000, true); break; @@ -591,12 +591,11 @@ bool EobCoreEngine::magicObjectStatusHit(EobMonsterInPlay *m, int type, bool try break; case 6: - if (!(p->statusFlags & 4) && m->mode != 7 && m->mode != 8 && m->mode != 10) { + if (!(_flags.gameID == GI_EOB1 && !(p->typeFlags & 3)) && !(p->immunityFlags & 4) && m->mode != 7 && m->mode != 8 && m->mode != 10) { m->mode = 0; m->spellStatusLeft = 20; - para = (getNextMonsterDirection(m->block, _currentBlock) ^ 4) >> 1; m->flags |= 8; - walkMonsterNextStep(m, -1, para); + walkMonsterNextStep(m, -1, (getNextMonsterDirection(m->block, _currentBlock) ^ 4) >> 1); } break; -- cgit v1.2.3 From aab9e62247af1c22772bb79821675fbab06c047d Mon Sep 17 00:00:00 2001 From: athrxx Date: Wed, 3 Aug 2011 00:40:21 +0200 Subject: KYRA: (EOB) - some more sequence code and bug fixes --- engines/kyra/magic_eob.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines/kyra/magic_eob.cpp') diff --git a/engines/kyra/magic_eob.cpp b/engines/kyra/magic_eob.cpp index 70e4892342..3eb7591413 100644 --- a/engines/kyra/magic_eob.cpp +++ b/engines/kyra/magic_eob.cpp @@ -75,7 +75,7 @@ void EobCoreEngine::useMagicScroll(int charIndex, int type, int weaponSlot) { } void EobCoreEngine::usePotion(int charIndex, int weaponSlot) { - EobCharacter *c = &_characters[_openBookChar]; + EobCharacter *c = &_characters[charIndex]; int val = deleteInventoryItem(charIndex, weaponSlot); snd_playSoundEffect(10); @@ -607,6 +607,7 @@ bool EobCoreEngine::magicObjectStatusHit(EobMonsterInPlay *m, int type, bool try } bool EobCoreEngine::turnUndeadHit(EobMonsterInPlay *m, int hitChance, int casterLevel) { + assert(_monsterProps[m->type].tuResist > 0); uint8 e = _turnUndeadEffect[_monsterProps[m->type].tuResist * 14 + MIN(casterLevel, 14)]; if (e == 0xff) { -- cgit v1.2.3 From bac0caeb0ff712fe9002985c44c1ea651b86e018 Mon Sep 17 00:00:00 2001 From: athrxx Date: Sat, 6 Aug 2011 00:40:53 +0200 Subject: KYRA: (EOB) - lots of fixes towards EOB1 playability also implement some new code (EOB1 portals, burning hands spell, etc.) --- engines/kyra/magic_eob.cpp | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'engines/kyra/magic_eob.cpp') diff --git a/engines/kyra/magic_eob.cpp b/engines/kyra/magic_eob.cpp index 3eb7591413..12d2524545 100644 --- a/engines/kyra/magic_eob.cpp +++ b/engines/kyra/magic_eob.cpp @@ -142,7 +142,7 @@ void EobCoreEngine::usePotion(int charIndex, int weaponSlot) { } void EobCoreEngine::useWand(int charIndex, int weaponSlot) { - int v = _items[_characters[charIndex].inventory[weaponSlot]].value - 1; + int v = _items[_characters[charIndex].inventory[weaponSlot]].value; if (!v) { _txt->printMessage(_wandStrings[0]); return; @@ -535,7 +535,7 @@ bool EobCoreEngine::magicObjectDamageHit(EobFlyingObject *fo, int dcTimes, int d if (!fo->item && (_characters[c].effectFlags & 8)) { res = true; } else { - if ((_characters[c].flags & 1) && hitTest && !monsterAttackHitTest(&_monsters[0], c)) { + if ((_characters[c].flags & 1) && (!hitTest || monsterAttackHitTest(&_monsters[0], c))) { int dmg = rollDice(dcTimes, dcPips, dcOffs) * level; res = true; calcAndInflictCharacterDamage(c, 0, 0, dmg, dmgFlag, s, dmgType); @@ -638,7 +638,31 @@ void EobCoreEngine::spellCallback_start_armor() { } void EobCoreEngine::spellCallback_start_burningHands() { + static const int16 bX[] = { 0, 152, 24, 120, 56, 88 }; + static const int8 bY[] = { 64, 64, 56, 56, 56, 56 }; + for (int i = 0; i < 6; i++) + drawBlockObject(i & 1, 0, _firebeamShapes[(5 - i) >> 1], bX[i], bY[i], 0); + _screen->updateScreen(); + delay(2 * _tickLength); + + int cl = getCharacterMageLevel(_openBookChar); + int bl = calcNewBlockPosition(_currentBlock, _currentDirection); + + const int8 *pos = getMonsterBlockPositions(bl); + _preventMonsterFlash = true; + + int numDest = (_flags.gameID == GI_EOB1) ? 2 : 6; + const uint8 *d = &_burningHandsDest[_currentDirection * (_flags.gameID == GI_EOB1 ? 2 : 8)]; + + for (int i = 0; i < numDest; i++, d++) { + if (pos[*d] == -1) + continue; + calcAndInflictMonsterDamage(&_monsters[pos[*d]], 1, 3, cl << 1, 0x21, 4, 0); + } + + updateAllMonsterShapes(); + _sceneUpdateRequired = true; } void EobCoreEngine::spellCallback_start_detectMagic() { @@ -949,6 +973,10 @@ void EobCoreEngine::spellCallback_start_turnUndead() { _preventMonsterFlash = false; } +bool EobCoreEngine::spellCallback_end_kuotoaAttack(EobFlyingObject *fo) { + return magicObjectDamageHit(fo, 0, 0, 12, 1); +} + bool EobCoreEngine::spellCallback_end_unk1Passive(EobFlyingObject *fo) { bool res = false; if (_partyEffectFlags & 0x20000) { -- cgit v1.2.3 From fc5b29fdbcf4170436a32da2c1f4b078b1f1f90f Mon Sep 17 00:00:00 2001 From: athrxx Date: Sun, 7 Aug 2011 03:31:15 +0200 Subject: KYRA: (EOB) - implemented some spells and fixed more bugs --- engines/kyra/magic_eob.cpp | 132 ++++++++++++++++++++++++++++++++------------- 1 file changed, 96 insertions(+), 36 deletions(-) (limited to 'engines/kyra/magic_eob.cpp') diff --git a/engines/kyra/magic_eob.cpp b/engines/kyra/magic_eob.cpp index 12d2524545..d06e15b36f 100644 --- a/engines/kyra/magic_eob.cpp +++ b/engines/kyra/magic_eob.cpp @@ -184,7 +184,7 @@ void EobCoreEngine::castSpell(int spell, int weaponSlot) { if (ci > 3) ci -= 2; - _activeSpellCasterPos = _dropItemDirIndex[(_currentDirection << 2) + ci]; + _activeSpellCharacterPos = _dropItemDirIndex[(_currentDirection << 2) + ci]; if (s->flags & 0x400) { if (c->inventory[0] && c->inventory[1]) { @@ -226,7 +226,7 @@ void EobCoreEngine::castSpell(int spell, int weaponSlot) { return; } - _activeSpellCaster = _openBookChar; + _activeSpellCharId = _openBookChar; startSpell(spell); } @@ -258,7 +258,7 @@ void EobCoreEngine::removeCharacterEffect(int spell, int charIndex, int showWarn } if (s->flags & 0x2) - recalcArmorClass(_activeSpellCaster); + recalcArmorClass(_activeSpellCharId); if (showWarning) { if (s->flags & 0x20A0) @@ -296,11 +296,11 @@ void EobCoreEngine::castOnWhomDialogue() { void EobCoreEngine::startSpell(int spell) { EobSpell *s = &_spells[spell]; - EobCharacter *c = &_characters[_activeSpellCaster]; + EobCharacter *c = &_characters[_activeSpellCharId]; snd_playSoundEffect(s->sound); if (s->flags & 0xa0) - sparkEffectDefensive(_activeSpellCaster); + sparkEffectDefensive(_activeSpellCharId); else if (s->flags & 0x40) sparkEffectDefensive(-1); else if (s->flags & 0x1000) @@ -312,9 +312,17 @@ void EobCoreEngine::startSpell(int spell) { } if ((s->flags & 0x30) && (s->effectFlags & c->effectFlags)) { - printWarning(Common::String::format(_magicStrings7[0], c->name, s->name).c_str()); + if (_flags.gameID == GI_EOB1) { + // TODO: warnings seem to exist at least for bless and aid + } else { + printWarning(Common::String::format(_magicStrings7[0], c->name, s->name).c_str()); + } } else if ((s->flags & 0x50) && (s->effectFlags & _partyEffectFlags)) { - printWarning(Common::String::format(_magicStrings7[1], s->name).c_str()); + if (_flags.gameID == GI_EOB1) { + // TODO: warnings seem to exist at least for bless and aid + } else { + printWarning(Common::String::format(_magicStrings7[1], s->name).c_str()); + } } else { if (s->flags & 8) setSpellEventTimer(spell, s->timingPara[0], s->timingPara[1], s->timingPara[2], s->timingPara[3]); @@ -341,10 +349,10 @@ void EobCoreEngine::startSpell(int spell) { } if (s->flags & 2) - recalcArmorClass(_activeSpellCaster); + recalcArmorClass(_activeSpellCharId); if (s->flags & 0x20A0) - gui_drawCharPortraitWithStats(_activeSpellCaster); + gui_drawCharPortraitWithStats(_activeSpellCharId); if (s->flags & 0x40) gui_drawAllCharPortraitsWithStats(); } @@ -438,7 +446,7 @@ void EobCoreEngine::sparkEffectOffensive() { void EobCoreEngine::setSpellEventTimer(int spell, int timerBaseFactor, int timerLength, int timerLevelFactor, int updateExistingTimer) { int l = _openBookType == 1 ? getCharacterClericPaladinLevel(_openBookChar) : getCharacterMageLevel(_openBookChar); uint32 countdown = timerLength * timerBaseFactor + timerLength * l * timerLevelFactor; - setCharEventTimer(_activeSpellCaster, countdown, -spell, updateExistingTimer); + setCharEventTimer(_activeSpellCharId, countdown, -spell, updateExistingTimer); } void EobCoreEngine::sortCharacterSpellList(int charIndex) { @@ -624,7 +632,23 @@ bool EobCoreEngine::turnUndeadHit(EobMonsterInPlay *m, int hitChance, int caster return true; } -void EobCoreEngine::printWarning(const char* str) { +int EobCoreEngine::findSingleSpellTarget(int dist) { + uint16 bl = _currentBlock; + int res = -1; + + for (int i = 0; i < dist && res == -1; i++) { + bl = calcNewBlockPosition(bl, _currentDirection); + res = getClosestMonster(_openBookChar, bl); + if (!(_wllWallFlags[_levelBlockProperties[bl].walls[_sceneDrawVarDown]] & 1)) { + i = dist; + res = -1; + } + } + + return res; +} + +void EobCoreEngine::printWarning(const char *str) { _txt->printMessage(str); snd_playSoundEffect(79); } @@ -634,7 +658,9 @@ void EobCoreEngine::printNoEffectWarning() { } void EobCoreEngine::spellCallback_start_armor() { - + _characters[_activeSpellCharId].effectsRemainder[0] = getCharacterMageLevel(_openBookChar) + 8; + if ((getDexterityArmorClassModifier(_characters[_activeSpellCharId].dexterityCur) + 6) >= _characters[_activeSpellCharId].armorClass) + printWarning(Common::String::format(_magicStrings6[0], _characters[_activeSpellCharId].name).c_str()); } void EobCoreEngine::spellCallback_start_burningHands() { @@ -649,7 +675,7 @@ void EobCoreEngine::spellCallback_start_burningHands() { int cl = getCharacterMageLevel(_openBookChar); int bl = calcNewBlockPosition(_currentBlock, _currentDirection); - const int8 *pos = getMonsterBlockPositions(bl); + const int8 *pos = getMonstersOnBlockPositions(bl); _preventMonsterFlash = true; int numDest = (_flags.gameID == GI_EOB1) ? 2 : 6; @@ -674,7 +700,7 @@ bool EobCoreEngine::spellCallback_end_detectMagic(EobFlyingObject*) { } void EobCoreEngine::spellCallback_start_magicMissile() { - launchMagicObject(_openBookChar, 0, _currentBlock, _activeSpellCasterPos, _currentDirection); + launchMagicObject(_openBookChar, 0, _currentBlock, _activeSpellCharacterPos, _currentDirection); } bool EobCoreEngine::spellCallback_end_magicMissile(EobFlyingObject *fo) { @@ -694,10 +720,11 @@ void EobCoreEngine::spellCallback_start_improvedIdentify() { } void EobCoreEngine::spellCallback_start_melfsAcidArrow() { - launchMagicObject(_openBookChar, 1, _currentBlock, _activeSpellCasterPos, _currentDirection); + launchMagicObject(_openBookChar, 1, _currentBlock, _activeSpellCharacterPos, _currentDirection); } bool EobCoreEngine::spellCallback_end_melfsAcidArrow(EobFlyingObject *fo) { + assert(fo); return magicObjectDamageHit(fo, 2, 4, 0, getCharacterMageLevel(fo->attackerId) / 3); } @@ -706,7 +733,7 @@ void EobCoreEngine::spellCallback_start_dispelMagic() { } void EobCoreEngine::spellCallback_start_fireball() { - launchMagicObject(_openBookChar, 2, _currentBlock, _activeSpellCasterPos, _currentDirection); + launchMagicObject(_openBookChar, 2, _currentBlock, _activeSpellCharacterPos, _currentDirection); } bool EobCoreEngine::spellCallback_end_fireball(EobFlyingObject *fo) { @@ -714,7 +741,7 @@ bool EobCoreEngine::spellCallback_end_fireball(EobFlyingObject *fo) { } void EobCoreEngine::spellCallback_start_flameArrow() { - launchMagicObject(_openBookChar, 3, _currentBlock, _activeSpellCasterPos, _currentDirection); + launchMagicObject(_openBookChar, 3, _currentBlock, _activeSpellCharacterPos, _currentDirection); } bool EobCoreEngine::spellCallback_end_flameArrow(EobFlyingObject *fo) { @@ -722,7 +749,7 @@ bool EobCoreEngine::spellCallback_end_flameArrow(EobFlyingObject *fo) { } void EobCoreEngine::spellCallback_start_holdPerson() { - launchMagicObject(_openBookChar, _flags.gameID == GI_EOB1 ? 4 : 3, _currentBlock, _activeSpellCasterPos, _currentDirection); + launchMagicObject(_openBookChar, _flags.gameID == GI_EOB1 ? 4 : 3, _currentBlock, _activeSpellCharacterPos, _currentDirection); } bool EobCoreEngine::spellCallback_end_holdPerson(EobFlyingObject *fo) { @@ -751,7 +778,7 @@ bool EobCoreEngine::spellCallback_end_holdPerson(EobFlyingObject *fo) { } void EobCoreEngine::spellCallback_start_lightningBolt() { - launchMagicObject(_openBookChar, _flags.gameID == GI_EOB1 ? 5 : 4, _currentBlock, _activeSpellCasterPos, _currentDirection); + launchMagicObject(_openBookChar, _flags.gameID == GI_EOB1 ? 5 : 4, _currentBlock, _activeSpellCharacterPos, _currentDirection); } bool EobCoreEngine::spellCallback_end_lightningBolt(EobFlyingObject *fo) { @@ -776,7 +803,7 @@ void EobCoreEngine::spellCallback_start_fear() { } void EobCoreEngine::spellCallback_start_iceStorm() { - launchMagicObject(_openBookChar, _flags.gameID == GI_EOB1 ? 6 : 5, _currentBlock, _activeSpellCasterPos, _currentDirection); + launchMagicObject(_openBookChar, _flags.gameID == GI_EOB1 ? 6 : 5, _currentBlock, _activeSpellCharacterPos, _currentDirection); } bool EobCoreEngine::spellCallback_end_iceStorm(EobFlyingObject *fo) { @@ -794,15 +821,32 @@ bool EobCoreEngine::spellCallback_end_iceStorm(EobFlyingObject *fo) { } void EobCoreEngine::spellCallback_start_removeCurse() { - + for (int i = 0; i < 27; i++) { + Item itm = _characters[_activeSpellCharId].inventory[i]; + if (itm && (_items[itm].flags & 0x20) && !isMagicWeapon(itm)) + _items[itm].flags = (_items[itm].flags & ~0x20) | 0x40; + } } void EobCoreEngine::spellCallback_start_coneOfCold() { + static const int8 *dirTables[] = { _coneOfColdDest1, _coneOfColdDest2, _coneOfColdDest3, _coneOfColdDest4 }; + + int cl = getCharacterMageLevel(_openBookChar); + //drawConeOfColdEffect(150, 50, 10, 1, 100, _coneOfColdGfxTbl); + + const int8 *tbl = dirTables[_currentDirection]; + _preventMonsterFlash = true; + + for (int i = 0; i < 7; i++) { + for (const int16 *m = findBlockMonsters((_currentBlock + tbl[i]) & 0x3ff, 4, _currentDirection, 1, 1); *m != -1; m++) + calcAndInflictMonsterDamage(&_monsters[*m], cl, 4, cl, 0x41, 5, 0); + } + updateAllMonsterShapes(); } void EobCoreEngine::spellCallback_start_holdMonster() { - + launchMagicObject(_openBookChar, _flags.gameID == GI_EOB1 ? 7 : 6, _currentBlock, _activeSpellCharacterPos, _currentDirection); } bool EobCoreEngine::spellCallback_end_holdMonster(EobFlyingObject *fo) { @@ -817,12 +861,16 @@ void EobCoreEngine::spellCallback_start_wallOfForce() { } void EobCoreEngine::spellCallback_start_disintegrate() { - + int d = findSingleSpellTarget(1); + if (d != -1) + magicObjectStatusHit(&_monsters[d], 4, true, 4); + memset(_visibleBlocks[13]->walls, 0, 4); + _sceneUpdateRequired = true; } void EobCoreEngine::spellCallback_start_fleshToStone() { sparkEffectOffensive(); - int t = getClosestMonsterPos(_openBookChar, calcNewBlockPosition(_currentBlock, _currentDirection)); + int t = getClosestMonster(_openBookChar, calcNewBlockPosition(_currentBlock, _currentDirection)); if (t != -1) magicObjectStatusHit(&_monsters[t], 5, true, 4); else @@ -830,8 +878,8 @@ void EobCoreEngine::spellCallback_start_fleshToStone() { } void EobCoreEngine::spellCallback_start_stoneToFlesh() { - if (_characters[_activeSpellCaster].flags & 8) - _characters[_activeSpellCaster].flags &= ~8; + if (_characters[_activeSpellCharId].flags & 8) + _characters[_activeSpellCharId].flags &= ~8; else printNoEffectWarning(); } @@ -846,11 +894,18 @@ bool EobCoreEngine::spellCallback_end_trueSeeing(EobFlyingObject*) { } void EobCoreEngine::spellCallback_start_slayLiving() { - + int d = findSingleSpellTarget(2); + if (d != -1) + if (!magicObjectStatusHit(&_monsters[d], 3, true, 4)) + inflictMonsterDamage(&_monsters[d], rollDice(2, 8, 1), true); } void EobCoreEngine::spellCallback_start_powerWordStun() { - + int d = findSingleSpellTarget(2); + if (d != -1) { + if (_monsters[d].hitPointsCur < 90) + magicObjectStatusHit(&_monsters[d], 5, true, 4); + } } void EobCoreEngine::spellCallback_start_causeLightWounds() { @@ -858,7 +913,7 @@ void EobCoreEngine::spellCallback_start_causeLightWounds() { } void EobCoreEngine::spellCallback_start_cureLightWounds() { - modifyCharacterHitpoints(_activeSpellCaster, rollDice(1, 8)); + modifyCharacterHitpoints(_activeSpellCharId, rollDice(1, 8)); } void EobCoreEngine::spellCallback_start_aid() { @@ -904,7 +959,7 @@ void EobCoreEngine::spellCallback_start_causeSeriousWounds() { } void EobCoreEngine::spellCallback_start_cureSeriousWounds() { - modifyCharacterHitpoints(_activeSpellCaster, rollDice(2, 8, 1)); + modifyCharacterHitpoints(_activeSpellCharId, rollDice(2, 8, 1)); } void EobCoreEngine::spellCallback_start_neutralizePoison() { @@ -916,11 +971,11 @@ void EobCoreEngine::spellCallback_start_causeCriticalWounds() { } void EobCoreEngine::spellCallback_start_cureCriticalWounds() { - modifyCharacterHitpoints(_activeSpellCaster, rollDice(3, 8, 3)); + modifyCharacterHitpoints(_activeSpellCharId, rollDice(3, 8, 3)); } void EobCoreEngine::spellCallback_start_flameStrike() { - launchMagicObject(_openBookChar, _flags.gameID == GI_EOB1 ? 8 : 7, _currentBlock, _activeSpellCasterPos, _currentDirection); + launchMagicObject(_openBookChar, _flags.gameID == GI_EOB1 ? 8 : 7, _currentBlock, _activeSpellCharacterPos, _currentDirection); } bool EobCoreEngine::spellCallback_end_flameStrike(EobFlyingObject *fo) { @@ -928,7 +983,12 @@ bool EobCoreEngine::spellCallback_end_flameStrike(EobFlyingObject *fo) { } void EobCoreEngine::spellCallback_start_raiseDead() { - + if (_characters[_activeSpellCharId].hitPointsCur == -10 || ((_characters[_activeSpellCharId].raceSex >> 1) == 1)) { + _characters[_activeSpellCharId].hitPointsCur = 1; + gui_drawCharPortraitWithStats(_activeSpellCharId); + } else { + printNoEffectWarning(); + } } void EobCoreEngine::spellCallback_start_harm() { @@ -936,15 +996,15 @@ void EobCoreEngine::spellCallback_start_harm() { } void EobCoreEngine::spellCallback_start_heal() { - EobCharacter *c = &_characters[_activeSpellCaster]; + EobCharacter *c = &_characters[_activeSpellCharId]; if (c->hitPointsMax <= c->hitPointsCur) printWarning(_magicStrings4[0]); else - modifyCharacterHitpoints(_activeSpellCaster, c->hitPointsMax - c->hitPointsCur); + modifyCharacterHitpoints(_activeSpellCharId, c->hitPointsMax - c->hitPointsCur); } void EobCoreEngine::spellCallback_start_layOnHands() { - modifyCharacterHitpoints(_activeSpellCaster, _characters[_openBookChar].level[0] << 1); + modifyCharacterHitpoints(_activeSpellCharId, _characters[_openBookChar].level[0] << 1); } void EobCoreEngine::spellCallback_start_turnUndead() { -- cgit v1.2.3 From 359f3efd03704965d258c90381412a5ef2cf9239 Mon Sep 17 00:00:00 2001 From: athrxx Date: Sun, 7 Aug 2011 22:14:10 +0200 Subject: KYRA: (EOB) - add some spells (shocking grasp, flame blade, vampiric touch etc.) --- engines/kyra/magic_eob.cpp | 243 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 195 insertions(+), 48 deletions(-) (limited to 'engines/kyra/magic_eob.cpp') diff --git a/engines/kyra/magic_eob.cpp b/engines/kyra/magic_eob.cpp index d06e15b36f..88046fd3a5 100644 --- a/engines/kyra/magic_eob.cpp +++ b/engines/kyra/magic_eob.cpp @@ -192,7 +192,7 @@ void EobCoreEngine::castSpell(int spell, int weaponSlot) { return; } - if (isMagicWeapon(c->inventory[0]) || isMagicWeapon(c->inventory[1])) { + if (isMagicEffectItem(c->inventory[0]) || isMagicEffectItem(c->inventory[1])) { printWarning(_magicStrings1[3]); return; } @@ -239,7 +239,7 @@ void EobCoreEngine::removeCharacterEffect(int spell, int charIndex, int showWarn printWarning(Common::String::format(_magicStrings3[_flags.gameID == GI_EOB1 ? 3 : 2], c->name, s->name).c_str()); if (s->endCallback) - (this->*s->endCallback)(0); + (this->*s->endCallback)(c); if (s->flags & 1) c->effectFlags &= ~s->effectFlags; @@ -270,13 +270,15 @@ void EobCoreEngine::removeCharacterEffect(int spell, int charIndex, int showWarn void EobCoreEngine::removeAllCharacterEffects(int charIndex) { EobCharacter *c = &_characters[charIndex]; + c->effectFlags = 0; memset(c->effectsRemainder, 0, 4); for (int i = 0; i < 10; i++) { - if (c->events[i] < 0) + if (c->events[i] < 0) { removeCharacterEffect(-c->events[i], charIndex, 0); - c->timers[i] = 0; - c->events[i] = 0; + c->timers[i] = 0; + c->events[i] = 0; + } } setupCharacterTimers(); @@ -444,7 +446,7 @@ void EobCoreEngine::sparkEffectOffensive() { } void EobCoreEngine::setSpellEventTimer(int spell, int timerBaseFactor, int timerLength, int timerLevelFactor, int updateExistingTimer) { - int l = _openBookType == 1 ? getCharacterClericPaladinLevel(_openBookChar) : getCharacterMageLevel(_openBookChar); + int l = _openBookType == 1 ? getClericPaladinLevel(_openBookChar) : getMageLevel(_openBookChar); uint32 countdown = timerLength * timerBaseFactor + timerLength * l * timerLevelFactor; setCharEventTimer(_activeSpellCharId, countdown, -spell, updateExistingTimer); } @@ -632,6 +634,63 @@ bool EobCoreEngine::turnUndeadHit(EobMonsterInPlay *m, int hitChance, int caster return true; } +int EobCoreEngine::getMagicWeaponSlot(int charIndex) { + return _characters[charIndex].inventory[1] ? 0 : 1; +} + +int EobCoreEngine::createMagicWeaponType(int invFlags, int handFlags, int armorClass, int allowedClasses, int dmgNumDice, int dmgPips, int dmgInc, int extraProps) { + int i = 51; + for (; i < 57; i++) { + if (_itemTypes[i].armorClass == -30) + break; + } + + if (i == 57) + return -1; + + EobItemType *tp = &_itemTypes[i]; + tp->invFlags = invFlags; + tp->requiredHands = 0; + tp->handFlags = handFlags; + tp->armorClass = armorClass; + tp->allowedClasses = allowedClasses; + tp->dmgNumDiceL = tp->dmgNumDiceS = dmgNumDice; + tp->dmgNumPipsL = tp->dmgNumPipsL = dmgPips; + tp->dmgIncL = tp->dmgIncS = dmgInc; + tp->extraProperties = extraProps; + + return i; +} + +Item EobCoreEngine::createMagicWeaponItem(int flags, int icon, int value, int type) { + Item i = 11; + for (; i < 17; i++) { + if (_items[i].block == -2) + break; + } + + if (i == 17) + return -1; + + EobItem *itm = &_items[i]; + itm->flags = 0x20 | flags; + itm->icon = icon; + itm->value = value; + itm->type = type; + itm->pos = 0; + itm->block = 0; + itm->nameId = itm->nameUnid = 0; + itm->prev = itm->next = 0; + + return i; +} + +void EobCoreEngine::removeMagicWeaponItem(Item item) { + _itemTypes[_items[item].type].armorClass = -30; + _items[item].block = -2; + _items[item].level = -1; +} + int EobCoreEngine::findSingleSpellTarget(int dist) { uint16 bl = _currentBlock; int res = -1; @@ -658,7 +717,7 @@ void EobCoreEngine::printNoEffectWarning() { } void EobCoreEngine::spellCallback_start_armor() { - _characters[_activeSpellCharId].effectsRemainder[0] = getCharacterMageLevel(_openBookChar) + 8; + _characters[_activeSpellCharId].effectsRemainder[0] = getMageLevel(_openBookChar) + 8; if ((getDexterityArmorClassModifier(_characters[_activeSpellCharId].dexterityCur) + 6) >= _characters[_activeSpellCharId].armorClass) printWarning(Common::String::format(_magicStrings6[0], _characters[_activeSpellCharId].name).c_str()); } @@ -672,7 +731,7 @@ void EobCoreEngine::spellCallback_start_burningHands() { _screen->updateScreen(); delay(2 * _tickLength); - int cl = getCharacterMageLevel(_openBookChar); + int cl = getMageLevel(_openBookChar); int bl = calcNewBlockPosition(_currentBlock, _currentDirection); const int8 *pos = getMonstersOnBlockPositions(bl); @@ -692,10 +751,11 @@ void EobCoreEngine::spellCallback_start_burningHands() { } void EobCoreEngine::spellCallback_start_detectMagic() { - + setHandItem(_itemInHand); } -bool EobCoreEngine::spellCallback_end_detectMagic(EobFlyingObject*) { +bool EobCoreEngine::spellCallback_end_detectMagic(void*) { + setHandItem(_itemInHand); return true; } @@ -703,15 +763,33 @@ void EobCoreEngine::spellCallback_start_magicMissile() { launchMagicObject(_openBookChar, 0, _currentBlock, _activeSpellCharacterPos, _currentDirection); } -bool EobCoreEngine::spellCallback_end_magicMissile(EobFlyingObject *fo) { - return magicObjectDamageHit(fo, 1, 4, 1, (getCharacterMageLevel(fo->attackerId) - 1) >> 1); +bool EobCoreEngine::spellCallback_end_magicMissile(void *obj) { + EobFlyingObject *fo = (EobFlyingObject*)obj; + return magicObjectDamageHit(fo, 1, 4, 1, (getMageLevel(fo->attackerId) - 1) >> 1); } void EobCoreEngine::spellCallback_start_shockingGrasp() { - + int t = createMagicWeaponType(0, 0, 0, 0x0f, 1, 8, getMageLevel(_openBookChar), 1); + Item i = (t != -1) ? createMagicWeaponItem(0x10, 82, 0, t) : -1; + if (t == -1 || i == -1) { + if (_flags.gameID == GI_EOB2) + printWarning(_magicStrings8[0]); + removeCharacterEffect(_activeSpell, _activeSpellCharId, 0); + deleteCharEventTimer(_activeSpellCharId, -_activeSpell); + _returnAfterSpellCallback = true; + } else { + _characters[_activeSpellCharId].inventory[getMagicWeaponSlot(_activeSpellCharId)] = i; + } } -bool EobCoreEngine::spellCallback_end_shockingGraspFlameBlade(EobFlyingObject*) { +bool EobCoreEngine::spellCallback_end_shockingGraspFlameBlade(void *obj) { + EobCharacter *c = (EobCharacter*)obj; + for (int i = 0; i < 2; i++) { + if (isMagicEffectItem(c->inventory[i])) { + removeMagicWeaponItem(c->inventory[i]); + c->inventory[i] = 0; + } + } return true; } @@ -723,36 +801,43 @@ void EobCoreEngine::spellCallback_start_melfsAcidArrow() { launchMagicObject(_openBookChar, 1, _currentBlock, _activeSpellCharacterPos, _currentDirection); } -bool EobCoreEngine::spellCallback_end_melfsAcidArrow(EobFlyingObject *fo) { +bool EobCoreEngine::spellCallback_end_melfsAcidArrow(void *obj) { + EobFlyingObject *fo = (EobFlyingObject*)obj; assert(fo); - return magicObjectDamageHit(fo, 2, 4, 0, getCharacterMageLevel(fo->attackerId) / 3); + return magicObjectDamageHit(fo, 2, 4, 0, getMageLevel(fo->attackerId) / 3); } void EobCoreEngine::spellCallback_start_dispelMagic() { - + for (int i = 0; i < 6; i++) { + if (testCharacter(i, 1)) + removeAllCharacterEffects(i); + } } void EobCoreEngine::spellCallback_start_fireball() { launchMagicObject(_openBookChar, 2, _currentBlock, _activeSpellCharacterPos, _currentDirection); } -bool EobCoreEngine::spellCallback_end_fireball(EobFlyingObject *fo) { - return magicObjectDamageHit(fo, 1, 6, 0, getCharacterMageLevel(fo->attackerId)); +bool EobCoreEngine::spellCallback_end_fireball(void *obj) { + EobFlyingObject *fo = (EobFlyingObject*)obj; + return magicObjectDamageHit(fo, 1, 6, 0, getMageLevel(fo->attackerId)); } void EobCoreEngine::spellCallback_start_flameArrow() { launchMagicObject(_openBookChar, 3, _currentBlock, _activeSpellCharacterPos, _currentDirection); } -bool EobCoreEngine::spellCallback_end_flameArrow(EobFlyingObject *fo) { - return magicObjectDamageHit(fo, 5, 6, 0, getCharacterMageLevel(fo->attackerId)); +bool EobCoreEngine::spellCallback_end_flameArrow(void *obj) { + EobFlyingObject *fo = (EobFlyingObject*)obj; + return magicObjectDamageHit(fo, 5, 6, 0, getMageLevel(fo->attackerId)); } void EobCoreEngine::spellCallback_start_holdPerson() { launchMagicObject(_openBookChar, _flags.gameID == GI_EOB1 ? 4 : 3, _currentBlock, _activeSpellCharacterPos, _currentDirection); } -bool EobCoreEngine::spellCallback_end_holdPerson(EobFlyingObject *fo) { +bool EobCoreEngine::spellCallback_end_holdPerson(void *obj) { + EobFlyingObject *fo = (EobFlyingObject*)obj; bool res = false; if (_flags.gameID == GI_EOB2 && fo->curBlock == _currentBlock) { @@ -781,15 +866,30 @@ void EobCoreEngine::spellCallback_start_lightningBolt() { launchMagicObject(_openBookChar, _flags.gameID == GI_EOB1 ? 5 : 4, _currentBlock, _activeSpellCharacterPos, _currentDirection); } -bool EobCoreEngine::spellCallback_end_lightningBolt(EobFlyingObject *fo) { - return magicObjectDamageHit(fo, 1, 6, 0, getCharacterMageLevel(fo->attackerId)); +bool EobCoreEngine::spellCallback_end_lightningBolt(void *obj) { + EobFlyingObject *fo = (EobFlyingObject*)obj; + return magicObjectDamageHit(fo, 1, 6, 0, getMageLevel(fo->attackerId)); } void EobCoreEngine::spellCallback_start_vampiricTouch() { - + int t = createMagicWeaponType(0, 0, 0, 0x0f, getMageLevel(_openBookChar) >> 1, 6, 0, 1); + Item i = (t != -1) ? createMagicWeaponItem(0x18, 83, 0, t) : -1; + if (t == -1 || i == -1) { + if (_flags.gameID == GI_EOB2) + printWarning(_magicStrings8[0]); + removeCharacterEffect(_activeSpell, _activeSpellCharId, 0); + deleteCharEventTimer(_activeSpellCharId, -_activeSpell); + _returnAfterSpellCallback = true; + } else { + _characters[_activeSpellCharId].inventory[getMagicWeaponSlot(_activeSpellCharId)] = i; + } } -bool EobCoreEngine::spellCallback_end_vampiricTouch(EobFlyingObject*) { +bool EobCoreEngine::spellCallback_end_vampiricTouch(void *obj) { + EobCharacter *c = (EobCharacter*)obj; + if (c->hitPointsCur > c->hitPointsMax) + c->hitPointsCur = c->hitPointsMax; + spellCallback_end_shockingGraspFlameBlade(obj); return true; } @@ -806,24 +906,29 @@ void EobCoreEngine::spellCallback_start_iceStorm() { launchMagicObject(_openBookChar, _flags.gameID == GI_EOB1 ? 6 : 5, _currentBlock, _activeSpellCharacterPos, _currentDirection); } -bool EobCoreEngine::spellCallback_end_iceStorm(EobFlyingObject *fo) { +bool EobCoreEngine::spellCallback_end_iceStorm(void *obj) { + EobFlyingObject *fo = (EobFlyingObject*)obj; static int8 blockAdv[] = { -32, 32, 1, -1 }; - bool res = magicObjectDamageHit(fo, 1, 6, 0, getCharacterMageLevel(fo->attackerId)); + bool res = magicObjectDamageHit(fo, 1, 6, 0, getMageLevel(fo->attackerId)); if (res) { for (int i = 0; i < 4; i++) { uint16 bl = fo->curBlock; fo->curBlock = (fo->curBlock + blockAdv[i]) & 0x3ff; - magicObjectDamageHit(fo, 1, 6, 0, getCharacterMageLevel(fo->attackerId)); + magicObjectDamageHit(fo, 1, 6, 0, getMageLevel(fo->attackerId)); fo->curBlock = bl; } } return res; } +void EobCoreEngine::spellCallback_start_stoneSkin() { + _characters[_activeSpellCharId].effectsRemainder[1] = (getMageLevel(_openBookChar) >> 1) + rollDice(1, 4); +} + void EobCoreEngine::spellCallback_start_removeCurse() { for (int i = 0; i < 27; i++) { Item itm = _characters[_activeSpellCharId].inventory[i]; - if (itm && (_items[itm].flags & 0x20) && !isMagicWeapon(itm)) + if (itm && (_items[itm].flags & 0x20) && !isMagicEffectItem(itm)) _items[itm].flags = (_items[itm].flags & ~0x20) | 0x40; } } @@ -831,7 +936,7 @@ void EobCoreEngine::spellCallback_start_removeCurse() { void EobCoreEngine::spellCallback_start_coneOfCold() { static const int8 *dirTables[] = { _coneOfColdDest1, _coneOfColdDest2, _coneOfColdDest3, _coneOfColdDest4 }; - int cl = getCharacterMageLevel(_openBookChar); + int cl = getMageLevel(_openBookChar); //drawConeOfColdEffect(150, 50, 10, 1, 100, _coneOfColdGfxTbl); const int8 *tbl = dirTables[_currentDirection]; @@ -849,7 +954,8 @@ void EobCoreEngine::spellCallback_start_holdMonster() { launchMagicObject(_openBookChar, _flags.gameID == GI_EOB1 ? 7 : 6, _currentBlock, _activeSpellCharacterPos, _currentDirection); } -bool EobCoreEngine::spellCallback_end_holdMonster(EobFlyingObject *fo) { +bool EobCoreEngine::spellCallback_end_holdMonster(void *obj) { + EobFlyingObject *fo = (EobFlyingObject*)obj; bool res = false; for (const int16 *m = findBlockMonsters(fo->curBlock, fo->curPos, fo->direction, 1, 1); *m != -1; m++) res |= magicObjectStatusHit(&_monsters[*m], 1, true, 4); @@ -888,16 +994,17 @@ void EobCoreEngine::spellCallback_start_trueSeeing() { _wllVmpMap[46] = 0; } -bool EobCoreEngine::spellCallback_end_trueSeeing(EobFlyingObject*) { +bool EobCoreEngine::spellCallback_end_trueSeeing(void*) { _wllVmpMap[46] = 1; return true; } void EobCoreEngine::spellCallback_start_slayLiving() { int d = findSingleSpellTarget(2); - if (d != -1) + if (d != -1) { if (!magicObjectStatusHit(&_monsters[d], 3, true, 4)) inflictMonsterDamage(&_monsters[d], rollDice(2, 8, 1), true); + } } void EobCoreEngine::spellCallback_start_powerWordStun() { @@ -917,22 +1024,55 @@ void EobCoreEngine::spellCallback_start_cureLightWounds() { } void EobCoreEngine::spellCallback_start_aid() { + if (!testCharacter(_activeSpellCharId, 3)) { + printNoEffectWarning(); + } else if (_characters[_activeSpellCharId].effectsRemainder[3]) { + printWarning(Common::String::format(_magicStrings8[(_flags.gameID == GI_EOB1) ? 2 : 5], _characters[_activeSpellCharId].name).c_str()); + } else { + _characters[_activeSpellCharId].effectsRemainder[3] = rollDice(1, 8); + _characters[_activeSpellCharId].hitPointsCur += _characters[_activeSpellCharId].effectsRemainder[3]; + _characters[_activeSpellCharId].effectFlags |= 0x1000; + return; + } + removeCharacterEffect(_activeSpell, _activeSpellCharId, 0); + deleteCharEventTimer(_activeSpellCharId, -_activeSpell); } -bool EobCoreEngine::spellCallback_end_aid(EobFlyingObject*) { +bool EobCoreEngine::spellCallback_end_aid(void *obj) { + EobCharacter *c = (EobCharacter*)obj; + c->hitPointsCur -= c->effectsRemainder[3]; + c->effectsRemainder[3] = 0; + c->effectFlags &= ~0x1000; return true; } void EobCoreEngine::spellCallback_start_flameBlade() { - + int t = createMagicWeaponType(0, 0, 0, 0x0f, 1, 4, 4, 1); + Item i = (t != -1) ? createMagicWeaponItem(0, 84, 0, t) : -1; + if (t == -1 || i == -1) { + if (_flags.gameID == GI_EOB2) + printWarning(_magicStrings8[0]); + removeCharacterEffect(_activeSpell, _activeSpellCharId, 0); + deleteCharEventTimer(_activeSpellCharId, -_activeSpell); + _returnAfterSpellCallback = true; + } else { + _characters[_activeSpellCharId].inventory[getMagicWeaponSlot(_activeSpellCharId)] = i; + } } void EobCoreEngine::spellCallback_start_slowPoison() { - + if (_characters[_activeSpellCharId].flags & 2) { + _characters[_activeSpellCharId].effectFlags |= 0x2000; + setSpellEventTimer(_activeSpell, 1, 32760, 1, 1); + } else { + printNoEffectWarning(); + } } -bool EobCoreEngine::spellCallback_end_slowPoison(EobFlyingObject*) { +bool EobCoreEngine::spellCallback_end_slowPoison(void *obj) { + EobCharacter *c = (EobCharacter*)obj; + c->effectFlags &= ~0x2000; return true; } @@ -963,7 +1103,10 @@ void EobCoreEngine::spellCallback_start_cureSeriousWounds() { } void EobCoreEngine::spellCallback_start_neutralizePoison() { - + if (_characters[_activeSpellCharId].flags & 2) + neutralizePoison(_activeSpellCharId); + else + printNoEffectWarning(); } void EobCoreEngine::spellCallback_start_causeCriticalWounds() { @@ -978,7 +1121,8 @@ void EobCoreEngine::spellCallback_start_flameStrike() { launchMagicObject(_openBookChar, _flags.gameID == GI_EOB1 ? 8 : 7, _currentBlock, _activeSpellCharacterPos, _currentDirection); } -bool EobCoreEngine::spellCallback_end_flameStrike(EobFlyingObject *fo) { +bool EobCoreEngine::spellCallback_end_flameStrike(void *obj) { + EobFlyingObject *fo = (EobFlyingObject*)obj; return magicObjectDamageHit(fo, 6, 8, 0, 0); } @@ -1012,7 +1156,7 @@ void EobCoreEngine::spellCallback_start_turnUndead() { if (!(_levelBlockProperties[bl].flags & 7)) return; - int cl = _openBookCasterLevel ? _openBookCasterLevel : getCharacterClericPaladinLevel(_openBookChar); + int cl = _openBookCasterLevel ? _openBookCasterLevel : getClericPaladinLevel(_openBookChar); int r = rollDice(1, 20); bool hit = false; @@ -1033,11 +1177,13 @@ void EobCoreEngine::spellCallback_start_turnUndead() { _preventMonsterFlash = false; } -bool EobCoreEngine::spellCallback_end_kuotoaAttack(EobFlyingObject *fo) { +bool EobCoreEngine::spellCallback_end_lightningBoltPassive(void *obj) { + EobFlyingObject *fo = (EobFlyingObject*)obj; return magicObjectDamageHit(fo, 0, 0, 12, 1); } -bool EobCoreEngine::spellCallback_end_unk1Passive(EobFlyingObject *fo) { +bool EobCoreEngine::spellCallback_end_unk1Passive(void *obj) { + EobFlyingObject *fo = (EobFlyingObject*)obj; bool res = false; if (_partyEffectFlags & 0x20000) { res = magicObjectDamageHit(fo, 4, 10, 6, 0); @@ -1051,23 +1197,24 @@ bool EobCoreEngine::spellCallback_end_unk1Passive(EobFlyingObject *fo) { return res; } -bool EobCoreEngine::spellCallback_end_unk2Passive(EobFlyingObject *fo) { +bool EobCoreEngine::spellCallback_end_unk2Passive(void *obj) { + EobFlyingObject *fo = (EobFlyingObject*)obj; return magicObjectDamageHit(fo, 0, 0, 18, 0); } -bool EobCoreEngine::spellCallback_end_deathSpellPassive(EobFlyingObject *fo) { +bool EobCoreEngine::spellCallback_end_deathSpellPassive(void*) { return true; } -bool EobCoreEngine::spellCallback_end_disintegratePassive(EobFlyingObject *fo) { +bool EobCoreEngine::spellCallback_end_disintegratePassive(void*) { return true; } -bool EobCoreEngine::spellCallback_end_causeCriticalWoundsPassive(EobFlyingObject *fo) { +bool EobCoreEngine::spellCallback_end_causeCriticalWoundsPassive(void*) { return true; } -bool EobCoreEngine::spellCallback_end_fleshToStonePassive(EobFlyingObject *fo) { +bool EobCoreEngine::spellCallback_end_fleshToStonePassive(void*) { return true; } -- cgit v1.2.3 From 0d54aff6324b1f6c739df89ab072328cc5402873 Mon Sep 17 00:00:00 2001 From: athrxx Date: Sun, 14 Aug 2011 18:29:45 +0200 Subject: KYRA: (EOB) - add EOB 1 intro (also add and fix several other things, like cone of cold vortex, drawShape issues, etc.) --- engines/kyra/magic_eob.cpp | 145 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 125 insertions(+), 20 deletions(-) (limited to 'engines/kyra/magic_eob.cpp') diff --git a/engines/kyra/magic_eob.cpp b/engines/kyra/magic_eob.cpp index 88046fd3a5..2ad0da7258 100644 --- a/engines/kyra/magic_eob.cpp +++ b/engines/kyra/magic_eob.cpp @@ -314,17 +314,14 @@ void EobCoreEngine::startSpell(int spell) { } if ((s->flags & 0x30) && (s->effectFlags & c->effectFlags)) { - if (_flags.gameID == GI_EOB1) { - // TODO: warnings seem to exist at least for bless and aid - } else { + if (_flags.gameID == GI_EOB2) printWarning(Common::String::format(_magicStrings7[0], c->name, s->name).c_str()); - } } else if ((s->flags & 0x50) && (s->effectFlags & _partyEffectFlags)) { - if (_flags.gameID == GI_EOB1) { - // TODO: warnings seem to exist at least for bless and aid - } else { + if (_flags.gameID == GI_EOB1 && s->effectFlags == 0x400) + // EOB 1 only warns in case of a bless spell + printWarning(_magicStrings8[1]); + else printWarning(Common::String::format(_magicStrings7[1], s->name).c_str()); - } } else { if (s->flags & 8) setSpellEventTimer(spell, s->timingPara[0], s->timingPara[1], s->timingPara[2], s->timingPara[3]); @@ -569,7 +566,7 @@ bool EobCoreEngine::magicObjectStatusHit(EobMonsterInPlay *m, int type, bool try return true; } - if (checkMonsterLevelConstModifiers(m, 0, p->level, mod, 6)) + if (trySavingThrow(m, 0, p->level, mod, 6)) return false; int para = 0; @@ -638,6 +635,26 @@ int EobCoreEngine::getMagicWeaponSlot(int charIndex) { return _characters[charIndex].inventory[1] ? 0 : 1; } +void EobCoreEngine::causeWounds(int dcTimes, int dcPips, int dcOffs) { + if (_openBookChar == 0 || _openBookChar == 1) { + int d = getClosestMonster(_openBookChar, calcNewBlockPosition(_currentBlock, _currentDirection)); + if (d != -1) { + if (!characterAttackHitTest(_openBookChar, d, 0, 1)) + return; + + if (dcTimes == -1) { + dcOffs = _monsters[d].hitPointsMax - rollDice(1, 4); + dcTimes = dcPips = 0; + } + calcAndInflictMonsterDamage(&_monsters[d], dcTimes, dcPips, dcOffs, 0x801, 4, 2); + } else { + printWarning(Common::String::format(_magicStrings3[_flags.gameID == GI_EOB1 ? 4 : 3], _characters[_openBookChar].name).c_str()); + } + } else { + printWarning(Common::String::format(_magicStrings3[_flags.gameID == GI_EOB1 ? 5 : 4], _characters[_openBookChar].name).c_str()); + } +} + int EobCoreEngine::createMagicWeaponType(int invFlags, int handFlags, int armorClass, int allowedClasses, int dmgNumDice, int dmgPips, int dmgInc, int extraProps) { int i = 51; for (; i < 57; i++) { @@ -655,7 +672,7 @@ int EobCoreEngine::createMagicWeaponType(int invFlags, int handFlags, int armorC tp->armorClass = armorClass; tp->allowedClasses = allowedClasses; tp->dmgNumDiceL = tp->dmgNumDiceS = dmgNumDice; - tp->dmgNumPipsL = tp->dmgNumPipsL = dmgPips; + tp->dmgNumPipsL = tp->dmgNumPipsS = dmgPips; tp->dmgIncL = tp->dmgIncS = dmgInc; tp->extraProperties = extraProps; @@ -707,6 +724,33 @@ int EobCoreEngine::findSingleSpellTarget(int dist) { return res; } +int EobCoreEngine::findFirstCharacterSpellTarget() { + int curCharIndex = rollDice(1, 6, -1); + for (_characterSpellTarget = 0; _characterSpellTarget < 6; _characterSpellTarget++) { + if (testCharacter(curCharIndex, 3)) + return curCharIndex; + if (++curCharIndex == 6) + curCharIndex = 0; + } + return -1; +} + +int EobCoreEngine::findNextCharacterSpellTarget(int curCharIndex) { + for (; _characterSpellTarget < 6; _characterSpellTarget++) { + if (++curCharIndex == 6) + curCharIndex = 0; + if (testCharacter(curCharIndex, 3)) + return curCharIndex; + } + return -1; +} + +int EobCoreEngine::charDeathSavingThrow(int charIndex, int div) { + if (specialAttackSavingThrow(charIndex, 4)) + div >>= 1; + return div; +} + void EobCoreEngine::printWarning(const char *str) { _txt->printMessage(str); snd_playSoundEffect(79); @@ -794,7 +838,11 @@ bool EobCoreEngine::spellCallback_end_shockingGraspFlameBlade(void *obj) { } void EobCoreEngine::spellCallback_start_improvedIdentify() { - + for (int i = 0; i < 2; i++) { + Item itm = _characters[_activeSpellCharId].inventory[i]; + if (itm) + _items[itm].flags |= 0x40; + } } void EobCoreEngine::spellCallback_start_melfsAcidArrow() { @@ -937,7 +985,15 @@ void EobCoreEngine::spellCallback_start_coneOfCold() { static const int8 *dirTables[] = { _coneOfColdDest1, _coneOfColdDest2, _coneOfColdDest3, _coneOfColdDest4 }; int cl = getMageLevel(_openBookChar); - //drawConeOfColdEffect(150, 50, 10, 1, 100, _coneOfColdGfxTbl); + + _screen->setCurPage(2); + _screen->fillRect(0, 0, 176, 120, 0); + _screen->setGfxParameters(0, 0, _screen->getPagePixel(2, 0, 0)); + drawSceneShapes(7); + _screen->setCurPage(0); + disableSysTimer(2); + _screen->drawVortex(150, 50, 10, 1, 100, _coneOfColdGfxTbl, _coneOfColdGfxTblSize); + enableSysTimer(2); const int8 *tbl = dirTables[_currentDirection]; _preventMonsterFlash = true; @@ -1016,7 +1072,7 @@ void EobCoreEngine::spellCallback_start_powerWordStun() { } void EobCoreEngine::spellCallback_start_causeLightWounds() { - + causeWounds(1, 8, 0); } void EobCoreEngine::spellCallback_start_cureLightWounds() { @@ -1095,7 +1151,7 @@ void EobCoreEngine::spellCallback_start_removeParalysis() { } void EobCoreEngine::spellCallback_start_causeSeriousWounds() { - + causeWounds(2, 8, 1); } void EobCoreEngine::spellCallback_start_cureSeriousWounds() { @@ -1110,7 +1166,7 @@ void EobCoreEngine::spellCallback_start_neutralizePoison() { } void EobCoreEngine::spellCallback_start_causeCriticalWounds() { - + causeWounds(3, 8, 3); } void EobCoreEngine::spellCallback_start_cureCriticalWounds() { @@ -1136,7 +1192,7 @@ void EobCoreEngine::spellCallback_start_raiseDead() { } void EobCoreEngine::spellCallback_start_harm() { - + causeWounds(-1, -1, -1); } void EobCoreEngine::spellCallback_start_heal() { @@ -1202,19 +1258,68 @@ bool EobCoreEngine::spellCallback_end_unk2Passive(void *obj) { return magicObjectDamageHit(fo, 0, 0, 18, 0); } -bool EobCoreEngine::spellCallback_end_deathSpellPassive(void*) { +bool EobCoreEngine::spellCallback_end_deathSpellPassive(void *obj) { + EobFlyingObject *fo = (EobFlyingObject*)obj; + if (fo->curBlock != _currentBlock) + return false; + + int numDest = rollDice(1, 4); + _txt->printMessage(_magicStrings2[2]); + for (int d = findFirstCharacterSpellTarget(); d != -1 && numDest; d = findNextCharacterSpellTarget(d)) { + if (_characters[d].level[0] < 8) { + inflictCharacterDamage(d, 300); + numDest--; + } + } + return true; } -bool EobCoreEngine::spellCallback_end_disintegratePassive(void*) { +bool EobCoreEngine::spellCallback_end_disintegratePassive(void *obj) { + EobFlyingObject *fo = (EobFlyingObject*)obj; + if (fo->curBlock != _currentBlock) + return false; + + int d = findFirstCharacterSpellTarget(); + if (d != -1) { + if (!charDeathSavingThrow(d, 1)) { + inflictCharacterDamage(d, 300); + _txt->printMessage(_magicStrings2[1], -1, _characters[d].name); + } + } + return true; } -bool EobCoreEngine::spellCallback_end_causeCriticalWoundsPassive(void*) { +bool EobCoreEngine::spellCallback_end_causeCriticalWoundsPassive(void *obj) { + EobFlyingObject *fo = (EobFlyingObject*)obj; + if (fo->curBlock != _currentBlock) + return false; + + int d = findFirstCharacterSpellTarget(); + if (d != -1) { + _txt->printMessage(_magicStrings2[3], -1, _characters[d].name); + inflictCharacterDamage(d, rollDice(3, 8, 3)); + } + return true; } -bool EobCoreEngine::spellCallback_end_fleshToStonePassive(void*) { +bool EobCoreEngine::spellCallback_end_fleshToStonePassive(void *obj) { + EobFlyingObject *fo = (EobFlyingObject*)obj; + if (fo->curBlock != _currentBlock) + return false; + + int d = findFirstCharacterSpellTarget(); + while (d != -1) { + if (!charDeathSavingThrow(d, 2)) { + statusAttack(d, 8, _magicStrings2[4], 5, 0, 0, 1); + d = -1; + } else { + d = findNextCharacterSpellTarget(d); + } + } + return true; } -- cgit v1.2.3 From b288889c978990423b08dad8f838d891610f36b5 Mon Sep 17 00:00:00 2001 From: athrxx Date: Mon, 15 Aug 2011 01:43:26 +0200 Subject: KYRA: (EOB) - implement wall of force spell --- engines/kyra/magic_eob.cpp | 59 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 8 deletions(-) (limited to 'engines/kyra/magic_eob.cpp') diff --git a/engines/kyra/magic_eob.cpp b/engines/kyra/magic_eob.cpp index 2ad0da7258..646d389706 100644 --- a/engines/kyra/magic_eob.cpp +++ b/engines/kyra/magic_eob.cpp @@ -24,6 +24,7 @@ #include "kyra/eobcommon.h" #include "kyra/resource.h" +#include "common/system.h" namespace Kyra { @@ -490,11 +491,11 @@ bool EobCoreEngine::magicObjectDamageHit(EobFlyingObject *fo, int dcTimes, int d int blockDamage = fo->flags & 2; int hitTest = fo->flags & 4; - int s = 5; - int dmgType = 3; + int savingThrowType = 5; + int savingThrowEffect = 3; if (fo->flags & 8) { - s = 4; - dmgType = 0; + savingThrowType = 4; + savingThrowEffect = 0; } int dmgFlag = _spells[fo->callBackIndex].damageFlags; @@ -516,7 +517,7 @@ bool EobCoreEngine::magicObjectDamageHit(EobFlyingObject *fo, int dcTimes, int d continue; } - calcAndInflictMonsterDamage(&_monsters[*m], 0, 0, dmg, dmgFlag, s, dmgType); + calcAndInflictMonsterDamage(&_monsters[*m], 0, 0, dmg, dmgFlag, savingThrowType, savingThrowEffect); res = true; } updateAllMonsterShapes(); @@ -532,7 +533,7 @@ bool EobCoreEngine::magicObjectDamageHit(EobFlyingObject *fo, int dcTimes, int d int dmg = rollDice(dcTimes, dcPips, dcOffs) * level; res = true; - calcAndInflictCharacterDamage(i, 0, 0, dmg, dmgFlag, s, dmgType); + calcAndInflictCharacterDamage(i, 0, 0, dmg, dmgFlag, savingThrowType, savingThrowEffect); } } else { int c = _dscItemPosIndex[(_currentDirection << 2) + (fo->curPos & 3)]; @@ -545,7 +546,7 @@ bool EobCoreEngine::magicObjectDamageHit(EobFlyingObject *fo, int dcTimes, int d if ((_characters[c].flags & 1) && (!hitTest || monsterAttackHitTest(&_monsters[0], c))) { int dmg = rollDice(dcTimes, dcPips, dcOffs) * level; res = true; - calcAndInflictCharacterDamage(c, 0, 0, dmg, dmgFlag, s, dmgType); + calcAndInflictCharacterDamage(c, 0, 0, dmg, dmgFlag, savingThrowType, savingThrowEffect); } } } @@ -708,6 +709,22 @@ void EobCoreEngine::removeMagicWeaponItem(Item item) { _items[item].level = -1; } +void EobCoreEngine::updateWallOfForceTimers() { + uint32 ct = _system->getMillis(); + for (int i = 0; i < 5; i++) { + if (!_wallsOfForce[i].block) + continue; + if (_wallsOfForce[i].duration < ct) + destroyWallOfForce(i); + } +} + +void EobCoreEngine::destroyWallOfForce(int index) { + memset(_levelBlockProperties[_wallsOfForce[index].block].walls, 0, 4); + _wallsOfForce[index].block = 0; + _sceneUpdateRequired = true; +} + int EobCoreEngine::findSingleSpellTarget(int dist) { uint16 bl = _currentBlock; int res = -1; @@ -924,7 +941,7 @@ void EobCoreEngine::spellCallback_start_vampiricTouch() { Item i = (t != -1) ? createMagicWeaponItem(0x18, 83, 0, t) : -1; if (t == -1 || i == -1) { if (_flags.gameID == GI_EOB2) - printWarning(_magicStrings8[0]); + printWarning(_magicStrings8[2]); removeCharacterEffect(_activeSpell, _activeSpellCharId, 0); deleteCharEventTimer(_activeSpellCharId, -_activeSpell); _returnAfterSpellCallback = true; @@ -1019,7 +1036,33 @@ bool EobCoreEngine::spellCallback_end_holdMonster(void *obj) { } void EobCoreEngine::spellCallback_start_wallOfForce() { + uint16 bl = calcNewBlockPosition(_currentBlock, _currentDirection); + LevelBlockProperty *l = &_levelBlockProperties[bl]; + if (l->walls[0] || l->walls[1] || l->walls[2] || l->walls[3] || (l->flags & 7)) { + printWarning(_magicStrings8[3]); + return; + } + + uint32 dur = 0xffffffff; + int s = 0; + int i = 0; + for (; i < 5; i++) { + if (!_wallsOfForce[i].block) + break; + if (_wallsOfForce[i].duration < dur) { + dur = _wallsOfForce[i].duration; + s = i; + } + } + + if (i == 5) + destroyWallOfForce(s); + + memset(_levelBlockProperties[bl].walls, 74, 4); + _wallsOfForce[s].block = bl; + _wallsOfForce[s].duration = _system->getMillis() + (((getMageLevel(_openBookChar) * 546) >> 1) + 546) * _tickLength; + _sceneUpdateRequired = true; } void EobCoreEngine::spellCallback_start_disintegrate() { -- cgit v1.2.3 From c35de374dfe545ffc5044a00a247c5814e3b250e Mon Sep 17 00:00:00 2001 From: athrxx Date: Sat, 20 Aug 2011 13:24:36 +0200 Subject: KYRA: (EOB) - lots of bug fixes, mostly for EOB II --- engines/kyra/magic_eob.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'engines/kyra/magic_eob.cpp') diff --git a/engines/kyra/magic_eob.cpp b/engines/kyra/magic_eob.cpp index 646d389706..0424558b04 100644 --- a/engines/kyra/magic_eob.cpp +++ b/engines/kyra/magic_eob.cpp @@ -360,7 +360,7 @@ void EobCoreEngine::startSpell(int spell) { if (_castScrollSlot) { gui_updateSlotAfterScrollUse(); } else { - c->disabledSlots |= 4; + _characters[_openBookChar].disabledSlots |= 4; setCharEventTimer(_openBookChar, 72, 11, 1); gui_toggleButtons(); gui_drawSpellbook(); @@ -405,7 +405,6 @@ void EobCoreEngine::sparkEffectDefensive(int charIndex) { _screen->updateScreen(); } } - resetSkipFlag(); delay(2 * _tickLength); } @@ -430,7 +429,6 @@ void EobCoreEngine::sparkEffectOffensive() { if (shpIndex) _screen->drawShape(2, _sparkShapes[shpIndex - 1], _sparkEffectOfX[ii], _sparkEffectOfY[ii], 0); } - resetSkipFlag(); delay(2 * _tickLength); _screen->copyRegion(0, 0, 0, 0, 176, 120, 2, 0, Screen::CR_NO_P_CHECK); _screen->updateScreen(); @@ -444,6 +442,7 @@ void EobCoreEngine::sparkEffectOffensive() { } void EobCoreEngine::setSpellEventTimer(int spell, int timerBaseFactor, int timerLength, int timerLevelFactor, int updateExistingTimer) { + assert (spell >= 0); int l = _openBookType == 1 ? getClericPaladinLevel(_openBookChar) : getMageLevel(_openBookChar); uint32 countdown = timerLength * timerBaseFactor + timerLength * l * timerLevelFactor; setCharEventTimer(_activeSpellCharId, countdown, -spell, updateExistingTimer); @@ -753,7 +752,7 @@ int EobCoreEngine::findFirstCharacterSpellTarget() { } int EobCoreEngine::findNextCharacterSpellTarget(int curCharIndex) { - for (; _characterSpellTarget < 6; _characterSpellTarget++) { + for (_characterSpellTarget++; _characterSpellTarget < 6; ) { if (++curCharIndex == 6) curCharIndex = 0; if (testCharacter(curCharIndex, 3)) @@ -763,8 +762,14 @@ int EobCoreEngine::findNextCharacterSpellTarget(int curCharIndex) { } int EobCoreEngine::charDeathSavingThrow(int charIndex, int div) { - if (specialAttackSavingThrow(charIndex, 4)) + bool _beholderOrgBhv = true; + // Due to a bug in the original code the saving throw result is completely ignored + // here. The Beholders' disintegrate spell will alway succeed while their flesh to + // stone spell will always fail. + if (_beholderOrgBhv) div >>= 1; + else + div = specialAttackSavingThrow(charIndex, 4) ? 1 : 0; return div; } @@ -1226,7 +1231,7 @@ bool EobCoreEngine::spellCallback_end_flameStrike(void *obj) { } void EobCoreEngine::spellCallback_start_raiseDead() { - if (_characters[_activeSpellCharId].hitPointsCur == -10 || ((_characters[_activeSpellCharId].raceSex >> 1) == 1)) { + if (_characters[_activeSpellCharId].hitPointsCur == -10 && ((_characters[_activeSpellCharId].raceSex >> 1) != 1)) { _characters[_activeSpellCharId].hitPointsCur = 1; gui_drawCharPortraitWithStats(_activeSpellCharId); } else { -- cgit v1.2.3 From 2448d885e4e331a22e1e468277142155a5ddda87 Mon Sep 17 00:00:00 2001 From: athrxx Date: Sun, 21 Aug 2011 20:26:07 +0200 Subject: KYRA: (EOB) - complete EOBII playability - fixed temp data generation, block data loading, some spell issues, etc. - both EOB I and II should now be completable - one big issue remaining (AdLib driver gets swamped with monster sounds which causes heavy lags in some levels) --- engines/kyra/magic_eob.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'engines/kyra/magic_eob.cpp') diff --git a/engines/kyra/magic_eob.cpp b/engines/kyra/magic_eob.cpp index 0424558b04..9063d512f0 100644 --- a/engines/kyra/magic_eob.cpp +++ b/engines/kyra/magic_eob.cpp @@ -236,8 +236,14 @@ void EobCoreEngine::removeCharacterEffect(int spell, int charIndex, int showWarn EobCharacter *c = &_characters[charIndex]; EobSpell *s = &_spells[spell]; - if (showWarning) + if (showWarning) { + int od = _screen->curDimIndex(); + Screen::FontId of = _screen->setFont(Screen::FID_6_FNT); + _screen->setScreenDim(7); printWarning(Common::String::format(_magicStrings3[_flags.gameID == GI_EOB1 ? 3 : 2], c->name, s->name).c_str()); + _screen->setScreenDim(od); + _screen->setFont(of); + } if (s->endCallback) (this->*s->endCallback)(c); @@ -1281,12 +1287,12 @@ void EobCoreEngine::spellCallback_start_turnUndead() { _preventMonsterFlash = false; } -bool EobCoreEngine::spellCallback_end_lightningBoltPassive(void *obj) { +bool EobCoreEngine::spellCallback_end_monster_lightningBolt(void *obj) { EobFlyingObject *fo = (EobFlyingObject*)obj; return magicObjectDamageHit(fo, 0, 0, 12, 1); } -bool EobCoreEngine::spellCallback_end_unk1Passive(void *obj) { +bool EobCoreEngine::spellCallback_end_monster_fireball1(void *obj) { EobFlyingObject *fo = (EobFlyingObject*)obj; bool res = false; if (_partyEffectFlags & 0x20000) { @@ -1301,12 +1307,12 @@ bool EobCoreEngine::spellCallback_end_unk1Passive(void *obj) { return res; } -bool EobCoreEngine::spellCallback_end_unk2Passive(void *obj) { +bool EobCoreEngine::spellCallback_end_monster_fireball2(void *obj) { EobFlyingObject *fo = (EobFlyingObject*)obj; return magicObjectDamageHit(fo, 0, 0, 18, 0); } -bool EobCoreEngine::spellCallback_end_deathSpellPassive(void *obj) { +bool EobCoreEngine::spellCallback_end_monster_deathSpell(void *obj) { EobFlyingObject *fo = (EobFlyingObject*)obj; if (fo->curBlock != _currentBlock) return false; @@ -1323,7 +1329,7 @@ bool EobCoreEngine::spellCallback_end_deathSpellPassive(void *obj) { return true; } -bool EobCoreEngine::spellCallback_end_disintegratePassive(void *obj) { +bool EobCoreEngine::spellCallback_end_monster_disintegrate(void *obj) { EobFlyingObject *fo = (EobFlyingObject*)obj; if (fo->curBlock != _currentBlock) return false; @@ -1339,7 +1345,7 @@ bool EobCoreEngine::spellCallback_end_disintegratePassive(void *obj) { return true; } -bool EobCoreEngine::spellCallback_end_causeCriticalWoundsPassive(void *obj) { +bool EobCoreEngine::spellCallback_end_monster_causeCriticalWounds(void *obj) { EobFlyingObject *fo = (EobFlyingObject*)obj; if (fo->curBlock != _currentBlock) return false; @@ -1353,7 +1359,7 @@ bool EobCoreEngine::spellCallback_end_causeCriticalWoundsPassive(void *obj) { return true; } -bool EobCoreEngine::spellCallback_end_fleshToStonePassive(void *obj) { +bool EobCoreEngine::spellCallback_end_monster_fleshToStone(void *obj) { EobFlyingObject *fo = (EobFlyingObject*)obj; if (fo->curBlock != _currentBlock) return false; -- cgit v1.2.3 From 1cbd56693086afa8ce93092c3638e1052e31a5d9 Mon Sep 17 00:00:00 2001 From: athrxx Date: Thu, 29 Sep 2011 22:51:36 +0200 Subject: KYRA: (EOB) - fix invalid string access (also fix several cpp-check warnings) --- engines/kyra/magic_eob.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/kyra/magic_eob.cpp') diff --git a/engines/kyra/magic_eob.cpp b/engines/kyra/magic_eob.cpp index 9063d512f0..b70058d7ff 100644 --- a/engines/kyra/magic_eob.cpp +++ b/engines/kyra/magic_eob.cpp @@ -542,7 +542,7 @@ bool EobCoreEngine::magicObjectDamageHit(EobFlyingObject *fo, int dcTimes, int d } } else { int c = _dscItemPosIndex[(_currentDirection << 2) + (fo->curPos & 3)]; - if ((c > 2) && (testCharacter(5, 1) || testCharacter(6, 1)) && rollDice(1, 2, -1)) + if ((c > 2) && (testCharacter(4, 1) || testCharacter(5, 1)) && rollDice(1, 2, -1)) c += 2; if (!fo->item && (_characters[c].effectFlags & 8)) { -- cgit v1.2.3 From aac7e16afa8546232a27754c6928cd43cd6ba876 Mon Sep 17 00:00:00 2001 From: athrxx Date: Mon, 28 Nov 2011 18:44:40 +0100 Subject: KYRA: (EOB) - fix some more bugs - wrong usage of static array which caused issues when restarting after RTL - portability issue with dialog labels - (original code) bug in hold person spell --- engines/kyra/magic_eob.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/kyra/magic_eob.cpp') diff --git a/engines/kyra/magic_eob.cpp b/engines/kyra/magic_eob.cpp index b70058d7ff..21bb10a1de 100644 --- a/engines/kyra/magic_eob.cpp +++ b/engines/kyra/magic_eob.cpp @@ -919,7 +919,7 @@ bool EobCoreEngine::spellCallback_end_holdPerson(void *obj) { if (_flags.gameID == GI_EOB2 && fo->curBlock == _currentBlock) { // party hit int numChar = rollDice(1, 4, 0); - int charIndex = rollDice(1, 6, 0); + int charIndex = rollDice(1, 6, -1); for (int i = 0; i < 6 && numChar; i++) { if (testCharacter(charIndex, 3)) { statusAttack(charIndex, 4, _magicStrings8[1], 4, 5, 9, 1); @@ -1010,7 +1010,7 @@ void EobCoreEngine::spellCallback_start_removeCurse() { } void EobCoreEngine::spellCallback_start_coneOfCold() { - static const int8 *dirTables[] = { _coneOfColdDest1, _coneOfColdDest2, _coneOfColdDest3, _coneOfColdDest4 }; + const int8 *dirTables[] = { _coneOfColdDest1, _coneOfColdDest2, _coneOfColdDest3, _coneOfColdDest4 }; int cl = getMageLevel(_openBookChar); -- cgit v1.2.3 From 8b618e46df21d90a1a5ad62633a2b9d3c1da0317 Mon Sep 17 00:00:00 2001 From: athrxx Date: Sun, 11 Dec 2011 12:29:09 +0100 Subject: KYRA: (EOB/LOL) - cleanup common code (rename some stuff and move EOB/LOL common code to separate files) --- engines/kyra/magic_eob.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'engines/kyra/magic_eob.cpp') diff --git a/engines/kyra/magic_eob.cpp b/engines/kyra/magic_eob.cpp index 21bb10a1de..e3428fb3c7 100644 --- a/engines/kyra/magic_eob.cpp +++ b/engines/kyra/magic_eob.cpp @@ -158,7 +158,7 @@ void EobCoreEngine::useWand(int charIndex, int weaponSlot) { uint16 bl2 = calcNewBlockPosition(bl1, _currentDirection); snd_playSoundEffect(98); sparkEffectOffensive(); - + if ((_wllWallFlags[_levelBlockProperties[bl2].walls[_currentDirection ^ 2]] & 4) && !(_levelBlockProperties[bl2].flags & 7) && (_levelBlockProperties[bl1].flags & 7)) { for (int i = 0; i < 30; i++) { if (_monsters[i].block != bl1) @@ -574,9 +574,9 @@ bool EobCoreEngine::magicObjectStatusHit(EobMonsterInPlay *m, int type, bool try if (trySavingThrow(m, 0, p->level, mod, 6)) return false; - + int para = 0; - + switch (type) { case 0: case 1: @@ -631,7 +631,7 @@ bool EobCoreEngine::turnUndeadHit(EobMonsterInPlay *m, int hitChance, int caster m->mode = 0; m->flags |= 8; m->spellStatusLeft = 40; - m->dir = (getNextMonsterDirection(m->block, _currentBlock) ^ 4) >> 1; + m->dir = (getNextMonsterDirection(m->block, _currentBlock) ^ 4) >> 1; } return true; @@ -647,7 +647,7 @@ void EobCoreEngine::causeWounds(int dcTimes, int dcPips, int dcOffs) { if (d != -1) { if (!characterAttackHitTest(_openBookChar, d, 0, 1)) return; - + if (dcTimes == -1) { dcOffs = _monsters[d].hitPointsMax - rollDice(1, 4); dcTimes = dcPips = 0; @@ -802,7 +802,7 @@ void EobCoreEngine::spellCallback_start_burningHands() { drawBlockObject(i & 1, 0, _firebeamShapes[(5 - i) >> 1], bX[i], bY[i], 0); _screen->updateScreen(); delay(2 * _tickLength); - + int cl = getMageLevel(_openBookChar); int bl = calcNewBlockPosition(_currentBlock, _currentDirection); @@ -915,7 +915,7 @@ void EobCoreEngine::spellCallback_start_holdPerson() { bool EobCoreEngine::spellCallback_end_holdPerson(void *obj) { EobFlyingObject *fo = (EobFlyingObject*)obj; bool res = false; - + if (_flags.gameID == GI_EOB2 && fo->curBlock == _currentBlock) { // party hit int numChar = rollDice(1, 4, 0); @@ -1011,7 +1011,7 @@ void EobCoreEngine::spellCallback_start_removeCurse() { void EobCoreEngine::spellCallback_start_coneOfCold() { const int8 *dirTables[] = { _coneOfColdDest1, _coneOfColdDest2, _coneOfColdDest3, _coneOfColdDest4 }; - + int cl = getMageLevel(_openBookChar); _screen->setCurPage(2); @@ -1022,11 +1022,11 @@ void EobCoreEngine::spellCallback_start_coneOfCold() { disableSysTimer(2); _screen->drawVortex(150, 50, 10, 1, 100, _coneOfColdGfxTbl, _coneOfColdGfxTblSize); enableSysTimer(2); - + const int8 *tbl = dirTables[_currentDirection]; _preventMonsterFlash = true; - for (int i = 0; i < 7; i++) { + for (int i = 0; i < 7; i++) { for (const int16 *m = findBlockMonsters((_currentBlock + tbl[i]) & 0x3ff, 4, _currentDirection, 1, 1); *m != -1; m++) calcAndInflictMonsterDamage(&_monsters[*m], cl, 4, cl, 0x41, 5, 0); } @@ -1265,12 +1265,12 @@ void EobCoreEngine::spellCallback_start_turnUndead() { uint16 bl = calcNewBlockPosition(_currentBlock, _currentDirection); if (!(_levelBlockProperties[bl].flags & 7)) return; - + int cl = _openBookCasterLevel ? _openBookCasterLevel : getClericPaladinLevel(_openBookChar); int r = rollDice(1, 20); bool hit = false; - for (const int16 *m = findBlockMonsters(bl, 4, 4, 1, 1); *m != -1; m++) { + for (const int16 *m = findBlockMonsters(bl, 4, 4, 1, 1); *m != -1; m++) { if ((_monsterProps[_monsters[*m].type].typeFlags & 4) && !(_monsters[*m].flags & 0x10)) { _preventMonsterFlash = true; _monsters[*m].flags |= 0x10; @@ -1333,7 +1333,7 @@ bool EobCoreEngine::spellCallback_end_monster_disintegrate(void *obj) { EobFlyingObject *fo = (EobFlyingObject*)obj; if (fo->curBlock != _currentBlock) return false; - + int d = findFirstCharacterSpellTarget(); if (d != -1) { if (!charDeathSavingThrow(d, 1)) { @@ -1363,7 +1363,7 @@ bool EobCoreEngine::spellCallback_end_monster_fleshToStone(void *obj) { EobFlyingObject *fo = (EobFlyingObject*)obj; if (fo->curBlock != _currentBlock) return false; - + int d = findFirstCharacterSpellTarget(); while (d != -1) { if (!charDeathSavingThrow(d, 2)) { @@ -1373,7 +1373,7 @@ bool EobCoreEngine::spellCallback_end_monster_fleshToStone(void *obj) { d = findNextCharacterSpellTarget(d); } } - + return true; } -- cgit v1.2.3 From 0aa32385230dbe1ab62bb2d02d04ca5cc46d928c Mon Sep 17 00:00:00 2001 From: athrxx Date: Mon, 12 Dec 2011 16:23:01 +0100 Subject: KYRA: (EOB/LOL) - rename some vars (all cases of Eob to EoB, all cases of Lol to LoL, all cases of LolEobCommon to RpgCommon) --- engines/kyra/magic_eob.cpp | 256 ++++++++++++++++++++++----------------------- 1 file changed, 128 insertions(+), 128 deletions(-) (limited to 'engines/kyra/magic_eob.cpp') diff --git a/engines/kyra/magic_eob.cpp b/engines/kyra/magic_eob.cpp index e3428fb3c7..c1b0327df2 100644 --- a/engines/kyra/magic_eob.cpp +++ b/engines/kyra/magic_eob.cpp @@ -28,8 +28,8 @@ namespace Kyra { -void EobCoreEngine::useMagicBookOrSymbol(int charIndex, int type) { - EobCharacter *c = &_characters[charIndex]; +void EoBCoreEngine::useMagicBookOrSymbol(int charIndex, int type) { + EoBCharacter *c = &_characters[charIndex]; _openBookSpellLevel = c->slotStatus[3]; _openBookSpellSelectedItem = c->slotStatus[2]; _openBookSpellListOffset = c->slotStatus[4]; @@ -66,7 +66,7 @@ void EobCoreEngine::useMagicBookOrSymbol(int charIndex, int type) { gui_drawSpellbook(); } -void EobCoreEngine::useMagicScroll(int charIndex, int type, int weaponSlot) { +void EoBCoreEngine::useMagicScroll(int charIndex, int type, int weaponSlot) { _openBookCharBackup = _openBookChar; _openBookTypeBackup = _openBookType; _castScrollSlot = weaponSlot + 1; @@ -75,8 +75,8 @@ void EobCoreEngine::useMagicScroll(int charIndex, int type, int weaponSlot) { castSpell(type, weaponSlot); } -void EobCoreEngine::usePotion(int charIndex, int weaponSlot) { - EobCharacter *c = &_characters[charIndex]; +void EoBCoreEngine::usePotion(int charIndex, int weaponSlot) { + EoBCharacter *c = &_characters[charIndex]; int val = deleteInventoryItem(charIndex, weaponSlot); snd_playSoundEffect(10); @@ -142,7 +142,7 @@ void EobCoreEngine::usePotion(int charIndex, int weaponSlot) { _txt->printMessage(_potionStrings[1], -1, c->name, _potionEffectStrings[val]); } -void EobCoreEngine::useWand(int charIndex, int weaponSlot) { +void EoBCoreEngine::useWand(int charIndex, int weaponSlot) { int v = _items[_characters[charIndex].inventory[weaponSlot]].value; if (!v) { _txt->printMessage(_wandStrings[0]); @@ -172,9 +172,9 @@ void EobCoreEngine::useWand(int charIndex, int weaponSlot) { } } -void EobCoreEngine::castSpell(int spell, int weaponSlot) { - EobSpell *s = &_spells[spell]; - EobCharacter *c = &_characters[_openBookChar]; +void EoBCoreEngine::castSpell(int spell, int weaponSlot) { + EoBSpell *s = &_spells[spell]; + EoBCharacter *c = &_characters[_openBookChar]; _activeSpell = spell; if ((s->flags & 0x100) && (c->effectFlags & 0x40)) @@ -231,10 +231,10 @@ void EobCoreEngine::castSpell(int spell, int weaponSlot) { startSpell(spell); } -void EobCoreEngine::removeCharacterEffect(int spell, int charIndex, int showWarning) { +void EoBCoreEngine::removeCharacterEffect(int spell, int charIndex, int showWarning) { assert(spell >= 0); - EobCharacter *c = &_characters[charIndex]; - EobSpell *s = &_spells[spell]; + EoBCharacter *c = &_characters[charIndex]; + EoBSpell *s = &_spells[spell]; if (showWarning) { int od = _screen->curDimIndex(); @@ -275,8 +275,8 @@ void EobCoreEngine::removeCharacterEffect(int spell, int charIndex, int showWarn } } -void EobCoreEngine::removeAllCharacterEffects(int charIndex) { - EobCharacter *c = &_characters[charIndex]; +void EoBCoreEngine::removeAllCharacterEffects(int charIndex) { + EoBCharacter *c = &_characters[charIndex]; c->effectFlags = 0; memset(c->effectsRemainder, 0, 4); @@ -298,14 +298,14 @@ void EobCoreEngine::removeAllCharacterEffects(int charIndex) { gui_drawAllCharPortraitsWithStats(); } -void EobCoreEngine::castOnWhomDialogue() { +void EoBCoreEngine::castOnWhomDialogue() { printWarning(_magicStrings3[0]); gui_setCastOnWhomButtons(); } -void EobCoreEngine::startSpell(int spell) { - EobSpell *s = &_spells[spell]; - EobCharacter *c = &_characters[_activeSpellCharId]; +void EoBCoreEngine::startSpell(int spell) { + EoBSpell *s = &_spells[spell]; + EoBCharacter *c = &_characters[_activeSpellCharId]; snd_playSoundEffect(s->sound); if (s->flags & 0xa0) @@ -379,7 +379,7 @@ void EobCoreEngine::startSpell(int spell) { } } -void EobCoreEngine::sparkEffectDefensive(int charIndex) { +void EoBCoreEngine::sparkEffectDefensive(int charIndex) { int first = charIndex; int last = charIndex; if (charIndex == -1) { @@ -418,7 +418,7 @@ void EobCoreEngine::sparkEffectDefensive(int charIndex) { gui_drawCharPortraitWithStats(i); } -void EobCoreEngine::sparkEffectOffensive() { +void EoBCoreEngine::sparkEffectOffensive() { disableSysTimer(2); _screen->copyRegion(0, 0, 0, 0, 176, 120, 0, 2, Screen::CR_NO_P_CHECK); @@ -447,14 +447,14 @@ void EobCoreEngine::sparkEffectOffensive() { enableSysTimer(2); } -void EobCoreEngine::setSpellEventTimer(int spell, int timerBaseFactor, int timerLength, int timerLevelFactor, int updateExistingTimer) { +void EoBCoreEngine::setSpellEventTimer(int spell, int timerBaseFactor, int timerLength, int timerLevelFactor, int updateExistingTimer) { assert (spell >= 0); int l = _openBookType == 1 ? getClericPaladinLevel(_openBookChar) : getMageLevel(_openBookChar); uint32 countdown = timerLength * timerBaseFactor + timerLength * l * timerLevelFactor; setCharEventTimer(_activeSpellCharId, countdown, -spell, updateExistingTimer); } -void EobCoreEngine::sortCharacterSpellList(int charIndex) { +void EoBCoreEngine::sortCharacterSpellList(int charIndex) { int8 *list = _characters[charIndex].mageSpells; for (int i = 0; i < 16; ) { @@ -490,7 +490,7 @@ void EobCoreEngine::sortCharacterSpellList(int charIndex) { } } -bool EobCoreEngine::magicObjectDamageHit(EobFlyingObject *fo, int dcTimes, int dcPips, int dcOffs, int level) { +bool EoBCoreEngine::magicObjectDamageHit(EoBFlyingObject *fo, int dcTimes, int dcPips, int dcOffs, int level) { int ignoreAttackerId = fo->flags & 0x10; int singleTargetCheckAdjacent = fo->flags & 1; int blockDamage = fo->flags & 2; @@ -565,8 +565,8 @@ bool EobCoreEngine::magicObjectDamageHit(EobFlyingObject *fo, int dcTimes, int d return res; } -bool EobCoreEngine::magicObjectStatusHit(EobMonsterInPlay *m, int type, bool tryEvade, int mod) { - EobMonsterProperty *p = &_monsterProps[m->type]; +bool EoBCoreEngine::magicObjectStatusHit(EoBMonsterInPlay *m, int type, bool tryEvade, int mod) { + EoBMonsterProperty *p = &_monsterProps[m->type]; if (tryEvade) { if (tryMonsterAttackEvasion(m) || (p->immunityFlags & 0x10)) return true; @@ -619,7 +619,7 @@ bool EobCoreEngine::magicObjectStatusHit(EobMonsterInPlay *m, int type, bool try return true; } -bool EobCoreEngine::turnUndeadHit(EobMonsterInPlay *m, int hitChance, int casterLevel) { +bool EoBCoreEngine::turnUndeadHit(EoBMonsterInPlay *m, int hitChance, int casterLevel) { assert(_monsterProps[m->type].tuResist > 0); uint8 e = _turnUndeadEffect[_monsterProps[m->type].tuResist * 14 + MIN(casterLevel, 14)]; @@ -637,11 +637,11 @@ bool EobCoreEngine::turnUndeadHit(EobMonsterInPlay *m, int hitChance, int caster return true; } -int EobCoreEngine::getMagicWeaponSlot(int charIndex) { +int EoBCoreEngine::getMagicWeaponSlot(int charIndex) { return _characters[charIndex].inventory[1] ? 0 : 1; } -void EobCoreEngine::causeWounds(int dcTimes, int dcPips, int dcOffs) { +void EoBCoreEngine::causeWounds(int dcTimes, int dcPips, int dcOffs) { if (_openBookChar == 0 || _openBookChar == 1) { int d = getClosestMonster(_openBookChar, calcNewBlockPosition(_currentBlock, _currentDirection)); if (d != -1) { @@ -661,7 +661,7 @@ void EobCoreEngine::causeWounds(int dcTimes, int dcPips, int dcOffs) { } } -int EobCoreEngine::createMagicWeaponType(int invFlags, int handFlags, int armorClass, int allowedClasses, int dmgNumDice, int dmgPips, int dmgInc, int extraProps) { +int EoBCoreEngine::createMagicWeaponType(int invFlags, int handFlags, int armorClass, int allowedClasses, int dmgNumDice, int dmgPips, int dmgInc, int extraProps) { int i = 51; for (; i < 57; i++) { if (_itemTypes[i].armorClass == -30) @@ -671,7 +671,7 @@ int EobCoreEngine::createMagicWeaponType(int invFlags, int handFlags, int armorC if (i == 57) return -1; - EobItemType *tp = &_itemTypes[i]; + EoBItemType *tp = &_itemTypes[i]; tp->invFlags = invFlags; tp->requiredHands = 0; tp->handFlags = handFlags; @@ -685,7 +685,7 @@ int EobCoreEngine::createMagicWeaponType(int invFlags, int handFlags, int armorC return i; } -Item EobCoreEngine::createMagicWeaponItem(int flags, int icon, int value, int type) { +Item EoBCoreEngine::createMagicWeaponItem(int flags, int icon, int value, int type) { Item i = 11; for (; i < 17; i++) { if (_items[i].block == -2) @@ -695,7 +695,7 @@ Item EobCoreEngine::createMagicWeaponItem(int flags, int icon, int value, int ty if (i == 17) return -1; - EobItem *itm = &_items[i]; + EoBItem *itm = &_items[i]; itm->flags = 0x20 | flags; itm->icon = icon; itm->value = value; @@ -708,13 +708,13 @@ Item EobCoreEngine::createMagicWeaponItem(int flags, int icon, int value, int ty return i; } -void EobCoreEngine::removeMagicWeaponItem(Item item) { +void EoBCoreEngine::removeMagicWeaponItem(Item item) { _itemTypes[_items[item].type].armorClass = -30; _items[item].block = -2; _items[item].level = -1; } -void EobCoreEngine::updateWallOfForceTimers() { +void EoBCoreEngine::updateWallOfForceTimers() { uint32 ct = _system->getMillis(); for (int i = 0; i < 5; i++) { if (!_wallsOfForce[i].block) @@ -724,13 +724,13 @@ void EobCoreEngine::updateWallOfForceTimers() { } } -void EobCoreEngine::destroyWallOfForce(int index) { +void EoBCoreEngine::destroyWallOfForce(int index) { memset(_levelBlockProperties[_wallsOfForce[index].block].walls, 0, 4); _wallsOfForce[index].block = 0; _sceneUpdateRequired = true; } -int EobCoreEngine::findSingleSpellTarget(int dist) { +int EoBCoreEngine::findSingleSpellTarget(int dist) { uint16 bl = _currentBlock; int res = -1; @@ -746,7 +746,7 @@ int EobCoreEngine::findSingleSpellTarget(int dist) { return res; } -int EobCoreEngine::findFirstCharacterSpellTarget() { +int EoBCoreEngine::findFirstCharacterSpellTarget() { int curCharIndex = rollDice(1, 6, -1); for (_characterSpellTarget = 0; _characterSpellTarget < 6; _characterSpellTarget++) { if (testCharacter(curCharIndex, 3)) @@ -757,7 +757,7 @@ int EobCoreEngine::findFirstCharacterSpellTarget() { return -1; } -int EobCoreEngine::findNextCharacterSpellTarget(int curCharIndex) { +int EoBCoreEngine::findNextCharacterSpellTarget(int curCharIndex) { for (_characterSpellTarget++; _characterSpellTarget < 6; ) { if (++curCharIndex == 6) curCharIndex = 0; @@ -767,7 +767,7 @@ int EobCoreEngine::findNextCharacterSpellTarget(int curCharIndex) { return -1; } -int EobCoreEngine::charDeathSavingThrow(int charIndex, int div) { +int EoBCoreEngine::charDeathSavingThrow(int charIndex, int div) { bool _beholderOrgBhv = true; // Due to a bug in the original code the saving throw result is completely ignored // here. The Beholders' disintegrate spell will alway succeed while their flesh to @@ -779,22 +779,22 @@ int EobCoreEngine::charDeathSavingThrow(int charIndex, int div) { return div; } -void EobCoreEngine::printWarning(const char *str) { +void EoBCoreEngine::printWarning(const char *str) { _txt->printMessage(str); snd_playSoundEffect(79); } -void EobCoreEngine::printNoEffectWarning() { +void EoBCoreEngine::printNoEffectWarning() { printWarning(_magicStrings4[0]); } -void EobCoreEngine::spellCallback_start_armor() { +void EoBCoreEngine::spellCallback_start_armor() { _characters[_activeSpellCharId].effectsRemainder[0] = getMageLevel(_openBookChar) + 8; if ((getDexterityArmorClassModifier(_characters[_activeSpellCharId].dexterityCur) + 6) >= _characters[_activeSpellCharId].armorClass) printWarning(Common::String::format(_magicStrings6[0], _characters[_activeSpellCharId].name).c_str()); } -void EobCoreEngine::spellCallback_start_burningHands() { +void EoBCoreEngine::spellCallback_start_burningHands() { static const int16 bX[] = { 0, 152, 24, 120, 56, 88 }; static const int8 bY[] = { 64, 64, 56, 56, 56, 56 }; @@ -822,25 +822,25 @@ void EobCoreEngine::spellCallback_start_burningHands() { _sceneUpdateRequired = true; } -void EobCoreEngine::spellCallback_start_detectMagic() { +void EoBCoreEngine::spellCallback_start_detectMagic() { setHandItem(_itemInHand); } -bool EobCoreEngine::spellCallback_end_detectMagic(void*) { +bool EoBCoreEngine::spellCallback_end_detectMagic(void*) { setHandItem(_itemInHand); return true; } -void EobCoreEngine::spellCallback_start_magicMissile() { +void EoBCoreEngine::spellCallback_start_magicMissile() { launchMagicObject(_openBookChar, 0, _currentBlock, _activeSpellCharacterPos, _currentDirection); } -bool EobCoreEngine::spellCallback_end_magicMissile(void *obj) { - EobFlyingObject *fo = (EobFlyingObject*)obj; +bool EoBCoreEngine::spellCallback_end_magicMissile(void *obj) { + EoBFlyingObject *fo = (EoBFlyingObject*)obj; return magicObjectDamageHit(fo, 1, 4, 1, (getMageLevel(fo->attackerId) - 1) >> 1); } -void EobCoreEngine::spellCallback_start_shockingGrasp() { +void EoBCoreEngine::spellCallback_start_shockingGrasp() { int t = createMagicWeaponType(0, 0, 0, 0x0f, 1, 8, getMageLevel(_openBookChar), 1); Item i = (t != -1) ? createMagicWeaponItem(0x10, 82, 0, t) : -1; if (t == -1 || i == -1) { @@ -854,8 +854,8 @@ void EobCoreEngine::spellCallback_start_shockingGrasp() { } } -bool EobCoreEngine::spellCallback_end_shockingGraspFlameBlade(void *obj) { - EobCharacter *c = (EobCharacter*)obj; +bool EoBCoreEngine::spellCallback_end_shockingGraspFlameBlade(void *obj) { + EoBCharacter *c = (EoBCharacter*)obj; for (int i = 0; i < 2; i++) { if (isMagicEffectItem(c->inventory[i])) { removeMagicWeaponItem(c->inventory[i]); @@ -865,7 +865,7 @@ bool EobCoreEngine::spellCallback_end_shockingGraspFlameBlade(void *obj) { return true; } -void EobCoreEngine::spellCallback_start_improvedIdentify() { +void EoBCoreEngine::spellCallback_start_improvedIdentify() { for (int i = 0; i < 2; i++) { Item itm = _characters[_activeSpellCharId].inventory[i]; if (itm) @@ -873,47 +873,47 @@ void EobCoreEngine::spellCallback_start_improvedIdentify() { } } -void EobCoreEngine::spellCallback_start_melfsAcidArrow() { +void EoBCoreEngine::spellCallback_start_melfsAcidArrow() { launchMagicObject(_openBookChar, 1, _currentBlock, _activeSpellCharacterPos, _currentDirection); } -bool EobCoreEngine::spellCallback_end_melfsAcidArrow(void *obj) { - EobFlyingObject *fo = (EobFlyingObject*)obj; +bool EoBCoreEngine::spellCallback_end_melfsAcidArrow(void *obj) { + EoBFlyingObject *fo = (EoBFlyingObject*)obj; assert(fo); return magicObjectDamageHit(fo, 2, 4, 0, getMageLevel(fo->attackerId) / 3); } -void EobCoreEngine::spellCallback_start_dispelMagic() { +void EoBCoreEngine::spellCallback_start_dispelMagic() { for (int i = 0; i < 6; i++) { if (testCharacter(i, 1)) removeAllCharacterEffects(i); } } -void EobCoreEngine::spellCallback_start_fireball() { +void EoBCoreEngine::spellCallback_start_fireball() { launchMagicObject(_openBookChar, 2, _currentBlock, _activeSpellCharacterPos, _currentDirection); } -bool EobCoreEngine::spellCallback_end_fireball(void *obj) { - EobFlyingObject *fo = (EobFlyingObject*)obj; +bool EoBCoreEngine::spellCallback_end_fireball(void *obj) { + EoBFlyingObject *fo = (EoBFlyingObject*)obj; return magicObjectDamageHit(fo, 1, 6, 0, getMageLevel(fo->attackerId)); } -void EobCoreEngine::spellCallback_start_flameArrow() { +void EoBCoreEngine::spellCallback_start_flameArrow() { launchMagicObject(_openBookChar, 3, _currentBlock, _activeSpellCharacterPos, _currentDirection); } -bool EobCoreEngine::spellCallback_end_flameArrow(void *obj) { - EobFlyingObject *fo = (EobFlyingObject*)obj; +bool EoBCoreEngine::spellCallback_end_flameArrow(void *obj) { + EoBFlyingObject *fo = (EoBFlyingObject*)obj; return magicObjectDamageHit(fo, 5, 6, 0, getMageLevel(fo->attackerId)); } -void EobCoreEngine::spellCallback_start_holdPerson() { +void EoBCoreEngine::spellCallback_start_holdPerson() { launchMagicObject(_openBookChar, _flags.gameID == GI_EOB1 ? 4 : 3, _currentBlock, _activeSpellCharacterPos, _currentDirection); } -bool EobCoreEngine::spellCallback_end_holdPerson(void *obj) { - EobFlyingObject *fo = (EobFlyingObject*)obj; +bool EoBCoreEngine::spellCallback_end_holdPerson(void *obj) { + EoBFlyingObject *fo = (EoBFlyingObject*)obj; bool res = false; if (_flags.gameID == GI_EOB2 && fo->curBlock == _currentBlock) { @@ -938,16 +938,16 @@ bool EobCoreEngine::spellCallback_end_holdPerson(void *obj) { return res; } -void EobCoreEngine::spellCallback_start_lightningBolt() { +void EoBCoreEngine::spellCallback_start_lightningBolt() { launchMagicObject(_openBookChar, _flags.gameID == GI_EOB1 ? 5 : 4, _currentBlock, _activeSpellCharacterPos, _currentDirection); } -bool EobCoreEngine::spellCallback_end_lightningBolt(void *obj) { - EobFlyingObject *fo = (EobFlyingObject*)obj; +bool EoBCoreEngine::spellCallback_end_lightningBolt(void *obj) { + EoBFlyingObject *fo = (EoBFlyingObject*)obj; return magicObjectDamageHit(fo, 1, 6, 0, getMageLevel(fo->attackerId)); } -void EobCoreEngine::spellCallback_start_vampiricTouch() { +void EoBCoreEngine::spellCallback_start_vampiricTouch() { int t = createMagicWeaponType(0, 0, 0, 0x0f, getMageLevel(_openBookChar) >> 1, 6, 0, 1); Item i = (t != -1) ? createMagicWeaponItem(0x18, 83, 0, t) : -1; if (t == -1 || i == -1) { @@ -961,15 +961,15 @@ void EobCoreEngine::spellCallback_start_vampiricTouch() { } } -bool EobCoreEngine::spellCallback_end_vampiricTouch(void *obj) { - EobCharacter *c = (EobCharacter*)obj; +bool EoBCoreEngine::spellCallback_end_vampiricTouch(void *obj) { + EoBCharacter *c = (EoBCharacter*)obj; if (c->hitPointsCur > c->hitPointsMax) c->hitPointsCur = c->hitPointsMax; spellCallback_end_shockingGraspFlameBlade(obj); return true; } -void EobCoreEngine::spellCallback_start_fear() { +void EoBCoreEngine::spellCallback_start_fear() { sparkEffectOffensive(); uint16 bl = calcNewBlockPosition(_currentBlock, _currentDirection); for (int i = 0; i < 30; i++) { @@ -978,12 +978,12 @@ void EobCoreEngine::spellCallback_start_fear() { } } -void EobCoreEngine::spellCallback_start_iceStorm() { +void EoBCoreEngine::spellCallback_start_iceStorm() { launchMagicObject(_openBookChar, _flags.gameID == GI_EOB1 ? 6 : 5, _currentBlock, _activeSpellCharacterPos, _currentDirection); } -bool EobCoreEngine::spellCallback_end_iceStorm(void *obj) { - EobFlyingObject *fo = (EobFlyingObject*)obj; +bool EoBCoreEngine::spellCallback_end_iceStorm(void *obj) { + EoBFlyingObject *fo = (EoBFlyingObject*)obj; static int8 blockAdv[] = { -32, 32, 1, -1 }; bool res = magicObjectDamageHit(fo, 1, 6, 0, getMageLevel(fo->attackerId)); if (res) { @@ -997,11 +997,11 @@ bool EobCoreEngine::spellCallback_end_iceStorm(void *obj) { return res; } -void EobCoreEngine::spellCallback_start_stoneSkin() { +void EoBCoreEngine::spellCallback_start_stoneSkin() { _characters[_activeSpellCharId].effectsRemainder[1] = (getMageLevel(_openBookChar) >> 1) + rollDice(1, 4); } -void EobCoreEngine::spellCallback_start_removeCurse() { +void EoBCoreEngine::spellCallback_start_removeCurse() { for (int i = 0; i < 27; i++) { Item itm = _characters[_activeSpellCharId].inventory[i]; if (itm && (_items[itm].flags & 0x20) && !isMagicEffectItem(itm)) @@ -1009,7 +1009,7 @@ void EobCoreEngine::spellCallback_start_removeCurse() { } } -void EobCoreEngine::spellCallback_start_coneOfCold() { +void EoBCoreEngine::spellCallback_start_coneOfCold() { const int8 *dirTables[] = { _coneOfColdDest1, _coneOfColdDest2, _coneOfColdDest3, _coneOfColdDest4 }; int cl = getMageLevel(_openBookChar); @@ -1034,19 +1034,19 @@ void EobCoreEngine::spellCallback_start_coneOfCold() { updateAllMonsterShapes(); } -void EobCoreEngine::spellCallback_start_holdMonster() { +void EoBCoreEngine::spellCallback_start_holdMonster() { launchMagicObject(_openBookChar, _flags.gameID == GI_EOB1 ? 7 : 6, _currentBlock, _activeSpellCharacterPos, _currentDirection); } -bool EobCoreEngine::spellCallback_end_holdMonster(void *obj) { - EobFlyingObject *fo = (EobFlyingObject*)obj; +bool EoBCoreEngine::spellCallback_end_holdMonster(void *obj) { + EoBFlyingObject *fo = (EoBFlyingObject*)obj; bool res = false; for (const int16 *m = findBlockMonsters(fo->curBlock, fo->curPos, fo->direction, 1, 1); *m != -1; m++) res |= magicObjectStatusHit(&_monsters[*m], 1, true, 4); return res; } -void EobCoreEngine::spellCallback_start_wallOfForce() { +void EoBCoreEngine::spellCallback_start_wallOfForce() { uint16 bl = calcNewBlockPosition(_currentBlock, _currentDirection); LevelBlockProperty *l = &_levelBlockProperties[bl]; if (l->walls[0] || l->walls[1] || l->walls[2] || l->walls[3] || (l->flags & 7)) { @@ -1076,7 +1076,7 @@ void EobCoreEngine::spellCallback_start_wallOfForce() { _sceneUpdateRequired = true; } -void EobCoreEngine::spellCallback_start_disintegrate() { +void EoBCoreEngine::spellCallback_start_disintegrate() { int d = findSingleSpellTarget(1); if (d != -1) magicObjectStatusHit(&_monsters[d], 4, true, 4); @@ -1084,7 +1084,7 @@ void EobCoreEngine::spellCallback_start_disintegrate() { _sceneUpdateRequired = true; } -void EobCoreEngine::spellCallback_start_fleshToStone() { +void EoBCoreEngine::spellCallback_start_fleshToStone() { sparkEffectOffensive(); int t = getClosestMonster(_openBookChar, calcNewBlockPosition(_currentBlock, _currentDirection)); if (t != -1) @@ -1093,23 +1093,23 @@ void EobCoreEngine::spellCallback_start_fleshToStone() { printWarning(_magicStrings8[4]); } -void EobCoreEngine::spellCallback_start_stoneToFlesh() { +void EoBCoreEngine::spellCallback_start_stoneToFlesh() { if (_characters[_activeSpellCharId].flags & 8) _characters[_activeSpellCharId].flags &= ~8; else printNoEffectWarning(); } -void EobCoreEngine::spellCallback_start_trueSeeing() { +void EoBCoreEngine::spellCallback_start_trueSeeing() { _wllVmpMap[46] = 0; } -bool EobCoreEngine::spellCallback_end_trueSeeing(void*) { +bool EoBCoreEngine::spellCallback_end_trueSeeing(void*) { _wllVmpMap[46] = 1; return true; } -void EobCoreEngine::spellCallback_start_slayLiving() { +void EoBCoreEngine::spellCallback_start_slayLiving() { int d = findSingleSpellTarget(2); if (d != -1) { if (!magicObjectStatusHit(&_monsters[d], 3, true, 4)) @@ -1117,7 +1117,7 @@ void EobCoreEngine::spellCallback_start_slayLiving() { } } -void EobCoreEngine::spellCallback_start_powerWordStun() { +void EoBCoreEngine::spellCallback_start_powerWordStun() { int d = findSingleSpellTarget(2); if (d != -1) { if (_monsters[d].hitPointsCur < 90) @@ -1125,15 +1125,15 @@ void EobCoreEngine::spellCallback_start_powerWordStun() { } } -void EobCoreEngine::spellCallback_start_causeLightWounds() { +void EoBCoreEngine::spellCallback_start_causeLightWounds() { causeWounds(1, 8, 0); } -void EobCoreEngine::spellCallback_start_cureLightWounds() { +void EoBCoreEngine::spellCallback_start_cureLightWounds() { modifyCharacterHitpoints(_activeSpellCharId, rollDice(1, 8)); } -void EobCoreEngine::spellCallback_start_aid() { +void EoBCoreEngine::spellCallback_start_aid() { if (!testCharacter(_activeSpellCharId, 3)) { printNoEffectWarning(); } else if (_characters[_activeSpellCharId].effectsRemainder[3]) { @@ -1149,15 +1149,15 @@ void EobCoreEngine::spellCallback_start_aid() { deleteCharEventTimer(_activeSpellCharId, -_activeSpell); } -bool EobCoreEngine::spellCallback_end_aid(void *obj) { - EobCharacter *c = (EobCharacter*)obj; +bool EoBCoreEngine::spellCallback_end_aid(void *obj) { + EoBCharacter *c = (EoBCharacter*)obj; c->hitPointsCur -= c->effectsRemainder[3]; c->effectsRemainder[3] = 0; c->effectFlags &= ~0x1000; return true; } -void EobCoreEngine::spellCallback_start_flameBlade() { +void EoBCoreEngine::spellCallback_start_flameBlade() { int t = createMagicWeaponType(0, 0, 0, 0x0f, 1, 4, 4, 1); Item i = (t != -1) ? createMagicWeaponItem(0, 84, 0, t) : -1; if (t == -1 || i == -1) { @@ -1171,7 +1171,7 @@ void EobCoreEngine::spellCallback_start_flameBlade() { } } -void EobCoreEngine::spellCallback_start_slowPoison() { +void EoBCoreEngine::spellCallback_start_slowPoison() { if (_characters[_activeSpellCharId].flags & 2) { _characters[_activeSpellCharId].effectFlags |= 0x2000; setSpellEventTimer(_activeSpell, 1, 32760, 1, 1); @@ -1180,13 +1180,13 @@ void EobCoreEngine::spellCallback_start_slowPoison() { } } -bool EobCoreEngine::spellCallback_end_slowPoison(void *obj) { - EobCharacter *c = (EobCharacter*)obj; +bool EoBCoreEngine::spellCallback_end_slowPoison(void *obj) { + EoBCharacter *c = (EoBCharacter*)obj; c->effectFlags &= ~0x2000; return true; } -void EobCoreEngine::spellCallback_start_createFood() { +void EoBCoreEngine::spellCallback_start_createFood() { for (int i = 0; i < 6; i++) { if (!testCharacter(i, 3)) continue; @@ -1194,7 +1194,7 @@ void EobCoreEngine::spellCallback_start_createFood() { } } -void EobCoreEngine::spellCallback_start_removeParalysis() { +void EoBCoreEngine::spellCallback_start_removeParalysis() { int numChar = 4; for (int i = 0; i < 6; i++) { if (!(_characters[i].flags & 4) || !numChar) @@ -1204,39 +1204,39 @@ void EobCoreEngine::spellCallback_start_removeParalysis() { } } -void EobCoreEngine::spellCallback_start_causeSeriousWounds() { +void EoBCoreEngine::spellCallback_start_causeSeriousWounds() { causeWounds(2, 8, 1); } -void EobCoreEngine::spellCallback_start_cureSeriousWounds() { +void EoBCoreEngine::spellCallback_start_cureSeriousWounds() { modifyCharacterHitpoints(_activeSpellCharId, rollDice(2, 8, 1)); } -void EobCoreEngine::spellCallback_start_neutralizePoison() { +void EoBCoreEngine::spellCallback_start_neutralizePoison() { if (_characters[_activeSpellCharId].flags & 2) neutralizePoison(_activeSpellCharId); else printNoEffectWarning(); } -void EobCoreEngine::spellCallback_start_causeCriticalWounds() { +void EoBCoreEngine::spellCallback_start_causeCriticalWounds() { causeWounds(3, 8, 3); } -void EobCoreEngine::spellCallback_start_cureCriticalWounds() { +void EoBCoreEngine::spellCallback_start_cureCriticalWounds() { modifyCharacterHitpoints(_activeSpellCharId, rollDice(3, 8, 3)); } -void EobCoreEngine::spellCallback_start_flameStrike() { +void EoBCoreEngine::spellCallback_start_flameStrike() { launchMagicObject(_openBookChar, _flags.gameID == GI_EOB1 ? 8 : 7, _currentBlock, _activeSpellCharacterPos, _currentDirection); } -bool EobCoreEngine::spellCallback_end_flameStrike(void *obj) { - EobFlyingObject *fo = (EobFlyingObject*)obj; +bool EoBCoreEngine::spellCallback_end_flameStrike(void *obj) { + EoBFlyingObject *fo = (EoBFlyingObject*)obj; return magicObjectDamageHit(fo, 6, 8, 0, 0); } -void EobCoreEngine::spellCallback_start_raiseDead() { +void EoBCoreEngine::spellCallback_start_raiseDead() { if (_characters[_activeSpellCharId].hitPointsCur == -10 && ((_characters[_activeSpellCharId].raceSex >> 1) != 1)) { _characters[_activeSpellCharId].hitPointsCur = 1; gui_drawCharPortraitWithStats(_activeSpellCharId); @@ -1245,23 +1245,23 @@ void EobCoreEngine::spellCallback_start_raiseDead() { } } -void EobCoreEngine::spellCallback_start_harm() { +void EoBCoreEngine::spellCallback_start_harm() { causeWounds(-1, -1, -1); } -void EobCoreEngine::spellCallback_start_heal() { - EobCharacter *c = &_characters[_activeSpellCharId]; +void EoBCoreEngine::spellCallback_start_heal() { + EoBCharacter *c = &_characters[_activeSpellCharId]; if (c->hitPointsMax <= c->hitPointsCur) printWarning(_magicStrings4[0]); else modifyCharacterHitpoints(_activeSpellCharId, c->hitPointsMax - c->hitPointsCur); } -void EobCoreEngine::spellCallback_start_layOnHands() { +void EoBCoreEngine::spellCallback_start_layOnHands() { modifyCharacterHitpoints(_activeSpellCharId, _characters[_openBookChar].level[0] << 1); } -void EobCoreEngine::spellCallback_start_turnUndead() { +void EoBCoreEngine::spellCallback_start_turnUndead() { uint16 bl = calcNewBlockPosition(_currentBlock, _currentDirection); if (!(_levelBlockProperties[bl].flags & 7)) return; @@ -1287,13 +1287,13 @@ void EobCoreEngine::spellCallback_start_turnUndead() { _preventMonsterFlash = false; } -bool EobCoreEngine::spellCallback_end_monster_lightningBolt(void *obj) { - EobFlyingObject *fo = (EobFlyingObject*)obj; +bool EoBCoreEngine::spellCallback_end_monster_lightningBolt(void *obj) { + EoBFlyingObject *fo = (EoBFlyingObject*)obj; return magicObjectDamageHit(fo, 0, 0, 12, 1); } -bool EobCoreEngine::spellCallback_end_monster_fireball1(void *obj) { - EobFlyingObject *fo = (EobFlyingObject*)obj; +bool EoBCoreEngine::spellCallback_end_monster_fireball1(void *obj) { + EoBFlyingObject *fo = (EoBFlyingObject*)obj; bool res = false; if (_partyEffectFlags & 0x20000) { res = magicObjectDamageHit(fo, 4, 10, 6, 0); @@ -1307,13 +1307,13 @@ bool EobCoreEngine::spellCallback_end_monster_fireball1(void *obj) { return res; } -bool EobCoreEngine::spellCallback_end_monster_fireball2(void *obj) { - EobFlyingObject *fo = (EobFlyingObject*)obj; +bool EoBCoreEngine::spellCallback_end_monster_fireball2(void *obj) { + EoBFlyingObject *fo = (EoBFlyingObject*)obj; return magicObjectDamageHit(fo, 0, 0, 18, 0); } -bool EobCoreEngine::spellCallback_end_monster_deathSpell(void *obj) { - EobFlyingObject *fo = (EobFlyingObject*)obj; +bool EoBCoreEngine::spellCallback_end_monster_deathSpell(void *obj) { + EoBFlyingObject *fo = (EoBFlyingObject*)obj; if (fo->curBlock != _currentBlock) return false; @@ -1329,8 +1329,8 @@ bool EobCoreEngine::spellCallback_end_monster_deathSpell(void *obj) { return true; } -bool EobCoreEngine::spellCallback_end_monster_disintegrate(void *obj) { - EobFlyingObject *fo = (EobFlyingObject*)obj; +bool EoBCoreEngine::spellCallback_end_monster_disintegrate(void *obj) { + EoBFlyingObject *fo = (EoBFlyingObject*)obj; if (fo->curBlock != _currentBlock) return false; @@ -1345,8 +1345,8 @@ bool EobCoreEngine::spellCallback_end_monster_disintegrate(void *obj) { return true; } -bool EobCoreEngine::spellCallback_end_monster_causeCriticalWounds(void *obj) { - EobFlyingObject *fo = (EobFlyingObject*)obj; +bool EoBCoreEngine::spellCallback_end_monster_causeCriticalWounds(void *obj) { + EoBFlyingObject *fo = (EoBFlyingObject*)obj; if (fo->curBlock != _currentBlock) return false; @@ -1359,8 +1359,8 @@ bool EobCoreEngine::spellCallback_end_monster_causeCriticalWounds(void *obj) { return true; } -bool EobCoreEngine::spellCallback_end_monster_fleshToStone(void *obj) { - EobFlyingObject *fo = (EobFlyingObject*)obj; +bool EoBCoreEngine::spellCallback_end_monster_fleshToStone(void *obj) { + EoBFlyingObject *fo = (EoBFlyingObject*)obj; if (fo->curBlock != _currentBlock) return false; -- cgit v1.2.3 From a95f34bc64ada8f1d35466a0e4cb10c96ba95580 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 27 Dec 2011 02:02:19 +0100 Subject: KYRA: Some formatting fixes. --- engines/kyra/magic_eob.cpp | 54 +++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'engines/kyra/magic_eob.cpp') diff --git a/engines/kyra/magic_eob.cpp b/engines/kyra/magic_eob.cpp index c1b0327df2..1c29206982 100644 --- a/engines/kyra/magic_eob.cpp +++ b/engines/kyra/magic_eob.cpp @@ -40,7 +40,7 @@ void EoBCoreEngine::useMagicBookOrSymbol(int charIndex, int type) { int8 *tmp = _openBookAvailableSpells + _openBookSpellLevel * 10 + _openBookSpellListOffset + _openBookSpellSelectedItem; if (*tmp <= 0) { - for (bool loop = true; loop && _openBookSpellSelectedItem < 10; ) { + for (bool loop = true; loop && _openBookSpellSelectedItem < 10;) { tmp = _openBookAvailableSpells + _openBookSpellLevel * 10 + _openBookSpellListOffset + _openBookSpellSelectedItem; if (*tmp > 0) { if (_openBookSpellSelectedItem > 5) { @@ -448,7 +448,7 @@ void EoBCoreEngine::sparkEffectOffensive() { } void EoBCoreEngine::setSpellEventTimer(int spell, int timerBaseFactor, int timerLength, int timerLevelFactor, int updateExistingTimer) { - assert (spell >= 0); + assert(spell >= 0); int l = _openBookType == 1 ? getClericPaladinLevel(_openBookChar) : getMageLevel(_openBookChar); uint32 countdown = timerLength * timerBaseFactor + timerLength * l * timerLevelFactor; setCharEventTimer(_activeSpellCharId, countdown, -spell, updateExistingTimer); @@ -457,7 +457,7 @@ void EoBCoreEngine::setSpellEventTimer(int spell, int timerBaseFactor, int timer void EoBCoreEngine::sortCharacterSpellList(int charIndex) { int8 *list = _characters[charIndex].mageSpells; - for (int i = 0; i < 16; ) { + for (int i = 0; i < 16;) { bool p = false; for (int ii = 0; ii < 9; ii++) { int8 *pos = &list[ii]; @@ -758,7 +758,7 @@ int EoBCoreEngine::findFirstCharacterSpellTarget() { } int EoBCoreEngine::findNextCharacterSpellTarget(int curCharIndex) { - for (_characterSpellTarget++; _characterSpellTarget < 6; ) { + for (_characterSpellTarget++; _characterSpellTarget < 6;) { if (++curCharIndex == 6) curCharIndex = 0; if (testCharacter(curCharIndex, 3)) @@ -826,7 +826,7 @@ void EoBCoreEngine::spellCallback_start_detectMagic() { setHandItem(_itemInHand); } -bool EoBCoreEngine::spellCallback_end_detectMagic(void*) { +bool EoBCoreEngine::spellCallback_end_detectMagic(void *) { setHandItem(_itemInHand); return true; } @@ -836,7 +836,7 @@ void EoBCoreEngine::spellCallback_start_magicMissile() { } bool EoBCoreEngine::spellCallback_end_magicMissile(void *obj) { - EoBFlyingObject *fo = (EoBFlyingObject*)obj; + EoBFlyingObject *fo = (EoBFlyingObject *)obj; return magicObjectDamageHit(fo, 1, 4, 1, (getMageLevel(fo->attackerId) - 1) >> 1); } @@ -855,7 +855,7 @@ void EoBCoreEngine::spellCallback_start_shockingGrasp() { } bool EoBCoreEngine::spellCallback_end_shockingGraspFlameBlade(void *obj) { - EoBCharacter *c = (EoBCharacter*)obj; + EoBCharacter *c = (EoBCharacter *)obj; for (int i = 0; i < 2; i++) { if (isMagicEffectItem(c->inventory[i])) { removeMagicWeaponItem(c->inventory[i]); @@ -878,7 +878,7 @@ void EoBCoreEngine::spellCallback_start_melfsAcidArrow() { } bool EoBCoreEngine::spellCallback_end_melfsAcidArrow(void *obj) { - EoBFlyingObject *fo = (EoBFlyingObject*)obj; + EoBFlyingObject *fo = (EoBFlyingObject *)obj; assert(fo); return magicObjectDamageHit(fo, 2, 4, 0, getMageLevel(fo->attackerId) / 3); } @@ -895,7 +895,7 @@ void EoBCoreEngine::spellCallback_start_fireball() { } bool EoBCoreEngine::spellCallback_end_fireball(void *obj) { - EoBFlyingObject *fo = (EoBFlyingObject*)obj; + EoBFlyingObject *fo = (EoBFlyingObject *)obj; return magicObjectDamageHit(fo, 1, 6, 0, getMageLevel(fo->attackerId)); } @@ -904,7 +904,7 @@ void EoBCoreEngine::spellCallback_start_flameArrow() { } bool EoBCoreEngine::spellCallback_end_flameArrow(void *obj) { - EoBFlyingObject *fo = (EoBFlyingObject*)obj; + EoBFlyingObject *fo = (EoBFlyingObject *)obj; return magicObjectDamageHit(fo, 5, 6, 0, getMageLevel(fo->attackerId)); } @@ -913,7 +913,7 @@ void EoBCoreEngine::spellCallback_start_holdPerson() { } bool EoBCoreEngine::spellCallback_end_holdPerson(void *obj) { - EoBFlyingObject *fo = (EoBFlyingObject*)obj; + EoBFlyingObject *fo = (EoBFlyingObject *)obj; bool res = false; if (_flags.gameID == GI_EOB2 && fo->curBlock == _currentBlock) { @@ -943,7 +943,7 @@ void EoBCoreEngine::spellCallback_start_lightningBolt() { } bool EoBCoreEngine::spellCallback_end_lightningBolt(void *obj) { - EoBFlyingObject *fo = (EoBFlyingObject*)obj; + EoBFlyingObject *fo = (EoBFlyingObject *)obj; return magicObjectDamageHit(fo, 1, 6, 0, getMageLevel(fo->attackerId)); } @@ -962,7 +962,7 @@ void EoBCoreEngine::spellCallback_start_vampiricTouch() { } bool EoBCoreEngine::spellCallback_end_vampiricTouch(void *obj) { - EoBCharacter *c = (EoBCharacter*)obj; + EoBCharacter *c = (EoBCharacter *)obj; if (c->hitPointsCur > c->hitPointsMax) c->hitPointsCur = c->hitPointsMax; spellCallback_end_shockingGraspFlameBlade(obj); @@ -983,7 +983,7 @@ void EoBCoreEngine::spellCallback_start_iceStorm() { } bool EoBCoreEngine::spellCallback_end_iceStorm(void *obj) { - EoBFlyingObject *fo = (EoBFlyingObject*)obj; + EoBFlyingObject *fo = (EoBFlyingObject *)obj; static int8 blockAdv[] = { -32, 32, 1, -1 }; bool res = magicObjectDamageHit(fo, 1, 6, 0, getMageLevel(fo->attackerId)); if (res) { @@ -1039,7 +1039,7 @@ void EoBCoreEngine::spellCallback_start_holdMonster() { } bool EoBCoreEngine::spellCallback_end_holdMonster(void *obj) { - EoBFlyingObject *fo = (EoBFlyingObject*)obj; + EoBFlyingObject *fo = (EoBFlyingObject *)obj; bool res = false; for (const int16 *m = findBlockMonsters(fo->curBlock, fo->curPos, fo->direction, 1, 1); *m != -1; m++) res |= magicObjectStatusHit(&_monsters[*m], 1, true, 4); @@ -1104,7 +1104,7 @@ void EoBCoreEngine::spellCallback_start_trueSeeing() { _wllVmpMap[46] = 0; } -bool EoBCoreEngine::spellCallback_end_trueSeeing(void*) { +bool EoBCoreEngine::spellCallback_end_trueSeeing(void *) { _wllVmpMap[46] = 1; return true; } @@ -1150,7 +1150,7 @@ void EoBCoreEngine::spellCallback_start_aid() { } bool EoBCoreEngine::spellCallback_end_aid(void *obj) { - EoBCharacter *c = (EoBCharacter*)obj; + EoBCharacter *c = (EoBCharacter *)obj; c->hitPointsCur -= c->effectsRemainder[3]; c->effectsRemainder[3] = 0; c->effectFlags &= ~0x1000; @@ -1181,7 +1181,7 @@ void EoBCoreEngine::spellCallback_start_slowPoison() { } bool EoBCoreEngine::spellCallback_end_slowPoison(void *obj) { - EoBCharacter *c = (EoBCharacter*)obj; + EoBCharacter *c = (EoBCharacter *)obj; c->effectFlags &= ~0x2000; return true; } @@ -1232,7 +1232,7 @@ void EoBCoreEngine::spellCallback_start_flameStrike() { } bool EoBCoreEngine::spellCallback_end_flameStrike(void *obj) { - EoBFlyingObject *fo = (EoBFlyingObject*)obj; + EoBFlyingObject *fo = (EoBFlyingObject *)obj; return magicObjectDamageHit(fo, 6, 8, 0, 0); } @@ -1288,12 +1288,12 @@ void EoBCoreEngine::spellCallback_start_turnUndead() { } bool EoBCoreEngine::spellCallback_end_monster_lightningBolt(void *obj) { - EoBFlyingObject *fo = (EoBFlyingObject*)obj; + EoBFlyingObject *fo = (EoBFlyingObject *)obj; return magicObjectDamageHit(fo, 0, 0, 12, 1); } bool EoBCoreEngine::spellCallback_end_monster_fireball1(void *obj) { - EoBFlyingObject *fo = (EoBFlyingObject*)obj; + EoBFlyingObject *fo = (EoBFlyingObject *)obj; bool res = false; if (_partyEffectFlags & 0x20000) { res = magicObjectDamageHit(fo, 4, 10, 6, 0); @@ -1308,12 +1308,12 @@ bool EoBCoreEngine::spellCallback_end_monster_fireball1(void *obj) { } bool EoBCoreEngine::spellCallback_end_monster_fireball2(void *obj) { - EoBFlyingObject *fo = (EoBFlyingObject*)obj; + EoBFlyingObject *fo = (EoBFlyingObject *)obj; return magicObjectDamageHit(fo, 0, 0, 18, 0); } bool EoBCoreEngine::spellCallback_end_monster_deathSpell(void *obj) { - EoBFlyingObject *fo = (EoBFlyingObject*)obj; + EoBFlyingObject *fo = (EoBFlyingObject *)obj; if (fo->curBlock != _currentBlock) return false; @@ -1330,7 +1330,7 @@ bool EoBCoreEngine::spellCallback_end_monster_deathSpell(void *obj) { } bool EoBCoreEngine::spellCallback_end_monster_disintegrate(void *obj) { - EoBFlyingObject *fo = (EoBFlyingObject*)obj; + EoBFlyingObject *fo = (EoBFlyingObject *)obj; if (fo->curBlock != _currentBlock) return false; @@ -1346,7 +1346,7 @@ bool EoBCoreEngine::spellCallback_end_monster_disintegrate(void *obj) { } bool EoBCoreEngine::spellCallback_end_monster_causeCriticalWounds(void *obj) { - EoBFlyingObject *fo = (EoBFlyingObject*)obj; + EoBFlyingObject *fo = (EoBFlyingObject *)obj; if (fo->curBlock != _currentBlock) return false; @@ -1360,7 +1360,7 @@ bool EoBCoreEngine::spellCallback_end_monster_causeCriticalWounds(void *obj) { } bool EoBCoreEngine::spellCallback_end_monster_fleshToStone(void *obj) { - EoBFlyingObject *fo = (EoBFlyingObject*)obj; + EoBFlyingObject *fo = (EoBFlyingObject *)obj; if (fo->curBlock != _currentBlock) return false; @@ -1377,6 +1377,6 @@ bool EoBCoreEngine::spellCallback_end_monster_fleshToStone(void *obj) { return true; } -} // End of namespace Kyra +} // End of namespace Kyra #endif // ENABLE_EOB -- cgit v1.2.3 From 536abf6d3de82f67342d73eefea7b63e3172f4d0 Mon Sep 17 00:00:00 2001 From: athrxx Date: Tue, 27 Dec 2011 12:53:53 +0100 Subject: KYRA: (EOB) - fix signed/unsigned mismatch --- engines/kyra/magic_eob.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/kyra/magic_eob.cpp') diff --git a/engines/kyra/magic_eob.cpp b/engines/kyra/magic_eob.cpp index 1c29206982..fbddd620d1 100644 --- a/engines/kyra/magic_eob.cpp +++ b/engines/kyra/magic_eob.cpp @@ -711,7 +711,7 @@ Item EoBCoreEngine::createMagicWeaponItem(int flags, int icon, int value, int ty void EoBCoreEngine::removeMagicWeaponItem(Item item) { _itemTypes[_items[item].type].armorClass = -30; _items[item].block = -2; - _items[item].level = -1; + _items[item].level = 0xff; } void EoBCoreEngine::updateWallOfForceTimers() { -- cgit v1.2.3 From 66da4777d476c6a9fc2a13351e3b30afc748fd94 Mon Sep 17 00:00:00 2001 From: athrxx Date: Tue, 21 Feb 2012 21:14:28 +0100 Subject: KYRA: (EOB) - implement EGA mode (hi res dithering) for EOB II (also fix various thing connected to CGA/EGA modes) --- engines/kyra/magic_eob.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/kyra/magic_eob.cpp') diff --git a/engines/kyra/magic_eob.cpp b/engines/kyra/magic_eob.cpp index fbddd620d1..b2949ce1d5 100644 --- a/engines/kyra/magic_eob.cpp +++ b/engines/kyra/magic_eob.cpp @@ -60,7 +60,7 @@ void EoBCoreEngine::useMagicBookOrSymbol(int charIndex, int type) { } if (!_updateFlags) - _screen->copyRegion(64, 121, 0, 0, 112, 56, 0, 10, Screen::CR_NO_P_CHECK); + _screen->copyRegion(64, 121, 0, 0, 112, 56, 0, (_screen->getPageScaleFactor(0) == 2) ? 4 : 10, Screen::CR_NO_P_CHECK); _updateFlags = 1; gui_setPlayFieldButtons(); gui_drawSpellbook(); -- cgit v1.2.3 From ecd1a9f9435c5fc5d502d75dd256394b5f3283f3 Mon Sep 17 00:00:00 2001 From: athrxx Date: Thu, 23 Feb 2012 21:36:14 +0100 Subject: KYRA: (EOB) - cleanup CGA/EGA code a bit --- engines/kyra/magic_eob.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/kyra/magic_eob.cpp') diff --git a/engines/kyra/magic_eob.cpp b/engines/kyra/magic_eob.cpp index b2949ce1d5..985286854b 100644 --- a/engines/kyra/magic_eob.cpp +++ b/engines/kyra/magic_eob.cpp @@ -60,7 +60,7 @@ void EoBCoreEngine::useMagicBookOrSymbol(int charIndex, int type) { } if (!_updateFlags) - _screen->copyRegion(64, 121, 0, 0, 112, 56, 0, (_screen->getPageScaleFactor(0) == 2) ? 4 : 10, Screen::CR_NO_P_CHECK); + _screen->copyRegion(64, 121, 0, 0, 112, 56, 0, _useHiResDithering ? 4 : 10, Screen::CR_NO_P_CHECK); _updateFlags = 1; gui_setPlayFieldButtons(); gui_drawSpellbook(); -- cgit v1.2.3