diff options
author | Strangerke | 2016-09-18 12:52:01 +0200 |
---|---|---|
committer | Strangerke | 2016-09-18 12:52:01 +0200 |
commit | 8668f6765b5b3472257b4d19fbdcb722d2c40ec7 (patch) | |
tree | 7027f4f65fd86bdaf8616f9ec26faf8e7ad01393 /engines/dm | |
parent | 0750c20fe7e2d152a7e2b181c455c3d24e653c86 (diff) | |
download | scummvm-rg350-8668f6765b5b3472257b4d19fbdcb722d2c40ec7.tar.gz scummvm-rg350-8668f6765b5b3472257b4d19fbdcb722d2c40ec7.tar.bz2 scummvm-rg350-8668f6765b5b3472257b4d19fbdcb722d2c40ec7.zip |
DM: Rename members of Behavior, some more renaming
Diffstat (limited to 'engines/dm')
-rw-r--r-- | engines/dm/dm.cpp | 12 | ||||
-rw-r--r-- | engines/dm/gfx.cpp | 2 | ||||
-rw-r--r-- | engines/dm/group.cpp | 115 | ||||
-rw-r--r-- | engines/dm/group.h | 39 | ||||
-rw-r--r-- | engines/dm/menus.cpp | 6 | ||||
-rw-r--r-- | engines/dm/movesens.cpp | 6 | ||||
-rw-r--r-- | engines/dm/projexpl.cpp | 4 |
7 files changed, 90 insertions, 94 deletions
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 0079850df4..d9ffd32298 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -907,7 +907,7 @@ void DMEngine::fuseSequence() { Thing lordChaosThing = _groupMan->groupGetThing(lordChaosMapX, lordChaosMapY); Group *lordGroup = (Group*)_dungeonMan->getThingData(lordChaosThing); lordGroup->_health[0] = 10000; - _dungeonMan->setGroupCells(lordGroup, k255_CreatureTypeSingleCenteredCreature, _dungeonMan->_partyMapIndex); + _dungeonMan->setGroupCells(lordGroup, kDMCreatureTypeSingleCenteredCreature, _dungeonMan->_partyMapIndex); _dungeonMan->setGroupDirections(lordGroup, returnOppositeDir(_dungeonMan->_partyDir), _dungeonMan->_partyMapIndex); bool removeFluxcagesFromLordChaosSquare = true; @@ -936,14 +936,14 @@ void DMEngine::fuseSequence() { } fuseSequenceUpdate(); for (int16 attackId = 55; attackId <= 255; attackId += 40) { - _projexpl->createExplosion(Thing::_explFireBall, attackId, lordChaosMapX, lordChaosMapY, k255_CreatureTypeSingleCenteredCreature); + _projexpl->createExplosion(Thing::_explFireBall, attackId, lordChaosMapX, lordChaosMapY, kDMCreatureTypeSingleCenteredCreature); fuseSequenceUpdate(); } _sound->requestPlay(k17_soundBUZZ, lordChaosMapX, lordChaosMapY, kDMSoundModePlayIfPrioritized); lordGroup->_type = kDMCreatureTypeLordOrder; fuseSequenceUpdate(); for (int16 attackId = 55; attackId <= 255; attackId += 40) { - _projexpl->createExplosion(Thing::_explHarmNonMaterial, attackId, lordChaosMapX, lordChaosMapY, k255_CreatureTypeSingleCenteredCreature); + _projexpl->createExplosion(Thing::_explHarmNonMaterial, attackId, lordChaosMapX, lordChaosMapY, kDMCreatureTypeSingleCenteredCreature); fuseSequenceUpdate(); } for (int16 cycleCount = 3; cycleCount > 0; cycleCount--) { @@ -954,8 +954,8 @@ void DMEngine::fuseSequence() { fuseSequenceUpdate(); } } - _projexpl->createExplosion(Thing::_explFireBall, 255, lordChaosMapX, lordChaosMapY, k255_CreatureTypeSingleCenteredCreature); - _projexpl->createExplosion(Thing::_explHarmNonMaterial, 255, lordChaosMapX, lordChaosMapY, k255_CreatureTypeSingleCenteredCreature); + _projexpl->createExplosion(Thing::_explFireBall, 255, lordChaosMapX, lordChaosMapY, kDMCreatureTypeSingleCenteredCreature); + _projexpl->createExplosion(Thing::_explHarmNonMaterial, 255, lordChaosMapX, lordChaosMapY, kDMCreatureTypeSingleCenteredCreature); fuseSequenceUpdate(); lordGroup->_type = kDMCreatureTypeGreyLord; fuseSequenceUpdate(); @@ -999,7 +999,7 @@ void DMEngine::fuseSequence() { } for (int16 attackId = 55; attackId <= 255; attackId += 40) { - _projexpl->createExplosion(Thing::_explHarmNonMaterial, attackId, lordChaosMapX, lordChaosMapY, k255_CreatureTypeSingleCenteredCreature); + _projexpl->createExplosion(Thing::_explHarmNonMaterial, attackId, lordChaosMapX, lordChaosMapY, kDMCreatureTypeSingleCenteredCreature); fuseSequenceUpdate(); } diff --git a/engines/dm/gfx.cpp b/engines/dm/gfx.cpp index d4f32fbccc..a629c56cd9 100644 --- a/engines/dm/gfx.cpp +++ b/engines/dm/gfx.cpp @@ -3301,7 +3301,7 @@ T0115015_DrawProjectileAsObject: creatureDirectionDelta = _vm->normalizeModulo4(directionParam - _vm->_groupMan->getCreatureValue(activeGroup->_directions, AL_0_creatureIndexRed)); twoHalfSquareCreaturesFrontView = false; AL_4_groupCells = activeGroup->_cells; - if (AL_4_groupCells == k255_CreatureTypeSingleCenteredCreature) { /* If there is a single centered creature in the group */ + if (AL_4_groupCells == kDMCreatureTypeSingleCenteredCreature) { /* If there is a single centered creature in the group */ if (remainingViewCellOrdinalsToProcess || (doorFrontViewDrawingPass == 1)) goto T0115129_DrawProjectiles; /* Do not draw a single centered creature now, wait until second pass (for a front view door) or until all cells have been drawn so the creature is drawn over all the objects on the floor */ diff --git a/engines/dm/group.cpp b/engines/dm/group.cpp index fd36d4b16c..1fa79fd67a 100644 --- a/engines/dm/group.cpp +++ b/engines/dm/group.cpp @@ -37,7 +37,8 @@ namespace DM { -int32 M32_setTime(int32 &map_time, int32 time) { + +int32 GroupMan::setTime(int32 &map_time, int32 time) { return map_time = (map_time & 0xFF000000) | time; } @@ -105,7 +106,7 @@ uint16 GroupMan::getGroupDirections(Group *group, int16 mapIndex) { int16 GroupMan::getCreatureOrdinalInCell(Group *group, uint16 cell) { uint16 currMapIndex = _vm->_dungeonMan->_currMapIndex; byte groupCells = getGroupCells(group, currMapIndex); - if (groupCells == k255_CreatureTypeSingleCenteredCreature) + if (groupCells == kDMCreatureTypeSingleCenteredCreature) return _vm->indexToOrdinal(0); int retval = 0; @@ -145,7 +146,7 @@ void GroupMan::dropGroupPossessions(int16 mapX, int16 mapY, Thing groupThing, So uint16 groupCells = getGroupCells(group, _vm->_dungeonMan->_currMapIndex); do { dropCreatureFixedPossessions(creatureType, mapX, mapY, - (groupCells == k255_CreatureTypeSingleCenteredCreature) ? (uint16)k255_CreatureTypeSingleCenteredCreature : getCreatureValue(groupCells, creatureIndex), soundMode); + (groupCells == kDMCreatureTypeSingleCenteredCreature) ? (uint16)kDMCreatureTypeSingleCenteredCreature : getCreatureValue(groupCells, creatureIndex), soundMode); } while (creatureIndex--); } @@ -248,7 +249,7 @@ void GroupMan::dropCreatureFixedPossessions(CreatureType creatureType, int16 map case kDMCreatureTypeAntman: fixedPossessions = fixedPossessionCreatur16TrolinAntman; break; - case kCreatureTypeMagentaWorm: + case kDMCreatureTypeMagentaWorm: fixedPossessions = fixedPossessionCreature15MagnetaWormWorm; break; case kDMCreatureTypeAnimatedArmour: @@ -289,7 +290,7 @@ void GroupMan::dropCreatureFixedPossessions(CreatureType creatureType, int16 map /* The same pointer type is used no matter the actual type k5_WeaponThingType, k6_ArmourThingType or k10_JunkThingType */ currWeapon->setType(currFixedPossession); currWeapon->setCursed(cursedPossessions); - nextUnusedThing = _vm->thingWithNewCell(nextUnusedThing, ((cell == k255_CreatureTypeSingleCenteredCreature) || !_vm->getRandomNumber(4)) ? _vm->getRandomNumber(4) : cell); + nextUnusedThing = _vm->thingWithNewCell(nextUnusedThing, ((cell == kDMCreatureTypeSingleCenteredCreature) || !_vm->getRandomNumber(4)) ? _vm->getRandomNumber(4) : cell); _vm->_moveSens->getMoveResult(nextUnusedThing, kDMMapXNotOnASquare, 0, mapX, mapY); currFixedPossession = *fixedPossessions++; } @@ -393,7 +394,7 @@ int16 GroupMan::groupGetDamageCreatureOutcome(Group *group, uint16 creatureIndex if (group->_health[creatureIndex] <= damage) { uint16 groupCells = getGroupCells(group, _vm->_dungeonMan->_currMapIndex); - uint16 cell = (groupCells == k255_CreatureTypeSingleCenteredCreature) ? (uint16)k255_CreatureTypeSingleCenteredCreature : getCreatureValue(groupCells, creatureIndex); + uint16 cell = (groupCells == kDMCreatureTypeSingleCenteredCreature) ? (uint16)kDMCreatureTypeSingleCenteredCreature : getCreatureValue(groupCells, creatureIndex); uint16 creatureCount = group->getCount(); uint16 retVal; @@ -416,7 +417,7 @@ int16 GroupMan::groupGetDamageCreatureOutcome(Group *group, uint16 creatureIndex if (currentMapIsPartyMap) activeGroup = &_activeGroups[group->getActiveGroupIndex()]; - if (group->getBehaviour() == k6_behavior_ATTACK) { + if (group->getBehaviour() == kDMBehaviorAttack) { TimelineEvent *curEvent = _vm->_timeline->_events; for (uint16 eventIndex = 0; eventIndex < _vm->_timeline->_eventMaxCount; eventIndex++) { uint16 curEventType = curEvent->_type; @@ -442,11 +443,11 @@ int16 GroupMan::groupGetDamageCreatureOutcome(Group *group, uint16 creatureIndex } uint16 fearResistance = creatureInfo->getFearResistance(); - if (currentMapIsPartyMap && (fearResistance) != k15_immuneToFear) { + if (currentMapIsPartyMap && (fearResistance != kDMImmuneToFear)) { fearResistance += creatureCount - 1; if (fearResistance < _vm->getRandomNumber(16)) { /* Test if the death of a creature frightens the remaining creatures in the group */ activeGroup->_delayFleeingFromTarget = _vm->getRandomNumber(100 - (fearResistance << 2)) + 20; - group->setBehaviour(k5_behavior_FLEE); + group->setBehaviour(kDMBehaviorFlee); } } } @@ -595,7 +596,7 @@ void GroupMan::processEvents29to41(int16 eventMapX, int16 eventMapY, int16 event /* Update the event */ TimelineEvent nextEvent; _vm->setMapAndTime(nextEvent._mapTime, _vm->_dungeonMan->_currMapIndex, _vm->_gameTime); - nextEvent._priority = 255 - creatureInfo._movementTicks; /* The fastest creatures (with small MovementTicks value) get higher event priority */ + nextEvent._priority = kDMMovementTicksImmobile - creatureInfo._movementTicks; /* The fastest creatures (with small MovementTicks value) get higher event priority */ nextEvent._Bu._location._mapX = eventMapX; nextEvent._Bu._location._mapY = eventMapY; /* If the creature is not on the party map then try and move the creature in a random direction and place a new event 37 in the timeline for the next creature movement */ @@ -635,7 +636,7 @@ T0209005_AddEventAndReturn: ticksSinceLastMove += 256; int16 movementTicks = creatureInfo._movementTicks; - if (movementTicks == k255_immobile) + if (movementTicks == kDMMovementTicksImmobile) movementTicks = 100; if (_vm->_championMan->_party._freezeLifeTicks && !isArchEnemy) { /* If life is frozen and the creature is not Lord Chaos (Lord Chaos is immune to Freeze Life) then reschedule the event later (except for reactions which are ignored when life if frozen) */ @@ -682,7 +683,7 @@ T0209005_AddEventAndReturn: if (eventType <= k31_TMEventTypeGroupReactionPartyIsAdjecent) { /* Process Reaction events 29 to 31 */ switch (eventType = eventType - k32_TMEventTypeUpdateAspectGroup) { case kM1_TMEventTypeCreateReactionEvent31ParyIsAdjacent: /* This event is used when the party bumps into a group or attacks a group physically (not with a spell). It causes the creature behavior to change to attack if it is not already attacking the party or fleeing from target */ - if ((AL0447_i_Behavior != k6_behavior_ATTACK) && (AL0447_i_Behavior != k5_behavior_FLEE)) { + if ((AL0447_i_Behavior != kDMBehaviorAttack) && (AL0447_i_Behavior != kDMBehaviorFlee)) { groupDeleteEvents(eventMapX, eventMapY); goto T0209044_SetBehavior6_Attack; } @@ -690,11 +691,11 @@ T0209005_AddEventAndReturn: activeGroup->_targetMapY = _vm->_dungeonMan->_partyMapY; return; case kM2_TMEventTypeCreateReactionEvent30HitByProjectile: /* This event is used for the reaction of a group after a projectile impacted with one creature in the group (some creatures may have been killed) */ - if ((AL0447_i_Behavior == k6_behavior_ATTACK) || (AL0447_i_Behavior == k5_behavior_FLEE)) /* If the creature is attacking the party or fleeing from the target then there is no reaction */ + if ((AL0447_i_Behavior == kDMBehaviorAttack) || (AL0447_i_Behavior == kDMBehaviorFlee)) /* If the creature is attacking the party or fleeing from the target then there is no reaction */ return; - AL0446_i_Behavior2Or3 = ((AL0447_i_Behavior == k3_behavior_USELESS) || (AL0447_i_Behavior == k2_behavior_USELESS)); + AL0446_i_Behavior2Or3 = ((AL0447_i_Behavior == kDMBehaviorUnknown3) || (AL0447_i_Behavior == kDMBehaviorUnknown2)); if (AL0446_i_Behavior2Or3 || (_vm->getRandomNumber(4))) { /* BUG0_00 Useless code. Behavior cannot be 2 nor 3 because these values are never used. The actual condition is thus: if 3/4 chances */ - if (!groupGetDistanceToVisibleParty(curGroup, kM1_wholeCreatureGroup, eventMapX, eventMapY)) { /* If the group cannot see the party then look in a random direction to try and search for the party */ + if (!groupGetDistanceToVisibleParty(curGroup, kDMWholeCreatureGroup, eventMapX, eventMapY)) { /* If the group cannot see the party then look in a random direction to try and search for the party */ approachAfterReaction = newGroupDirectionFound = false; goto T0209073_SetDirectionGroup; } @@ -702,24 +703,24 @@ T0209005_AddEventAndReturn: return; } /* No 'break': proceed to instruction after the next 'case' below. Reaction is to move in a random direction to try and avoid other projectiles */ case kM3_TMEventTypeCreateReactionEvent29DangerOnSquare: /* This event is used when some creatures in the group were killed by a Poison Cloud or by a closing door or if Lord Chaos is surrounded by 3 Fluxcages. It causes the creature to move in a random direction to avoid the danger */ - approachAfterReaction = (AL0447_i_Behavior == k6_behavior_ATTACK); /* If the creature behavior is 'Attack' and it has to move to avoid danger then it will change its behavior to 'Approach' after the movement */ + approachAfterReaction = (AL0447_i_Behavior == kDMBehaviorAttack); /* If the creature behavior is 'Attack' and it has to move to avoid danger then it will change its behavior to 'Approach' after the movement */ newGroupDirectionFound = false; goto T0209058_MoveInRandomDirection; } } if (eventType < k37_TMEventTypeUpdateBehaviourGroup) { /* Process Update Aspect events 32 to 36 */ nextEvent._type = eventType + 5; - if (groupGetDistanceToVisibleParty(curGroup, kM1_wholeCreatureGroup, eventMapX, eventMapY)) { - if ((AL0447_i_Behavior != k6_behavior_ATTACK) && (AL0447_i_Behavior != k5_behavior_FLEE)) { + if (groupGetDistanceToVisibleParty(curGroup, kDMWholeCreatureGroup, eventMapX, eventMapY)) { + if ((AL0447_i_Behavior != kDMBehaviorAttack) && (AL0447_i_Behavior != kDMBehaviorFlee)) { if (_vm->getDistance(_vm->_dungeonMan->_partyMapX, _vm->_dungeonMan->_partyMapY, eventMapX, eventMapY) <= 1) goto T0209044_SetBehavior6_Attack; - if (((AL0447_i_Behavior == k0_behavior_WANDER) || (AL0447_i_Behavior == k3_behavior_USELESS)) && (AL0447_i_Behavior != k7_behavior_APPROACH)) /* BUG0_00 Useless code. Behavior cannot be 3 because this value is never used. Moreover, the second condition in the && is redundant (if the value is 0 or 3, it cannot be 7). The actual condition is: if (AL0447_i_Behavior == k0_behavior_WANDER) */ + if (((AL0447_i_Behavior == kDMBehaviorWander) || (AL0447_i_Behavior == kDMBehaviorUnknown3)) && (AL0447_i_Behavior != kDMBehaviorApproach)) /* BUG0_00 Useless code. Behavior cannot be 3 because this value is never used. Moreover, the second condition in the && is redundant (if the value is 0 or 3, it cannot be 7). The actual condition is: if (AL0447_i_Behavior == k0_behavior_WANDER) */ goto T0209054_SetBehavior7_Approach; } activeGroup->_targetMapX = _vm->_dungeonMan->_partyMapX; activeGroup->_targetMapY = _vm->_dungeonMan->_partyMapY; } - if (AL0447_i_Behavior == k6_behavior_ATTACK) { + if (AL0447_i_Behavior == kDMBehaviorAttack) { AL0446_i_CreatureAspectIndex = eventType - k33_TMEventTypeUpdateAspectCreature_0; /* Value -1 for event 32, meaning aspect will be updated for all creatures in the group */ nextAspectUpdateTime = getCreatureAspectUpdateTime(activeGroup, AL0446_i_CreatureAspectIndex, getFlag(activeGroup->_aspect[AL0446_i_CreatureAspectIndex], kDMAspectMaskActiveGroupIsAttacking)); goto T0209136; @@ -736,8 +737,8 @@ T0209005_AddEventAndReturn: if (eventType == k37_TMEventTypeUpdateBehaviourGroup) { /* Process event 37, Update Group Behavior */ bool allowMovementOverFakePitsAndFakeWalls; - if ((AL0447_i_Behavior == k0_behavior_WANDER) || (AL0447_i_Behavior == k2_behavior_USELESS) || (AL0447_i_Behavior == k3_behavior_USELESS)) { /* BUG0_00 Useless code. Behavior cannot be 2 nor 3 because these values are never used. The actual condition is: if (AL0447_i_Behavior == k0_behavior_WANDER) */ - distanceToVisibleParty = groupGetDistanceToVisibleParty(curGroup, kM1_wholeCreatureGroup, eventMapX, eventMapY); + if ((AL0447_i_Behavior == kDMBehaviorWander) || (AL0447_i_Behavior == kDMBehaviorUnknown2) || (AL0447_i_Behavior == kDMBehaviorUnknown3)) { /* BUG0_00 Useless code. Behavior cannot be 2 nor 3 because these values are never used. The actual condition is: if (AL0447_i_Behavior == k0_behavior_WANDER) */ + distanceToVisibleParty = groupGetDistanceToVisibleParty(curGroup, kDMWholeCreatureGroup, eventMapX, eventMapY); if (distanceToVisibleParty) { if ((distanceToVisibleParty <= (creatureInfo.getAttackRange())) && ((!AL0450_i_DistanceXToParty) || (!AL0451_i_DistanceYToParty))) { /* If the creature is in range for attack and on the same row or column as the party on the map */ T0209044_SetBehavior6_Attack: @@ -746,15 +747,15 @@ T0209044_SetBehavior6_Attack: } activeGroup->_targetMapX = _vm->_dungeonMan->_partyMapX; activeGroup->_targetMapY = _vm->_dungeonMan->_partyMapY; - curGroup->setBehaviour(k6_behavior_ATTACK); + curGroup->setBehaviour(kDMBehaviorAttack); AL0446_i_Direction = _currGroupPrimaryDirToParty; for (AL0447_i_CreatureIndex = creatureCount; AL0447_i_CreatureIndex >= 0; AL0447_i_CreatureIndex--) { if ((getCreatureValue(activeGroup->_directions, AL0447_i_CreatureIndex) != AL0446_i_Direction) && ((!AL0447_i_CreatureIndex) || (!_vm->getRandomNumber(2)))) { setGroupDirection(activeGroup, AL0446_i_Direction, AL0447_i_CreatureIndex, creatureCount && (creatureSize == kDMCreatureSizeHalf)); - M32_setTime(nextEvent._mapTime, _vm->_gameTime + _vm->getRandomNumber(4) + 2); /* Random delay represents the time for the creature to turn */ + setTime(nextEvent._mapTime, _vm->_gameTime + _vm->getRandomNumber(4) + 2); /* Random delay represents the time for the creature to turn */ } else { - M32_setTime(nextEvent._mapTime, _vm->_gameTime + 1); + setTime(nextEvent._mapTime, _vm->_gameTime + 1); } if (notUpdateBehaviorFl) { nextEvent._mapTime += MIN((uint16)((creatureInfo._attackTicks >> 1) + _vm->getRandomNumber(4)), ticks); @@ -764,16 +765,16 @@ T0209044_SetBehavior6_Attack: } return; } - if (AL0447_i_Behavior != k2_behavior_USELESS) { /* BUG0_00 Useless code. Behavior cannot be 2 because this value is never used */ + if (AL0447_i_Behavior != kDMBehaviorUnknown2) { /* BUG0_00 Useless code. Behavior cannot be 2 because this value is never used */ T0209054_SetBehavior7_Approach: - curGroup->setBehaviour(k7_behavior_APPROACH); + curGroup->setBehaviour(kDMBehaviorApproach); activeGroup->_targetMapX = _vm->_dungeonMan->_partyMapX; activeGroup->_targetMapY = _vm->_dungeonMan->_partyMapY; nextEvent._mapTime += 1; goto T0209134_SetEvent37; } } else { - if (AL0447_i_Behavior == k0_behavior_WANDER) { + if (AL0447_i_Behavior == kDMBehaviorWander) { primaryDirectionToOrFromParty = getSmelledPartyPrimaryDirOrdinal(&creatureInfo, eventMapX, eventMapY); if (primaryDirectionToOrFromParty) { primaryDirectionToOrFromParty--; @@ -812,7 +813,7 @@ T0209061_MoveGroup: } if (_groupMovementBlockedByParty) { if ((eventType != kM3_TMEventTypeCreateReactionEvent29DangerOnSquare) && - ((curGroup->getBehaviour() != k5_behavior_FLEE) || + ((curGroup->getBehaviour() != kDMBehaviorFlee) || !getFirstPossibleMovementDirOrdinal(&creatureInfo, eventMapX, eventMapY, false) || _vm->getRandomNumber(2))) goto T0209044_SetBehavior6_Attack; @@ -841,15 +842,15 @@ T0209073_SetDirectionGroup: if (!newGroupDirectionFound) return; if (approachAfterReaction) - curGroup->setBehaviour(k7_behavior_APPROACH); + curGroup->setBehaviour(kDMBehaviorApproach); stopAttacking(activeGroup, eventMapX, eventMapY); } } } } else { - if (AL0447_i_Behavior == k7_behavior_APPROACH) { - distanceToVisibleParty = groupGetDistanceToVisibleParty(curGroup, kM1_wholeCreatureGroup, eventMapX, eventMapY); + if (AL0447_i_Behavior == kDMBehaviorApproach) { + distanceToVisibleParty = groupGetDistanceToVisibleParty(curGroup, kDMWholeCreatureGroup, eventMapX, eventMapY); if (distanceToVisibleParty) { if ((distanceToVisibleParty <= creatureInfo.getAttackRange()) && ((!AL0450_i_DistanceXToParty) || (!AL0451_i_DistanceYToParty))) /* If the creature is in range for attack and on the same row or column as the party on the map */ goto T0209044_SetBehavior6_Attack; @@ -865,7 +866,7 @@ T0209082_WalkTowardTarget: /* If the creature reached its target but the party is not there anymore */ if ((eventMapX == AL0450_i_TargetMapX) && (eventMapY == AL0451_i_TargetMapY)) { newGroupDirectionFound = false; - curGroup->setBehaviour(k0_behavior_WANDER); + curGroup->setBehaviour(kDMBehaviorWander); goto T0209073_SetDirectionGroup; } } @@ -898,11 +899,11 @@ T0209089_DoubleSquareMove: } setDirGroup(activeGroup, primaryDirectionToOrFromParty, creatureCount, creatureSize); } else { - if (AL0447_i_Behavior == k5_behavior_FLEE) { + if (AL0447_i_Behavior == kDMBehaviorFlee) { T0209094_FleeFromTarget: allowMovementOverFakePitsAndFakeWalls = true; /* If the creature can see the party then update target coordinates */ - distanceToVisibleParty = groupGetDistanceToVisibleParty(curGroup, kM1_wholeCreatureGroup, eventMapX, eventMapY); + distanceToVisibleParty = groupGetDistanceToVisibleParty(curGroup, kDMWholeCreatureGroup, eventMapX, eventMapY); if (distanceToVisibleParty) { AL0450_i_TargetMapX = (activeGroup->_targetMapX = _vm->_dungeonMan->_partyMapX); AL0451_i_TargetMapY = (activeGroup->_targetMapY = _vm->_dungeonMan->_partyMapY); @@ -910,7 +911,7 @@ T0209094_FleeFromTarget: if (!(--(activeGroup->_delayFleeingFromTarget))) { /* If the creature is not afraid anymore then stop fleeing from target */ T0209096_SetBehavior0_Wander: newGroupDirectionFound = false; - curGroup->setBehaviour(k0_behavior_WANDER); + curGroup->setBehaviour(kDMBehaviorWander); goto T0209073_SetDirectionGroup; } if (_vm->getRandomNumber(2)) { @@ -936,7 +937,7 @@ T0209096_SetBehavior0_Wander: } } } else { /* Process events 38 to 41, Update Creature Behavior */ - if (AL0447_i_Behavior == k5_behavior_FLEE) { + if (AL0447_i_Behavior == kDMBehaviorFlee) { if (creatureCount) { stopAttacking(activeGroup, eventMapX, eventMapY); } @@ -961,10 +962,10 @@ T0209096_SetBehavior0_Wander: } /* If there is a single creature in the group that is not full square sized and 1/4 chance */ if (!creatureCount && (creatureSize != kDMCreatureSizeFull) && !((AL0446_i_GroupCellsCriteria = _vm->getRandomNumber(65536)) & 0x00C0)) { - if (activeGroup->_cells != k255_CreatureTypeSingleCenteredCreature) { + if (activeGroup->_cells != kDMCreatureTypeSingleCenteredCreature) { /* If the creature is not already on the center of the square then change its cell */ if (AL0446_i_GroupCellsCriteria & 0x0038) /* 7/8 chances of changing cell to the center of the square */ - activeGroup->_cells = k255_CreatureTypeSingleCenteredCreature; + activeGroup->_cells = kDMCreatureTypeSingleCenteredCreature; else /* 1/8 chance of changing cell to the next or previous cell on the square */ AL0446_i_GroupCellsCriteria = _vm->normalizeModulo4(_vm->normalizeModulo4(activeGroup->_cells) + ((AL0446_i_GroupCellsCriteria & 0x0001) ? 1 : -1)); } @@ -986,11 +987,11 @@ T0209096_SetBehavior0_Wander: if ((AL0446_i_Range == 1) && (!getFlag(AL0446_i_CreatureAttributes = creatureInfo._attributes, kDMCreatureMaskPreferBackRow) || !_vm->getRandomNumber(4) || !getFlag(AL0446_i_CreatureAttributes, kDMCreatureMaskAttackAnyChamp)) && (creatureSize == kDMCreatureSizeQuarter) && - (activeGroup->_cells != k255_CreatureTypeSingleCenteredCreature) && + (activeGroup->_cells != kDMCreatureTypeSingleCenteredCreature) && ((AL0446_i_Cell = getCreatureValue(activeGroup->_cells, AL0447_i_CreatureIndex)) != primaryDirectionToOrFromParty) && (AL0446_i_Cell != _vm->turnDirRight(primaryDirectionToOrFromParty))) { /* If the creature cannot cast spells (range = 1) and is not on a cell where it can attack the party directly and is a quarter square sized creature not in the center of the square then the creature moves to another cell and attack does not occur immediately */ if (!creatureCount && _vm->getRandomNumber(2)) { - activeGroup->_cells = k255_CreatureTypeSingleCenteredCreature; + activeGroup->_cells = kDMCreatureTypeSingleCenteredCreature; } else { if ((primaryDirectionToOrFromParty & 0x0001) == (AL0446_i_Cell & 0x0001)) AL0446_i_Cell--; @@ -1014,7 +1015,7 @@ T0209096_SetBehavior0_Wander: nextAspectUpdateTime = getCreatureAspectUpdateTime(activeGroup, AL0447_i_CreatureIndex, isCreatureAttacking(curGroup, eventMapX, eventMapY, AL0447_i_CreatureIndex)); nextEvent._mapTime += (creatureInfo._animationTicks & 0xF) + _vm->getRandomNumber(2); } else { - curGroup->setBehaviour(k7_behavior_APPROACH); + curGroup->setBehaviour(kDMBehaviorApproach); if (creatureCount) { stopAttacking(activeGroup, eventMapX, eventMapY); } @@ -1022,14 +1023,14 @@ T0209096_SetBehavior0_Wander: } } else { /* If the party is visible, update target coordinates */ - if (groupGetDistanceToVisibleParty(curGroup, kM1_wholeCreatureGroup, eventMapX, eventMapY)) { + if (groupGetDistanceToVisibleParty(curGroup, kDMWholeCreatureGroup, eventMapX, eventMapY)) { activeGroup->_targetMapX = _vm->_dungeonMan->_partyMapX; activeGroup->_targetMapY = _vm->_dungeonMan->_partyMapY; setGroupDirection(activeGroup, primaryDirectionToOrFromParty, AL0447_i_CreatureIndex, creatureCount && (creatureSize == kDMCreatureSizeHalf)); nextEvent._mapTime += 2; nextAspectUpdateTime = _vm->filterTime(nextEvent._mapTime); } else { /* If the party is not visible, move to the target (last known party location) */ - curGroup->setBehaviour(k7_behavior_APPROACH); + curGroup->setBehaviour(kDMBehaviorApproach); if (creatureCount) { stopAttacking(activeGroup, eventMapX, eventMapY); } @@ -1046,7 +1047,7 @@ T0209134_SetEvent37: } T0209135: if (!nextAspectUpdateTime) { - nextAspectUpdateTime = getCreatureAspectUpdateTime(activeGroup, kM1_wholeCreatureGroup, false); + nextAspectUpdateTime = getCreatureAspectUpdateTime(activeGroup, kDMWholeCreatureGroup, false); } T0209136: if (notUpdateBehaviorFl) { @@ -1062,7 +1063,7 @@ bool GroupMan::isMovementPossible(CreatureInfo *creatureInfo, int16 mapX, int16 _groupMovementBlockedByGroupThing = Thing::_endOfList; _groupMovementBlockedByDoor = false; _groupMovementBlockedByParty = false; - if (creatureInfo->_movementTicks == k255_immobile) + if (creatureInfo->_movementTicks == kDMMovementTicksImmobile) return false; _vm->_dungeonMan->mapCoordsAfterRelMovement((Direction)dir, 1, 0, mapX, mapY); @@ -1342,7 +1343,7 @@ void GroupMan::addGroupEvent(TimelineEvent *event, uint32 time) { if (time < (uint32)_vm->filterTime(event->_mapTime)) { event->_type -= 5; event->_Cu._ticks = _vm->filterTime(event->_mapTime) - time; - M32_setTime(event->_mapTime, time); + setTime(event->_mapTime, time); } else event->_Cu._ticks = time - _vm->filterTime(event->_mapTime); @@ -1421,7 +1422,7 @@ bool GroupMan::isCreatureAttacking(Group *group, int16 mapX, int16 mapY, uint16 int16 targetCell; byte groupCells = activeGroup._cells; - if (groupCells == k255_CreatureTypeSingleCenteredCreature) + if (groupCells == kDMCreatureTypeSingleCenteredCreature) targetCell = _vm->getRandomNumber(2); else targetCell = ((getCreatureValue(groupCells, creatureIndex) + 5 - primaryDirectionToParty) & 0x0002) >> 1; @@ -1563,7 +1564,7 @@ void GroupMan::stealFromChampion(Group *group, uint16 championIndex) { } if (!_vm->getRandomNumber(8) || (objectStolen && _vm->getRandomNumber(2))) { _activeGroups[group->getActiveGroupIndex()]._delayFleeingFromTarget = _vm->getRandomNumber(64) + 20; - group->setBehaviour(k5_behavior_FLEE); + group->setBehaviour(kDMBehaviorFlee); } } @@ -1641,13 +1642,13 @@ void GroupMan::dropMovingCreatureFixedPossession(Thing thing, int16 mapX, int16 void GroupMan::startWandering(int16 mapX, int16 mapY) { Group *L0332_ps_Group = (Group *)_vm->_dungeonMan->getThingData(groupGetThing(mapX, mapY)); - if (L0332_ps_Group->getBehaviour() >= k4_behavior_USELESS) { - L0332_ps_Group->setBehaviour(k0_behavior_WANDER); + if (L0332_ps_Group->getBehaviour() >= kDMBehaviorUnknown4) { + L0332_ps_Group->setBehaviour(kDMBehaviorWander); } TimelineEvent nextEvent; _vm->setMapAndTime(nextEvent._mapTime, _vm->_dungeonMan->_currMapIndex, (_vm->_gameTime + 1)); nextEvent._type = k37_TMEventTypeUpdateBehaviourGroup; - nextEvent._priority = 255 - _vm->_dungeonMan->_creatureInfos[L0332_ps_Group->_type]._movementTicks; /* The fastest creatures (with small MovementTicks value) get higher event priority */ + nextEvent._priority = kDMMovementTicksImmobile - _vm->_dungeonMan->_creatureInfos[L0332_ps_Group->_type]._movementTicks; /* The fastest creatures (with small MovementTicks value) get higher event priority */ nextEvent._Cu._ticks = 0; nextEvent._Bu._location._mapX = mapX; nextEvent._Bu._location._mapY = mapY; @@ -1679,7 +1680,7 @@ void GroupMan::addActiveGroup(Thing thing, int16 mapX, int16 mapY) { activeGroup->_directions = (Direction)getGroupValueUpdatedWithCreatureValue(activeGroup->_directions, creatureIndex, curGroup->getDir()); activeGroup->_aspect[creatureIndex] = 0; } while (creatureIndex--); - getCreatureAspectUpdateTime(activeGroup, kM1_wholeCreatureGroup, false); + getCreatureAspectUpdateTime(activeGroup, kDMWholeCreatureGroup, false); } void GroupMan::removeActiveGroup(uint16 activeGroupIndex) { @@ -1691,8 +1692,8 @@ void GroupMan::removeActiveGroup(uint16 activeGroupIndex) { _currActiveGroupCount--; group->_cells = activeGroup->_cells; group->setDir(_vm->normalizeModulo4(activeGroup->_directions)); - if (group->getBehaviour() >= k4_behavior_USELESS) { - group->setBehaviour(k0_behavior_WANDER); + if (group->getBehaviour() >= kDMBehaviorUnknown4) { + group->setBehaviour(kDMBehaviorWander); } activeGroup->_groupThingIndex = -1; } @@ -1743,7 +1744,7 @@ Thing GroupMan::groupGetGenerated(CreatureType creatureType, int16 healthMultipl if (severalCreaturesInGroup) cell = _vm->getRandomNumber(4); else - groupCells = k255_CreatureTypeSingleCenteredCreature; + groupCells = kDMCreatureTypeSingleCenteredCreature; group->_type = creatureType; CreatureInfo *creatureInfo = &_vm->_dungeonMan->_creatureInfos[group->_type]; @@ -1953,7 +1954,7 @@ void GroupMan::fuseAction(uint16 mapX, uint16 mapY) { if ((mapX < 0) || (mapX >= _vm->_dungeonMan->_currMapWidth) || (mapY < 0) || (mapY >= _vm->_dungeonMan->_currMapHeight)) return; - _vm->_projexpl->createExplosion(Thing::_explHarmNonMaterial, 255, mapX, mapY, k255_CreatureTypeSingleCenteredCreature); /* BUG0_17 The game crashes after the Fuse action is performed while looking at a wall on a map boundary. An explosion thing is created on the square in front of the party but there is no check to ensure the square coordinates are in the map bounds. This corrupts a memory location and leads to a game crash */ + _vm->_projexpl->createExplosion(Thing::_explHarmNonMaterial, 255, mapX, mapY, kDMCreatureTypeSingleCenteredCreature); /* BUG0_17 The game crashes after the Fuse action is performed while looking at a wall on a map boundary. An explosion thing is created on the square in front of the party but there is no check to ensure the square coordinates are in the map bounds. This corrupts a memory location and leads to a game crash */ Thing lordChaosThing = Thing(isLordChaosOnSquare(mapX, mapY)); if (lordChaosThing.toUint16()) { bool isFluxcages[4]; diff --git a/engines/dm/group.h b/engines/dm/group.h index 82985a29e6..a60eb75999 100644 --- a/engines/dm/group.h +++ b/engines/dm/group.h @@ -53,7 +53,7 @@ enum CreatureType { kDMCreatureTypeSkeleton = 12, // @ C12_CREATURE_SKELETON kDMCreatureTypeCouatl = 13, // @ C13_CREATURE_COUATL kDMCreatureTypeVexirk = 14, // @ C14_CREATURE_VEXIRK - kCreatureTypeMagentaWorm = 15, // @ C15_CREATURE_MAGENTA_WORM_WORM + kDMCreatureTypeMagentaWorm = 15, // @ C15_CREATURE_MAGENTA_WORM_WORM kDMCreatureTypeAntman = 16, // @ C16_CREATURE_TROLIN_ANTMAN kDMCreatureTypeGiantWasp = 17, // @ C17_CREATURE_GIANT_WASP_MUNCHER kDMCreatureTypeAnimatedArmour = 18, // @ C18_CREATURE_ANIMATED_ARMOUR_DETH_KNIGHT @@ -67,14 +67,27 @@ enum CreatureType { kDMCreatureTypeGreyLord = 26 // @ C26_CREATURE_GREY_LORD }; -#define k255_CreatureTypeSingleCenteredCreature 255 // @ C255_SINGLE_CENTERED_CREATURE - enum CreatureSize { kDMCreatureSizeQuarter = 0, // @ C0_SIZE_QUARTER_SQUARE kDMCreatureSizeHalf = 1, // @ C1_SIZE_HALF_SQUARE kDMCreatureSizeFull = 2 // @ C2_SIZE_FULL_SQUARE }; +enum Behavior { + kDMBehaviorWander = 0, // @ C0_BEHAVIOR_WANDER + kDMBehaviorUnknown2 = 2, // @ C2_BEHAVIOR_USELESS + kDMBehaviorUnknown3 = 3, // @ C3_BEHAVIOR_USELESS + kDMBehaviorUnknown4 = 4, // @ C4_BEHAVIOR_USELESS + kDMBehaviorFlee = 5, // @ C5_BEHAVIOR_FLEE + kDMBehaviorAttack = 6, // @ C6_BEHAVIOR_ATTACK + kDMBehaviorApproach = 7 // @ C7_BEHAVIOR_APPROACH +}; + +#define kDMImmuneToFear 15 // @ C15_IMMUNE_TO_FEAR +#define kDMMovementTicksImmobile 255 // @ C255_IMMOBILE +#define kDMWholeCreatureGroup -1 // @ CM1_WHOLE_CREATURE_GROUP +#define kDMCreatureTypeSingleCenteredCreature 255 // @ C255_SINGLE_CENTERED_CREATURE + enum CreatureMask { kDMCreatureMaskSize = 0x0003, // @ MASK0x0003_SIZE kDMCreatureMaskSideAttack = 0x0004, // @ MASK0x0004_SIDE_ATTACK @@ -111,7 +124,6 @@ public: byte _aspect[4]; }; // @ ACTIVE_GROUP - class Group { public: Thing _nextThing; @@ -141,23 +153,6 @@ public: void setDoNotDiscard(bool val) { _flags = (_flags & ~(1 << 10)) | ((val & 1) << 10); } }; // @ GROUP -#define k0_behavior_WANDER 0 // @ C0_BEHAVIOR_WANDER -#define k2_behavior_USELESS 2 // @ C2_BEHAVIOR_USELESS -#define k3_behavior_USELESS 3 // @ C3_BEHAVIOR_USELESS -#define k4_behavior_USELESS 4 // @ C4_BEHAVIOR_USELESS -#define k5_behavior_FLEE 5 // @ C5_BEHAVIOR_FLEE -#define k6_behavior_ATTACK 6 // @ C6_BEHAVIOR_ATTACK -#define k7_behavior_APPROACH 7 // @ C7_BEHAVIOR_APPROACH - -#define k15_immuneToFear 15 // @ C15_IMMUNE_TO_FEAR - -#define k255_immobile 255 // @ C255_IMMOBILE -#define kM1_wholeCreatureGroup -1 // @ CM1_WHOLE_CREATURE_GROUP - - -int32 M32_setTime(int32 &map_time, int32 time); // @ M32_SET_TIME - - class GroupMan { DMEngine *_vm; byte _dropMovingCreatureFixedPossessionsCell[4]; // @ G0392_auc_DropMovingCreatureFixedPossessionsCells @@ -178,6 +173,7 @@ class GroupMan { bool _groupMovBlockedByWallStairsPitFakeWalFluxCageTeleporter; // @ G0387_B_GroupMovementBlockedByWallStairsPitFakeWallFluxcageTeleporter int32 twoHalfSquareSizedCreaturesGroupLastDirectionSetTime; // @ G0395_l_TwoHalfSquareSizedCreaturesGroupLastDirectionSetTime uint16 toggleFlag(uint16 &val, uint16 mask); // @ M10_TOGGLE + int32 setTime(int32 &map_time, int32 time); // @ M32_SET_TIME public: uint16 _maxActiveGroupCount; // @ G0376_ui_MaximumActiveGroupCount @@ -254,7 +250,6 @@ public: void saveActiveGroupPart(Common::OutSaveFile *file); void loadActiveGroupPart(Common::InSaveFile *file); }; - } #endif diff --git a/engines/dm/menus.cpp b/engines/dm/menus.cpp index 41579f4afe..894bf658a9 100644 --- a/engines/dm/menus.cpp +++ b/engines/dm/menus.cpp @@ -1551,15 +1551,15 @@ bool MenuMan::isGroupFrightenedByAction(int16 champIndex, uint16 actionIndex, in 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)) { + if ((fearResistance > _vm->getRandomNumber(frightAmount)) || (fearResistance == kDMImmuneToFear)) { experience >>= 1; } else { ActiveGroup *activeGroup = &_vm->_groupMan->_activeGroups[targetGroup->getActiveGroupIndex()]; - if (targetGroup->getBehaviour() == k6_behavior_ATTACK) { + if (targetGroup->getBehaviour() == kDMBehaviorAttack) { _vm->_groupMan->stopAttacking(activeGroup, mapX, mapY); _vm->_groupMan->startWandering(mapX, mapY); } - targetGroup->setBehaviour(k5_behavior_FLEE); + targetGroup->setBehaviour(kDMBehaviorFlee); activeGroup->_delayFleeingFromTarget = ((16 - fearResistance) << 2) / creatureInfo->_movementTicks; retVal = true; } diff --git a/engines/dm/movesens.cpp b/engines/dm/movesens.cpp index b80f006e8c..d22db51cfa 100644 --- a/engines/dm/movesens.cpp +++ b/engines/dm/movesens.cpp @@ -620,7 +620,7 @@ int16 MovesensMan::getSound(CreatureType creatureType) { case kDMCreatureTypeRuster: case kDMCreatureTypeScreamer: case kDMCreatureTypeRockpile: - case kCreatureTypeMagentaWorm: + case kDMCreatureTypeMagentaWorm: case kDMCreatureTypeOitu: return k26_soundMOVE_SCREAMER_ROCK_ROCKPILE_MAGENTA_WORM_WORM_PAIN_RAT_HELLHOUND_RUSTER_GIANT_SCORPION_SCORPION_OITU; case kDMCreatureTypeRedDragon: @@ -653,7 +653,7 @@ int16 MovesensMan::getTeleporterRotatedGroupResult(Teleporter *teleporter, Thing updatedGroupDirections = _vm->normalizeModulo4(groupDirections + rotation); uint16 updatedGroupCells = _vm->_groupMan->getGroupCells(group, mapIndex); - if (updatedGroupCells != k255_CreatureTypeSingleCenteredCreature) { + if (updatedGroupCells != kDMCreatureTypeSingleCenteredCreature) { int16 groupCells = updatedGroupCells; int16 creatureSize = getFlag(_vm->_dungeonMan->_creatureInfos[group->_type]._attributes, kDMCreatureMaskSize); int16 relativeRotation = _vm->normalizeModulo4(4 + updatedGroupDirections - groupDirections); @@ -673,7 +673,7 @@ int16 MovesensMan::getTeleporterRotatedGroupResult(Teleporter *teleporter, Thing } _vm->_dungeonMan->setGroupDirections(group, updatedGroupDirections, mapIndex); _vm->_dungeonMan->setGroupCells(group, updatedGroupCells, mapIndex); - if ((mapIndex == _vm->_dungeonMan->_partyMapIndex) && (group->setBehaviour(k6_behavior_ATTACK))) + if ((mapIndex == _vm->_dungeonMan->_partyMapIndex) && (group->setBehaviour(kDMBehaviorAttack))) return group->getActiveGroupIndex() + 2; return 1; diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp index f692e70656..dc08ee7f89 100644 --- a/engines/dm/projexpl.cpp +++ b/engines/dm/projexpl.cpp @@ -208,7 +208,7 @@ bool ProjExpl::hasProjectileImpactOccurred(int16 impactType, int16 mapXCombo, in } if ((projectileAssociatedThing == Thing::_explLightningBolt) && !(explosionAttack >>= 1)) goto T0217044; - createExplosion(projectileAssociatedThing, explosionAttack, mapXCombo, mapYCombo, (projectileAssociatedThing == Thing::_explPoisonCloud) ? (uint16)k255_CreatureTypeSingleCenteredCreature : cell); + createExplosion(projectileAssociatedThing, explosionAttack, mapXCombo, mapYCombo, (projectileAssociatedThing == Thing::_explPoisonCloud) ? (uint16)kDMCreatureTypeSingleCenteredCreature : cell); } else { uint16 soundIndex; if ((projectileAssociatedThing).getType() == kDMThingTypeWeapon) @@ -294,7 +294,7 @@ void ProjExpl::createExplosion(Thing explThing, uint16 attack, uint16 mapXCombo, projectileMapY >>= 8; } - if (cell == k255_CreatureTypeSingleCenteredCreature) + if (cell == kDMCreatureTypeSingleCenteredCreature) explosion->setCentered(true); else { explosion->setCentered(false); |