Skip to content

Commit

Permalink
Network
Browse files Browse the repository at this point in the history
  • Loading branch information
kphoenix137 committed Sep 17, 2024
1 parent 4137fe9 commit 3c478f9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Source/inv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2203,7 +2203,7 @@ void DoTelekinesis()
if (pcursmonst != -1) {
auto &monter = Monsters[pcursmonst];
if (!M_Talker(monter) && monter.talkMsg == TEXT_NONE)
NetSendCmdParam1(true, CMD_KNOCKBACK, pcursmonst);
NetSendCmdParam5(true, CMD_KNOCKBACK, pcursmonst, MyPlayer->position.tile.x, MyPlayer->position.tile.y, 0, 0);
}
NewCursor(CURSOR_HAND);
}
Expand Down
4 changes: 2 additions & 2 deletions Source/missiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ bool MonsterMHit(const Player &player, int monsterId, int mindam, int maxdam, in
monster.tag(player);
PlayEffect(monster, MonsterSound::Hit);
} else {
if (monster.mode != MonsterMode::Petrified && missileData.isArrow() && HasAnyOf(player._pIFlags, ItemSpecialEffect::Knockback))
M_GetKnockback(monster, startPos);
if (monster.mode != MonsterMode::Petrified && missileData.isArrow() && HasAnyOf(player._pIFlags, ItemSpecialEffect::Knockback) && &player == MyPlayer)
NetSendCmdParam5(true, CMD_KNOCKBACK, monster.getId(), startPos.x, startPos.y, 0, 0);
if (monster.type().type != MT_GOLEM)
M_StartHit(monster, player, dam);
}
Expand Down
7 changes: 5 additions & 2 deletions Source/msg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1651,12 +1651,15 @@ size_t OnSpellPlayer(const TCmd *pCmd, Player &player)

size_t OnKnockback(const TCmd *pCmd, Player &player)
{
const auto &message = *reinterpret_cast<const TCmdParam1 *>(pCmd);
const auto &message = *reinterpret_cast<const TCmdParam5 *>(pCmd);
const uint16_t monsterIdx = SDL_SwapLE16(message.wParam1);
WorldTilePosition startPos;
startPos.x = SDL_SwapLE16(message.wParam2);
startPos.y = SDL_SwapLE16(message.wParam3);

if (gbBufferMsgs != 1 && player.isOnActiveLevel() && monsterIdx < MaxMonsters) {
Monster &monster = Monsters[monsterIdx];
M_GetKnockback(monster, player.position.tile);
M_GetKnockback(monster, startPos);
M_StartHit(monster, player, 0);
}

Expand Down
4 changes: 2 additions & 2 deletions Source/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,8 +690,8 @@ bool PlrHitMonst(Player &player, Monster &monster, bool adjacentDamage = false)
if ((monster.hitPoints >> 6) <= 0) {
M_StartKill(monster, player);
} else {
if (monster.mode != MonsterMode::Petrified && HasAnyOf(player._pIFlags, ItemSpecialEffect::Knockback))
M_GetKnockback(monster, player.position.tile);
if (monster.mode != MonsterMode::Petrified && HasAnyOf(player._pIFlags, ItemSpecialEffect::Knockback) && &player == MyPlayer)
NetSendCmdParam5(true, CMD_KNOCKBACK, monster.getId(), player.position.tile.x, player.position.tile.y, 0, 0);
M_StartHit(monster, player, dam);
}
return true;
Expand Down

0 comments on commit 3c478f9

Please sign in to comment.