использую этот код
в последней строчке вывожу данные,и они все верные.Но при тесте в игре ревик дает по 45 дамага,а умираю я за 2 выстрела,что делать?const {
ignoreWeapons,
damageWeapons,
damageWeaponGroups
} = require('./src/weapons/damageHandler/settings.js');
// The value from this range will determine what percentage of the original damage will be cut
const defaultPercent = {
max: 13,
min: 8
}
const randomInt = (min, max) => Math.random() * (max - min) + min;
mp.events.add("incomingDamage", (sourceEntity, sourcePlayer, targetEntity, weapon, boneIndex, damage) => {
if (targetEntity.type === "player" && sourcePlayer && !(weapon in ignoreWeapons)) {
if (global.adminGodMode) {
return true;
}
let max = defaultPercent.max;
let min = defaultPercent.max;
let damage = 0;
const weaponGroupHash = mp.game.weapon.getWeapontypeGroup(weapon);
if (weapon in damageWeapons) {
damageC = damageWeapons[weapon].damage;
} else if (weaponGroupHash in damageWeaponGroups) {
max = damageWeaponGroups[weaponGroupHash].max;
min = damageWeaponGroups[weaponGroupHash].min;
}
const percent = randomInt(min, max) / 100;
let customDamage = damage - (damage * percent);
// Check for a hit in the head. A hit to the head carries with it much more damage than on other points of the body.
if (boneIndex === 20) {
customDamage /= 10;
}
const currentHealthdo = targetEntity.getHealth();
targetEntity.applyDamageTo(damageC, false);
const currentHealth = targetEntity.getHealth();
// This check is necessary in order for the "PlayerDeath" event to be triggered if the player died after taking damage
if (currentHealth > 0) {
// Setting the initial damage received in the event to 0
mp.game.weapon.setCurrentDamageEventAmount(0);
}
mp.game.graphics.notify(Percent ${percent} customDamage ${customDamage} currentHealth ${currentHealth} Health ${targetEntity.getHealth()} Healthdo ${currentHealthdo} Damage ${damage} Weapon${weapon}
);
}
})