diff options
Diffstat (limited to 'engines/kyra/sprites_lol.cpp')
-rw-r--r-- | engines/kyra/sprites_lol.cpp | 77 |
1 files changed, 31 insertions, 46 deletions
diff --git a/engines/kyra/sprites_lol.cpp b/engines/kyra/sprites_lol.cpp index fbf4c7c5c2..9f7e05627b 100644 --- a/engines/kyra/sprites_lol.cpp +++ b/engines/kyra/sprites_lol.cpp @@ -59,7 +59,7 @@ void LoLEngine::loadMonsterShapes(const char *file, int monsterIndex, int animTy for (int i = 0; i < 4; i++) { for (int ii = 0; ii < 16; ii++) { - uint8 **of = &_monsterShapesEx[monsterIndex * 192 + i * 48 + ii * 3]; + uint8 **of = &_monsterDecorationShapes[monsterIndex * 192 + i * 48 + ii * 3]; int s = (i << 4) + ii + 17; of[0] = _screen->makeShapeCopy(p, s); of[1] = _screen->makeShapeCopy(p, s + 1); @@ -140,9 +140,9 @@ void LoLEngine::releaseMonsterShapes(int monsterIndex) { for (int i = 0; i < 192; i++) { int pos = (monsterIndex * 192) + i; - if (_monsterShapesEx[pos]) { - delete[] _monsterShapesEx[pos]; - _monsterShapesEx[pos] = 0; + if (_monsterDecorationShapes[pos]) { + delete[] _monsterDecorationShapes[pos]; + _monsterDecorationShapes[pos] = 0; } } } @@ -159,7 +159,7 @@ int LoLEngine::deleteMonstersFromBlock(int block) { continue; } - MonsterInPlay *m = &_monsters[i & 0x7fff]; + LolMonsterInPlay *m = &_monsters[i & 0x7fff]; cnt++; setMonsterMode(m, 14); @@ -173,7 +173,7 @@ int LoLEngine::deleteMonstersFromBlock(int block) { return cnt; } -void LoLEngine::setMonsterMode(MonsterInPlay *monster, int mode) { +void LoLEngine::setMonsterMode(LolMonsterInPlay *monster, int mode) { if (monster->mode == 13 && mode != 14) return; @@ -210,7 +210,7 @@ void LoLEngine::setMonsterMode(MonsterInPlay *monster, int mode) { } } -bool LoLEngine::updateMonsterAdjustBlocks(MonsterInPlay *monster) { +bool LoLEngine::updateMonsterAdjustBlocks(LolMonsterInPlay *monster) { static const uint8 dims[] = { 0, 13, 9, 3 }; if (monster->properties->flags & 8) return true; @@ -251,7 +251,7 @@ bool LoLEngine::updateMonsterAdjustBlocks(MonsterInPlay *monster) { return (fx1 >= fx2) ? false : true; } -void LoLEngine::placeMonster(MonsterInPlay *monster, uint16 x, uint16 y) { +void LoLEngine::placeMonster(LolMonsterInPlay *monster, uint16 x, uint16 y) { bool cont = true; int t = monster->block; if (monster->block) { @@ -329,7 +329,7 @@ int LoLEngine::calcMonsterDirection(uint16 x1, uint16 y1, uint16 x2, uint16 y2) return retVal[r]; } -void LoLEngine::setMonsterDirection(MonsterInPlay *monster, int dir) { +void LoLEngine::setMonsterDirection(LolMonsterInPlay *monster, int dir) { monster->direction = dir; if (!(dir & 1) || ((monster->direction - (monster->facing << 1)) >= 2)) @@ -338,7 +338,7 @@ void LoLEngine::setMonsterDirection(MonsterInPlay *monster, int dir) { checkSceneUpdateNeed(monster->block); } -void LoLEngine::monsterDropItems(MonsterInPlay *monster) { +void LoLEngine::monsterDropItems(LolMonsterInPlay *monster) { uint16 a = monster->assignedItems; while (a) { uint16 b = a; @@ -503,7 +503,7 @@ int LoLEngine::checkBlockForWallsAndSufficientSpace(int block, int x, int y, int uint16 b = _levelBlockProperties[block].assignedObjects; while (b & 0x8000) { - MonsterInPlay *monster = &_monsters[b & 0x7fff]; + LolMonsterInPlay *monster = &_monsters[b & 0x7fff]; if (monster->mode < 13) { int r = checkDrawObjectSpace(x, y, monster->x, monster->y); @@ -645,7 +645,7 @@ void LoLEngine::drawBlockObjects(int blockArrayIndex) { } void LoLEngine::drawMonster(uint16 id) { - MonsterInPlay *m = &_monsters[id]; + LolMonsterInPlay *m = &_monsters[id]; int16 flg = _monsterDirFlags[(_currentDirection << 2) + m->facing]; int curFrm = getMonsterCurFrame(m, flg & 0xffef); uint8 *shp = 0; @@ -670,7 +670,7 @@ void LoLEngine::drawMonster(uint16 id) { if (v == -1) break; - uint8 *shp2 = _monsterShapesEx[m->properties->shapeIndex * 192 + v * 48 + curFrm * 3]; + uint8 *shp2 = _monsterDecorationShapes[m->properties->shapeIndex * 192 + v * 48 + curFrm * 3]; if (!shp2) continue; @@ -721,7 +721,7 @@ void LoLEngine::drawMonster(uint16 id) { delete[] tbl; } -int LoLEngine::getMonsterCurFrame(MonsterInPlay *m, uint16 dirFlags) { +int LoLEngine::getMonsterCurFrame(LolMonsterInPlay *m, uint16 dirFlags) { int tmp = 0; switch (_monsterAnimType[m->properties->shapeIndex]) { case 0: @@ -901,7 +901,7 @@ void LoLEngine::drawDoor(uint8 *shape, uint8 *doorPalette, int index, int unk2, if (!shape) return; - uint8 c = _dscDoor1[(_currentDirection << 5) + unk2]; + uint8 c = _dscDoorY2[(_currentDirection << 5) + unk2]; int r = (c / 5) + 5 * _dscDimMap[index]; uint16 d = _dscShapeOvlIndex[r]; uint16 t = (index << 5) + c; @@ -1080,7 +1080,7 @@ int LoLEngine::calcDrawingLayerParameters(int x1, int y1, int &x2, int &y2, uint return l; } -void LoLEngine::updateMonster(MonsterInPlay *monster) { +void LoLEngine::updateMonster(LolMonsterInPlay *monster) { static const uint8 flags[] = { 1, 0, 1, 3, 3, 0, 0, 3, 4, 1, 0, 0, 4, 0, 0 }; if (monster->mode > 14) return; @@ -1228,7 +1228,7 @@ void LoLEngine::updateMonster(MonsterInPlay *monster) { monster->flags &= 0xffef; } -void LoLEngine::moveMonster(MonsterInPlay *monster) { +void LoLEngine::moveMonster(LolMonsterInPlay *monster) { static const int8 turnPos[] = { 0, 2, 6, 6, 0, 2, 4, 4, 2, 2, 4, 6, 0, 0, 4, 6, 0 }; if (monster->x != monster->destX || monster->y != monster->destY) { walkMonster(monster); @@ -1238,7 +1238,7 @@ void LoLEngine::moveMonster(MonsterInPlay *monster) { } } -void LoLEngine::walkMonster(MonsterInPlay *monster) { +void LoLEngine::walkMonster(LolMonsterInPlay *monster) { if (monster->properties->flags & 0x400) return; @@ -1253,7 +1253,7 @@ void LoLEngine::walkMonster(MonsterInPlay *monster) { } else { setMonsterDirection(monster, s); if (monster->numDistAttacks) { - if (getMonsterDistance(monster->block, _currentBlock) >= 2) { + if (getBlockDistance(monster->block, _currentBlock) >= 2) { if (checkForPossibleDistanceAttack(monster->block, monster->direction, 3, _currentBlock) != 5) { if (monster->distAttackTick) return; @@ -1269,7 +1269,7 @@ void LoLEngine::walkMonster(MonsterInPlay *monster) { placeMonster(monster, fx, fy); } -bool LoLEngine::chasePartyWithDistanceAttacks(MonsterInPlay *monster) { +bool LoLEngine::chasePartyWithDistanceAttacks(LolMonsterInPlay *monster) { if (!monster->numDistAttacks) return false; @@ -1295,7 +1295,7 @@ bool LoLEngine::chasePartyWithDistanceAttacks(MonsterInPlay *monster) { int flyingObject = monster->properties->distWeapons[s]; if (flyingObject & 0xc000) { - if (getMonsterDistance(monster->block, _currentBlock) > 1) { + if (getBlockDistance(monster->block, _currentBlock) > 1) { int type = flyingObject & 0x4000 ? 0 : 1; flyingObject = makeItem(flyingObject & 0x3fff, 0, 0); @@ -1305,7 +1305,7 @@ bool LoLEngine::chasePartyWithDistanceAttacks(MonsterInPlay *monster) { } } } else if (!(flyingObject & 0x2000)) { - if (getMonsterDistance(monster->block, _currentBlock) > 1) + if (getBlockDistance(monster->block, _currentBlock) > 1) return false; if (flyingObject == 1) { @@ -1326,7 +1326,7 @@ bool LoLEngine::chasePartyWithDistanceAttacks(MonsterInPlay *monster) { } else if (flyingObject == 3) { // shriek for (int i = 0; i < 30; i++) { - if (getMonsterDistance(monster->block, _monsters[i].block) < 7) + if (getBlockDistance(monster->block, _monsters[i].block) < 7) setMonsterMode(monster, 7); } _txt->printMessage(2, "%s", getLangString(0x401a)); @@ -1347,7 +1347,7 @@ bool LoLEngine::chasePartyWithDistanceAttacks(MonsterInPlay *monster) { return true; } -void LoLEngine::chasePartyWithCloseAttacks(MonsterInPlay *monster) { +void LoLEngine::chasePartyWithCloseAttacks(LolMonsterInPlay *monster) { if (!(monster->flags & 8)) { int dir = calcMonsterDirection(monster->x & 0xff00, monster->y & 0xff00, _partyPosX & 0xff00, _partyPosY & 0xff00); int x1 = _partyPosX; @@ -1389,7 +1389,7 @@ void LoLEngine::chasePartyWithCloseAttacks(MonsterInPlay *monster) { } } -int LoLEngine::walkMonsterCalcNextStep(MonsterInPlay *monster) { +int LoLEngine::walkMonsterCalcNextStep(LolMonsterInPlay *monster) { static const int8 walkMonsterTable1[] = { 7, -6, 5, -4, 3, -2, 1, 0 }; static const int8 walkMonsterTable2[] = { -7, 6, -5, 4, -3, 2, -1, 0 }; @@ -1445,23 +1445,8 @@ int LoLEngine::walkMonsterCalcNextStep(MonsterInPlay *monster) { return -1; } -int LoLEngine::getMonsterDistance(uint16 block1, uint16 block2) { - int b1x = block1 & 0x1f; - int b1y = block1 >> 5; - int b2x = block2 & 0x1f; - int b2y = block2 >> 5; - - uint8 dy = ABS(b2y - b1y); - uint8 dx = ABS(b2x - b1x); - - if (dx > dy) - SWAP(dx, dy); - - return (dx >> 1) + dy; -} - int LoLEngine::checkForPossibleDistanceAttack(uint16 monsterBlock, int direction, int distance, uint16 curBlock) { - int mdist = getMonsterDistance(curBlock, monsterBlock); + int mdist = getBlockDistance(curBlock, monsterBlock); if (mdist > distance) return 5; @@ -1494,7 +1479,7 @@ int LoLEngine::checkForPossibleDistanceAttack(uint16 monsterBlock, int direction return 5; } -int LoLEngine::walkMonsterCheckDest(int x, int y, MonsterInPlay *monster, int unk) { +int LoLEngine::walkMonsterCheckDest(int x, int y, LolMonsterInPlay *monster, int unk) { uint8 m = monster->mode; monster->mode = 15; @@ -1512,7 +1497,7 @@ void LoLEngine::getNextStepCoords(int16 srcX, int16 srcY, int &newX, int &newY, newY = (srcY + shiftTableY[direction]) & 0x1fff; } -void LoLEngine::rearrangeAttackingMonster(MonsterInPlay *monster) { +void LoLEngine::rearrangeAttackingMonster(LolMonsterInPlay *monster) { int t = (monster->direction >> 1); uint16 mx = monster->x; uint16 my = monster->y; @@ -1579,7 +1564,7 @@ void LoLEngine::rearrangeAttackingMonster(MonsterInPlay *monster) { placeMonster(monster, mx, my); } -void LoLEngine::moveStrayingMonster(MonsterInPlay *monster) { +void LoLEngine::moveStrayingMonster(LolMonsterInPlay *monster) { int x = 0; int y = 0; @@ -1616,13 +1601,13 @@ void LoLEngine::moveStrayingMonster(MonsterInPlay *monster) { } } -void LoLEngine::killMonster(MonsterInPlay *monster) { +void LoLEngine::killMonster(LolMonsterInPlay *monster) { setMonsterMode(monster, 14); monsterDropItems(monster); checkSceneUpdateNeed(monster->block); uint8 w = _levelBlockProperties[monster->block].walls[0]; - uint8 f = _levelBlockProperties[monster->block].flags; + uint16 f = _levelBlockProperties[monster->block].flags; if (_wllVmpMap[w] == 0 && _wllShapeMap[w] == 0 && !(f & 0x40) && !(monster->properties->flags & 0x1000)) _levelBlockProperties[monster->block].flags |= 0x80; |