Browse Source

Enable opening Hive and Crypt using gamepad

pull/3105/head
staphen 4 years ago committed by Anders Jenbo
parent
commit
ee23f41e0c
  1. 23
      Source/controls/plrctrls.cpp
  2. 29
      Source/inv.cpp
  3. 14
      Source/town.cpp
  4. 14
      Source/town.h

23
Source/controls/plrctrls.cpp

@ -18,6 +18,7 @@
#include "minitext.h"
#include "missiles.h"
#include "stores.h"
#include "town.h"
#include "towners.h"
#include "trigs.h"
@ -1398,6 +1399,28 @@ bool TryDropItem()
return false;
}
if (myPlayer.HoldItem.IDidx == IDI_RUNEBOMB) {
for (auto dir : PathDirs) {
Point position = myPlayer.position.tile + dir;
if (OpensHive(position)) {
NetSendCmdPItem(true, CMD_PUTITEM, { 79, 61 });
NewCursor(CURSOR_HAND);
return true;
}
}
}
if (myPlayer.HoldItem.IDidx == IDI_MAPOFDOOM) {
for (auto dir : PathDirs) {
Point position = myPlayer.position.tile + dir;
if (OpensGrave(position)) {
NetSendCmdPItem(true, CMD_PUTITEM, { 35, 20 });
NewCursor(CURSOR_HAND);
return true;
}
}
}
cursPosition = myPlayer.position.future + Direction::SouthEast;
if (!DropItemBeforeTrig()) {
// Try to drop on the other side

29
Source/inv.cpp

@ -20,6 +20,7 @@
#include "options.h"
#include "plrmsg.h"
#include "stores.h"
#include "town.h"
#include "towners.h"
#include "controls/plrctrls.h"
#include "utils/language.h"
@ -1722,33 +1723,28 @@ bool TryInvPut()
int InvPutItem(Player &player, Point position)
{
if (!PutItem(player, position))
return -1;
if (currlevel == 0) {
int yp = cursPosition.y;
int xp = cursPosition.x;
if (player.HoldItem._iCurs == ICURS_RUNE_BOMB && xp >= 79 && xp <= 82 && yp >= 61 && yp <= 64) {
if (player.plrlevel == 0) {
if (player.HoldItem.IDidx == IDI_RUNEBOMB && OpensHive(position)) {
NetSendCmd(false, CMD_OPENHIVE);
auto &quest = Quests[Q_FARMER];
quest._qactive = QUEST_DONE;
if (gbIsMultiplayer) {
if (gbIsMultiplayer)
NetSendCmdQuest(true, quest);
return -1;
}
return -1;
}
if (player.HoldItem.IDidx == IDI_MAPOFDOOM && xp >= 35 && xp <= 38 && yp >= 20 && yp <= 24) {
if (player.HoldItem.IDidx == IDI_MAPOFDOOM && OpensGrave(position)) {
NetSendCmd(false, CMD_OPENCRYPT);
auto &quest = Quests[Q_GRAVE];
quest._qactive = QUEST_DONE;
if (gbIsMultiplayer) {
if (gbIsMultiplayer)
NetSendCmdQuest(true, quest);
}
return -1;
}
}
if (!PutItem(player, position))
return -1;
assert(CanPut(position));
int ii = AllocateItem();
@ -1771,6 +1767,13 @@ int InvPutItem(Player &player, Point position)
int SyncPutItem(Player &player, Point position, int idx, uint16_t icreateinfo, int iseed, int id, int dur, int mdur, int ch, int mch, int ivalue, uint32_t ibuff, int toHit, int maxDam, int minStr, int minMag, int minDex, int ac)
{
if (player.plrlevel == 0) {
if (idx == IDI_RUNEBOMB && OpensHive(position))
return -1;
if (idx == IDI_MAPOFDOOM && OpensGrave(position))
return -1;
}
if (!PutItem(player, position))
return -1;

14
Source/town.cpp

@ -200,6 +200,20 @@ void DrlgTPass3()
} // namespace
bool OpensHive(Point position)
{
int yp = position.y;
int xp = position.x;
return xp >= 79 && xp <= 82 && yp >= 61 && yp <= 64;
}
bool OpensGrave(Point position)
{
int yp = position.y;
int xp = position.x;
return xp >= 35 && xp <= 38 && yp >= 20 && yp <= 24;
}
void TownOpenHive()
{
dPiece[78][60] = 0x48a;

14
Source/town.h

@ -10,6 +10,20 @@
namespace devilution {
/**
* @brief Check if hive can be opened by dropping rune bomb on a tile
* @param position The position of the tile
* @return True if the bomb would open hive
*/
bool OpensHive(Point position);
/**
* @brief Check if grave can be opened by dropping cathedral map on a tile
* @param position The position of the tile
* @return True if the map would open the grave
*/
bool OpensGrave(Point position);
/**
* @brief Update the map to show the open hive
*/

Loading…
Cancel
Save