Skip to content

Commit

Permalink
DM: Add F0282_CHAMPION_ProcessCommands160To162_ClickInResurrectReinca…
Browse files Browse the repository at this point in the history
…rnatePanel
  • Loading branch information
Bendegúz Nagy committed Aug 26, 2016
1 parent c1abeff commit eddf2f4
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 22 deletions.
8 changes: 4 additions & 4 deletions engines/dm/champion.cpp
Expand Up @@ -38,12 +38,12 @@ namespace DM {

Box gBoxMouth = Box(55, 72, 12, 29); // @ G0048_s_Graphic562_Box_Mouth
Box gBoxEye = Box(11, 28, 12, 29); // @ G0049_s_Graphic562_Box_Eye
Box gBoxChampionIcons[4] = { // @ G0054_ai_Graphic562_Box_ChampionIcons
Box gBoxChampionIcons[4] = {
Box(281, 299, 0, 13),
Box(301, 319, 0, 13),
Box(301, 319, 15, 28),
Box(281, 299, 15, 28)};
Color gChampionColor[4] = {(Color)7, (Color)11, (Color)8, (Color)14}; // @ G0046_auc_Graphic562_ChampionColor
Color gChampionColor[4] = {(Color)7, (Color)11, (Color)8, (Color)14};

uint16 gSlotMasks[38] = { // @ G0038_ai_Graphic562_SlotMasks
/* 30 for champion inventory, 8 for chest */
Expand Down Expand Up @@ -265,8 +265,8 @@ void ChampionMan::addCandidateChampionToParty(uint16 championPortraitIndex) {
int16 mapY = _vm->_dungeonMan->_currMap._partyPosY;

uint16 championObjectsCell = returnOppositeDir((direction)(dunMan._currMap._partyDir));
mapX += _dirIntoStepCountEast[dunMan._currMap._partyDir];
mapY += _dirIntoStepCountNorth[dunMan._currMap._partyDir];
mapX += gDirIntoStepCountEast[dunMan._currMap._partyDir];
mapY += gDirIntoStepCountNorth[dunMan._currMap._partyDir];
thing = dunMan.getSquareFirstThing(mapX, mapY);
AL_0_slotIndex_Red = kChampionSlotBackpackLine_1_1;
uint16 slotIndex_Green;
Expand Down
11 changes: 9 additions & 2 deletions engines/dm/champion.h
Expand Up @@ -35,6 +35,9 @@

namespace DM {

extern Box gBoxChampionIcons[4]; // @ G0054_ai_Graphic562_Box_ChampionIcons
extern Color gChampionColor[4]; // @ G0046_auc_Graphic562_ChampionColor

class Scent {
uint16 _scent;
public:
Expand Down Expand Up @@ -157,7 +160,7 @@ enum ChampionIndex {
kChampionSecond = 1,
kChampionThird = 2,
kChampionFourth = 3,
kChmpionCloseInventory = 4, // @ C04_CHAMPION_CLOSE_INVENTORY
kChampionCloseInventory = 4, // @ C04_CHAMPION_CLOSE_INVENTORY
kChampionSpecialInventory = 5 // @ C05_CHAMPION_SPECIAL_INVENTORY
};

Expand Down Expand Up @@ -366,7 +369,7 @@ class Champion {
void setSkillExp(ChampionSkill skill, int32 val) { _skills[skill]._experience = val; }
void setSkillTempExp(ChampionSkill skill, int16 val) { _skills[skill]._temporaryExperience= val; }

byte getStatistic(ChampionStatisticType type, ChampionStatisticValue valType) { return _statistics[type][valType]; }
byte& getStatistic(ChampionStatisticType type, ChampionStatisticValue valType) { return _statistics[type][valType]; }
void setStatistic(ChampionStatisticType type, ChampionStatisticValue valType, byte newVal) { _statistics[type][valType] = newVal; }

uint16 getAttributes() { return _attributes; }
Expand Down Expand Up @@ -409,6 +412,10 @@ class Champion {
_actionDefense = _food = _water = _load = _shieldDefense = 0;
memset(_portrait, 0, 464);
}
void resetSkillsToZero() {
for (int16 i = 0; i < 20; ++i)
_skills[i].resetToZero();
}
}; // @ CHAMPION_INCLUDING_PORTRAIT

class ChampionMan {
Expand Down
4 changes: 2 additions & 2 deletions engines/dm/dm.cpp
Expand Up @@ -52,8 +52,8 @@

namespace DM {

int8 _dirIntoStepCountEast[4] = {0 /* North */, 1 /* East */, 0 /* West */, -1 /* South */}; // @ G0233_ai_Graphic559_DirectionToStepEastCount
int8 _dirIntoStepCountNorth[4] = {-1 /* North */, 0 /* East */, 1 /* West */, 0 /* South */}; // @ G0234_ai_Graphic559_DirectionToStepNorthCount
int8 gDirIntoStepCountEast[4] = {0 /* North */, 1 /* East */, 0 /* West */, -1 /* South */}; // @ G0233_ai_Graphic559_DirectionToStepEastCount
int8 gDirIntoStepCountNorth[4] = {-1 /* North */, 0 /* East */, 1 /* West */, 0 /* South */}; // @ G0234_ai_Graphic559_DirectionToStepNorthCount

void turnDirRight(direction &dir) { dir = (direction)((dir + 1) & 3); }
void turnDirLeft(direction &dir) { dir = (direction)((dir - 1) & 3); }
Expand Down
4 changes: 2 additions & 2 deletions engines/dm/dm.h
Expand Up @@ -56,8 +56,8 @@ enum direction {
};

// TODO: refactor direction into a class
extern int8 _dirIntoStepCountEast[4];
extern int8 _dirIntoStepCountNorth[4];
extern int8 gDirIntoStepCountEast[4];
extern int8 gDirIntoStepCountNorth[4];

void turnDirRight(direction &dir);
void turnDirLeft(direction &dir);
Expand Down
8 changes: 4 additions & 4 deletions engines/dm/dungeonman.cpp
Expand Up @@ -360,11 +360,11 @@ CreatureInfo gCreatureInfo[kCreatureTypeCount] = { // @ G0243_as_Graphic559_Crea
{26, 0, 0x38AA, 0x0000, 12, 22, 255, 180, 210, 0, 130, 0x6369, 0xFF37, 0x0FBF, 0x0564, 0xFB52, 5}};

void DungeonMan::mapCoordsAfterRelMovement(direction dir, int16 stepsForward, int16 stepsRight, int16 &posX, int16 &posY) {
posX += _dirIntoStepCountEast[dir] * stepsForward;
posY += _dirIntoStepCountNorth[dir] * stepsForward;
posX += gDirIntoStepCountEast[dir] * stepsForward;
posY += gDirIntoStepCountNorth[dir] * stepsForward;
turnDirRight(dir);
posX += _dirIntoStepCountEast[dir] * stepsRight;
posY += _dirIntoStepCountNorth[dir] * stepsRight;
posX += gDirIntoStepCountEast[dir] * stepsRight;
posY += gDirIntoStepCountNorth[dir] * stepsRight;
}

DungeonMan::DungeonMan(DMEngine *dmEngine) : _vm(dmEngine), _rawDunFileData(NULL), _maps(NULL), _rawMapData(NULL) {
Expand Down
90 changes: 85 additions & 5 deletions engines/dm/eventman.cpp
Expand Up @@ -32,6 +32,7 @@
#include "dungeonman.h"
#include "movesens.h"
#include "objectman.h"
#include "inventory.h"



Expand Down Expand Up @@ -517,8 +518,8 @@ void EventManager::commandProcessType80ClickInDungeonViewTouchFrontWall() {
CurrMapData &currMap = dunMan._currMap;
uint16 mapX = currMap._partyPosX;
uint16 mapY = currMap._partyPosY;
mapX += _dirIntoStepCountEast[currMap._partyDir];
mapY += _dirIntoStepCountNorth[currMap._partyDir];
mapX += gDirIntoStepCountEast[currMap._partyDir];
mapY += gDirIntoStepCountNorth[currMap._partyDir];
if ((mapX >= 0)
&& (mapX < currMap._width)
&& (mapY >= 0)
Expand All @@ -542,8 +543,8 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY
}
mapX = currMap._partyPosX;
mapY = currMap._partyPosY;
mapX += _dirIntoStepCountEast[currMap._partyDir];
mapY += _dirIntoStepCountNorth[currMap._partyDir];
mapX += gDirIntoStepCountEast[currMap._partyDir];
mapY += gDirIntoStepCountNorth[currMap._partyDir];

if (champMan._leaderEmptyHanded) {
if (Door(dunMan.getSquareFirstThingData(mapX, mapY)).hasButton() &&
Expand All @@ -564,7 +565,7 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY
if (viewCell == kViewCellDoorButtonOrWallOrn) {
if (!dunMan._isFacingAlcove) {
commandProcessType80ClickInDungeonViewTouchFrontWall();
}
}
} else {
warning("MISSING CODE: F0373_COMMAND_ProcessType80_ClickInDungeonView_GrabLeaderHandObject");
}
Expand Down Expand Up @@ -616,4 +617,83 @@ void EventManager::commandProcessType80ClickInDungeonView(int16 posX, int16 posY
}
}

void EventManager::commandProcessCommands160To162ClickInResurrectReincarnatePanel(CommandType commandType) {
ChampionMan &champMan = *_vm->_championMan;
InventoryMan &invMan = *_vm->_inventoryMan;
DisplayMan &dispMan = *_vm->_displayMan;
CurrMapData &currMap = _vm->_dungeonMan->_currMap;
DungeonMan &dunMan = *_vm->_dungeonMan;

uint16 championIndex = champMan._partyChampionCount - 1;
Champion *champ = &champMan._champions[championIndex];
if (commandType == kCommandClickInPanelCancel) {
invMan.toggleInventory(kChampionCloseInventory);
champMan._candidateChampionOrdinal = _vm->indexToOrdinal(kChampionNone);
if (champMan._partyChampionCount == 1) {
commandSetLeader(kChampionNone);
}
champMan._partyChampionCount--;
Box box;
box._y1 = 0;
box._y2 = 28 + 1;
box._x1 = championIndex * kChampionStatusBoxSpacing;
box._x2 = box._x1 + 66 + 1;
dispMan._useByteBoxCoordinates = false;
dispMan.clearScreenBox(kColorBlack, box);
dispMan.clearScreenBox(kColorBlack, gBoxChampionIcons[champMan.championIconIndex(champ->_cell, currMap._partyDir) * 2]);
warning("F0457_START_DrawEnabledMenus_CPSF");
warning("F0078_MOUSE_ShowPointer");
return;
}

champMan._candidateChampionOrdinal = _vm->indexToOrdinal(kChampionNone);
int16 mapX = currMap._partyPosX;
int16 mapY = currMap._partyPosY;

mapX += gDirIntoStepCountEast[currMap._partyDir];
mapY += gDirIntoStepCountNorth[currMap._partyDir];
for (uint16 slotIndex = kChampionSlotReadyHand; slotIndex < kChampionSlotChest_1; slotIndex++) {
Thing thing = champ->getSlot((ChampionSlot)slotIndex);
if (thing != Thing::_thingNone) {
warning("MISSING CODE: F0164_DUNGEON_UnlinkThingFromList");
}
}
Thing thing = dunMan.getSquareFirstThing(mapX, mapY);
for (;;) { // infinite
if (thing.getType() == kSensorThingType) {
((Sensor*)dunMan.getThingData(thing))->setTypeDisabled();
break;
}
thing = dunMan.getNextThing(thing);
}

if (commandType == kCommandClickInPanelReincarnate) {
warning("MISSING CODE: F0281_CHAMPION_Rename");
champ->resetSkillsToZero();

for (uint16 i = 0; i < 12; i++) {
uint16 statIndex = _vm->_rnd->getRandomNumber(7);
champ->getStatistic((ChampionStatisticType)statIndex, kChampionStatCurrent)++; // returns reference
champ->getStatistic((ChampionStatisticType)statIndex, kChampionStatMaximum)++; // returns reference
}
}

if (champMan._partyChampionCount == 1) {
warning("MISSING CODE: setting time, G0362_l_LastPartyMovementTime , G0313_ul_GameTime");
commandSetLeader(kChampionFirst);
warning("MISSING CODE: F0394_MENUS_SetMagicCasterAndDrawSpellArea");
} else {
warning("MISSING CODE: F0393_MENUS_DrawSpellAreaControls");
}

warning("MISSING CODE: F0051_TEXT_MESSAGEAREA_PrintLineFeed");
Color champColor = gChampionColor[championIndex]; // unreferenced because of missing code
warning("MISSING CODE: F0047_TEXT_MESSAGEAREA_PrintMessage");
warning("MISSING CODE: F0047_TEXT_MESSAGEAREA_PrintMessage");

invMan.toggleInventory(kChampionCloseInventory);
warning("MISSING CODE: F0457_START_DrawEnabledMenus_CPSF");
warning("MISSING CODE: F0067_MOUSE_SetPointerToNormal");
}

}; // end of namespace DM
2 changes: 2 additions & 0 deletions engines/dm/eventman.h
Expand Up @@ -31,6 +31,7 @@
#include "common/events.h"
#include "common/queue.h"

#include "dm.h"
#include "gfx.h"
#include "champion.h"

Expand Down Expand Up @@ -248,6 +249,7 @@ class EventManager {
void commandSetLeader(ChampionIndex index); // @ F0368_COMMAND_SetLeader
void commandProcessType80ClickInDungeonViewTouchFrontWall(); // @ F0372_COMMAND_ProcessType80_ClickInDungeonView_TouchFrontWall
void commandProcessType80ClickInDungeonView(int16 posX, int16 posY); // @ F0377_COMMAND_ProcessType80_ClickInDungeonView
void commandProcessCommands160To162ClickInResurrectReincarnatePanel(CommandType commandType); // @ F0282_CHAMPION_ProcessCommands160To162_ClickInResurrectReincarnatePanel
};

}
Expand Down
6 changes: 3 additions & 3 deletions engines/dm/inventory.cpp
Expand Up @@ -53,14 +53,14 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
EventManager &em = *_vm->_eventMan;
DisplayMan &dm = *_vm->_displayMan;

if ((championIndex == kChmpionCloseInventory) && !cm._champions[championIndex]._currHealth)
if ((championIndex == kChampionCloseInventory) && !cm._champions[championIndex]._currHealth)
return;
if (_vm->_pressingEye || _vm->_pressingMouth)
return;
_vm->_stopWaitingForPlayerInput = true;
int16 invChampOrdinal = _inventoryChampionOrdinal; // copy, as the original will be edited
if (_vm->indexToOrdinal(championIndex) == invChampOrdinal) {
championIndex = kChmpionCloseInventory;
championIndex = kChampionCloseInventory;
}

Champion *champion;
Expand All @@ -75,7 +75,7 @@ void InventoryMan::toggleInventory(ChampionIndex championIndex) {
if (cm._partyIsSleeping) {
return;
}
if (championIndex == kChmpionCloseInventory) {
if (championIndex == kChampionCloseInventory) {
em._refreshMousePointerInMainLoop = true;
_vm->_menuMan->drawMovementArrows();
em._secondaryMouseInput = gSecondaryMouseInput_Movement;
Expand Down

0 comments on commit eddf2f4

Please sign in to comment.