diff options
author | Bendegúz Nagy | 2016-07-12 07:56:59 +0200 |
---|---|---|
committer | Bendegúz Nagy | 2016-08-26 23:02:22 +0200 |
commit | 9aa6c28fabd95d3aeaf5840386fb5d3327247d62 (patch) | |
tree | c23daa36db754528c9af372d7119e825b72a5924 /engines | |
parent | e8342f2d2abe58f03788c6db3302f6b29ac1bfe4 (diff) | |
download | scummvm-rg350-9aa6c28fabd95d3aeaf5840386fb5d3327247d62.tar.gz scummvm-rg350-9aa6c28fabd95d3aeaf5840386fb5d3327247d62.tar.bz2 scummvm-rg350-9aa6c28fabd95d3aeaf5840386fb5d3327247d62.zip |
DM: Add f245_timlineProcessEvent5_squareCorridor
Diffstat (limited to 'engines')
-rw-r--r-- | engines/dm/dungeonman.h | 4 | ||||
-rw-r--r-- | engines/dm/group.cpp | 43 | ||||
-rw-r--r-- | engines/dm/group.h | 2 | ||||
-rw-r--r-- | engines/dm/timeline.cpp | 76 | ||||
-rw-r--r-- | engines/dm/timeline.h | 1 |
5 files changed, 124 insertions, 2 deletions
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index e0a1d8ff50..049c8eae6f 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -336,7 +336,9 @@ public: direction getTargetCell() { return (direction)((_action >> 4) & 3); } uint16 M47_kineticEnergy() { return (_action & 0xFF); }// @ M47_KINETIC_ENERGY uint16 M48_stepEnergy() { return (_action >> 8) & 0xFF; }// @ M48_STEP_ENERGY - uint16 M49_localEffect() { return (_action >> 4); } + uint16 M49_localEffect() { return _action; } // @ M49_LOCAL_EFFECT + uint16 M45_healthMultiplier() { return (_action & 0xF); } // @ M45_HEALTH_MULTIPLIER + uint16 M46_ticks() { return (_action >> 4) & 0xFFF; } // @ M46_TICKS // some macros missing, i got bored diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp index a39065bbba..73c21198ac 100644 --- a/engines/dm/group.cpp +++ b/engines/dm/group.cpp @@ -1766,4 +1766,47 @@ void GroupMan::f195_addAllActiveGroups() { } } } + +Thing GroupMan::f185_groupGetGenerated(int16 creatureType, int16 healthMultiplier, uint16 creatureCount, direction dir, int16 mapX, int16 mapY) { + Thing L0349_T_GroupThing; + uint16 L0350_ui_BaseHealth; + uint16 L0351_ui_Cell = 0; + uint16 L0352_ui_GroupCells = 0; + Group* L0353_ps_Group; + CreatureInfo* L0354_ps_CreatureInfo; + bool L0355_B_SeveralCreaturesInGroup; + + + if (((_g377_currActiveGroupCount >= (_vm->_groupMan->_g376_maxActiveGroupCount - 5)) && (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex)) || ((L0349_T_GroupThing = _vm->_dungeonMan->f166_getUnusedThing(k4_GroupThingType)) == Thing::_none)) { + return Thing::_none; + } + L0353_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0349_T_GroupThing); + L0353_ps_Group->_slot = Thing::_endOfList; + L0353_ps_Group->setDoNotDiscard(false); + L0353_ps_Group->setDir(dir); + L0353_ps_Group->setCount(creatureCount); + if (L0355_B_SeveralCreaturesInGroup = creatureCount) { + L0351_ui_Cell = _vm->getRandomNumber(4); + } else { + L0352_ui_GroupCells = k255_CreatureTypeSingleCenteredCreature; + } + L0354_ps_CreatureInfo = &g243_CreatureInfo[L0353_ps_Group->_type = creatureType]; + L0350_ui_BaseHealth = L0354_ps_CreatureInfo->_baseHealth; + do { + L0353_ps_Group->_health[creatureCount] = (L0350_ui_BaseHealth * healthMultiplier) + _vm->getRandomNumber((L0350_ui_BaseHealth >> 2) + 1); + if (L0355_B_SeveralCreaturesInGroup) { + L0352_ui_GroupCells = f178_getGroupValueUpdatedWithCreatureValue(L0352_ui_GroupCells, creatureCount, L0351_ui_Cell++); + if (getFlag(L0354_ps_CreatureInfo->_attributes, k0x0003_MaskCreatureInfo_size) == k1_MaskCreatureSizeHalf) { + L0351_ui_Cell++; + } + L0351_ui_Cell &= 0x0003; + } + } while (creatureCount--); + L0353_ps_Group->_cells = L0352_ui_GroupCells; + if (_vm->_movsens->f267_getMoveResult(L0349_T_GroupThing, kM1_MapXNotOnASquare, 0, mapX, mapY)) { /* If F0267_MOVE_GetMoveResult_CPSCE returns true then the group was either killed by a projectile impact (in which case the thing data was marked as unused) or the party is on the destination square and an event is created to move the creature into the dungeon later (in which case the thing is referenced in the event) */ + return Thing::_none; + } + warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + return L0349_T_GroupThing; +} } diff --git a/engines/dm/group.h b/engines/dm/group.h index ca7cb527ed..6153d514d2 100644 --- a/engines/dm/group.h +++ b/engines/dm/group.h @@ -133,6 +133,7 @@ public: direction getDir() { return (direction)((_flags >> 8) & 0x3); } void setDir(uint16 val) { _flags = (_flags & ~(0x3 << 8)) | ((val & 0x3) << 8); } uint16 getDoNotDiscard() { return (_flags >> 10) & 0x1; } + void setDoNotDiscard(bool val) { _flags = (_flags & ~(1 << 10)) | ((val & 1) << 10); } }; // @ GROUP #define k0_behavior_WANDER 0 // @ C0_BEHAVIOR_WANDER @@ -233,6 +234,7 @@ public: void f184_removeActiveGroup(uint16 activeGroupIndex); // @ F0184_GROUP_RemoveActiveGroup void f194_removeAllActiveGroups(); // @ F0194_GROUP_RemoveAllActiveGroups void f195_addAllActiveGroups(); // @ F0195_GROUP_AddAllActiveGroups + Thing f185_groupGetGenerated(int16 creatureType, int16 healthMultiplier, uint16 creatureCount, direction dir, int16 mapX, int16 mapY); // @ F0185_GROUP_GetGenerated diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp index 524b5a5050..17376485c5 100644 --- a/engines/dm/timeline.cpp +++ b/engines/dm/timeline.cpp @@ -32,6 +32,7 @@ #include "group.h" #include "projexpl.h" #include "movesens.h" +#include "text.h" namespace DM { @@ -259,7 +260,7 @@ void Timeline::f261_processTimeline() { f248_timelineProcessEvent6_squareWall(L0681_ps_Event); break; case k5_TMEventTypeCorridor: - //F0245_TIMELINE_ProcessEvent5_Square_Corridor(L0681_ps_Event); + f245_timlineProcessEvent5_squareCorridor(L0681_ps_Event); break; case k60_TMEventTypeMoveGroupSilent: case k61_TMEventTypeMoveGroupAudible: @@ -741,4 +742,77 @@ void Timeline::f247_triggerProjectileLauncher(Sensor* sensor, TimelineEvent* eve } _vm->_projexpl->_g365_createLanucherProjectile = false; } + +void Timeline::f245_timlineProcessEvent5_squareCorridor(TimelineEvent* event) { +#define k0x0008_randomizeGeneratedCreatureCount 0x0008 // @ MASK0x0008_RANDOMIZE_GENERATED_CREATURE_COUNT +#define k0x0007_generatedCreatureCount 0x0007 // @ MASK0x0007_GENERATED_CREATURE_COUNT + + int16 L0610_i_ThingType; + bool L0611_B_TextCurrentlyVisible; + int16 L0612_i_CreatureCount; + Thing L0613_T_Thing; + Sensor* L0614_ps_Sensor; + TextString* L0615_ps_TextString; + uint16 L0616_ui_MapX; + uint16 L0617_ui_MapY; + uint16 L0618_ui_Multiple; +#define AL0618_ui_HealthMultiplier L0618_ui_Multiple +#define AL0618_ui_Ticks L0618_ui_Multiple + TimelineEvent L0619_s_Event; + + + L0613_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(L0616_ui_MapX = event->_B._location._mapX, L0617_ui_MapY = event->_B._location._mapY); + while (L0613_T_Thing != Thing::_endOfList) { + if ((L0610_i_ThingType = L0613_T_Thing.getType()) == k2_TextstringType) { + L0615_ps_TextString = (TextString*)_vm->_dungeonMan->f156_getThingData(L0613_T_Thing); + L0611_B_TextCurrentlyVisible = L0615_ps_TextString->isVisible(); + if (event->_C.A._effect == k2_SensorEffToggle) { + L0615_ps_TextString->setVisible(!L0611_B_TextCurrentlyVisible); + } else { + L0615_ps_TextString->setVisible((event->_C.A._effect == k0_SensorEffSet)); + } + if (!L0611_B_TextCurrentlyVisible && L0615_ps_TextString->isVisible() && (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (L0616_ui_MapX == _vm->_dungeonMan->_g306_partyMapX) && (L0617_ui_MapY == _vm->_dungeonMan->_g307_partyMapY)) { + _vm->_dungeonMan->f168_decodeText(_vm->_g353_stringBuildBuffer, L0613_T_Thing, k1_TextTypeMessage); + _vm->_textMan->f47_messageAreaPrintMessage(k15_ColorWhite, _vm->_g353_stringBuildBuffer); + } + } else { + if (L0610_i_ThingType == k3_SensorThingType) { + L0614_ps_Sensor = (Sensor*)_vm->_dungeonMan->f156_getThingData(L0613_T_Thing); + if (L0614_ps_Sensor->getType() == k6_SensorFloorGroupGenerator) { + L0612_i_CreatureCount = L0614_ps_Sensor->getValue(); + if (getFlag(L0612_i_CreatureCount, k0x0008_randomizeGeneratedCreatureCount)) { + L0612_i_CreatureCount = _vm->getRandomNumber(getFlag(L0612_i_CreatureCount, k0x0007_generatedCreatureCount)); + } else { + L0612_i_CreatureCount--; + } + if ((AL0618_ui_HealthMultiplier = L0614_ps_Sensor->M45_healthMultiplier()) == 0) { + AL0618_ui_HealthMultiplier = _vm->_dungeonMan->_g269_currMap->_difficulty; + } + _vm->_groupMan->f185_groupGetGenerated(L0614_ps_Sensor->getData(), AL0618_ui_HealthMultiplier, L0612_i_CreatureCount, (direction)_vm->getRandomNumber(4), L0616_ui_MapX, L0617_ui_MapY); + if (L0614_ps_Sensor->getAudibleA()) { + warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD"); + } + if (L0614_ps_Sensor->getOnlyOnce()) { + L0614_ps_Sensor->setTypeDisabled(); + } else { + if ((AL0618_ui_Ticks = L0614_ps_Sensor->M46_ticks()) != 0) { + L0614_ps_Sensor->setTypeDisabled(); + if (AL0618_ui_Ticks > 127) { + AL0618_ui_Ticks = (AL0618_ui_Ticks - 126) << 6; + } + L0619_s_Event._type = k65_TMEventTypeEnableGroupGenerator; + M33_setMapAndTime(L0619_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime + AL0618_ui_Ticks); + L0619_s_Event._priority = 0; + L0619_s_Event._B._location._mapX = L0616_ui_MapX; + L0619_s_Event._B._location._mapY = L0617_ui_MapY; + L0619_s_Event._B._location._mapY = L0617_ui_MapY; + _vm->_timeline->f238_addEventGetEventIndex(&L0619_s_Event); + } + } + } + } + } + L0613_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0613_T_Thing); + } +} } diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h index a11b26c297..3e5cbcdf65 100644 --- a/engines/dm/timeline.h +++ b/engines/dm/timeline.h @@ -172,6 +172,7 @@ public: void f250_timelineProcessEvent8_squareTeleporter(TimelineEvent *event); // @ F0250_TIMELINE_ProcessEvent8_Square_Teleporter void f248_timelineProcessEvent6_squareWall(TimelineEvent *event); // @ F0248_TIMELINE_ProcessEvent6_Square_Wall void f247_triggerProjectileLauncher(Sensor *sensor, TimelineEvent *event); // @ F0247_TIMELINE_TriggerProjectileLauncher + void f245_timlineProcessEvent5_squareCorridor(TimelineEvent *event); // @ F0245_TIMELINE_ProcessEvent5_Square_Corridor }; |