Improved offraidHeal to not show unnecessary warnings

This commit is contained in:
Dev 2024-10-24 14:28:48 +01:00
parent c6b78dba1d
commit e7ebdab3f0

View File

@ -81,7 +81,7 @@ export class HealthController {
const healItemEffectDetails = healingItemDbDetails[1]._props.effects_damage; const healItemEffectDetails = healingItemDbDetails[1]._props.effects_damage;
const bodyPartToHeal: IBodyPartHealth = pmcData.Health.BodyParts[request.part]; const bodyPartToHeal: IBodyPartHealth = pmcData.Health.BodyParts[request.part];
if (!bodyPartToHeal) { if (!bodyPartToHeal) {
this.logger.warning(`Tried to heal a non-existent body part: ${request.part}`); this.logger.warning(`Player: ${sessionID} Tried to heal a non-existent body part: ${request.part}`);
return output; return output;
} }
@ -91,16 +91,11 @@ export class HealthController {
// Check if healing item removes negative effects // Check if healing item removes negative effects
const itemRemovesEffects = Object.keys(healingItemDbDetails[1]._props.effects_damage).length > 0; const itemRemovesEffects = Object.keys(healingItemDbDetails[1]._props.effects_damage).length > 0;
if (itemRemovesEffects) { if (itemRemovesEffects && bodyPartToHeal.Effects) {
// Check body parts effects against what the healing item can remove // Can remove effects and limb has effects to remove
if (!bodyPartToHeal.Effects) {
this.logger.warning(`Tried to remove effects from body part: ${request.part} without effects`);
return output;
}
const effectsOnBodyPart = Object.keys(bodyPartToHeal.Effects); const effectsOnBodyPart = Object.keys(bodyPartToHeal.Effects);
for (const effectKey of effectsOnBodyPart) { for (const effectKey of effectsOnBodyPart) {
// Check if healing item removes the effect on limb
const matchingEffectFromHealingItem = healItemEffectDetails[effectKey]; const matchingEffectFromHealingItem = healItemEffectDetails[effectKey];
if (!matchingEffectFromHealingItem) { if (!matchingEffectFromHealingItem) {
// Healing item doesnt have matching effect, it doesnt remove the effect // Healing item doesnt have matching effect, it doesnt remove the effect