fix character death recording logic

This commit is contained in:
fusion32 2025-09-06 00:12:47 -03:00
parent 8d565e9116
commit 4c4e538136
3 changed files with 17 additions and 20 deletions

View File

@ -862,6 +862,7 @@ struct TPlayer: TCreature {
bool IsAttackJustified(uint32 VictimID);
void RecordAttack(uint32 VictimID);
void RecordMurder(uint32 VictimID);
void RecordDeath(uint32 AttackerID, int OldLevel, const char *Remark);
int CheckPlayerkilling(int Now);
void ClearAttacker(uint32 VictimID);
void ClearPlayerkillingMarks(void);

View File

@ -817,34 +817,16 @@ int TCreature::Damage(TCreature *Attacker, int Damage, int DamageType){
}
if(this->Type == PLAYER){
if(MurdererID != 0 && MurdererID != this->ID){
bool Justified = true;
if(IsCreaturePlayer(MurdererID)){
TPlayer *Murderer = GetPlayer(MurdererID);
if(Murderer != NULL){
Justified = Murderer->IsAttackJustified(this->ID);
Murderer->RecordMurder(this->ID);
}
}
CharacterDeathOrder(this, OldLevel, MurdererID, Remark, !Justified);
}
((TPlayer*)this)->RecordDeath(MurdererID, OldLevel, Remark);
uint32 MostDangerousID = this->Combat.GetMostDangerousAttacker();
if(MostDangerousID != 0
&& MostDangerousID != MurdererID
&& MostDangerousID != this->ID
&& IsCreaturePlayer(MostDangerousID)){
bool Justified = true;
TPlayer *MostDangerous = GetPlayer(MostDangerousID);
if(MostDangerous != NULL){
Justified = MostDangerous->IsAttackJustified(this->ID);
MostDangerous->RecordMurder(this->ID);
}
// TODO(fusion): The original function is confusing at this point
// but it seems correct that the remark is included only with the
// murderer.
CharacterDeathOrder(this, OldLevel, MostDangerousID, "", !Justified);
((TPlayer*)this)->RecordDeath(MostDangerousID, OldLevel, "");
}
}
}

View File

@ -1534,6 +1534,20 @@ void TPlayer::RecordMurder(uint32 VictimID){
}
}
void TPlayer::RecordDeath(uint32 AttackerID, int OldLevel, const char *Remark){
bool Justified = true;
if(AttackerID != 0 && AttackerID != this->ID && IsCreaturePlayer(AttackerID)){
TPlayer *Attacker = GetPlayer(AttackerID);
if(Attacker == NULL){
return;
}
Justified = Attacker->IsAttackJustified(this->ID);
Attacker->RecordMurder(this->ID);
}
CharacterDeathOrder(this, OldLevel, AttackerID, Remark, !Justified);
}
int TPlayer::CheckPlayerkilling(int Now){
int LastDay = 0;
int LastWeek = 0;