Skip to content

Commit

Permalink
Merge branch 'main' into set-new-release-version
Browse files Browse the repository at this point in the history
  • Loading branch information
dudantas authored Nov 8, 2023
2 parents 71f9a4b + 7bba687 commit 359f9c6
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/creatures/creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,14 @@ void Creature::onCreatureMove(const std::shared_ptr<Creature> &creature, const s
void Creature::onDeath() {
bool lastHitUnjustified = false;
bool mostDamageUnjustified = false;
std::shared_ptr<Creature> lastHitCreature = g_game().getCreatureByID(lastHitCreatureId);
std::shared_ptr<Creature> lastHitCreatureMaster;
if (lastHitCreature) {
lastHitUnjustified = lastHitCreature->onKilledCreature(static_self_cast<Creature>(), true);
lastHitCreatureMaster = lastHitCreature->getMaster();
} else {
lastHitCreatureMaster = nullptr;
}

std::shared_ptr<Creature> mostDamageCreature = nullptr;

Expand Down Expand Up @@ -671,15 +679,11 @@ void Creature::onDeath() {
it.first->onGainExperience(it.second, getCreature());
}

std::shared_ptr<Creature> mostDamageCreatureMaster = nullptr;
if (mostDamageCreature) {
mostDamageCreatureMaster = mostDamageCreature->getMaster();
mostDamageUnjustified = mostDamageCreature->onKilledCreature(getCreature(), false);
}

std::shared_ptr<Creature> lastHitCreature = g_game().getCreatureByID(lastHitCreatureId);
if (lastHitCreature && lastHitCreature != mostDamageCreature && lastHitCreature != mostDamageCreatureMaster) {
lastHitUnjustified = lastHitCreature->onKilledCreature(getCreature(), true);
if (mostDamageCreature && mostDamageCreature != lastHitCreature && mostDamageCreature != lastHitCreatureMaster) {
auto mostDamageCreatureMaster = mostDamageCreature->getMaster();
if (lastHitCreature != mostDamageCreatureMaster && (lastHitCreatureMaster == nullptr || mostDamageCreatureMaster != lastHitCreatureMaster)) {
mostDamageUnjustified = mostDamageCreature->onKilledCreature(static_self_cast<Creature>(), false);
}
}

bool droppedCorpse = dropCorpse(lastHitCreature, mostDamageCreature, lastHitUnjustified, mostDamageUnjustified);
Expand Down

0 comments on commit 359f9c6

Please sign in to comment.