Browse Source

Combine Telekinesis with other object network commands

pull/5064/head
ephphatha 4 years ago committed by Anders Jenbo
parent
commit
0c08980c71
  1. 2
      Source/inv.cpp
  2. 19
      Source/msg.cpp
  3. 5
      Source/msg.h

2
Source/inv.cpp

@ -2084,7 +2084,7 @@ void CloseInventory()
void DoTelekinesis()
{
if (pcursobj != -1)
NetSendCmdParam1(true, CMD_OPOBJT, pcursobj);
NetSendCmdLoc(MyPlayerId, true, CMD_OPOBJT, cursPosition);
if (pcursitem != -1)
NetSendCmdGItem(true, CMD_REQUESTAGITEM, MyPlayerId, pcursitem);
if (pcursmonst != -1) {

19
Source/msg.cpp

@ -1215,14 +1215,15 @@ size_t OnTargetSpellTile(const TCmd *pCmd, Player &player)
return sizeof(message);
}
size_t OnObjectTileAction(const TCmd &cmd, Player &player, action_id action)
size_t OnObjectTileAction(const TCmd &cmd, Player &player, action_id action, bool pathToObject = true)
{
const auto &message = reinterpret_cast<const TCmdLoc &>(cmd);
const Point position { message.x, message.y };
const Object *object = ObjectAtPosition(position);
if (gbBufferMsgs != 1 && player.isOnActiveLevel() && object != nullptr) {
MakePlrPath(player, position, !object->_oSolidFlag && !object->_oDoorFlag);
if (pathToObject)
MakePlrPath(player, position, !object->_oSolidFlag && !object->_oDoorFlag);
player.destAction = action;
player.destParam1 = object->GetId();
@ -1231,18 +1232,6 @@ size_t OnObjectTileAction(const TCmd &cmd, Player &player, action_id action)
return sizeof(message);
}
size_t OnOperateObjectTelekinesis(const TCmd *pCmd, Player &player)
{
const auto &message = *reinterpret_cast<const TCmdParam1 *>(pCmd);
if (gbBufferMsgs != 1 && player.isOnActiveLevel() && message.wParam1 < MAXOBJECTS) {
player.destAction = ACTION_OPERATETK;
player.destParam1 = message.wParam1;
}
return sizeof(message);
}
size_t OnAttackMonster(const TCmd *pCmd, Player &player)
{
const auto &message = *reinterpret_cast<const TCmdParam1 *>(pCmd);
@ -3005,7 +2994,7 @@ size_t ParseCmd(int pnum, const TCmd *pCmd)
case CMD_DISARMXY:
return OnObjectTileAction(*pCmd, player, ACTION_DISARM);
case CMD_OPOBJT:
return OnOperateObjectTelekinesis(pCmd, player);
return OnObjectTileAction(*pCmd, player, ACTION_OPERATETK, false);
case CMD_ATTACKID:
return OnAttackMonster(pCmd, player);
case CMD_ATTACKPID:

5
Source/msg.h

@ -164,8 +164,9 @@ enum _cmd_id : uint8_t {
CMD_RESURRECT,
// Operate object using telekinesis.
//
// body (TCmdParam1):
// int16_t object_num
// body (TCmdLoc):
// int8_t x
// int8_t y
CMD_OPOBJT,
// Knockback target monster using telekinesis.
//

Loading…
Cancel
Save