Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Knockback #7093

Merged
merged 7 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Source/missiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ int ProjectileTrapDamage()
return currlevel + GenerateRnd(2 * currlevel);
}

bool MonsterMHit(const Player &player, int monsterId, int mindam, int maxdam, int dist, MissileID t, DamageType damageType, bool shift)
bool MonsterMHit(const Player &player, int monsterId, int mindam, int maxdam, int dist, MissileID t, WorldTilePosition startPos, DamageType damageType, bool shift)
{
Monster &monster = Monsters[monsterId];

Expand Down Expand Up @@ -268,7 +268,7 @@ bool MonsterMHit(const Player &player, int monsterId, int mindam, int maxdam, in
PlayEffect(monster, MonsterSound::Hit);
} else {
if (monster.mode != MonsterMode::Petrified && missileData.isArrow() && HasAnyOf(player._pIFlags, ItemSpecialEffect::Knockback))
M_GetKnockback(monster);
M_GetKnockback(monster, startPos);
if (monster.type().type != MT_GOLEM)
M_StartHit(monster, player, dam);
}
Expand Down Expand Up @@ -422,7 +422,7 @@ void CheckMissileCol(Missile &missile, DamageType damageType, int minDamage, int
// then the missile can potentially hit this target
isMonsterHit = MonsterTrapHit(mid, minDamage, maxDamage, missile._midist, missile._mitype, damageType, isDamageShifted);
} else if (IsAnyOf(missile._micaster, TARGET_BOTH, TARGET_MONSTERS)) {
isMonsterHit = MonsterMHit(*missile.sourcePlayer(), mid, minDamage, maxDamage, missile._midist, missile._mitype, damageType, isDamageShifted);
isMonsterHit = MonsterMHit(*missile.sourcePlayer(), mid, minDamage, maxDamage, missile._midist, missile._mitype, missile.position.start, damageType, isDamageShifted);
}
}

Expand Down
8 changes: 4 additions & 4 deletions Source/monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3733,9 +3733,9 @@ void M_ClearSquares(const Monster &monster)
}
}

void M_GetKnockback(Monster &monster)
void M_GetKnockback(Monster &monster, WorldTilePosition attackerStartPos)
{
Direction dir = Opposite(monster.direction);
Direction dir = GetDirection(attackerStartPos, monster.position.tile);
if (!IsRelativeMoveOK(monster, monster.position.old, dir)) {
return;
}
Expand Down Expand Up @@ -4448,7 +4448,7 @@ void MissToMonst(Missile &missile, Point position)

if (player->_pmode != PM_GOTHIT && player->_pmode != PM_DEATH)
StartPlrHit(*player, 0, true);
Point newPosition = oldPosition + monster.direction;
Point newPosition = oldPosition + GetDirection(missile.position.start, oldPosition);
if (PosOkPlayer(*player, newPosition)) {
player->position.tile = newPosition;
FixPlayerLocation(*player, player->_pdir);
Expand All @@ -4469,7 +4469,7 @@ void MissToMonst(Missile &missile, Point position)
if (IsAnyOf(monster.type().type, MT_NSNAKE, MT_RSNAKE, MT_BSNAKE, MT_GSNAKE))
return;

Point newPosition = oldPosition + monster.direction;
Point newPosition = oldPosition + GetDirection(missile.position.start, oldPosition);
if (IsTileAvailable(*target, newPosition)) {
monster.occupyTile(newPosition, false);
dMonster[oldPosition.x][oldPosition.y] = 0;
Expand Down
2 changes: 1 addition & 1 deletion Source/monster.h
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ void ApplyMonsterDamage(DamageType damageType, Monster &monster, int damage);
bool M_Talker(const Monster &monster);
void M_StartStand(Monster &monster, Direction md);
void M_ClearSquares(const Monster &monster);
void M_GetKnockback(Monster &monster);
void M_GetKnockback(Monster &monster, WorldTilePosition attackerStartPos);
void M_StartHit(Monster &monster, int dam);
void M_StartHit(Monster &monster, const Player &player, int dam);
void StartMonsterDeath(Monster &monster, const Player &player, bool sendmsg);
Expand Down
2 changes: 1 addition & 1 deletion Source/msg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1659,7 +1659,7 @@ size_t OnKnockback(const TCmd *pCmd, Player &player)

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

Expand Down
2 changes: 1 addition & 1 deletion Source/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ bool PlrHitMonst(Player &player, Monster &monster, bool adjacentDamage = false)
M_StartKill(monster, player);
} else {
if (monster.mode != MonsterMode::Petrified && HasAnyOf(player._pIFlags, ItemSpecialEffect::Knockback))
M_GetKnockback(monster);
M_GetKnockback(monster, player.position.tile);
M_StartHit(monster, player, dam);
}
return true;
Expand Down
Loading