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 /engines/dm/champion.cpp | |
parent | 75fe72b27cd2a76a2ecee8f0476a9ef089e6d857 (diff) | |
download | scummvm-rg350-3a654ff91e8548caf4365c657d5110b9d4a36c3e.tar.gz scummvm-rg350-3a654ff91e8548caf4365c657d5110b9d4a36c3e.tar.bz2 scummvm-rg350-3a654ff91e8548caf4365c657d5110b9d4a36c3e.zip |
DM: Add ChampionMan::f320_applyAndDrawPendingDamageAndWounds()
Diffstat (limited to 'engines/dm/champion.cpp')
-rw-r--r-- | engines/dm/champion.cpp | 219 |
1 files changed, 219 insertions, 0 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)
|