aboutsummaryrefslogtreecommitdiff
path: root/engines/dm
diff options
context:
space:
mode:
authorBendegúz Nagy2016-09-05 19:05:02 +0200
committerBendegúz Nagy2016-09-05 19:05:02 +0200
commit4befd3a23214953632d1cdc5ba32d2bd1bb7293d (patch)
treec164877888bf1b68c32cbf3cde87444148d9fe12 /engines/dm
parent3191f2605bbb28704a88ecbf9faa72b62bcb12e7 (diff)
parent4663d190c4112279cfbb321d7edebd78dafcb161 (diff)
downloadscummvm-rg350-4befd3a23214953632d1cdc5ba32d2bd1bb7293d.tar.gz
scummvm-rg350-4befd3a23214953632d1cdc5ba32d2bd1bb7293d.tar.bz2
scummvm-rg350-4befd3a23214953632d1cdc5ba32d2bd1bb7293d.zip
Merge branch 'dm' of github.com:WinterGrascph/scummvm into dm
Diffstat (limited to 'engines/dm')
-rw-r--r--engines/dm/champion.cpp43
-rw-r--r--engines/dm/eventman.cpp26
-rw-r--r--engines/dm/gfx.cpp73
-rw-r--r--engines/dm/gfx.h5
-rw-r--r--engines/dm/group.cpp8
-rw-r--r--engines/dm/inventory.cpp235
-rw-r--r--engines/dm/loadsave.cpp43
-rw-r--r--engines/dm/lzw.cpp27
-rw-r--r--engines/dm/lzw.h2
-rw-r--r--engines/dm/menus.cpp1578
-rw-r--r--engines/dm/menus.h6
-rw-r--r--engines/dm/movesens.cpp1465
-rw-r--r--engines/dm/movesens.h2
13 files changed, 1704 insertions, 1809 deletions
diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp
index 7d696a3fe3..6385547433 100644
--- a/engines/dm/champion.cpp
+++ b/engines/dm/champion.cpp
@@ -1495,19 +1495,19 @@ void ChampionMan::championKill(uint16 champIndex) {
_vm->_displayMan->fillScreenBox(_boxChampionIcons[curChampionIconIndex], k0_ColorBlack);
drawChampionState((ChampionIndex)champIndex);
- int16 aliveChampionIndex;
- for (aliveChampionIndex = k0_ChampionFirst, curChampion = _champions; aliveChampionIndex < _partyChampionCount; aliveChampionIndex++, curChampion++) {
- if (curChampion->_currHealth)
- break;
- }
+ ChampionIndex aliveChampionIndex;
+ int idx = 0;
+ for (curChampion = _champions; (idx < _partyChampionCount) && (curChampion->_currHealth == 0); idx++, curChampion++)
+ ;
+ aliveChampionIndex = (ChampionIndex)idx;
if (aliveChampionIndex == _partyChampionCount) { /* BUG0_43 The game does not end if the last living champion in the party is killed while looking at a candidate champion in a portrait. The condition to end the game when the whole party is killed is not true because the code considers the candidate champion as alive (in the loop above) */
_partyDead = true;
return;
}
if (champIndex == _leaderIndex)
- _vm->_eventMan->commandSetLeader((ChampionIndex)aliveChampionIndex);
+ _vm->_eventMan->commandSetLeader(aliveChampionIndex);
if (champIndex == _magicCasterChampionIndex)
_vm->_menuMan->setMagicCasterAndDrawSpellArea(aliveChampionIndex);
@@ -1829,28 +1829,31 @@ ChampionIndex ChampionMan::getIndexInCell(int16 cell) {
void ChampionMan::resetDataToStartGame() {
if (!_vm->_newGameFl) {
- Thing L0787_T_Thing;
- if ((L0787_T_Thing = _leaderHandObject) == Thing::_none) {
+ Thing handThing = _leaderHandObject;
+ if (handThing == Thing::_none) {
_leaderEmptyHanded = true;
_leaderHandObjectIconIndex = kM1_IconIndiceNone;
_vm->_eventMan->setMousePointer();
- } else {
- putObjectInLeaderHand(L0787_T_Thing, true); /* This call will add the weight of the leader hand object to the Load of the leader a first time */
- }
- Champion *L0788_ps_Champion = _champions;
- int16 L0785_i_ChampionIndex;
- for (L0785_i_ChampionIndex = k0_ChampionFirst; L0785_i_ChampionIndex < _partyChampionCount; L0785_i_ChampionIndex++, L0788_ps_Champion++) {
- clearFlag(L0788_ps_Champion->_attributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand);
- setFlag(L0788_ps_Champion->_attributes, k0x8000_ChampionAttributeActionHand | k0x1000_ChampionAttributeStatusBox | k0x0400_ChampionAttributeIcon);
+ } else
+ putObjectInLeaderHand(handThing, true); /* This call will add the weight of the leader hand object to the Load of the leader a first time */
+
+ Champion *curChampion = _champions;
+ for (int16 idx = 0; idx < _partyChampionCount; idx++, curChampion++) {
+ clearFlag(curChampion->_attributes, k0x0080_ChampionAttributeNameTitle | k0x0100_ChampionAttributeStatistics | k0x0200_ChampionAttributeLoad | k0x0400_ChampionAttributeIcon | k0x0800_ChampionAttributePanel | k0x1000_ChampionAttributeStatusBox | k0x2000_ChampionAttributeWounds | k0x4000_ChampionAttributeViewport | k0x8000_ChampionAttributeActionHand);
+ setFlag(curChampion->_attributes, k0x8000_ChampionAttributeActionHand | k0x1000_ChampionAttributeStatusBox | k0x0400_ChampionAttributeIcon);
}
drawAllChampionStates();
- if ((L0785_i_ChampionIndex = _leaderIndex) != kM1_ChampionNone) {
+
+ ChampionIndex championIndex = _leaderIndex;
+ if (championIndex != kM1_ChampionNone) {
_leaderIndex = kM1_ChampionNone;
- _vm->_eventMan->commandSetLeader((ChampionIndex)L0785_i_ChampionIndex);
+ _vm->_eventMan->commandSetLeader(championIndex);
}
- if ((L0785_i_ChampionIndex = _magicCasterChampionIndex) != kM1_ChampionNone) {
+
+ championIndex = _magicCasterChampionIndex;
+ if (championIndex != kM1_ChampionNone) {
_magicCasterChampionIndex = kM1_ChampionNone;
- _vm->_menuMan->setMagicCasterAndDrawSpellArea(L0785_i_ChampionIndex);
+ _vm->_menuMan->setMagicCasterAndDrawSpellArea(championIndex);
}
return;
}
diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp
index 4ccd9bab0f..76a54976dc 100644
--- a/engines/dm/eventman.cpp
+++ b/engines/dm/eventman.cpp
@@ -1497,43 +1497,43 @@ void EventManager::mouseProcessCommands125To128_clickOnChampionIcon(uint16 champ
}
void EventManager::commandProcessType100_clickInSpellArea(uint16 posX, uint16 posY) {
- int16 championIndex = kM1_ChampionNone;
+ ChampionIndex championIndex = kM1_ChampionNone;
if (posY <= 48) {
switch (_vm->_championMan->_magicCasterChampionIndex) {
case 0:
if ((posX >= 280) && (posX <= 291))
- championIndex = 1;
+ championIndex = k1_ChampionSecond;
else if ((posX >= 294) && (posX <= 305))
- championIndex = 2;
+ championIndex = k2_ChampionThird;
else if (posX >= 308)
- championIndex = 3;
+ championIndex = k3_ChampionFourth;
break;
case 1:
if ((posX >= 233) && (posX <= 244))
- championIndex = 0;
+ championIndex = k0_ChampionFirst;
else if ((posX >= 294) && (posX <= 305))
- championIndex = 2;
+ championIndex = k2_ChampionThird;
else if (posX >= 308)
- championIndex = 3;
+ championIndex = k3_ChampionFourth;
break;
case 2:
if ((posX >= 233) && (posX <= 244))
- championIndex = 0;
+ championIndex = k0_ChampionFirst;
else if ((posX >= 247) && (posX <= 258))
- championIndex = 1;
+ championIndex = k1_ChampionSecond;
else if (posX >= 308)
- championIndex = 3;
+ championIndex = k3_ChampionFourth;
break;
case 3:
if ((posX >= 247) && (posX <= 258))
- championIndex = 1;
+ championIndex = k1_ChampionSecond;
else if ((posX >= 261) && (posX <= 272))
- championIndex = 2;
+ championIndex = k2_ChampionThird;
else if (posX <= 244)
- championIndex = 0;
+ championIndex = k0_ChampionFirst;
break;
default:
break;
diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp
index 00bf044893..25f60d4fba 100644
--- a/engines/dm/gfx.cpp
+++ b/engines/dm/gfx.cpp
@@ -834,7 +834,7 @@ void DisplayMan::loadIntoBitmap(uint16 index, byte *destBitmap) {
}
}
-void DisplayMan::blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, uint16 srcX, uint16 srcY, uint16 srcByteWidth,
+void DisplayMan::blitToBitmap(byte *srcBitmap, byte *destBitmap, const Box &box, uint16 srcX, uint16 srcY, uint16 srcByteWidth,
uint16 destByteWidth, Color transparent, int16 srcHeight, int16 destHight) {
uint16 srcWidth = srcByteWidth * 2;
uint16 destWidth = destByteWidth * 2;
@@ -1177,12 +1177,7 @@ void DisplayMan::blitToViewport(byte *bitmap, int16 *box, int16 byteWidth, Color
blitToViewport(bitmap, actualBox, byteWidth, transparent, height);
}
-void DisplayMan::blitToScreen(byte *bitmap, int16 *box, int16 byteWidth, Color transparent, int16 height) {
- Box actualBox(box[0], box[1], box[2], box[3]);
- blitToScreen(bitmap, &actualBox, byteWidth, transparent, height);
-}
-
-void DisplayMan::blitToScreen(byte *bitmap, Box *box, int16 byteWidth, Color transparent, int16 height) {
+void DisplayMan::blitToScreen(byte *bitmap, const Box *box, int16 byteWidth, Color transparent, int16 height) {
_useByteBoxCoordinates = false;
blitToBitmap(bitmap, _bitmapScreen, *box, 0, 0, byteWidth, k160_byteWidthScreen, transparent, height, k200_heightScreen);
}
@@ -2628,7 +2623,7 @@ bool DisplayMan::isDrawnWallOrnAnAlcove(int16 wallOrnOrd, ViewWall viewWallIndex
unsigned char inscriptionString[70];
bool isInscription = (wallOrnamentIndex == _vm->_dungeonMan->_currMapInscriptionWallOrnIndex);
if (isInscription)
- _vm->_dungeonMan->decodeText((char*)inscriptionString, _inscriptionThing, k0_TextTypeInscription);
+ _vm->_dungeonMan->decodeText((char *)inscriptionString, _inscriptionThing, k0_TextTypeInscription);
int16 blitPosX;
byte *ornBlitBitmap;
@@ -3234,14 +3229,14 @@ T0115015_DrawProjectileAsObject:
ActiveGroup *activeGroup;
if (group == nullptr) { /* If all creature data and info has not already been gathered */
- group = (Group*)_vm->_dungeonMan->getThingData(groupThing);
+ group = (Group *)_vm->_dungeonMan->getThingData(groupThing);
activeGroup = &_vm->_groupMan->_activeGroups[group->getActiveGroupIndex()];
CreatureInfo *creatureInfo = &_vm->_dungeonMan->_creatureInfos[group->_type];
creatureAspectStruct = &_creatureAspects219[creatureInfo->_creatureAspectIndex];
creatureSize = getFlag(creatureInfo->_attributes, k0x0003_MaskCreatureInfo_size);
creatureGraphicInfoGreen = creatureInfo->_graphicInfo;
}
- objectAspect = (ObjectAspect*)creatureAspectStruct;
+ objectAspect = (ObjectAspect *)creatureAspectStruct;
AL_0_creatureIndexRed = _vm->_groupMan->getCreatureOrdinalInCell(group, cellYellowBear);
if (AL_0_creatureIndexRed) { /* If there is a creature on the cell being processed */
@@ -3297,12 +3292,12 @@ T0115015_DrawProjectileAsObject:
viewSquareIndex--;
T0115077_DrawSecondHalfSquareCreature:
- coordinateSet = creatureCoordinateSets[((CreatureAspect*)objectAspect)->getCoordSet()][viewSquareIndex][AL_2_viewCell];
+ coordinateSet = creatureCoordinateSets[((CreatureAspect *)objectAspect)->getCoordSet()][viewSquareIndex][AL_2_viewCell];
if (!coordinateSet[1])
goto T0115126_CreatureNotVisible;
AL_0_creatureGraphicInfoRed = creatureGraphicInfoGreen;
- AL_4_nativeBitmapIndex = k446_FirstCreatureGraphicIndice + ((CreatureAspect*)objectAspect)->_firstNativeBitmapRelativeIndex; /* By default, assume using the front image */
- derivedBitmapIndex = ((CreatureAspect*)objectAspect)->_firstDerivedBitmapIndex;
+ AL_4_nativeBitmapIndex = k446_FirstCreatureGraphicIndice + ((CreatureAspect *)objectAspect)->_firstNativeBitmapRelativeIndex; /* By default, assume using the front image */
+ derivedBitmapIndex = ((CreatureAspect *)objectAspect)->_firstDerivedBitmapIndex;
int16 sourceByteWidth;
int16 sourceHeight;
useCreatureSideBitmap = getFlag(AL_0_creatureGraphicInfoRed, k0x0008_CreatureInfoGraphicMaskSide) && (creatureDirectionDelta & 0x0001);
@@ -3310,15 +3305,15 @@ T0115077_DrawSecondHalfSquareCreature:
useCreatureAttackBitmap = useFlippedHorizontallyCreatureFrontImage = useCreatureBackBitmap = false;
AL_4_nativeBitmapIndex++; /* Skip the front image. Side image is right after the front image */
derivedBitmapIndex += 2;
- sourceByteWidth = byteWidth = ((CreatureAspect*)objectAspect)->_byteWidthSide;
- sourceHeight = heightRedEagle = ((CreatureAspect*)objectAspect)->_heightSide;
+ sourceByteWidth = byteWidth = ((CreatureAspect *)objectAspect)->_byteWidthSide;
+ sourceHeight = heightRedEagle = ((CreatureAspect *)objectAspect)->_heightSide;
} else {
useCreatureBackBitmap = getFlag(AL_0_creatureGraphicInfoRed, k0x0010_CreatureInfoGraphicMaskBack) && (creatureDirectionDelta == 0);
useCreatureAttackBitmap = !useCreatureBackBitmap && getFlag(creatureAspectInt, k0x0080_MaskActiveGroupIsAttacking) && getFlag(AL_0_creatureGraphicInfoRed, k0x0020_CreatureInfoGraphicMaskAttack);
if (useCreatureAttackBitmap) {
useFlippedHorizontallyCreatureFrontImage = false;
- sourceByteWidth = byteWidth = ((CreatureAspect*)objectAspect)->_byteWidthAttack;
- sourceHeight = heightRedEagle = ((CreatureAspect*)objectAspect)->_heightAttack;
+ sourceByteWidth = byteWidth = ((CreatureAspect *)objectAspect)->_byteWidthAttack;
+ sourceHeight = heightRedEagle = ((CreatureAspect *)objectAspect)->_heightAttack;
AL_4_nativeBitmapIndex++; /* Skip the front image */
derivedBitmapIndex += 2;
if (getFlag(AL_0_creatureGraphicInfoRed, k0x0008_CreatureInfoGraphicMaskSide)) {
@@ -3331,8 +3326,8 @@ T0115077_DrawSecondHalfSquareCreature:
derivedBitmapIndex += 2;
}
} else {
- sourceByteWidth = byteWidth = ((CreatureAspect*)objectAspect)->_byteWidthFront;
- sourceHeight = heightRedEagle = ((CreatureAspect*)objectAspect)->_heightFront;
+ sourceByteWidth = byteWidth = ((CreatureAspect *)objectAspect)->_byteWidthFront;
+ sourceHeight = heightRedEagle = ((CreatureAspect *)objectAspect)->_heightFront;
if (useCreatureBackBitmap) {
useFlippedHorizontallyCreatureFrontImage = false;
if (getFlag(AL_0_creatureGraphicInfoRed, k0x0008_CreatureInfoGraphicMaskSide)) {
@@ -3363,7 +3358,7 @@ T0115077_DrawSecondHalfSquareCreature:
if (viewSquareIndex >= k6_ViewSquare_D1C) { /* Creature is on D1 */
creaturePaddingPixelCount = 0;
AL_8_shiftSetIndex = k0_ShiftSet_D0BackD1Front;
- transparentColor = ((CreatureAspect*)objectAspect)->getTranspColour();
+ transparentColor = ((CreatureAspect *)objectAspect)->getTranspColour();
if (useCreatureSideBitmap) {
bitmapRedBanana = getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
if (creatureDirectionDelta == 1) {
@@ -3405,7 +3400,7 @@ T0115077_DrawSecondHalfSquareCreature:
byteWidth = getScaledDimension(sourceByteWidth, scale);
heightRedEagle = getScaledDimension(sourceHeight, scale);
- transparentColor = paletteChanges[((CreatureAspect*)objectAspect)->getTranspColour()] / 10;
+ transparentColor = paletteChanges[((CreatureAspect *)objectAspect)->getTranspColour()] / 10;
bool derivedBitmapInCache = isDerivedBitmapInCache(derivedBitmapIndex);
if (derivedBitmapInCache)
@@ -3484,25 +3479,25 @@ T0115129_DrawProjectiles:
thingParam = firstThingToDraw; /* Restart processing list of objects from the beginning. The next loop draws only projectile objects among the list */
do {
if ((thingParam.getType() == k14_ProjectileThingType) && (thingParam.getCell() == cellYellowBear)) {
- Projectile *projectile = (Projectile*)_vm->_dungeonMan->getThingData(thingParam);
+ Projectile *projectile = (Projectile *)_vm->_dungeonMan->getThingData(thingParam);
if ((AL_4_projectileAspect = _vm->_dungeonMan->getProjectileAspect(projectile->_slot)) < 0) { /* Negative value: projectile aspect is the ordinal of a PROJECTIL_ASPECT */
- objectAspect = (ObjectAspect*)&_projectileAspect[_vm->ordinalToIndex(-AL_4_projectileAspect)];
- AL_4_nativeBitmapIndex = ((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + k316_FirstProjectileGraphicIndice;
- projectileAspectType = getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0003_ProjectileAspectTypeMask);
+ objectAspect = (ObjectAspect *)&_projectileAspect[_vm->ordinalToIndex(-AL_4_projectileAspect)];
+ AL_4_nativeBitmapIndex = ((ProjectileAspect *)objectAspect)->_firstNativeBitmapRelativeIndex + k316_FirstProjectileGraphicIndice;
+ projectileAspectType = getFlag(((ProjectileAspect *)objectAspect)->_graphicInfo, k0x0003_ProjectileAspectTypeMask);
- bool doNotScaleWithKineticEnergy = !getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0100_ProjectileScaleWithKineticEnergyMask);
+ bool doNotScaleWithKineticEnergy = !getFlag(((ProjectileAspect *)objectAspect)->_graphicInfo, k0x0100_ProjectileScaleWithKineticEnergyMask);
if ((doNotScaleWithKineticEnergy || (projectile->_kineticEnergy == 255)) && (viewSquareIndex == k9_ViewSquare_D0C)) {
scale = 0; /* Use native bitmap without resizing */
- byteWidth = ((ProjectileAspect*)objectAspect)->_byteWidth;
- heightRedEagle = ((ProjectileAspect*)objectAspect)->_height;
+ byteWidth = ((ProjectileAspect *)objectAspect)->_byteWidth;
+ heightRedEagle = ((ProjectileAspect *)objectAspect)->_height;
} else {
AL_8_projectileScaleIndex = ((viewSquareIndex / 3) << 1) + (AL_2_viewCell >> 1);
scale = _projectileScales[AL_8_projectileScaleIndex];
if (!doNotScaleWithKineticEnergy) {
scale = (scale * MAX(96, projectile->_kineticEnergy + 1)) >> 8;
}
- byteWidth = getScaledDimension(((ProjectileAspect*)objectAspect)->_byteWidth, scale);
- heightRedEagle = getScaledDimension(((ProjectileAspect*)objectAspect)->_height, scale);
+ byteWidth = getScaledDimension(((ProjectileAspect *)objectAspect)->_byteWidth, scale);
+ heightRedEagle = getScaledDimension(((ProjectileAspect *)objectAspect)->_height, scale);
}
bool projectileAspectTypeHasBackGraphicAndRotation = (projectileAspectType == k0_ProjectileAspectHasBackGraphicRotation);
if (projectileAspectTypeHasBackGraphicAndRotation)
@@ -3533,7 +3528,7 @@ T0115129_DrawProjectiles:
projectileBitmapIndexDelta = 1;
flipVertical = projectileAspectTypeHasBackGraphicAndRotation && (AL_2_viewCell < k2_ViewCellBackRight);
- flipHorizontal = getFlag(((ProjectileAspect*)objectAspect)->_graphicInfo, k0x0010_ProjectileSideMask) && !((viewLane == k2_ViewLaneRight) || (!viewLane && ((AL_2_viewCell == k1_ViewCellFrontRight) || (AL_2_viewCell == k2_ViewCellBackRight))));
+ flipHorizontal = getFlag(((ProjectileAspect *)objectAspect)->_graphicInfo, k0x0010_ProjectileSideMask) && !((viewLane == k2_ViewLaneRight) || (!viewLane && ((AL_2_viewCell == k1_ViewCellFrontRight) || (AL_2_viewCell == k2_ViewCellBackRight))));
}
AL_4_nativeBitmapIndex += projectileBitmapIndexDelta;
@@ -3544,7 +3539,7 @@ T0115129_DrawProjectiles:
if (flipHorizontal)
paddingPixelCount = (7 - ((byteWidth - 1) & 0x0007)) << 1;
- if (doNotScaleWithKineticEnergy && isDerivedBitmapInCache(derivedBitmapIndex = k282_DerivedBitmapFirstProjectile + ((ProjectileAspect*)objectAspect)->_firstDerivedBitmapRelativeIndex + (projectileBitmapIndexDelta * 6) + AL_8_projectileScaleIndex)) {
+ if (doNotScaleWithKineticEnergy && isDerivedBitmapInCache(derivedBitmapIndex = k282_DerivedBitmapFirstProjectile + ((ProjectileAspect *)objectAspect)->_firstDerivedBitmapRelativeIndex + (projectileBitmapIndexDelta * 6) + AL_8_projectileScaleIndex)) {
bitmapRedBanana = getDerivedBitmap(derivedBitmapIndex);
} else {
bitmapGreenAnt = getNativeBitmapOrGraphic(AL_4_nativeBitmapIndex);
@@ -3553,7 +3548,7 @@ T0115129_DrawProjectiles:
else
bitmapRedBanana = _tmpBitmap;
- blitToBitmapShrinkWithPalChange(bitmapGreenAnt, bitmapRedBanana, ((ProjectileAspect*)objectAspect)->_byteWidth << 1, ((ProjectileAspect*)objectAspect)->_height, byteWidth << 1, heightRedEagle, _palChangesProjectile[AL_8_projectileScaleIndex >> 1]);
+ blitToBitmapShrinkWithPalChange(bitmapGreenAnt, bitmapRedBanana, ((ProjectileAspect *)objectAspect)->_byteWidth << 1, ((ProjectileAspect *)objectAspect)->_height, byteWidth << 1, heightRedEagle, _palChangesProjectile[AL_8_projectileScaleIndex >> 1]);
if (doNotScaleWithKineticEnergy) {
addDerivedBitmap(derivedBitmapIndex);
}
@@ -3613,7 +3608,7 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
do {
if (thingParam.getType() == k15_ExplosionThingType) {
AL_2_cellPurpleMan = thingParam.getCell();
- Explosion *explosion = (Explosion*)_vm->_dungeonMan->getThingData(thingParam);
+ Explosion *explosion = (Explosion *)_vm->_dungeonMan->getThingData(thingParam);
bool rebirthExplosion = ((uint16)(AL_4_explosionType = explosion->getType()) >= k100_ExplosionType_RebirthStep1);
if (rebirthExplosion && ((AL_1_viewSquareExplosionIndex < k3_ViewSquare_D3C_Explosion) || (AL_1_viewSquareExplosionIndex > k9_ViewSquare_D1C_Explosion) || (AL_2_cellPurpleMan != cellYellowBear))) /* If explosion is rebirth and is not visible */
continue;
@@ -3629,13 +3624,13 @@ T0115171_BackFromT0115015_DrawProjectileAsObject:;
AL_4_explosionAspectIndex = k3_ExplosionAspectSmoke;
} else {
if (AL_4_explosionType == k100_ExplosionType_RebirthStep1) {
- objectAspect = (ObjectAspect*)&_projectileAspect[_vm->ordinalToIndex(-_vm->_dungeonMan->getProjectileAspect(Thing::_explLightningBolt))];
- bitmapRedBanana = getNativeBitmapOrGraphic(((ProjectileAspect*)objectAspect)->_firstNativeBitmapRelativeIndex + (k316_FirstProjectileGraphicIndice + 1));
+ objectAspect = (ObjectAspect *)&_projectileAspect[_vm->ordinalToIndex(-_vm->_dungeonMan->getProjectileAspect(Thing::_explLightningBolt))];
+ bitmapRedBanana = getNativeBitmapOrGraphic(((ProjectileAspect *)objectAspect)->_firstNativeBitmapRelativeIndex + (k316_FirstProjectileGraphicIndice + 1));
explosionCoordinates = rebirthStep1ExplosionCoordinates[AL_1_viewSquareExplosionIndex - 3];
- byteWidth = getScaledDimension((((ProjectileAspect*)objectAspect)->_byteWidth), explosionCoordinates[2]);
- heightRedEagle = getScaledDimension((((ProjectileAspect*)objectAspect)->_height), explosionCoordinates[2]);
+ byteWidth = getScaledDimension((((ProjectileAspect *)objectAspect)->_byteWidth), explosionCoordinates[2]);
+ heightRedEagle = getScaledDimension((((ProjectileAspect *)objectAspect)->_height), explosionCoordinates[2]);
if (AL_1_viewSquareExplosionIndex != k9_ViewSquare_D1C_Explosion) {
- blitToBitmapShrinkWithPalChange(bitmapRedBanana, _tmpBitmap, ((ProjectileAspect*)objectAspect)->_byteWidth << 1, ((ProjectileAspect*)objectAspect)->_height, byteWidth << 1, heightRedEagle, _palChangesNoChanges);
+ blitToBitmapShrinkWithPalChange(bitmapRedBanana, _tmpBitmap, ((ProjectileAspect *)objectAspect)->_byteWidth << 1, ((ProjectileAspect *)objectAspect)->_height, byteWidth << 1, heightRedEagle, _palChangesNoChanges);
bitmapRedBanana = _tmpBitmap;
}
goto T0115200_DrawExplosion;
diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h
index 1d1f8c4338..76f08e8859 100644
--- a/engines/dm/gfx.h
+++ b/engines/dm/gfx.h
@@ -727,15 +727,14 @@ public:
void blitToViewport(byte *bitmap, Box &box, int16 byteWidth, Color transparent, int16 height); // @ F0020_MAIN_BlitToViewport
void blitToViewport(byte *bitmap, int16 *box, int16 byteWidth, Color transparent, int16 height); // @ F0020_MAIN_BlitToViewport
- void blitToScreen(byte *bitmap, int16 *box, int16 byteWidth, Color transparent, int16 height); // @ F0021_MAIN_BlitToScreen
- void blitToScreen(byte *bitmap, Box *box, int16 byteWidth, Color transparent, int16 height); // @ F0021_MAIN_BlitToScreen
+ void blitToScreen(byte *bitmap, const Box *box, int16 byteWidth, Color transparent, int16 height); // @ F0021_MAIN_BlitToScreen
/* srcHeight and destHeight are not necessary for blitting, only error checking, thus they are defaulted for existing code which
does not pass anything, newly imported calls do pass srcHeght and srcWidth, so this is a ceonvenience change so the the parameters
match the original exactly, if need arises for heights then we'll have to retrospectively add them in old function calls*/
/* Expects inclusive boundaries in box */
- void blitToBitmap(byte *srcBitmap, byte *destBitmap, Box &box, uint16 srcX, uint16 srcY, uint16 srcByteWidth,
+ void blitToBitmap(byte *srcBitmap, byte *destBitmap, const Box &box, uint16 srcX, uint16 srcY, uint16 srcByteWidth,
uint16 destByteWidth, Color transparent, int16 srcHeight, int16 destHight); // @ F0132_VIDEO_Blit
/* Expects inclusive boundaries in box */
void blitBoxFilledWithMaskedBitmap(byte *src, byte *dest, byte *mask, byte *tmp, Box &box, int16 lastUnitIndex,
diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp
index fe80a1013c..160c97de99 100644
--- a/engines/dm/group.cpp
+++ b/engines/dm/group.cpp
@@ -1727,7 +1727,7 @@ Thing GroupMan::groupGetGenerated(int16 creatureType, int16 healthMultiplier, ui
|| (groupThing == Thing::_none)) {
return Thing::_none;
}
- Group *group = (Group*)_vm->_dungeonMan->getThingData(groupThing);
+ Group *group = (Group *)_vm->_dungeonMan->getThingData(groupThing);
group->_slot = Thing::_endOfList;
group->setDoNotDiscard(false);
group->setDir(dir);
@@ -1776,7 +1776,7 @@ int16 GroupMan::getMeleeTargetCreatureOrdinal(int16 groupX, int16 groupY, int16
if (groupThing == Thing::_endOfList)
return 0;
- Group *group = (Group*)_vm->_dungeonMan->getThingData(groupThing);
+ Group *group = (Group *)_vm->_dungeonMan->getThingData(groupThing);
signed char orderedCellsToAttack[4];
setOrderedCellsToAttack(orderedCellsToAttack, groupX, groupY, partyX, partyY, champCell);
uint16 counter = 0;
@@ -1882,7 +1882,7 @@ void GroupMan::fluxCageAction(int16 mapX, int16 mapY) {
return;
_vm->_dungeonMan->linkThingToList(unusedThing, Thing(0), mapX, mapY);
- (((Explosion*)_vm->_dungeonMan->_thingData[k15_ExplosionThingType])[unusedThing.getIndex()]).setType(k50_ExplosionType_Fluxcage);
+ (((Explosion *)_vm->_dungeonMan->_thingData[k15_ExplosionThingType])[unusedThing.getIndex()]).setType(k50_ExplosionType_Fluxcage);
TimelineEvent newEvent;
setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_currMapIndex, _vm->_gameTime + 100);
newEvent._type = k24_TMEventTypeRemoveFluxcage;
@@ -1935,7 +1935,7 @@ bool GroupMan::isFluxcageOnSquare(int16 mapX, int16 mapY) {
Thing thing = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY);
while (thing != Thing::_endOfList) {
- if ((thing.getType() == k15_ExplosionThingType) && (((Explosion*)_vm->_dungeonMan->_thingData[k15_ExplosionThingType])[thing.getIndex()].getType() == k50_ExplosionType_Fluxcage))
+ if ((thing.getType() == k15_ExplosionThingType) && (((Explosion *)_vm->_dungeonMan->_thingData[k15_ExplosionThingType])[thing.getIndex()].getType() == k50_ExplosionType_Fluxcage))
return true;
thing = _vm->_dungeonMan->getNextThing(thing);
diff --git a/engines/dm/inventory.cpp b/engines/dm/inventory.cpp
index 9c12835973..efe1e04a9f 100644
--- a/engines/dm/inventory.cpp
+++ b/engines/dm/inventory.cpp
@@ -273,7 +273,7 @@ void InventoryMan::closeChest() {
bool processFirstChestSlot = true;
if (_openChest == Thing::_none)
return;
- Container *container = (Container*)dunMan.getThingData(_openChest);
+ Container *container = (Container *)dunMan.getThingData(_openChest);
_openChest = Thing::_none;
container->getSlot() = Thing::_endOfList;
Thing prevThing;
@@ -294,8 +294,8 @@ void InventoryMan::closeChest() {
}
}
-void InventoryMan::drawPanelScrollTextLine(int16 yPos, char* text) {
- for (char* iter = text; *iter != '\0'; ++iter) {
+void InventoryMan::drawPanelScrollTextLine(int16 yPos, char *text) {
+ for (char *iter = text; *iter != '\0'; ++iter) {
if ((*iter >= 'A') && (*iter <= 'Z'))
*iter -= 64;
else if (*iter >= '{') // this branch is CHANGE5_03_IMPROVEMENT
@@ -304,7 +304,7 @@ void InventoryMan::drawPanelScrollTextLine(int16 yPos, char* text) {
_vm->_textMan->printToViewport(162 - (6 * strlen(text) / 2), yPos, k0_ColorBlack, text, k15_ColorWhite);
}
-void InventoryMan::drawPanelScroll(Scroll* scroll) {
+void InventoryMan::drawPanelScroll(Scroll *scroll) {
DisplayMan &dispMan = *_vm->_displayMan;
char stringFirstLine[300];
@@ -352,7 +352,7 @@ void InventoryMan::drawPanelScroll(Scroll* scroll) {
}
}
-void InventoryMan::openAndDrawChest(Thing thingToOpen, Container* chest, bool isPressingEye) {
+void InventoryMan::openAndDrawChest(Thing thingToOpen, Container *chest, bool isPressingEye) {
DisplayMan &dispMan = *_vm->_displayMan;
ObjectMan &objMan = *_vm->_objectMan;
@@ -393,7 +393,7 @@ void InventoryMan::drawIconToViewport(IconIndice iconIndex, int16 xPos, int16 yP
_vm->_displayMan->blitToViewport(iconBitmap, boxIcon, k8_byteWidth, kM1_ColorNoTransparency, 16);
}
-void InventoryMan::buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, const char** attribStrings, char* destString, const char* prefixString, const char* suffixString) {
+void InventoryMan::buildObjectAttributeString(int16 potentialAttribMask, int16 actualAttribMask, const char **attribStrings, char *destString, const char *prefixString, const char *suffixString) {
uint16 identicalBitCount = 0;
int16 attribMask = 1;
for (uint16 stringIndex = 0; stringIndex < 16; stringIndex++, attribMask <<= 1) {
@@ -489,7 +489,7 @@ void InventoryMan::drawPanelObject(Thing thingToDraw, bool pressingEye) {
drawPanelObjectDescriptionString("\f"); // form feed
ThingType thingType = thingToDraw.getType();
if (thingType == k7_ScrollThingType)
- drawPanelScroll((Scroll*)rawThingPtr);
+ drawPanelScroll((Scroll *)rawThingPtr);
else if (thingType == k9_ContainerThingType)
openAndDrawChest(thingToDraw, (Container *)rawThingPtr, pressingEye);
else {
@@ -693,7 +693,7 @@ void InventoryMan::setDungeonViewPalette() {
Thing slotThing = curChampion->_slots[slotIndex];
if ((_vm->_objectMan->getObjectType(slotThing) >= k4_IconIndiceWeaponTorchUnlit) &&
(_vm->_objectMan->getObjectType(slotThing) <= k7_IconIndiceWeaponTorchLit)) {
- Weapon *curWeapon = (Weapon*)_vm->_dungeonMan->getThingData(slotThing);
+ Weapon *curWeapon = (Weapon *)_vm->_dungeonMan->getThingData(slotThing);
*curTorchLightPower = curWeapon->getChargeCount();
} else {
*curTorchLightPower = 0;
@@ -779,9 +779,9 @@ void InventoryMan::decreaseTorchesLightPower() {
}
void InventoryMan::drawChampionSkillsAndStatistics() {
- static const char* statisticNamesEN[7] = {"L", "STRENGTH", "DEXTERITY", "WISDOM", "VITALITY", "ANTI-MAGIC", "ANTI-FIRE"};
- static const char* statisticNamesDE[7] = {"L", "STAERKE", "FLINKHEIT", "WEISHEIT", "VITALITAET", "ANTI-MAGIE", "ANTI-FEUER"};
- static const char* statisticNamesFR[7] = {"L", "FORCE", "DEXTERITE", "SAGESSE", "VITALITE", "ANTI-MAGIE", "ANTI-FEU"};
+ static const char *statisticNamesEN[7] = {"L", "STRENGTH", "DEXTERITY", "WISDOM", "VITALITY", "ANTI-MAGIC", "ANTI-FIRE"};
+ static const char *statisticNamesDE[7] = {"L", "STAERKE", "FLINKHEIT", "WEISHEIT", "VITALITAET", "ANTI-MAGIE", "ANTI-FEUER"};
+ static const char *statisticNamesFR[7] = {"L", "FORCE", "DEXTERITE", "SAGESSE", "VITALITE", "ANTI-MAGIE", "ANTI-FEU"};
const char **statisticNames;
@@ -864,7 +864,7 @@ void InventoryMan::drawStopPressingEye() {
}
void InventoryMan::clickOnMouth() {
- static int16 G0242_ai_Graphic559_FoodAmounts[8] = {
+ static int16 foodAmounts[8] = {
500, /* Apple */
600, /* Corn */
650, /* Bread */
@@ -872,27 +872,8 @@ void InventoryMan::clickOnMouth() {
550, /* Screamer Slice */
350, /* Worm round */
990, /* Drumstick / Shank */
- 1400}; /* Dragon steak */
-
- Thing L1078_T_Thing;
- uint16 L1079_ui_IconIndex;
- uint16 L1080_ui_ChampionIndex;
- bool L1081_B_RemoveObjectFromLeaderHand;
- Junk* L1082_ps_Junk;
- Champion* L1083_ps_Champion;
- TimelineEvent L1084_s_Event;
- uint16 L1085_ui_Multiple;
-#define AL1085_ui_PotionPower L1085_ui_Multiple
-#define AL1085_ui_AdjustedPotionPower L1085_ui_Multiple
-#define AL1085_ui_Counter L1085_ui_Multiple
- uint16 L1086_ui_Counter;
- int16 L1087_i_Wounds;
- uint16 L1088_ui_Multiple;
-#define AL1088_ui_ThingType L1088_ui_Multiple
-#define AL1088_ui_Mana L1088_ui_Multiple
-#define AL1088_ui_HealWoundIterationCount L1088_ui_Multiple
- uint16 L1089_ui_Weight;
-
+ 1400 /* Dragon steak */
+ };
if (_vm->_championMan->_leaderEmptyHanded) {
if (_panelContent == k0_PanelContentFoodWaterPoisoned)
@@ -916,113 +897,116 @@ void InventoryMan::clickOnMouth() {
if (_vm->_championMan->_candidateChampionOrdinal)
return;
- L1078_T_Thing = _vm->_championMan->_leaderHandObject;
- if (!getFlag(_vm->_dungeonMan->_objectInfos[_vm->_dungeonMan->getObjectInfoIndex(L1078_T_Thing)]._allowedSlots, k0x0001_ObjectAllowedSlotMouth))
+ Thing handThing = _vm->_championMan->_leaderHandObject;
+ if (!getFlag(_vm->_dungeonMan->_objectInfos[_vm->_dungeonMan->getObjectInfoIndex(handThing)]._allowedSlots, k0x0001_ObjectAllowedSlotMouth))
return;
- L1079_ui_IconIndex = _vm->_objectMan->getIconIndex(L1078_T_Thing);
- AL1088_ui_ThingType = L1078_T_Thing.getType();
- L1089_ui_Weight = _vm->_dungeonMan->getObjectWeight(L1078_T_Thing);
- L1080_ui_ChampionIndex = _vm->ordinalToIndex(_inventoryChampionOrdinal);
- L1083_ps_Champion = &_vm->_championMan->_champions[L1080_ui_ChampionIndex];
- L1082_ps_Junk = (Junk*)_vm->_dungeonMan->getThingData(L1078_T_Thing);
- if ((L1079_ui_IconIndex >= k8_IconIndiceJunkWater) && (L1079_ui_IconIndex <= k9_IconIndiceJunkWaterSkin)) {
- if (!(L1082_ps_Junk->getChargeCount())) {
+ uint16 iconIndex = _vm->_objectMan->getIconIndex(handThing);
+ uint16 handThingType = handThing.getType();
+ uint16 handThingWeight = _vm->_dungeonMan->getObjectWeight(handThing);
+ uint16 championIndex = _vm->ordinalToIndex(_inventoryChampionOrdinal);
+ Champion *curChampion = &_vm->_championMan->_champions[championIndex];
+ Junk *junkData = (Junk *)_vm->_dungeonMan->getThingData(handThing);
+ bool removeObjectFromLeaderHand;
+ if ((iconIndex >= k8_IconIndiceJunkWater) && (iconIndex <= k9_IconIndiceJunkWaterSkin)) {
+ if (!(junkData->getChargeCount()))
return;
- }
- L1083_ps_Champion->_water = MIN(L1083_ps_Champion->_water + 800, 2048);
- L1082_ps_Junk->setChargeCount(L1082_ps_Junk->getChargeCount() - 1);
- L1081_B_RemoveObjectFromLeaderHand = false;
- } else {
- if (AL1088_ui_ThingType == k8_PotionThingType) {
- L1081_B_RemoveObjectFromLeaderHand = false;
- } else {
- L1082_ps_Junk->setNextThing(Thing::_none);
- L1081_B_RemoveObjectFromLeaderHand = true;
- }
+
+ curChampion->_water = MIN(curChampion->_water + 800, 2048);
+ junkData->setChargeCount(junkData->getChargeCount() - 1);
+ removeObjectFromLeaderHand = false;
+ } else if (handThingType == k8_PotionThingType)
+ removeObjectFromLeaderHand = false;
+ else {
+ junkData->setNextThing(Thing::_none);
+ removeObjectFromLeaderHand = true;
}
_vm->_eventMan->showMouse();
- if (L1081_B_RemoveObjectFromLeaderHand) {
+ if (removeObjectFromLeaderHand)
_vm->_championMan->getObjectRemovedFromLeaderHand();
- }
- if (AL1088_ui_ThingType == k8_PotionThingType) {
- AL1085_ui_PotionPower = ((Potion*)L1082_ps_Junk)->getPower();
- L1086_ui_Counter = ((511 - AL1085_ui_PotionPower) / (32 + (AL1085_ui_PotionPower + 1) / 8)) >> 1;
- AL1085_ui_AdjustedPotionPower = (AL1085_ui_PotionPower / 25) + 8; /* Value between 8 and 18 */
- switch (((Potion*)L1082_ps_Junk)->getType()) {
+
+ if (handThingType == k8_PotionThingType) {
+ uint16 potionPower = ((Potion *)junkData)->getPower();
+ uint16 counter = ((511 - potionPower) / (32 + (potionPower + 1) / 8)) >> 1;
+ uint16 adjustedPotionPower = (potionPower / 25) + 8; /* Value between 8 and 18 */
+
+ switch (((Potion *)junkData)->getType()) {
case k6_PotionTypeRos:
- adjustStatisticCurrentValue(L1083_ps_Champion, k2_ChampionStatDexterity, AL1085_ui_AdjustedPotionPower);
+ adjustStatisticCurrentValue(curChampion, k2_ChampionStatDexterity, adjustedPotionPower);
break;
case k7_PotionTypeKu:
- adjustStatisticCurrentValue(L1083_ps_Champion, k1_ChampionStatStrength, (((Potion*)L1082_ps_Junk)->getPower() / 35) + 5); /* Value between 5 and 12 */
+ adjustStatisticCurrentValue(curChampion, k1_ChampionStatStrength, (((Potion *)junkData)->getPower() / 35) + 5); /* Value between 5 and 12 */
break;
case k8_PotionTypeDane:
- adjustStatisticCurrentValue(L1083_ps_Champion, k3_ChampionStatWisdom, AL1085_ui_AdjustedPotionPower);
+ adjustStatisticCurrentValue(curChampion, k3_ChampionStatWisdom, adjustedPotionPower);
break;
case k9_PotionTypeNeta:
- adjustStatisticCurrentValue(L1083_ps_Champion, k4_ChampionStatVitality, AL1085_ui_AdjustedPotionPower);
+ adjustStatisticCurrentValue(curChampion, k4_ChampionStatVitality, adjustedPotionPower);
break;
case k10_PotionTypeAntivenin:
- _vm->_championMan->unpoison(L1080_ui_ChampionIndex);
+ _vm->_championMan->unpoison(championIndex);
break;
case k11_PotionTypeMon:
- L1083_ps_Champion->_currStamina += MIN(L1083_ps_Champion->_maxStamina - L1083_ps_Champion->_currStamina, L1083_ps_Champion->_maxStamina / L1086_ui_Counter);
+ curChampion->_currStamina += MIN(curChampion->_maxStamina - curChampion->_currStamina, curChampion->_maxStamina / counter);
break;
- case k12_PotionTypeYa:
- AL1085_ui_AdjustedPotionPower += AL1085_ui_AdjustedPotionPower >> 1;
- if (L1083_ps_Champion->_shieldDefense > 50) {
- AL1085_ui_AdjustedPotionPower >>= 2;
+ case k12_PotionTypeYa: {
+ adjustedPotionPower += adjustedPotionPower >> 1;
+ if (curChampion->_shieldDefense > 50)
+ adjustedPotionPower >>= 2;
+
+ curChampion->_shieldDefense += adjustedPotionPower;
+ TimelineEvent newEvent;
+ newEvent._type = k72_TMEventTypeChampionShield;
+ setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + (adjustedPotionPower * adjustedPotionPower));
+ newEvent._priority = championIndex;
+ newEvent._B._defense = adjustedPotionPower;
+ _vm->_timeline->addEventGetEventIndex(&newEvent);
+ setFlag(curChampion->_attributes, k0x1000_ChampionAttributeStatusBox);
}
- L1083_ps_Champion->_shieldDefense += AL1085_ui_AdjustedPotionPower;
- L1084_s_Event._type = k72_TMEventTypeChampionShield;
- setMapAndTime(L1084_s_Event._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + (AL1085_ui_AdjustedPotionPower * AL1085_ui_AdjustedPotionPower));
- L1084_s_Event._priority = L1080_ui_ChampionIndex;
- L1084_s_Event._B._defense = AL1085_ui_AdjustedPotionPower;
- _vm->_timeline->addEventGetEventIndex(&L1084_s_Event);
- setFlag(L1083_ps_Champion->_attributes, k0x1000_ChampionAttributeStatusBox);
break;
- case k13_PotionTypeEe:
- AL1088_ui_Mana = MIN(900, (L1083_ps_Champion->_currMana + AL1085_ui_AdjustedPotionPower) + (AL1085_ui_AdjustedPotionPower - 8));
- if (AL1088_ui_Mana > L1083_ps_Champion->_maxMana) {
- AL1088_ui_Mana -= (AL1088_ui_Mana - MAX(L1083_ps_Champion->_currMana, L1083_ps_Champion->_maxMana)) >> 1;
+ case k13_PotionTypeEe: {
+ uint16 mana = MIN(900, (curChampion->_currMana + adjustedPotionPower) + (adjustedPotionPower - 8));
+ if (mana > curChampion->_maxMana)
+ mana -= (mana - MAX(curChampion->_currMana, curChampion->_maxMana)) >> 1;
+
+ curChampion->_currMana = mana;
}
- L1083_ps_Champion->_currMana = AL1088_ui_Mana;
break;
- case k14_PotionTypeVi:
- AL1088_ui_HealWoundIterationCount = MAX(1, (((Potion*)L1082_ps_Junk)->getPower() / 42));
- L1083_ps_Champion->_currHealth += L1083_ps_Champion->_maxHealth / L1086_ui_Counter;
- L1087_i_Wounds = L1083_ps_Champion->_wounds;
- if (L1087_i_Wounds) { /* If the champion is wounded */
- L1086_ui_Counter = 10;
+ case k14_PotionTypeVi: {
+ uint16 healWoundIterationCount = MAX(1, (((Potion *)junkData)->getPower() / 42));
+ curChampion->_currHealth += curChampion->_maxHealth / counter;
+ int16 wounds = curChampion->_wounds;
+ if (wounds) { /* If the champion is wounded */
+ counter = 10;
do {
- for (AL1085_ui_Counter = 0; AL1085_ui_Counter < AL1088_ui_HealWoundIterationCount; AL1085_ui_Counter++) {
- L1083_ps_Champion->_wounds &= _vm->getRandomNumber(65536);
- }
- AL1088_ui_HealWoundIterationCount = 1;
- } while ((L1087_i_Wounds == L1083_ps_Champion->_wounds) && --L1086_ui_Counter); /* Loop until at least one wound is healed or there are no more heal iterations */
+ for (uint16 i = 0; i < healWoundIterationCount; i++)
+ curChampion->_wounds &= _vm->getRandomNumber(65536);
+
+ healWoundIterationCount = 1;
+ } while ((wounds == curChampion->_wounds) && --counter); /* Loop until at least one wound is healed or there are no more heal iterations */
+ }
+ setFlag(curChampion->_attributes, k0x0200_ChampionAttributeLoad | k0x2000_ChampionAttributeWounds);
}
- setFlag(L1083_ps_Champion->_attributes, k0x0200_ChampionAttributeLoad | k0x2000_ChampionAttributeWounds);
break;
case k15_PotionTypeWaterFlask:
- L1083_ps_Champion->_water = MIN(L1083_ps_Champion->_water + 1600, 2048);
+ curChampion->_water = MIN(curChampion->_water + 1600, 2048);
break;
default:
break;
}
- ((Potion*)L1082_ps_Junk)->setType(k20_PotionTypeEmptyFlask);
- } else if ((L1079_ui_IconIndex >= k168_IconIndiceJunkApple) && (L1079_ui_IconIndex < k176_IconIndiceJunkIronKey)) {
- L1083_ps_Champion->_food = MIN(L1083_ps_Champion->_food + G0242_ai_Graphic559_FoodAmounts[L1079_ui_IconIndex - k168_IconIndiceJunkApple], 2048);
- }
+ ((Potion *)junkData)->setType(k20_PotionTypeEmptyFlask);
+ } else if ((iconIndex >= k168_IconIndiceJunkApple) && (iconIndex < k176_IconIndiceJunkIronKey))
+ curChampion->_food = MIN(curChampion->_food + foodAmounts[iconIndex - k168_IconIndiceJunkApple], 2048);
- if (L1083_ps_Champion->_currStamina > L1083_ps_Champion->_maxStamina)
- L1083_ps_Champion->_currStamina = L1083_ps_Champion->_maxStamina;
+ if (curChampion->_currStamina > curChampion->_maxStamina)
+ curChampion->_currStamina = curChampion->_maxStamina;
- if (L1083_ps_Champion->_currHealth > L1083_ps_Champion->_maxHealth)
- L1083_ps_Champion->_currHealth = L1083_ps_Champion->_maxHealth;
+ if (curChampion->_currHealth > curChampion->_maxHealth)
+ curChampion->_currHealth = curChampion->_maxHealth;
- if (L1081_B_RemoveObjectFromLeaderHand) {
- for (L1086_ui_Counter = 5; --L1086_ui_Counter; _vm->delay(8)) { /* Animate mouth icon */
- _vm->_objectMan->drawIconToScreen(k205_IconIndiceMouthOpen + !(L1086_ui_Counter & 0x0001), 56, 46);
+ if (removeObjectFromLeaderHand) {
+ for (uint16 i = 5; --i; _vm->delay(8)) { /* Animate mouth icon */
+ _vm->_objectMan->drawIconToScreen(k205_IconIndiceMouthOpen + !(i & 0x0001), 56, 46);
_vm->_eventMan->discardAllInput();
if (_vm->_engineShouldQuit)
return;
@@ -1030,36 +1014,35 @@ void InventoryMan::clickOnMouth() {
}
} else {
_vm->_championMan->drawChangedObjectIcons();
- _vm->_championMan->_champions[_vm->_championMan->_leaderIndex]._load += _vm->_dungeonMan->getObjectWeight(L1078_T_Thing) - L1089_ui_Weight;
+ _vm->_championMan->_champions[_vm->_championMan->_leaderIndex]._load += _vm->_dungeonMan->getObjectWeight(handThing) - handThingWeight;
setFlag(_vm->_championMan->_champions[_vm->_championMan->_leaderIndex]._attributes, k0x0200_ChampionAttributeLoad);
}
_vm->_sound->requestPlay(k08_soundSWALLOW, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k0_soundModePlayImmediately);
- setFlag(L1083_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
- if (_panelContent == k0_PanelContentFoodWaterPoisoned) {
- setFlag(L1083_ps_Champion->_attributes, k0x0800_ChampionAttributePanel);
- }
- _vm->_championMan->drawChampionState((ChampionIndex)L1080_ui_ChampionIndex);
+ setFlag(curChampion->_attributes, k0x0100_ChampionAttributeStatistics);
+
+ if (_panelContent == k0_PanelContentFoodWaterPoisoned)
+ setFlag(curChampion->_attributes, k0x0800_ChampionAttributePanel);
+
+ _vm->_championMan->drawChampionState((ChampionIndex)championIndex);
_vm->_eventMan->hideMouse();
}
-void InventoryMan::adjustStatisticCurrentValue(Champion* champ, uint16 statIndex, int16 valueDelta) {
- int16 L1077_i_Multiple;
-#define AL1077_i_CurrentValue L1077_i_Multiple
-#define AL1077_i_Delta L1077_i_Multiple
-
+void InventoryMan::adjustStatisticCurrentValue(Champion *champ, uint16 statIndex, int16 valueDelta) {
+ int16 delta;
if (valueDelta >= 0) {
- if ((AL1077_i_CurrentValue = champ->_statistics[statIndex][k1_ChampionStatCurrent]) > 120) {
+ int16 currentValue = champ->_statistics[statIndex][k1_ChampionStatCurrent];
+ if (currentValue > 120) {
valueDelta >>= 1;
- if (AL1077_i_CurrentValue > 150) {
+ if (currentValue > 150) {
valueDelta >>= 1;
}
valueDelta++;
}
- AL1077_i_Delta = MIN(valueDelta, (int16)(170 - AL1077_i_CurrentValue));
+ delta = MIN(valueDelta, (int16)(170 - currentValue));
} else { /* BUG0_00 Useless code. The function is always called with valueDelta having a positive value */
- AL1077_i_Delta = MAX(valueDelta, int16(champ->_statistics[statIndex][k2_ChampionStatMinimum] - champ->_statistics[statIndex][k1_ChampionStatCurrent]));
+ delta = MAX(valueDelta, int16(champ->_statistics[statIndex][k2_ChampionStatMinimum] - champ->_statistics[statIndex][k1_ChampionStatCurrent]));
}
- champ->_statistics[statIndex][k1_ChampionStatCurrent] += AL1077_i_Delta;
+ champ->_statistics[statIndex][k1_ChampionStatCurrent] += delta;
}
void InventoryMan::clickOnEye() {
@@ -1077,13 +1060,13 @@ void InventoryMan::clickOnEye() {
_vm->_eventMan->hideMouse();
_vm->delay(8);
drawIconToViewport(k203_IconIndiceEyeLooking, 12, 13);
- if (_vm->_championMan->_leaderEmptyHanded) {
+ if (_vm->_championMan->_leaderEmptyHanded)
drawChampionSkillsAndStatistics();
- } else {
+ else {
_vm->_objectMan->clearLeaderObjectName();
drawPanelObject(_vm->_championMan->_leaderHandObject, true);
}
_vm->_displayMan->drawViewport(k0_viewportNotDungeonView);
-
}
+
}
diff --git a/engines/dm/loadsave.cpp b/engines/dm/loadsave.cpp
index a9ee6f8d0a..5feb484523 100644
--- a/engines/dm/loadsave.cpp
+++ b/engines/dm/loadsave.cpp
@@ -40,14 +40,13 @@
#include "dm/projexpl.h"
#include "dm/dialog.h"
-
namespace DM {
LoadgameResponse DMEngine::loadgame(int16 slot) {
if (slot == -1 && _newGameFl == k0_modeLoadSavedGame)
return kM1_LoadgameFailure;
- bool L1366_B_FadePalette = true;
+ bool fadePalette = true;
Common::String fileName;
Common::SaveFileManager *saveFileManager = nullptr;
Common::InSaveFile *file = nullptr;
@@ -131,7 +130,7 @@ LoadgameResponse DMEngine::loadgame(int16 slot) {
_timeline->initTimeline();
_groupMan->initActiveGroups();
- if (L1366_B_FadePalette) {
+ if (fadePalette) {
_displayMan->startEndFadeToPalette(_displayMan->_blankBuffer);
delay(1);
_displayMan->fillScreen(k0_ColorBlack);
@@ -154,7 +153,6 @@ LoadgameResponse DMEngine::loadgame(int16 slot) {
_dialog->dialogDraw(nullptr, "CHARGEMENT DU JEU . . .", nullptr, nullptr, nullptr, nullptr, true, true, true);
break;
}
-
}
_championMan->_partyDead = false;
@@ -254,10 +252,10 @@ Common::String DMEngine::getSavefileName(uint16 slot) {
return Common::String::format("%s.%03u", _targetName.c_str(), slot);
}
-#define SAVEGAME_ID MKTAG('D', 'M', 'D', 'M')
+#define SAVEGAME_ID MKTAG('D', 'M', '2', '1')
#define SAVEGAME_VERSION 1
-void DMEngine::writeSaveGameHeader(Common::OutSaveFile* out, const Common::String& saveName) {
+void DMEngine::writeSaveGameHeader(Common::OutSaveFile *out, const Common::String& saveName) {
out->writeUint32BE(SAVEGAME_ID);
// Write version
@@ -268,9 +266,9 @@ void DMEngine::writeSaveGameHeader(Common::OutSaveFile* out, const Common::Strin
out->writeByte(0);
// Save the game thumbnail
- if (_saveThumbnail) {
+ if (_saveThumbnail)
out->write(_saveThumbnail->getData(), _saveThumbnail->size());
- } else
+ else
Graphics::saveThumbnail(*out);
// Creation date/time
@@ -291,9 +289,8 @@ bool DMEngine::writeCompleteSaveFile(int16 saveSlot, Common::String& saveDescrip
Common::SaveFileManager *saveFileManager = _system->getSavefileManager();
Common::OutSaveFile *file = saveFileManager->openForSaving(savefileName);
- if (!file) {
+ if (!file)
return false;
- }
writeSaveGameHeader(file, saveDescription);
@@ -339,29 +336,27 @@ bool DMEngine::writeCompleteSaveFile(int16 saveSlot, Common::String& saveDescrip
file->writeUint32BE(0x6f85e3d3);
// save _g278_dungeonFileHeader
- {
- DungeonFileHeader &header = _dungeonMan->_dungeonFileHeader;
- file->writeUint16BE(header._ornamentRandomSeed);
- file->writeUint16BE(header._rawMapDataSize);
- file->writeByte(header._mapCount);
- file->writeByte(0); // to match the structure of dungeon.dat, will be discarded
- file->writeUint16BE(header._textDataWordCount);
- file->writeUint16BE(header._partyStartLocation);
- file->writeUint16BE(header._squareFirstThingCount);
- for (uint16 i = 0; i < 16; ++i)
- file->writeUint16BE(header._thingCounts[i]);
- }
+ DungeonFileHeader &header = _dungeonMan->_dungeonFileHeader;
+ file->writeUint16BE(header._ornamentRandomSeed);
+ file->writeUint16BE(header._rawMapDataSize);
+ file->writeByte(header._mapCount);
+ file->writeByte(0); // to match the structure of dungeon.dat, will be discarded
+ file->writeUint16BE(header._textDataWordCount);
+ file->writeUint16BE(header._partyStartLocation);
+ file->writeUint16BE(header._squareFirstThingCount);
+ for (uint16 i = 0; i < 16; ++i)
+ file->writeUint16BE(header._thingCounts[i]);
// save _g277_dungeonMaps
for (uint16 i = 0; i < _dungeonMan->_dungeonFileHeader._mapCount; ++i) {
Map &map = _dungeonMan->_dungeonMaps[i];
- uint16 tmp;
file->writeUint16BE(map._rawDunDataOffset);
file->writeUint32BE(0); // to match the structure of dungeon.dat, will be discarded
file->writeByte(map._offsetMapX);
file->writeByte(map._offsetMapY);
+ uint16 tmp;
tmp = ((map._height & 0x1F) << 11) | ((map._width & 0x1F) << 6) | (map._level & 0x3F);
file->writeUint16BE(tmp);
@@ -405,7 +400,7 @@ bool DMEngine::writeCompleteSaveFile(int16 saveSlot, Common::String& saveDescrip
return true;
}
-bool readSaveGameHeader(Common::InSaveFile* in, SaveGameHeader* header) {
+bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader *header) {
uint32 id = in->readUint32BE();
// Check if it's a valid ScummVM savegame
diff --git a/engines/dm/lzw.cpp b/engines/dm/lzw.cpp
index a93b0c875a..dc5055f687 100644
--- a/engines/dm/lzw.cpp
+++ b/engines/dm/lzw.cpp
@@ -106,28 +106,25 @@ int16 LZWdecompressor::getNextInputCode(Common::MemoryReadStream &inputStream, i
}
void LZWdecompressor::outputCharacter(byte character, byte **out) {
- byte *L1558_pc_Output = *out;
+ byte *output = *out;
if (false == _repetitionEnabled) {
- if (character == 0x90) {
+ if (character == 0x90)
_repetitionEnabled = true;
- } else {
- *L1558_pc_Output++ = _charToRepeat = character;
- }
- *out = L1558_pc_Output;
- return;
+ else
+ *output++ = _charToRepeat = character;
} else {
if (character) { /* If character following 0x90 is not 0x00 then it is the repeat count */
- while (--character) {
- *L1558_pc_Output++ = _charToRepeat;
- }
- } else { /* else output a 0x90 character */
- *L1558_pc_Output++ = 0x90;
- }
+ while (--character)
+ *output++ = _charToRepeat;
+ } else /* else output a 0x90 character */
+ *output++ = 0x90;
+
_repetitionEnabled = false;
- *out = L1558_pc_Output;
- return;
}
+
+ *out = output;
+ return;
}
int32 LZWdecompressor::decompress(Common::MemoryReadStream &inStream, int32 inputByteCount, byte *out) {
diff --git a/engines/dm/lzw.h b/engines/dm/lzw.h
index 3603423718..313b74b6d8 100644
--- a/engines/dm/lzw.h
+++ b/engines/dm/lzw.h
@@ -51,7 +51,7 @@ class LZWdecompressor {
int16 _inputBufferBitCount;
int16 _charToRepeat;
- byte* _tempBuffer;
+ byte *_tempBuffer;
int16 *_prefixCode;
byte *_appendCharacter;
diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp
index 687e619661..b2f159f857 100644
--- a/engines/dm/menus.cpp
+++ b/engines/dm/menus.cpp
@@ -87,7 +87,53 @@ void MenuMan::initConstants() {
16, /* SPIT */
14, /* BRANDISH */
10, /* THROW */
- 3 /* FUSE */
+ 3 /* FUSE */
+ };
+ static unsigned char 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 */
};
_boxActionArea1ActionMenu = Box(224, 319, 77, 97); // @ G0501_s_Graphic560_Box_ActionArea1ActionMenu
@@ -96,8 +142,10 @@ void MenuMan::initConstants() {
_boxActionArea = Box(224, 319, 77, 121); // @ G0001_s_Graphic562_Box_ActionArea
_boxSpellArea = Box(224, 319, 42, 74);
- for (int i = 0; i < 40; i++)
+ for (int i = 0; i < 44; i++) {
_actionSkillIndex[i] = actionSkillIndex[i];
+ _actionDisabledTicks[i] = actionDisabledTicks[i];
+ }
}
MenuMan::MenuMan(DMEngine *vm) : _vm(vm) {
@@ -282,8 +330,8 @@ void MenuMan::drawActionArea() {
_refreshActionArea = false;
}
-const char* MenuMan::getActionName(ChampionAction actionIndex) {
- const char *g490_ChampionActionNames[44] = { // @ G0490_ac_Graphic560_ActionNames
+const char *MenuMan::getActionName(ChampionAction actionIndex) {
+ const char *championActionNames[44] = { // @ G0490_ac_Graphic560_ActionNames
"N", "BLOCK", "CHOP", "X", "BLOW HORN", "FLIP", "PUNCH",
"KICK", "WAR CRY", "STAB", "CLIMB DOWN", "FREEZE LIFE",
"HIT", "SWING", "STAB", "THRUST", "JAB", "PARRY", "HACK",
@@ -294,7 +342,7 @@ const char* MenuMan::getActionName(ChampionAction actionIndex) {
"BRANDISH", "THROW", "FUSE"
};
- return (actionIndex == k255_ChampionActionNone) ? "" : g490_ChampionActionNames[actionIndex];
+ return (actionIndex == k255_ChampionActionNone) ? "" : championActionNames[actionIndex];
}
void MenuMan::drawSpellAreaControls(ChampionIndex champIndex) {
@@ -308,55 +356,61 @@ void MenuMan::drawSpellAreaControls(ChampionIndex champIndex) {
int16 champHP3 = _vm->_championMan->_champions[3]._currHealth;
_vm->_eventMan->showMouse();
_vm->_displayMan->fillScreenBox(boxSpellAreaControls, k0_ColorBlack);
+
switch (champIndex) {
case 0:
_vm->_eventMan->highlightScreenBox(233, 277, 42, 49);
_vm->_textMan->printToLogicalScreen(235, 48, k0_ColorBlack, k4_ColorCyan, champ->_name);
if (_vm->_championMan->_partyChampionCount > 1) {
- if (champHP1) {
+ if (champHP1)
_vm->_eventMan->highlightScreenBox(280, 291, 42, 48);
- }
-T0393002:
+
if (_vm->_championMan->_partyChampionCount > 2) {
- if (champHP2) {
+ if (champHP2)
_vm->_eventMan->highlightScreenBox(294, 305, 42, 48);
- }
-T0393003:
- if (_vm->_championMan->_partyChampionCount > 3) {
- if (champHP3) {
- _vm->_eventMan->highlightScreenBox(308, 319, 42, 48);
- }
- }
+
+ if ((_vm->_championMan->_partyChampionCount > 3) && champHP3)
+ _vm->_eventMan->highlightScreenBox(308, 319, 42, 48);
}
}
break;
case 1:
- if (champHP0) {
+ if (champHP0)
_vm->_eventMan->highlightScreenBox(233, 244, 42, 48);
- }
+
_vm->_eventMan->highlightScreenBox(247, 291, 42, 49);
_vm->_textMan->printToLogicalScreen(249, 48, k0_ColorBlack, k4_ColorCyan, champ->_name);
- goto T0393002;
+ if (_vm->_championMan->_partyChampionCount > 2) {
+ if (champHP2)
+ _vm->_eventMan->highlightScreenBox(294, 305, 42, 48);
+
+ if ((_vm->_championMan->_partyChampionCount > 3) && champHP3)
+ _vm->_eventMan->highlightScreenBox(308, 319, 42, 48);
+ }
+ break;
case 2:
- if (champHP0) {
+ if (champHP0)
_vm->_eventMan->highlightScreenBox(233, 244, 42, 48);
- }
- if (champHP1) {
+
+ if (champHP1)
_vm->_eventMan->highlightScreenBox(247, 258, 42, 48);
- }
+
_vm->_eventMan->highlightScreenBox(261, 305, 42, 49);
_vm->_textMan->printToLogicalScreen(263, 48, k0_ColorBlack, k4_ColorCyan, champ->_name);
- goto T0393003;
+ if ((_vm->_championMan->_partyChampionCount > 3) && champHP3)
+ _vm->_eventMan->highlightScreenBox(308, 319, 42, 48);
+ break;
+
case 3:
- if (champHP0) {
+ if (champHP0)
_vm->_eventMan->highlightScreenBox(233, 244, 42, 48);
- }
- if (champHP1) {
+
+ if (champHP1)
_vm->_eventMan->highlightScreenBox(247, 258, 42, 48);
- }
- if (champHP2) {
+
+ if (champHP2)
_vm->_eventMan->highlightScreenBox(261, 272, 42, 48);
- }
+
_vm->_eventMan->highlightScreenBox(275, 319, 42, 49);
_vm->_textMan->printToLogicalScreen(277, 48, k0_ColorBlack, k4_ColorCyan, champ->_name);
break;
@@ -366,44 +420,42 @@ T0393003:
_vm->_eventMan->hideMouse();
}
-#define k2_SpellAreaAvailableSymbols 2 // @ C2_SPELL_AREA_AVAILABLE_SYMBOLS
-#define k3_SpellAreaChampionSymbols 3 // @ C3_SPELL_AREA_CHAMPION_SYMBOLS
-
void MenuMan::buildSpellAreaLine(int16 spellAreaBitmapLine) {
static Box boxSpellAreaLine(0, 95, 0, 11); // @ K0074_s_Box_SpellAreaLine
- char L1204_ac_SpellSymbolString[2] = {'\0', '\0'};
- Champion *L1203_ps_Champion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex];
+ char spellSymbolString[2] = {'\0', '\0'};
+ Champion *magicChampion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex];
if (spellAreaBitmapLine == k2_SpellAreaAvailableSymbols) {
_vm->_displayMan->_useByteBoxCoordinates = false;
_vm->_displayMan->blitToBitmap(_bitmapSpellAreaLines, _bitmapSpellAreaLine, boxSpellAreaLine, 0, 12, k48_byteWidth, k48_byteWidth, kM1_ColorNoTransparency, 36, 12);
int16 x = 1;
- char character = 96 + (6 * L1203_ps_Champion->_symbolStep);
+ char character = 96 + (6 * magicChampion->_symbolStep);
for (uint16 symbolIndex = 0; symbolIndex < 6; symbolIndex++) {
- L1204_ac_SpellSymbolString[0] = character++;
- _vm->_textMan->printTextToBitmap(_bitmapSpellAreaLine, 48, x += 14, 8, k4_ColorCyan, k0_ColorBlack, L1204_ac_SpellSymbolString, 12);
+ spellSymbolString[0] = character++;
+ x += 14;
+ _vm->_textMan->printTextToBitmap(_bitmapSpellAreaLine, 48, x, 8, k4_ColorCyan, k0_ColorBlack, spellSymbolString, 12);
}
} else if (spellAreaBitmapLine == k3_SpellAreaChampionSymbols) {
_vm->_displayMan->_useByteBoxCoordinates = false;
_vm->_displayMan->blitToBitmap(_bitmapSpellAreaLines, _bitmapSpellAreaLine, boxSpellAreaLine, 0, 24, k48_byteWidth, k48_byteWidth, kM1_ColorNoTransparency, 36, 12);
int16 x = 8;
for (uint16 symbolIndex = 0; symbolIndex < 4; symbolIndex++) {
- if ((L1204_ac_SpellSymbolString[0] = L1203_ps_Champion->_symbols[symbolIndex]) == '\0')
+ if ((spellSymbolString[0] = magicChampion->_symbols[symbolIndex]) == '\0')
break;
- _vm->_textMan->printTextToBitmap(_bitmapSpellAreaLine, 48, x += 9, 8, k4_ColorCyan, k0_ColorBlack, L1204_ac_SpellSymbolString, 12);
+ x += 9;
+ _vm->_textMan->printTextToBitmap(_bitmapSpellAreaLine, 48, x, 8, k4_ColorCyan, k0_ColorBlack, spellSymbolString, 12);
}
}
}
-void MenuMan::setMagicCasterAndDrawSpellArea(int16 champIndex) {
+void MenuMan::setMagicCasterAndDrawSpellArea(ChampionIndex champIndex) {
static Box boxSpellAreaLine2(224, 319, 50, 61); // @ K0075_s_Box_SpellAreaLine2
static Box boxSpellAreaLine3(224, 319, 62, 73); // @ K0076_s_Box_SpellAreaLine3
- Champion* L1213_ps_Champion;
-
- if ((champIndex == _vm->_championMan->_magicCasterChampionIndex) || ((champIndex != kM1_ChampionNone) && !_vm->_championMan->_champions[champIndex]._currHealth)) {
+ if ((champIndex == _vm->_championMan->_magicCasterChampionIndex)
+ || ((champIndex != kM1_ChampionNone) && !_vm->_championMan->_champions[champIndex]._currHealth))
return;
- }
+
if (_vm->_championMan->_magicCasterChampionIndex == kM1_ChampionNone) {
_vm->_eventMan->showMouse();
_vm->_displayMan->blitToScreen(_vm->_displayMan->getNativeBitmapOrGraphic(k9_MenuSpellAreaBackground), &_boxSpellArea, k48_byteWidth, kM1_ColorNoTransparency, 33);
@@ -417,10 +469,10 @@ void MenuMan::setMagicCasterAndDrawSpellArea(int16 champIndex) {
_vm->_eventMan->hideMouse();
return;
}
- L1213_ps_Champion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex = (ChampionIndex)champIndex];
+ _vm->_championMan->_magicCasterChampionIndex = champIndex;
buildSpellAreaLine(k2_SpellAreaAvailableSymbols);
_vm->_eventMan->showMouse();
- drawSpellAreaControls((ChampionIndex)champIndex);
+ drawSpellAreaControls(champIndex);
_vm->_displayMan->blitToScreen(_bitmapSpellAreaLine, &boxSpellAreaLine2, k48_byteWidth, kM1_ColorNoTransparency, 12);
buildSpellAreaLine(k3_SpellAreaChampionSymbols);
_vm->_displayMan->blitToScreen(_bitmapSpellAreaLine, &boxSpellAreaLine3, k48_byteWidth, kM1_ColorNoTransparency, 12);
@@ -428,23 +480,18 @@ void MenuMan::setMagicCasterAndDrawSpellArea(int16 champIndex) {
}
void MenuMan::drawEnabledMenus() {
- int16 L1462_i_Multiple;
-#define AL1462_i_MagicCasterChampionIndex L1462_i_Multiple
-#define AL1462_i_InventoryChampionOrdinal L1462_i_Multiple
-
-
if (_vm->_championMan->_partyIsSleeping) {
_vm->_eventMan->drawSleepScreen();
_vm->_displayMan->drawViewport(k0_viewportNotDungeonView);
} else {
- AL1462_i_MagicCasterChampionIndex = _vm->_championMan->_magicCasterChampionIndex;
+ ChampionIndex casterChampionIndex = _vm->_championMan->_magicCasterChampionIndex;
_vm->_championMan->_magicCasterChampionIndex = kM1_ChampionNone; /* Force next function to draw the spell area */
- setMagicCasterAndDrawSpellArea(AL1462_i_MagicCasterChampionIndex);
- if (!_vm->_championMan->_actingChampionOrdinal) {
+ setMagicCasterAndDrawSpellArea(casterChampionIndex);
+ if (!_vm->_championMan->_actingChampionOrdinal)
_actionAreaContainsIcons = true;
- }
+
drawActionArea();
- AL1462_i_InventoryChampionOrdinal = _vm->_inventoryMan->_inventoryChampionOrdinal;
+ int16 AL1462_i_InventoryChampionOrdinal = _vm->_inventoryMan->_inventoryChampionOrdinal;
if (AL1462_i_InventoryChampionOrdinal) {
_vm->_inventoryMan->_inventoryChampionOrdinal = _vm->indexToOrdinal(kM1_ChampionNone);
_vm->_inventoryMan->toggleInventory((ChampionIndex)_vm->ordinalToIndex(AL1462_i_InventoryChampionOrdinal));
@@ -457,186 +504,189 @@ void MenuMan::drawEnabledMenus() {
}
int16 MenuMan::getClickOnSpellCastResult() {
- int16 L1259_i_SpellCastResult;
- Champion* L1260_ps_Champion;
-
-
- L1260_ps_Champion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex];
+ Champion *casterChampion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex];
_vm->_eventMan->showMouse();
_vm->_eventMan->highlightBoxDisable();
- if ((L1259_i_SpellCastResult = getChampionSpellCastResult(_vm->_championMan->_magicCasterChampionIndex)) != k3_spellCastFailureNeedsFlask) {
- L1260_ps_Champion->_symbols[0] = '\0';
- drawAvailableSymbols(L1260_ps_Champion->_symbolStep = 0);
- drawChampionSymbols(L1260_ps_Champion);
- } else {
- L1259_i_SpellCastResult = k0_spellCastFailure;
- }
+
+ int16 spellCastResult = getChampionSpellCastResult(_vm->_championMan->_magicCasterChampionIndex);
+ if (spellCastResult != k3_spellCastFailureNeedsFlask) {
+ casterChampion->_symbols[0] = '\0';
+ drawAvailableSymbols(casterChampion->_symbolStep = 0);
+ drawChampionSymbols(casterChampion);
+ } else
+ spellCastResult = k0_spellCastFailure;
+
_vm->_eventMan->hideMouse();
- return L1259_i_SpellCastResult;
+ return spellCastResult;
}
int16 MenuMan::getChampionSpellCastResult(uint16 champIndex) {
- uint16 L1267_ui_Multiple;
-#define AL1267_ui_SkillLevel L1267_ui_Multiple
-#define AL1267_ui_LightPower L1267_ui_Multiple
-#define AL1267_ui_SpellPower L1267_ui_Multiple
-#define AL1267_ui_Ticks L1267_ui_Multiple
- int16 L1268_i_PowerSymbolOrdinal;
- uint16 L1269_ui_Multiple;
-#define AL1269_ui_RequiredSkillLevel L1269_ui_Multiple
-#define AL1269_ui_EmptyFlaskWeight L1269_ui_Multiple
-#define AL1269_ui_Ticks L1269_ui_Multiple
- Champion* L1270_ps_Champion;
- Spell* L1271_ps_Spell;
- Thing L1272_T_Object;
- uint16 L1273_ui_Experience;
- int16 L1274_i_MissingSkillLevelCount;
- Potion* L1275_ps_Potion;
- TimelineEvent L1276_s_Event;
- Junk* L1277_ps_Junk;
-
-
- if (champIndex >= _vm->_championMan->_partyChampionCount) {
+ if (champIndex >= _vm->_championMan->_partyChampionCount)
return k0_spellCastFailure;
- }
- L1270_ps_Champion = &_vm->_championMan->_champions[champIndex];
- if (!(L1270_ps_Champion->_currHealth)) {
+
+ Champion *curChampion = &_vm->_championMan->_champions[champIndex];
+ if (!curChampion->_currHealth)
return k0_spellCastFailure;
- }
- L1271_ps_Spell = getSpellFromSymbols((unsigned char *)L1270_ps_Champion->_symbols);
- if (L1271_ps_Spell == 0) {
- menusPrintSpellFailureMessage(L1270_ps_Champion, k1_spellCastSuccess, 0);
+
+ Spell *curSpell = getSpellFromSymbols((unsigned char *)curChampion->_symbols);
+ if (!curSpell) {
+ menusPrintSpellFailureMessage(curChampion, k1_spellCastSuccess, 0);
return k0_spellCastFailure;
}
- L1268_i_PowerSymbolOrdinal = L1270_ps_Champion->_symbols[0] - '_'; /* Values 1 to 6 */
- AL1269_ui_RequiredSkillLevel = L1271_ps_Spell->_baseRequiredSkillLevel + L1268_i_PowerSymbolOrdinal;
- L1273_ui_Experience = _vm->getRandomNumber(8) + (AL1269_ui_RequiredSkillLevel << 4) + ((_vm->ordinalToIndex(L1268_i_PowerSymbolOrdinal) * L1271_ps_Spell->_baseRequiredSkillLevel) << 3) + (AL1269_ui_RequiredSkillLevel * AL1269_ui_RequiredSkillLevel);
- AL1267_ui_SkillLevel = _vm->_championMan->getSkillLevel(champIndex, L1271_ps_Spell->_skillIndex);
- if (AL1267_ui_SkillLevel < AL1269_ui_RequiredSkillLevel) {
- L1274_i_MissingSkillLevelCount = AL1269_ui_RequiredSkillLevel - AL1267_ui_SkillLevel;
- while (L1274_i_MissingSkillLevelCount--) {
- if (_vm->getRandomNumber(128) > MIN(L1270_ps_Champion->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent] + 15, 115)) {
- _vm->_championMan->addSkillExperience(champIndex, L1271_ps_Spell->_skillIndex, L1273_ui_Experience >> (AL1269_ui_RequiredSkillLevel - AL1267_ui_SkillLevel));
- menusPrintSpellFailureMessage(L1270_ps_Champion, k0_failureNeedsMorePractice, L1271_ps_Spell->_skillIndex);
+ int16 powerSymbolOrdinal = curChampion->_symbols[0] - '_'; /* Values 1 to 6 */
+ uint16 requiredSkillLevel = curSpell->_baseRequiredSkillLevel + powerSymbolOrdinal;
+ uint16 experience = _vm->getRandomNumber(8) + (requiredSkillLevel << 4) + ((_vm->ordinalToIndex(powerSymbolOrdinal) * curSpell->_baseRequiredSkillLevel) << 3) + (requiredSkillLevel * requiredSkillLevel);
+ uint16 skillLevel = _vm->_championMan->getSkillLevel(champIndex, curSpell->_skillIndex);
+ if (skillLevel < requiredSkillLevel) {
+ int16 missingSkillLevelCount = requiredSkillLevel - skillLevel;
+ while (missingSkillLevelCount--) {
+ if (_vm->getRandomNumber(128) > MIN(curChampion->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent] + 15, 115)) {
+ _vm->_championMan->addSkillExperience(champIndex, curSpell->_skillIndex, experience >> (requiredSkillLevel - skillLevel));
+ menusPrintSpellFailureMessage(curChampion, k0_failureNeedsMorePractice, curSpell->_skillIndex);
return k0_spellCastFailure;
}
}
}
- switch (L1271_ps_Spell->getKind()) {
- case k1_spellKindPotion:
- if ((L1275_ps_Potion = getEmptyFlaskInHand(L1270_ps_Champion, &L1272_T_Object)) == NULL) {
- menusPrintSpellFailureMessage(L1270_ps_Champion, k10_failureNeedsFlaskInHand, 0);
+ switch (curSpell->getKind()) {
+ case k1_spellKindPotion: {
+ Thing newObject;
+ Potion *newPotion = getEmptyFlaskInHand(curChampion, &newObject);
+ if (!newPotion) {
+ menusPrintSpellFailureMessage(curChampion, k10_failureNeedsFlaskInHand, 0);
return k3_spellCastFailureNeedsFlask;
}
- AL1269_ui_EmptyFlaskWeight = _vm->_dungeonMan->getObjectWeight(L1272_T_Object);
- L1275_ps_Potion->setType((PotionType)L1271_ps_Spell->getType());
- L1275_ps_Potion->setPower(_vm->getRandomNumber(16) + (L1268_i_PowerSymbolOrdinal * 40));
- L1270_ps_Champion->_load += _vm->_dungeonMan->getObjectWeight(L1272_T_Object) - AL1269_ui_EmptyFlaskWeight;
+ uint16 emptyFlaskWeight = _vm->_dungeonMan->getObjectWeight(newObject);
+ newPotion->setType((PotionType)curSpell->getType());
+ newPotion->setPower(_vm->getRandomNumber(16) + (powerSymbolOrdinal * 40));
+ curChampion->_load += _vm->_dungeonMan->getObjectWeight(newObject) - emptyFlaskWeight;
_vm->_championMan->drawChangedObjectIcons();
if (_vm->_inventoryMan->_inventoryChampionOrdinal == _vm->indexToOrdinal(champIndex)) {
- setFlag(L1270_ps_Champion->_attributes, k0x0200_ChampionAttributeLoad);
+ setFlag(curChampion->_attributes, k0x0200_ChampionAttributeLoad);
_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
}
+ }
break;
case k2_spellKindProjectile:
- if (L1270_ps_Champion->_dir != _vm->_dungeonMan->_partyDir) {
- L1270_ps_Champion->_dir = _vm->_dungeonMan->_partyDir;
- setFlag(L1270_ps_Champion->_attributes, k0x0400_ChampionAttributeIcon);
+ if (curChampion->_dir != _vm->_dungeonMan->_partyDir) {
+ curChampion->_dir = _vm->_dungeonMan->_partyDir;
+ setFlag(curChampion->_attributes, k0x0400_ChampionAttributeIcon);
_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
}
- if (L1271_ps_Spell->getType() == k4_spellType_projectileOpenDoor) {
- AL1267_ui_SkillLevel <<= 1;
- }
- _vm->_championMan->isProjectileSpellCast(champIndex, Thing(L1271_ps_Spell->getType() + Thing::_firstExplosion.toUint16()), getBoundedValue(21, (L1268_i_PowerSymbolOrdinal + 2) * (4 + (AL1267_ui_SkillLevel << 1)), 255), 0);
+ if (curSpell->getType() == k4_spellType_projectileOpenDoor)
+ skillLevel <<= 1;
+
+ _vm->_championMan->isProjectileSpellCast(champIndex, Thing(curSpell->getType() + Thing::_firstExplosion.toUint16()), getBoundedValue(21, (powerSymbolOrdinal + 2) * (4 + (skillLevel << 1)), 255), 0);
break;
- case k3_spellKindOther:
- L1276_s_Event._priority = 0;
- AL1267_ui_SpellPower = (L1268_i_PowerSymbolOrdinal + 1) << 2;
- switch (L1271_ps_Spell->getType()) {
- case k0_spellType_otherLight:
- AL1269_ui_Ticks = 10000 + ((AL1267_ui_SpellPower - 8) << 9);
- AL1267_ui_LightPower = (AL1267_ui_SpellPower >> 1);
- AL1267_ui_LightPower--;
- goto T0412019;
- case k5_spellType_otherMagicTorch:
- AL1269_ui_Ticks = 2000 + ((AL1267_ui_SpellPower - 3) << 7);
- AL1267_ui_LightPower = (AL1267_ui_SpellPower >> 2);
- AL1267_ui_LightPower++;
-T0412019:
- _vm->_championMan->_party._magicalLightAmount += _vm->_championMan->_lightPowerToLightAmount[AL1267_ui_LightPower];
- createEvent70_light(-AL1267_ui_LightPower, AL1269_ui_Ticks);
+ case k3_spellKindOther: {
+ TimelineEvent newEvent;
+ newEvent._priority = 0;
+ uint16 spellPower = (powerSymbolOrdinal + 1) << 2;
+ uint16 ticks;
+ switch (curSpell->getType()) {
+ case k0_spellType_otherLight: {
+ ticks = 10000 + ((spellPower - 8) << 9);
+ uint16 lightPower = (spellPower >> 1);
+ lightPower--;
+ _vm->_championMan->_party._magicalLightAmount += _vm->_championMan->_lightPowerToLightAmount[lightPower];
+ createEvent70_light(-lightPower, ticks);
+ }
break;
- case k1_spellType_otherDarkness:
- AL1267_ui_LightPower = (AL1267_ui_SpellPower >> 2);
- _vm->_championMan->_party._magicalLightAmount -= _vm->_championMan->_lightPowerToLightAmount[AL1267_ui_LightPower];
- createEvent70_light(AL1267_ui_LightPower, 98);
+ case k5_spellType_otherMagicTorch: {
+ ticks = 2000 + ((spellPower - 3) << 7);
+ uint16 lightPower = (spellPower >> 2);
+ lightPower++;
+ _vm->_championMan->_party._magicalLightAmount += _vm->_championMan->_lightPowerToLightAmount[lightPower];
+ createEvent70_light(-lightPower, ticks);
+ }
+ break;
+ case k1_spellType_otherDarkness: {
+ uint16 lightPower = (spellPower >> 2);
+ _vm->_championMan->_party._magicalLightAmount -= _vm->_championMan->_lightPowerToLightAmount[lightPower];
+ createEvent70_light(lightPower, 98);
+ }
break;
- case k2_spellType_otherThievesEye:
- L1276_s_Event._type = k73_TMEventTypeThievesEye;
+ case k2_spellType_otherThievesEye: {
+ newEvent._type = k73_TMEventTypeThievesEye;
_vm->_championMan->_party._event73Count_ThievesEye++;
- AL1267_ui_SpellPower = (AL1267_ui_SpellPower >> 1);
- goto T0412032;
- case k3_spellType_otherInvisibility:
- L1276_s_Event._type = k71_TMEventTypeInvisibility;
+ spellPower = (spellPower >> 1);
+ uint16 spellTicks = spellPower * spellPower;
+ setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + spellTicks);
+ _vm->_timeline->addEventGetEventIndex(&newEvent);
+ }
+ break;
+ case k3_spellType_otherInvisibility: {
+ newEvent._type = k71_TMEventTypeInvisibility;
_vm->_championMan->_party._event71Count_Invisibility++;
- goto T0412033;
- case k4_spellType_otherPartyShield:
- L1276_s_Event._type = k74_TMEventTypePartyShield;
- L1276_s_Event._B._defense = AL1267_ui_SpellPower;
- if (_vm->_championMan->_party._shieldDefense > 50) {
- L1276_s_Event._B._defense >>= 2;
+ uint16 spellTicks = spellPower;
+ setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + spellTicks);
+ _vm->_timeline->addEventGetEventIndex(&newEvent);
}
- _vm->_championMan->_party._shieldDefense += L1276_s_Event._B._defense;
+ break;
+ case k4_spellType_otherPartyShield: {
+ newEvent._type = k74_TMEventTypePartyShield;
+ newEvent._B._defense = spellPower;
+ if (_vm->_championMan->_party._shieldDefense > 50)
+ newEvent._B._defense >>= 2;
+
+ _vm->_championMan->_party._shieldDefense += newEvent._B._defense;
_vm->_timeline->refreshAllChampionStatusBoxes();
- goto T0412032;
- case k6_spellType_otherFootprints:
- L1276_s_Event._type = k79_TMEventTypeFootprints;
+ uint16 spellTicks = spellPower * spellPower;
+ setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + spellTicks);
+ _vm->_timeline->addEventGetEventIndex(&newEvent);
+ }
+ break;
+ case k6_spellType_otherFootprints: {
+ newEvent._type = k79_TMEventTypeFootprints;
_vm->_championMan->_party._event79Count_Footprints++;
_vm->_championMan->_party._firstScentIndex = _vm->_championMan->_party._scentCount;
- if (L1268_i_PowerSymbolOrdinal < 3) {
+ if (powerSymbolOrdinal < 3)
_vm->_championMan->_party._lastScentIndex = _vm->_championMan->_party._firstScentIndex;
- } else {
+ else
_vm->_championMan->_party._lastScentIndex = 0;
+
+ uint16 spellTicks = spellPower * spellPower;
+ setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + spellTicks);
+ _vm->_timeline->addEventGetEventIndex(&newEvent);
}
-T0412032:
- AL1267_ui_Ticks = AL1267_ui_SpellPower * AL1267_ui_SpellPower;
-T0412033:
- setMapAndTime(L1276_s_Event._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + AL1267_ui_Ticks);
- _vm->_timeline->addEventGetEventIndex(&L1276_s_Event);
break;
- case k7_spellType_otherZokathra:
- if ((L1272_T_Object = _vm->_dungeonMan->getUnusedThing(k10_JunkThingType)) == Thing::_none)
+ case k7_spellType_otherZokathra: {
+ Thing unusedObject = _vm->_dungeonMan->getUnusedThing(k10_JunkThingType);
+ if (unusedObject == Thing::_none)
break;
- L1277_ps_Junk = (Junk*)_vm->_dungeonMan->getThingData(L1272_T_Object);
- L1277_ps_Junk->setType(k51_JunkTypeZokathra);
- ChampionSlot AL1267_ui_SlotIndex;
- if (L1270_ps_Champion->_slots[k0_ChampionSlotReadyHand] == Thing::_none) {
- AL1267_ui_SlotIndex = k0_ChampionSlotReadyHand;
- } else {
- if (L1270_ps_Champion->_slots[k1_ChampionSlotActionHand] == Thing::_none) {
- AL1267_ui_SlotIndex = k1_ChampionSlotActionHand;
- } else {
- AL1267_ui_SlotIndex = kM1_ChampionSlotLeaderHand;
- }
- }
- if ((AL1267_ui_SlotIndex == k0_ChampionSlotReadyHand) || (AL1267_ui_SlotIndex == k1_ChampionSlotActionHand)) {
- _vm->_championMan->addObjectInSlot((ChampionIndex)champIndex, L1272_T_Object, AL1267_ui_SlotIndex);
+
+ Junk *junkData = (Junk *)_vm->_dungeonMan->getThingData(unusedObject);
+ junkData->setType(k51_JunkTypeZokathra);
+ ChampionSlot slotIndex;
+ if (curChampion->_slots[k0_ChampionSlotReadyHand] == Thing::_none)
+ slotIndex = k0_ChampionSlotReadyHand;
+ else if (curChampion->_slots[k1_ChampionSlotActionHand] == Thing::_none)
+ slotIndex = k1_ChampionSlotActionHand;
+ else
+ slotIndex = kM1_ChampionSlotLeaderHand;
+
+ if ((slotIndex == k0_ChampionSlotReadyHand) || (slotIndex == k1_ChampionSlotActionHand)) {
+ _vm->_championMan->addObjectInSlot((ChampionIndex)champIndex, unusedObject, slotIndex);
_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
- } else {
- _vm->_moveSens->getMoveResult(L1272_T_Object, kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY);
+ } else
+ _vm->_moveSens->getMoveResult(unusedObject, kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY);
+
}
break;
case k8_spellType_otherFireshield:
- isPartySpellOrFireShieldSuccessful(L1270_ps_Champion, false, (AL1267_ui_SpellPower * AL1267_ui_SpellPower) + 100, false);
+ isPartySpellOrFireShieldSuccessful(curChampion, false, (spellPower * spellPower) + 100, false);
+ break;
+ default:
+ break;
+ }
}
}
- _vm->_championMan->addSkillExperience(champIndex, L1271_ps_Spell->_skillIndex, L1273_ui_Experience);
- _vm->_championMan->disableAction(champIndex, L1271_ps_Spell->getDuration());
+ _vm->_championMan->addSkillExperience(champIndex, curSpell->_skillIndex, experience);
+ _vm->_championMan->disableAction(champIndex, curSpell->getDuration());
return k1_spellCastSuccess;
}
-Spell* MenuMan::getSpellFromSymbols(byte* symbols) {
- static Spell G0487_as_Graphic560_Spells[25] = {
+Spell *MenuMan::getSpellFromSymbols(byte *symbols) {
+ static Spell SpellsArray[25] = {
/* { Symbols, BaseRequiredSkillLevel, SkillIndex, Attributes } */
Spell(0x00666F00, 2, 15, 0x7843),
Spell(0x00667073, 1, 18, 0x4863),
@@ -666,31 +716,33 @@ Spell* MenuMan::getSpellFromSymbols(byte* symbols) {
};
if (*(symbols + 1)) {
- int16 AL1262_i_BitShiftCount = 24;
- int32 L1261_l_Symbols = 0;
- do {
- L1261_l_Symbols |= (long)*symbols++ << AL1262_i_BitShiftCount;
- } while (*symbols && ((AL1262_i_BitShiftCount -= 8) >= 0));
- Spell *L1263_ps_Spell = G0487_as_Graphic560_Spells;
- int16 AL1262_i_SpellIndex = 25;
- while (AL1262_i_SpellIndex--) {
- if (L1263_ps_Spell->_symbols & 0xFF000000) { /* If byte 1 of spell is not 0 then the spell includes the power symbol */
- if (L1261_l_Symbols == L1263_ps_Spell->_symbols) { /* Compare champion symbols, including power symbol, with spell (never used with actual spells) */
- return L1263_ps_Spell;
+ int16 bitShiftCount = 24;
+ int32 curSymbols = 0;
+ do
+ curSymbols |= (long)*symbols++ << bitShiftCount;
+ while (*symbols && ((bitShiftCount -= 8) >= 0));
+ Spell *curSpell = SpellsArray;
+ int16 spellIndex = 25;
+ while (spellIndex--) {
+ if (curSpell->_symbols & 0xFF000000) { /* If byte 1 of spell is not 0 then the spell includes the power symbol */
+ if (curSymbols == curSpell->_symbols) { /* Compare champion symbols, including power symbol, with spell (never used with actual spells) */
+ return curSpell;
}
- } else {
- if ((L1261_l_Symbols & 0x00FFFFFF) == L1263_ps_Spell->_symbols) { /* Compare champion symbols, except power symbol, with spell */
- return L1263_ps_Spell;
- }
- }
- L1263_ps_Spell++;
+ } else if ((curSymbols & 0x00FFFFFF) == curSpell->_symbols) /* Compare champion symbols, except power symbol, with spell */
+ return curSpell;
+
+ curSpell++;
}
}
- return NULL;
+ return nullptr;
}
-void MenuMan::menusPrintSpellFailureMessage(Champion* champ, uint16 failureType, uint16 skillIndex) {
- const char *L1264_pc_Message = nullptr;
+void MenuMan::menusPrintSpellFailureMessage(Champion *champ, uint16 failureType, uint16 skillIndex) {
+ const char *messagesEN[4] = {" NEEDS MORE PRACTICE WITH THIS ", " SPELL.", " MUMBLES A MEANINGLESS SPELL."," NEEDS AN EMPTY FLASK IN HAND FOR POTION."};
+ const char *messagesDE[4] = {" BRAUCHT MEHR UEBUNG MIT DIESEM ", " ZAUBERSPRUCH.",
+ " MURMELT EINEN SINNLOSEN ZAUBERSPRUCH.", " MUSS FUER DEN TRANK EINE LEERE FLASCHE BEREITHALTEN."};
+ const char *messagesFR[5] = {" DOIT PRATIQUER DAVANTAGE SON ", "ENVOUTEMENT.", " MARMONNE UNE CONJURATION IMCOMPREHENSIBLE.",
+ " DOIT AVOIR UN FLACON VIDE EN MAIN POUR LA POTION.", "EXORCISME."};
if (skillIndex > k3_ChampionSkillWizard)
skillIndex = (skillIndex - 4) / 4;
@@ -698,263 +750,198 @@ void MenuMan::menusPrintSpellFailureMessage(Champion* champ, uint16 failureType,
_vm->_textMan->printLineFeed();
_vm->_textMan->printMessage(k4_ColorCyan, champ->_name);
- const char *messages_EN_ANY[4] = {" NEEDS MORE PRACTICE WITH THIS ", " SPELL.", " MUMBLES A MEANINGLESS SPELL."," NEEDS AN EMPTY FLASK IN HAND FOR POTION."};
- const char *messages_DE_DEU[4] = {" BRAUCHT MEHR UEBUNG MIT DIESEM ", " ZAUBERSPRUCH.",
- " MURMELT EINEN SINNLOSEN ZAUBERSPRUCH.", " MUSS FUER DEN TRANK EINE LEERE FLASCHE BEREITHALTEN."};
- const char *messages_FR_FRA[5] = {" DOIT PRATIQUER DAVANTAGE SON ", "ENVOUTEMENT.", " MARMONNE UNE CONJURATION IMCOMPREHENSIBLE.",
- " DOIT AVOIR UN FLACON VIDE EN MAIN POUR LA POTION.", "EXORCISME."};
const char **messages;
switch (_vm->getGameLanguage()) { // localized
- default:
- case Common::EN_ANY:
- messages = messages_EN_ANY; break;
case Common::DE_DEU:
- messages = messages_DE_DEU; break;
+ messages = messagesDE;
+ break;
case Common::FR_FRA:
- messages = messages_FR_FRA; break;
+ messages = messagesFR;
+ break;
+ default:
+ messages = messagesEN;
+ break;
}
+ const char *message = nullptr;
switch (failureType) {
case k0_failureNeedsMorePractice:
_vm->_textMan->printMessage(k4_ColorCyan, messages[0]);
_vm->_textMan->printMessage(k4_ColorCyan, _vm->_championMan->_baseSkillName[skillIndex]);
if (_vm->getGameLanguage() != Common::FR_FRA || skillIndex == k3_ChampionSkillWizard)
- L1264_pc_Message = messages[1];
+ message = messages[1];
else
- L1264_pc_Message = messages[4];
+ message = messages[4];
break;
case k1_failureMeaninglessSpell:
- L1264_pc_Message = messages[2];
+ message = messages[2];
break;
case k10_failureNeedsFlaskInHand:
- L1264_pc_Message = messages[3];
+ message = messages[3];
break;
}
- _vm->_textMan->printMessage(k4_ColorCyan, L1264_pc_Message);
+ _vm->_textMan->printMessage(k4_ColorCyan, message);
}
-Potion* MenuMan::getEmptyFlaskInHand(Champion* champ, Thing* potionThing) {
- Thing L1265_T_Thing;
- int16 L1266_i_SlotIndex;
-
- for (L1266_i_SlotIndex = k2_ChampionSlotHead; --L1266_i_SlotIndex >= k0_ChampionSlotReadyHand; ) {
- if (((L1265_T_Thing = champ->_slots[L1266_i_SlotIndex]) != Thing::_none) && (_vm->_objectMan->getIconIndex(L1265_T_Thing) == k195_IconIndicePotionEmptyFlask)) {
- *potionThing = L1265_T_Thing;
- return (Potion*)_vm->_dungeonMan->getThingData(L1265_T_Thing);
+Potion *MenuMan::getEmptyFlaskInHand(Champion *champ, Thing *potionThing) {
+ for (int16 slotIndex = k2_ChampionSlotHead; --slotIndex >= k0_ChampionSlotReadyHand; ) {
+ Thing curThing = champ->_slots[slotIndex];
+ if ((curThing != Thing::_none) && (_vm->_objectMan->getIconIndex(curThing) == k195_IconIndicePotionEmptyFlask)) {
+ *potionThing = curThing;
+ return (Potion *)_vm->_dungeonMan->getThingData(curThing);
}
}
return nullptr;
}
void MenuMan::createEvent70_light(int16 lightPower, int16 ticks) {
- TimelineEvent L1241_s_Event;
-
- L1241_s_Event._type = k70_TMEventTypeLight;
- L1241_s_Event._B._lightPower = lightPower;
- setMapAndTime(L1241_s_Event._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + ticks);
- L1241_s_Event._priority = 0;
- _vm->_timeline->addEventGetEventIndex(&L1241_s_Event);
+ TimelineEvent newEvent;
+ newEvent._type = k70_TMEventTypeLight;
+ newEvent._B._lightPower = lightPower;
+ setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + ticks);
+ newEvent._priority = 0;
+ _vm->_timeline->addEventGetEventIndex(&newEvent);
_vm->_inventoryMan->setDungeonViewPalette();
}
-bool MenuMan::isPartySpellOrFireShieldSuccessful(Champion* champ, bool spellShield, uint16 ticks, bool useMana) {
- bool L1239_B_IsPartySpellOrFireShieldSuccessful;
- TimelineEvent L1240_s_Event;
-
-
- L1239_B_IsPartySpellOrFireShieldSuccessful = true;
+bool MenuMan::isPartySpellOrFireShieldSuccessful(Champion *champ, bool spellShield, uint16 ticks, bool useMana) {
+ bool isPartyMagicShieldSuccessful = true;
if (useMana) {
- if (champ->_currMana == 0) {
+ if (champ->_currMana == 0)
return false;
- }
+
if (champ->_currMana < 4) {
ticks >>= 1;
champ->_currMana = 0;
- L1239_B_IsPartySpellOrFireShieldSuccessful = false;
- } else {
+ isPartyMagicShieldSuccessful = false;
+ } else
champ->_currMana -= 4;
- }
}
- L1240_s_Event._B._defense = ticks >> 5;
+ TimelineEvent newEvent;
+ newEvent._B._defense = ticks >> 5;
if (spellShield) {
- L1240_s_Event._type = k77_TMEventTypeSpellShield;
- if (_vm->_championMan->_party._spellShieldDefense > 50) {
- L1240_s_Event._B._defense >>= 2;
- }
- _vm->_championMan->_party._spellShieldDefense += L1240_s_Event._B._defense;
+ newEvent._type = k77_TMEventTypeSpellShield;
+ if (_vm->_championMan->_party._spellShieldDefense > 50)
+ newEvent._B._defense >>= 2;
+
+ _vm->_championMan->_party._spellShieldDefense += newEvent._B._defense;
} else {
- L1240_s_Event._type = k78_TMEventTypeFireShield;
- if (_vm->_championMan->_party._fireShieldDefense > 50) {
- L1240_s_Event._B._defense >>= 2;
- }
- _vm->_championMan->_party._fireShieldDefense += L1240_s_Event._B._defense;
+ newEvent._type = k78_TMEventTypeFireShield;
+ if (_vm->_championMan->_party._fireShieldDefense > 50)
+ newEvent._B._defense >>= 2;
+
+ _vm->_championMan->_party._fireShieldDefense += newEvent._B._defense;
}
- L1240_s_Event._priority = 0;
- setMapAndTime(L1240_s_Event._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + ticks);
- _vm->_timeline->addEventGetEventIndex(&L1240_s_Event);
+ newEvent._priority = 0;
+ setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + ticks);
+ _vm->_timeline->addEventGetEventIndex(&newEvent);
_vm->_timeline->refreshAllChampionStatusBoxes();
- return L1239_B_IsPartySpellOrFireShieldSuccessful;
+
+ return isPartyMagicShieldSuccessful;
}
void MenuMan::drawAvailableSymbols(uint16 symbolStep) {
- uint16 L1214_ui_Counter;
- int16 L1215_i_X;
- char L1216_c_Character;
- char L1217_ac_String[2];
-
- L1217_ac_String[1] = '\0';
- L1216_c_Character = 96 + 6 * symbolStep;
- L1215_i_X = 225;
- for (L1214_ui_Counter = 0; L1214_ui_Counter < 6; L1214_ui_Counter++) {
- L1217_ac_String[0] = L1216_c_Character++;
- _vm->_textMan->printToLogicalScreen(L1215_i_X += 14, 58, k4_ColorCyan, k0_ColorBlack, L1217_ac_String);
+ char displayBuffer[2];
+ displayBuffer[1] = '\0';
+ char curCharacter = 96 + 6 * symbolStep;
+ int16 textPosX = 225;
+ for (uint16 L1214_ui_Counter = 0; L1214_ui_Counter < 6; L1214_ui_Counter++) {
+ displayBuffer[0] = curCharacter++;
+ textPosX += 14;
+ _vm->_textMan->printToLogicalScreen(textPosX, 58, k4_ColorCyan, k0_ColorBlack, displayBuffer);
}
}
-void MenuMan::drawChampionSymbols(Champion* champ) {
- uint16 L1218_ui_SymbolIndex;
- int16 L1219_i_X;
- uint16 L1220_ui_SymbolCount;
- char L1221_ac_String[2];
+void MenuMan::drawChampionSymbols(Champion *champ) {
+ uint16 symbolCount = strlen(champ->_symbols);
+ int16 textPosX = 232;
+ char displayBuffer[2];
+ displayBuffer[1] = '\0';
+ for (uint16 symbolIndex = 0; symbolIndex < 4; symbolIndex++) {
+ if (symbolIndex >= symbolCount)
+ displayBuffer[0] = ' ';
+ else
+ displayBuffer[0] = champ->_symbols[symbolIndex];
- L1220_ui_SymbolCount = strlen(champ->_symbols);
- L1219_i_X = 232;
- L1221_ac_String[1] = '\0';
- for (L1218_ui_SymbolIndex = 0; L1218_ui_SymbolIndex < 4; L1218_ui_SymbolIndex++) {
- if (L1218_ui_SymbolIndex >= L1220_ui_SymbolCount) {
- L1221_ac_String[0] = ' ';
- } else {
- L1221_ac_String[0] = champ->_symbols[L1218_ui_SymbolIndex];
- }
- _vm->_textMan->printToLogicalScreen(L1219_i_X += 9, 70, k4_ColorCyan, k0_ColorBlack, L1221_ac_String);
+ textPosX += 9;
+ _vm->_textMan->printToLogicalScreen(textPosX, 70, k4_ColorCyan, k0_ColorBlack, displayBuffer);
}
}
void MenuMan::addChampionSymbol(int16 symbolIndex) {
- static byte G0485_aauc_Graphic560_SymbolBaseManaCost[4][6] = {
+ static byte symbolBaseManaCost[4][6] = {
{1, 2, 3, 4, 5, 6}, /* Power 1 */
{2, 3, 4, 5, 6, 7}, /* Power 2 */
{4, 5, 6, 7, 7, 9}, /* Power 3 */
{2, 2, 3, 4, 6, 7} /* Power 4 */
};
- static byte G0486_auc_Graphic560_SymbolManaCostMultiplier[6] = {8, 12, 16, 20, 24, 28};
-
- uint16 L1222_ui_SymbolStep;
- uint16 L1223_ui_ManaCost;
- uint16 L1224_ui_SymbolIndex;
- Champion *L1225_ps_Champion;
-
- L1225_ps_Champion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex];
- L1222_ui_SymbolStep = L1225_ps_Champion->_symbolStep;
- L1223_ui_ManaCost = G0485_aauc_Graphic560_SymbolBaseManaCost[L1222_ui_SymbolStep][symbolIndex];
- if (L1222_ui_SymbolStep) {
- L1223_ui_ManaCost = (L1223_ui_ManaCost * G0486_auc_Graphic560_SymbolManaCostMultiplier[L1224_ui_SymbolIndex = L1225_ps_Champion->_symbols[0] - 96]) >> 3;
+ static byte symbolManaCostMultiplier[6] = {8, 12, 16, 20, 24, 28};
+
+ Champion *casterChampion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex];
+ uint16 symbolStep = casterChampion->_symbolStep;
+ uint16 manaCost = symbolBaseManaCost[symbolStep][symbolIndex];
+ if (symbolStep) {
+ uint16 symbolIndex = casterChampion->_symbols[0] - 96;
+ manaCost = (manaCost * symbolManaCostMultiplier[symbolIndex]) >> 3;
}
- if (L1223_ui_ManaCost <= L1225_ps_Champion->_currMana) {
- L1225_ps_Champion->_currMana -= L1223_ui_ManaCost;
- setFlag(L1225_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
- L1225_ps_Champion->_symbols[L1222_ui_SymbolStep] = 96 + (L1222_ui_SymbolStep * 6) + symbolIndex;
- L1225_ps_Champion->_symbols[L1222_ui_SymbolStep + 1] = '\0';
- L1225_ps_Champion->_symbolStep = L1222_ui_SymbolStep = returnNextVal(L1222_ui_SymbolStep);
+
+ if (manaCost <= casterChampion->_currMana) {
+ casterChampion->_currMana -= manaCost;
+ setFlag(casterChampion->_attributes, k0x0100_ChampionAttributeStatistics);
+ casterChampion->_symbols[symbolStep] = 96 + (symbolStep * 6) + symbolIndex;
+ casterChampion->_symbols[symbolStep + 1] = '\0';
+ casterChampion->_symbolStep = symbolStep = returnNextVal(symbolStep);
_vm->_eventMan->showMouse();
- drawAvailableSymbols(L1222_ui_SymbolStep);
- drawChampionSymbols(L1225_ps_Champion);
+ drawAvailableSymbols(symbolStep);
+ drawChampionSymbols(casterChampion);
_vm->_championMan->drawChampionState(_vm->_championMan->_magicCasterChampionIndex);
_vm->_eventMan->hideMouse();
}
}
void MenuMan::deleteChampionSymbol() {
- int16 L1226_ui_SymbolStep;
- Champion *L1228_ps_Champion;
-
- L1228_ps_Champion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex];
- if (!strlen(L1228_ps_Champion->_symbols)) {
+ Champion *casterChampion = &_vm->_championMan->_champions[_vm->_championMan->_magicCasterChampionIndex];
+ if (!strlen(casterChampion->_symbols))
return;
- }
- L1228_ps_Champion->_symbolStep = L1226_ui_SymbolStep = returnPrevVal(L1228_ps_Champion->_symbolStep);
- L1228_ps_Champion->_symbols[L1226_ui_SymbolStep] = '\0';
+
+ int16 symbolStep = returnPrevVal(casterChampion->_symbolStep);
+ casterChampion->_symbolStep = symbolStep;
+ casterChampion->_symbols[symbolStep] = '\0';
_vm->_eventMan->showMouse();
- drawAvailableSymbols(L1226_ui_SymbolStep);
- drawChampionSymbols(L1228_ps_Champion);
+ drawAvailableSymbols(symbolStep);
+ drawChampionSymbols(casterChampion);
_vm->_eventMan->hideMouse();
}
bool MenuMan::didClickTriggerAction(int16 actionListIndex) {
- uint16 L1196_ui_ChampionIndex;
- uint16 L1197_ui_ActionIndex;
- bool L1198_B_ClickTriggeredAction;
- Champion* L1199_ps_Champion;
-
+ bool retVal = false;
if (!_vm->_championMan->_actingChampionOrdinal || (actionListIndex != -1 && (_actionList._actionIndices[actionListIndex] == k255_ChampionActionNone)))
- return false;
-
- L1199_ps_Champion = &_vm->_championMan->_champions[L1196_ui_ChampionIndex = _vm->ordinalToIndex(_vm->_championMan->_actingChampionOrdinal)];
- if (actionListIndex == -1) {
- // L1198_B_ClickTriggeredAction is set to -1 since booleans are stored in int16 in the original
- L1198_B_ClickTriggeredAction = true;
- } else {
- L1197_ui_ActionIndex = _actionList._actionIndices[actionListIndex];
- L1199_ps_Champion->_actionDefense += _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 = isActionPerformed(L1196_ui_ChampionIndex, L1197_ui_ActionIndex);
- L1199_ps_Champion->_actionIndex = (ChampionAction)L1197_ui_ActionIndex;
+ return retVal;
+
+ uint16 championIndex = _vm->ordinalToIndex(_vm->_championMan->_actingChampionOrdinal);
+ Champion *curChampion = &_vm->_championMan->_champions[championIndex];
+ if (actionListIndex == -1)
+ retVal = true;
+ else {
+ uint16 actionIndex = _actionList._actionIndices[actionListIndex];
+ // Fix original bug - When disabled ticks is equal to zero, increasing the defense leads
+ // to a permanent increment.
+ if (_actionDisabledTicks[actionIndex])
+ curChampion->_actionDefense += _actionDefense[actionIndex];
+
+ setFlag(curChampion->_attributes, k0x0100_ChampionAttributeStatistics);
+ retVal = isActionPerformed(championIndex, actionIndex);
+ curChampion->_actionIndex = (ChampionAction)actionIndex;
}
clearActingChampion();
- return L1198_B_ClickTriggeredAction;
+ return retVal;
}
bool MenuMan::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] = {
+ static unsigned char actionStaminaArray[44] = {
0, /* N */
4, /* BLOCK */
10, /* CHOP */
@@ -998,8 +985,9 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
3, /* SPIT */
2, /* BRANDISH */
0, /* THROW */
- 2}; /* FUSE */
- static unsigned char G0497_auc_Graphic560_ActionExperienceGain[44] = {
+ 2 /* FUSE */
+ };
+ static unsigned char actionExperienceGainArray[44] = {
0, /* N */
8, /* BLOCK */
10, /* CHOP */
@@ -1043,85 +1031,57 @@ bool MenuMan::isActionPerformed(uint16 champIndex, int16 actionIndex) {
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 = 0;
-#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->_partyChampionCount) {
+ 1 /* FUSE */
+ };
+
+ if (champIndex >= _vm->_championMan->_partyChampionCount)
return false;
- }
- L1247_ps_Champion = &_vm->_championMan->_champions[champIndex];
- L1248_ps_Weapon = (Weapon*)_vm->_dungeonMan->getThingData(L1247_ps_Champion->_slots[k1_ChampionSlotActionHand]);
- if (!L1247_ps_Champion->_currHealth) {
+
+ Champion *curChampion = &_vm->_championMan->_champions[champIndex];
+ if (!curChampion->_currHealth)
return false;
- }
- L1251_i_MapX = _vm->_dungeonMan->_partyMapX;
- L1252_i_MapY = _vm->_dungeonMan->_partyMapY;
- L1251_i_MapX += _vm->_dirIntoStepCountEast[L1247_ps_Champion->_dir], L1252_i_MapY += _vm->_dirIntoStepCountNorth[L1247_ps_Champion->_dir];
- _actionTargetGroupThing = _vm->_groupMan->groupGetThing(L1251_i_MapX, L1252_i_MapY);
- L1249_ui_ActionDisabledTicks = G0491_auc_Graphic560_ActionDisabledTicks[actionIndex];
- L1254_i_ActionSkillIndex = _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->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->getSkillLevel(champIndex, L1254_i_ActionSkillIndex));
- }
+
+ Weapon *weaponInHand = (Weapon *)_vm->_dungeonMan->getThingData(curChampion->_slots[k1_ChampionSlotActionHand]);
+
+ int16 nextMapX = _vm->_dungeonMan->_partyMapX;
+ int16 nextMapY = _vm->_dungeonMan->_partyMapY;
+ nextMapX += _vm->_dirIntoStepCountEast[curChampion->_dir];
+ nextMapY += _vm->_dirIntoStepCountNorth[curChampion->_dir];
+ _actionTargetGroupThing = _vm->_groupMan->groupGetThing(nextMapX, nextMapY);
+ uint16 actionDisabledTicks = _actionDisabledTicks[actionIndex];
+ int16 actionSkillIndex = _actionSkillIndex[actionIndex];
+ int16 actionStamina = actionStaminaArray[actionIndex] + _vm->getRandomNumber(2);
+ int16 actionExperienceGain = actionExperienceGainArray[actionIndex];
+ uint16 targetSquare = _vm->_dungeonMan->getSquare(nextMapX, nextMapY).toByte();
+
+ int16 requiredManaAmount = 0;
+ if (((actionSkillIndex >= k16_ChampionSkillFire) && (actionSkillIndex <= k19_ChampionSkillWater)) || (actionSkillIndex == k3_ChampionSkillWizard))
+ requiredManaAmount = 7 - MIN<uint16>(6, _vm->_championMan->getSkillLevel(champIndex, actionSkillIndex));
+
+ bool setDirectionFl = false;
+ int16 kineticEnergy = 0;
+ Thing explosionThing = Thing::_none;
+ bool actionPerformed = true;
switch (actionIndex) {
case k23_ChampionActionLightning:
- AL1250_i_KineticEnergy = 180;
- AL1245_T_ExplosionThing = Thing::_explLightningBolt.toUint16();
- goto T0407014;
+ kineticEnergy = 180;
+ explosionThing = Thing::_explLightningBolt;
+ setDirectionFl = true;
+ break;
case k21_ChampionActionDispel:
- AL1250_i_KineticEnergy = 150;
- AL1245_T_ExplosionThing = Thing::_explHarmNonMaterial.toUint16();
- goto T0407014;
+ kineticEnergy = 150;
+ explosionThing = Thing::_explHarmNonMaterial;
+ setDirectionFl = true;
+ break;
case k20_ChampionActionFireball:
- AL1250_i_KineticEnergy = 150;
- goto T0407013;
+ kineticEnergy = 150;
+ explosionThing = Thing::_explFireBall;
+ setDirectionFl = true;
+ break;
case k40_ChampionActionSpit:
- AL1250_i_KineticEnergy = 250;
-T0407013:
- AL1245_T_ExplosionThing = Thing::_explFireBall.toUint16();
-T0407014:
- 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->isProjectileSpellCast(champIndex, Thing(AL1245_T_ExplosionThing), AL1250_i_KineticEnergy, AL1246_i_RequiredManaAmount))) {
- L1255_i_ActionExperienceGain >>= 1;
- }
- decrementCharges(L1247_ps_Champion);
+ kineticEnergy = 250;
+ explosionThing = Thing::_explFireBall;
+ setDirectionFl = true;
break;
case k30_ChampionActionBash:
case k18_ChampionActionHack:
@@ -1129,10 +1089,10 @@ T0407014:
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)) {
+ if ((Square(targetSquare).getType() == k4_DoorElemType) && (Square(targetSquare).getDoorState() == k4_doorState_CLOSED)) {
_vm->_sound->requestPlay(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
- L1249_ui_ActionDisabledTicks = 6;
- _vm->_groupMan->groupIsDoorDestoryedByAttack(L1251_i_MapX, L1252_i_MapY, _vm->_championMan->getStrength(champIndex, k1_ChampionSlotActionHand), false, 2);
+ actionDisabledTicks = 6;
+ _vm->_groupMan->groupIsDoorDestoryedByAttack(nextMapX, nextMapY, _vm->_championMan->getStrength(champIndex, k1_ChampionSlotActionHand), false, 2);
_vm->_sound->requestPlay(k04_soundWOODEN_THUD_ATTACK_TROLIN_ANTMAN_STONE_GOLEM, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k2_soundModePlayOneTickLater);
break;
}
@@ -1147,220 +1107,260 @@ T0407014:
case k28_ChampionActionSlash:
case k29_ChampionActionCleave:
case k6_ChampionActionPunch:
- if (!(AL1245_B_ActionPerformed = isMeleeActionPerformed(champIndex, L1247_ps_Champion, actionIndex, L1251_i_MapX, L1252_i_MapY, L1254_i_ActionSkillIndex))) {
- L1255_i_ActionExperienceGain >>= 1;
- L1249_ui_ActionDisabledTicks >>= 1;
+ if (!(actionPerformed = isMeleeActionPerformed(champIndex, curChampion, actionIndex, nextMapX, nextMapY, actionSkillIndex))) {
+ actionExperienceGain >>= 1;
+ actionDisabledTicks >>= 1;
}
break;
case k22_ChampionActionConfuse:
- decrementCharges(L1247_ps_Champion);
+ decrementCharges(curChampion);
+ // No break on purpose
case k8_ChampionActionWarCry:
case k37_ChampionActionCalm:
case k41_ChampionActionBrandish:
case k4_ChampionActionBlowHorn:
- if (actionIndex == k8_ChampionActionWarCry) {
- _vm->_sound->requestPlay(k28_soundWAR_CRY, L1251_i_MapX, L1252_i_MapY, k0_soundModePlayImmediately);
- }
- if (actionIndex == k4_ChampionActionBlowHorn) {
- _vm->_sound->requestPlay(k25_soundBLOW_HORN, L1251_i_MapX, L1252_i_MapY, k0_soundModePlayImmediately);
- }
- AL1245_B_ActionPerformed = isGroupFrightenedByAction(champIndex, actionIndex, L1251_i_MapX, L1252_i_MapY);
+ if (actionIndex == k8_ChampionActionWarCry)
+ _vm->_sound->requestPlay(k28_soundWAR_CRY, nextMapX, nextMapY, k0_soundModePlayImmediately);
+ else if (actionIndex == k4_ChampionActionBlowHorn)
+ _vm->_sound->requestPlay(k25_soundBLOW_HORN, nextMapX, nextMapY, k0_soundModePlayImmediately);
+
+ actionPerformed = isGroupFrightenedByAction(champIndex, actionIndex, nextMapX, nextMapY);
break;
- case k32_ChampionActionShoot:
- if (Thing(L1247_ps_Champion->_slots[k0_ChampionSlotReadyHand]).getType() != k5_WeaponThingType)
- goto T0407032;
- L1256_ps_WeaponInfoActionHand = &_vm->_dungeonMan->_weaponInfos[L1248_ps_Weapon->getType()];
- L1257_ps_WeaponInfoReadyHand = _vm->_dungeonMan->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:
- _actionDamage = kM2_damageNoAmmunition;
- L1255_i_ActionExperienceGain = 0;
- AL1245_B_ActionPerformed = false;
- break;
- }
- AL1246_i_StepEnergy -= k32_WeaponClassFirstSling;
+ case k32_ChampionActionShoot: {
+ if (Thing(curChampion->_slots[k0_ChampionSlotReadyHand]).getType() != k5_WeaponThingType) {
+ _actionDamage = kM2_damageNoAmmunition;
+ actionExperienceGain = 0;
+ actionPerformed = false;
+ break;
+ }
+
+ WeaponInfo *weaponInfoActionHand = &_vm->_dungeonMan->_weaponInfos[weaponInHand->getType()];
+ WeaponInfo *weaponInfoReadyHand = _vm->_dungeonMan->getWeaponInfo(curChampion->_slots[k0_ChampionSlotReadyHand]);
+ int16 actionHandWeaponClass = weaponInfoActionHand->_class;
+ int16 readyHandWeaponClass = weaponInfoReadyHand->_class;
+ int16 stepEnergy = actionHandWeaponClass;
+ if ((actionHandWeaponClass >= k16_WeaponClassFirstBow) && (actionHandWeaponClass <= k31_WeaponClassLastBow)) {
+ if (readyHandWeaponClass != k10_WeaponClassBowAmmunition) {
+ _actionDamage = kM2_damageNoAmmunition;
+ actionExperienceGain = 0;
+ actionPerformed = false;
+ break;
+ }
+ stepEnergy -= k16_WeaponClassFirstBow;
+ } else if ((actionHandWeaponClass >= k32_WeaponClassFirstSling) && (actionHandWeaponClass <= k47_WeaponClassLastSling)) {
+ if (readyHandWeaponClass != k11_WeaponClassSlingAmmunition) {
+ _actionDamage = kM2_damageNoAmmunition;
+ actionExperienceGain = 0;
+ actionPerformed = false;
+ break;
}
+ stepEnergy -= k32_WeaponClassFirstSling;
}
- setChampionDirectionToPartyDirection(L1247_ps_Champion);
- { // so gotos won't skip init
- Thing AL1250_T_Object = _vm->_championMan->getObjectRemovedFromSlot(champIndex, k0_ChampionSlotReadyHand);
- _vm->_sound->requestPlay(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
- _vm->_championMan->championShootProjectile(L1247_ps_Champion, AL1250_T_Object, L1256_ps_WeaponInfoActionHand->_kineticEnergy + L1257_ps_WeaponInfoReadyHand->_kineticEnergy, (L1256_ps_WeaponInfoActionHand->getShootAttack() + _vm->_championMan->getSkillLevel(champIndex, k11_ChampionSkillShoot)) << 1, AL1246_i_StepEnergy);
+
+ setChampionDirectionToPartyDirection(curChampion);
+ Thing removedObject = _vm->_championMan->getObjectRemovedFromSlot(champIndex, k0_ChampionSlotReadyHand);
+ _vm->_sound->requestPlay(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
+ _vm->_championMan->championShootProjectile(curChampion, removedObject, weaponInfoActionHand->_kineticEnergy + weaponInfoReadyHand->_kineticEnergy, (weaponInfoActionHand->getShootAttack() + _vm->_championMan->getSkillLevel(champIndex, k11_ChampionSkillShoot)) << 1, stepEnergy);
}
break;
case k5_ChampionActionFlip: {
- const char *messages_EN_ANY[2] = {"IT COMES UP HEADS.", "IT COMES UP TAILS."};
- const char *messages_DE_DEU[2] = {"DIE KOPFSEITE IST OBEN.", "DIE ZAHL IST OBEN."};
- const char *messages_FR_FRA[2] = {"C'EST FACE.", "C'EST PILE."};
+ const char *messagesEN[2] = {"IT COMES UP HEADS.", "IT COMES UP TAILS."};
+ const char *messagesDE[2] = {"DIE KOPFSEITE IST OBEN.", "DIE ZAHL IST OBEN."};
+ const char *messagesFR[2] = {"C'EST FACE.", "C'EST PILE."};
const char **message;
switch (_vm->getGameLanguage()) { // localized
default:
- case Common::EN_ANY: message = messages_EN_ANY; break;
- case Common::DE_DEU: message = messages_DE_DEU; break;
- case Common::FR_FRA: message = messages_FR_FRA; break;
+ case Common::EN_ANY:
+ message = messagesEN;
+ break;
+ case Common::DE_DEU:
+ message = messagesDE;
+ break;
+ case Common::FR_FRA:
+ message = messagesFR;
+ break;
}
- if (_vm->getRandomNumber(2)) {
+ if (_vm->getRandomNumber(2))
printMessageAfterReplacements(message[0]);
- } else {
+ else
printMessageAfterReplacements(message[1]);
+
}
- }
- break;
+ break;
case k33_ChampionActionSpellshield:
case k34_ChampionActionFireshield:
- if (!isPartySpellOrFireShieldSuccessful(L1247_ps_Champion, actionIndex == k33_ChampionActionSpellshield, 280, true)) {
- L1255_i_ActionExperienceGain >>= 2;
- L1249_ui_ActionDisabledTicks >>= 1;
- } else {
- decrementCharges(L1247_ps_Champion);
- }
+ if (!isPartySpellOrFireShieldSuccessful(curChampion, actionIndex == k33_ChampionActionSpellshield, 280, true)) {
+ actionExperienceGain >>= 2;
+ actionDisabledTicks >>= 1;
+ } else
+ decrementCharges(curChampion);
+
break;
case k27_ChampionActionInvoke:
- AL1250_i_KineticEnergy = _vm->getRandomNumber(128) + 100;
+ kineticEnergy = _vm->getRandomNumber(128) + 100;
switch (_vm->getRandomNumber(6)) {
case 0:
- AL1245_T_ExplosionThing = Thing::_explPoisonBolt.toUint16();
- goto T0407014;
+ explosionThing = Thing::_explPoisonBolt;
+ break;
case 1:
- AL1245_T_ExplosionThing = Thing::_explPoisonCloud.toUint16();
- goto T0407014;
+ explosionThing = Thing::_explPoisonCloud;
+ break;
case 2:
- AL1245_T_ExplosionThing = Thing::_explHarmNonMaterial.toUint16();
- goto T0407014;
+ explosionThing = Thing::_explHarmNonMaterial;
+ break;
default:
- goto T0407013;
+ explosionThing = Thing::_explFireBall;
+ break;
}
+ setDirectionFl = true;
+ break;
+
case k35_ChampionActionFluxcage:
- setChampionDirectionToPartyDirection(L1247_ps_Champion);
- _vm->_groupMan->fluxCageAction(L1251_i_MapX, L1252_i_MapY);
+ setChampionDirectionToPartyDirection(curChampion);
+ _vm->_groupMan->fluxCageAction(nextMapX, nextMapY);
break;
case k43_ChampionActionFuse:
- setChampionDirectionToPartyDirection(L1247_ps_Champion);
- L1251_i_MapX = _vm->_dungeonMan->_partyMapX;
- L1252_i_MapY = _vm->_dungeonMan->_partyMapY;
- L1251_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_partyDir], L1252_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_partyDir];
- _vm->_groupMan->fuseAction(L1251_i_MapX, L1252_i_MapY);
+ setChampionDirectionToPartyDirection(curChampion);
+ nextMapX = _vm->_dungeonMan->_partyMapX;
+ nextMapY = _vm->_dungeonMan->_partyMapY;
+ nextMapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_partyDir], nextMapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_partyDir];
+ _vm->_groupMan->fuseAction(nextMapX, nextMapY);
break;
- case k36_ChampionActionHeal:
+ 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->getSkillLevel(champIndex, k13_ChampionSkillHeal));
- L1255_i_ActionExperienceGain = 2;
+ int16 missingHealth = curChampion->_maxHealth - curChampion->_currHealth;
+ if ((missingHealth > 0) && curChampion->_currMana) {
+ int16 healingCapability = MIN((uint16)10, _vm->_championMan->getSkillLevel(champIndex, k13_ChampionSkillHeal));
+ actionExperienceGain = 2;
+ uint16 healingAmount;
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;
+ healingAmount = MIN(missingHealth, healingCapability);
+ curChampion->_currHealth += healingAmount;
+ actionExperienceGain += 2;
+ curChampion->_currMana = curChampion->_currMana - 2;
+ if (curChampion->_currMana > 0)
+ missingHealth -= healingAmount;
+ } while ((curChampion->_currMana > 0) && missingHealth);
+
+ if (curChampion->_currMana < 0)
+ curChampion->_currMana = 0;
+
+ setFlag(curChampion->_attributes, k0x0100_ChampionAttributeStatistics);
+ actionPerformed = true;
+ }
}
break;
- case k39_ChampionActionWindow:
- AL1246_i_Ticks = _vm->getRandomNumber(_vm->_championMan->getSkillLevel(champIndex, L1254_i_ActionSkillIndex) + 8) + 5;
- L1258_s_Event._priority = 0;
- L1258_s_Event._type = k73_TMEventTypeThievesEye;
- setMapAndTime(L1258_s_Event._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + AL1246_i_Ticks);
- _vm->_timeline->addEventGetEventIndex(&L1258_s_Event);
+ case k39_ChampionActionWindow: {
+ int16 windowTicks = _vm->getRandomNumber(_vm->_championMan->getSkillLevel(champIndex, actionSkillIndex) + 8) + 5;
+ TimelineEvent newEvent;
+ newEvent._priority = 0;
+ newEvent._type = k73_TMEventTypeThievesEye;
+ setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_partyMapIndex, _vm->_gameTime + windowTicks);
+ _vm->_timeline->addEventGetEventIndex(&newEvent);
_vm->_championMan->_party._event73Count_ThievesEye++;
- goto T0407076;
+ decrementCharges(curChampion);
+ }
+ break;
case k10_ChampionActionClimbDown:
- L1251_i_MapX = _vm->_dungeonMan->_partyMapX;
- L1252_i_MapY = _vm->_dungeonMan->_partyMapY;
- L1251_i_MapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_partyDir];
- L1252_i_MapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_partyDir];
+ nextMapX = _vm->_dungeonMan->_partyMapX;
+ nextMapY = _vm->_dungeonMan->_partyMapY;
+ nextMapX += _vm->_dirIntoStepCountEast[_vm->_dungeonMan->_partyDir];
+ nextMapY += _vm->_dirIntoStepCountNorth[_vm->_dungeonMan->_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->getSquare(L1251_i_MapX, L1252_i_MapY).getType() == k2_PitElemType) && (_vm->_groupMan->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 */
+ if ((_vm->_dungeonMan->getSquare(nextMapX, nextMapY).getType() == k2_PitElemType) && (_vm->_groupMan->groupGetThing(nextMapX, nextMapY) == 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->_moveSens->_useRopeToClimbDownPit = true;
- _vm->_moveSens->getMoveResult(Thing::_party, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, L1251_i_MapX, L1252_i_MapY);
+ _vm->_moveSens->getMoveResult(Thing::_party, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, nextMapX, nextMapY);
_vm->_moveSens->_useRopeToClimbDownPit = false;
} else {
- L1249_ui_ActionDisabledTicks = 0;
+ 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:
+ case k11_ChampionActionFreezeLife: {
+ int16 freezeTicks;
+ if (weaponInHand->getType() == k42_JunkTypeMagicalBoxBlue) {
+ freezeTicks = 30;
+ _vm->_championMan->getObjectRemovedFromSlot(champIndex, k1_ChampionSlotActionHand);
+ weaponInHand->setNextThing(Thing::_none);
+ } else if (weaponInHand->getType() == k43_JunkTypeMagicalBoxGreen) {
+ freezeTicks = 125;
_vm->_championMan->getObjectRemovedFromSlot(champIndex, k1_ChampionSlotActionHand);
- L1248_ps_Weapon->setNextThing(Thing::_none);
+ weaponInHand->setNextThing(Thing::_none);
} else {
- AL1246_i_Ticks = 70;
- decrementCharges(L1247_ps_Champion);
+ freezeTicks = 70;
+ decrementCharges(curChampion);
+ }
+ _vm->_championMan->_party._freezeLifeTicks = MIN(200, _vm->_championMan->_party._freezeLifeTicks + freezeTicks);
}
- _vm->_championMan->_party._freezeLifeTicks = MIN(200, _vm->_championMan->_party._freezeLifeTicks + AL1246_i_Ticks);
break;
case k38_ChampionActionLight:
_vm->_championMan->_party._magicalLightAmount += _vm->_championMan->_lightPowerToLightAmount[2];
createEvent70_light(-2, 2500);
-T0407076:
- decrementCharges(L1247_ps_Champion);
+ decrementCharges(curChampion);
break;
case k42_ChampionActionThrow:
- setChampionDirectionToPartyDirection(L1247_ps_Champion);
- AL1245_B_ActionPerformed = _vm->_championMan->isObjectThrown(champIndex, k1_ChampionSlotActionHand, (L1247_ps_Champion->_cell == returnNextVal(_vm->_dungeonMan->_partyDir)) || (L1247_ps_Champion->_cell == (ViewCell)returnOppositeDir(_vm->_dungeonMan->_partyDir)));
- if (AL1245_B_ActionPerformed) {
- _vm->_timeline->_events[L1247_ps_Champion->_enableActionEventIndex]._B._slotOrdinal = _vm->indexToOrdinal(k1_ChampionSlotActionHand);
- }
- }
- if (L1249_ui_ActionDisabledTicks) {
- _vm->_championMan->disableAction(champIndex, L1249_ui_ActionDisabledTicks);
- }
- if (L1253_i_ActionStamina) {
- _vm->_championMan->decrementStamina(champIndex, L1253_i_ActionStamina);
+ setChampionDirectionToPartyDirection(curChampion);
+ actionPerformed = _vm->_championMan->isObjectThrown(champIndex, k1_ChampionSlotActionHand, (curChampion->_cell == returnNextVal(_vm->_dungeonMan->_partyDir)) || (curChampion->_cell == (ViewCell)returnOppositeDir(_vm->_dungeonMan->_partyDir)));
+ if (actionPerformed)
+ _vm->_timeline->_events[curChampion->_enableActionEventIndex]._B._slotOrdinal = _vm->indexToOrdinal(k1_ChampionSlotActionHand);
+ break;
}
- if (L1255_i_ActionExperienceGain) {
- _vm->_championMan->addSkillExperience(champIndex, L1254_i_ActionSkillIndex, L1255_i_ActionExperienceGain);
+
+ if (setDirectionFl) {
+ setChampionDirectionToPartyDirection(curChampion);
+ if (curChampion->_currMana < requiredManaAmount) {
+ kineticEnergy = MAX(2, curChampion->_currMana * kineticEnergy / requiredManaAmount);
+ requiredManaAmount = curChampion->_currMana;
+ }
+ actionPerformed = _vm->_championMan->isProjectileSpellCast(champIndex, explosionThing, kineticEnergy, requiredManaAmount);
+ if (!actionPerformed)
+ actionExperienceGain >>= 1;
+
+ decrementCharges(curChampion);
}
+ if (actionDisabledTicks)
+ _vm->_championMan->disableAction(champIndex, actionDisabledTicks);
+
+ if (actionStamina)
+ _vm->_championMan->decrementStamina(champIndex, actionStamina);
+
+ if (actionExperienceGain)
+ _vm->_championMan->addSkillExperience(champIndex, actionSkillIndex, actionExperienceGain);
+
_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
- return AL1245_B_ActionPerformed;
+ return actionPerformed;
}
-void MenuMan::setChampionDirectionToPartyDirection(Champion* champ) {
+void MenuMan::setChampionDirectionToPartyDirection(Champion *champ) {
if (champ->_dir != _vm->_dungeonMan->_partyDir) {
champ->_dir = _vm->_dungeonMan->_partyDir;
setFlag(champ->_attributes, k0x0400_ChampionAttributeIcon);
}
}
-void MenuMan::decrementCharges(Champion* champ) {
- Thing L1242_T_Thing;
- Junk* L1243_ps_Junk;
-
- L1243_ps_Junk = (Junk*)_vm->_dungeonMan->getThingData(L1242_T_Thing = champ->_slots[k1_ChampionSlotActionHand]);
- switch (L1242_T_Thing.getType()) {
+void MenuMan::decrementCharges(Champion *champ) {
+ Thing slotActionThing = champ->_slots[k1_ChampionSlotActionHand];
+ Junk *slotActionData = (Junk *)_vm->_dungeonMan->getThingData(slotActionThing);
+ switch (slotActionThing.getType()) {
case k5_WeaponThingType:
- if (((Weapon*)L1243_ps_Junk)->getChargeCount()) {
- ((Weapon*)L1243_ps_Junk)->setChargeCount(((Weapon*)L1243_ps_Junk)->getChargeCount() - 1);
+ if (((Weapon *)slotActionData)->getChargeCount()) {
+ ((Weapon *)slotActionData)->setChargeCount(((Weapon *)slotActionData)->getChargeCount() - 1);
}
break;
case k6_ArmourThingType:
- if (((Armour*)L1243_ps_Junk)->getChargeCount()) {
- ((Armour*)L1243_ps_Junk)->setChargeCount(((Armour*)L1243_ps_Junk)->getChargeCount() - 1);
+ if (((Armour *)slotActionData)->getChargeCount()) {
+ ((Armour *)slotActionData)->setChargeCount(((Armour *)slotActionData)->getChargeCount() - 1);
}
break;
case k10_JunkThingType:
- if (L1243_ps_Junk->getChargeCount()) {
- L1243_ps_Junk->setChargeCount(L1243_ps_Junk->getChargeCount() - 1);
+ if (slotActionData->getChargeCount()) {
+ slotActionData->setChargeCount(slotActionData->getChargeCount() - 1);
}
break;
default:
@@ -1369,8 +1369,8 @@ void MenuMan::decrementCharges(Champion* champ) {
_vm->_championMan->drawChangedObjectIcons();
}
-bool MenuMan::isMeleeActionPerformed(int16 champIndex, Champion* champ, int16 actionIndex, int16 targetMapX, int16 targetMapY, int16 skillIndex) {
- static unsigned char G0492_auc_Graphic560_ActionDamageFactor[44] = {
+bool MenuMan::isMeleeActionPerformed(int16 champIndex, Champion *champ, int16 actionIndex, int16 targetMapX, int16 targetMapY, int16 skillIndex) {
+ static unsigned char actionDamageFactorArray[44] = {
0, /* N */
15, /* BLOCK */
48, /* CHOP */
@@ -1414,8 +1414,9 @@ bool MenuMan::isMeleeActionPerformed(int16 champIndex, Champion* champ, int16 ac
0, /* SPIT */
0, /* BRANDISH */
0, /* THROW */
- 0}; /* FUSE */
- static unsigned char G0493_auc_Graphic560_ActionHitProbability[44] = {
+ 0 /* FUSE */
+ };
+ static unsigned char actionHitProbabilityArray[44] = {
0, /* N */
22, /* BLOCK */
48, /* CHOP */
@@ -1459,136 +1460,125 @@ bool MenuMan::isMeleeActionPerformed(int16 champIndex, Champion* champ, int16 ac
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;
+ 0 /* FUSE */
+ };
_vm->_sound->requestPlay(k16_soundCOMBAT_ATTACK_SKELETON_ANIMATED_ARMOUR_DETH_KNIGHT, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
if (_actionTargetGroupThing == Thing::_endOfList)
- goto T0402010;
- L1238_i_CreatureOrdinal = _vm->_groupMan->getMeleeTargetCreatureOrdinal(targetMapX, targetMapY, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, AL1236_ui_ChampionCell = champ->_cell);
- if (L1238_i_CreatureOrdinal) {
- switch (normalizeModulo4(AL1236_ui_ChampionCell + 4 - champ->_dir)) {
+ return false;
+
+ uint16 championCell = champ->_cell;
+ int16 targetCreatureOrdinal = _vm->_groupMan->getMeleeTargetCreatureOrdinal(targetMapX, targetMapY, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, championCell);
+ if (targetCreatureOrdinal) {
+ uint16 viewCell = normalizeModulo4(championCell + 4 - champ->_dir);
+ switch (viewCell) {
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->getIndexInCell(normalizeModulo4(AL1236_ui_ChampionCell + AL1237_ui_CellDelta)) != kM1_ChampionNone) {
+ uint16 cellDelta = (viewCell == k2_ViewCellBackRight) ? 3 : 1;
+ /* Check if there is another champion in front */
+ if (_vm->_championMan->getIndexInCell(normalizeModulo4(championCell + cellDelta)) != kM1_ChampionNone) {
_actionDamage = kM1_damageCantReach;
- goto T0402010;
+ return false;
}
+ break;
}
+
if ((actionIndex == k24_ChampionActionDisrupt) && !getFlag(_vm->_dungeonMan->getCreatureAttributes(_actionTargetGroupThing), k0x0040_MaskCreatureInfo_nonMaterial))
- goto T0402010;
- AL1237_ui_ActionHitProbability = G0493_auc_Graphic560_ActionHitProbability[actionIndex];
- AL1236_ui_ActionDamageFactor = G0492_auc_Graphic560_ActionDamageFactor[actionIndex];
+ return false;
+
+ uint16 actionHitProbability = actionHitProbabilityArray[actionIndex];
+ uint16 actionDamageFactor = actionDamageFactorArray[actionIndex];
if ((_vm->_objectMan->getIconIndex(champ->_slots[k1_ChampionSlotActionHand]) == k40_IconIndiceWeaponVorpalBlade) || (actionIndex == k24_ChampionActionDisrupt)) {
- setFlag(AL1237_ui_ActionHitProbability, k0x8000_hitNonMaterialCreatures);
+ setFlag(actionHitProbability, k0x8000_hitNonMaterialCreatures);
}
- _actionDamage = _vm->_groupMan->getMeleeActionDamage(champ, champIndex, (Group*)_vm->_dungeonMan->getThingData(_actionTargetGroupThing), _vm->ordinalToIndex(L1238_i_CreatureOrdinal), targetMapX, targetMapY, AL1237_ui_ActionHitProbability, AL1236_ui_ActionDamageFactor, skillIndex);
+ _actionDamage = _vm->_groupMan->getMeleeActionDamage(champ, champIndex, (Group *)_vm->_dungeonMan->getThingData(_actionTargetGroupThing), _vm->ordinalToIndex(targetCreatureOrdinal), targetMapX, targetMapY, actionHitProbability, actionDamageFactor, skillIndex);
return true;
}
-T0402010:
+
return false;
}
bool MenuMan::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;
+ bool isGroupFrightenedByAction = false;
+ if (_actionTargetGroupThing == Thing::_endOfList)
+ return isGroupFrightenedByAction;
+ uint16 experience = 0;
+ int16 frightAmount = 0;
- L1232_B_IsGroupFrightenedByAction = false;
- if (_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 */
+ frightAmount = 3;
+ 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;
+ frightAmount = 7;
+ experience = 35;
break;
case k41_ChampionActionBrandish:
- L1229_i_FrightAmount = 6;
- L1231_ui_Experience = 30;
+ frightAmount = 6;
+ experience = 30;
break;
case k4_ChampionActionBlowHorn:
- L1229_i_FrightAmount = 6;
- L1231_ui_Experience = 20;
+ frightAmount = 6;
+ experience = 20;
break;
case k22_ChampionActionConfuse:
- L1229_i_FrightAmount = 12;
- L1231_ui_Experience = 45;
+ frightAmount = 12;
+ experience = 45;
+ break;
}
- L1229_i_FrightAmount += _vm->_championMan->getSkillLevel(champIndex, k14_ChampionSkillInfluence);
- L1233_ps_Group = (Group*)_vm->_dungeonMan->getThingData(_actionTargetGroupThing);
- L1234_ps_CreatureInfo = &_vm->_dungeonMan->_creatureInfos[L1233_ps_Group->_type];
- if (((L1230_ui_FearResistance = L1234_ps_CreatureInfo->getFearResistance()) > _vm->getRandomNumber(L1229_i_FrightAmount)) || (L1230_ui_FearResistance == k15_immuneToFear)) {
- L1231_ui_Experience >>= 1;
+ frightAmount += _vm->_championMan->getSkillLevel(champIndex, k14_ChampionSkillInfluence);
+ Group *targetGroup = (Group *)_vm->_dungeonMan->getThingData(_actionTargetGroupThing);
+ CreatureInfo *creatureInfo = &_vm->_dungeonMan->_creatureInfos[targetGroup->_type];
+ uint16 fearResistance = creatureInfo->getFearResistance();
+ if ((fearResistance > _vm->getRandomNumber(frightAmount)) || (fearResistance == k15_immuneToFear)) {
+ experience >>= 1;
} else {
- L1235_ps_ActiveGroup = &_vm->_groupMan->_activeGroups[L1233_ps_Group->getActiveGroupIndex()];
- if (L1233_ps_Group->getBehaviour() == k6_behavior_ATTACK) {
- _vm->_groupMan->stopAttacking(L1235_ps_ActiveGroup, mapX, mapY);
+ ActiveGroup *activeGroup = &_vm->_groupMan->_activeGroups[targetGroup->getActiveGroupIndex()];
+ if (targetGroup->getBehaviour() == k6_behavior_ATTACK) {
+ _vm->_groupMan->stopAttacking(activeGroup, mapX, mapY);
_vm->_groupMan->startWandering(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;
+ targetGroup->setBehaviour(k5_behavior_FLEE);
+ activeGroup->_delayFleeingFromTarget = ((16 - fearResistance) << 2) / creatureInfo->_movementTicks;
+ isGroupFrightenedByAction = true;
}
- _vm->_championMan->addSkillExperience(champIndex, k14_ChampionSkillInfluence, L1231_ui_Experience);
-T0401016:
- return L1232_B_IsGroupFrightenedByAction;
-}
-
-void MenuMan::printMessageAfterReplacements(const char* str) {
- char* L1164_pc_Character;
- char* L1165_pc_ReplacementString;
- char L1166_ac_OutputString[128];
+ _vm->_championMan->addSkillExperience(champIndex, k14_ChampionSkillInfluence, experience);
+ return isGroupFrightenedByAction;
+}
- L1164_pc_Character = L1166_ac_OutputString;
- *L1164_pc_Character++ = '\n'; /* New line */
+void MenuMan::printMessageAfterReplacements(const char *str) {
+ char outputString[128];
+ char *curCharacter = outputString;
+ *curCharacter++ = '\n'; /* New line */
+ char *replacementString = "";
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->_champions[_vm->ordinalToIndex(_vm->_championMan->_actingChampionOrdinal)]._name;
- }
- *L1164_pc_Character = '\0';
- strcat(L1166_ac_OutputString, L1165_pc_ReplacementString);
- L1164_pc_Character += strlen(L1165_pc_ReplacementString);
- *L1164_pc_Character++ = ' ';
+ if (*(curCharacter - 1) != '\n') /* New line */
+ *curCharacter++ = ' ';
+
+ if (*str == 'p') /* '@p' in the source string is replaced by the champion name followed by a space */
+ replacementString = _vm->_championMan->_champions[_vm->ordinalToIndex(_vm->_championMan->_actingChampionOrdinal)]._name;
+
+ *curCharacter = '\0';
+ strcat(outputString, replacementString);
+ curCharacter += strlen(replacementString);
+ *curCharacter++ = ' ';
} else {
- *L1164_pc_Character++ = *str;
+ *curCharacter++ = *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->printMessage(k4_ColorCyan, L1166_ac_OutputString);
- }
+ *curCharacter = '\0';
+
+ if (outputString[1]) /* If the string is not empty (the first character is a new line \n) */
+ _vm->_textMan->printMessage(k4_ColorCyan, outputString);
}
void MenuMan::processCommands116To119_setActingChampion(uint16 champIndex) {
- static ActionSet G0489_as_Graphic560_ActionSets[44] = {
+ static ActionSet 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),
@@ -1633,164 +1623,162 @@ void MenuMan::processCommands116To119_setActingChampion(uint16 champIndex) {
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;
-
+ ActionSet(6, 11, 255, 0x80, 0x00)
+ };
- L1190_ps_Champion = &_vm->_championMan->_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 Punch, Kick and War Cry */
- } else if ((L1188_ui_ActionSetIndex = _vm->_dungeonMan->_objectInfos[_vm->_dungeonMan->getObjectInfoIndex(L1189_T_Thing)]._actionSetIndex) == 0) {
+ Champion *curChampion = &_vm->_championMan->_champions[champIndex];
+ if (getFlag(curChampion->_attributes, k0x0008_ChampionAttributeDisableAction) || !curChampion->_currHealth)
return;
+
+ uint16 actionSetIndex;
+ Thing slotActionThing = curChampion->_slots[k1_ChampionSlotActionHand];
+
+ if (slotActionThing == Thing::_none)
+ actionSetIndex = 2; /* Actions Punch, Kick and War Cry */
+ else {
+ actionSetIndex = _vm->_dungeonMan->_objectInfos[_vm->_dungeonMan->getObjectInfoIndex(slotActionThing)]._actionSetIndex;
+ if (actionSetIndex == 0)
+ return;
}
- L1191_ps_ActionSet = &G0489_as_Graphic560_ActionSets[L1188_ui_ActionSetIndex];
+
+ ActionSet *actionSet = &actionSets[actionSetIndex];
_vm->_championMan->_actingChampionOrdinal = _vm->indexToOrdinal(champIndex);
- setActionList(L1191_ps_ActionSet);
+ setActionList(actionSet);
_actionAreaContainsIcons = false;
- setFlag(L1190_ps_Champion->_attributes, k0x8000_ChampionAttributeActionHand);
+ setFlag(curChampion->_attributes, k0x8000_ChampionAttributeActionHand);
_vm->_championMan->drawChampionState((ChampionIndex)champIndex);
drawActionArea();
drawActionArea();
}
-void MenuMan::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;
-
+void MenuMan::setActionList(ActionSet *actionSet) {
_actionList._actionIndices[0] = (ChampionAction)actionSet->_actionIndices[0];
_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)
+ uint16 nextAvailableActionListIndex = 1;
+ for (uint16 idx = 1; idx < 3; idx++) {
+ uint16 actionIndex = actionSet->_actionIndices[idx];
+
+ if (actionIndex == k255_ChampionActionNone)
continue;
- if (getFlag(L1172_ui_MinimumSkillLevel = actionSet->_actionProperties[L1169_ui_ActionListIndex - 1], k0x0080_actionRequiresCharge) && !getActionObjectChargeCount())
+
+ uint16 minimumSkillLevel = actionSet->_actionProperties[idx - 1];
+ if (getFlag(minimumSkillLevel, k0x0080_actionRequiresCharge) && !getActionObjectChargeCount())
continue;
- clearFlag(L1172_ui_MinimumSkillLevel, k0x0080_actionRequiresCharge);
- if (_vm->_championMan->getSkillLevel(_vm->ordinalToIndex(_vm->_championMan->_actingChampionOrdinal), _actionSkillIndex[L1171_ui_ActionIndex]) >= L1172_ui_MinimumSkillLevel) {
- _actionList._actionIndices[L1170_ui_NextAvailableActionListIndex] = (ChampionAction)L1171_ui_ActionIndex;
- _actionList._minimumSkillLevel[L1170_ui_NextAvailableActionListIndex] = L1172_ui_MinimumSkillLevel;
- L1170_ui_NextAvailableActionListIndex++;
+
+ clearFlag(minimumSkillLevel, k0x0080_actionRequiresCharge);
+ if (_vm->_championMan->getSkillLevel(_vm->ordinalToIndex(_vm->_championMan->_actingChampionOrdinal), _actionSkillIndex[actionIndex]) >= minimumSkillLevel) {
+ _actionList._actionIndices[nextAvailableActionListIndex] = (ChampionAction)actionIndex;
+ _actionList._minimumSkillLevel[nextAvailableActionListIndex] = minimumSkillLevel;
+ nextAvailableActionListIndex++;
}
}
- _actionCount = L1170_ui_NextAvailableActionListIndex;
- for (L1169_ui_ActionListIndex = L1170_ui_NextAvailableActionListIndex; L1169_ui_ActionListIndex < 3; L1169_ui_ActionListIndex++) {
- _actionList._actionIndices[L1169_ui_ActionListIndex] = k255_ChampionActionNone;
- }
+ _actionCount = nextAvailableActionListIndex;
+
+ for (uint16 idx = nextAvailableActionListIndex; idx < 3; idx++)
+ _actionList._actionIndices[idx] = k255_ChampionActionNone;
}
int16 MenuMan::getActionObjectChargeCount() {
- Thing L1167_T_Thing;
- Junk* L1168_ps_Junk;
-
-
- L1168_ps_Junk = (Junk*)_vm->_dungeonMan->getThingData(L1167_T_Thing = _vm->_championMan->_champions[_vm->ordinalToIndex(_vm->_championMan->_actingChampionOrdinal)]._slots[k1_ChampionSlotActionHand]);
- switch (L1167_T_Thing.getType()) {
+ Thing slotActionThing = _vm->_championMan->_champions[_vm->ordinalToIndex(_vm->_championMan->_actingChampionOrdinal)]._slots[k1_ChampionSlotActionHand];
+ Junk *junkData = (Junk *)_vm->_dungeonMan->getThingData(slotActionThing);
+ switch (slotActionThing.getType()) {
case k5_WeaponThingType:
- return ((Weapon*)L1168_ps_Junk)->getChargeCount();
+ return ((Weapon *)junkData)->getChargeCount();
case k6_ArmourThingType:
- return ((Armour*)L1168_ps_Junk)->getChargeCount();
+ return ((Armour *)junkData)->getChargeCount();
case k10_JunkThingType:
- return L1168_ps_Junk->getChargeCount();
+ return junkData->getChargeCount();
default:
return 1;
}
}
void MenuMan::drawActionDamage(int16 damage) {
- static const Box G0502_s_Graphic560_Box_ActionAreaMediumDamage = Box(242, 305, 81, 117);
- static const Box G0503_s_Graphic560_Box_ActionAreaSmallDamage = Box(251, 292, 81, 117);
-
- uint16 L1174_ui_Multiple;
-#define AL1174_ui_DerivedBitmapIndex L1174_ui_Multiple
-#define AL1174_ui_CharacterIndex L1174_ui_Multiple
- int16 L1175_i_ByteWidth;
- int16 L1176_i_Multiple;
-#define AL1176_i_X L1176_i_Multiple
-#define AL1176_i_PixelWidth L1176_i_Multiple
- byte* L1177_puc_Bitmap;
- unsigned char* L1178_puc_Multiple;
-#define AL1178_puc_String L1178_puc_Multiple
-#define AL1178_puc_Bitmap L1178_puc_Multiple
- char L1179_ac_String[6];
- const Box* L1180_ps_Box;
- int16 L1643_i_Width;
+ static const Box actionAreaMediumDamage(242, 305, 81, 117);
+ static const Box actionAreaSmallDamage(251, 292, 81, 117);
_vm->_eventMan->showMouse();
_vm->_displayMan->_useByteBoxCoordinates = false;
_vm->_displayMan->fillScreenBox(_boxActionArea, k0_ColorBlack);
if (damage < 0) {
- static const char *messages_EN_ANY[2] = {"CAN'T REACH", "NEED AMMO"};
- static const char *messages_DE_DEU[2] = {"ZU WEIT WEG", "MEHR MUNITION"};
- static const char *messages_FR_FRA[2] = {"TROP LOIN", "SANS MUNITION"};
- static int16 pos_EN_ANY[2] = {242, 248};
- static int16 pos_DE_DEU[2] = {242, 236};
- static int16 pos_FR_FRA[2] = {248, 236};
+ static const char *messagesEN[2] = {"CAN'T REACH", "NEED AMMO"};
+ static const char *messagesDE[2] = {"ZU WEIT WEG", "MEHR MUNITION"};
+ static const char *messagesFR[2] = {"TROP LOIN", "SANS MUNITION"};
+ static int16 posEN[2] = {242, 248};
+ static int16 posDE[2] = {242, 236};
+ static int16 posFR[2] = {248, 236};
const char **message;
int16 *pos;
switch (_vm->getGameLanguage()) { // localized
+ case Common::DE_DEU:
+ message = messagesDE;
+ pos = posDE;
+ break;
+ case Common::FR_FRA:
+ message = messagesFR;
+ pos = posFR;
+ break;
default:
- case Common::EN_ANY: message = messages_EN_ANY; pos = pos_EN_ANY; break;
- case Common::DE_DEU: message = messages_DE_DEU; pos = pos_DE_DEU; break;
- case Common::FR_FRA: message = messages_FR_FRA; pos = pos_FR_FRA; break;
+ message = messagesEN;
+ pos = posEN;
+ break;
}
+ const char *displayString;
+ int16 textPosX;
if (damage == kM1_damageCantReach) {
- AL1176_i_X = pos[0];
- AL1178_puc_String = (byte*)message[0];
+ textPosX = pos[0];
+ displayString = message[0];
} else {
- AL1176_i_X = pos[1];
- AL1178_puc_String = (byte*)message[1];
+ textPosX = pos[1];
+ displayString = message[1];
}
- _vm->_textMan->printToLogicalScreen(AL1176_i_X, 100, k4_ColorCyan, k0_ColorBlack, (char *)AL1178_puc_String);
+ _vm->_textMan->printToLogicalScreen(textPosX, 100, k4_ColorCyan, k0_ColorBlack, displayString);
} else {
+ int16 byteWidth;
+ byte *blitBitmap;
+ const Box *blitBox;
+ int16 displayHeight;
if (damage > 40) {
- L1180_ps_Box = &_boxActionArea3ActionMenu;
- L1177_puc_Bitmap = _vm->_displayMan->getNativeBitmapOrGraphic(k14_damageToCreatureIndice);
- L1175_i_ByteWidth = k48_byteWidth;
- L1643_i_Width = 45;
+ blitBox = &_boxActionArea3ActionMenu;
+ blitBitmap = _vm->_displayMan->getNativeBitmapOrGraphic(k14_damageToCreatureIndice);
+ byteWidth = k48_byteWidth;
+ displayHeight = 45;
} else {
+ uint16 derivedBitmapIndex;
+ int16 destPixelWidth;
if (damage > 15) {
- AL1174_ui_DerivedBitmapIndex = k2_DerivedBitmapDamageToCreatureMedium;
- AL1176_i_PixelWidth = 64;
- L1175_i_ByteWidth = k32_byteWidth;
- L1180_ps_Box = &G0502_s_Graphic560_Box_ActionAreaMediumDamage;
+ derivedBitmapIndex = k2_DerivedBitmapDamageToCreatureMedium;
+ destPixelWidth = 64;
+ byteWidth = k32_byteWidth;
+ blitBox = &actionAreaMediumDamage;
} else {
- AL1174_ui_DerivedBitmapIndex = k3_DerivedBitmapDamageToCreatureSmall;
- AL1176_i_PixelWidth = 42;
- L1175_i_ByteWidth = k24_byteWidth;
- L1180_ps_Box = &G0503_s_Graphic560_Box_ActionAreaSmallDamage;
+ derivedBitmapIndex = k3_DerivedBitmapDamageToCreatureSmall;
+ destPixelWidth = 42;
+ byteWidth = k24_byteWidth;
+ blitBox = &actionAreaSmallDamage;
}
- L1643_i_Width = 37;
- if (!_vm->_displayMan->isDerivedBitmapInCache(AL1174_ui_DerivedBitmapIndex)) {
- AL1178_puc_Bitmap = _vm->_displayMan->getNativeBitmapOrGraphic(k14_damageToCreatureIndice);
- L1177_puc_Bitmap = _vm->_displayMan->getDerivedBitmap(AL1174_ui_DerivedBitmapIndex);
- _vm->_displayMan->blitToBitmapShrinkWithPalChange(AL1178_puc_Bitmap, L1177_puc_Bitmap, 96, 45, AL1176_i_PixelWidth, 37, _vm->_displayMan->_palChangesNoChanges);
- _vm->_displayMan->addDerivedBitmap(AL1174_ui_DerivedBitmapIndex);
+ displayHeight = 37;
+ if (!_vm->_displayMan->isDerivedBitmapInCache(derivedBitmapIndex)) {
+ byte *nativeBitmap = _vm->_displayMan->getNativeBitmapOrGraphic(k14_damageToCreatureIndice);
+ blitBitmap = _vm->_displayMan->getDerivedBitmap(derivedBitmapIndex);
+ _vm->_displayMan->blitToBitmapShrinkWithPalChange(nativeBitmap, blitBitmap, 96, 45, destPixelWidth, 37, _vm->_displayMan->_palChangesNoChanges);
+ _vm->_displayMan->addDerivedBitmap(derivedBitmapIndex);
} else {
- L1177_puc_Bitmap = _vm->_displayMan->getDerivedBitmap(AL1174_ui_DerivedBitmapIndex);
+ blitBitmap = _vm->_displayMan->getDerivedBitmap(derivedBitmapIndex);
}
}
- _vm->_displayMan->blitToScreen(L1177_puc_Bitmap, (int16 *)L1180_ps_Box, L1175_i_ByteWidth, kM1_ColorNoTransparency, L1643_i_Width);
+ _vm->_displayMan->blitToScreen(blitBitmap, blitBox, byteWidth, kM1_ColorNoTransparency, displayHeight);
/* Convert damage value to string */
- AL1174_ui_CharacterIndex = 5;
- AL1176_i_X = 274;
- L1179_ac_String[5] = '\0';
+ uint16 charIndex = 5;
+ int16 textPosX = 274;
+ char scoreString[6];
+ scoreString[5] = '\0';
do {
- L1179_ac_String[--AL1174_ui_CharacterIndex] = '0' + (damage % 10);
- AL1176_i_X -= 3;
+ scoreString[--charIndex] = '0' + (damage % 10);
+ textPosX -= 3;
} while (damage /= 10);
- _vm->_textMan->printToLogicalScreen(AL1176_i_X, 100, k4_ColorCyan, k0_ColorBlack, &L1179_ac_String[AL1174_ui_CharacterIndex]);
+ _vm->_textMan->printToLogicalScreen(textPosX, 100, k4_ColorCyan, k0_ColorBlack, &scoreString[charIndex]);
}
_vm->_eventMan->hideMouse();
}
diff --git a/engines/dm/menus.h b/engines/dm/menus.h
index 1d37651bf8..11232486d5 100644
--- a/engines/dm/menus.h
+++ b/engines/dm/menus.h
@@ -36,7 +36,10 @@ namespace DM {
#define kM1_damageCantReach -1 // @ CM1_DAMAGE_CANT_REACH
#define kM2_damageNoAmmunition -2 // @ CM2_DAMAGE_NO_AMMUNITION
+#define k2_SpellAreaAvailableSymbols 2 // @ C2_SPELL_AREA_AVAILABLE_SYMBOLS
+#define k3_SpellAreaChampionSymbols 3 // @ C3_SPELL_AREA_CHAMPION_SYMBOLS
+#define k0x0080_actionRequiresCharge 0x0080 // @ MASK0x0080_ACTION_REQUIRES_CHARGE
#define k0x8000_hitNonMaterialCreatures 0x8000 // @ MASK0x8000_HIT_NON_MATERIAL_CREATURES
class ActionList {
@@ -90,7 +93,7 @@ public:
const char *getActionName(ChampionAction actionIndex); // @ F0384_MENUS_GetActionName
void drawSpellAreaControls(ChampionIndex champIndex); // @ F0393_MENUS_DrawSpellAreaControls
void buildSpellAreaLine(int16 spellAreaBitmapLine);// @ F0392_MENUS_BuildSpellAreaLine
- void setMagicCasterAndDrawSpellArea(int16 champIndex); // @ F0394_MENUS_SetMagicCasterAndDrawSpellArea
+ void setMagicCasterAndDrawSpellArea(ChampionIndex champIndex); // @ F0394_MENUS_SetMagicCasterAndDrawSpellArea
void drawEnabledMenus(); // @ F0457_START_DrawEnabledMenus_CPSF
int16 getClickOnSpellCastResult(); // @ F0408_MENUS_GetClickOnSpellCastResult
int16 getChampionSpellCastResult(uint16 champIndex); // @ F0412_MENUS_GetChampionSpellCastResult
@@ -122,6 +125,7 @@ public:
Box _boxActionArea; // @ G0001_s_Graphic562_Box_ActionArea
Box _boxSpellArea;
unsigned char _actionSkillIndex[44]; // @ G0496_auc_Graphic560_ActionSkillIndex
+ unsigned char _actionDisabledTicks[44];
void initConstants();
};
diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp
index 308c9e6467..07909c8b2f 100644
--- a/engines/dm/movesens.cpp
+++ b/engines/dm/movesens.cpp
@@ -40,7 +40,7 @@
namespace DM {
-MovesensMan::MovesensMan(DMEngine* vm) : _vm(vm) {
+MovesensMan::MovesensMan(DMEngine *vm) : _vm(vm) {
_moveResultMapX = 0;
_moveResultMapY = 0;
_moveResultMapIndex = 0;
@@ -54,601 +54,565 @@ MovesensMan::MovesensMan(DMEngine* vm) : _vm(vm) {
}
bool MovesensMan::sensorIsTriggeredByClickOnWall(int16 mapX, int16 mapY, uint16 cellParam) {
- Thing L0750_T_ThingBeingProcessed;
- uint16 L0751_ui_ThingType;
- uint16 L0752_ui_Cell;
- bool L0753_B_DoNotTriggerSensor;
- Thing* L0754_ps_Generic;
- Sensor* L0755_ps_Sensor;
- int16 L0756_i_SensorEffect;
- uint16 L0757_ui_SensorType;
- int16 L0758_i_SensorData;
- bool L0759_B_AtLeastOneSensorWasTriggered;
- int16 L0760_ai_SensorCountToProcessPerCell[4];
- Thing L0761_T_LeaderHandObject;
- Thing L0762_T_ThingOnSquare;
- Thing L0763_T_LastProcessedThing;
- Thing L0764_T_SquareFirstThing;
- Sensor* L0765_ps_Sensor;
-
-
- L0759_B_AtLeastOneSensorWasTriggered = false;
- L0761_T_LeaderHandObject = _vm->_championMan->_leaderHandObject;
- for (L0752_ui_Cell = k0_CellNorthWest; L0752_ui_Cell < k3_CellSouthWest + 1; L0752_ui_Cell++) {
- L0760_ai_SensorCountToProcessPerCell[L0752_ui_Cell] = 0;
- }
- L0764_T_SquareFirstThing = L0750_T_ThingBeingProcessed = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY);
- while (L0750_T_ThingBeingProcessed != Thing::_endOfList) {
- if ((L0751_ui_ThingType = (L0750_T_ThingBeingProcessed).getType()) == k3_SensorThingType) {
- L0760_ai_SensorCountToProcessPerCell[(L0750_T_ThingBeingProcessed).getCell()]++;
- } else {
- if (L0751_ui_ThingType >= k4_GroupThingType)
- break;
- }
- L0750_T_ThingBeingProcessed = _vm->_dungeonMan->getNextThing(L0750_T_ThingBeingProcessed);
+ bool atLeastOneSensorWasTriggered = false;
+ Thing leaderHandObject = _vm->_championMan->_leaderHandObject;
+ int16 sensorCountToProcessPerCell[4];
+ for (int16 i = k0_CellNorthWest; i < k3_CellSouthWest + 1; i++)
+ sensorCountToProcessPerCell[i] = 0;
+
+ Thing squareFirstThing = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY);
+ Thing thingBeingProcessed = squareFirstThing;
+ while (thingBeingProcessed != Thing::_endOfList) {
+ ThingType thingType = thingBeingProcessed.getType();
+ if (thingType == k3_SensorThingType)
+ sensorCountToProcessPerCell[thingBeingProcessed.getCell()]++;
+ else if (thingType >= k4_GroupThingType)
+ break;
+
+ thingBeingProcessed = _vm->_dungeonMan->getNextThing(thingBeingProcessed);
}
- L0763_T_LastProcessedThing = L0750_T_ThingBeingProcessed = L0764_T_SquareFirstThing;
- while (L0750_T_ThingBeingProcessed != Thing::_endOfList) {
- if ((L0751_ui_ThingType = (L0750_T_ThingBeingProcessed).getType()) == k3_SensorThingType) {
- L0760_ai_SensorCountToProcessPerCell[L0752_ui_Cell = (L0750_T_ThingBeingProcessed).getCell()]--;
- L0755_ps_Sensor = (Sensor *)_vm->_dungeonMan->getThingData(L0750_T_ThingBeingProcessed);
- if ((L0757_ui_SensorType = (L0755_ps_Sensor)->getType()) == k0_SensorDisabled)
- goto T0275058_ProceedToNextThing;
- if ((_vm->_championMan->_leaderIndex == kM1_ChampionNone) && (L0757_ui_SensorType != k127_SensorWallChampionPortrait))
- goto T0275058_ProceedToNextThing;
- if (L0752_ui_Cell != cellParam)
- goto T0275058_ProceedToNextThing;
- L0758_i_SensorData = L0755_ps_Sensor->getData();
- L0756_i_SensorEffect = L0755_ps_Sensor->getAttrEffectA();
- switch (L0757_ui_SensorType) {
- case k1_SensorWallOrnClick:
- L0753_B_DoNotTriggerSensor = false;
- if (L0755_ps_Sensor->getAttrEffectA() == k3_SensorEffHold) {
- goto T0275058_ProceedToNextThing;
- }
- break;
- case k2_SensorWallOrnClickWithAnyObj:
- L0753_B_DoNotTriggerSensor = (_vm->_championMan->_leaderEmptyHanded != L0755_ps_Sensor->getAttrRevertEffectA());
- break;
- case k17_SensorWallOrnClickWithSpecObjRemovedSensor:
- case k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors:
- if (L0760_ai_SensorCountToProcessPerCell[L0752_ui_Cell]) /* If the sensor is not the last one of its type on the cell */
- goto T0275058_ProceedToNextThing;
- case k3_SensorWallOrnClickWithSpecObj:
- case k4_SensorWallOrnClickWithSpecObjRemoved:
- L0753_B_DoNotTriggerSensor = ((L0758_i_SensorData == _vm->_objectMan->getObjectType(L0761_T_LeaderHandObject)) == L0755_ps_Sensor->getAttrRevertEffectA());
- if (!L0753_B_DoNotTriggerSensor && (L0757_ui_SensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor)) {
- if (L0763_T_LastProcessedThing == L0750_T_ThingBeingProcessed) /* If the sensor is the only one of its type on the cell */
+ Thing lastProcessedThing = thingBeingProcessed = squareFirstThing;
+ while (thingBeingProcessed != Thing::_endOfList) {
+ bool skipToNextThing = false;
+ uint16 ProcessedThingType = thingBeingProcessed.getType();
+ if (ProcessedThingType == k3_SensorThingType) {
+ int16 cellIdx = thingBeingProcessed.getCell();
+ sensorCountToProcessPerCell[cellIdx]--;
+ Sensor *currentSensor = (Sensor *)_vm->_dungeonMan->getThingData(thingBeingProcessed);
+ SensorType processedSensorType = currentSensor->getType();
+ if (processedSensorType == k0_SensorDisabled)
+ skipToNextThing = true;
+ else if ((_vm->_championMan->_leaderIndex == kM1_ChampionNone) && (processedSensorType != k127_SensorWallChampionPortrait))
+ skipToNextThing = true;
+ else if (cellIdx != cellParam)
+ skipToNextThing = true;
+
+ bool doNotTriggerSensor;
+ int16 sensorData = 0;
+ int16 sensorEffect = 0;
+ if (!skipToNextThing) {
+ sensorData = currentSensor->getData();
+ sensorEffect = currentSensor->getAttrEffectA();
+
+ switch (processedSensorType) {
+ case k1_SensorWallOrnClick:
+ doNotTriggerSensor = false;
+ if (currentSensor->getAttrEffectA() == k3_SensorEffHold)
+ skipToNextThing = true;
+ break;
+ case k2_SensorWallOrnClickWithAnyObj:
+ doNotTriggerSensor = (_vm->_championMan->_leaderEmptyHanded != currentSensor->getAttrRevertEffectA());
+ break;
+ case k17_SensorWallOrnClickWithSpecObjRemovedSensor:
+ case k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors:
+ if (sensorCountToProcessPerCell[cellIdx]) { /* If the sensor is not the last one of its type on the cell */
+ skipToNextThing = true;
break;
- L0765_ps_Sensor = (Sensor *)_vm->_dungeonMan->getThingData(L0763_T_LastProcessedThing);
- L0765_ps_Sensor->setNextThing(L0755_ps_Sensor->getNextThing());
- L0755_ps_Sensor->setNextThing(Thing::_none);
- L0750_T_ThingBeingProcessed = L0763_T_LastProcessedThing;
- }
- if (!L0753_B_DoNotTriggerSensor && (L0757_ui_SensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors)) {
- triggerLocalEffect(k2_SensorEffToggle, mapX, mapY, L0752_ui_Cell); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
- }
- break;
- case k12_SensorWallObjGeneratorRotateSensors:
- if (L0760_ai_SensorCountToProcessPerCell[L0752_ui_Cell]) /* If the sensor is not the last one of its type on the cell */
- goto T0275058_ProceedToNextThing;
- L0753_B_DoNotTriggerSensor = !_vm->_championMan->_leaderEmptyHanded;
- if (!L0753_B_DoNotTriggerSensor) {
- triggerLocalEffect(k2_SensorEffToggle, mapX, mapY, L0752_ui_Cell); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
- }
- break;
- case k13_SensorWallSingleObjStorageRotateSensors:
- if (_vm->_championMan->_leaderEmptyHanded) {
- if ((L0761_T_LeaderHandObject = getObjectOfTypeInCell(mapX, mapY, L0752_ui_Cell, L0758_i_SensorData)) == Thing::_none)
- goto T0275058_ProceedToNextThing;
- _vm->_dungeonMan->unlinkThingFromList(L0761_T_LeaderHandObject, Thing(0), mapX, mapY);
- _vm->_championMan->putObjectInLeaderHand(L0761_T_LeaderHandObject, true);
- } else {
- if ((_vm->_objectMan->getObjectType(L0761_T_LeaderHandObject) != L0758_i_SensorData) || (getObjectOfTypeInCell(mapX, mapY, L0752_ui_Cell, L0758_i_SensorData) != Thing::_none))
- goto T0275058_ProceedToNextThing;
+ }
+ // No break on purpose
+ case k3_SensorWallOrnClickWithSpecObj:
+ case k4_SensorWallOrnClickWithSpecObjRemoved:
+ doNotTriggerSensor = ((sensorData == _vm->_objectMan->getObjectType(leaderHandObject)) == currentSensor->getAttrRevertEffectA());
+ if (!doNotTriggerSensor && (processedSensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor)) {
+ if (lastProcessedThing == thingBeingProcessed) /* If the sensor is the only one of its type on the cell */
+ break;
+ Sensor *lastSensor = (Sensor *)_vm->_dungeonMan->getThingData(lastProcessedThing);
+ lastSensor->setNextThing(currentSensor->getNextThing());
+ currentSensor->setNextThing(Thing::_none);
+ thingBeingProcessed = lastProcessedThing;
+ }
+ if (!doNotTriggerSensor && (processedSensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors)) {
+ triggerLocalEffect(k2_SensorEffToggle, mapX, mapY, cellIdx); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
+ }
+ break;
+ case k12_SensorWallObjGeneratorRotateSensors:
+ if (sensorCountToProcessPerCell[cellIdx]) { /* If the sensor is not the last one of its type on the cell */
+ skipToNextThing = true;
+ break;
+ }
+ doNotTriggerSensor = !_vm->_championMan->_leaderEmptyHanded;
+ if (!doNotTriggerSensor)
+ triggerLocalEffect(k2_SensorEffToggle, mapX, mapY, cellIdx); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
+ break;
+ case k13_SensorWallSingleObjStorageRotateSensors:
+ if (_vm->_championMan->_leaderEmptyHanded) {
+ leaderHandObject = getObjectOfTypeInCell(mapX, mapY, cellIdx, sensorData);
+ if (leaderHandObject == Thing::_none) {
+ skipToNextThing = true;
+ break;
+ }
+ _vm->_dungeonMan->unlinkThingFromList(leaderHandObject, Thing(0), mapX, mapY);
+ _vm->_championMan->putObjectInLeaderHand(leaderHandObject, true);
+ } else {
+ if ((_vm->_objectMan->getObjectType(leaderHandObject) != sensorData) || (getObjectOfTypeInCell(mapX, mapY, cellIdx, sensorData) != Thing::_none)) {
+ skipToNextThing = true;
+ break;
+ }
+ _vm->_championMan->getObjectRemovedFromLeaderHand();
+ _vm->_dungeonMan->linkThingToList(thingWithNewCell(leaderHandObject, cellIdx), Thing(0), mapX, mapY);
+ leaderHandObject = Thing::_none;
+ }
+ triggerLocalEffect(k2_SensorEffToggle, mapX, mapY, cellIdx); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
+ if ((sensorEffect == k3_SensorEffHold) && !_vm->_championMan->_leaderEmptyHanded)
+ doNotTriggerSensor = true;
+ else
+ doNotTriggerSensor = false;
+
+ break;
+ case k16_SensorWallObjExchanger: {
+ if (sensorCountToProcessPerCell[cellIdx]) { /* If the sensor is not the last one of its type on the cell */
+ skipToNextThing = true;
+ break;
+ }
+ Thing thingOnSquare = _vm->_dungeonMan->getSquareFirstObject(mapX, mapY);
+ if ((_vm->_objectMan->getObjectType(leaderHandObject) != sensorData) || (thingOnSquare == Thing::_none)) {
+ skipToNextThing = true;
+ break;
+ }
+ _vm->_dungeonMan->unlinkThingFromList(thingOnSquare, Thing(0), mapX, mapY);
_vm->_championMan->getObjectRemovedFromLeaderHand();
- _vm->_dungeonMan->linkThingToList(thingWithNewCell(L0761_T_LeaderHandObject, L0752_ui_Cell), Thing(0), mapX, mapY);
- L0761_T_LeaderHandObject = Thing::_none;
- }
- triggerLocalEffect(k2_SensorEffToggle, mapX, mapY, L0752_ui_Cell); /* This will cause a rotation of the sensors at the specified cell on the specified square after all sensors have been processed */
- if ((L0756_i_SensorEffect == k3_SensorEffHold) && !_vm->_championMan->_leaderEmptyHanded) {
- L0753_B_DoNotTriggerSensor = true;
- } else {
- L0753_B_DoNotTriggerSensor = false;
+ _vm->_dungeonMan->linkThingToList(thingWithNewCell(leaderHandObject, cellIdx), Thing(0), mapX, mapY);
+ _vm->_championMan->putObjectInLeaderHand(thingOnSquare, true);
+ doNotTriggerSensor = false;
+ }
+ break;
+ case k127_SensorWallChampionPortrait:
+ _vm->_championMan->addCandidateChampionToParty(sensorData);
+ skipToNextThing = true;
+ break;
+ default:
+ skipToNextThing = true;
+ break;
}
- break;
- case k16_SensorWallObjExchanger:
- if (L0760_ai_SensorCountToProcessPerCell[L0752_ui_Cell]) /* If the sensor is not the last one of its type on the cell */
- goto T0275058_ProceedToNextThing;
- L0762_T_ThingOnSquare = _vm->_dungeonMan->getSquareFirstObject(mapX, mapY);
- if ((_vm->_objectMan->getObjectType(L0761_T_LeaderHandObject) != L0758_i_SensorData) || (L0762_T_ThingOnSquare == Thing::_none))
- goto T0275058_ProceedToNextThing;
- _vm->_dungeonMan->unlinkThingFromList(L0762_T_ThingOnSquare, Thing(0), mapX, mapY);
- _vm->_championMan->getObjectRemovedFromLeaderHand();
- _vm->_dungeonMan->linkThingToList(thingWithNewCell(L0761_T_LeaderHandObject, L0752_ui_Cell), Thing(0), mapX, mapY);
- _vm->_championMan->putObjectInLeaderHand(L0762_T_ThingOnSquare, true);
- L0753_B_DoNotTriggerSensor = false;
- break;
- case k127_SensorWallChampionPortrait:
- _vm->_championMan->addCandidateChampionToParty(L0758_i_SensorData);
- goto T0275058_ProceedToNextThing;
- default:
- goto T0275058_ProceedToNextThing;
}
- if (L0756_i_SensorEffect == k3_SensorEffHold) {
- L0756_i_SensorEffect = L0753_B_DoNotTriggerSensor ? k1_SensorEffClear : k0_SensorEffSet;
- L0753_B_DoNotTriggerSensor = false;
- }
- if (!L0753_B_DoNotTriggerSensor) {
- L0759_B_AtLeastOneSensorWasTriggered = true;
- if (L0755_ps_Sensor->getAttrAudibleA()) {
- _vm->_sound->requestPlay(k01_soundSWITCH, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
+
+ if (!skipToNextThing) {
+ if (sensorEffect == k3_SensorEffHold) {
+ sensorEffect = doNotTriggerSensor ? k1_SensorEffClear : k0_SensorEffSet;
+ doNotTriggerSensor = false;
}
- if (!_vm->_championMan->_leaderEmptyHanded && ((L0757_ui_SensorType == k4_SensorWallOrnClickWithSpecObjRemoved) || (L0757_ui_SensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors) || (L0757_ui_SensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor))) {
- L0754_ps_Generic = (Thing *)_vm->_dungeonMan->getThingData(L0761_T_LeaderHandObject);
- *L0754_ps_Generic = Thing::_none;
- _vm->_championMan->getObjectRemovedFromLeaderHand();
- L0761_T_LeaderHandObject = Thing::_none;
- } else {
- if (_vm->_championMan->_leaderEmptyHanded &&
- (L0757_ui_SensorType == k12_SensorWallObjGeneratorRotateSensors) &&
- ((L0761_T_LeaderHandObject = _vm->_dungeonMan->getObjForProjectileLaucherOrObjGen(L0758_i_SensorData)) != Thing::_none)) {
- _vm->_championMan->putObjectInLeaderHand(L0761_T_LeaderHandObject, true);
+ if (!doNotTriggerSensor) {
+ atLeastOneSensorWasTriggered = true;
+ if (currentSensor->getAttrAudibleA())
+ _vm->_sound->requestPlay(k01_soundSWITCH, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k1_soundModePlayIfPrioritized);
+
+ if (!_vm->_championMan->_leaderEmptyHanded && ((processedSensorType == k4_SensorWallOrnClickWithSpecObjRemoved) || (processedSensorType == k11_SensorWallOrnClickWithSpecObjRemovedRotateSensors) || (processedSensorType == k17_SensorWallOrnClickWithSpecObjRemovedSensor))) {
+ Thing *leaderThing = (Thing *)_vm->_dungeonMan->getThingData(leaderHandObject);
+ *leaderThing = Thing::_none;
+ _vm->_championMan->getObjectRemovedFromLeaderHand();
+ leaderHandObject = Thing::_none;
+ } else if (_vm->_championMan->_leaderEmptyHanded
+ && (processedSensorType == k12_SensorWallObjGeneratorRotateSensors)) {
+ leaderHandObject = _vm->_dungeonMan->getObjForProjectileLaucherOrObjGen(sensorData);
+ if (leaderHandObject != Thing::_none)
+ _vm->_championMan->putObjectInLeaderHand(leaderHandObject, true);
}
+ triggerEffect(currentSensor, sensorEffect, mapX, mapY, cellIdx);
}
- triggerEffect(L0755_ps_Sensor, L0756_i_SensorEffect, mapX, mapY, L0752_ui_Cell);
+ skipToNextThing = true;
}
- goto T0275058_ProceedToNextThing;
}
- if (L0751_ui_ThingType >= k4_GroupThingType)
+ if (!skipToNextThing && (ProcessedThingType >= k4_GroupThingType))
break;
-T0275058_ProceedToNextThing:
- L0763_T_LastProcessedThing = L0750_T_ThingBeingProcessed;
- L0750_T_ThingBeingProcessed = _vm->_dungeonMan->getNextThing(L0750_T_ThingBeingProcessed);
+
+ lastProcessedThing = thingBeingProcessed;
+ thingBeingProcessed = _vm->_dungeonMan->getNextThing(thingBeingProcessed);
}
processRotationEffect();
- return L0759_B_AtLeastOneSensorWasTriggered;
+ return atLeastOneSensorWasTriggered;
}
bool MovesensMan::getMoveResult(Thing thing, int16 mapX, int16 mapY, int16 destMapX, int16 destMapY) {
- int16 L0708_i_Multiple = 0;
-#define AL0708_i_DestinationSquare L0708_i_Multiple
-#define AL0708_i_ScentIndex L0708_i_Multiple
-#define AL0708_i_ActiveGroupIndex L0708_i_Multiple
- int16 L0709_i_Multiple;
-#define AL0709_i_DestinationSquareType L0709_i_Multiple
-#define AL0709_i_ChampionIndex L0709_i_Multiple
- int16 L0710_i_ThingType;
- Champion* L0711_ps_Champion;
- Teleporter* L0712_ps_Teleporter;
- int16 L0718_i_RequiredTeleporterScope;
- // Strangerke: Only present in v2.1, but it fixes a bug, so I propose to keep it
- int16 L0719_i_TraversedPitCount;
- uint16 L0720_ui_MoveGroupResult;
- uint16 L0727_ui_Multiple;
-#define AL0727_ui_ThingCell L0727_ui_Multiple
-#define AL0727_ui_Outcome L0727_ui_Multiple
-#define AL0727_ui_Backup L0727_ui_Multiple
- int16 L0728_i_ChainedMoveCount;
- uint16 L1638_ui_MovementSoundIndex;
-
- L0710_i_ThingType = kM1_PartyThingType;
- L0719_i_TraversedPitCount = 0;
- L0720_ui_MoveGroupResult = 0;
-
- uint16 L0717_ui_ThingCell = 0;
-
- bool L0713_B_ThingLevitates = false;
+ ThingType thingType = kM1_PartyThingType;
+ int16 traversedPitCount = 0;
+ uint16 moveGroupResult = 0;
+ uint16 thingCell = 0;
+ bool thingLevitates = false;
+
if (thing != Thing::_party) {
- L0710_i_ThingType = thing.getType();
- L0717_ui_ThingCell = thing.getCell();
- L0713_B_ThingLevitates = isLevitating(thing);
+ thingType = thing.getType();
+ thingCell = thing.getCell();
+ thingLevitates = isLevitating(thing);
}
/* If moving the party or a creature on the party map from a dungeon square then check for a projectile impact */
- if ((mapX >= 0) && ((thing == Thing::_party) || ((L0710_i_ThingType == k4_GroupThingType) && (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex)))) {
- if (moveIsKilledByProjectileImpact(mapX, mapY, destMapX, destMapY, thing)) {
+ if ((mapX >= 0) && ((thing == Thing::_party) || ((thingType == k4_GroupThingType) && (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex)))) {
+ if (moveIsKilledByProjectileImpact(mapX, mapY, destMapX, destMapY, thing))
return true; /* The specified group thing cannot be moved because it was killed by a projectile impact */
- }
}
- uint16 L0714_ui_MapIndexSource = 0;
- uint16 L0715_ui_MapIndexDestination = 0;
- bool L0721_B_GroupOnPartyMap = false;
- bool L0725_B_PartySquare = false;
- bool L0726_B_Audible = false;
+ uint16 mapIndexSource = 0;
+ uint16 mapIndexDestination = 0;
+ bool groupOnPartyMap = false;
+ bool partySquare = false;
+ bool audibleTeleporter = false;
if (destMapX >= 0) {
- L0714_ui_MapIndexSource = L0715_ui_MapIndexDestination = _vm->_dungeonMan->_currMapIndex;
- L0721_B_GroupOnPartyMap = (L0714_ui_MapIndexSource == _vm->_dungeonMan->_partyMapIndex) && (mapX >= 0);
- uint16 L0716_ui_Direction = 0;
- bool L0722_B_FallKilledGroup = false;
- bool L0723_B_DrawDungeonViewWhileFalling = false;
- bool L0724_B_DestinationIsTeleporterTarget = false;
+ mapIndexSource = mapIndexDestination = _vm->_dungeonMan->_currMapIndex;
+ groupOnPartyMap = (mapIndexSource == _vm->_dungeonMan->_partyMapIndex) && (mapX >= 0);
+ uint16 direction = 0;
+ bool fallKilledGroup = false;
+ bool drawDungeonViewWhileFalling = false;
+ bool destinationIsTeleporterTarget = false;
+ int16 requiredTeleporterScope;
if (thing == Thing::_party) {
_vm->_dungeonMan->_partyMapX = destMapX;
_vm->_dungeonMan->_partyMapY = destMapY;
- L0718_i_RequiredTeleporterScope = k0x0002_TelepScopeObjOrParty;
- L0723_B_DrawDungeonViewWhileFalling = !_vm->_inventoryMan->_inventoryChampionOrdinal && !_vm->_championMan->_partyIsSleeping;
- L0716_ui_Direction = _vm->_dungeonMan->_partyDir;
- } else {
- if (L0710_i_ThingType == k4_GroupThingType) {
- L0718_i_RequiredTeleporterScope = k0x0001_TelepScopeCreatures;
- } else {
- L0718_i_RequiredTeleporterScope = (k0x0001_TelepScopeCreatures | k0x0002_TelepScopeObjOrParty);
- }
- }
- if (L0710_i_ThingType == k14_ProjectileThingType) {
- L0712_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->getThingData(thing);
+ requiredTeleporterScope = k0x0002_TelepScopeObjOrParty;
+ drawDungeonViewWhileFalling = !_vm->_inventoryMan->_inventoryChampionOrdinal && !_vm->_championMan->_partyIsSleeping;
+ direction = _vm->_dungeonMan->_partyDir;
+ } else if (thingType == k4_GroupThingType)
+ requiredTeleporterScope = k0x0001_TelepScopeCreatures;
+ else
+ requiredTeleporterScope = (k0x0001_TelepScopeCreatures | k0x0002_TelepScopeObjOrParty);
+
+ if (thingType == k14_ProjectileThingType) {
+ Teleporter *L0712_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->getThingData(thing);
_moveResultDir = (_vm->_timeline->_events[((Projectile *)L0712_ps_Teleporter)->_eventIndex])._C._projectile.getDir();
}
- for (L0728_i_ChainedMoveCount = 1000; --L0728_i_ChainedMoveCount; ) { /* No more than 1000 chained moves at once (in a chain of teleporters and pits for example) */
- AL0708_i_DestinationSquare = _vm->_dungeonMan->_currMapData[destMapX][destMapY];
- if ((AL0709_i_DestinationSquareType = Square(AL0708_i_DestinationSquare).getType()) == k5_ElementTypeTeleporter) {
- if (!getFlag(AL0708_i_DestinationSquare, k0x0008_TeleporterOpen))
+
+ int16 destinationSquareData = 0;
+ /* No more than 1000 chained moves at once (in a chain of teleporters and pits for example) */
+ for (int16 chainedMoveCount = 1000; --chainedMoveCount; ) {
+ destinationSquareData = _vm->_dungeonMan->_currMapData[destMapX][destMapY];
+ SquareType destinationSquareType = Square(destinationSquareData).getType();
+ if (destinationSquareType == k5_ElementTypeTeleporter) {
+ if (!getFlag(destinationSquareData, k0x0008_TeleporterOpen))
break;
- L0712_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->getSquareFirstThingData(destMapX, destMapY);
- if ((L0712_ps_Teleporter->getScope() == k0x0001_TelepScopeCreatures) && (L0710_i_ThingType != k4_GroupThingType))
+
+ Teleporter *teleporter = (Teleporter *)_vm->_dungeonMan->getSquareFirstThingData(destMapX, destMapY);
+ if ((teleporter->getScope() == k0x0001_TelepScopeCreatures) && (thingType != k4_GroupThingType))
break;
- if ((L0718_i_RequiredTeleporterScope != (k0x0001_TelepScopeCreatures | k0x0002_TelepScopeObjOrParty)) && !getFlag(L0712_ps_Teleporter->getScope(), L0718_i_RequiredTeleporterScope))
+
+ if ((requiredTeleporterScope != (k0x0001_TelepScopeCreatures | k0x0002_TelepScopeObjOrParty)) && !getFlag(teleporter->getScope(), requiredTeleporterScope))
break;
- L0724_B_DestinationIsTeleporterTarget = (destMapX == L0712_ps_Teleporter->getTargetMapX()) && (destMapY == L0712_ps_Teleporter->getTargetMapY()) && (L0715_ui_MapIndexDestination == L0712_ps_Teleporter->getTargetMapIndex());
- destMapX = L0712_ps_Teleporter->getTargetMapX();
- destMapY = L0712_ps_Teleporter->getTargetMapY();
- L0726_B_Audible = L0712_ps_Teleporter->isAudible();
- _vm->_dungeonMan->setCurrentMap(L0715_ui_MapIndexDestination = L0712_ps_Teleporter->getTargetMapIndex());
+
+ destinationIsTeleporterTarget = (destMapX == teleporter->getTargetMapX()) && (destMapY == teleporter->getTargetMapY()) && (mapIndexDestination == teleporter->getTargetMapIndex());
+ destMapX = teleporter->getTargetMapX();
+ destMapY = teleporter->getTargetMapY();
+ audibleTeleporter = teleporter->isAudible();
+ _vm->_dungeonMan->setCurrentMap(mapIndexDestination = teleporter->getTargetMapIndex());
if (thing == Thing::_party) {
_vm->_dungeonMan->_partyMapX = destMapX;
_vm->_dungeonMan->_partyMapY = destMapY;
- if (L0712_ps_Teleporter->isAudible()) {
+ if (teleporter->isAudible())
_vm->_sound->requestPlay(k17_soundBUZZ, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k0_soundModePlayImmediately);
- }
- L0723_B_DrawDungeonViewWhileFalling = true;
- if (L0712_ps_Teleporter->getAbsoluteRotation()) {
- _vm->_championMan->setPartyDirection(L0712_ps_Teleporter->getRotation());
- } else {
- _vm->_championMan->setPartyDirection(normalizeModulo4(_vm->_dungeonMan->_partyDir + L0712_ps_Teleporter->getRotation()));
- }
+
+ drawDungeonViewWhileFalling = true;
+ if (teleporter->getAbsoluteRotation())
+ _vm->_championMan->setPartyDirection(teleporter->getRotation());
+ else
+ _vm->_championMan->setPartyDirection(normalizeModulo4(_vm->_dungeonMan->_partyDir + teleporter->getRotation()));
} else {
- if (L0710_i_ThingType == k4_GroupThingType) {
- if (L0712_ps_Teleporter->isAudible()) {
+ if (thingType == k4_GroupThingType) {
+ if (teleporter->isAudible())
_vm->_sound->requestPlay(k17_soundBUZZ, destMapX, destMapY, k1_soundModePlayIfPrioritized);
- }
- L0720_ui_MoveGroupResult = getTeleporterRotatedGroupResult(L0712_ps_Teleporter, thing, L0714_ui_MapIndexSource);
+
+ moveGroupResult = getTeleporterRotatedGroupResult(teleporter, thing, mapIndexSource);
} else {
- if (L0710_i_ThingType == k14_ProjectileThingType) {
- thing = getTeleporterRotatedProjectileThing(L0712_ps_Teleporter, thing);
- } else {
- if (!(L0712_ps_Teleporter->getAbsoluteRotation()) && (mapX != -2)) {
- thing = thingWithNewCell(thing, normalizeModulo4(thing.getCell() + L0712_ps_Teleporter->getRotation()));
- }
- }
+ if (thingType == k14_ProjectileThingType)
+ thing = getTeleporterRotatedProjectileThing(teleporter, thing);
+ else if (!(teleporter->getAbsoluteRotation()) && (mapX != -2))
+ thing = thingWithNewCell(thing, normalizeModulo4(thing.getCell() + teleporter->getRotation()));
}
}
- if (L0724_B_DestinationIsTeleporterTarget)
+ if (destinationIsTeleporterTarget)
break;
} else {
- if ((AL0709_i_DestinationSquareType == k2_ElementTypePit) && !L0713_B_ThingLevitates && getFlag(AL0708_i_DestinationSquare, k0x0008_PitOpen) && !getFlag(AL0708_i_DestinationSquare, k0x0001_PitImaginary)) {
- if (L0723_B_DrawDungeonViewWhileFalling && !_useRopeToClimbDownPit) {
- L0723_B_DrawDungeonViewWhileFalling = true;
- if (L0719_i_TraversedPitCount) {
- _vm->_dungeonMan->setCurrentMapAndPartyMap(L0715_ui_MapIndexDestination);
+ if ((destinationSquareType == k2_ElementTypePit) && !thingLevitates && getFlag(destinationSquareData, k0x0008_PitOpen) && !getFlag(destinationSquareData, k0x0001_PitImaginary)) {
+ if (drawDungeonViewWhileFalling && !_useRopeToClimbDownPit) {
+ drawDungeonViewWhileFalling = true;
+ if (traversedPitCount) {
+ _vm->_dungeonMan->setCurrentMapAndPartyMap(mapIndexDestination);
_vm->_displayMan->loadCurrentMapGraphics();
}
- L0719_i_TraversedPitCount++;
+ traversedPitCount++;
_vm->_displayMan->drawDungeon(_vm->_dungeonMan->_partyDir, destMapX, destMapY); /* BUG0_28 When falling through multiple pits the dungeon view is updated to show each traversed map but the graphics used for creatures, wall and floor ornaments may not be correct. The dungeon view is drawn for each map by using the graphics loaded for the source map. Therefore the graphics for creatures, wall and floor ornaments may not look like what they should */
/* BUG0_71 Some timings are too short on fast computers. When the party falls in a series of pits, the dungeon view is refreshed too quickly because the execution speed is not limited */
/* BUG0_01 While drawing creatures the engine will read invalid ACTIVE_GROUP data in _vm->_groupMan->_g375_activeGroups because the data is for the creatures on the source map and not the map being drawn. The only consequence is that creatures may be drawn with incorrect bitmaps and/or directions */
}
- L0715_ui_MapIndexDestination = _vm->_dungeonMan->getLocationAfterLevelChange(L0715_ui_MapIndexDestination, 1, &destMapX, &destMapY);
- _vm->_dungeonMan->setCurrentMap(L0715_ui_MapIndexDestination);
+ mapIndexDestination = _vm->_dungeonMan->getLocationAfterLevelChange(mapIndexDestination, 1, &destMapX, &destMapY);
+ _vm->_dungeonMan->setCurrentMap(mapIndexDestination);
if (thing == Thing::_party) {
_vm->_dungeonMan->_partyMapX = destMapX;
_vm->_dungeonMan->_partyMapY = destMapY;
if (_vm->_championMan->_partyChampionCount > 0) {
if (_useRopeToClimbDownPit) {
- for (AL0709_i_ChampionIndex = k0_ChampionFirst, L0711_ps_Champion = _vm->_championMan->_champions; AL0709_i_ChampionIndex < _vm->_championMan->_partyChampionCount; AL0709_i_ChampionIndex++, L0711_ps_Champion++) {
- if (L0711_ps_Champion->_currHealth) {
- _vm->_championMan->decrementStamina(AL0709_i_ChampionIndex, ((L0711_ps_Champion->_load * 25) / _vm->_championMan->getMaximumLoad(L0711_ps_Champion)) + 1);
- }
- }
- } else {
- if (_vm->_championMan->getDamagedChampionCount(20, k0x0010_ChampionWoundLegs | k0x0020_ChampionWoundFeet, k2_attackType_SELF)) {
- _vm->_sound->requestPlay(k06_soundSCREAM, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k0_soundModePlayImmediately);
+ Champion *curChampion = _vm->_championMan->_champions;
+ for (int16 championIdx = k0_ChampionFirst; championIdx < _vm->_championMan->_partyChampionCount; championIdx++, curChampion++) {
+ if (curChampion->_currHealth)
+ _vm->_championMan->decrementStamina(championIdx, ((curChampion->_load * 25) / _vm->_championMan->getMaximumLoad(curChampion)) + 1);
}
- }
+ } else if (_vm->_championMan->getDamagedChampionCount(20, k0x0010_ChampionWoundLegs | k0x0020_ChampionWoundFeet, k2_attackType_SELF))
+ _vm->_sound->requestPlay(k06_soundSCREAM, _vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, k0_soundModePlayImmediately);
}
_useRopeToClimbDownPit = false;
- } else {
- if (L0710_i_ThingType == k4_GroupThingType) {
- _vm->_dungeonMan->setCurrentMap(L0714_ui_MapIndexSource);
- AL0727_ui_Outcome = _vm->_groupMan->getDamageAllCreaturesOutcome((Group *)_vm->_dungeonMan->getThingData(thing), mapX, mapY, 20, false);
- _vm->_dungeonMan->setCurrentMap(L0715_ui_MapIndexDestination);
- L0722_B_FallKilledGroup = (AL0727_ui_Outcome == k2_outcomeKilledAllCreaturesInGroup);
- if (L0722_B_FallKilledGroup)
- break;
- if (AL0727_ui_Outcome == k1_outcomeKilledSomeCreaturesInGroup) {
- _vm->_groupMan->dropMovingCreatureFixedPossession(thing, destMapX, destMapY);
- }
- }
+ } else if (thingType == k4_GroupThingType) {
+ _vm->_dungeonMan->setCurrentMap(mapIndexSource);
+ uint16 outcome = _vm->_groupMan->getDamageAllCreaturesOutcome((Group *)_vm->_dungeonMan->getThingData(thing), mapX, mapY, 20, false);
+ _vm->_dungeonMan->setCurrentMap(mapIndexDestination);
+ fallKilledGroup = (outcome == k2_outcomeKilledAllCreaturesInGroup);
+ if (fallKilledGroup)
+ break;
+
+ if (outcome == k1_outcomeKilledSomeCreaturesInGroup)
+ _vm->_groupMan->dropMovingCreatureFixedPossession(thing, destMapX, destMapY);
}
- } else {
- if ((AL0709_i_DestinationSquareType == k3_ElementTypeStairs) && (thing != Thing::_party) && (L0710_i_ThingType != k14_ProjectileThingType)) {
- if (!getFlag(AL0708_i_DestinationSquare, k0x0004_StairsUp)) {
- L0715_ui_MapIndexDestination = _vm->_dungeonMan->getLocationAfterLevelChange(L0715_ui_MapIndexDestination, 1, &destMapX, &destMapY);
- _vm->_dungeonMan->setCurrentMap(L0715_ui_MapIndexDestination);
- }
- L0716_ui_Direction = _vm->_dungeonMan->getStairsExitDirection(destMapX, destMapY);
- destMapX += _vm->_dirIntoStepCountEast[L0716_ui_Direction], destMapY += _vm->_dirIntoStepCountNorth[L0716_ui_Direction];
- L0716_ui_Direction = returnOppositeDir((Direction)L0716_ui_Direction);
- AL0727_ui_ThingCell = thing.getCell();
- AL0727_ui_ThingCell = normalizeModulo4((((AL0727_ui_ThingCell - L0716_ui_Direction + 1) & 0x0002) >> 1) + L0716_ui_Direction);
- thing = thingWithNewCell(thing, AL0727_ui_ThingCell);
- } else
- break;
- }
+ } else if ((destinationSquareType == k3_ElementTypeStairs) && (thing != Thing::_party) && (thingType != k14_ProjectileThingType)) {
+ if (!getFlag(destinationSquareData, k0x0004_StairsUp)) {
+ mapIndexDestination = _vm->_dungeonMan->getLocationAfterLevelChange(mapIndexDestination, 1, &destMapX, &destMapY);
+ _vm->_dungeonMan->setCurrentMap(mapIndexDestination);
+ }
+ direction = _vm->_dungeonMan->getStairsExitDirection(destMapX, destMapY);
+ destMapX += _vm->_dirIntoStepCountEast[direction], destMapY += _vm->_dirIntoStepCountNorth[direction];
+ direction = returnOppositeDir((Direction)direction);
+ uint16 thingCell = thing.getCell();
+ thingCell = normalizeModulo4((((thingCell - direction + 1) & 0x0002) >> 1) + direction);
+ thing = thingWithNewCell(thing, thingCell);
+ } else
+ break;
}
}
- if ((L0710_i_ThingType == k4_GroupThingType) && (L0722_B_FallKilledGroup || !_vm->_dungeonMan->isCreatureAllowedOnMap(thing, L0715_ui_MapIndexDestination))) {
+ if ((thingType == k4_GroupThingType) && (fallKilledGroup || !_vm->_dungeonMan->isCreatureAllowedOnMap(thing, mapIndexDestination))) {
_vm->_groupMan->dropMovingCreatureFixedPossession(thing, destMapX, destMapY);
_vm->_groupMan->dropGroupPossessions(destMapX, destMapY, thing, k2_soundModePlayOneTickLater);
- _vm->_dungeonMan->setCurrentMap(L0714_ui_MapIndexSource);
- if (mapX >= 0) {
+ _vm->_dungeonMan->setCurrentMap(mapIndexSource);
+ if (mapX >= 0)
_vm->_groupMan->groupDelete(mapX, mapY);
- }
+
return true; /* The specified group thing cannot be moved because it was killed by a fall or because it is not allowed on the destination map */
}
_moveResultMapX = destMapX;
_moveResultMapY = destMapY;
- _moveResultMapIndex = L0715_ui_MapIndexDestination;
+ _moveResultMapIndex = mapIndexDestination;
_moveResultCell = thing.getCell();
- L0725_B_PartySquare = (L0715_ui_MapIndexDestination == L0714_ui_MapIndexSource) && (destMapX == mapX) && (destMapY == mapY);
- if (L0725_B_PartySquare) {
+ partySquare = (mapIndexDestination == mapIndexSource) && (destMapX == mapX) && (destMapY == mapY);
+ if (partySquare) {
if (thing == Thing::_party) {
- if (_vm->_dungeonMan->_partyDir == L0716_ui_Direction) {
- return false;
- }
- } else {
- if ((_moveResultCell == L0717_ui_ThingCell) && (L0710_i_ThingType != k14_ProjectileThingType)) {
+ if (_vm->_dungeonMan->_partyDir == direction)
return false;
- }
- }
+ } else if ((_moveResultCell == thingCell) && (thingType != k14_ProjectileThingType))
+ return false;
} else {
if ((thing == Thing::_party) && _vm->_championMan->_partyChampionCount) {
- AL0727_ui_Backup = AL0708_i_DestinationSquare;
- AL0708_i_ScentIndex = _vm->_championMan->_party._scentCount;
- while (AL0708_i_ScentIndex >= 24) {
+ uint16 oldDestinationSquare = destinationSquareData;
+ int16 scentIndex = _vm->_championMan->_party._scentCount;
+ while (scentIndex >= 24) {
_vm->_championMan->deleteScent(0);
- AL0708_i_ScentIndex--;
+ scentIndex--;
}
- if (AL0708_i_ScentIndex) {
+
+ if (scentIndex)
_vm->_championMan->addScentStrength(mapX, mapY, (int)(_vm->_gameTime - _vm->_projexpl->_lastPartyMovementTime));
- }
+
_vm->_projexpl->_lastPartyMovementTime = _vm->_gameTime;
_vm->_championMan->_party._scentCount++;
- if (_vm->_championMan->_party._event79Count_Footprints) {
+ if (_vm->_championMan->_party._event79Count_Footprints)
_vm->_championMan->_party._lastScentIndex = _vm->_championMan->_party._scentCount;
- }
- _vm->_championMan->_party._scents[AL0708_i_ScentIndex].setMapX(destMapX);
- _vm->_championMan->_party._scents[AL0708_i_ScentIndex].setMapY(destMapY);
- _vm->_championMan->_party._scents[AL0708_i_ScentIndex].setMapIndex(L0715_ui_MapIndexDestination);
- _vm->_championMan->_party._scentStrengths[AL0708_i_ScentIndex] = 0;
+
+ _vm->_championMan->_party._scents[scentIndex].setMapX(destMapX);
+ _vm->_championMan->_party._scents[scentIndex].setMapY(destMapY);
+ _vm->_championMan->_party._scents[scentIndex].setMapIndex(mapIndexDestination);
+ _vm->_championMan->_party._scentStrengths[scentIndex] = 0;
_vm->_championMan->addScentStrength(destMapX, destMapY, k0x8000_mergeCycles | 24);
- AL0708_i_DestinationSquare = AL0727_ui_Backup;
- }
- if (L0715_ui_MapIndexDestination != L0714_ui_MapIndexSource) {
- _vm->_dungeonMan->setCurrentMap(L0714_ui_MapIndexSource);
+ destinationSquareData = oldDestinationSquare;
}
+ if (mapIndexDestination != mapIndexSource)
+ _vm->_dungeonMan->setCurrentMap(mapIndexSource);
}
}
if (mapX >= 0) {
- if (thing == Thing::_party) {
- processThingAdditionOrRemoval(mapX, mapY, Thing::_party, L0725_B_PartySquare, false);
- } else {
- if (L0713_B_ThingLevitates) {
- _vm->_dungeonMan->unlinkThingFromList(thing, Thing(0), mapX, mapY);
- } else {
- processThingAdditionOrRemoval(mapX, mapY, thing, (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (mapX == _vm->_dungeonMan->_partyMapX) && (mapY == _vm->_dungeonMan->_partyMapY), false);
- }
- }
+ if (thing == Thing::_party)
+ processThingAdditionOrRemoval(mapX, mapY, Thing::_party, partySquare, false);
+ else if (thingLevitates)
+ _vm->_dungeonMan->unlinkThingFromList(thing, Thing::_none, mapX, mapY);
+ else
+ processThingAdditionOrRemoval(mapX, mapY, thing, (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (mapX == _vm->_dungeonMan->_partyMapX) && (mapY == _vm->_dungeonMan->_partyMapY), false);
}
if (destMapX >= 0) {
if (thing == Thing::_party) {
- _vm->_dungeonMan->setCurrentMap(L0715_ui_MapIndexDestination);
+ _vm->_dungeonMan->setCurrentMap(mapIndexDestination);
if ((thing = _vm->_groupMan->groupGetThing(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY)) != Thing::_endOfList) { /* Delete group if party moves onto its square */
_vm->_groupMan->dropGroupPossessions(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, thing, k1_soundModePlayIfPrioritized);
_vm->_groupMan->groupDelete(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY);
}
- if (L0715_ui_MapIndexDestination == L0714_ui_MapIndexSource) {
- processThingAdditionOrRemoval(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, Thing::_party, L0725_B_PartySquare, true);
- } else {
- _vm->_dungeonMan->setCurrentMap(L0714_ui_MapIndexSource);
- _vm->_newPartyMapIndex = L0715_ui_MapIndexDestination;
+
+ if (mapIndexDestination == mapIndexSource)
+ processThingAdditionOrRemoval(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, Thing::_party, partySquare, true);
+ else {
+ _vm->_dungeonMan->setCurrentMap(mapIndexSource);
+ _vm->_newPartyMapIndex = mapIndexDestination;
}
} else {
- if (L0710_i_ThingType == k4_GroupThingType) {
- _vm->_dungeonMan->setCurrentMap(L0715_ui_MapIndexDestination);
- L0712_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->getThingData(thing);
- AL0708_i_ActiveGroupIndex = ((Group *)L0712_ps_Teleporter)->getActiveGroupIndex();
- if (((L0715_ui_MapIndexDestination == _vm->_dungeonMan->_partyMapIndex) && (destMapX == _vm->_dungeonMan->_partyMapX) && (destMapY == _vm->_dungeonMan->_partyMapY)) || (_vm->_groupMan->groupGetThing(destMapX, destMapY) != Thing::_endOfList)) { /* If a group tries to move to the party square or over another group then create an event to move the group later */
- _vm->_dungeonMan->setCurrentMap(L0714_ui_MapIndexSource);
- if (mapX >= 0) {
+ if (thingType == k4_GroupThingType) {
+ _vm->_dungeonMan->setCurrentMap(mapIndexDestination);
+ Teleporter *L0712_ps_Teleporter = (Teleporter *)_vm->_dungeonMan->getThingData(thing);
+ int16 activeGroupIndex = ((Group *)L0712_ps_Teleporter)->getActiveGroupIndex();
+ if (((mapIndexDestination == _vm->_dungeonMan->_partyMapIndex) && (destMapX == _vm->_dungeonMan->_partyMapX) && (destMapY == _vm->_dungeonMan->_partyMapY)) || (_vm->_groupMan->groupGetThing(destMapX, destMapY) != Thing::_endOfList)) { /* If a group tries to move to the party square or over another group then create an event to move the group later */
+ _vm->_dungeonMan->setCurrentMap(mapIndexSource);
+ if (mapX >= 0)
_vm->_groupMan->groupDeleteEvents(mapX, mapY);
- }
- if (L0721_B_GroupOnPartyMap) {
- _vm->_groupMan->removeActiveGroup(AL0708_i_ActiveGroupIndex);
- }
- createEventMoveGroup(thing, destMapX, destMapY, L0715_ui_MapIndexDestination, L0726_B_Audible);
+
+ if (groupOnPartyMap)
+ _vm->_groupMan->removeActiveGroup(activeGroupIndex);
+
+ createEventMoveGroup(thing, destMapX, destMapY, mapIndexDestination, audibleTeleporter);
return true; /* The specified group thing cannot be moved because the party or another group is on the destination square */
}
- L1638_ui_MovementSoundIndex = getSound(((Group *)_vm->_dungeonMan->_thingData[k4_GroupThingType])[thing.getIndex()]._type);
- if (L1638_ui_MovementSoundIndex < k34_D13_soundCount) {
- _vm->_sound->requestPlay(L1638_ui_MovementSoundIndex, destMapX, destMapY, k1_soundModePlayIfPrioritized);
- }
- if (L0721_B_GroupOnPartyMap && (L0715_ui_MapIndexDestination != _vm->_dungeonMan->_partyMapIndex)) { /* If the group leaves the party map */
- _vm->_groupMan->removeActiveGroup(AL0708_i_ActiveGroupIndex);
- L0720_ui_MoveGroupResult = true;
- } else {
- if ((L0715_ui_MapIndexDestination == _vm->_dungeonMan->_partyMapIndex) && (!L0721_B_GroupOnPartyMap)) { /* If the group arrives on the party map */
- _vm->_groupMan->addActiveGroup(thing, destMapX, destMapY);
- L0720_ui_MoveGroupResult = true;
- }
+ uint16 movementSoundIndex = getSound(((Group *)_vm->_dungeonMan->_thingData[k4_GroupThingType])[thing.getIndex()]._type);
+ if (movementSoundIndex < k34_D13_soundCount)
+ _vm->_sound->requestPlay(movementSoundIndex, destMapX, destMapY, k1_soundModePlayIfPrioritized);
+
+ if (groupOnPartyMap && (mapIndexDestination != _vm->_dungeonMan->_partyMapIndex)) { /* If the group leaves the party map */
+ _vm->_groupMan->removeActiveGroup(activeGroupIndex);
+ moveGroupResult = true;
+ } else if ((mapIndexDestination == _vm->_dungeonMan->_partyMapIndex) && (!groupOnPartyMap)) { /* If the group arrives on the party map */
+ _vm->_groupMan->addActiveGroup(thing, destMapX, destMapY);
+ moveGroupResult = true;
}
- if (L0713_B_ThingLevitates) {
+ if (thingLevitates)
_vm->_dungeonMan->linkThingToList(thing, Thing(0), destMapX, destMapY);
- } else {
+ else
processThingAdditionOrRemoval(destMapX, destMapY, thing, false, true);
- }
- if (L0720_ui_MoveGroupResult || (mapX < 0)) { /* If group moved from one map to another or if it was just placed on a square */
+
+ if (moveGroupResult || (mapX < 0)) /* If group moved from one map to another or if it was just placed on a square */
_vm->_groupMan->startWandering(destMapX, destMapY);
- }
- _vm->_dungeonMan->setCurrentMap(L0714_ui_MapIndexSource);
+
+ _vm->_dungeonMan->setCurrentMap(mapIndexSource);
if (mapX >= 0) {
- if (L0720_ui_MoveGroupResult > 1) { /* If the group behavior was C6_BEHAVIOR_ATTACK before being teleported from and to the party map */
- _vm->_groupMan->stopAttacking(&_vm->_groupMan->_activeGroups[L0720_ui_MoveGroupResult - 2], mapX, mapY);
- } else {
- if (L0720_ui_MoveGroupResult) { /* If the group was teleported or leaved the party map or entered the party map */
- _vm->_groupMan->groupDeleteEvents(mapX, mapY);
- }
- }
+ if (moveGroupResult > 1) /* If the group behavior was C6_BEHAVIOR_ATTACK before being teleported from and to the party map */
+ _vm->_groupMan->stopAttacking(&_vm->_groupMan->_activeGroups[moveGroupResult - 2], mapX, mapY);
+ else if (moveGroupResult) /* If the group was teleported or leaved the party map or entered the party map */
+ _vm->_groupMan->groupDeleteEvents(mapX, mapY);
}
- return L0720_ui_MoveGroupResult;
+ return moveGroupResult;
}
- _vm->_dungeonMan->setCurrentMap(L0715_ui_MapIndexDestination);
- if (L0710_i_ThingType == k14_ProjectileThingType) { /* BUG0_29 An explosion can trigger a floor sensor. Explosions do not trigger floor sensors on the square where they are created. However, if an explosion is moved by a teleporter (or by falling into a pit, see BUG0_26) after it was created, it can trigger floor sensors on the destination square. This is because explosions are not considered as levitating in the code, while projectiles are. The condition here should be (L0713_B_ThingLevitates) so that explosions would not start sensor processing on their destination square as they should be Levitating. This would work if F0264_MOVE_IsLevitating returned true for explosions (see BUG0_26) */
+ _vm->_dungeonMan->setCurrentMap(mapIndexDestination);
+ if (thingType == k14_ProjectileThingType) /* BUG0_29 An explosion can trigger a floor sensor. Explosions do not trigger floor sensors on the square where they are created. However, if an explosion is moved by a teleporter (or by falling into a pit, see BUG0_26) after it was created, it can trigger floor sensors on the destination square. This is because explosions are not considered as levitating in the code, while projectiles are. The condition here should be (L0713_B_ThingLevitates) so that explosions would not start sensor processing on their destination square as they should be Levitating. This would work if F0264_MOVE_IsLevitating returned true for explosions (see BUG0_26) */
_vm->_dungeonMan->linkThingToList(thing, Thing(0), destMapX, destMapY);
- } else {
+ else
processThingAdditionOrRemoval(destMapX, destMapY, thing, (_vm->_dungeonMan->_currMapIndex == _vm->_dungeonMan->_partyMapIndex) && (destMapX == _vm->_dungeonMan->_partyMapX) && (destMapY == _vm->_dungeonMan->_partyMapY), true);
- }
- _vm->_dungeonMan->setCurrentMap(L0714_ui_MapIndexSource);
+
+ _vm->_dungeonMan->setCurrentMap(mapIndexSource);
}
}
return false;
}
bool MovesensMan::isLevitating(Thing thing) {
- int16 L0695_i_ThingType;
-
+ ThingType thingType = thing.getType();
+ bool retVal = false;
+ if (thingType == k4_GroupThingType)
+ retVal = getFlag(_vm->_dungeonMan->getCreatureAttributes(thing), k0x0020_MaskCreatureInfo_levitation);
+ else if ((thingType == k14_ProjectileThingType) || (thingType == k15_ExplosionThingType))
+ // Fix original bug involving explosions falling in pits
+ retVal = true;
- if ((L0695_i_ThingType = thing.getType()) == k4_GroupThingType) {
- return getFlag(_vm->_dungeonMan->getCreatureAttributes(thing), k0x0020_MaskCreatureInfo_levitation);
- }
- if (L0695_i_ThingType == k14_ProjectileThingType) { /* BUG0_26 An explosion may fall in a pit. If a pit is opened while there is an explosion above then the explosion falls into the pit in F0267_MOVE_GetMoveResult_CPSCE. Explosions are not considered as levitating so they are moved when the pit is opened. This function should return true for explosions */
- return true;
- }
- return false;
+ return retVal;
}
bool MovesensMan::moveIsKilledByProjectileImpact(int16 srcMapX, int16 srcMapY, int16 destMapX, int16 destMapY, Thing thing) {
- Thing L0697_T_Thing;
- uint16 L0699_ui_Multiple;
-#define AL0699_ui_Cell L0699_ui_Multiple
-#define AL0699_ui_PrimaryDirection L0699_ui_Multiple
-#define AL0699_ui_ChampionOrCreatureOrdinal L0699_ui_Multiple
- int16 L0700_i_Multiple;
-#define AL0700_B_CreatureAlive L0700_i_Multiple
-#define AL0700_i_Distance L0700_i_Multiple
-#define AL0700_i_SecondaryDirection L0700_i_Multiple
- Group* L0701_ps_Group;
- int16 L0702_i_ImpactType;
- bool L0703_B_CheckDestinationSquareProjectileImpacts;
- uint16 L0704_ui_ProjectileMapX;
- uint16 L0705_ui_ProjectileMapY;
- byte L0706_auc_IntermediaryChampionOrCreatureOrdinalInCell[4]; /* This array is used only when moving between two adjacent squares and is used to test projectile impacts when the party or group is in the 'intermediary' step between the two squares. Without this test, in the example below no impact would be detected. In this example, the party moves from the source square on the left (which contains a single champion at cell 2) to the destination square on the right (which contains a single projectile at cell 3).
- Party: Projectiles on target square: Incorrect result without the test for the intermediary step (the champion would have passed through the projectile without impact):
- 00 -> 00 00
- 01 P0 P1 */
- byte L0707_auc_ChampionOrCreatureOrdinalInCell[4]; /* This array has an entry for each cell on the source square, containing the ordinal of the champion or creature (0 if there is no champion or creature at this cell) */
-
-
- L0703_B_CheckDestinationSquareProjectileImpacts = false;
+ /* This array is used only when moving between two adjacent squares and is used to test projectile
+ impacts when the party or group is in the 'intermediary' step between the two squares. Without
+ this test, in the example below no impact would be detected. In this example, the party moves from
+ the source square on the left (which contains a single champion at cell 2) to the destination square
+ on the right (which contains a single projectile at cell 3).
+ Party: Projectiles on target square: Incorrect result without the test for the intermediary step (the champion would have passed through the projectile without impact):
+ 00 -> 00 00
+ 01 P0 P1 */
+ byte intermediaryChampionOrCreatureOrdinalInCell[4];
+
+ /* This array has an entry for each cell on the source square, containing the ordinal of the champion
+ or creature (0 if there is no champion or creature at this cell) */
+ byte championOrCreatureOrdinalInCell[4];
+
+ bool checkDestinationSquareProjectileImpacts = false;
for (int16 i = 0; i < 4; ++i)
- L0707_auc_ChampionOrCreatureOrdinalInCell[i] = 0;
+ championOrCreatureOrdinalInCell[i] = 0;
+
+ SquareType impactType;
if (thing == Thing::_party) {
- L0702_i_ImpactType = kM2_ChampionElemType;
- for (AL0699_ui_Cell = k0_CellNorthWest; AL0699_ui_Cell < k3_CellSouthWest + 1; AL0699_ui_Cell++) {
- if (_vm->_championMan->getIndexInCell((ViewCell)AL0699_ui_Cell) >= 0) {
- L0707_auc_ChampionOrCreatureOrdinalInCell[AL0699_ui_Cell] = _vm->indexToOrdinal(AL0699_ui_Cell);
- }
+ impactType = kM2_ChampionElemType;
+ for (uint16 cellIdx = k0_CellNorthWest; cellIdx < k3_CellSouthWest + 1; cellIdx++) {
+ if (_vm->_championMan->getIndexInCell((ViewCell)cellIdx) >= 0)
+ championOrCreatureOrdinalInCell[cellIdx] = _vm->indexToOrdinal(cellIdx);
}
} else {
- L0702_i_ImpactType = kM1_CreatureElemType;
- L0701_ps_Group = (Group *)_vm->_dungeonMan->getThingData(thing);
- for (AL0699_ui_Cell = k0_CellNorthWest, AL0700_B_CreatureAlive = false; AL0699_ui_Cell < k3_CellSouthWest + 1; AL0699_ui_Cell++) {
- AL0700_B_CreatureAlive |= L0701_ps_Group->_health[AL0699_ui_Cell];
- if (_vm->_groupMan->getCreatureOrdinalInCell(L0701_ps_Group, AL0699_ui_Cell)) {
- L0707_auc_ChampionOrCreatureOrdinalInCell[AL0699_ui_Cell] = _vm->indexToOrdinal(AL0699_ui_Cell);
- }
+ impactType = kM1_CreatureElemType;
+ Group *curGroup = (Group *)_vm->_dungeonMan->getThingData(thing);
+ int16 creatureAlive = 0;
+ for (uint16 cellIdx = k0_CellNorthWest; cellIdx < k3_CellSouthWest + 1; cellIdx++) {
+ creatureAlive |= curGroup->_health[cellIdx];
+ if (_vm->_groupMan->getCreatureOrdinalInCell(curGroup, cellIdx))
+ championOrCreatureOrdinalInCell[cellIdx] = _vm->indexToOrdinal(cellIdx);
}
- if (!AL0700_B_CreatureAlive) {
+ if (!creatureAlive)
return false;
- }
}
- if ((destMapX >= 0) && ((abs(srcMapX - destMapX) + abs(srcMapY - destMapY)) == 1)) { /* If source and destination squares are adjacent (if party or group is not being teleported) */
- AL0699_ui_PrimaryDirection = _vm->_groupMan->getDirsWhereDestIsVisibleFromSource(srcMapX, srcMapY, destMapX, destMapY);
- AL0700_i_SecondaryDirection = returnNextVal(AL0699_ui_PrimaryDirection);
+ if ((destMapX >= 0) && ((abs(srcMapX - destMapX) + abs(srcMapY - destMapY)) == 1)) {
+ /* If source and destination squares are adjacent (if party or group is not being teleported) */
+ int16 primaryDirection = _vm->_groupMan->getDirsWhereDestIsVisibleFromSource(srcMapX, srcMapY, destMapX, destMapY);
+ int16 secondaryDirection = returnNextVal(primaryDirection);
for (int16 i = 0; i < 4; ++i)
- L0706_auc_IntermediaryChampionOrCreatureOrdinalInCell[i] = 0;
+ intermediaryChampionOrCreatureOrdinalInCell[i] = 0;
- L0706_auc_IntermediaryChampionOrCreatureOrdinalInCell[returnPrevVal(AL0699_ui_PrimaryDirection)] = L0707_auc_ChampionOrCreatureOrdinalInCell[AL0699_ui_PrimaryDirection];
- if (L0706_auc_IntermediaryChampionOrCreatureOrdinalInCell[returnPrevVal(AL0699_ui_PrimaryDirection)]) {
- L0703_B_CheckDestinationSquareProjectileImpacts = true;
- }
+ intermediaryChampionOrCreatureOrdinalInCell[returnPrevVal(primaryDirection)] = championOrCreatureOrdinalInCell[primaryDirection];
+ if (intermediaryChampionOrCreatureOrdinalInCell[returnPrevVal(primaryDirection)])
+ checkDestinationSquareProjectileImpacts = true;
- L0706_auc_IntermediaryChampionOrCreatureOrdinalInCell[returnNextVal(AL0700_i_SecondaryDirection)] = L0707_auc_ChampionOrCreatureOrdinalInCell[AL0700_i_SecondaryDirection];
- if (L0706_auc_IntermediaryChampionOrCreatureOrdinalInCell[returnNextVal(AL0700_i_SecondaryDirection)]) {
- L0703_B_CheckDestinationSquareProjectileImpacts = true;
- }
- if (!L0707_auc_ChampionOrCreatureOrdinalInCell[AL0699_ui_PrimaryDirection]) {
- L0707_auc_ChampionOrCreatureOrdinalInCell[AL0699_ui_PrimaryDirection] = L0707_auc_ChampionOrCreatureOrdinalInCell[returnPrevVal(AL0699_ui_PrimaryDirection)];
- }
- if (!L0707_auc_ChampionOrCreatureOrdinalInCell[AL0700_i_SecondaryDirection]) {
- L0707_auc_ChampionOrCreatureOrdinalInCell[AL0700_i_SecondaryDirection] = L0707_auc_ChampionOrCreatureOrdinalInCell[returnNextVal(AL0700_i_SecondaryDirection)];
- }
+ intermediaryChampionOrCreatureOrdinalInCell[returnNextVal(secondaryDirection)] = championOrCreatureOrdinalInCell[secondaryDirection];
+ if (intermediaryChampionOrCreatureOrdinalInCell[returnNextVal(secondaryDirection)])
+ checkDestinationSquareProjectileImpacts = true;
+
+ if (!championOrCreatureOrdinalInCell[primaryDirection])
+ championOrCreatureOrdinalInCell[primaryDirection] = championOrCreatureOrdinalInCell[returnPrevVal(primaryDirection)];
+
+ if (!championOrCreatureOrdinalInCell[secondaryDirection])
+ championOrCreatureOrdinalInCell[secondaryDirection] = championOrCreatureOrdinalInCell[returnNextVal(secondaryDirection)];
}
- L0704_ui_ProjectileMapX = srcMapX; /* Check impacts with projectiles on the source square */
- L0705_ui_ProjectileMapY = srcMapY;
+ uint16 projectileMapX = srcMapX; /* Check impacts with projectiles on the source square */
+ uint16 projectileMapY = srcMapY;
T0266017_CheckProjectileImpacts:
- L0697_T_Thing = _vm->_dungeonMan->getSquareFirstThing(L0704_ui_ProjectileMapX, L0705_ui_ProjectileMapY);
- while (L0697_T_Thing != Thing::_endOfList) {
- if (((L0697_T_Thing).getType() == k14_ProjectileThingType) &&
- (_vm->_timeline->_events[(((Projectile *)_vm->_dungeonMan->_thingData[k14_ProjectileThingType])[(L0697_T_Thing).getIndex()])._eventIndex]._type != k48_TMEventTypeMoveProjectileIgnoreImpacts) && (AL0699_ui_ChampionOrCreatureOrdinal = L0707_auc_ChampionOrCreatureOrdinalInCell[(L0697_T_Thing).getCell()]) &&
- _vm->_projexpl->hasProjectileImpactOccurred(L0702_i_ImpactType, srcMapX, srcMapY, _vm->ordinalToIndex(AL0699_ui_ChampionOrCreatureOrdinal), L0697_T_Thing)) {
- _vm->_projexpl->projectileDeleteEvent(L0697_T_Thing);
- if (_vm->_projexpl->_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup) {
- return true;
+ Thing curThing = _vm->_dungeonMan->getSquareFirstThing(projectileMapX, projectileMapY);
+ while (curThing != Thing::_endOfList) {
+ if ((curThing.getType() == k14_ProjectileThingType) &&
+ (_vm->_timeline->_events[(((Projectile *)_vm->_dungeonMan->_thingData[k14_ProjectileThingType])[curThing.getIndex()])._eventIndex]._type != k48_TMEventTypeMoveProjectileIgnoreImpacts)) {
+ int16 championOrCreatureOrdinal = championOrCreatureOrdinalInCell[curThing.getCell()];
+ if (championOrCreatureOrdinal && _vm->_projexpl->hasProjectileImpactOccurred(impactType, srcMapX, srcMapY, _vm->ordinalToIndex(championOrCreatureOrdinal), curThing)) {
+ _vm->_projexpl->projectileDeleteEvent(curThing);
+ if (_vm->_projexpl->_creatureDamageOutcome == k2_outcomeKilledAllCreaturesInGroup)
+ return true;
+
+ goto T0266017_CheckProjectileImpacts;
}
- goto T0266017_CheckProjectileImpacts;
}
- L0697_T_Thing = _vm->_dungeonMan->getNextThing(L0697_T_Thing);
+ curThing = _vm->_dungeonMan->getNextThing(curThing);
}
- if (L0703_B_CheckDestinationSquareProjectileImpacts) {
- srcMapX |= ((L0704_ui_ProjectileMapX = destMapX) + 1) << 8; /* Check impacts with projectiles on the destination square */
- srcMapY |= (L0705_ui_ProjectileMapY = destMapY) << 8;
+ if (checkDestinationSquareProjectileImpacts) {
+ srcMapX |= ((projectileMapX = destMapX) + 1) << 8; /* Check impacts with projectiles on the destination square */
+ srcMapY |= (projectileMapY = destMapY) << 8;
for (uint16 i = 0; i < 4; ++i)
- L0707_auc_ChampionOrCreatureOrdinalInCell[i] = L0706_auc_IntermediaryChampionOrCreatureOrdinalInCell[i];
- L0703_B_CheckDestinationSquareProjectileImpacts = false;
+ championOrCreatureOrdinalInCell[i] = intermediaryChampionOrCreatureOrdinalInCell[i];
+ checkDestinationSquareProjectileImpacts = false;
goto T0266017_CheckProjectileImpacts;
}
return false;
}
void MovesensMan::addEvent(byte type, byte mapX, byte mapY, byte cell, byte effect, int32 time) {
- TimelineEvent L0729_s_Event;
-
- setMapAndTime(L0729_s_Event._mapTime, _vm->_dungeonMan->_currMapIndex, time);
- L0729_s_Event._type = type;
- L0729_s_Event._priority = 0;
- L0729_s_Event._B._location._mapX = mapX;
- L0729_s_Event._B._location._mapY = mapY;
- L0729_s_Event._C.A._cell = cell;
- L0729_s_Event._C.A._effect = effect;
- _vm->_timeline->addEventGetEventIndex(&L0729_s_Event);
+ TimelineEvent newEvent;
+ setMapAndTime(newEvent._mapTime, _vm->_dungeonMan->_currMapIndex, time);
+ newEvent._type = type;
+ newEvent._priority = 0;
+ newEvent._B._location._mapX = mapX;
+ newEvent._B._location._mapY = mapY;
+ newEvent._C.A._cell = cell;
+ newEvent._C.A._effect = effect;
+ _vm->_timeline->addEventGetEventIndex(&newEvent);
}
int16 MovesensMan::getSound(byte creatureType) {
- if (_vm->_championMan->_partyIsSleeping) {
+ if (_vm->_championMan->_partyIsSleeping)
return 35;
- }
switch (creatureType) {
case k3_CreatureTypeWizardEyeFlyingEye:
@@ -687,320 +651,299 @@ int16 MovesensMan::getSound(byte creatureType) {
case k17_CreatureTypeGiantWaspMuncher:
return k23_soundMOVE_COUATL_GIANT_WASP_MUNCHER;
}
- return -1000; // if this is returned, it's an error, this should break it good
+
+ return 35;
}
-int16 MovesensMan::getTeleporterRotatedGroupResult(Teleporter* teleporter, Thing thing, uint16 mapIndex) {
- int16 L0683_i_Rotation;
- uint16 L0684_ui_GroupDirections;
- uint16 L0685_ui_UpdatedGroupDirections;
- Group* L0686_ps_Group;
- uint16 L0687_ui_UpdatedGroupCells;
- int16 L0688_i_CreatureIndex;
- bool L0689_B_AbsoluteRotation;
- uint16 L0690_ui_GroupCells;
- int16 L0691_i_CreatureSize;
- int16 L0692_i_RelativeRotation;
-
- L0686_ps_Group = (Group *)_vm->_dungeonMan->getThingData(thing);
- L0683_i_Rotation = teleporter->getRotation();
- L0684_ui_GroupDirections = _vm->_groupMan->getGroupDirections(L0686_ps_Group, mapIndex);
-
- L0689_B_AbsoluteRotation = teleporter->getAbsoluteRotation();
- if (L0689_B_AbsoluteRotation) {
- L0685_ui_UpdatedGroupDirections = L0683_i_Rotation;
- } else {
- L0685_ui_UpdatedGroupDirections = normalizeModulo4(L0684_ui_GroupDirections + L0683_i_Rotation);
- }
+int16 MovesensMan::getTeleporterRotatedGroupResult(Teleporter *teleporter, Thing thing, uint16 mapIndex) {
+ Group *group = (Group *)_vm->_dungeonMan->getThingData(thing);
+ Direction rotation = teleporter->getRotation();
+ uint16 groupDirections = _vm->_groupMan->getGroupDirections(group, mapIndex);
- L0687_ui_UpdatedGroupCells = _vm->_groupMan->getGroupCells(L0686_ps_Group, mapIndex);
- if (L0687_ui_UpdatedGroupCells != k255_CreatureTypeSingleCenteredCreature) {
- L0690_ui_GroupCells = L0687_ui_UpdatedGroupCells;
- L0691_i_CreatureSize = getFlag(_vm->_dungeonMan->_creatureInfos[L0686_ps_Group->_type]._attributes, k0x0003_MaskCreatureInfo_size);
- L0692_i_RelativeRotation = normalizeModulo4(4 + L0685_ui_UpdatedGroupDirections - L0684_ui_GroupDirections);
- for (L0688_i_CreatureIndex = 0; L0688_i_CreatureIndex <= L0686_ps_Group->getCount(); L0688_i_CreatureIndex++) {
- L0685_ui_UpdatedGroupDirections = _vm->_groupMan->getGroupValueUpdatedWithCreatureValue(L0685_ui_UpdatedGroupDirections, L0688_i_CreatureIndex, L0689_B_AbsoluteRotation ? L0683_i_Rotation : normalizeModulo4(L0684_ui_GroupDirections + L0683_i_Rotation));
- if (L0691_i_CreatureSize == k0_MaskCreatureSizeQuarter) {
- L0692_i_RelativeRotation = !L0689_B_AbsoluteRotation;
- if (L0692_i_RelativeRotation)
- L0692_i_RelativeRotation = L0683_i_Rotation;
- }
- if (L0692_i_RelativeRotation) {
- L0687_ui_UpdatedGroupCells = _vm->_groupMan->getGroupValueUpdatedWithCreatureValue(L0687_ui_UpdatedGroupCells, L0688_i_CreatureIndex, normalizeModulo4(L0690_ui_GroupCells + L0692_i_RelativeRotation));
+ bool absoluteRotation = teleporter->getAbsoluteRotation();
+ uint16 updatedGroupDirections;
+ if (absoluteRotation)
+ updatedGroupDirections = rotation;
+ else
+ updatedGroupDirections = normalizeModulo4(groupDirections + rotation);
+
+ uint16 updatedGroupCells = _vm->_groupMan->getGroupCells(group, mapIndex);
+ if (updatedGroupCells != k255_CreatureTypeSingleCenteredCreature) {
+ int16 groupCells = updatedGroupCells;
+ int16 creatureSize = getFlag(_vm->_dungeonMan->_creatureInfos[group->_type]._attributes, k0x0003_MaskCreatureInfo_size);
+ int16 relativeRotation = normalizeModulo4(4 + updatedGroupDirections - groupDirections);
+ for (int16 creatureIdx = 0; creatureIdx <= group->getCount(); creatureIdx++) {
+ updatedGroupDirections = _vm->_groupMan->getGroupValueUpdatedWithCreatureValue(updatedGroupDirections, creatureIdx, absoluteRotation ? rotation : normalizeModulo4(groupDirections + rotation));
+ if (creatureSize == k0_MaskCreatureSizeQuarter) {
+ relativeRotation = absoluteRotation ? 1 : 0;
+ if (relativeRotation)
+ relativeRotation = rotation;
}
- L0684_ui_GroupDirections >>= 2;
- L0690_ui_GroupCells >>= 2;
+ if (relativeRotation)
+ updatedGroupCells = _vm->_groupMan->getGroupValueUpdatedWithCreatureValue(updatedGroupCells, creatureIdx, normalizeModulo4(groupCells + relativeRotation));
+
+ groupDirections >>= 2;
+ groupCells >>= 2;
}
}
- _vm->_dungeonMan->setGroupDirections(L0686_ps_Group, L0685_ui_UpdatedGroupDirections, mapIndex);
- _vm->_dungeonMan->setGroupCells(L0686_ps_Group, L0687_ui_UpdatedGroupCells, mapIndex);
- if ((mapIndex == _vm->_dungeonMan->_partyMapIndex) && (L0686_ps_Group->setBehaviour(k6_behavior_ATTACK))) {
- return L0686_ps_Group->getActiveGroupIndex() + 2;
- }
+ _vm->_dungeonMan->setGroupDirections(group, updatedGroupDirections, mapIndex);
+ _vm->_dungeonMan->setGroupCells(group, updatedGroupCells, mapIndex);
+ if ((mapIndex == _vm->_dungeonMan->_partyMapIndex) && (group->setBehaviour(k6_behavior_ATTACK)))
+ return group->getActiveGroupIndex() + 2;
+
return 1;
}
-Thing MovesensMan::getTeleporterRotatedProjectileThing(Teleporter* teleporter, Thing projectileThing) {
- int16 L0693_i_UpdatedDirection;
- int16 L0694_i_Rotation;
-
- L0693_i_UpdatedDirection = _moveResultDir;
- L0694_i_Rotation = teleporter->getRotation();
- if (teleporter->getAbsoluteRotation()) {
- L0693_i_UpdatedDirection = L0694_i_Rotation;
- } else {
- L0693_i_UpdatedDirection = normalizeModulo4(L0693_i_UpdatedDirection + L0694_i_Rotation);
- projectileThing = thingWithNewCell(projectileThing, normalizeModulo4((projectileThing).getCell() + L0694_i_Rotation));
+Thing MovesensMan::getTeleporterRotatedProjectileThing(Teleporter *teleporter, Thing projectileThing) {
+ int16 updatedDirection = _moveResultDir;
+ int16 rotation = teleporter->getRotation();
+ if (teleporter->getAbsoluteRotation())
+ updatedDirection = rotation;
+ else {
+ updatedDirection = normalizeModulo4(updatedDirection + rotation);
+ projectileThing = thingWithNewCell(projectileThing, normalizeModulo4(projectileThing.getCell() + rotation));
}
- _moveResultDir = L0693_i_UpdatedDirection;
+ _moveResultDir = updatedDirection;
return projectileThing;
}
void MovesensMan::processThingAdditionOrRemoval(uint16 mapX, uint16 mapY, Thing thing, bool partySquare, bool addThing) {
- Thing L0766_T_Thing;
- int16 L0767_i_ThingType;
- bool L0768_B_TriggerSensor;
- Sensor* L0769_ps_Sensor;
- int16 L0770_ui_SensorTriggeredCell;
- uint16 L0771_ui_ThingType;
- bool L0772_B_SquareContainsObject;
- bool L0773_B_SquareContainsGroup;
- int16 L0774_i_ObjectType;
- bool L0775_B_SquareContainsThingOfSameType;
- bool L0776_B_SquareContainsThingOfDifferentType;
- uint16 L0777_ui_Square;
- int16 L0778_i_Effect;
- int16 L0779_i_SensorData;
-
-
+ int16 thingType;
+ IconIndice objectType;
if (thing != Thing::_party) {
- L0767_i_ThingType = thing.getType();
- L0774_i_ObjectType = _vm->_objectMan->getObjectType(thing);
+ thingType = thing.getType();
+ objectType = _vm->_objectMan->getObjectType(thing);
} else {
- L0767_i_ThingType = kM1_PartyThingType;
- L0774_i_ObjectType = kM1_IconIndiceNone;
+ thingType = kM1_PartyThingType;
+ objectType = kM1_IconIndiceNone;
}
- if ((!addThing) && (L0767_i_ThingType != kM1_PartyThingType)) {
+
+ if ((!addThing) && (thingType != kM1_PartyThingType))
_vm->_dungeonMan->unlinkThingFromList(thing, Thing(0), mapX, mapY);
- }
- L0777_ui_Square = _vm->_dungeonMan->_currMapData[mapX][mapY];
- if (Square(L0777_ui_Square).getType() == k0_WallElemType) {
- L0770_ui_SensorTriggeredCell = thing.getCell();
- } else {
- L0770_ui_SensorTriggeredCell = kM1_CellAny; // this will wrap around
- }
- L0772_B_SquareContainsObject = L0773_B_SquareContainsGroup = L0775_B_SquareContainsThingOfSameType = L0776_B_SquareContainsThingOfDifferentType = false;
- L0766_T_Thing = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY);
- if (L0770_ui_SensorTriggeredCell == kM1_CellAny) {
- while (L0766_T_Thing != Thing::_endOfList) {
- if ((L0771_ui_ThingType = (L0766_T_Thing).getType()) == k4_GroupThingType) {
- L0773_B_SquareContainsGroup = true;
- } else {
- if ((L0771_ui_ThingType == k2_TextstringType) && (L0767_i_ThingType == kM1_PartyThingType) && addThing && !partySquare) {
- _vm->_dungeonMan->decodeText(_vm->_stringBuildBuffer, L0766_T_Thing, k1_TextTypeMessage);
- _vm->_textMan->printMessage(k15_ColorWhite, _vm->_stringBuildBuffer);
- } else {
- if ((L0771_ui_ThingType > k4_GroupThingType) && (L0771_ui_ThingType < k14_ProjectileThingType)) {
- L0772_B_SquareContainsObject = true;
- L0775_B_SquareContainsThingOfSameType |= (_vm->_objectMan->getObjectType(L0766_T_Thing) == L0774_i_ObjectType);
- L0776_B_SquareContainsThingOfDifferentType |= (_vm->_objectMan->getObjectType(L0766_T_Thing) != L0774_i_ObjectType);
- }
- }
+ Square curSquare = Square(_vm->_dungeonMan->_currMapData[mapX][mapY]);
+ int16 sensorTriggeredCell;
+ if (curSquare.getType() == k0_WallElemType)
+ sensorTriggeredCell = thing.getCell();
+ else
+ sensorTriggeredCell = kM1_CellAny; // this will wrap around
+
+ bool squareContainsObject = false;
+ bool squareContainsGroup = false;
+ bool squareContainsThingOfSameType = false;
+ bool squareContainsThingOfDifferentType = false;
+ Thing curThing = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY);
+ if (sensorTriggeredCell == kM1_CellAny) {
+ while (curThing != Thing::_endOfList) {
+ uint16 curThingType = curThing.getType();
+ if (curThingType == k4_GroupThingType)
+ squareContainsGroup = true;
+ else if ((curThingType == k2_TextstringType) && (thingType == kM1_PartyThingType) && addThing && !partySquare) {
+ _vm->_dungeonMan->decodeText(_vm->_stringBuildBuffer, curThing, k1_TextTypeMessage);
+ _vm->_textMan->printMessage(k15_ColorWhite, _vm->_stringBuildBuffer);
+ } else if ((curThingType > k4_GroupThingType) && (curThingType < k14_ProjectileThingType)) {
+ squareContainsObject = true;
+ squareContainsThingOfSameType |= (_vm->_objectMan->getObjectType(curThing) == objectType);
+ squareContainsThingOfDifferentType |= (_vm->_objectMan->getObjectType(curThing) != objectType);
}
- L0766_T_Thing = _vm->_dungeonMan->getNextThing(L0766_T_Thing);
+ curThing = _vm->_dungeonMan->getNextThing(curThing);
}
} else {
- while (L0766_T_Thing != Thing::_endOfList) {
- if ((L0770_ui_SensorTriggeredCell == (L0766_T_Thing).getCell()) && ((L0766_T_Thing).getType() > k4_GroupThingType)) {
- L0772_B_SquareContainsObject = true;
- L0775_B_SquareContainsThingOfSameType |= (_vm->_objectMan->getObjectType(L0766_T_Thing) == L0774_i_ObjectType);
- L0776_B_SquareContainsThingOfDifferentType |= (_vm->_objectMan->getObjectType(L0766_T_Thing) != L0774_i_ObjectType);
+ while (curThing != Thing::_endOfList) {
+ if ((sensorTriggeredCell == curThing.getCell()) && (curThing.getType() > k4_GroupThingType)) {
+ squareContainsObject = true;
+ squareContainsThingOfSameType |= (_vm->_objectMan->getObjectType(curThing) == objectType);
+ squareContainsThingOfDifferentType |= (_vm->_objectMan->getObjectType(curThing) != objectType);
}
- L0766_T_Thing = _vm->_dungeonMan->getNextThing(L0766_T_Thing);
+ curThing = _vm->_dungeonMan->getNextThing(curThing);
}
}
- if (addThing && (L0767_i_ThingType != kM1_PartyThingType)) {
+ if (addThing && (thingType != kM1_PartyThingType))
_vm->_dungeonMan->linkThingToList(thing, Thing(0), mapX, mapY);
- }
- L0766_T_Thing = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY);
- while (L0766_T_Thing != Thing::_endOfList) {
- L0771_ui_ThingType = (L0766_T_Thing).getType();
- if (L0771_ui_ThingType == k3_SensorThingType) {
- L0769_ps_Sensor = (Sensor *)_vm->_dungeonMan->getThingData(L0766_T_Thing);
- if ((L0769_ps_Sensor)->getType() == k0_SensorDisabled)
- goto T0276079;
- L0779_i_SensorData = L0769_ps_Sensor->getData();
- L0768_B_TriggerSensor = addThing;
- if (L0770_ui_SensorTriggeredCell == kM1_CellAny) {
- switch (L0769_ps_Sensor->getType()) {
- case k1_SensorFloorTheronPartyCreatureObj:
- if (partySquare || L0772_B_SquareContainsObject || L0773_B_SquareContainsGroup) /* BUG0_30 A floor sensor is not triggered when you put an object on the floor if a levitating creature is present on the same square. The condition to determine if the sensor should be triggered checks if there is a creature on the square but does not check whether the creature is levitating. While it is normal not to trigger the sensor if there is a non levitating creature on the square (because it was already triggered by the creature itself), a levitating creature should not prevent triggering the sensor with an object. */
- goto T0276079;
- break;
- case k2_SensorFloorTheronPartyCreature:
- if ((L0767_i_ThingType > k4_GroupThingType) || partySquare || L0773_B_SquareContainsGroup)
- goto T0276079;
- break;
- case k3_SensorFloorParty:
- if ((L0767_i_ThingType != kM1_PartyThingType) || (_vm->_championMan->_partyChampionCount == 0))
- goto T0276079;
- if (L0779_i_SensorData == 0) {
- if (partySquare)
- goto T0276079;
- } else {
- if (!addThing) {
- L0768_B_TriggerSensor = false;
- } else {
- L0768_B_TriggerSensor = (L0779_i_SensorData == _vm->indexToOrdinal(_vm->_dungeonMan->_partyDir));
+
+ curThing = _vm->_dungeonMan->getSquareFirstThing(mapX, mapY);
+ while (curThing != Thing::_endOfList) {
+ bool skipToNextThing = false;
+ uint16 curThingType = curThing.getType();
+ if (curThingType == k3_SensorThingType) {
+ Sensor *curSensor = (Sensor *)_vm->_dungeonMan->getThingData(curThing);
+ if (curSensor->getType() == k0_SensorDisabled)
+ skipToNextThing = true;
+
+ if (!skipToNextThing) {
+ int16 curSensorData = curSensor->getData();
+ bool triggerSensor = addThing;
+ if (sensorTriggeredCell == kM1_CellAny) {
+ switch (curSensor->getType()) {
+ case k1_SensorFloorTheronPartyCreatureObj:
+ if (partySquare || squareContainsObject || squareContainsGroup) /* BUG0_30 A floor sensor is not triggered when you put an object on the floor if a levitating creature is present on the same square. The condition to determine if the sensor should be triggered checks if there is a creature on the square but does not check whether the creature is levitating. While it is normal not to trigger the sensor if there is a non levitating creature on the square (because it was already triggered by the creature itself), a levitating creature should not prevent triggering the sensor with an object. */
+ skipToNextThing = true;
+ break;
+ case k2_SensorFloorTheronPartyCreature:
+ if ((thingType > k4_GroupThingType) || partySquare || squareContainsGroup)
+ skipToNextThing = true;
+ break;
+ case k3_SensorFloorParty:
+ if ((thingType != kM1_PartyThingType) || (_vm->_championMan->_partyChampionCount == 0)) {
+ skipToNextThing = true;
+ break;
+ }
+
+ if (curSensorData == 0) {
+ if (partySquare)
+ skipToNextThing = true;
+ } else if (!addThing)
+ triggerSensor = false;
+ else
+ triggerSensor = (curSensorData == _vm->indexToOrdinal(_vm->_dungeonMan->_partyDir));
+ break;
+ case k4_SensorFloorObj:
+ if ((curSensorData != _vm->_objectMan->getObjectType(thing)) || squareContainsThingOfSameType)
+ skipToNextThing = true;
+ break;
+ case k5_SensorFloorPartyOnStairs:
+ if ((thingType != kM1_PartyThingType) || (curSquare.getType() != k3_StairsElemType))
+ skipToNextThing = true;
+ break;
+ case k6_SensorFloorGroupGenerator:
+ skipToNextThing = true;
+ break;
+ case k7_SensorFloorCreature:
+ if ((thingType > k4_GroupThingType) || (thingType == kM1_PartyThingType) || squareContainsGroup)
+ skipToNextThing = true;
+ break;
+ case k8_SensorFloorPartyPossession:
+ if (thingType != kM1_PartyThingType)
+ skipToNextThing = true;
+ else
+ triggerSensor = isObjectInPartyPossession(curSensorData);
+ break;
+ case k9_SensorFloorVersionChecker:
+ if ((thingType != kM1_PartyThingType) || !addThing || partySquare)
+ skipToNextThing = true;
+ else
+ // Strangerke: 20 is a hardcoded version of the game. later version uses 21. Not present in the original dungeons anyway.
+ triggerSensor = (curSensorData <= 20);
+ break;
+ default:
+ skipToNextThing = true;
+ break;
+ }
+ } else {
+ if (sensorTriggeredCell != curThing.getCell())
+ skipToNextThing = true;
+ else {
+ switch (curSensor->getType()) {
+ case k1_SensorWallOrnClick:
+ if (squareContainsObject)
+ skipToNextThing = true;
+ break;
+ case k2_SensorWallOrnClickWithAnyObj:
+ if (squareContainsThingOfSameType || (curSensor->getData() != _vm->_objectMan->getObjectType(thing)))
+ skipToNextThing = true;
+ break;
+ case k3_SensorWallOrnClickWithSpecObj:
+ if (squareContainsThingOfDifferentType || (curSensor->getData() == _vm->_objectMan->getObjectType(thing)))
+ skipToNextThing = true;
+ break;
+ default:
+ skipToNextThing = true;
+ break;
}
}
- break;
- case k4_SensorFloorObj:
- if ((L0779_i_SensorData != _vm->_objectMan->getObjectType(thing)) || L0775_B_SquareContainsThingOfSameType)
- goto T0276079;
- break;
- case k5_SensorFloorPartyOnStairs:
- if ((L0767_i_ThingType != kM1_PartyThingType) || (Square(L0777_ui_Square).getType() != k3_StairsElemType))
- goto T0276079;
- break;
- case k6_SensorFloorGroupGenerator:
- goto T0276079;
- case k7_SensorFloorCreature:
- if ((L0767_i_ThingType > k4_GroupThingType) || (L0767_i_ThingType == kM1_PartyThingType) || L0773_B_SquareContainsGroup)
- goto T0276079;
- break;
- case k8_SensorFloorPartyPossession:
- if (L0767_i_ThingType != kM1_PartyThingType)
- goto T0276079;
- L0768_B_TriggerSensor = isObjcetInPartyPossession(L0779_i_SensorData);
- break;
- case k9_SensorFloorVersionChecker:
- if ((L0767_i_ThingType != kM1_PartyThingType) || !addThing || partySquare)
- goto T0276079;
- // Strangerke: 20 is a hardcoded version of the game. later version uses 21. Not present in the original dungeons anyway.
- L0768_B_TriggerSensor = (L0779_i_SensorData <= 20);
- break;
- default:
- goto T0276079;
}
- } else {
- if (L0770_ui_SensorTriggeredCell != (L0766_T_Thing).getCell())
- goto T0276079;
- switch (L0769_ps_Sensor->getType()) {
- case k1_SensorWallOrnClick:
- if (L0772_B_SquareContainsObject)
- goto T0276079;
- break;
- case k2_SensorWallOrnClickWithAnyObj:
- if (L0775_B_SquareContainsThingOfSameType || (L0769_ps_Sensor->getData() != _vm->_objectMan->getObjectType(thing)))
- goto T0276079;
- break;
- case k3_SensorWallOrnClickWithSpecObj:
- if (L0776_B_SquareContainsThingOfDifferentType || (L0769_ps_Sensor->getData() == _vm->_objectMan->getObjectType(thing)))
- goto T0276079;
- break;
- default:
- goto T0276079;
+ if (!skipToNextThing) {
+ triggerSensor ^= curSensor->getAttrRevertEffectA();
+ int16 curSensorEffect = curSensor->getAttrEffectA();
+ if (curSensorEffect == k3_SensorEffHold)
+ curSensorEffect = triggerSensor ? k0_SensorEffSet : k1_SensorEffClear;
+ else if (!triggerSensor)
+ skipToNextThing = true;
+
+ if (!skipToNextThing) {
+ if (curSensor->getAttrAudibleA())
+ _vm->_sound->requestPlay(k01_soundSWITCH, mapX, mapY, k1_soundModePlayIfPrioritized);
+
+ triggerEffect(curSensor, curSensorEffect, mapX, mapY, (uint16)kM1_CellAny); // this will wrap around
+ skipToNextThing = true;
+ }
}
}
- L0768_B_TriggerSensor ^= L0769_ps_Sensor->getAttrRevertEffectA();
- L0778_i_Effect = L0769_ps_Sensor->getAttrEffectA();
- if (L0778_i_Effect == k3_SensorEffHold) {
- L0778_i_Effect = L0768_B_TriggerSensor ? k0_SensorEffSet : k1_SensorEffClear;
- } else if (!L0768_B_TriggerSensor)
- goto T0276079;
-
- if (L0769_ps_Sensor->getAttrAudibleA())
- _vm->_sound->requestPlay(k01_soundSWITCH, mapX, mapY, k1_soundModePlayIfPrioritized);
-
- triggerEffect(L0769_ps_Sensor, L0778_i_Effect, mapX, mapY, (uint16)kM1_CellAny); // this will wrap around
- goto T0276079;
}
- if (L0771_ui_ThingType >= k4_GroupThingType)
+ if (!skipToNextThing && (curThingType >= k4_GroupThingType))
break;
-T0276079:
- L0766_T_Thing = _vm->_dungeonMan->getNextThing(L0766_T_Thing);
+
+ curThing = _vm->_dungeonMan->getNextThing(curThing);
}
processRotationEffect();
}
-bool MovesensMan::isObjcetInPartyPossession(int16 objectType) {
- int16 L0742_i_ChampionIndex;
- uint16 L0743_ui_SlotIndex = 0;
- Thing L0744_T_Thing = Thing::_none;
- Champion* L0745_ps_Champion;
- Thing* L0746_pT_Thing = nullptr;
- int16 L0747_i_ObjectType;
- bool L0748_B_LeaderHandObjectProcessed;
- Container* L0749_ps_Container;
-
-
- L0748_B_LeaderHandObjectProcessed = false;
- for (L0742_i_ChampionIndex = k0_ChampionFirst, L0745_ps_Champion = _vm->_championMan->_champions; L0742_i_ChampionIndex < _vm->_championMan->_partyChampionCount; L0742_i_ChampionIndex++, L0745_ps_Champion++) {
- if (L0745_ps_Champion->_currHealth) {
- L0746_pT_Thing = L0745_ps_Champion->_slots;
- for (L0743_ui_SlotIndex = k0_ChampionSlotReadyHand; (L0743_ui_SlotIndex < k30_ChampionSlotChest_1) && !L0748_B_LeaderHandObjectProcessed; L0743_ui_SlotIndex++) {
- L0744_T_Thing = *L0746_pT_Thing++;
-T0274003:
- L0747_i_ObjectType = _vm->_objectMan->getObjectType(L0744_T_Thing);
- if (L0747_i_ObjectType == objectType) {
- return true;
+bool MovesensMan::isObjectInPartyPossession(int16 objectType) {
+ bool leaderHandObjectProcessed = false;
+ Champion *curChampion = _vm->_championMan->_champions;
+ int16 championIdx;
+ uint16 slotIdx = 0;
+ Thing curThing;
+ Thing *curSlotThing = nullptr;
+ for (championIdx = k0_ChampionFirst; championIdx < _vm->_championMan->_partyChampionCount; championIdx++, curChampion++) {
+ if (curChampion->_currHealth) {
+ curSlotThing = curChampion->_slots;
+ for (slotIdx = k0_ChampionSlotReadyHand; (slotIdx < k30_ChampionSlotChest_1) || !leaderHandObjectProcessed; slotIdx++) {
+ if (slotIdx < k30_ChampionSlotChest_1)
+ curThing = *curSlotThing++;
+ else {
+ leaderHandObjectProcessed = true;
+ curThing = _vm->_championMan->_leaderHandObject;
}
- if (L0747_i_ObjectType == k144_IconIndiceContainerChestClosed) {
- L0749_ps_Container = (Container *)_vm->_dungeonMan->getThingData(L0744_T_Thing);
- L0744_T_Thing = L0749_ps_Container->getSlot();
- while (L0744_T_Thing != Thing::_endOfList) {
- if (_vm->_objectMan->getObjectType(L0744_T_Thing) == objectType) {
+
+ int16 curObjectType = _vm->_objectMan->getObjectType(curThing);
+ if (curObjectType == objectType)
+ return true;
+
+ if (curObjectType == k144_IconIndiceContainerChestClosed) {
+ Container *container = (Container *)_vm->_dungeonMan->getThingData(curThing);
+ curThing = container->getSlot();
+ while (curThing != Thing::_endOfList) {
+ if (_vm->_objectMan->getObjectType(curThing) == objectType)
return true;
- }
- L0744_T_Thing = _vm->_dungeonMan->getNextThing(L0744_T_Thing);
+
+ curThing = _vm->_dungeonMan->getNextThing(curThing);
}
}
}
}
}
- if (!L0748_B_LeaderHandObjectProcessed) {
- L0748_B_LeaderHandObjectProcessed = true;
- L0744_T_Thing = _vm->_championMan->_leaderHandObject;
- goto T0274003;
- }
return false;
}
-void MovesensMan::triggerEffect(Sensor* sensor, int16 effect, int16 mapX, int16 mapY, uint16 cell) {
- byte g59_squareTypeToEventType[7] = { // @ G0059_auc_Graphic562_SquareTypeToEventType
+void MovesensMan::triggerEffect(Sensor *sensor, int16 effect, int16 mapX, int16 mapY, uint16 cell) {
+ TimelineEventType squareTypeToEventTypeArray[7] = { // @ G0059_auc_Graphic562_SquareTypeToEventType
k6_TMEventTypeWall,
k5_TMEventTypeCorridor,
k9_TMEventTypePit,
k0_TMEventTypeNone,
k10_TMEventTypeDoor,
k8_TMEventTypeTeleporter,
- k7_TMEventTypeFakeWall}; /* 1 byte of padding inserted by compiler */
-
- int16 L0736_i_TargetMapX;
- int16 L0737_i_TargetMapY;
- int32 L0738_l_Time;
- uint16 L0739_ui_SquareType;
- uint16 L0740_ui_TargetCell;
+ k7_TMEventTypeFakeWall
+ };
-
- if (sensor->getAttrOnlyOnce()) {
+ if (sensor->getAttrOnlyOnce())
sensor->setTypeDisabled();
- }
- L0738_l_Time = _vm->_gameTime + sensor->getAttrValue();
- if (sensor->getAttrLocalEffect()) {
+
+ int32 endTime = _vm->_gameTime + sensor->getAttrValue();
+ if (sensor->getAttrLocalEffect())
triggerLocalEffect(sensor->getActionLocalEffect(), mapX, mapY, cell);
- } else {
- L0736_i_TargetMapX = sensor->getActionTargetMapX();
- L0737_i_TargetMapY = sensor->getActionTargetMapY();
- L0739_ui_SquareType = Square(_vm->_dungeonMan->_currMapData[L0736_i_TargetMapX][L0737_i_TargetMapY]).getType();
- if (L0739_ui_SquareType == k0_ElementTypeWall) {
- L0740_ui_TargetCell = sensor->getActionTargetCell();
- } else {
- L0740_ui_TargetCell = k0_CellNorthWest;
- }
- addEvent(g59_squareTypeToEventType[L0739_ui_SquareType], L0736_i_TargetMapX, L0737_i_TargetMapY, L0740_ui_TargetCell, effect, L0738_l_Time);
+ else {
+ int16 targetMapX = sensor->getActionTargetMapX();
+ int16 targetMapY = sensor->getActionTargetMapY();
+ SquareType curSquareType = Square(_vm->_dungeonMan->_currMapData[targetMapX][targetMapY]).getType();
+ uint16 targetCell;
+ if (curSquareType == k0_ElementTypeWall)
+ targetCell = sensor->getActionTargetCell();
+ else
+ targetCell = k0_CellNorthWest;
+
+ addEvent(squareTypeToEventTypeArray[curSquareType], targetMapX, targetMapY, targetCell, effect, endTime);
}
}
@@ -1016,85 +959,73 @@ void MovesensMan::triggerLocalEffect(int16 localEffect, int16 effX, int16 effY,
}
void MovesensMan::addSkillExperience(int16 skillIndex, uint16 exp, bool leaderOnly) {
-
if (leaderOnly) {
- if (_vm->_championMan->_leaderIndex != kM1_ChampionNone) {
+ if (_vm->_championMan->_leaderIndex != kM1_ChampionNone)
_vm->_championMan->addSkillExperience(_vm->_championMan->_leaderIndex, skillIndex, exp);
- }
} else {
exp /= _vm->_championMan->_partyChampionCount;
- Champion *L0731_ps_Champion = _vm->_championMan->_champions;
- for (int16 L0730_i_ChampionIndex = k0_ChampionFirst; L0730_i_ChampionIndex < _vm->_championMan->_partyChampionCount; L0730_i_ChampionIndex++, L0731_ps_Champion++) {
- if (L0731_ps_Champion->_currHealth) {
- _vm->_championMan->addSkillExperience(L0730_i_ChampionIndex, skillIndex, exp);
- }
+ Champion *curChampion = _vm->_championMan->_champions;
+ for (int16 championIdx = k0_ChampionFirst; championIdx < _vm->_championMan->_partyChampionCount; championIdx++, curChampion++) {
+ if (curChampion->_currHealth)
+ _vm->_championMan->addSkillExperience(championIdx, skillIndex, exp);
}
}
}
void MovesensMan::processRotationEffect() {
- Thing L0732_T_FirstSensorThing;
- Thing L0733_T_LastSensorThing;
- Sensor* L0734_ps_FirstSensor;
- Sensor* L0735_ps_LastSensor;
-
-
- if (_sensorRotationEffect == kM1_SensorEffNone) {
+ if (_sensorRotationEffect == kM1_SensorEffNone)
return;
- }
+
switch (_sensorRotationEffect) {
case k1_SensorEffClear:
case k2_SensorEffToggle:
- L0732_T_FirstSensorThing = _vm->_dungeonMan->getSquareFirstThing(_sensorRotationEffMapX, _sensorRotationEffMapY);
- while (((L0732_T_FirstSensorThing).getType() != k3_SensorThingType) || ((_sensorRotationEffCell != kM1_CellAny) && ((L0732_T_FirstSensorThing).getCell() != _sensorRotationEffCell))) {
- L0732_T_FirstSensorThing = _vm->_dungeonMan->getNextThing(L0732_T_FirstSensorThing);
+ Thing firstSensorThing = _vm->_dungeonMan->getSquareFirstThing(_sensorRotationEffMapX, _sensorRotationEffMapY);
+ while ((firstSensorThing.getType() != k3_SensorThingType)
+ || ((_sensorRotationEffCell != kM1_CellAny) && (firstSensorThing.getCell() != _sensorRotationEffCell))) {
+ firstSensorThing = _vm->_dungeonMan->getNextThing(firstSensorThing);
}
- L0734_ps_FirstSensor = (Sensor *)_vm->_dungeonMan->getThingData(L0732_T_FirstSensorThing);
- L0733_T_LastSensorThing = L0734_ps_FirstSensor->getNextThing();
- while ((L0733_T_LastSensorThing != Thing::_endOfList) && (((L0733_T_LastSensorThing).getType() != k3_SensorThingType) || ((_sensorRotationEffCell != kM1_CellAny) && ((L0733_T_LastSensorThing).getCell() != _sensorRotationEffCell)))) {
- L0733_T_LastSensorThing = _vm->_dungeonMan->getNextThing(L0733_T_LastSensorThing);
+ Sensor *firstSensor = (Sensor *)_vm->_dungeonMan->getThingData(firstSensorThing);
+ Thing lastSensorThing = firstSensor->getNextThing();
+ while ((lastSensorThing != Thing::_endOfList)
+ && ((lastSensorThing.getType() != k3_SensorThingType)
+ || ((_sensorRotationEffCell != kM1_CellAny) && (lastSensorThing.getCell() != _sensorRotationEffCell)))) {
+ lastSensorThing = _vm->_dungeonMan->getNextThing(lastSensorThing);
}
- if (L0733_T_LastSensorThing == Thing::_endOfList)
+ if (lastSensorThing == Thing::_endOfList)
break;
- _vm->_dungeonMan->unlinkThingFromList(L0732_T_FirstSensorThing, Thing(0), _sensorRotationEffMapX, _sensorRotationEffMapY);
- L0735_ps_LastSensor = (Sensor *)_vm->_dungeonMan->getThingData(L0733_T_LastSensorThing);
- L0733_T_LastSensorThing = _vm->_dungeonMan->getNextThing(L0733_T_LastSensorThing);
- while (((L0733_T_LastSensorThing != Thing::_endOfList) && ((L0733_T_LastSensorThing).getType() == k3_SensorThingType))) {
- if ((_sensorRotationEffCell == kM1_CellAny) || ((L0733_T_LastSensorThing).getCell() == _sensorRotationEffCell)) {
- L0735_ps_LastSensor = (Sensor *)_vm->_dungeonMan->getThingData(L0733_T_LastSensorThing);
- }
- L0733_T_LastSensorThing = _vm->_dungeonMan->getNextThing(L0733_T_LastSensorThing);
+ _vm->_dungeonMan->unlinkThingFromList(firstSensorThing, Thing(0), _sensorRotationEffMapX, _sensorRotationEffMapY);
+ Sensor *lastSensor = (Sensor *)_vm->_dungeonMan->getThingData(lastSensorThing);
+ lastSensorThing = _vm->_dungeonMan->getNextThing(lastSensorThing);
+ while (((lastSensorThing != Thing::_endOfList) && (lastSensorThing.getType() == k3_SensorThingType))) {
+ if ((_sensorRotationEffCell == kM1_CellAny) || (lastSensorThing.getCell() == _sensorRotationEffCell))
+ lastSensor = (Sensor *)_vm->_dungeonMan->getThingData(lastSensorThing);
+ lastSensorThing = _vm->_dungeonMan->getNextThing(lastSensorThing);
}
- L0734_ps_FirstSensor->setNextThing(L0735_ps_LastSensor->getNextThing());
- L0735_ps_LastSensor->setNextThing(L0732_T_FirstSensorThing);
+ firstSensor->setNextThing(lastSensor->getNextThing());
+ lastSensor->setNextThing(firstSensorThing);
}
_sensorRotationEffect = kM1_SensorEffNone;
}
void MovesensMan::createEventMoveGroup(Thing groupThing, int16 mapX, int16 mapY, int16 mapIndex, bool audible) {
- TimelineEvent L0696_s_Event;
-
- setMapAndTime(L0696_s_Event._mapTime, mapIndex, _vm->_gameTime + 5);
- L0696_s_Event._type = audible ? k61_TMEventTypeMoveGroupAudible : k60_TMEventTypeMoveGroupSilent;
- L0696_s_Event._priority = 0;
- L0696_s_Event._B._location._mapX = mapX;
- L0696_s_Event._B._location._mapY = mapY;
- L0696_s_Event._C._slot = groupThing.toUint16();
- _vm->_timeline->addEventGetEventIndex(&L0696_s_Event);
+ TimelineEvent newEvent;
+ setMapAndTime(newEvent._mapTime, mapIndex, _vm->_gameTime + 5);
+ newEvent._type = audible ? k61_TMEventTypeMoveGroupAudible : k60_TMEventTypeMoveGroupSilent;
+ newEvent._priority = 0;
+ newEvent._B._location._mapX = mapX;
+ newEvent._B._location._mapY = mapY;
+ newEvent._C._slot = groupThing.toUint16();
+ _vm->_timeline->addEventGetEventIndex(&newEvent);
}
Thing MovesensMan::getObjectOfTypeInCell(int16 mapX, int16 mapY, int16 cell, int16 objectType) {
- Thing L0741_T_Thing;
-
-
- L0741_T_Thing = _vm->_dungeonMan->getSquareFirstObject(mapX, mapY);
- while (L0741_T_Thing != Thing::_endOfList) {
- if (_vm->_objectMan->getObjectType(L0741_T_Thing) == objectType) {
- if ((cell == kM1_CellAny) || ((L0741_T_Thing.getCell()) == cell)) {
- return L0741_T_Thing;
- }
+ Thing curThing = _vm->_dungeonMan->getSquareFirstObject(mapX, mapY);
+ while (curThing != Thing::_endOfList) {
+ if (_vm->_objectMan->getObjectType(curThing) == objectType) {
+ if ((cell == kM1_CellAny) || (curThing.getCell() == cell))
+ return curThing;
}
- L0741_T_Thing = _vm->_dungeonMan->getNextThing(L0741_T_Thing);
+ curThing = _vm->_dungeonMan->getNextThing(curThing);
}
return Thing::_none;
}
diff --git a/engines/dm/movesens.h b/engines/dm/movesens.h
index ce023bc5c1..7746fcac6c 100644
--- a/engines/dm/movesens.h
+++ b/engines/dm/movesens.h
@@ -60,7 +60,7 @@ public:
int16 getTeleporterRotatedGroupResult(Teleporter *teleporter, Thing thing, uint16 mapIndex);// @ F0262_MOVE_GetTeleporterRotatedGroupResult
Thing getTeleporterRotatedProjectileThing(Teleporter *teleporter, Thing projectileThing); // @ F0263_MOVE_GetTeleporterRotatedProjectileThing
void processThingAdditionOrRemoval(uint16 mapX, uint16 mapY, Thing thing, bool partySquare, bool addThing);// @ F0276_SENSOR_ProcessThingAdditionOrRemoval
- bool isObjcetInPartyPossession(int16 objectType); // @ F0274_SENSOR_IsObjectInPartyPossession
+ bool isObjectInPartyPossession(int16 objectType); // @ F0274_SENSOR_IsObjectInPartyPossession
void triggerEffect(Sensor *sensor, int16 effect, int16 mapX, int16 mapY, uint16 cell); // @ F0272_SENSOR_TriggerEffect
void triggerLocalEffect(int16 localEffect, int16 effX, int16 effY, int16 effCell); // @ F0270_SENSOR_TriggerLocalEffect
void addSkillExperience(int16 skillIndex, uint16 exp, bool leaderOnly); // @ F0269_SENSOR_AddSkillExperience