Skip to content

Commit 4652f1a

Browse files
committed
Added a config option for mob level multiplier
1 parent de6abd3 commit 4652f1a

2 files changed

Lines changed: 21 additions & 17 deletions

File tree

src/main/java/com/azuredoom/levelingcore/config/GUIConfig.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,12 @@ public class GUIConfig {
277277
(exConfig, extraInfo) -> exConfig.showMobLvls
278278
)
279279
.add()
280+
.append(
281+
new KeyedCodec<Double>("MobLevelMultiplier", Codec.DOUBLE),
282+
(exConfig, aDouble, extraInfo) -> exConfig.mobLevelMultiplier = aDouble,
283+
(exConfig, extraInfo) -> exConfig.mobLevelMultiplier
284+
)
285+
.add()
280286
.build();
281287

282288
private boolean enableXPLossOnDeath = false;
@@ -367,6 +373,8 @@ public class GUIConfig {
367373

368374
private boolean showMobLvls = true;
369375

376+
private double mobLevelMultiplier = 0.35;
377+
370378
public GUIConfig() {}
371379

372380
/**
@@ -619,4 +627,8 @@ public boolean isShowPlayerLvls() {
619627
public boolean isShowMobLvls() {
620628
return showMobLvls;
621629
}
630+
631+
public double getMobLevelMultiplier() {
632+
return mobLevelMultiplier;
633+
}
622634
}

src/main/java/com/azuredoom/levelingcore/systems/xp/GainXPEventSystem.java

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -109,20 +109,12 @@ public void onComponentAdded(
109109
return;
110110
var xpAmountHealth = Math.max(1, (long) (maxHealth * this.config.get().getDefaultXPGainPercentage()));
111111
var getXPMapping = xpMap.getOrDefault(entity.getNPCTypeId(), Math.toIntExact(xpAmountHealth));
112-
var xpAmount = config.get().isUseConfigXPMappingsInsteadOfHealthDefaults()
113-
? getXPMapping
112+
double levelScale = Math.pow(mobLevel.level, config.get().getMobLevelMultiplier());
113+
long base = config.get().isUseConfigXPMappingsInsteadOfHealthDefaults()
114+
? (long) (getXPMapping)
114115
: xpAmountHealth;
115-
final var levelWindow = 5;
116-
final var maxBonusMult = 1.25;
117-
118-
int diff = Math.abs(playerLevel - mobLevel.level);
119-
if (diff <= levelWindow) {
120-
var t = 1.0 - (diff / (double) levelWindow);
121-
var mult = 1.0 + (maxBonusMult - 1.0) * t;
122-
xpAmount = Math.max(1L, Math.round(xpAmount * mult));
123-
}
124-
long finalXpAmount = xpAmount;
125-
if (finalXpAmount <= 0)
116+
long xpAmount = Math.round(base * levelScale);
117+
if (xpAmount <= 0)
126118
return;
127119
store.getExternalData().getWorld().execute(() -> {
128120
LevelingCoreApi.getLevelServiceIfPresent().ifPresent(levelService -> {
@@ -131,13 +123,13 @@ public void onComponentAdded(
131123
PluginManager.get()
132124
.getPlugin(new PluginIdentifier("tsumori", "partypro")) != null
133125
) {
134-
PartyProCompat.onXPGain(finalXpAmount, player.getUuid(), levelService, config, playerRef);
126+
PartyProCompat.onXPGain(xpAmount, player.getUuid(), levelService, config, playerRef);
135127
} else if (
136128
PluginManager.get()
137129
.getPlugin(new PluginIdentifier("com.carsonk", "Party Plugin")) != null
138130
) {
139131
PartyPluginCompat.onXPGain(
140-
finalXpAmount,
132+
xpAmount,
141133
player.getUuid(),
142134
levelService,
143135
config,
@@ -148,9 +140,9 @@ public void onComponentAdded(
148140
if (!config.get().isDisableXPGainNotification())
149141
NotificationsUtil.sendNotification(
150142
playerRef,
151-
CommandLang.GAINED.param("xp", finalXpAmount)
143+
CommandLang.GAINED.param("xp", xpAmount)
152144
);
153-
levelService.addXp(player.getUuid(), finalXpAmount);
145+
levelService.addXp(player.getUuid(), xpAmount);
154146
XPBarHud.updateHud(playerRef);
155147
}
156148
LevelingCore.mobLevelRegistry.remove(entity.getUuid());

0 commit comments

Comments
 (0)