Skip to content

Commit

Permalink
DM: Add f245_timlineProcessEvent5_squareCorridor
Browse files Browse the repository at this point in the history
  • Loading branch information
Bendegúz Nagy committed Aug 26, 2016
1 parent e8342f2 commit 9aa6c28
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 2 deletions.
4 changes: 3 additions & 1 deletion engines/dm/dungeonman.h
Expand Up @@ -336,7 +336,9 @@ class Sensor {
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
Expand Down
43 changes: 43 additions & 0 deletions engines/dm/group.cpp
Expand Up @@ -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;
}
}
2 changes: 2 additions & 0 deletions engines/dm/group.h
Expand Up @@ -133,6 +133,7 @@ class Group {
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
Expand Down Expand Up @@ -233,6 +234,7 @@ class GroupMan {
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



Expand Down
76 changes: 75 additions & 1 deletion engines/dm/timeline.cpp
Expand Up @@ -32,6 +32,7 @@
#include "group.h"
#include "projexpl.h"
#include "movesens.h"
#include "text.h"


namespace DM {
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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);
}
}
}
1 change: 1 addition & 0 deletions engines/dm/timeline.h
Expand Up @@ -172,6 +172,7 @@ class Timeline {
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
};


Expand Down

0 comments on commit 9aa6c28

Please sign in to comment.