Open krafttomten opened 2 years ago
As per lastHitUnjustified
, this looks like an easy pick.
If you see here: https://github.com/otland/forgottenserver/blob/eb5f5d68a85eb5f8e5ade23153d699e93d4287a3/src/creature.cpp#L657
this is always false
for non-players (monsters, including summons etc).
What you could try, is changing this method: https://github.com/otland/forgottenserver/blob/eb5f5d68a85eb5f8e5ade23153d699e93d4287a3/src/creature.cpp#L1130-L1142
into:
bool Creature::onKilledCreature(Creature* target, bool)
{
+ bool unjustified = false;
if (master) {
- master->onKilledCreature(target);
+ unjustified = master->onKilledCreature(target);
}
// scripting event - onKill
const CreatureEventList& killEvents = getCreatureEvents(CREATURE_EVENT_KILL);
for (CreatureEvent* killEvent : killEvents) {
killEvent->executeOnKill(this, target);
}
- return false;
+ return unjustified;
}
### Steps to reproduce The core of the problem is that the killer does not get unjustified kills where he should and that the mostDamageUnjustified never has any other value than false, which makes it useless. There are several ways of showing the different nuances of the problem:
Setup:
Procedure 1
Procedure 2
Procedure 3
### Behaviour Procedure 1: ### Expected behaviour
The terminal should print true, true The killer should get an unjustified kill, which he does - as expected.
### Actual behaviour The terminal prints false, false The killer was a monster, but it had a master which commanded its behaviour, so for the SQL entry to make sense, it should be registred as an unjustified kill because the last hit was caused by a player. Most damage was dealt by a player, so this should also register as unjustified. The killer gets an unjustified kill, as expected.
Procedure 2: ### Expected behaviour The terminal should print true true Both killers should get an unjustified kill
### Actual behaviour The terminal prints true false Only the lasthit killer gets an unjustified kill
Procedure 3: ### Expected behaviour The terminal should print false true The mostDamageKiller should get an unjustified kill
### Actual behaviour The terminal prints false false The killer does not get an unjustified kill
Environment
TFS 1.4, Windows, but it should not be environment specific
Reproduction environment
Not necessary, the only change that is recommended is a print, to visualize the problem.