aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBendegúz Nagy2016-07-11 15:20:00 +0200
committerBendegúz Nagy2016-08-26 23:02:22 +0200
commit12f06fd1d9460524ba8e9307a89edc1454516c27 (patch)
treee9b2268da9b20a68882efc08843f455fdca62164
parentdd3f12c7d5b85cb8bd6644a8c9de9fe49ca4166a (diff)
downloadscummvm-rg350-12f06fd1d9460524ba8e9307a89edc1454516c27.tar.gz
scummvm-rg350-12f06fd1d9460524ba8e9307a89edc1454516c27.tar.bz2
scummvm-rg350-12f06fd1d9460524ba8e9307a89edc1454516c27.zip
DM: Add f219_processEvents48To49_projectile
-rw-r--r--engines/dm/dm.cpp2
-rw-r--r--engines/dm/projexpl.cpp86
-rw-r--r--engines/dm/projexpl.h12
-rw-r--r--engines/dm/timeline.cpp6
4 files changed, 100 insertions, 6 deletions
diff --git a/engines/dm/dm.cpp b/engines/dm/dm.cpp
index fd3c30ec1c..8a49b23e87 100644
--- a/engines/dm/dm.cpp
+++ b/engines/dm/dm.cpp
@@ -365,7 +365,7 @@ T0002002:
_g313_gameTime++;
if (!(_g313_gameTime & 511))
- //_inventoryMan->f338_decreaseTorchesLightPower();
+ _inventoryMan->f338_decreaseTorchesLightPower();
if (_g310_disabledMovementTicks) {
_g310_disabledMovementTicks--;
}
diff --git a/engines/dm/projexpl.cpp b/engines/dm/projexpl.cpp
index 94d9d21847..53b3f3afef 100644
--- a/engines/dm/projexpl.cpp
+++ b/engines/dm/projexpl.cpp
@@ -414,4 +414,90 @@ void ProjExpl::f215_projectileDelete(Thing projectileThing, Thing* groupSlot, in
}
L0480_ps_Projectile->_nextThing = Thing::_none;
}
+
+void ProjExpl::f219_processEvents48To49_projectile(TimelineEvent* event) {
+ TimelineEvent* L0519_ps_Event;
+ Projectile* L0520_ps_Projectile;
+ Thing L0515_T_ProjectileThingNewCell;
+ uint16 L0516_ui_Multiple;
+#define AL0516_ui_StepEnergy L0516_ui_Multiple
+#define AL0516_ui_Square L0516_ui_Multiple
+ Thing L0521_T_ProjectileThing;
+ uint16 L0517_ui_ProjectileDirection;
+ bool L0522_B_ProjectileMovesToOtherSquare;
+ int16 L0523_i_DestinationMapX;
+ int16 L0524_i_DestinationMapY;
+ uint16 L0518_ui_Cell;
+ int16 L0525_i_SourceMapX;
+ int16 L0526_i_SourceMapY;
+ TimelineEvent L0527_s_Event;
+
+
+ L0527_s_Event = *event;
+ L0519_ps_Event = &L0527_s_Event;
+ L0520_ps_Projectile = (Projectile*)_vm->_dungeonMan->f156_getThingData(L0521_T_ProjectileThing = L0515_T_ProjectileThingNewCell = Thing(L0519_ps_Event->_B._slot));
+ L0523_i_DestinationMapX = L0519_ps_Event->_C._projectile.getMapX();
+ L0524_i_DestinationMapY = L0519_ps_Event->_C._projectile.getMapY();
+ if (L0519_ps_Event->_type == k48_TMEventTypeMoveProjectileIgnoreImpacts) {
+ L0519_ps_Event->_type = k49_TMEventTypeMoveProjectile;
+ } else {
+ L0518_ui_Cell = (L0515_T_ProjectileThingNewCell).getCell();
+ if ((_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) && (L0523_i_DestinationMapX == _vm->_dungeonMan->_g306_partyMapX) && (L0524_i_DestinationMapY == _vm->_dungeonMan->_g307_partyMapY) && f217_projectileHasImpactOccurred(kM2_ChampionElemType, L0523_i_DestinationMapX, L0524_i_DestinationMapY, L0518_ui_Cell, L0515_T_ProjectileThingNewCell)) {
+ return;
+ }
+ if ((_vm->_groupMan->f175_groupGetThing(L0523_i_DestinationMapX, L0524_i_DestinationMapY) != Thing::_endOfList) && f217_projectileHasImpactOccurred(kM1_CreatureElemType, L0523_i_DestinationMapX, L0524_i_DestinationMapY, L0518_ui_Cell, L0521_T_ProjectileThing)) {
+ return;
+ }
+ if (L0520_ps_Projectile->_kineticEnergy <= (AL0516_ui_StepEnergy = L0519_ps_Event->_C._projectile.getStepEnergy())) {
+ _vm->_dungeonMan->f164_unlinkThingFromList(L0515_T_ProjectileThingNewCell = L0521_T_ProjectileThing, Thing(0), L0523_i_DestinationMapX, L0524_i_DestinationMapY);
+ f215_projectileDelete(L0515_T_ProjectileThingNewCell, NULL, L0523_i_DestinationMapX, L0524_i_DestinationMapY);
+ return;
+ }
+ L0520_ps_Projectile->_kineticEnergy -= AL0516_ui_StepEnergy;
+ if (L0520_ps_Projectile->_attack < AL0516_ui_StepEnergy) {
+ L0520_ps_Projectile->_attack = 0;
+ } else {
+ L0520_ps_Projectile->_attack -= AL0516_ui_StepEnergy;
+ }
+ }
+ if (L0522_B_ProjectileMovesToOtherSquare = ((L0517_ui_ProjectileDirection = L0519_ps_Event->_C._projectile.getDir()) == (L0518_ui_Cell = (L0515_T_ProjectileThingNewCell = Thing(L0519_ps_Event->_B._slot)).getCell())) || (returnNextVal(L0517_ui_ProjectileDirection) == L0518_ui_Cell)) {
+ L0525_i_SourceMapX = L0523_i_DestinationMapX;
+ L0526_i_SourceMapY = L0524_i_DestinationMapY;
+ L0523_i_DestinationMapX += _vm->_dirIntoStepCountEast[L0517_ui_ProjectileDirection], L0524_i_DestinationMapY += _vm->_dirIntoStepCountNorth[L0517_ui_ProjectileDirection];
+ if ((Square(AL0516_ui_Square = _vm->_dungeonMan->f151_getSquare(L0523_i_DestinationMapX, L0524_i_DestinationMapY).toByte()).getType() == k0_ElementTypeWall) ||
+ ((Square(AL0516_ui_Square).getType() == k6_ElementTypeFakeWall) && !getFlag(AL0516_ui_Square, (k0x0001_FakeWallImaginary | k0x0004_FakeWallOpen))) ||
+ ((Square(AL0516_ui_Square).getType() == k3_ElementTypeStairs) && (Square(_vm->_dungeonMan->_g271_currMapData[L0525_i_SourceMapX][L0526_i_SourceMapY]).getType() == k3_ElementTypeStairs))) {
+ if (f217_projectileHasImpactOccurred(Square(AL0516_ui_Square).getType(), L0525_i_SourceMapX, L0526_i_SourceMapY, L0518_ui_Cell, L0515_T_ProjectileThingNewCell)) {
+ return;
+ }
+ }
+ }
+ if ((L0517_ui_ProjectileDirection & 0x0001) == (L0518_ui_Cell & 0x0001)) {
+ L0518_ui_Cell--;
+ } else {
+ L0518_ui_Cell++;
+ }
+ L0515_T_ProjectileThingNewCell = M15_thingWithNewCell(L0515_T_ProjectileThingNewCell, L0518_ui_Cell &= 0x0003);
+ if (L0522_B_ProjectileMovesToOtherSquare) {
+ _vm->_movsens->f267_getMoveResult(L0515_T_ProjectileThingNewCell, L0525_i_SourceMapX, L0526_i_SourceMapY, L0523_i_DestinationMapX, L0524_i_DestinationMapY);
+ L0519_ps_Event->_C._projectile.setMapX(_vm->_movsens->_g397_moveResultMapX);
+ L0519_ps_Event->_C._projectile.setMapY(_vm->_movsens->_g398_moveResultMapY);
+ L0519_ps_Event->_C._projectile.setDir((direction)_vm->_movsens->_g400_moveResultDir);
+ L0515_T_ProjectileThingNewCell = M15_thingWithNewCell(L0515_T_ProjectileThingNewCell, _vm->_movsens->_g401_moveResultCell);
+ M31_setMap(L0519_ps_Event->_mapTime, _vm->_movsens->_g399_moveResultMapIndex);
+ } else {
+ if ((Square(_vm->_dungeonMan->f151_getSquare(L0523_i_DestinationMapX, L0524_i_DestinationMapY)).getType() == k4_DoorElemType) && f217_projectileHasImpactOccurred(k4_DoorElemType, L0523_i_DestinationMapX, L0524_i_DestinationMapY, L0518_ui_Cell, L0521_T_ProjectileThing)) {
+ return;
+ }
+ _vm->_dungeonMan->f164_unlinkThingFromList(L0515_T_ProjectileThingNewCell, Thing(0), L0523_i_DestinationMapX, L0524_i_DestinationMapY);
+ _vm->_dungeonMan->f163_linkThingToList(L0515_T_ProjectileThingNewCell, Thing(0), L0523_i_DestinationMapX, L0524_i_DestinationMapY);
+ }
+ L0519_ps_Event->_mapTime += (_vm->_dungeonMan->_g272_currMapIndex == _vm->_dungeonMan->_g309_partyMapIndex) ? 1 : 3;
+ //Strangerke: CHECKME: Maybe we should keep that piece of code too as it sounds like it's fixing a weird behavior of projectiles on different maps
+#ifdef COMPILE42_CSB20EN_CSB21EN /* CHANGE7_20_IMPROVEMENT Projectiles now move at the same speed on all maps instead of moving slower on maps other than the party map */
+ L0519_ps_Event->Map_Time++;
+#endif
+ L0519_ps_Event->_B._slot = L0515_T_ProjectileThingNewCell.toUint16();
+ L0520_ps_Projectile->_eventIndex = _vm->_timeline->f238_addEventGetEventIndex(L0519_ps_Event);
+}
}
diff --git a/engines/dm/projexpl.h b/engines/dm/projexpl.h
index 32829f15af..125bd8e30f 100644
--- a/engines/dm/projexpl.h
+++ b/engines/dm/projexpl.h
@@ -30,6 +30,8 @@
#include "dm.h"
+namespace DM {
+
#define k0_outcomeKilledNoCreaturesInGroup 0 // @ C0_OUTCOME_KILLED_NO_CREATURES_IN_GROUP
#define k1_outcomeKilledSomeCreaturesInGroup 1 // @ C1_OUTCOME_KILLED_SOME_CREATURES_IN_GROUP
#define k2_outcomeKilledAllCreaturesInGroup 2 // @ C2_OUTCOME_KILLED_ALL_CREATURES_IN_GROUP
@@ -70,10 +72,12 @@
#define k33_soundMOVE_SKELETON 33 // @ C33_SOUND_MOVE_SKELETON
-namespace DM {
- class Projectile;
+#define M31_setMap(map_time, map) ((map_time) = (((map_time) & 0x00FFFFFF) | (((int32)(map)) << 24)))
- class ProjExpl {
+class TimelineEvent;
+class Projectile;
+
+class ProjExpl {
DMEngine *_vm;
public:
int16 _g364_creatureDamageOutcome; // @ G0364_i_CreatureDamageOutcome
@@ -94,6 +98,8 @@ public:
int16 f218_projectileGetImpactCount(int16 impactType, int16 mapX, int16 mapY, int16 cell); // @ F0218_PROJECTILE_GetImpactCount
void f214_projectileDeleteEvent(Thing thing); // @ F0214_PROJECTILE_DeleteEvent
void f215_projectileDelete(Thing projectileThing, Thing *groupSlot, int16 mapX, int16 mapY); // @ F0215_PROJECTILE_Delete
+ void f219_processEvents48To49_projectile(TimelineEvent *event); // @ F0219_PROJECTILE_ProcessEvents48To49_Projectile
+
};
}
diff --git a/engines/dm/timeline.cpp b/engines/dm/timeline.cpp
index 8f071574a5..c98338cb94 100644
--- a/engines/dm/timeline.cpp
+++ b/engines/dm/timeline.cpp
@@ -29,6 +29,8 @@
#include "dungeonman.h"
#include "champion.h"
#include "inventory.h"
+#include "group.h"
+#include "projexpl.h"
namespace DM {
@@ -224,12 +226,12 @@ void Timeline::f261_processTimeline() {
_vm->_dungeonMan->f173_setCurrentMap(M29_map(L0682_s_Event._mapTime));
AL0680_ui_EventType = L0682_s_Event._type;
if ((AL0680_ui_EventType > (k29_TMEventTypeGroupReactionDangerOnSquare - 1)) && (AL0680_ui_EventType < (k41_TMEventTypeUpdateBehaviour_3 + 1))) {
- //F0209_GROUP_ProcessEvents29to41(L0682_s_Event._B._location._mapX, L0682_s_Event._B._location._mapY, AL0680_ui_EventType, L0682_s_Event._C._ticks);
+ _vm->_groupMan->f209_processEvents29to41(L0682_s_Event._B._location._mapX, L0682_s_Event._B._location._mapY, AL0680_ui_EventType, L0682_s_Event._C._ticks);
} else {
switch (AL0680_ui_EventType) {
case k48_TMEventTypeMoveProjectileIgnoreImpacts:
case k49_TMEventTypeMoveProjectile:
- //F0219_PROJECTILE_ProcessEvents48To49_Projectile(L0681_ps_Event);
+ _vm->_projexpl->f219_processEvents48To49_projectile(L0681_ps_Event);
break;
case k1_TMEventTypeDoorAnimation:
//F0241_TIMELINE_ProcessEvent1_DoorAnimation(L0681_ps_Event);