mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-22 01:32:19 +00:00
More Item Attribute Things
This commit is contained in:
1 parent
9b7af03de3
commit
50977543c0
13 files changed
+312
-162
No files matched your search
@@ -1,15 +1,59 @@
|
||||
package noppes.npcs.attribute;
|
||||
|
||||
import noppes.npcs.attribute.player.PlayerAttributeTracker;
|
||||
import noppes.npcs.controllers.MagicController;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
public class DamageCalculator {
|
||||
private static final Random random = new Random();
|
||||
|
||||
public static double calculateDamage(PlayerAttributeTracker attacker, PlayerAttributeTracker defender, double baseDamage) {
|
||||
|
||||
public static double calculateDamage(PlayerAttributeTracker attacker, PlayerAttributeTracker defender, int baseDamage) {
|
||||
return 0;
|
||||
// Calculate physical damage
|
||||
double mainAttack = attacker.getAttributeValue(ModAttributes.MAIN_ATTACK);
|
||||
double mainBoost = attacker.getAttributeValue(ModAttributes.MAGIC_BOOST) + 1;
|
||||
double physicalDamage = (baseDamage * mainBoost) + mainAttack;
|
||||
|
||||
// Calculate neutral damage
|
||||
double neutralDamage = attacker.getAttributeValue(ModAttributes.NEUTRAL_ATTACK);
|
||||
double neutralBoost = attacker.getAttributeValue(ModAttributes.NEUTRAL_BOOST) + 1;
|
||||
double neutralTotal = neutralDamage * neutralBoost;
|
||||
|
||||
// Calculate magic damage
|
||||
double magicTotal = 0.0;
|
||||
MagicController magicController = MagicController.getInstance();
|
||||
for (Map.Entry<Integer, Double> entry : attacker.magicDamage.entrySet()) {
|
||||
int magicId = entry.getKey();
|
||||
if (magicController.getMagic(magicId) != null) {
|
||||
double attackMagic = entry.getValue();
|
||||
double defenseMagic = defender.magicDefense.getOrDefault(magicId, 0.0);
|
||||
double effectiveMagic = attackMagic - defenseMagic;
|
||||
|
||||
double boostMagic = attacker.magicBoost.getOrDefault(magicId, 0.0);
|
||||
double resistanceMagic = defender.magicResistance.getOrDefault(magicId, 0.0);
|
||||
double effectiveBoost = boostMagic - resistanceMagic;
|
||||
|
||||
double magicDamageForMagic = effectiveMagic * (effectiveBoost + 1);
|
||||
// Ensure magic damage doesn't drop below 0 for this magic
|
||||
magicTotal += Math.max(0, magicDamageForMagic);
|
||||
}
|
||||
}
|
||||
|
||||
// Sum all damage components
|
||||
double totalDamage = physicalDamage + neutralTotal + magicTotal;
|
||||
|
||||
// Critical hit: if critical, double damage and add bonus
|
||||
double criticalChance = attacker.getAttributeValue(ModAttributes.CRITICAL_CHANCE);
|
||||
double criticalBonus = attacker.getAttributeValue(ModAttributes.CRITICAL_DAMAGE);
|
||||
if (random.nextDouble() < (criticalChance / 100)) {
|
||||
totalDamage = (totalDamage * 2) + criticalBonus;
|
||||
}
|
||||
|
||||
return totalDamage;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user