Expand ranged weapon scaling
This commit is contained in:
@@ -5,6 +5,9 @@ import net.fretux.ascend.config.AscendConfig;
|
||||
import net.fretux.ascend.player.PlayerStatsProvider;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.projectile.AbstractArrow;
|
||||
import net.minecraft.world.entity.projectile.FireworkRocketEntity;
|
||||
import net.minecraft.world.entity.projectile.ThrownTrident;
|
||||
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
@@ -32,6 +35,9 @@ public class WeaponMagicScalingEvents {
|
||||
double bonusMult = 1.0d + Math.min(magicScaling * perPoint * getScaling(), maxBonus);
|
||||
modified = (float) (modified * bonusMult);
|
||||
}
|
||||
} else if (isRangedDamage(event.getSource())) {
|
||||
double rangedMultiplier = getRangedScalingMultiplier(stats, event.getSource());
|
||||
modified = (float) (modified * rangedMultiplier);
|
||||
} else {
|
||||
double attackSpeed = 4.0d;
|
||||
if (player.getAttribute(Attributes.ATTACK_SPEED) != null) {
|
||||
@@ -69,4 +75,35 @@ public class WeaponMagicScalingEvents {
|
||||
|| id.equals("thrown")
|
||||
|| id.equals("potion");
|
||||
}
|
||||
|
||||
private static boolean isRangedDamage(DamageSource source) {
|
||||
return source.isProjectile()
|
||||
|| source.getDirectEntity() instanceof AbstractArrow
|
||||
|| source.getDirectEntity() instanceof ThrownTrident
|
||||
|| source.getDirectEntity() instanceof FireworkRocketEntity;
|
||||
}
|
||||
|
||||
private static double getRangedScalingMultiplier(
|
||||
net.fretux.ascend.player.PlayerStats stats,
|
||||
DamageSource source
|
||||
) {
|
||||
double bonus = 1.0d;
|
||||
int agility = stats.getAttributeLevel("agility");
|
||||
if (agility > 0) {
|
||||
double perPoint = 0.004d;
|
||||
double maxBonus = 0.35d;
|
||||
bonus *= 1.0d + Math.min(agility * perPoint * getScaling(), maxBonus);
|
||||
}
|
||||
|
||||
if (source.getDirectEntity() instanceof ThrownTrident) {
|
||||
int strength = stats.getAttributeLevel("strength");
|
||||
if (strength > 0) {
|
||||
double perPoint = 0.003d;
|
||||
double maxBonus = 0.25d;
|
||||
bonus *= 1.0d + Math.min(strength * perPoint * getScaling(), maxBonus);
|
||||
}
|
||||
}
|
||||
|
||||
return bonus;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user