aboutsummaryrefslogtreecommitdiff
path: root/engines/dm
diff options
context:
space:
mode:
Diffstat (limited to 'engines/dm')
-rw-r--r--engines/dm/TODOs/todo.txt4
-rw-r--r--engines/dm/champion.cpp2
-rw-r--r--engines/dm/dungeonman.cpp2
-rw-r--r--engines/dm/dungeonman.h3
-rw-r--r--engines/dm/eventman.cpp41
-rw-r--r--engines/dm/eventman.h1
-rw-r--r--engines/dm/group.cpp240
-rw-r--r--engines/dm/group.h10
-rw-r--r--engines/dm/menus.cpp864
-rw-r--r--engines/dm/menus.h31
-rw-r--r--engines/dm/movesens.cpp2
-rw-r--r--engines/dm/timeline.h2
12 files changed, 1194 insertions, 8 deletions
diff --git a/engines/dm/TODOs/todo.txt b/engines/dm/TODOs/todo.txt
index 4839d2d781..9137975b9f 100644
--- a/engines/dm/TODOs/todo.txt
+++ b/engines/dm/TODOs/todo.txt
@@ -6,7 +6,9 @@ Bugs:
Logic:
When object are put on the right side of the current square, they disappear
- Drawing door ornaments segfaults when going back to the start
+ Drawing door ornaments segfaults when going back to the start
+ !! It seems that that deleted events' _type fields are not getting set to 0, when looking for available slots, the code looks for events with 0 _type fields,
+ this results in segfaults
Possible bugs:
- k1_LeftMouseButton and k2_RightMouseButton have values 1 and 2 respectively, contrary to the original in the original: MASK0x0001_MOUSE_RIGHT_BUTTON, MASK0x0002_MOUSE_LEFT_BUTTON
diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 906c95bf47..b9c286ac92 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1059,7 +1059,7 @@ bool ChampionMan::f308_isLucky(Champion* champ, uint16 percentage) {
if (_vm->getRandomNumber(2) && (_vm->getRandomNumber(100) > percentage)) {
return true;
}
- register unsigned char* L0928_puc_Statistic = champ->_statistics[k0_ChampionStatLuck];
+ unsigned char* L0928_puc_Statistic = champ->_statistics[k0_ChampionStatLuck];
AP0646_ui_IsLucky = (_vm->getRandomNumber(L0928_puc_Statistic[k1_ChampionStatCurrent]) > percentage);
L0928_puc_Statistic[k1_ChampionStatCurrent] = f26_getBoundedValue((int32)L0928_puc_Statistic[k2_ChampionStatMinimum], (int32)L0928_puc_Statistic[k1_ChampionStatCurrent] + (AP0646_ui_IsLucky ? -2 : 2), (int32)L0928_puc_Statistic[k0_ChampionStatMaximum]);
return AP0646_ui_IsLucky;
diff --git a/engines/dm/dungeonman.cpp b/engines/dm/dungeonman.cpp
index 7d916196b4..3d1f931edb 100644
--- a/engines/dm/dungeonman.cpp
+++ b/engines/dm/dungeonman.cpp
@@ -795,7 +795,7 @@ Square DungeonMan::f152_getRelSquare(direction dir, int16 stepsForward, int16 st
int16 DungeonMan::f160_getSquareFirstThingIndex(int16 mapX, int16 mapY) {
uint16 L0260_ui_ThingIndex;
int16 L0261_i_MapY;
- register unsigned char* L0262_puc_Square;
+ unsigned char* L0262_puc_Square;
L0262_puc_Square = _vm->_dungeonMan->_g271_currMapData[mapX];
diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h
index 305a9219d9..515ef93413 100644
--- a/engines/dm/dungeonman.h
+++ b/engines/dm/dungeonman.h
@@ -379,6 +379,7 @@ public:
uint16 getChargeCount() { return (_desc >> 10) & 0xF; }
uint16 setChargeCount(uint16 val) { _desc = (_desc & ~(0xF << 10)) | ((val & 0xF) << 10); return (val & 0xF); }
Thing getNextThing() { return _nextThing; }
+ void setNextThing(Thing val) { _nextThing = val; }
uint16 getCursed() { return (_desc >> 8) & 1; }
void setCursed(uint16 val) { _desc = (_desc & ~(1 << 8)) | ((val & 1) << 8); }
uint16 getPoisoned() { return (_desc >> 9) & 1; }
@@ -405,6 +406,8 @@ public:
uint16 getCursed() { return (_attributes >> 8) & 1; }
uint16 getBroken() { return (_attributes >> 13) & 1; }
uint16 getDoNotDiscard() { return (_attributes >> 7) & 1; }
+ uint16 getChargeCount() { return (_attributes >> 9) & 0xF; }
+ void setChargeCount(uint16 val) { _attributes = (_attributes & ~(0xF << 9)) | ((val & 0xF) << 9); }
}; // @ ARMOUR
class Scroll {
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 6be06e6040..b1ffe30af6 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -685,7 +685,7 @@ void EventManager::f380_processCommandQueue() {
}
if (cmdType == k111_CommandClickInActionArea) {
if (!_vm->_championMan->_g299_candidateChampionOrdinal) {
- warning(false, "MISSING CODE: F0371_COMMAND_ProcessType111To115_ClickInActionArea_CPSE(L1161_i_CommandX, L1162_i_CommandY);");
+ f371_commandProcessType111To115_ClickInActionArea(L1161_i_CommandX, L1162_i_CommandY);
}
return;
}
@@ -1310,7 +1310,7 @@ void EventManager::f70_mouseProcessCommands125To128_clickOnChampionIcon(uint16 c
int16 L0053_i_ChampionIndex;
int16 L0054_i_ChampionIndex;
Box* L0055_pi_ChampionIconBox;
- register unsigned char* L0056_puc_Bitmap;
+ byte* L0056_puc_Bitmap;
_gK100_preventBuildPointerScreenArea = true;
@@ -1465,4 +1465,41 @@ void EventManager::f369_commandProcessTypes101To108_clickInSpellSymbolsArea(Comm
_vm->_menuMan->f400_deleteChampionSymbol();
}
}
+
+void EventManager::f371_commandProcessType111To115_ClickInActionArea(int16 posX, int16 posY) {
+ uint16 L1134_ui_Command;
+
+
+ if (_vm->_championMan->_g506_actingChampionOrdinal) {
+ L1134_ui_Command = _vm->_eventMan->f358_getCommandTypeFromMouseInput(g452_MouseInput_ActionAreaNames, Common::Point(posX, posY), k1_LeftMouseButton);
+ if (L1134_ui_Command != k0_CommandNone) {
+ if (L1134_ui_Command == k112_CommandClickInActionAreaPass) {
+ warning(false, "MISSING CODE: F0362_COMMAND_HighlightBoxEnable");
+ _vm->_menuMan->f391_didClickTriggerAction(-1);
+ } else {
+ if ((L1134_ui_Command - k112_CommandClickInActionAreaPass) <= _vm->_menuMan->_g507_actionCount) {
+ if (L1134_ui_Command == k113_CommandClickInActionAreaAction_0) {
+ warning(false, "MISSING CODE: F0362_COMMAND_HighlightBoxEnable");
+ } else {
+ if (L1134_ui_Command == k114_CommandClickInActionAreaAction_1) {
+ warning(false, "MISSING CODE: F0362_COMMAND_HighlightBoxEnable");
+ } else {
+ warning(false, "MISSING CODE: F0362_COMMAND_HighlightBoxEnable");
+ }
+ }
+ _vm->_g321_stopWaitingForPlayerInput = _vm->_menuMan->f391_didClickTriggerAction(L1134_ui_Command - k113_CommandClickInActionAreaAction_0);
+ }
+ }
+ }
+ } else {
+ if (_vm->_menuMan->_g509_actionAreaContainsIcons) {
+ L1134_ui_Command = _vm->_eventMan->f358_getCommandTypeFromMouseInput(g453_MouseInput_ActionAreaIcons, Common::Point(posX, posY), k1_LeftMouseButton);
+ if (L1134_ui_Command != k0_CommandNone) {
+ if ((L1134_ui_Command = L1134_ui_Command - k116_CommandClickInActionAreaChampion_0_Action) < _vm->_championMan->_g305_partyChampionCount) {
+ _vm->_menuMan->f389_processCommands116To119_setActingChampion(L1134_ui_Command);
+ }
+ }
+ }
+ }
+}
} // end of namespace DM
diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h
index 7ad24a7e88..24fca0f261 100644
--- a/engines/dm/eventman.h
+++ b/engines/dm/eventman.h
@@ -302,6 +302,7 @@ public:
void f70_mouseProcessCommands125To128_clickOnChampionIcon(uint16 champIconIndex); // @ F0070_MOUSE_ProcessCommands125To128_ClickOnChampionIcon
void f370_commandProcessType100_clickInSpellArea(uint16 posX, uint16 posY); // @ F0370_COMMAND_ProcessType100_ClickInSpellArea
void f369_commandProcessTypes101To108_clickInSpellSymbolsArea(CommandType cmdType); // @ F0369_COMMAND_ProcessTypes101To108_ClickInSpellSymbolsArea_CPSE
+ void f371_commandProcessType111To115_ClickInActionArea(int16 posX, int16 posY); // @ F0371_COMMAND_ProcessType111To115_ClickInActionArea_CPSE
};
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index 49ac924333..617735e6b6 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -31,6 +31,8 @@
#include "movesens.h"
#include "projexpl.h"
#include "timeline.h"
+#include "objectman.h"
+#include "menus.h"
namespace DM {
@@ -1817,4 +1819,242 @@ bool GroupMan::f223_isSquareACorridorTeleporterPitOrDoor(int16 mapX, int16 mapY)
|| (L0544_i_SquareType == k5_ElementTypeTeleporter) || (L0544_i_SquareType == k2_ElementTypePit) || (L0544_i_SquareType == k4_DoorElemType));
}
+int16 GroupMan::f177_getMeleeTargetCreatureOrdinal(int16 groupX, int16 groupY, int16 partyX, int16 partyY, uint16 champCell) {
+ uint16 L0321_ui_Counter;
+ int16 L0322_i_CreatureOrdinal;
+ Thing L0323_T_GroupThing;
+ Group* L0324_ps_Group;
+ signed char L0325_auc_OrderedCellsToAttack[4];
+
+
+ if ((L0323_T_GroupThing = _vm->_groupMan->f175_groupGetThing(groupX, groupY)) == Thing::_endOfList) {
+ return 0;
+ }
+ L0324_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0323_T_GroupThing);
+ f229_setOrderedCellsToAttack(L0325_auc_OrderedCellsToAttack, groupX, groupY, partyX, partyY, champCell);
+ L0321_ui_Counter = 0;
+ for (;;) { /*_Infinite loop_*/
+ if (L0322_i_CreatureOrdinal = _vm->_groupMan->f176_getCreatureOrdinalInCell(L0324_ps_Group, L0325_auc_OrderedCellsToAttack[L0321_ui_Counter])) {
+ return L0322_i_CreatureOrdinal;
+ }
+ L0321_ui_Counter++;
+ }
+}
+
+int16 GroupMan::f231_getMeleeActionDamage(Champion* champ, int16 champIndex, Group* group, int16 creatureIndex, int16 mapX, int16 mapXóY, uint16 actionHitProbability, uint16 actionDamageFactor, int16 skillIndex) {
+ int16 L0565_i_Damage = 0;
+ int16 L0566_i_Damage = 0;
+ int16 L0567_i_DoubledMapDifficulty;
+ int16 L0568_i_Defense;
+ int16 L0569_i_Outcome;
+ bool L0570_B_ActionHitsNonMaterialCreatures;
+ int16 L0571_i_ActionHandObjectIconIndex;
+ CreatureInfo* L0572_ps_CreatureInfo;
+
+ if (champIndex >= _vm->_championMan->_g305_partyChampionCount) {
+ return 0;
+ }
+ if (!champ->_currHealth) {
+ return 0;
+ }
+ L0567_i_DoubledMapDifficulty = _vm->_dungeonMan->_g269_currMap->_difficulty << 1;
+ L0572_ps_CreatureInfo = &g243_CreatureInfo[group->_type];
+ L0571_i_ActionHandObjectIconIndex = _vm->_objectMan->f33_getIconIndex(champ->_slots[k1_ChampionSlotActionHand]);
+ if (L0570_B_ActionHitsNonMaterialCreatures = getFlag(actionHitProbability, k0x8000_hitNonMaterialCreatures)) {
+ clearFlag(actionHitProbability, k0x8000_hitNonMaterialCreatures);
+ }
+ if ((!getFlag(L0572_ps_CreatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial) || L0570_B_ActionHitsNonMaterialCreatures) &&
+ ((_vm->_championMan->f311_getDexterity(champ) > (_vm->getRandomNumber(32) + L0572_ps_CreatureInfo->_dexterity + L0567_i_DoubledMapDifficulty - 16)) ||
+ (!_vm->getRandomNumber(4)) ||
+ (_vm->_championMan->f308_isLucky(champ, 75 - actionHitProbability)))) {
+ if (!(L0565_i_Damage = _vm->_championMan->f312_getStrength(champIndex, k1_ChampionSlotActionHand))) {
+ goto T0231009;
+ }
+ L0565_i_Damage += _vm->getRandomNumber((L0565_i_Damage >> 1) + 1);
+ L0565_i_Damage = ((long)L0565_i_Damage * (long)actionDamageFactor) >> 5;
+ L0568_i_Defense = _vm->getRandomNumber(32) + L0572_ps_CreatureInfo->_defense + L0567_i_DoubledMapDifficulty;
+ if (L0571_i_ActionHandObjectIconIndex == k39_IconIndiceWeaponDiamondEdge) {
+ L0568_i_Defense -= L0568_i_Defense >> 2;
+ } else {
+ if (L0571_i_ActionHandObjectIconIndex == k43_IconIndiceWeaponHardcleaveExecutioner) {
+ L0568_i_Defense -= L0568_i_Defense >> 3;
+ }
+ }
+ if ((L0566_i_Damage = L0565_i_Damage = _vm->getRandomNumber(32) + L0565_i_Damage - L0568_i_Defense) <= 1) {
+T0231009:
+ if (!(L0565_i_Damage = _vm->getRandomNumber(4))) {
+ goto T0231015;
+ }
+ L0565_i_Damage++;
+ if (((L0566_i_Damage += _vm->getRandomNumber(16)) > 0) || (_vm->getRandomNumber(2))) {
+ L0565_i_Damage += _vm->getRandomNumber(4);
+ if (!_vm->getRandomNumber(4)) {
+ L0565_i_Damage += MAX(0, L0566_i_Damage + _vm->getRandomNumber(16));
+ }
+ }
+ }
+ L0565_i_Damage >>= 1;
+ L0565_i_Damage += _vm->getRandomNumber(L0565_i_Damage) + _vm->getRandomNumber(4);
+ L0565_i_Damage += _vm->getRandomNumber(L0565_i_Damage);
+ L0565_i_Damage >>= 2;
+ L0565_i_Damage += _vm->getRandomNumber(4) + 1;
+ if ((L0571_i_ActionHandObjectIconIndex == k40_IconIndiceWeaponVorpalBlade) && !getFlag(L0572_ps_CreatureInfo->_attributes, k0x0040_MaskCreatureInfo_nonMaterial) && !(L0565_i_Damage >>= 1))
+ goto T0231015;
+ if (_vm->getRandomNumber(64) < _vm->_championMan->f303_getSkillLevel(champIndex, skillIndex)) {
+ L0565_i_Damage += L0565_i_Damage + 10;
+ }
+ L0569_i_Outcome = f190_groupGetDamageCreatureOutcome(group, creatureIndex, mapX, mapXóY, L0565_i_Damage, true);
+ _vm->_championMan->f304_addSkillExperience(champIndex, skillIndex, (L0565_i_Damage * L0572_ps_CreatureInfo->M58_getExperience() >> 4) + 3);
+ _vm->_championMan->f325_decrementStamine(champIndex, _vm->getRandomNumber(4) + 4);
+ goto T0231016;
+ }
+T0231015:
+ L0565_i_Damage = 0;
+ L0569_i_Outcome = k0_outcomeKilledNoCreaturesInGroup;
+ _vm->_championMan->f325_decrementStamine(champIndex, _vm->getRandomNumber(2) + 2);
+T0231016:
+ _vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
+ if (L0569_i_Outcome != k2_outcomeKilledAllCreaturesInGroup) {
+ f209_processEvents29to41(mapX, mapXóY, kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent, 0);
+ }
+ return L0565_i_Damage;
+}
+
+void GroupMan::f224_fluxCageAction(int16 mapX, int16 mapY) {
+ Thing L0545_T_Thing;
+ int16 L0546_i_Multiple;
+#define AL0546_i_SquareType L0546_i_Multiple
+#define AL0546_i_FluxcageCount L0546_i_Multiple
+ TimelineEvent L0547_s_Event;
+
+
+ if (((AL0546_i_SquareType = _vm->_dungeonMan->f151_getSquare(mapX, mapY).getType()) == k0_ElementTypeWall) || (AL0546_i_SquareType == k3_ElementTypeStairs)) {
+ return;
+ }
+ if ((L0545_T_Thing = _vm->_dungeonMan->f166_getUnusedThing(k15_ExplosionThingType)) == Thing::_none) {
+ return;
+ }
+ _vm->_dungeonMan->f163_linkThingToList(L0545_T_Thing, Thing(0), mapX, mapY);
+ (((Explosion*)_vm->_dungeonMan->_g284_thingData[k15_ExplosionThingType])[L0545_T_Thing.getIndex()]).setType(k50_ExplosionType_Fluxcage);
+ M33_setMapAndTime(L0547_s_Event._mapTime, _vm->_dungeonMan->_g272_currMapIndex, _vm->_g313_gameTime + 100);
+ L0547_s_Event._type = k24_TMEventTypeRemoveFluxcage;
+ L0547_s_Event._priority = 0;
+ L0547_s_Event._C._slot = L0545_T_Thing.toUint16();
+ L0547_s_Event._B._location._mapX = mapX;
+ L0547_s_Event._B._location._mapY = mapY;
+ L0547_s_Event._B._location._mapY = mapY;
+ _vm->_timeline->f238_addEventGetEventIndex(&L0547_s_Event);
+ if (f222_isLordChaosOnSquare(mapX, mapY - 1)) {
+ mapY--;
+ AL0546_i_FluxcageCount = f221_isFluxcageOnSquare(mapX + 1, mapY);
+ goto T0224005;
+ }
+ if (f222_isLordChaosOnSquare(mapX - 1, mapY)) {
+ mapX--;
+ AL0546_i_FluxcageCount = f221_isFluxcageOnSquare(mapX, mapY + 1);
+T0224005:
+ AL0546_i_FluxcageCount += f221_isFluxcageOnSquare(mapX, mapY - 1) + f221_isFluxcageOnSquare(mapX - 1, mapY);
+ } else {
+ if (f222_isLordChaosOnSquare(mapX + 1, mapY)) {
+ mapX++;
+ AL0546_i_FluxcageCount = f221_isFluxcageOnSquare(mapX, mapY - 1);
+ goto T0224008;
+ }
+ if (f222_isLordChaosOnSquare(mapX, mapY + 1)) {
+ mapY++;
+ AL0546_i_FluxcageCount = f221_isFluxcageOnSquare(mapX - 1, mapY);
+T0224008:
+ AL0546_i_FluxcageCount += f221_isFluxcageOnSquare(mapX, mapY + 1) + f221_isFluxcageOnSquare(mapX + 1, mapY);
+ } else {
+ AL0546_i_FluxcageCount = 0;
+ }
+ }
+ if (AL0546_i_FluxcageCount == 2) {
+ f209_processEvents29to41(mapX, mapY, kM3_TMEventTypeCreateReactionEvent29DangerOnSquare, 0);
+ }
+}
+
+uint16 GroupMan::f222_isLordChaosOnSquare(int16 mapX, int16 mapY) {
+ Thing L0542_T_Thing;
+ Group* L0543_ps_Group;
+
+ if ((L0542_T_Thing = _vm->_groupMan->f175_groupGetThing(mapX, mapY)) == Thing::_endOfList) {
+ return 0;
+ }
+ L0543_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(L0542_T_Thing);
+ if (L0543_ps_Group->_type == k23_CreatureTypeLordChaos) {
+ return L0542_T_Thing.toUint16();
+ }
+ return 0;
+}
+
+bool GroupMan::f221_isFluxcageOnSquare(int16 mapX, int16 mapY) {
+ Thing L0540_T_Thing;
+ int16 L0541_i_SquareType;
+
+ if (((L0541_i_SquareType = _vm->_dungeonMan->f151_getSquare(mapX, mapY).getType()) == k0_ElementTypeWall) || (L0541_i_SquareType == k3_ElementTypeStairs)) {
+ return false;
+ }
+ L0540_T_Thing = _vm->_dungeonMan->f161_getSquareFirstThing(mapX, mapY);
+ while (L0540_T_Thing != Thing::_endOfList) {
+ if ((L0540_T_Thing.getType() == k15_ExplosionThingType) && (((Explosion*)_vm->_dungeonMan->_g284_thingData[k15_ExplosionThingType])[L0540_T_Thing.getIndex()].getType() == k50_ExplosionType_Fluxcage)) {
+ return true;
+ }
+ L0540_T_Thing = _vm->_dungeonMan->f159_getNextThing(L0540_T_Thing);
+ }
+ return false;
+}
+
+void GroupMan::f225_fuseAction(uint16 mapX, uint16 mapY) {
+ int16 L0548_i_MapX;
+ int16 L0549_i_MapY;
+ uint16 L0551_ui_FluxcageCount;
+ uint16 L0552_ui_FluxcageIndex;
+ uint16 L0553_ui_Counter;
+ bool L0554_aB_Fluxcages[4];
+ Thing L0555_T_LordChaosThing;
+
+ if ((mapX < 0) || (mapX >= _vm->_dungeonMan->_g273_currMapWidth) || (mapY < 0) || (mapY >= _vm->_dungeonMan->_g274_currMapHeight)) {
+ return;
+ }
+
+ _vm->_projexpl->f213_explosionCreate(Thing::_explHarmNonMaterial, 255, mapX, mapY, k255_CreatureTypeSingleCenteredCreature); /* BUG0_17 The game crashes after the Fuse action is performed while looking at a wall on a map boundary. An explosion thing is created on the square in front of the party but there is no check to ensure the square coordinates are in the map bounds. This corrupts a memory location and leads to a game crash */
+ if ((L0555_T_LordChaosThing = Thing(f222_isLordChaosOnSquare(mapX, mapY))).toUint16()) {
+ L0551_ui_FluxcageCount = (L0554_aB_Fluxcages[0] = f221_isFluxcageOnSquare(mapX - 1, mapY)) +
+ (L0554_aB_Fluxcages[1] = f221_isFluxcageOnSquare(mapX + 1, mapY)) +
+ (L0554_aB_Fluxcages[2] = f221_isFluxcageOnSquare(mapX, mapY - 1)) +
+ (L0554_aB_Fluxcages[3] = f221_isFluxcageOnSquare(mapX, mapY + 1));
+ while (L0551_ui_FluxcageCount++ < 4) {
+ L0548_i_MapX = mapX;
+ L0549_i_MapY = mapY;
+ L0552_ui_FluxcageIndex = _vm->getRandomNumber(4);
+ for (L0553_ui_Counter = 5; --L0553_ui_Counter; L0552_ui_FluxcageIndex = returnNextVal(L0552_ui_FluxcageIndex)) {
+ if (!L0554_aB_Fluxcages[L0552_ui_FluxcageIndex]) {
+ L0554_aB_Fluxcages[L0552_ui_FluxcageIndex] = true;
+ switch (L0552_ui_FluxcageIndex) {
+ case 0:
+ L0548_i_MapX--;
+ break;
+ case 1:
+ L0548_i_MapX++;
+ break;
+ case 2:
+ L0549_i_MapY--;
+ break;
+ case 3:
+ L0549_i_MapY++;
+ }
+ break;
+ }
+ }
+ if (f223_isSquareACorridorTeleporterPitOrDoor(L0548_i_MapX, L0549_i_MapY)) {
+ if (!_vm->_movsens->f267_getMoveResult(L0555_T_LordChaosThing, mapX, mapY, L0548_i_MapX, L0549_i_MapY)) {
+ f180_startWanedring(L0548_i_MapX, L0549_i_MapY);
+ }
+ return;
+ }
+ }
+ warning(false, "F0446_STARTEND_FuseSequence()");
+ }
+}
}
diff --git a/engines/dm/group.h b/engines/dm/group.h
index 242e52768d..fd7d98afe7 100644
--- a/engines/dm/group.h
+++ b/engines/dm/group.h
@@ -32,6 +32,7 @@
#include "dm.h"
namespace DM {
+ class Champion;
class TimelineEvent;
class CreatureInfo;
@@ -236,7 +237,14 @@ public:
void f195_addAllActiveGroups(); // @ F0195_GROUP_AddAllActiveGroups
Thing f185_groupGetGenerated(int16 creatureType, int16 healthMultiplier, uint16 creatureCount, direction dir, int16 mapX, int16 mapY); // @ F0185_GROUP_GetGenerated
bool f223_isSquareACorridorTeleporterPitOrDoor(int16 mapX, int16 mapY); // @ F0223_GROUP_IsSquareACorridorTeleporterPitOrDoor
-
+ int16 f177_getMeleeTargetCreatureOrdinal(int16 groupX, int16 groupY, int16 partyX, int16 paryY,
+ uint16 champCell); // @ F0177_GROUP_GetMeleeTargetCreatureOrdinal
+ int16 f231_getMeleeActionDamage(Champion *champ, int16 champIndex, Group *group, int16 creatureIndex,
+ int16 mapX, int16 mapXóY, uint16 actionHitProbability, uint16 actionDamageFactor, int16 skillIndex); // @ F0231_GROUP_GetMeleeActionDamage
+ void f224_fluxCageAction(int16 mapX, int16 mapY); // @ F0224_GROUP_FluxCageAction
+ uint16 f222_isLordChaosOnSquare(int16 mapX, int16 mapY); // @ F0222_GROUP_IsLordChaosOnSquare
+ bool f221_isFluxcageOnSquare(int16 mapX, int16 mapY); // @ F0221_GROUP_IsFluxcageOnSquare
+ void f225_fuseAction(uint16 mapX, uint16 mapY); // @ F0225_GROUP_FuseAction
};
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index d35ec7553a..06a286c65e 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -35,10 +35,59 @@
#include "eventman.h"
#include "timeline.h"
#include "movesens.h"
+#include "group.h"
+#include "projexpl.h"
namespace DM {
+unsigned char g496_ActionSkillIndex[44] = { // @ G0496_auc_Graphic560_ActionSkillIndex
+ 0, /* N */
+ 7, /* BLOCK */
+ 6, /* CHOP */
+ 0, /* X */
+ 14, /* BLOW HORN */
+ 12, /* FLIP */
+ 9, /* PUNCH */
+ 9, /* KICK */
+ 7, /* WAR CRY Atari ST Versions 1.0 1987-12-08 1987-12-11 1.1: 14 */
+ 9, /* STAB */
+ 8, /* CLIMB DOWN */
+ 14, /* FREEZE LIFE */
+ 9, /* HIT */
+ 4, /* SWING */
+ 5, /* STAB */
+ 5, /* THRUST */
+ 5, /* JAB */
+ 7, /* PARRY */
+ 4, /* HACK */
+ 4, /* BERZERK */
+ 16, /* FIREBALL */
+ 17, /* DISPELL */
+ 14, /* CONFUSE */
+ 17, /* LIGHTNING */
+ 17, /* DISRUPT */
+ 6, /* MELEE */
+ 8, /* X */
+ 3, /* INVOKE */
+ 4, /* SLASH */
+ 4, /* CLEAVE */
+ 6, /* BASH */
+ 6, /* STUN */
+ 11, /* SHOOT */
+ 15, /* SPELLSHIELD */
+ 15, /* FIRESHIELD */
+ 3, /* FLUXCAGE */
+ 13, /* HEAL */
+ 14, /* CALM */
+ 17, /* LIGHT */
+ 18, /* WINDOW */
+ 16, /* SPIT */
+ 14, /* BRANDISH */
+ 10, /* THROW */
+ 3}; /* FUSE */
+
+
Box g499_BoxActionArea3ActionMenu = Box(224, 319, 77, 121); // @ G0499_s_Graphic560_Box_ActionArea3ActionsMenu
Box g500_BoxActionArea2ActionMenu = Box(224, 319, 77, 109); // @ G0500_s_Graphic560_Box_ActionArea2ActionsMenu
Box g501_BoxActionArea1ActionMenu = Box(224, 319, 77, 97); // @ G0501_s_Graphic560_Box_ActionArea1ActionMenu
@@ -56,6 +105,8 @@ MenuMan::MenuMan(DMEngine *vm) : _vm(vm) {
_g513_actionDamage = 0;
_g713_actionList.resetToZero();
_gK72_bitmapSpellAreaLine = new byte[96 * 12];
+ _g517_actionTargetGroupThing = Thing(0);
+ _g507_actionCount = 0;
}
MenuMan::~MenuMan() {
@@ -813,4 +864,817 @@ void MenuMan::f400_deleteChampionSymbol() {
f398_drawChampionSymbols(L1228_ps_Champion);
_vm->_eventMan->f77_hideMouse();
}
+
+bool MenuMan::f391_didClickTriggerAction(int16 actionListIndex) {
+ uint16 L1196_ui_ChampionIndex;
+ uint16 L1197_ui_ActionIndex;
+ bool L1198_B_ClickTriggeredAction;
+ Champion* L1199_ps_Champion;
+
+
+ if (!_vm->_championMan->_g506_actingChampionOrdinal || (actionListIndex != -1 && (_vm->_menuMan->_g713_actionList._actionIndices[actionListIndex] == k255_ChampionActionNone)))
+ return false;
+
+ L1199_ps_Champion = &_vm->_championMan->_gK71_champions[L1196_ui_ChampionIndex = _vm->M1_ordinalToIndex(_vm->_championMan->_g506_actingChampionOrdinal)];
+ if (actionListIndex == -1) {
+ warning(false, "possible bug in f391_didClickTriggerAction");
+ // L1198_B_ClickTriggeredAction is set to -1 since booleans are stored in int16 in the original
+ L1198_B_ClickTriggeredAction = true;
+ } else {
+ L1197_ui_ActionIndex = _vm->_menuMan->_g713_actionList._actionIndices[actionListIndex];
+ L1199_ps_Champion->_actionDefense += g495_actionDefense[L1197_ui_ActionIndex]; /* BUG0_54 The defense modifier of an action is permanent.
+ Each action has an associated defense modifier value and a number of ticks while the champion cannot perform another action because the action icon is grayed out. If an action has a non zero defense modifier and a zero value for the number of ticks then the defense modifier is applied but it is never removed. This causes no issue in the original games because there are no actions in this case but it may occur in a version where data is customized. This statement should only be executed if the value for the action in G0491_auc_Graphic560_ActionDisabledTicks is not 0 otherwise the action is not disabled at the end of F0407_MENUS_IsActionPerformed and thus not enabled later in F0253_TIMELINE_ProcessEvent11Part1_EnableChampionAction where the defense modifier is also removed */
+ setFlag(L1199_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
+ L1198_B_ClickTriggeredAction = f407_isActionPerformed(L1196_ui_ChampionIndex, L1197_ui_ActionIndex);
+ L1199_ps_Champion->_actionIndex = (ChampionAction)L1197_ui_ActionIndex;
+ }
+ _vm->_menuMan->f388_clearActingChampion();
+ return L1198_B_ClickTriggeredAction;
+}
+
+bool MenuMan::f407_isActionPerformed(uint16 champIndex, int16 actionIndex) {
+ static unsigned char G0491_auc_Graphic560_ActionDisabledTicks[44] = {
+ 0, /* N */
+ 6, /* BLOCK */
+ 8, /* CHOP */
+ 0, /* X */
+ 6, /* BLOW HORN */
+ 3, /* FLIP */
+ 1, /* PUNCH */
+ 5, /* KICK */
+ 3, /* WAR CRY */
+ 5, /* STAB */
+ 35, /* CLIMB DOWN */
+ 20, /* FREEZE LIFE */
+ 4, /* HIT */
+ 6, /* SWING */
+ 10, /* STAB */
+ 16, /* THRUST */
+ 2, /* JAB */
+ 18, /* PARRY */
+ 8, /* HACK */
+ 30, /* BERZERK */
+ 42, /* FIREBALL */
+ 31, /* DISPELL */
+ 10, /* CONFUSE */
+ 38, /* LIGHTNING */
+ 9, /* DISRUPT */
+ 20, /* MELEE */
+ 10, /* X */
+ 16, /* INVOKE */
+ 4, /* SLASH */
+ 12, /* CLEAVE */
+ 20, /* BASH */
+ 7, /* STUN */
+ 14, /* SHOOT */
+ 30, /* SPELLSHIELD */
+ 35, /* FIRESHIELD */
+ 2, /* FLUXCAGE */
+ 19, /* HEAL */
+ 9, /* CALM */
+ 10, /* LIGHT */
+ 15, /* WINDOW */
+ 22, /* SPIT */
+ 10, /* BRANDISH */
+ 0, /* THROW */
+ 2}; /* FUSE */
+ static unsigned char G0494_auc_Graphic560_ActionStamina[44] = {
+ 0, /* N */
+ 4, /* BLOCK */
+ 10, /* CHOP */
+ 0, /* X */
+ 1, /* BLOW HORN */
+ 0, /* FLIP */
+ 1, /* PUNCH */
+ 3, /* KICK */
+ 1, /* WAR CRY */
+ 3, /* STAB */
+ 40, /* CLIMB DOWN */
+ 3, /* FREEZE LIFE */
+ 3, /* HIT */
+ 2, /* SWING */
+ 4, /* STAB */
+ 17, /* THRUST */
+ 3, /* JAB */
+ 1, /* PARRY */
+ 6, /* HACK */
+ 40, /* BERZERK */
+ 5, /* FIREBALL */
+ 2, /* DISPELL */
+ 2, /* CONFUSE */
+ 4, /* LIGHTNING */
+ 5, /* DISRUPT */
+ 25, /* MELEE */
+ 1, /* X */
+ 2, /* INVOKE */
+ 2, /* SLASH */
+ 10, /* CLEAVE */
+ 9, /* BASH */
+ 2, /* STUN */
+ 3, /* SHOOT */
+ 1, /* SPELLSHIELD */
+ 2, /* FIRESHIELD */
+ 6, /* FLUXCAGE */
+ 1, /* HEAL */
+ 1, /* CALM */
+ 3, /* LIGHT */
+ 2, /* WINDOW */
+ 3, /* SPIT */
+ 2, /* BRANDISH */
+ 0, /* THROW */
+ 2}; /* FUSE */
+ unsigned char G0497_auc_Graphic560_ActionExperienceGain[44] = {
+ 0, /* N */
+ 8, /* BLOCK */
+ 10, /* CHOP */
+ 0, /* X */
+ 0, /* BLOW HORN */
+ 0, /* FLIP */
+ 8, /* PUNCH */
+ 13, /* KICK */
+ 7, /* WAR CRY */
+ 15, /* STAB */
+ 15, /* CLIMB DOWN */
+ 22, /* FREEZE LIFE */
+ 10, /* HIT */
+ 6, /* SWING */
+ 12, /* STAB */
+ 19, /* THRUST */
+ 11, /* JAB */
+ 17, /* PARRY */
+ 9, /* HACK */
+ 40, /* BERZERK */
+ 35, /* FIREBALL */
+ 25, /* DISPELL */
+ 0, /* CONFUSE */
+ 30, /* LIGHTNING */
+ 10, /* DISRUPT */
+ 24, /* MELEE */
+ 0, /* X */
+ 25, /* INVOKE */
+ 9, /* SLASH */
+ 12, /* CLEAVE */
+ 11, /* BASH */
+ 10, /* STUN */
+ 20, /* SHOOT Atari ST Versions 1.0 1987-12-08 1987-12-11: 9 */
+ 20, /* SPELLSHIELD */
+ 20, /* FIRESHIELD */
+ 12, /* FLUXCAGE */
+ 0, /* HEAL */
+ 0, /* CALM */
+ 20, /* LIGHT */
+ 30, /* WINDOW */
+ 25, /* SPIT */
+ 0, /* BRANDISH */
+ 5, /* THROW */
+ 1}; /* FUSE */
+ uint16 L1244_ui_Multiple;
+#define AL1244_ui_TargetSquare L1244_ui_Multiple
+#define AL1244_ui_HealingAmount L1244_ui_Multiple
+#define AL1244_ui_ManaCost L1244_ui_Multiple
+ int16 L1245_i_Multiple;
+#define AL1245_T_ExplosionThing L1245_i_Multiple
+#define AL1245_B_ActionPerformed L1245_i_Multiple
+ int16 L1246_i_Multiple;
+#define AL1246_i_RequiredManaAmount L1246_i_Multiple
+#define AL1246_i_ActionHandWeaponClass L1246_i_Multiple
+#define AL1246_i_StepEnergy L1246_i_Multiple
+#define AL1246_i_HealingCapability L1246_i_Multiple
+#define AL1246_i_Ticks L1246_i_Multiple
+ Champion* L1247_ps_Champion;
+ Weapon* L1248_ps_Weapon;
+ uint16 L1249_ui_ActionDisabledTicks;
+ int16 L1250_i_Multiple;
+#define AL1250_i_KineticEnergy L1250_i_Multiple
+#define AL1250_i_ReadyHandWeaponClass L1250_i_Multiple
+#define AL1250_i_MissingHealth L1250_i_Multiple
+#define AL1250_i_HealingAmount L1250_i_Multiple
+ int16 L1251_i_MapX;
+ int16 L1252_i_MapY;
+ int16 L1253_i_ActionStamina;
+ int16 L1254_i_ActionSkillIndex;
+ int16 L1255_i_ActionExperienceGain;
+ WeaponInfo* L1256_ps_WeaponInfoActionHand;
+ WeaponInfo* L1257_ps_WeaponInfoReadyHand;
+ TimelineEvent L1258_s_Event;
+
+
+ if (champIndex >= _vm->_championMan->_g305_partyChampionCount) {
+ return false;
+ }
+ L1247_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex];
+ L1248_ps_Weapon = (Weapon*)_vm->_dungeonMan->f156_getThingData(L1247_ps_Champion->_slots[k1_ChampionSlotActionHand]);
+ if (!L1247_ps_Champion->_currHealth) {
+ return false;
+ }
+ L1251_i_MapX = _vm->_dungeonMan->_g306_partyMapX;
+ L1252_i_MapY = _vm->_dungeonMan->_g307_partyMapY;
+ L1251_i_MapX += _vm->_dirIntoStepCountEast[L1247_ps_Champion->_dir], L1252_i_MapY += _vm->_dirIntoStepCountNorth[L1247_ps_Champion->_dir];
+ _g517_actionTargetGroupThing = _vm->_groupMan->f175_groupGetThing(L1251_i_MapX, L1252_i_MapY);
+ L1249_ui_ActionDisabledTicks = G0491_auc_Graphic560_ActionDisabledTicks[actionIndex];
+ L1254_i_ActionSkillIndex = g496_ActionSkillIndex[actionIndex];
+ L1253_i_ActionStamina = G0494_auc_Graphic560_ActionStamina[actionIndex] + _vm->getRandomNumber(2);
+ L1255_i_ActionExperienceGain = G0497_auc_Graphic560_ActionExperienceGain[actionIndex];
+ AL1244_ui_TargetSquare = _vm->_dungeonMan->f151_getSquare(L1251_i_MapX, L1252_i_MapY).toByte();
+ AL1245_B_ActionPerformed = true;
+ if (((L1254_i_ActionSkillIndex >= k16_ChampionSkillFire) && (L1254_i_ActionSkillIndex <= k19_ChampionSkillWater)) || (L1254_i_ActionSkillIndex == k3_ChampionSkillWizard)) {
+ AL1246_i_RequiredManaAmount = 7 - MIN((uint16)6, _vm->_championMan->f303_getSkillLevel(champIndex, L1254_i_ActionSkillIndex));
+ }
+ switch (actionIndex) {
+ case k23_ChampionActionLightning:
+ AL1250_i_KineticEnergy = 180;
+ AL1245_T_ExplosionThing = Thing::_explLightningBolt.toUint16();
+ goto T0407014;
+ case k21_ChampionActionDispel:
+ AL1250_i_KineticEnergy = 150;
+ AL1245_T_ExplosionThing = Thing::_explHarmNonMaterial.toUint16();
+ goto T0407014;
+ case k20_ChampionActionFireball:
+ AL1250_i_KineticEnergy = 150;
+ goto T0407013;
+ case k40_ChampionActionSpit:
+ AL1250_i_KineticEnergy = 250;
+T0407013:
+ AL1245_T_ExplosionThing = Thing::_explFireBall.toUint16();
+T0407014:
+ f406_setChampionDirectionToPartyDirection(L1247_ps_Champion);
+ if (L1247_ps_Champion->_currMana < AL1246_i_RequiredManaAmount) {
+ AL1250_i_KineticEnergy = MAX(2, L1247_ps_Champion->_currMana * AL1250_i_KineticEnergy / AL1246_i_RequiredManaAmount);
+ AL1246_i_RequiredManaAmount = L1247_ps_Champion->_currMana;
+ }
+ if (!(AL1245_B_ActionPerformed = _vm->_championMan->f327_isProjectileSpellCast(champIndex, Thing(AL1245_T_ExplosionThing), AL1250_i_KineticEnergy, AL1246_i_RequiredManaAmount))) {
+ L1255_i_ActionExperienceGain >>= 1;
+ }
+ f405_decrementCharges(L1247_ps_Champion);
+ break;
+ case k30_ChampionActionBash:
+ case k18_ChampionActionHack:
+ case k19_ChampionActionBerzerk:
+ case k7_ChampionActionKick:
+ case k13_ChampionActionSwing:
+ case k2_ChampionActionChop:
+ if ((Square(AL1244_ui_TargetSquare).getType() == k4_DoorElemType) && (Square(AL1244_ui_TargetSquare).getDoorState() == k4_doorState_CLOSED)) {
+ warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+ L1249_ui_ActionDisabledTicks = 6;
+ _vm->_groupMan->f232_groupIsDoorDestoryedByAttack(L1251_i_MapX, L1252_i_MapY, _vm->_championMan->f312_getStrength(champIndex, k1_ChampionSlotActionHand), false, 2);
+ warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+ break;
+ }
+ case k24_ChampionActionDisrupt:
+ case k16_ChampionActionJab:
+ case k17_ChampionActionParry:
+ case k14_ChampionActionStab_C014:
+ case k9_ChampionActionStab_C009:
+ case k31_ChampionActionStun:
+ case k15_ChampionActionThrust:
+ case k25_ChampionActionMelee:
+ case k28_ChampionActionSlash:
+ case k29_ChampionActionCleave:
+ case k6_ChampionActionPunch:
+ if (!(AL1245_B_ActionPerformed = f402_isMeleeActionPerformed(champIndex, L1247_ps_Champion, actionIndex, L1251_i_MapX, L1252_i_MapY, L1254_i_ActionSkillIndex))) {
+ L1255_i_ActionExperienceGain >>= 1;
+ L1249_ui_ActionDisabledTicks >>= 1;
+ }
+ break;
+ case k22_ChampionActionConfuse:
+ f405_decrementCharges(L1247_ps_Champion);
+ case k8_ChampionActionWarCry:
+ case k37_ChampionActionCalm:
+ case k41_ChampionActionBrandish:
+ case k4_ChampionActionBlowHorn:
+ if (actionIndex == k8_ChampionActionWarCry) {
+ warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+ }
+ if (actionIndex == k4_ChampionActionBlowHorn) {
+ warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+ }
+ AL1245_B_ActionPerformed = f401_isGroupFrightenedByAction(champIndex, actionIndex, L1251_i_MapX, L1252_i_MapY);
+ break;
+ case k32_ChampionActionShoot:
+ if (Thing(L1247_ps_Champion->_slots[k0_ChampionSlotReadyHand]).getType() != k5_WeaponThingType)
+ goto T0407032;
+ L1256_ps_WeaponInfoActionHand = &g238_WeaponInfo[L1248_ps_Weapon->getType()];
+ L1257_ps_WeaponInfoReadyHand = _vm->_dungeonMan->f158_getWeaponInfo(L1247_ps_Champion->_slots[k0_ChampionSlotReadyHand]);
+ AL1246_i_ActionHandWeaponClass = L1256_ps_WeaponInfoActionHand->_class;
+ AL1250_i_ReadyHandWeaponClass = L1257_ps_WeaponInfoReadyHand->_class;
+ if ((AL1246_i_ActionHandWeaponClass >= k16_WeaponClassFirstBow) && (AL1246_i_ActionHandWeaponClass <= k31_WeaponClassLastBow)) {
+ if (AL1250_i_ReadyHandWeaponClass != k10_WeaponClassBowAmmunition)
+ goto T0407032;
+ AL1246_i_StepEnergy -= k16_WeaponClassFirstBow;
+ } else {
+ if ((AL1246_i_ActionHandWeaponClass >= k32_WeaponClassFirstSling) && (AL1246_i_ActionHandWeaponClass <= k47_WeaponClassLastSling)) {
+ if (AL1250_i_ReadyHandWeaponClass != k11_WeaponClassSlingAmmunition) {
+T0407032:
+ _vm->_menuMan->_g513_actionDamage = kM2_damageNoAmmunition;
+ L1255_i_ActionExperienceGain = 0;
+ AL1245_B_ActionPerformed = false;
+ break;
+ }
+ AL1246_i_StepEnergy -= k32_WeaponClassFirstSling;
+ }
+ }
+ f406_setChampionDirectionToPartyDirection(L1247_ps_Champion);
+ { // so gotos won't skip init
+ Thing AL1250_T_Object = _vm->_championMan->f300_getObjectRemovedFromSlot(champIndex, k0_ChampionSlotReadyHand);
+ warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+ _vm->_championMan->f326_championShootProjectile(L1247_ps_Champion, AL1250_T_Object, L1256_ps_WeaponInfoActionHand->_kineticEnergy + L1257_ps_WeaponInfoReadyHand->_kineticEnergy, (L1256_ps_WeaponInfoActionHand->getShootAttack() + _vm->_championMan->f303_getSkillLevel(champIndex, k11_ChampionSkillShoot)) << 1, AL1246_i_StepEnergy);
+ }
+ break;
+ case k5_ChampionActionFlip:
+ // TODO: localization
+ if (_vm->getRandomNumber(2)) {
+ f381_printMessageAfterReplacements("IT COMES UP HEADS.");
+ } else {
+ f381_printMessageAfterReplacements("IT COMES UP TAILS.");
+ }
+ break;
+ case k33_ChampionActionSpellshield:
+ case k34_ChampionActionFireshield:
+ if (!f403_isPartySpellOrFireShieldSuccessful(L1247_ps_Champion, actionIndex == k33_ChampionActionSpellshield, 280, true)) {
+ L1255_i_ActionExperienceGain >>= 2;
+ L1249_ui_ActionDisabledTicks >>= 1;
+ } else {
+ f405_decrementCharges(L1247_ps_Champion);
+ }
+ break;
+ case k27_ChampionActionInvoke:
+ AL1250_i_KineticEnergy = _vm->getRandomNumber(128) + 100;
+ switch (_vm->getRandomNumber(6)) {
+ case 0:
+ AL1245_T_ExplosionThing = Thing::_explPoisonBolt.toUint16();
+ goto T0407014;
+ case 1:
+ AL1245_T_ExplosionThing = Thing::_explPoisonCloud.toUint16();
+ goto T0407014;
+ case 2:
+ AL1245_T_ExplosionThing = Thing::_explHarmNonMaterial.toUint16();
+ goto T0407014;
+ default:
+ goto T0407013;
+ }
+ case k35_ChampionActionFluxcage:
+ f406_setChampionDirectionToPartyDirection(L1247_ps_Champion);
+ _vm->_groupMan->f224_fluxCageAction(L1251_i_MapX, L1252_i_MapY);
+ break;
+ case k43_ChampionActionFuse:
+ f406_setChampionDirectionToPartyDirection(L1247_ps_Champion);
+ L1251_i_MapX = _vm->_dungeonMan->_g306_partyMapX;
+ L1252_i_MapY = _vm->_dungeonMan->_g307_partyMapY;
+ L1251_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], L1252_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
+ _vm->_groupMan->f225_fuseAction(L1251_i_MapX, L1252_i_MapY);
+ break;
+ case k36_ChampionActionHeal:
+ /* CHANGE2_17_IMPROVEMENT Heal action is much more effective
+ Heal cycles occur as long as the champion has missing health and enough mana. Cycle count = Min(Current Mana / 2, Missing health / Min(10, Heal skill level))
+ Healing amount is Min(Missing health, Min(10, Heal skill level)) * heal cycle count
+ Mana cost is 2 * heal cycle count
+ Experience gain is 2 + 2 * heal cycle count */
+ if (((AL1250_i_MissingHealth = L1247_ps_Champion->_maxHealth - L1247_ps_Champion->_currHealth) > 0) && L1247_ps_Champion->_currMana) {
+ AL1246_i_HealingCapability = MIN((uint16)10, _vm->_championMan->f303_getSkillLevel(champIndex, k13_ChampionSkillHeal));
+ L1255_i_ActionExperienceGain = 2;
+ do {
+ AL1244_ui_HealingAmount = MIN(AL1250_i_MissingHealth, AL1246_i_HealingCapability);
+ L1247_ps_Champion->_currHealth += AL1244_ui_HealingAmount;
+ L1255_i_ActionExperienceGain += 2;
+ } while (((L1247_ps_Champion->_currMana = L1247_ps_Champion->_currMana - 2) > 0) && (AL1250_i_MissingHealth = AL1250_i_MissingHealth - AL1244_ui_HealingAmount));
+ if (L1247_ps_Champion->_currMana < 0) {
+ L1247_ps_Champion->_currMana = 0;
+ }
+ setFlag(L1247_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
+ AL1245_B_ActionPerformed = true;
+ }
+ break;
+ case k39_ChampionActionWindow:
+ AL1246_i_Ticks = _vm->getRandomNumber(_vm->_championMan->f303_getSkillLevel(champIndex, L1254_i_ActionSkillIndex) + 8) + 5;
+ L1258_s_Event._priority = 0;
+ L1258_s_Event._type = k73_TMEventTypeThievesEye;
+ M33_setMapAndTime(L1258_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + AL1246_i_Ticks);
+ _vm->_timeline->f238_addEventGetEventIndex(&L1258_s_Event);
+ _vm->_championMan->_g407_party._event73Count_ThievesEye++;
+ goto T0407076;
+ case k10_ChampionActionClimbDown:
+ L1251_i_MapX = _vm->_dungeonMan->_g306_partyMapX;
+ L1252_i_MapY = _vm->_dungeonMan->_g307_partyMapY;
+ L1251_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_g308_partyDir], L1252_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_g308_partyDir];
+ /* CHANGE6_00_FIX The presence of a group over the pit is checked so that you cannot climb down a pit with the rope if there is a group levitating over it */
+ if ((_vm->_dungeonMan->f151_getSquare(L1251_i_MapX, L1252_i_MapY).getType() == k2_ElementTypePit) && (_vm->_groupMan->f175_groupGetThing(L1251_i_MapX, L1252_i_MapY) == Thing::_endOfList)) {
+ /* BUG0_77 The party moves forward when using the rope in front of a closed pit. The engine does not check whether the pit is open before moving the party over the pit. This is not consistent with the behavior when using the rope in front of a corridor where nothing happens */
+ _vm->_movsens->_g402_useRopeToClimbDownPit = true;
+ _vm->_movsens->f267_getMoveResult(Thing::_party, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, L1251_i_MapX, L1252_i_MapY);
+ _vm->_movsens->_g402_useRopeToClimbDownPit = false;
+ } else {
+ L1249_ui_ActionDisabledTicks = 0;
+ }
+ break;
+ case k11_ChampionActionFreezeLife:
+ if (L1248_ps_Weapon->getType() == k42_JunkTypeMagicalBoxBlue) {
+ AL1246_i_Ticks = 30;
+ goto T0407071;
+ }
+ if (L1248_ps_Weapon->getType() == k43_JunkTypeMagicalBoxGreen) {
+ AL1246_i_Ticks = 125;
+T0407071:
+ _vm->_championMan->f300_getObjectRemovedFromSlot(champIndex, k1_ChampionSlotActionHand);
+ L1248_ps_Weapon->setNextThing(Thing::_none);
+ } else {
+ AL1246_i_Ticks = 70;
+ f405_decrementCharges(L1247_ps_Champion);
+ }
+ _vm->_championMan->_g407_party._freezeLifeTicks = MIN(200, _vm->_championMan->_g407_party._freezeLifeTicks + AL1246_i_Ticks);
+ break;
+ case k38_ChampionActionLight:
+ _vm->_championMan->_g407_party._magicalLightAmount += g39_LightPowerToLightAmount[2];
+ f404_createEvent70_light(-2, 2500);
+T0407076:
+ f405_decrementCharges(L1247_ps_Champion);
+ break;
+ case k42_ChampionActionThrow:
+ f406_setChampionDirectionToPartyDirection(L1247_ps_Champion);
+ if (AL1245_B_ActionPerformed = _vm->_championMan->f328_isObjectThrown(champIndex, k1_ChampionSlotActionHand, (L1247_ps_Champion->_cell == returnNextVal(_vm->_dungeonMan->_g308_partyDir)) || (L1247_ps_Champion->_cell == returnOppositeDir(_vm->_dungeonMan->_g308_partyDir)))) {
+ _vm->_timeline->_g370_events[L1247_ps_Champion->_enableActionEventIndex]._B._slotOrdinal = _vm->M0_indexToOrdinal(k1_ChampionSlotActionHand);
+ }
+ }
+ if (L1249_ui_ActionDisabledTicks) {
+ _vm->_championMan->f330_disableAction(champIndex, L1249_ui_ActionDisabledTicks);
+ }
+ if (L1253_i_ActionStamina) {
+ _vm->_championMan->f325_decrementStamine(champIndex, L1253_i_ActionStamina);
+ }
+ if (L1255_i_ActionExperienceGain) {
+ _vm->_championMan->f304_addSkillExperience(champIndex, L1254_i_ActionSkillIndex, L1255_i_ActionExperienceGain);
+ }
+ _vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
+ return AL1245_B_ActionPerformed;
+}
+
+void MenuMan::f406_setChampionDirectionToPartyDirection(Champion* champ) {
+ if (champ->_dir != _vm->_dungeonMan->_g308_partyDir) {
+ champ->_dir = _vm->_dungeonMan->_g308_partyDir;
+ setFlag(champ->_attributes, k0x0400_ChampionAttributeIcon);
+ }
+}
+
+void MenuMan::f405_decrementCharges(Champion* champ) {
+ Thing L1242_T_Thing;
+ Junk* L1243_ps_Junk;
+
+ L1243_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L1242_T_Thing = champ->_slots[k1_ChampionSlotActionHand]);
+ switch (L1242_T_Thing.getType()) {
+ case k5_WeaponThingType:
+ if (((Weapon*)L1243_ps_Junk)->getChargeCount()) {
+ ((Weapon*)L1243_ps_Junk)->setChargeCount(((Weapon*)L1243_ps_Junk)->getChargeCount() - 1);
+ }
+ break;
+ case k6_ArmourThingType:
+ if (((Armour*)L1243_ps_Junk)->getChargeCount()) {
+ ((Armour*)L1243_ps_Junk)->setChargeCount(((Armour*)L1243_ps_Junk)->getChargeCount() - 1);
+ }
+ break;
+ case k10_JunkThingType:
+ if (L1243_ps_Junk->getChargeCount()) {
+ L1243_ps_Junk->setChargeCount(L1243_ps_Junk->getChargeCount() - 1);
+ }
+ }
+ _vm->_championMan->f296_drawChangedObjectIcons();
+}
+
+bool MenuMan::f402_isMeleeActionPerformed(int16 champIndex, Champion* champ, int16 actionIndex, int16 targetMapX, int16 targetMapY, int16 skillIndex) {
+ static unsigned char G0492_auc_Graphic560_ActionDamageFactor[44] = {
+ 0, /* N */
+ 15, /* BLOCK */
+ 48, /* CHOP */
+ 0, /* X */
+ 0, /* BLOW HORN */
+ 0, /* FLIP */
+ 32, /* PUNCH */
+ 48, /* KICK */
+ 0, /* WAR CRY */
+ 48, /* STAB */
+ 0, /* CLIMB DOWN */
+ 0, /* FREEZE LIFE */
+ 20, /* HIT */
+ 16, /* SWING */
+ 60, /* STAB */
+ 66, /* THRUST */
+ 8, /* JAB */
+ 8, /* PARRY */
+ 25, /* HACK */
+ 96, /* BERZERK */
+ 0, /* FIREBALL */
+ 0, /* DISPELL */
+ 0, /* CONFUSE */
+ 0, /* LIGHTNING */
+ 55, /* DISRUPT */
+ 60, /* MELEE */
+ 0, /* X */
+ 0, /* INVOKE */
+ 16, /* SLASH */
+ 48, /* CLEAVE */
+ 50, /* BASH */
+ 16, /* STUN */
+ 0, /* SHOOT */
+ 0, /* SPELLSHIELD */
+ 0, /* FIRESHIELD */
+ 0, /* FLUXCAGE */
+ 0, /* HEAL */
+ 0, /* CALM */
+ 0, /* LIGHT */
+ 0, /* WINDOW */
+ 0, /* SPIT */
+ 0, /* BRANDISH */
+ 0, /* THROW */
+ 0}; /* FUSE */
+ static unsigned char G0493_auc_Graphic560_ActionHitProbability[44] = {
+ 0, /* N */
+ 22, /* BLOCK */
+ 48, /* CHOP */
+ 0, /* X */
+ 0, /* BLOW HORN */
+ 0, /* FLIP */
+ 38, /* PUNCH */
+ 28, /* KICK */
+ 0, /* WAR CRY */
+ 30, /* STAB */
+ 0, /* CLIMB DOWN */
+ 0, /* FREEZE LIFE */
+ 20, /* HIT */
+ 32, /* SWING */
+ 42, /* STAB */
+ 57, /* THRUST */
+ 70, /* JAB */
+ 18, /* PARRY */
+ 27, /* HACK */
+ 46, /* BERZERK */
+ 0, /* FIREBALL */
+ 0, /* DISPELL */
+ 0, /* CONFUSE */
+ 0, /* LIGHTNING */
+ 46, /* DISRUPT */
+ 64, /* MELEE */
+ 0, /* X */
+ 0, /* INVOKE */
+ 26, /* SLASH */
+ 40, /* CLEAVE */
+ 32, /* BASH */
+ 50, /* STUN */
+ 0, /* SHOOT */
+ 0, /* SPELLSHIELD */
+ 0, /* FIRESHIELD */
+ 0, /* FLUXCAGE */
+ 0, /* HEAL */
+ 0, /* CALM */
+ 0, /* LIGHT */
+ 0, /* WINDOW */
+ 0, /* SPIT */
+ 0, /* BRANDISH */
+ 0, /* THROW */
+ 0}; /* FUSE */
+
+ uint16 L1236_ui_Multiple;
+#define AL1236_ui_ChampionCell L1236_ui_Multiple
+#define AL1236_ui_ActionDamageFactor L1236_ui_Multiple
+ uint16 L1237_ui_Multiple;
+#define AL1237_ui_Direction L1237_ui_Multiple
+#define AL1237_ui_CellDelta L1237_ui_Multiple
+#define AL1237_ui_ActionHitProbability L1237_ui_Multiple
+ int16 L1238_i_CreatureOrdinal;
+
+
+ warning(false, "MISSING CODE: F0064_SOUND_RequestPlay_CPSD");
+ if (_g517_actionTargetGroupThing == Thing::_endOfList)
+ goto T0402010;
+ if (L1238_i_CreatureOrdinal = _vm->_groupMan->f177_getMeleeTargetCreatureOrdinal(targetMapX, targetMapY, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY, AL1236_ui_ChampionCell = champ->_cell)) {
+ switch (M21_normalizeModulo4(AL1236_ui_ChampionCell + 4 - champ->_dir)) {
+ case k2_ViewCellBackRight: /* Champion is on the back right of the square and tries to attack a creature in the front right of its square */
+ AL1237_ui_CellDelta = 3;
+ goto T0402005;
+ case k3_ViewCellBackLeft: /* Champion is on the back left of the square and tries to attack a creature in the front left of its square */
+ AL1237_ui_CellDelta = 1;
+T0402005: /* Check if there is another champion in front */
+ if (_vm->_championMan->f285_getIndexInCell(M21_normalizeModulo4(AL1236_ui_ChampionCell + AL1237_ui_CellDelta)) != kM1_ChampionNone) {
+ _vm->_menuMan->_g513_actionDamage = kM1_damageCantReach;
+ goto T0402010;
+ }
+ }
+ if ((actionIndex == k24_ChampionActionDisrupt) && !getFlag(_vm->_dungeonMan->f144_getCreatureAttributes(_g517_actionTargetGroupThing), k0x0040_MaskCreatureInfo_nonMaterial))
+ goto T0402010;
+ AL1237_ui_ActionHitProbability = G0493_auc_Graphic560_ActionHitProbability[actionIndex];
+ AL1236_ui_ActionDamageFactor = G0492_auc_Graphic560_ActionDamageFactor[actionIndex];
+ if ((_vm->_objectMan->f33_getIconIndex(champ->_slots[k1_ChampionSlotActionHand]) == k40_IconIndiceWeaponVorpalBlade) || (actionIndex == k24_ChampionActionDisrupt)) {
+ setFlag(AL1237_ui_ActionHitProbability, k0x8000_hitNonMaterialCreatures);
+ }
+ _vm->_menuMan->_g513_actionDamage = _vm->_groupMan->f231_getMeleeActionDamage(champ, champIndex, (Group*)_vm->_dungeonMan->f156_getThingData(_g517_actionTargetGroupThing), _vm->M1_ordinalToIndex(L1238_i_CreatureOrdinal), targetMapX, targetMapY, AL1237_ui_ActionHitProbability, AL1236_ui_ActionDamageFactor, skillIndex);
+ return true;
+ }
+T0402010:
+ return false;
+}
+
+bool MenuMan::f401_isGroupFrightenedByAction(int16 champIndex, uint16 actionIndex, int16 mapX, int16 mapY) {
+ int16 L1229_i_FrightAmount = 0;
+ uint16 L1230_ui_FearResistance;
+ uint16 L1231_ui_Experience = 0;
+ bool L1232_B_IsGroupFrightenedByAction;
+ Group* L1233_ps_Group;
+ CreatureInfo* L1234_ps_CreatureInfo;
+ ActiveGroup* L1235_ps_ActiveGroup;
+
+
+ L1232_B_IsGroupFrightenedByAction = false;
+ if (_g517_actionTargetGroupThing == Thing::_endOfList)
+ goto T0401016;
+ switch (actionIndex) {
+ case k8_ChampionActionWarCry:
+ L1229_i_FrightAmount = 3;
+ L1231_ui_Experience = 12; /* War Cry gives experience in priest skill k14_ChampionSkillInfluence below. The War Cry action also has an experience gain of 7 defined in G0497_auc_Graphic560_ActionExperienceGain in the same skill (versions 1.1 and below) or in the fighter skill k7_ChampionSkillParry (versions 1.2 and above). In versions 1.2 and above, this is the only action that gives experience in two skills */
+ break;
+ case k37_ChampionActionCalm:
+ L1229_i_FrightAmount = 7;
+ L1231_ui_Experience = 35;
+ break;
+ case k41_ChampionActionBrandish:
+ L1229_i_FrightAmount = 6;
+ L1231_ui_Experience = 30;
+ break;
+ case k4_ChampionActionBlowHorn:
+ L1229_i_FrightAmount = 6;
+ L1231_ui_Experience = 20;
+ break;
+ case k22_ChampionActionConfuse:
+ L1229_i_FrightAmount = 12;
+ L1231_ui_Experience = 45;
+ }
+ L1229_i_FrightAmount += _vm->_championMan->f303_getSkillLevel(champIndex, k14_ChampionSkillInfluence);
+ L1233_ps_Group = (Group*)_vm->_dungeonMan->f156_getThingData(_g517_actionTargetGroupThing);
+ L1234_ps_CreatureInfo = &g243_CreatureInfo[L1233_ps_Group->_type];
+ if (((L1230_ui_FearResistance = L1234_ps_CreatureInfo->M57_getFearResistance()) > _vm->getRandomNumber(L1229_i_FrightAmount)) || (L1230_ui_FearResistance == k15_immuneToFear)) {
+ L1231_ui_Experience >>= 1;
+ } else {
+ L1235_ps_ActiveGroup = &_vm->_groupMan->_g375_activeGroups[L1233_ps_Group->getActiveGroupIndex()];
+ if (L1233_ps_Group->getBehaviour() == k6_behavior_ATTACK) {
+ _vm->_groupMan->f182_stopAttacking(L1235_ps_ActiveGroup, mapX, mapY);
+ _vm->_groupMan->f180_startWanedring(mapX, mapY);
+ }
+ L1233_ps_Group->setBehaviour(k5_behavior_FLEE);
+ L1235_ps_ActiveGroup->_delayFleeingFromTarget = ((16 - L1230_ui_FearResistance) << 2) / L1234_ps_CreatureInfo->_movementTicks;
+ L1232_B_IsGroupFrightenedByAction = true;
+ }
+ _vm->_championMan->f304_addSkillExperience(champIndex, k14_ChampionSkillInfluence, L1231_ui_Experience);
+T0401016:
+ return L1232_B_IsGroupFrightenedByAction;
+}
+
+void MenuMan::f381_printMessageAfterReplacements(char* str) {
+ char* L1164_pc_Character;
+ char* L1165_pc_ReplacementString;
+ char L1166_ac_OutputString[128];
+
+
+ L1164_pc_Character = L1166_ac_OutputString;
+ *L1164_pc_Character++ = '\n'; /* New line */
+ do {
+ if (*str == '@') {
+ str++;
+ if (*(L1164_pc_Character - 1) != '\n') { /* New line */
+ *L1164_pc_Character++ = ' ';
+ }
+ switch (*str) {
+ case 'p': /* '@p' in the source string is replaced by the champion name followed by a space */
+ L1165_pc_ReplacementString = _vm->_championMan->_gK71_champions[_vm->M1_ordinalToIndex(_vm->_championMan->_g506_actingChampionOrdinal)]._name;
+ }
+ *L1164_pc_Character = '\0';
+ strcat(L1166_ac_OutputString, L1165_pc_ReplacementString);
+ L1164_pc_Character += strlen(L1165_pc_ReplacementString);
+ *L1164_pc_Character++ = ' ';
+ } else {
+ *L1164_pc_Character++ = *str;
+ }
+ } while (*str++);
+ *L1164_pc_Character = '\0';
+ if (L1166_ac_OutputString[1]) { /* If the string is not empty (the first character is a new line \n) */
+ _vm->_textMan->f47_messageAreaPrintMessage(k4_ColorCyan, L1166_ac_OutputString);
+ }
+}
+
+void MenuMan::f389_processCommands116To119_setActingChampion(uint16 champIndex) {
+ static ActionSet G0489_as_Graphic560_ActionSets[44] = {
+ /* { ActionIndices[0], ActionIndices[1], ActionIndices[2], ActionProperties[0], ActionProperties[1], Useless } */
+ ActionSet(255, 255, 255, 0x00, 0x00),
+ ActionSet(27, 43, 35, 0x00, 0x00),
+ ActionSet(6, 7, 8, 0x00, 0x00),
+ ActionSet(0, 0, 0, 0x00, 0x00),
+ ActionSet(0, 0, 0, 0x00, 0x00),
+ ActionSet(13, 255, 255, 0x00, 0x00),
+ ActionSet(13, 20, 255, 0x87, 0x00),
+ ActionSet(13, 23, 255, 0x83, 0x00),
+ ActionSet(28, 41, 22, 0x02, 0x83),
+ ActionSet(16, 2, 23, 0x00, 0x84),
+ ActionSet(2, 25, 20, 0x02, 0x86),
+ ActionSet(17, 41, 34, 0x03, 0x05),
+ ActionSet(42, 9, 28, 0x00, 0x02),
+ ActionSet(13, 17, 2, 0x02, 0x03),
+ ActionSet(16, 17, 15, 0x01, 0x05),
+ ActionSet(28, 17, 25, 0x01, 0x05),
+ ActionSet(2, 25, 15, 0x05, 0x06),
+ ActionSet(9, 2, 29, 0x02, 0x05),
+ ActionSet(16, 29, 24, 0x02, 0x04),
+ ActionSet(13, 15, 19, 0x05, 0x07),
+ ActionSet(13, 2, 25, 0x00, 0x05),
+ ActionSet(2, 29, 19, 0x03, 0x08),
+ ActionSet(13, 30, 31, 0x02, 0x04),
+ ActionSet(13, 31, 25, 0x03, 0x06),
+ ActionSet(42, 30, 255, 0x00, 0x00),
+ ActionSet(0, 0, 0, 0x00, 0x00),
+ ActionSet(42, 9, 255, 0x00, 0x00),
+ ActionSet(32, 255, 255, 0x00, 0x00),
+ ActionSet(37, 33, 36, 0x82, 0x03),
+ ActionSet(37, 33, 34, 0x83, 0x84),
+ ActionSet(17, 38, 21, 0x80, 0x83),
+ ActionSet(13, 21, 34, 0x83, 0x84),
+ ActionSet(36, 37, 41, 0x02, 0x03),
+ ActionSet(13, 23, 39, 0x82, 0x84),
+ ActionSet(13, 17, 40, 0x00, 0x83),
+ ActionSet(17, 36, 38, 0x03, 0x84),
+ ActionSet(4, 255, 255, 0x00, 0x00),
+ ActionSet(5, 255, 255, 0x00, 0x00),
+ ActionSet(11, 255, 255, 0x00, 0x00),
+ ActionSet(10, 255, 255, 0x00, 0x00),
+ ActionSet(42, 9, 255, 0x00, 0x00),
+ ActionSet(1, 12, 255, 0x02, 0x00),
+ ActionSet(42, 255, 255, 0x00, 0x00),
+ ActionSet(6, 11, 255, 0x80, 0x00)};
+ uint16 L1188_ui_ActionSetIndex;
+ Thing L1189_T_Thing;
+ Champion* L1190_ps_Champion;
+ ActionSet* L1191_ps_ActionSet;
+
+
+ L1190_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex];
+ if (getFlag(L1190_ps_Champion->_attributes, k0x0008_ChampionAttributeDisableAction) || !L1190_ps_Champion->_currHealth) {
+ return;
+ }
+ if ((L1189_T_Thing = L1190_ps_Champion->_slots[k1_ChampionSlotActionHand]) == Thing::_none) {
+ L1188_ui_ActionSetIndex = 2; /* Actions Punck, Kick and War Cry */
+ } else {
+ if ((L1188_ui_ActionSetIndex = g237_ObjectInfo[_vm->_dungeonMan->f141_getObjectInfoIndex(L1189_T_Thing)]._actionSetIndex) == 0) {
+ return;
+ }
+ }
+ L1191_ps_ActionSet = &G0489_as_Graphic560_ActionSets[L1188_ui_ActionSetIndex];
+ _vm->_championMan->_g506_actingChampionOrdinal = _vm->M0_indexToOrdinal(champIndex);
+ f383_setActionList(L1191_ps_ActionSet);
+ _vm->_menuMan->_g509_actionAreaContainsIcons = false;
+ setFlag(L1190_ps_Champion->_attributes, k0x8000_ChampionAttributeActionHand);
+ _vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
+ _vm->_menuMan->f387_drawActionArea();
+ _vm->_menuMan->f387_drawActionArea();
+}
+
+void MenuMan::f383_setActionList(ActionSet* actionSet) {
+
+#define k0x0080_actionRequiresCharge 0x0080 // @ MASK0x0080_ACTION_REQUIRES_CHARGE
+
+ uint16 L1169_ui_ActionListIndex;
+ uint16 L1170_ui_NextAvailableActionListIndex;
+ uint16 L1171_ui_ActionIndex;
+ uint16 L1172_ui_MinimumSkillLevel;
+
+ _vm->_menuMan->_g713_actionList._actionIndices[0] = (ChampionAction)actionSet->_actionIndices[0];
+ _vm->_menuMan->_g713_actionList._minimumSkillLevel[0] = 1;
+ L1170_ui_NextAvailableActionListIndex = 1;
+ for (L1169_ui_ActionListIndex = 1; L1169_ui_ActionListIndex < 3; L1169_ui_ActionListIndex++) {
+ if ((L1171_ui_ActionIndex = actionSet->_actionIndices[L1169_ui_ActionListIndex]) == k255_ChampionActionNone)
+ continue;
+ if (getFlag(L1172_ui_MinimumSkillLevel = actionSet->_actionProperties[L1169_ui_ActionListIndex - 1], k0x0080_actionRequiresCharge) && !f382_getActionObjectChargeCount())
+ continue;
+ clearFlag(L1172_ui_MinimumSkillLevel, k0x0080_actionRequiresCharge);
+ if (_vm->_championMan->f303_getSkillLevel(_vm->M1_ordinalToIndex(_vm->_championMan->_g506_actingChampionOrdinal), g496_ActionSkillIndex[L1171_ui_ActionIndex]) >= L1172_ui_MinimumSkillLevel) {
+ _vm->_menuMan->_g713_actionList._actionIndices[L1170_ui_NextAvailableActionListIndex] = (ChampionAction)L1171_ui_ActionIndex;
+ _vm->_menuMan->_g713_actionList._minimumSkillLevel[L1170_ui_NextAvailableActionListIndex] = L1172_ui_MinimumSkillLevel;
+ L1170_ui_NextAvailableActionListIndex++;
+ }
+ }
+ _g507_actionCount = L1170_ui_NextAvailableActionListIndex;
+ for (L1169_ui_ActionListIndex = L1170_ui_NextAvailableActionListIndex; L1169_ui_ActionListIndex < 3; L1169_ui_ActionListIndex++) {
+ _vm->_menuMan->_g713_actionList._actionIndices[L1169_ui_ActionListIndex] = k255_ChampionActionNone;
+ }
+}
+
+int16 MenuMan::f382_getActionObjectChargeCount() {
+ Thing L1167_T_Thing;
+ Junk* L1168_ps_Junk;
+
+
+ L1168_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L1167_T_Thing = _vm->_championMan->_gK71_champions[_vm->M1_ordinalToIndex(_vm->_championMan->_g506_actingChampionOrdinal)]._slots[k1_ChampionSlotActionHand]);
+ switch (L1167_T_Thing.getType()) {
+ case k5_WeaponThingType:
+ return ((Weapon*)L1168_ps_Junk)->getChargeCount();
+ case k6_ArmourThingType:
+ return ((Armour*)L1168_ps_Junk)->getChargeCount();
+ case k10_JunkThingType:
+ return L1168_ps_Junk->getChargeCount();
+ default:
+ return 1;
+ }
+}
}
diff --git a/engines/dm/menus.h b/engines/dm/menus.h
index 0aabcab3f0..f0a1c2bf58 100644
--- a/engines/dm/menus.h
+++ b/engines/dm/menus.h
@@ -34,6 +34,11 @@
namespace DM {
+#define kM1_damageCantReach -1 // @ CM1_DAMAGE_CANT_REACH
+#define kM2_damageNoAmmunition -2 // @ CM2_DAMAGE_NO_AMMUNITION
+
+#define k0x8000_hitNonMaterialCreatures 0x8000 // @ MASK0x8000_HIT_NON_MATERIAL_CREATURES
+
extern Box g1_BoxActionArea; // @ G0001_s_Graphic562_Box_ActionArea
extern Box g0_BoxSpellArea; // @ G0000_s_Graphic562_Box_SpellArea
@@ -50,6 +55,19 @@ public:
}
}; // @ ACTION_LIST
+class ActionSet {
+public:
+ byte _actionIndices[3]; /* 1 byte of padding inserted by compiler on Atari ST, not on Amiga */
+ byte _actionProperties[2]; /* Bit 7: requires charge, Bit 6-0: minimum skill level */
+ ActionSet(byte a1, byte a2, byte a3, byte b1, byte b2) {
+ _actionIndices[0] = a1;
+ _actionIndices[1] = a2;
+ _actionIndices[2] = a3;
+ _actionProperties[0] = b1;
+ _actionProperties[1] = b2;
+ }
+}; // @ ACTION_SET
+
class MenuMan {
DMEngine *_vm;
public:
@@ -61,6 +79,8 @@ public:
int16 _g513_actionDamage; // @ G0513_i_ActionDamage
ActionList _g713_actionList; // @ G0713_s_ActionList
byte *_gK72_bitmapSpellAreaLine; // @ K0072_puc_Bitmap_SpellAreaLine
+ Thing _g517_actionTargetGroupThing; // @ G0517_T_ActionTargetGroupThing
+ uint16 _g507_actionCount; // @ G0507_ui_ActionCount
void f388_clearActingChampion(); // @ F0388_MENUS_ClearActingChampion
void f386_drawActionIcon(ChampionIndex championIndex); // @ F0386_MENUS_DrawActionIcon
@@ -85,6 +105,17 @@ public:
void f398_drawChampionSymbols(Champion *champ); // @ F0398_MENUS_DrawChampionSymbols
void f399_addChampionSymbol(int16 symbolIndex); // @ F0399_MENUS_AddChampionSymbol
void f400_deleteChampionSymbol(); // @ F0400_MENUS_DeleteChampionSymbol
+ bool f391_didClickTriggerAction(int16 actionListIndex); // @ F0391_MENUS_DidClickTriggerAction
+ bool f407_isActionPerformed(uint16 champIndex, int16 actionIndex); // @ F0407_MENUS_IsActionPerformed
+ void f406_setChampionDirectionToPartyDirection(Champion *champ); // @ F0406_MENUS_SetChampionDirectionToPartyDirection
+ void f405_decrementCharges(Champion *champ); // @ F0405_MENUS_DecrementCharges
+ bool f402_isMeleeActionPerformed(int16 champIndex, Champion *champ, int16 actionIndex, int16 targetMapX,
+ int16 targetMapY, int16 skillIndex); // @ F0402_MENUS_IsMeleeActionPerformed
+ bool f401_isGroupFrightenedByAction(int16 champIndex, uint16 actionIndex, int16 mapX, int16 mapY); // @ F0401_MENUS_IsGroupFrightenedByAction
+ void f381_printMessageAfterReplacements(char *str); // @ F0381_MENUS_PrintMessageAfterReplacements
+ void f389_processCommands116To119_setActingChampion(uint16 champIndex); // @ F0389_MENUS_ProcessCommands116To119_SetActingChampion
+ void f383_setActionList(ActionSet *actionSet); // @ F0383_MENUS_SetActionList
+ int16 f382_getActionObjectChargeCount(); // @ F0382_MENUS_GetActionObjectChargeCount
};
}
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 6cb159a205..34e83ca262 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -963,7 +963,7 @@ void MovesensMan::f272_sensorTriggerEffect(Sensor* sensor, int16 effect, int16 m
int16 L0736_i_TargetMapX;
int16 L0737_i_TargetMapY;
- register long L0738_l_Time;
+ int32 L0738_l_Time;
uint16 L0739_ui_SquareType;
uint16 L0740_ui_TargetCell;
diff --git a/engines/dm/timeline.h b/engines/dm/timeline.h
index 49a7ca4477..08c6ce1c5f 100644
--- a/engines/dm/timeline.h
+++ b/engines/dm/timeline.h
@@ -95,7 +95,7 @@ k82_TMEventTypeMagicMap_C82 = 82, // @ C82_EVENT_MAGIC_MAP
k83_TMEventTypeMagicMap_C83 = 83 // @ C83_EVENT_MAGIC_MAP
};
-extern signed char g495_actionDefense[44];
+extern signed char g495_actionDefense[44]; // @ G0495_ac_Graphic560_ActionDefense
class TimelineEvent {
public: