From b597d71bcdd7792df1cc53d8354f700b0dc4ab72 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 22 Jan 2015 19:41:55 -0500 Subject: XEEN: Implemented animate3d --- engines/xeen/combat.cpp | 2 +- engines/xeen/combat.h | 2 +- engines/xeen/interface_map.cpp | 117 ++++++++++++++++++++++++++++++++++++++++- engines/xeen/interface_map.h | 8 +++ engines/xeen/map.cpp | 3 ++ engines/xeen/map.h | 3 ++ 6 files changed, 131 insertions(+), 4 deletions(-) (limited to 'engines') diff --git a/engines/xeen/combat.cpp b/engines/xeen/combat.cpp index 98dff4c6d9..4d3cb53bf9 100644 --- a/engines/xeen/combat.cpp +++ b/engines/xeen/combat.cpp @@ -32,7 +32,7 @@ Combat::Combat(XeenEngine *vm): _vm(vm) { Common::fill(&_monsterScale[0], &_monsterScale[12], 0); Common::fill(&_elemPow[0], &_elemPow[12], 0); Common::fill(&_elemScale[0], &_elemScale[12], 0); - Common::fill(&_shooting[0], &_shooting[6], 0); + Common::fill(&_shooting[0], &_shooting[8], 0); } void Combat::clear() { diff --git a/engines/xeen/combat.h b/engines/xeen/combat.h index 8e54353212..882f90e604 100644 --- a/engines/xeen/combat.h +++ b/engines/xeen/combat.h @@ -57,7 +57,7 @@ public: int _monsterScale[12]; int _elemPow[12]; int _elemScale[12]; - bool _shooting[6]; + bool _shooting[8]; public: Combat(XeenEngine *vm); diff --git a/engines/xeen/interface_map.cpp b/engines/xeen/interface_map.cpp index be344aef22..70297be5af 100644 --- a/engines/xeen/interface_map.cpp +++ b/engines/xeen/interface_map.cpp @@ -27,7 +27,9 @@ namespace Xeen { -OutdoorDrawList::OutdoorDrawList() : _skySprite(_data[1]), _groundSprite(_data[2]) { +OutdoorDrawList::OutdoorDrawList() : _skySprite(_data[1]), _groundSprite(_data[2]), + _combatImgs1(&_data[124]), _combatImgs2(&_data[95]), + _combatImgs3(&_data[76]), _combatImgs4(&_data[53]) { _data[0] = DrawStruct(0, 8, 8); _data[1] = DrawStruct(1, 8, 25); _data[2] = DrawStruct(0, 8, 67); @@ -185,7 +187,9 @@ IndoorDrawList::IndoorDrawList() : _objects0(_data[149]), _objects1(_data[125]), _objects2(_data[126]), _objects3(_data[127]), _objects4(_data[97]), _objects5(_data[98]), _objects6(_data[99]), _objects7(_data[55]), _objects8(_data[56]), - _objects9(_data[58]), _objects10(_data[57]), _objects11(_data[59]) { + _objects9(_data[58]), _objects10(_data[57]), _objects11(_data[59]), + _combatImgs1(&_data[162]), _combatImgs2(&_data[135]), + _combatImgs3(&_data[111]), _combatImgs4(&_data[80]) { // Setup draw structure positions _data[0] = DrawStruct(0, 8, 8); _data[1] = DrawStruct(1, 8, 25); @@ -631,9 +635,118 @@ void InterfaceMap::draw3d(bool updateFlag) { events.wait(2); } +/** + * Handles animation of monsters, wall items, and combat within the 3d + * view by cycling the appropriate frame numbers + */ void InterfaceMap::animate3d() { + Combat &combat = *_vm->_combat; + Map &map = *_vm->_map; + _overallFrame = (_overallFrame + 1) % 5; + _combatFloatCounter = (_combatFloatCounter + 1) % 8; + + for (uint idx = 0; idx < map._mobData._monsters.size(); ++idx) { + MazeMonster &monster = map._mobData._monsters[idx]; + if (!monster._field7) { + if (monster._frame < 8) { + MonsterStruct &monsterData = map._monsterData[monster._spriteId]; + if (!monsterData._loopAnimation) { + // Monster isn't specially looped, so cycle through the 8 frames + monster._frame = (monster._frame + 1) % 8; + } else if (!monster._field9) { + monster._frame = (monster._frame + 1) % 8; + if (monster._frame == 0) { + monster._field9 ^= 1; + monster._frame = 6; + } + } else { + if (monster._frame) + --monster._frame; + if (monster._frame == 0) + monster._field9 = 0; + } + } else if (monster._frame == 11) { + --monster._fieldA; + if (monster._fieldA == 0) + monster._frame = 0; + } else { + ++monster._frame; + if (monster._frame == 11) { + --monster._frame; + monster._frame = monster._fieldA ? 10 : 0; + } + } + } + // Block 2 + if (monster._effect2) { + if (monster._effect1) { + if (monster._effect1 & 0x80) { + if (monster._effect3) + --monster._effect3; + if (monster._effect3 == 0) + monster._effect1 ^= 0x80; + } else { + monster._effect3 = (monster._effect3 + 1) % 3; + if (monster._effect3 == 0) { + monster._effect1 ^= 0x80; + monster._effect3 = 2; + } + } + } + } else { + monster._effect3 = (monster._effect3 + 1) % 8; + if (monster._effect3 == 0) { + MonsterStruct &monsterData = map._monsterData[monster._spriteId]; + monster._effect1 = monster._effect2 = monsterData._animationEffect; + } + } + } + + DrawStruct *combatImgs1 = map._isOutdoors ? _outdoorList._combatImgs1 : _indoorList._combatImgs1; + DrawStruct *combatImgs2 = map._isOutdoors ? _outdoorList._combatImgs2 : _indoorList._combatImgs2; + DrawStruct *combatImgs3 = map._isOutdoors ? _outdoorList._combatImgs3 : _indoorList._combatImgs3; + DrawStruct *combatImgs4 = map._isOutdoors ? _outdoorList._combatImgs4 : _indoorList._combatImgs4; + + if (_flag1) { + for (int idx = 0; idx < 8; ++idx) { + if (combatImgs1[idx]._sprites) { + combatImgs1[idx]._sprites = nullptr; + combat._shooting[idx] = false; + } else if (combatImgs2[idx]._sprites) { + combatImgs1[idx]._sprites = combatImgs2[idx]._sprites; + combatImgs2[idx]._sprites = nullptr; + } else if (combatImgs3[idx]._sprites) { + combatImgs2[idx]._sprites = combatImgs3[idx]._sprites; + combatImgs3[idx]._sprites = nullptr; + } else if (combatImgs4[idx]._sprites) { + combatImgs3[idx]._sprites = combatImgs4[idx]._sprites; + combatImgs4[idx]._sprites = nullptr; + } + } + } else if (_charsShooting) { + for (int idx = 0; idx < 8; ++idx) { + if (combatImgs4[idx]._sprites) { + combatImgs4[idx]._sprites = nullptr; + } else if (combatImgs3[idx]._sprites) { + combatImgs4[idx]._sprites = combatImgs3[idx]._sprites; + combatImgs3[idx]._sprites = nullptr; + } else if (combatImgs2[idx]._sprites) { + combatImgs3[idx]._sprites = combatImgs2[idx]._sprites; + combatImgs2[idx]._sprites = nullptr; + } else if (combatImgs1[idx]._sprites) { + combatImgs2[idx]._sprites = combatImgs1[idx]._sprites; + combatImgs1[idx]._sprites = nullptr; + } + } + } + + for (uint idx = 0; idx < map._mobData._wallItems.size(); ++idx) { + MazeWallItem &wallItem = map._mobData._wallItems[idx]; + wallItem._frame = (wallItem._frame + 1) % wallItem._sprites->size(); + } } + void InterfaceMap::setMazeBits() { Common::fill(&_wo[0], &_wo[308], 0); diff --git a/engines/xeen/interface_map.h b/engines/xeen/interface_map.h index 12e5ac6410..0867907516 100644 --- a/engines/xeen/interface_map.h +++ b/engines/xeen/interface_map.h @@ -36,6 +36,10 @@ public: DrawStruct _data[132]; DrawStruct &_skySprite; DrawStruct &_groundSprite; + DrawStruct * const _combatImgs1; + DrawStruct * const _combatImgs2; + DrawStruct * const _combatImgs3; + DrawStruct * const _combatImgs4; public: OutdoorDrawList(); @@ -68,6 +72,10 @@ public: DrawStruct &_objects0, &_objects1, &_objects2, &_objects3; DrawStruct &_objects4, &_objects5, &_objects6, &_objects7; DrawStruct &_objects8, &_objects9, &_objects10, &_objects11; + DrawStruct * const _combatImgs1; + DrawStruct * const _combatImgs2; + DrawStruct * const _combatImgs3; + DrawStruct * const _combatImgs4; public: IndoorDrawList(); diff --git a/engines/xeen/map.cpp b/engines/xeen/map.cpp index d2f4c5e18d..5c49e37f4c 100644 --- a/engines/xeen/map.cpp +++ b/engines/xeen/map.cpp @@ -644,6 +644,9 @@ MazeMonster::MazeMonster() { _id = 0; _spriteId = 0; _isAttacking = false; + _field7 = 0; + _field9 = 0; + _fieldA = 0; _hp = 0; _effect1 = _effect2 = 0; _effect3 = 0; diff --git a/engines/xeen/map.h b/engines/xeen/map.h index 8735973738..7815d143d5 100644 --- a/engines/xeen/map.h +++ b/engines/xeen/map.h @@ -236,6 +236,9 @@ struct MazeMonster { int _id; int _spriteId; bool _isAttacking; + int _field7; + int _field9; + int _fieldA; int _hp; int _effect1, _effect2; int _effect3; -- cgit v1.2.3