Skip to content

Commit

Permalink
KYRA: (EOB) - fix various bugs and implement some spells
Browse files Browse the repository at this point in the history
  • Loading branch information
athrxx authored and Johannes Schickel committed Dec 26, 2011
1 parent 9140fd8 commit c302b3e
Show file tree
Hide file tree
Showing 13 changed files with 248 additions and 148 deletions.
2 changes: 1 addition & 1 deletion engines/kyra/eob2.cpp
Expand Up @@ -272,7 +272,7 @@ void DarkMoonEngine::replaceMonster(int unit, uint16 block, int pos, int dir, in
}

bool DarkMoonEngine::killMonsterExtra(EobMonsterInPlay *m) {
if (_currentLevel == 16 && _currentSub == 1 && (_monsterProps[m->type].flags & 4)) {
if (_currentLevel == 16 && _currentSub == 1 && (_monsterProps[m->type].capsFlags & 4)) {
if (m->type) {
_playFinale = true;
_runFlag = false;
Expand Down
20 changes: 10 additions & 10 deletions engines/kyra/eobcommon.cpp
Expand Up @@ -1547,7 +1547,7 @@ void EobCoreEngine::inflictMonsterDamage(EobMonsterInPlay *m, int damage, bool g
m->hitPointsCur -= damage;
m->flags = (m->flags & 0xf7) | 1;

if (_monsterProps[m->type].flags & 0x2000) {
if (_monsterProps[m->type].capsFlags & 0x2000) {
explodeMonster(m);
checkSceneUpdateNeed(m->block);
m->hitPointsCur = 0;
Expand Down Expand Up @@ -1762,7 +1762,7 @@ void EobCoreEngine::monsterCloseAttack(EobMonsterInPlay *m) {
}

if (dmg > 0) {
if ((_monsterProps[m->type].flags & 0x80) && rollDice(1, 4, -1) != 3) {
if ((_monsterProps[m->type].capsFlags & 0x80) && rollDice(1, 4, -1) != 3) {
int slot = rollDice(1, 27, -1);
for (int iii = 0; iii < 27; iii++) {
Item itm = _characters[c].inventory[slot];
Expand All @@ -1782,20 +1782,20 @@ void EobCoreEngine::monsterCloseAttack(EobMonsterInPlay *m) {

inflictCharacterDamage(c, dmg);

if (_monsterProps[m->type].flags & 0x10) {
if (_monsterProps[m->type].capsFlags & 0x10) {
statusAttack(c, 2, _monsterSpecAttStrings[_flags.gameID == GI_EOB1 ? 3 : 2], 0, 1, 8, 1);
_characters[c].effectFlags &= ~0x2000;
}

if (_monsterProps[m->type].flags & 0x20)
if (_monsterProps[m->type].capsFlags & 0x20)
statusAttack(c, 4, _monsterSpecAttStrings[_flags.gameID == GI_EOB1 ? 4 : 3], 2, 5, 9, 1);

if (_monsterProps[m->type].flags & 0x8000)
if (_monsterProps[m->type].capsFlags & 0x8000)
statusAttack(c, 8, _monsterSpecAttStrings[4], 2, 0, 0, 1);

}

if (!(_monsterProps[m->type].flags & 0x4000))
if (!(_monsterProps[m->type].capsFlags & 0x4000))
return;
}
}
Expand Down Expand Up @@ -1848,7 +1848,7 @@ int EobCoreEngine::calcCloseDistanceMonsterDamage(EobMonsterInPlay *m, int times
s = 1;
}

if ((flags & 0x100) && ((_flags.gameID == GI_EOB2 && (p->statusFlags & 0x100)) || (_flags.gameID == GI_EOB1 && (p->flags & 4))) && (!(_itemTypes[_items[pips].type].allowedClasses & 4 /* bug in original code ??*/)))
if ((flags & 0x100) && ((_flags.gameID == GI_EOB2 && (p->statusFlags & 0x100)) || (_flags.gameID == GI_EOB1 && (p->capsFlags & 4))) && (!(_itemTypes[_items[pips].type].allowedClasses & 4 /* bug in original code ??*/)))
s >>= 1;

if (p->statusFlags & 0x2000) {
Expand All @@ -1866,7 +1866,7 @@ int EobCoreEngine::calcCloseDistanceMonsterDamage(EobMonsterInPlay *m, int times
}

if (flags & 1) {
if (checkMonsterDamageEvasion(m))
if (tryMonsterAttackEvasion(m))
s = 0;
}

Expand All @@ -1887,7 +1887,7 @@ int EobCoreEngine::calcDamageModifers(int charIndex, EobMonsterInPlay *m, int it
if (item) {
EobItemType *p = &_itemTypes[itemType];
int t = m ? m->type : 0;
s += ((m && (_monsterProps[t].flags & 1)) ? rollDice(p->dmgNumDiceL, p->dmgNumPipsL, p->dmgIncS /* bug in original code ? */) :
s += ((m && (_monsterProps[t].capsFlags & 1)) ? rollDice(p->dmgNumDiceL, p->dmgNumPipsL, p->dmgIncS /* bug in original code ? */) :
rollDice(p->dmgNumDiceS, p->dmgNumPipsS, p->dmgIncS));
s += _items[item].value;
} else {
Expand Down Expand Up @@ -1941,7 +1941,7 @@ int EobCoreEngine::recalcDamageModifier(int damageType, int dmgModifier) {
return dmgModifier;
}

bool EobCoreEngine::checkMonsterDamageEvasion(EobMonsterInPlay *m) {
bool EobCoreEngine::tryMonsterAttackEvasion(EobMonsterInPlay *m) {
return rollDice(1, 100) < _monsterProps[m->type].dmgModifierEvade ? true : false;
}

Expand Down
20 changes: 12 additions & 8 deletions engines/kyra/eobcommon.h
Expand Up @@ -169,8 +169,8 @@ struct EobMonsterProperty {
int8 base;
} dmgDc[3];
uint16 statusFlags;
uint16 flags;
int32 u22;
uint32 capsFlags;
uint32 typeFlags;
int32 experience;

uint8 u30;
Expand All @@ -182,7 +182,7 @@ struct EobMonsterProperty {

int8 remoteWeapons[5];

uint8 u41;
uint8 tuResist;
uint8 dmgModifierEvade;

uint8 decorations[3];
Expand All @@ -199,7 +199,7 @@ struct EobMonsterInPlay {
int8 mode;
int8 f_9;
int8 curAttackFrame;
uint8 f_b;
int8 spellStatusLeft;
int16 hitPointsMax;
int16 hitPointsCur;
uint16 dest;
Expand Down Expand Up @@ -334,7 +334,7 @@ friend class CharacterGenerator;
void setCharEventTimer(int charIndex, uint32 countdown, int evnt, int updateExistingTimer);
void deleteCharEventTimer(int charIndex, int evnt);
void setupCharacterTimers();
void manualAdvanceTimer(int sysTimer, uint32 millis);
void advanceTimers(uint32 millis);

void timerProcessMonsters(int timerNum);
void timerSpecialCharacterUpdate(int timerNum);
Expand Down Expand Up @@ -511,7 +511,7 @@ friend class CharacterGenerator;
bool walkMonsterNextStep(EobMonsterInPlay *m, int destBlock, int direction);
void updateMonsterFollowPath(EobMonsterInPlay *m, int turnSteps);
void updateMonstersStraying(EobMonsterInPlay *m, int a);
void updateMonsters_mode710(EobMonsterInPlay *m);
void updateMonstersSpellStatus(EobMonsterInPlay *m);
void setBlockMonsterDirection(int block, int dir);

uint8 *_monsterOvl1;
Expand Down Expand Up @@ -829,7 +829,7 @@ friend class CharacterGenerator;
int getConstModifierTableValue(int hpModifier, int level, int b);
bool calcDamageCheckItemType(int itemType);
int recalcDamageModifier(int damageType, int dmgModifier);
bool checkMonsterDamageEvasion(EobMonsterInPlay *m);
bool tryMonsterAttackEvasion(EobMonsterInPlay *m);
int getStrHitChanceModifier(int charIndex);
int getStrDamageModifier(int charIndex);
int getDexHitChanceModifier(int charIndex);
Expand All @@ -856,7 +856,11 @@ friend class CharacterGenerator;
void setSpellEventTimer(int spell, int timerBaseFactor, int timerLength, int timerLevelFactor, int updateExistingTimer);
void sortCharacterSpellList(int charIndex);

bool magicObjectHit(EobFlyingObject *fo, int dcTimes, int dcPips, int dcOffs, int level);
bool magicObjectDamageHit(EobFlyingObject *fo, int dcTimes, int dcPips, int dcOffs, int level);
bool magicObjectStatusHit(EobMonsterInPlay *m, int type, bool tryEvade, int mod);

void printWarning(const char* str);
void printNoEffectWarning();

void spellCallback_start_empty() {}
bool spellCallback_end_empty(EobFlyingObject *fo) { return true; }
Expand Down
38 changes: 21 additions & 17 deletions engines/kyra/gui_eob.cpp
Expand Up @@ -665,11 +665,13 @@ void EobCoreEngine::gui_drawSpellbook() {
int textXs = 71;
int textY = 170;
int col3 = _bkgColor_1;
int col4 = _color6;

if (_flags.gameID == GI_EOB1) {
textCol2 = 11;
textXa = textXs = 73;
textY = 168;
col4 = _bkgColor_1;
}

for (int i = 0; i < 7; i++) {
Expand All @@ -686,7 +688,7 @@ void EobCoreEngine::gui_drawSpellbook() {
if (d >= 0 && i < 6 && (i + _openBookSpellListOffset) < 9)
_screen->printText(_openBookSpellList[d], textXs, 132 + 6 * i, textCol1, col3);
else
_screen->printText(_magicStrings1[0], textXa, textY, 12, _color6);
_screen->printText(_magicStrings1[0], textXa, textY, 12, col4);
}
}

Expand Down Expand Up @@ -805,7 +807,7 @@ void EobCoreEngine::gui_initButton(int index, int, int, int) {

if (_flags.gameID == GI_EOB1) {
// EOB1 spellbook modifications
if (index > 61 && index < 67)
if (index > 60 && index < 66)
d = &_buttonDefs[index + 33];
if (index == 88)
d = &_buttonDefs[index + 12];
Expand Down Expand Up @@ -867,7 +869,7 @@ int EobCoreEngine::clickedCamp(Button *button) {
_screen->updateScreen();

enableSysTimer(2);
manualAdvanceTimer(2, _restPartyElapsedTime);
advanceTimers(_restPartyElapsedTime);
_restPartyElapsedTime = 0;

checkPartyStatus(true);
Expand Down Expand Up @@ -1083,7 +1085,7 @@ int EobCoreEngine::clickedSpellbookList(Button *button) {

int s = _openBookAvailableSpells[_openBookSpellLevel * 10 + _openBookSpellListOffset + _openBookSpellSelectedItem];
if (_openBookType == 1)
s += _mageSpellListSize;
s += _clericSpellOffset;

castSpell(s, 0);

Expand All @@ -1100,11 +1102,10 @@ int EobCoreEngine::clickedSpellbookList(Button *button) {
}

int EobCoreEngine::clickedCastSpellOnCharacter(Button *button) {
_activeSpellCaster = button->arg;
_activeSpellCaster = button->arg & 0xff;

if (_activeSpellCaster == 255) {
_txt->printMessage(_magicStrings3[1]);
snd_playSoundEffect(79);
if (_activeSpellCaster == 0xff) {
printWarning(_magicStrings3[_flags.gameID == GI_EOB1 ? 2 : 1]);
if (_castScrollSlot) {
gui_updateSlotAfterScrollUse();
} else {
Expand Down Expand Up @@ -2774,7 +2775,7 @@ void GUI_Eob::runMemorizePrayMenu(int charIndex, int spellType) {

for (int i = 0; i < 80; i++) {
int8 s = charSpellList[i];
if (s == 0 || s == _vm->_spellLevelsClericSize)
if (s == 0 || (_vm->game() == GI_EOB2 && s == 29))
continue;

if (s < 0)
Expand Down Expand Up @@ -2938,8 +2939,8 @@ void GUI_Eob::runMemorizePrayMenu(int charIndex, int spellType) {
_screen->setFont(Screen::FID_8_FNT);

memset(charSpellList, 0, 80);
if (spellType)
charSpellList[0] = _vm->_spellLevelsClericSize;
if (spellType && _vm->game() == GI_EOB2)
charSpellList[0] = 29;

for (int i = 0; i < 32; i++) {
if (_numAssignedSpellsOfType[i * 2] < _numAssignedSpellsOfType[i * 2 + 1])
Expand Down Expand Up @@ -3187,7 +3188,7 @@ bool GUI_Eob::restParty() {

*list *= -1;
crs[i] = 48;
_vm->_txt->printMessage(Common::String::format(_vm->_menuStringsRest2[0], _vm->_characters[i].name, _vm->_spells[_vm->_mageSpellListSize + *list].name).c_str());
_vm->_txt->printMessage(Common::String::format(_vm->_menuStringsRest2[0], _vm->_characters[i].name, _vm->_spells[_vm->_clericSpellOffset + *list].name).c_str());
_vm->delay(80);
break;
}
Expand Down Expand Up @@ -3485,7 +3486,7 @@ void GUI_Eob::messageDialogue(int dim, int id, int buttonTextCol) {
}

int GUI_Eob::selectCharacterDialogue(int id) {
uint8 flags = (id == 26) ? 0x14 : 0x02;
uint8 flags = (id == 26) ? (_vm->game() == GI_EOB1 ? 0x04 : 0x14) : 0x02;
_vm->removeInputTop();

_charSelectRedraw = false;
Expand Down Expand Up @@ -3613,10 +3614,13 @@ int GUI_Eob::selectCharacterDialogue(int id) {
_screen->setFont(Screen::FID_8_FNT);

if (result != -1 && id != 53) {
if (flags == 0x14) {
if (_vm->_classModifierFlags[_vm->_characters[result].cClass] & 0x10 && _vm->_characters[result].level[0] < 9) {
displayTextBox(24);
result = -1;
if (flags & 4) {
int lv = _vm->getCharacterLevelIndex(4, _vm->_characters[result].cClass);
if (lv != -1) {
if (_vm->_characters[result].level[lv] < 9) {
displayTextBox(24);
result = -1;
}
}
} else {
if (_vm->checkInventoryForItem(result, 29, -1) == -1) {
Expand Down
3 changes: 1 addition & 2 deletions engines/kyra/items_eob.cpp
Expand Up @@ -445,8 +445,7 @@ void EobCoreEngine::eatItemInHand(int charIndex) {
} else if (_itemInHand && _items[_itemInHand].type != 31) {
_txt->printMessage(_warningStrings[3]);
} else if (_items[_itemInHand].value == -1) {
_txt->printMessage(_warningStrings[2]);
snd_playSoundEffect(79);
printWarning(_warningStrings[2]);
} else {
c->food += _items[_itemInHand].value;
if (c->food > 100)
Expand Down

0 comments on commit c302b3e

Please sign in to comment.