Small version update
This commit is contained in:
@@ -3,6 +3,7 @@ package net.fretux.ascend.event;
|
|||||||
import net.fretux.ascend.AscendMod;
|
import net.fretux.ascend.AscendMod;
|
||||||
import net.fretux.ascend.config.AscendConfig;
|
import net.fretux.ascend.config.AscendConfig;
|
||||||
import net.fretux.ascend.player.PlayerStatsProvider;
|
import net.fretux.ascend.player.PlayerStatsProvider;
|
||||||
|
import net.fretux.ascend.player.StatEffects;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.particles.ParticleTypes;
|
import net.minecraft.core.particles.ParticleTypes;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
@@ -216,17 +217,24 @@ public class ActivityEvents {
|
|||||||
public static void onPlayerDealsDamage(LivingDamageEvent event) {
|
public static void onPlayerDealsDamage(LivingDamageEvent event) {
|
||||||
if (!(event.getSource().getEntity() instanceof Player player)) return;
|
if (!(event.getSource().getEntity() instanceof Player player)) return;
|
||||||
if (player.level().isClientSide) return;
|
if (player.level().isClientSide) return;
|
||||||
LivingEntity target = event.getEntity();
|
|
||||||
player.getCapability(PlayerStatsProvider.PLAYER_STATS).ifPresent(stats -> {
|
player.getCapability(PlayerStatsProvider.PLAYER_STATS).ifPresent(stats -> {
|
||||||
int strength = stats.getAttributeLevel("strength");
|
float damage = event.getAmount();
|
||||||
if (strength <= 0) return;
|
var stack = player.getMainHandItem();
|
||||||
float bypassFraction = Math.min(strength * 0.001f, 0.30f);
|
if (!stack.isEmpty()) {
|
||||||
int armor = target.getArmorValue();
|
double multiplier = 1.0d;
|
||||||
if (armor <= 0 || bypassFraction <= 0f) return;
|
if (stack.getItem() instanceof net.minecraft.world.item.AxeItem) {
|
||||||
float baseDamage = event.getAmount();
|
int heavy = stats.getAttributeLevel("heavy_scaling");
|
||||||
float armorFactor = (float) armor / (armor + 100.0f);
|
multiplier = StatEffects.getHeavyWeaponScalingMultiplier(heavy);
|
||||||
float bonus = baseDamage * armorFactor * bypassFraction;
|
} else if (stack.getItem() instanceof net.minecraft.world.item.SwordItem) {
|
||||||
event.setAmount(baseDamage + bonus);
|
int medium = stats.getAttributeLevel("medium_scaling");
|
||||||
|
multiplier = StatEffects.getWeaponScalingMultiplier(medium);
|
||||||
|
} else {
|
||||||
|
int light = stats.getAttributeLevel("light_scaling");
|
||||||
|
multiplier = StatEffects.getLightWeaponScalingMultiplier(light);
|
||||||
|
}
|
||||||
|
damage *= multiplier;
|
||||||
|
}
|
||||||
|
event.setAmount(damage);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ public class ServerboundShrineChoicePacket {
|
|||||||
if (stats.getKnowledge() >= 15) {
|
if (stats.getKnowledge() >= 15) {
|
||||||
stats.addKnowledge(-15);
|
stats.addKnowledge(-15);
|
||||||
stats.refundAllPoints();
|
stats.refundAllPoints();
|
||||||
|
net.fretux.ascend.player.StatEffects.applyAll(player);
|
||||||
player.sendSystemMessage(Component.literal("YOU ARE A BLANK SLATE. EMPTY. FORGOTTEN."));
|
player.sendSystemMessage(Component.literal("YOU ARE A BLANK SLATE. EMPTY. FORGOTTEN."));
|
||||||
RemembranceEssenceItem.consume(player);
|
RemembranceEssenceItem.consume(player);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -24,18 +24,33 @@ public final class StatEffects {
|
|||||||
private static final UUID FORTITUDE_KB_RESIST_UUID =
|
private static final UUID FORTITUDE_KB_RESIST_UUID =
|
||||||
UUID.fromString("e4b5c6d7-8e9f-4012-9abc-334455667788");
|
UUID.fromString("e4b5c6d7-8e9f-4012-9abc-334455667788");
|
||||||
|
|
||||||
private StatEffects() {}
|
private StatEffects() {
|
||||||
|
}
|
||||||
|
|
||||||
private static double getScaling() {
|
private static double getScaling() {
|
||||||
return AscendConfig.COMMON.attributeScalingMultiplier.get();
|
return AscendConfig.COMMON.attributeScalingMultiplier.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static double mediumScalingPercent(int x) {
|
||||||
|
if (x <= 0) return 0.0d;
|
||||||
|
return Math.pow(3.5d * x, 0.61d);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double lightScalingPercent(int x) {
|
||||||
|
if (x <= 0) return 0.0d;
|
||||||
|
return Math.pow(4.0d * x, 0.55d);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static double heavyScalingPercent(int x) {
|
||||||
|
if (x <= 0) return 0.0d;
|
||||||
|
return (0.4d * x) + (5.0d * Math.sin(0.065d * x));
|
||||||
|
}
|
||||||
|
|
||||||
public static void applyAll(Player player) {
|
public static void applyAll(Player player) {
|
||||||
player.getCapability(PlayerStatsProvider.PLAYER_STATS).ifPresent(stats -> {
|
player.getCapability(PlayerStatsProvider.PLAYER_STATS).ifPresent(stats -> {
|
||||||
applyStrength(player, stats.getAttributeLevel("strength"));
|
applyStrength(player, stats.getAttributeLevel("strength"));
|
||||||
applyAgility(player, stats.getAttributeLevel("agility"));
|
applyAgility(player, stats.getAttributeLevel("agility"));
|
||||||
applyFortitude(player, stats.getAttributeLevel("fortitude"));
|
applyFortitude(player, stats.getAttributeLevel("fortitude"));
|
||||||
// - Willpower: see getWillpowerSanityMultiplier / getWillpowerTempoMultiplier.
|
|
||||||
if (IronsSpellbooksCompat.isLoaded()) {
|
if (IronsSpellbooksCompat.isLoaded()) {
|
||||||
IronsSpellbooksCompat.applyAll(player);
|
IronsSpellbooksCompat.applyAll(player);
|
||||||
}
|
}
|
||||||
@@ -43,11 +58,12 @@ public final class StatEffects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void applyStrength(Player player, int strengthLevel) {
|
public static void applyStrength(Player player, int strengthLevel) {
|
||||||
|
// Always remove first so resets correctly.
|
||||||
AttributeInstance atk = player.getAttribute(Attributes.ATTACK_DAMAGE);
|
AttributeInstance atk = player.getAttribute(Attributes.ATTACK_DAMAGE);
|
||||||
if (atk != null) {
|
if (atk != null) {
|
||||||
atk.removeModifier(STRENGTH_DAMAGE_UUID);
|
atk.removeModifier(STRENGTH_DAMAGE_UUID);
|
||||||
if (strengthLevel > 0) {
|
if (strengthLevel > 0) {
|
||||||
double dmgBonus = strengthLevel * 0.1d * getScaling();
|
double dmgBonus = (mediumScalingPercent(strengthLevel) * 0.1d) * getScaling();
|
||||||
atk.addTransientModifier(new AttributeModifier(
|
atk.addTransientModifier(new AttributeModifier(
|
||||||
STRENGTH_DAMAGE_UUID,
|
STRENGTH_DAMAGE_UUID,
|
||||||
"Ascend Strength damage bonus",
|
"Ascend Strength damage bonus",
|
||||||
@@ -57,12 +73,11 @@ public final class StatEffects {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Knockback
|
|
||||||
AttributeInstance kb = player.getAttribute(Attributes.ATTACK_KNOCKBACK);
|
AttributeInstance kb = player.getAttribute(Attributes.ATTACK_KNOCKBACK);
|
||||||
if (kb != null) {
|
if (kb != null) {
|
||||||
kb.removeModifier(STRENGTH_KNOCKBACK_UUID);
|
kb.removeModifier(STRENGTH_KNOCKBACK_UUID);
|
||||||
if (strengthLevel > 0) {
|
if (strengthLevel > 0) {
|
||||||
double kbBonus = strengthLevel * 0.015d * getScaling();
|
double kbBonus = (mediumScalingPercent(strengthLevel) * 0.015d) * getScaling();
|
||||||
kb.addTransientModifier(new AttributeModifier(
|
kb.addTransientModifier(new AttributeModifier(
|
||||||
STRENGTH_KNOCKBACK_UUID,
|
STRENGTH_KNOCKBACK_UUID,
|
||||||
"Ascend Strength knockback bonus",
|
"Ascend Strength knockback bonus",
|
||||||
@@ -155,9 +170,20 @@ public final class StatEffects {
|
|||||||
|
|
||||||
public static double getWeaponScalingMultiplier(int scalingLevel) {
|
public static double getWeaponScalingMultiplier(int scalingLevel) {
|
||||||
if (scalingLevel <= 0) return 1.0d;
|
if (scalingLevel <= 0) return 1.0d;
|
||||||
double perPoint = 0.005d;
|
double percent = mediumScalingPercent(scalingLevel);
|
||||||
double maxBonus = 0.50d;
|
return 1.0d + (percent / 100.0d);
|
||||||
return 1.0d + Math.min(scalingLevel * perPoint, maxBonus);
|
}
|
||||||
|
|
||||||
|
public static double getLightWeaponScalingMultiplier(int scalingLevel) {
|
||||||
|
if (scalingLevel <= 0) return 1.0d;
|
||||||
|
double percent = lightScalingPercent(scalingLevel);
|
||||||
|
return 1.0d + (percent / 100.0d);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double getHeavyWeaponScalingMultiplier(int scalingLevel) {
|
||||||
|
if (scalingLevel <= 0) return 1.0d;
|
||||||
|
double percent = heavyScalingPercent(scalingLevel);
|
||||||
|
return 1.0d + (percent / 100.0d);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getMagicScalingMultiplier(int scalingLevel) {
|
public static double getMagicScalingMultiplier(int scalingLevel) {
|
||||||
|
|||||||
Reference in New Issue
Block a user