diff options
author | Bendegúz Nagy | 2016-07-13 19:51:14 +0200 |
---|---|---|
committer | Bendegúz Nagy | 2016-08-26 23:02:22 +0200 |
commit | 3a654ff91e8548caf4365c657d5110b9d4a36c3e (patch) | |
tree | dfbe28003e5223b7196fbf958c074550f7938926 | |
parent | 75fe72b27cd2a76a2ecee8f0476a9ef089e6d857 (diff) | |
download | scummvm-rg350-3a654ff91e8548caf4365c657d5110b9d4a36c3e.tar.gz scummvm-rg350-3a654ff91e8548caf4365c657d5110b9d4a36c3e.tar.bz2 scummvm-rg350-3a654ff91e8548caf4365c657d5110b9d4a36c3e.zip |
DM: Add ChampionMan::f320_applyAndDrawPendingDamageAndWounds()
-rw-r--r-- | engines/dm/champion.cpp | 219 | ||||
-rw-r--r-- | engines/dm/champion.h | 5 | ||||
-rw-r--r-- | engines/dm/dm.cpp | 2 | ||||
-rw-r--r-- | engines/dm/dungeonman.h | 1 | ||||
-rw-r--r-- | engines/dm/eventman.cpp | 7 | ||||
-rw-r--r-- | engines/dm/eventman.h | 2 | ||||
-rw-r--r-- | engines/dm/gfx.h | 2 |
7 files changed, 235 insertions, 3 deletions
diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index 52be549f61..b9bb5e3d2c 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -35,6 +35,7 @@ #include "timeline.h"
#include "projexpl.h"
#include "group.h"
+#include "movesens.h"
namespace DM {
@@ -1335,6 +1336,224 @@ void ChampionMan::f326_championShootProjectile(Champion* champ, Thing thing, int _vm->_g312_lastProjectileDisabledMovementDirection = L0990_ui_Direction;
}
+void ChampionMan::f320_applyAndDrawPendingDamageAndWounds() {
+ uint16 L0967_ui_ChampionIndex;
+ uint16 L0968_ui_PendingDamage;
+ int16 L0969_i_Multiple;
+#define AL0969_i_Health L0969_i_Multiple
+#define AL0969_i_X L0969_i_Multiple
+#define AL0969_i_EventIndex L0969_i_Multiple
+ int16 L0970_i_PendingWounds;
+ Champion* L0971_ps_Champion;
+ TimelineEvent* L0972_ps_Event;
+ int16 L0973_i_Y;
+ TimelineEvent L0974_s_Event;
+ Box L0975_s_Box;
+
+
+ L0971_ps_Champion = _vm->_championMan->_gK71_champions;
+ for (L0967_ui_ChampionIndex = k0_ChampionFirst; L0967_ui_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; L0967_ui_ChampionIndex++, L0971_ps_Champion++) {
+ setFlag(L0971_ps_Champion->_wounds, L0970_i_PendingWounds = _g410_championPendingWounds[L0967_ui_ChampionIndex]);
+ _g410_championPendingWounds[L0967_ui_ChampionIndex] = 0;
+ if (!(L0968_ui_PendingDamage = _g409_championPendingDamage[L0967_ui_ChampionIndex]))
+ continue;
+ _g409_championPendingDamage[L0967_ui_ChampionIndex] = 0;
+ if (!(AL0969_i_Health = L0971_ps_Champion->_currHealth))
+ continue;
+ if ((AL0969_i_Health = AL0969_i_Health - L0968_ui_PendingDamage) <= 0) {
+ _vm->_championMan->f319_championKill(L0967_ui_ChampionIndex);
+ } else {
+ L0971_ps_Champion->_currHealth = AL0969_i_Health;
+ setFlag(L0971_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
+ if (L0970_i_PendingWounds) {
+ setFlag(L0971_ps_Champion->_attributes, k0x2000_ChampionAttributeWounds);
+ }
+ AL0969_i_X = L0967_ui_ChampionIndex * k69_ChampionStatusBoxSpacing;
+ L0975_s_Box._y1 = 0;
+ _vm->_eventMan->f78_showMouse();
+ if (_vm->M0_indexToOrdinal(L0967_ui_ChampionIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
+ L0975_s_Box._y2 = 28;
+ L0975_s_Box._x2 = (L0975_s_Box._x1 = AL0969_i_X + 7) + 31; /* Box is over the champion portrait in the status box */
+ _vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k16_damageToChampionBig), &L0975_s_Box, k16_byteWidth, k10_ColorFlesh, 29);
+ if (L0968_ui_PendingDamage < 10) { /* 1 digit */
+ AL0969_i_X += 21;
+ } else {
+ if (L0968_ui_PendingDamage < 100) { /* 2 digits */
+ AL0969_i_X += 18;
+ } else { /* 3 digits */
+ AL0969_i_X += 15;
+ }
+ }
+ L0973_i_Y = 16;
+ } else {
+ L0975_s_Box._y2 = 6;
+ L0975_s_Box._x2 = (L0975_s_Box._x1 = AL0969_i_X) + 47; /* Box is over the champion name in the status box */
+ _vm->_displayMan->f21_blitToScreen(_vm->_displayMan->f489_getNativeBitmapOrGraphic(k15_damageToChampionSmallIndice), &L0975_s_Box, k24_byteWidth, k10_ColorFlesh, 7);
+ if (L0968_ui_PendingDamage < 10) { /* 1 digit */
+ AL0969_i_X += 19;
+ } else {
+ if (L0968_ui_PendingDamage < 100) { /* 2 digits */
+ AL0969_i_X += 16;
+ } else { /* 3 digits */
+ AL0969_i_X += 13;
+ }
+ }
+ L0973_i_Y = 5;
+ }
+ _vm->_textMan->f53_printToLogicalScreen(AL0969_i_X, L0973_i_Y, k15_ColorWhite, k8_ColorRed, _vm->_championMan->f288_getStringFromInteger(L0968_ui_PendingDamage, false, 3).c_str());
+ if ((AL0969_i_EventIndex = L0971_ps_Champion->_hideDamageReceivedIndex) == -1) {
+ L0974_s_Event._type = k12_TMEventTypeHideDamageReceived;
+ M33_setMapAndTime(L0974_s_Event._mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 5);
+ L0974_s_Event._priority = L0967_ui_ChampionIndex;
+ L0971_ps_Champion->_hideDamageReceivedIndex = _vm->_timeline->f238_addEventGetEventIndex(&L0974_s_Event);
+ } else {
+ L0972_ps_Event = &_vm->_timeline->_g370_events[AL0969_i_EventIndex];
+ M33_setMapAndTime(L0972_ps_Event->_mapTime, _vm->_dungeonMan->_g309_partyMapIndex, _vm->_g313_gameTime + 5);
+ _vm->_timeline->f236_fixChronology(_vm->_timeline->f235_getIndex(AL0969_i_EventIndex));
+ }
+ _vm->_championMan->f292_drawChampionState((ChampionIndex)L0967_ui_ChampionIndex);
+ _vm->_eventMan->f77_hideMouse();
+ }
+ }
+}
+
+void ChampionMan::f319_championKill(uint16 champIndex) {
+ uint16 L0962_ui_Multiple = 0;
+#define AL0962_ui_Cell L0962_ui_Multiple
+#define AL0962_ui_ChampionIconIndex L0962_ui_Multiple
+ int16 L0963_i_AliveChampionIndex;
+ Thing L0964_T_Thing;
+ Champion* L0965_ps_Champion;
+ Junk* L0966_ps_Junk;
+
+
+ L0965_ps_Champion = &_vm->_championMan->_gK71_champions[champIndex];
+ L0965_ps_Champion->_currHealth = 0;
+ setFlag(L0965_ps_Champion->_attributes, k0x1000_ChampionAttributeStatusBox);
+ if (_vm->M0_indexToOrdinal(champIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
+ if (_vm->_g331_pressingEye) {
+ _vm->_g331_pressingEye = false;
+ _vm->_eventMan->_g597_ignoreMouseMovements = false;
+ if (!_vm->_championMan->_g415_leaderEmptyHanded) {
+ _vm->_objectMan->f34_drawLeaderObjectName(_vm->_championMan->_g414_leaderHandObject);
+ }
+ _vm->_eventMan->_g587_hideMousePointerRequestCount = 1;
+ _vm->_eventMan->f77_hideMouse();
+ } else {
+ if (_vm->_g333_pressingMouth) {
+ _vm->_g333_pressingMouth = false;
+ _vm->_eventMan->_g597_ignoreMouseMovements = false;
+ _vm->_eventMan->_g587_hideMousePointerRequestCount = 1;
+ _vm->_eventMan->f77_hideMouse();
+ }
+ }
+ _vm->_inventoryMan->f355_toggleInventory(k4_ChampionCloseInventory);
+ }
+ f318_dropAllObjects(champIndex);
+ L0964_T_Thing = _vm->_dungeonMan->f166_getUnusedThing(k0x8000_championBones | k10_JunkThingType);
+ if (L0964_T_Thing == Thing::_none) {
+ } else {
+ L0966_ps_Junk = (Junk*)_vm->_dungeonMan->f156_getThingData(L0964_T_Thing);
+ L0966_ps_Junk->setType(k5_JunkTypeBones);
+ L0966_ps_Junk->setDoNotDiscard(true);
+ L0966_ps_Junk->setChargeCount(champIndex);
+ AL0962_ui_Cell = L0965_ps_Champion->_cell;
+ _vm->_movsens->f267_getMoveResult(M15_thingWithNewCell(L0964_T_Thing, AL0962_ui_Cell), kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
+ }
+ L0965_ps_Champion->_symbolStep = 0;
+ L0965_ps_Champion->_symbols[0] = '\0';
+ L0965_ps_Champion->_dir = _vm->_dungeonMan->_g308_partyDir;
+ L0965_ps_Champion->_maximumDamageReceived = 0;
+ AL0962_ui_ChampionIconIndex = _vm->_championMan->M26_championIconIndex(AL0962_ui_Cell, _vm->_dungeonMan->_g308_partyDir);
+ if (_vm->M0_indexToOrdinal(AL0962_ui_ChampionIconIndex) == _vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap) {
+ _vm->_eventMan->_g598_mousePointerBitmapUpdated = true;
+ _vm->_eventMan->_g599_useChampionIconOrdinalAsMousePointerBitmap = _vm->M0_indexToOrdinal(kM1_ChampionNone);
+ warning(false, "IGNORED CODE:G0592_B_BuildMousePointerScreenAreaRequested = true");
+ }
+ if (L0965_ps_Champion->_poisonEventCount) {
+ f323_unpoison(champIndex);
+ }
+ _vm->_displayMan->_g578_useByteBoxCoordinates = false;
+ _vm->_displayMan->D24_fillScreenBox(g54_BoxChampionIcons[AL0962_ui_ChampionIconIndex << 2], k0_ColorBlack);
+ _vm->_championMan->f292_drawChampionState((ChampionIndex)champIndex);
+ for (L0963_i_AliveChampionIndex = k0_ChampionFirst, L0965_ps_Champion = _vm->_championMan->_gK71_champions; L0963_i_AliveChampionIndex < _vm->_championMan->_g305_partyChampionCount; L0963_i_AliveChampionIndex++, L0965_ps_Champion++) {
+ if (L0965_ps_Champion->_currHealth)
+ break;
+ }
+ if (L0963_i_AliveChampionIndex == _vm->_championMan->_g305_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) */
+ _vm->_championMan->_g303_partyDead = true;
+ return;
+ }
+ if (champIndex == _vm->_championMan->_g411_leaderIndex) {
+ _vm->_eventMan->f368_commandSetLeader((ChampionIndex)L0963_i_AliveChampionIndex);
+ }
+ if (champIndex == _vm->_championMan->_g514_magicCasterChampionIndex) {
+ _vm->_menuMan->f394_setMagicCasterAndDrawSpellArea(L0963_i_AliveChampionIndex);
+ } else {
+ _vm->_menuMan->f393_drawSpellAreaControls(_vm->_championMan->_g514_magicCasterChampionIndex);
+ }
+}
+
+void ChampionMan::f318_dropAllObjects(uint16 champIndex) {
+ static int16 G0057_ai_Graphic562_SlotDropOrder[30] = {
+ k5_ChampionSlotFeet,
+ k4_ChampionSlotLegs,
+ k9_ChampionSlotQuiverLine_2_2,
+ k8_ChampionSlotQuiverLine_1_2,
+ k7_ChampionSlotQuiverLine_2_1,
+ k12_ChampionSlotQuiverLine_1_1,
+ k6_ChampionSlotPouch_2,
+ k11_ChampionSlotPouch_1,
+ k3_ChampionSlotTorso,
+ k13_ChampionSlotBackpackLine_1_1,
+ k14_ChampionSlotBackpackLine_2_2,
+ k15_ChampionSlotBackpackLine_2_3,
+ k16_ChampionSlotBackpackLine_2_4,
+ k17_ChampionSlotBackpackLine_2_5,
+ k18_ChampionSlotBackpackLine_2_6,
+ k19_ChampionSlotBackpackLine_2_7,
+ k20_ChampionSlotBackpackLine_2_8,
+ k21_ChampionSlotBackpackLine_2_9,
+ k22_ChampionSlotBackpackLine_1_2,
+ k23_ChampionSlotBackpackLine_1_3,
+ k24_ChampionSlotBackpackLine_1_4,
+ k25_ChampionSlotBackpackLine_1_5,
+ k26_ChampionSlotBackpackLine_1_6,
+ k27_ChampionSlotBackpackLine_1_7,
+ k28_ChampionSlotBackpackLine_1_8,
+ k29_ChampionSlotBackpackLine_1_9,
+ k10_ChampionSlotNeck,
+ k2_ChampionSlotHead,
+ k0_ChampionSlotReadyHand,
+ k1_ChampionSlotActionHand};
+
+ uint16 L0959_ui_Cell;
+ Thing L0960_T_Thing;
+ uint16 L0961_ui_SlotIndex;
+
+ L0959_ui_Cell = _vm->_championMan->_gK71_champions[champIndex]._cell;
+ for (L0961_ui_SlotIndex = k0_ChampionSlotReadyHand; L0961_ui_SlotIndex < k30_ChampionSlotChest_1; L0961_ui_SlotIndex++) {
+ if ((L0960_T_Thing = f300_getObjectRemovedFromSlot(champIndex, G0057_ai_Graphic562_SlotDropOrder[L0961_ui_SlotIndex])) != Thing::_none) {
+ _vm->_movsens->f267_getMoveResult(M15_thingWithNewCell(L0960_T_Thing, L0959_ui_Cell), kM1_MapXNotOnASquare, 0, _vm->_dungeonMan->_g306_partyMapX, _vm->_dungeonMan->_g307_partyMapY);
+ }
+ }
+}
+
+void ChampionMan::f323_unpoison(int16 champIndex) {
+ int16 L0982_i_EventIndex;
+ TimelineEvent* L0983_ps_Event;
+
+ if (champIndex == kM1_ChampionNone) {
+ return;
+ }
+ for (L0982_i_EventIndex = 0, L0983_ps_Event = _vm->_timeline->_g370_events; L0982_i_EventIndex < _vm->_timeline->_g369_eventMaxCount; L0983_ps_Event++, L0982_i_EventIndex++) {
+ if ((L0983_ps_Event->_type== k75_TMEventTypePoisonChampion) && (L0983_ps_Event->_priority == champIndex)) {
+ _vm->_timeline->f237_deleteEvent(L0982_i_EventIndex);
+ }
+ }
+ _vm->_championMan->_gK71_champions[champIndex]._poisonEventCount = 0;
+}
+
ChampionIndex ChampionMan::f285_getIndexInCell(int16 cell) {
for (uint16 i = 0; i < _g305_partyChampionCount; ++i) {
if ((_gK71_champions[i]._cell == cell) && _gK71_champions[i]._currHealth)
diff --git a/engines/dm/champion.h b/engines/dm/champion.h index 5d98ecbd41..2bb23809a0 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -575,7 +575,10 @@ public: bool f327_isProjectileSpellCast(uint16 champIndex, Thing thing, int16 kineticEnergy, uint16 requiredManaAmount); // @ F0327_CHAMPION_IsProjectileSpellCast void f326_championShootProjectile(Champion *champ, Thing thing, int16 kineticEnergy, int16 attack, int16 stepEnergy); // @ F0326_CHAMPION_ShootProjectile - + void f320_applyAndDrawPendingDamageAndWounds(); // @ F0320_CHAMPION_ApplyAndDrawPendingDamageAndWounds + void f319_championKill(uint16 champIndex); // @ F0319_CHAMPION_Kill + void f318_dropAllObjects(uint16 champIndex); // @ F0318_CHAMPION_DropAllObjects + void f323_unpoison(int16 champIndex); // @ F0323_CHAMPION_Unpoison }; diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 6a50e3eade..317508a9f8 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -361,7 +361,7 @@ T0002002: } // F0363_COMMAND_HighlightBoxDisable(); // F0065_SOUND_PlayPendingSound_CPSD(); - // F0320_CHAMPION_ApplyAndDrawPendingDamageAndWounds + _championMan->f320_applyAndDrawPendingDamageAndWounds(); if (_championMan->_g303_partyDead) break; _g313_gameTime++; diff --git a/engines/dm/dungeonman.h b/engines/dm/dungeonman.h index 515ef93413..a9bc369efe 100644 --- a/engines/dm/dungeonman.h +++ b/engines/dm/dungeonman.h @@ -495,6 +495,7 @@ public: uint16 getChargeCount() { return (_attributes >> 14) & 0x3; } void setChargeCount(uint16 val) { _attributes = (_attributes & ~(0x3 << 14)) | ((val & 0x3) << 14); } uint16 getDoNotDiscard() { return (_attributes >> 7) & 1; } + void setDoNotDiscard(uint16 val) { _attributes = (_attributes & ~(1 << 7)) | ((val & 1) << 7); } Thing getNextThing() { return _nextThing; } void setNextThing(Thing thing) { _nextThing = thing; } diff --git a/engines/dm/eventman.cpp b/engines/dm/eventman.cpp index b1ffe30af6..5fe80e2eda 100644 --- a/engines/dm/eventman.cpp +++ b/engines/dm/eventman.cpp @@ -355,6 +355,8 @@ EventManager::EventManager(DMEngine *vm) : _vm(vm) { _gK100_preventBuildPointerScreenArea = false; _g443_primaryKeyboardInput = nullptr; _g444_secondaryKeyboardInput = nullptr; + _g597_ignoreMouseMovements = false; + _g587_hideMousePointerRequestCount = 0; } EventManager::~EventManager() { @@ -518,10 +520,12 @@ void EventManager::f69_setMousePointer() { } void EventManager::f78_showMouse() { + //if(_g587_hideMousePointerRequestCount++ == 0) CursorMan.showMouse(true); } void EventManager::f77_hideMouse() { + // if(_g587_hideMousePointerRequestCount-- == 1) // CursorMan.showMouse(false); } @@ -564,7 +568,8 @@ void EventManager::processInput() { } case Common::EVENT_MOUSEMOVE: - _mousePos = event.mouse; + if (!_g597_ignoreMouseMovements) + _mousePos = event.mouse; break; case Common::EVENT_LBUTTONDOWN: case Common::EVENT_RBUTTONDOWN: diff --git a/engines/dm/eventman.h b/engines/dm/eventman.h index 24fca0f261..0a77cf8064 100644 --- a/engines/dm/eventman.h +++ b/engines/dm/eventman.h @@ -268,6 +268,8 @@ public: uint16 _g599_useChampionIconOrdinalAsMousePointerBitmap; // @ G0599_ui_UseChampionIconOrdinalAsMousePointerBitmap KeyboardInput *_g443_primaryKeyboardInput; // @ G0443_ps_PrimaryKeyboardInput KeyboardInput *_g444_secondaryKeyboardInput; // @ G0444_ps_SecondaryKeyboardInput + bool _g597_ignoreMouseMovements;// @ G0597_B_IgnoreMouseMovements + int16 _g587_hideMousePointerRequestCount; // @ G0587_i_HideMousePointerRequestCount void initMouse(); void f67_setMousePointerToNormal(int16 mousePointer); // @ F0067_MOUSE_SetPointerToNormal diff --git a/engines/dm/gfx.h b/engines/dm/gfx.h index 2ca77b99d1..d1cc5b77cd 100644 --- a/engines/dm/gfx.h +++ b/engines/dm/gfx.h @@ -207,6 +207,8 @@ enum GraphicIndice { k10_MenuActionAreaIndice = 10, // @ C010_GRAPHIC_MENU_ACTION_AREA k11_MenuSpellAreLinesIndice = 11, // @ C011_GRAPHIC_MENU_SPELL_AREA_LINES k13_MovementArrowsIndice = 13, // @ C013_GRAPHIC_MOVEMENT_ARROWS + k15_damageToChampionSmallIndice = 15, // @ C015_GRAPHIC_DAMAGE_TO_CHAMPION_SMALL + k16_damageToChampionBig = 16, // @ C016_GRAPHIC_DAMAGE_TO_CHAMPION_BIG k17_InventoryGraphicIndice = 17, // @ C017_GRAPHIC_INVENTORY k18_ArrowForChestContentIndice = 18, // @ C018_GRAPHIC_ARROW_FOR_CHEST_CONTENT k19_EyeForObjectDescriptionIndice = 19, // @ C019_GRAPHIC_EYE_FOR_OBJECT_DESCRIPTION |