Skip to content

Commit

Permalink
fix: 💙fix challenger armor trait error on getting damage
Browse files Browse the repository at this point in the history
  • Loading branch information
Krutoy242 committed Aug 15, 2024
1 parent 4cc6dab commit cde03d9
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions scripts/cot/trait/mods/scalinghealth.zs
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ b.localizedDescription = game.localize('e2ee.tconstruct.material.challenger.desc
b.maxLevel = 4;
b.getModifications = function(trait, player, mods, armor, damageSource, damage, index) {
if (damage <= 0.0) return mods;
val bonus = getArmorBonus(trait, armor, player);
val bonus = getAnyBonus(1, player);
mods.armorMod *= bonus;
mods.toughnessMod *= bonus;
return mods;
};
b.onDamaged = function (trait, armor, player, source, damage, newDamage, evt) {
if (player.world.remote || newDamage <= 0) return newDamage;
val bonus = getArmorBonus(trait, armor, player);
val bonus = getAnyBonus(1, player);
showFX(player, player.x, player.y, player.z, bonus);
return newDamage;
};
Expand All @@ -76,13 +76,6 @@ function getToolBonus(trait as Trait, tool as IItemStack, entity as IEntity) as
return getAnyBonus(data.level, entity);
}

function getArmorBonus(trait as ArmorTrait, tool as IItemStack, entity as IEntity) as double {
if (isNull(trait)) return 1.0;
val data = trait.getData(tool);
if (isNull(data)) return 1.0;
return getAnyBonus(data.level, entity);
}

function getAnyBonus(level as double, entity as IEntity) as double {
val areaDiff = entity.world.getAreaDifficultyAt(entity.position);
return getBonus(areaDiff, level);
Expand Down

0 comments on commit cde03d9

Please sign in to comment.