Skip to content

Commit

Permalink
Merge pull request #11 from jprzimba/fix-chain-targets
Browse files Browse the repository at this point in the history
Fix chain targets
  • Loading branch information
jprzimba authored Dec 30, 2024
2 parents 2e3c23a + 9c0d6c0 commit 402338b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
2 changes: 2 additions & 0 deletions markdowns/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
### Bug Fixes

- Fixed influenced creatures not spawning. ([Tryller](https://github.com/jprzimba))
- Fixed sending damage higher then monster health. ([Tryller](https://github.com/jprzimba))
- Fixed chain targets. ([Mortera-world](https://github.com/Mortera-world))
- Fixed houses with pool bug. ([Tryller](https://github.com/jprzimba))
- Fixed some V.I.P list issues. ([Tryller](https://github.com/jprzimba))
- Fixed gotoHouse talkaction. ([Tryller](https://github.com/jprzimba))
Expand Down
46 changes: 46 additions & 0 deletions src/creatures/combat/combat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1516,6 +1516,52 @@ std::vector<std::pair<Position, std::vector<uint32_t>>> Combat::pickChainTargets
if (!spectator || visited.contains(spectator->getID())) {
continue;
}

if (spectator->getZoneType() == ZONE_PROTECTION) {
visited.insert(spectator->getID());
continue;
}

if (spectator->getNpc()) {
visited.insert(spectator->getID());
continue;
}

if (spectator == caster) {
visited.insert(spectator->getID());
continue;
}

const auto &casterPlayer = caster->getPlayer();
const auto &casterMonster = caster->getMonster();
const auto &spectatorPlayer = spectator->getPlayer();
const auto &spectatorSummon = spectator->isSummon();

if (casterPlayer) {
if (casterPlayer->hasSecureMode()) {
if (spectatorPlayer) {
visited.insert(spectator->getID());
continue;
}

if (spectatorSummon && spectator->getMaster() && spectator->getMaster()->getPlayer()) {
visited.insert(spectator->getID());
continue;
}
}
} else if (casterMonster) {
if (spectatorSummon) {
const auto &master = spectator->getMaster();
if (!master || !master->getPlayer()) {
visited.insert(spectator->getID());
continue;
}
} else if (!spectator->getPlayer()) {
visited.insert(spectator->getID());
continue;
}
}

if (!isValidChainTarget(caster, currentTarget, spectator, params, aggressive)) {
visited.insert(spectator->getID());
continue;
Expand Down

0 comments on commit 402338b

Please sign in to comment.