diff options
-rw-r--r-- | engines/dm/champion.cpp | 154 | ||||
-rw-r--r-- | engines/dm/champion.h | 1 | ||||
-rw-r--r-- | engines/dm/dm.cpp | 6 |
3 files changed, 157 insertions, 4 deletions
diff --git a/engines/dm/champion.cpp b/engines/dm/champion.cpp index b9bb5e3d2c..717e182b62 100644 --- a/engines/dm/champion.cpp +++ b/engines/dm/champion.cpp @@ -1547,13 +1547,165 @@ void ChampionMan::f323_unpoison(int16 champIndex) { 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)) {
+ 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;
}
+void ChampionMan::f331_applyTimeEffects() {
+ uint16 L1006_ui_Multiple;
+#define AL1006_ui_GameTime L1006_ui_Multiple
+#define AL1006_ui_ChampionIndex L1006_ui_Multiple
+ uint16 L1007_ui_Multiple;
+#define AL1007_ui_ScentIndex L1007_ui_Multiple
+#define AL1007_ui_ManaGain L1007_ui_Multiple
+#define AL1007_ui_StaminaGainCycleCount L1007_ui_Multiple
+#define AL1007_ui_StatisticIndex L1007_ui_Multiple
+ uint16 L1008_ui_Multiple;
+#define AL1008_ui_WizardSkillLevel L1008_ui_Multiple
+#define AL1008_ui_Delay L1008_ui_Multiple
+#define AL1008_ui_StaminaAboveHalf L1008_ui_Multiple
+#define AL1008_ui_StatisticMaximum L1008_ui_Multiple
+ int16 L1009_i_Multiple;
+#define AL1009_i_SkillIndex L1009_i_Multiple
+#define AL1009_i_StaminaMagnitude L1009_i_Multiple
+#define AL1009_i_StaminaLoss L1009_i_Multiple
+ Champion* L1010_ps_Champion;
+ unsigned char* L1011_puc_Statistic;
+ uint16 L1012_ui_TimeCriteria;
+ int16 L1013_i_Multiple;
+#define AL1013_i_StaminaAmount L1013_i_Multiple
+#define AL1013_i_HealthGain L1013_i_Multiple
+ Scent L1014_s_Scent;
+
+
+ if (!_vm->_championMan->_g305_partyChampionCount) {
+ return;
+ }
+ L1014_s_Scent.setMapX(_vm->_dungeonMan->_g306_partyMapX);
+ L1014_s_Scent.setMapY(_vm->_dungeonMan->_g307_partyMapY);
+ L1014_s_Scent.setMapIndex(_vm->_dungeonMan->_g309_partyMapIndex);
+ AL1007_ui_ScentIndex = 0;
+ while ((int16)AL1007_ui_ScentIndex < (int16)(_vm->_championMan->_g407_party._scentCount - 1)) {
+ if (&_vm->_championMan->_g407_party._scents[AL1007_ui_ScentIndex] != &L1014_s_Scent) {
+ if (!(_vm->_championMan->_g407_party._scentStrengths[AL1007_ui_ScentIndex] = MAX(0, _vm->_championMan->_g407_party._scentStrengths[AL1007_ui_ScentIndex] - 1)) && !AL1007_ui_ScentIndex) {
+ f316_deleteScent(0);
+ continue;
+ }
+ }
+ AL1007_ui_ScentIndex++;
+ }
+ AL1006_ui_GameTime = _vm->_g313_gameTime;
+ L1012_ui_TimeCriteria = (((AL1006_ui_GameTime & 0x0080) + ((AL1006_ui_GameTime & 0x0100) >> 2)) + ((AL1006_ui_GameTime & 0x0040) << 2)) >> 2;
+ for (AL1006_ui_ChampionIndex = k0_ChampionFirst, L1010_ps_Champion = _vm->_championMan->_gK71_champions; AL1006_ui_ChampionIndex < _vm->_championMan->_g305_partyChampionCount; AL1006_ui_ChampionIndex++, L1010_ps_Champion++) {
+ if (L1010_ps_Champion->_currHealth && (_vm->M0_indexToOrdinal(AL1006_ui_ChampionIndex) != _vm->_championMan->_g299_candidateChampionOrdinal)) {
+ if ((L1010_ps_Champion->_currMana < L1010_ps_Champion->_maxMana) && (L1012_ui_TimeCriteria < (L1010_ps_Champion->_statistics[k3_ChampionStatWisdom][k1_ChampionStatCurrent] + (AL1008_ui_WizardSkillLevel = _vm->_championMan->f303_getSkillLevel(AL1006_ui_ChampionIndex, k3_ChampionSkillWizard) + _vm->_championMan->f303_getSkillLevel(AL1006_ui_ChampionIndex, k2_ChampionSkillPriest))))) {
+ AL1007_ui_ManaGain = L1010_ps_Champion->_maxMana / 40;
+ if (_vm->_championMan->_g300_partyIsSleeping) {
+ AL1007_ui_ManaGain = AL1007_ui_ManaGain << 1;
+ }
+ AL1007_ui_ManaGain++;
+ f325_decrementStamine(AL1006_ui_ChampionIndex, AL1007_ui_ManaGain * MAX(7, 16 - AL1008_ui_WizardSkillLevel));
+ L1010_ps_Champion->_currMana += MIN(AL1007_ui_ManaGain, (uint16)(L1010_ps_Champion->_maxMana - L1010_ps_Champion->_currMana));
+ } else {
+ if (L1010_ps_Champion->_currMana > L1010_ps_Champion->_maxMana) {
+ L1010_ps_Champion->_currMana--;
+ }
+ }
+ for (AL1009_i_SkillIndex = k19_ChampionSkillWater; AL1009_i_SkillIndex >= k0_ChampionSkillFighter; AL1009_i_SkillIndex--) {
+ if (L1010_ps_Champion->_skills[AL1009_i_SkillIndex]._temporaryExperience > 0) {
+ L1010_ps_Champion->_skills[AL1009_i_SkillIndex]._temporaryExperience--;
+ }
+ }
+ AL1007_ui_StaminaGainCycleCount = 4;
+ AL1009_i_StaminaMagnitude = L1010_ps_Champion->_maxStamina;
+ while (L1010_ps_Champion->_currStamina < (AL1009_i_StaminaMagnitude >>= 1)) {
+ AL1007_ui_StaminaGainCycleCount += 2;
+ }
+ AL1009_i_StaminaLoss = 0;
+ AL1013_i_StaminaAmount = f26_getBoundedValue(1, (L1010_ps_Champion->_maxStamina >> 8) - 1, 6);
+ if (_vm->_championMan->_g300_partyIsSleeping) {
+ AL1013_i_StaminaAmount <<= 1;
+ }
+ if ((AL1008_ui_Delay = (_vm->_g313_gameTime - _vm->_projexpl->_g362_lastPartyMovementTime)) > 80) {
+ AL1013_i_StaminaAmount++;
+ if (AL1008_ui_Delay > 250) {
+ AL1013_i_StaminaAmount++;
+ }
+ }
+ do {
+ AL1008_ui_StaminaAboveHalf = (AL1007_ui_StaminaGainCycleCount <= 4);
+ if (L1010_ps_Champion->_food < -512) {
+ if (AL1008_ui_StaminaAboveHalf) {
+ AL1009_i_StaminaLoss += AL1013_i_StaminaAmount;
+ L1010_ps_Champion->_food -= 2;
+ }
+ } else {
+ if (L1010_ps_Champion->_food >= 0) {
+ AL1009_i_StaminaLoss -= AL1013_i_StaminaAmount;
+ }
+ L1010_ps_Champion->_food -= AL1008_ui_StaminaAboveHalf ? 2 : AL1007_ui_StaminaGainCycleCount >> 1;
+ }
+ if (L1010_ps_Champion->_water < -512) {
+ if (AL1008_ui_StaminaAboveHalf) {
+ AL1009_i_StaminaLoss += AL1013_i_StaminaAmount;
+ L1010_ps_Champion->_water -= 1;
+ }
+ } else {
+ if (L1010_ps_Champion->_water >= 0) {
+ AL1009_i_StaminaLoss -= AL1013_i_StaminaAmount;
+ }
+ L1010_ps_Champion->_water -= AL1008_ui_StaminaAboveHalf ? 1 : AL1007_ui_StaminaGainCycleCount >> 2;
+ }
+ } while (--AL1007_ui_StaminaGainCycleCount && ((L1010_ps_Champion->_currStamina - AL1009_i_StaminaLoss) < L1010_ps_Champion->_maxStamina));
+ f325_decrementStamine(AL1006_ui_ChampionIndex, AL1009_i_StaminaLoss);
+ if (L1010_ps_Champion->_food < -1024) {
+ L1010_ps_Champion->_food = -1024;
+ }
+ if (L1010_ps_Champion->_water < -1024) {
+ L1010_ps_Champion->_water = -1024;
+ }
+ if ((L1010_ps_Champion->_currHealth < L1010_ps_Champion->_maxHealth) && (L1010_ps_Champion->_currStamina >= (L1010_ps_Champion->_maxStamina >> 2)) && (L1012_ui_TimeCriteria < (L1010_ps_Champion->_statistics[k4_ChampionStatVitality][k1_ChampionStatCurrent] + 12))) {
+ AL1013_i_HealthGain = (L1010_ps_Champion->_maxHealth >> 7) + 1;
+ if (_vm->_championMan->_g300_partyIsSleeping) {
+ AL1013_i_HealthGain <<= 1;
+ }
+ if (_vm->_objectMan->f33_getIconIndex(L1010_ps_Champion->_slots[k10_ChampionSlotNeck]) == k121_IconIndiceJunkEkkhardCross) {
+ AL1013_i_HealthGain += (AL1013_i_HealthGain >> 1) + 1;
+ }
+ L1010_ps_Champion->_currHealth += MIN(AL1013_i_HealthGain, (int16)(L1010_ps_Champion->_maxHealth - L1010_ps_Champion->_currHealth));
+ }
+ if (!((int)_vm->_g313_gameTime & (_vm->_championMan->_g300_partyIsSleeping ? 63 : 255))) {
+ for (AL1007_ui_StatisticIndex = k0_ChampionStatLuck; AL1007_ui_StatisticIndex <= k6_ChampionStatAntifire; AL1007_ui_StatisticIndex++) {
+ L1011_puc_Statistic = L1010_ps_Champion->_statistics[AL1007_ui_StatisticIndex];
+ AL1008_ui_StatisticMaximum = L1011_puc_Statistic[k0_ChampionStatMaximum];
+ if (L1011_puc_Statistic[k1_ChampionStatCurrent] < AL1008_ui_StatisticMaximum) {
+ L1011_puc_Statistic[k1_ChampionStatCurrent]++;
+ } else {
+ if (L1011_puc_Statistic[k1_ChampionStatCurrent] > AL1008_ui_StatisticMaximum) {
+ L1011_puc_Statistic[k1_ChampionStatCurrent] -= L1011_puc_Statistic[k1_ChampionStatCurrent] / AL1008_ui_StatisticMaximum;
+ }
+ }
+ }
+ }
+ if (!_vm->_championMan->_g300_partyIsSleeping && (L1010_ps_Champion->_dir != _vm->_dungeonMan->_g308_partyDir) && (_vm->_projexpl->_g361_lastCreatureAttackTime < (_vm->_g313_gameTime - 60))) {
+ L1010_ps_Champion->_dir = _vm->_dungeonMan->_g308_partyDir;
+ L1010_ps_Champion->_maximumDamageReceived = 0;
+ setFlag(L1010_ps_Champion->_attributes, k0x0400_ChampionAttributeIcon);
+ }
+ setFlag(L1010_ps_Champion->_attributes, k0x0100_ChampionAttributeStatistics);
+ if (_vm->M0_indexToOrdinal(AL1006_ui_ChampionIndex) == _vm->_inventoryMan->_g432_inventoryChampionOrdinal) {
+ if (_vm->_g333_pressingMouth || _vm->_g331_pressingEye || (_vm->_inventoryMan->_g424_panelContent == k0_PanelContentFoodWaterPoisoned)) {
+ setFlag(L1010_ps_Champion->_attributes, k0x0800_ChampionAttributePanel);
+ }
+ }
+ }
+ }
+ f293_drawAllChampionStates();
+}
+
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 2bb23809a0..d4491d50c8 100644 --- a/engines/dm/champion.h +++ b/engines/dm/champion.h @@ -579,6 +579,7 @@ public: void f319_championKill(uint16 champIndex); // @ F0319_CHAMPION_Kill void f318_dropAllObjects(uint16 champIndex); // @ F0318_CHAMPION_DropAllObjects void f323_unpoison(int16 champIndex); // @ F0323_CHAMPION_Unpoison + void f331_applyTimeEffects(); // @ F0331_CHAMPION_ApplyTimeEffects_CPSF }; diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp index 317508a9f8..2bd4a2e753 100644 --- a/engines/dm/dm.cpp +++ b/engines/dm/dm.cpp @@ -374,9 +374,9 @@ T0002002: _menuMan->f390_refreshActionAreaAndSetChampDirMaxDamageReceived(); - // if (!((int)_vm->_g313_gameTime & (_vm->_championMan->_g300_partyIsSleeping ? 15 : 63))) { - // F0331_CHAMPION_ApplyTimeEffects_CPSF(); - // } + if (!((int32)_g313_gameTime & (_championMan->_g300_partyIsSleeping ? 15 : 63))) { + _championMan->f331_applyTimeEffects(); + } if (_g310_disabledMovementTicks) _g310_disabledMovementTicks--; |