mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-20 18:09:44 +00:00
Attribute THINGS
This commit is contained in:
1 parent
c132db8299
commit
4e0359902d
4 files changed
+77
-6
No files matched your search
@@ -8,18 +8,20 @@ import noppes.npcs.entity.EntityNPCInterface;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import static noppes.npcs.attribute.AttributeController.getTracker;
|
||||
|
||||
public class AttributeAttackHelper {
|
||||
private static final Random random = new Random();
|
||||
|
||||
public static float calculateDamagePlayer(EntityPlayer attacker, EntityPlayer defender, float base){
|
||||
return calculateDamagePlayer(AttributeController.getTracker(attacker), AttributeController.getTracker(defender), base);
|
||||
return calculateDamagePlayer(getTracker(attacker), getTracker(defender), base);
|
||||
}
|
||||
|
||||
public static float calculateDamagePlayer(PlayerAttributeTracker attacker, PlayerAttributeTracker defender, float baseDamage) {
|
||||
|
||||
// Calculate physical damage
|
||||
float mainAttack = attacker.getAttributeValue(ModAttributes.MAIN_ATTACK);
|
||||
float mainBoost = attacker.getAttributeValue(ModAttributes.MAGIC_BOOST) + 1;
|
||||
float mainBoost = attacker.getAttributeValue(ModAttributes.MAIN_BOOST) + 1;
|
||||
float physicalDamage = (baseDamage * mainBoost) + mainAttack;
|
||||
|
||||
// Calculate neutral damage
|
||||
@@ -64,7 +66,7 @@ public class AttributeAttackHelper {
|
||||
|
||||
// Calculate physical damage
|
||||
float mainAttack = attacker.getAttributeValue(ModAttributes.MAIN_ATTACK);
|
||||
float mainBoost = attacker.getAttributeValue(ModAttributes.MAGIC_BOOST) + 1;
|
||||
float mainBoost = attacker.getAttributeValue(ModAttributes.MAIN_BOOST) + 1;
|
||||
float physicalDamage = (baseDamage * mainBoost) + mainAttack;
|
||||
|
||||
// Calculate neutral damage
|
||||
@@ -105,4 +107,47 @@ public class AttributeAttackHelper {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates a player's total damage when attacking an opponent with no defense.
|
||||
* In this calculation, any defensive modifiers (such as magic defense or resistance)
|
||||
* are assumed to be zero.
|
||||
*
|
||||
* @param attacker The attacker's attribute tracker.
|
||||
* @return The total calculated damage.
|
||||
*/
|
||||
public static float calculateMaximumOutput(PlayerAttributeTracker attacker) {
|
||||
// Neutral damage remains unchanged.
|
||||
float neutralDamage = attacker.getAttributeValue(ModAttributes.NEUTRAL_ATTACK);
|
||||
float neutralBoost = attacker.getAttributeValue(ModAttributes.NEUTRAL_BOOST) + 1;
|
||||
float neutralTotal = neutralDamage * neutralBoost;
|
||||
|
||||
// For magic damage, we ignore any defensive values.
|
||||
float magicTotal = 0.0f;
|
||||
MagicController magicController = MagicController.getInstance();
|
||||
for (Map.Entry<Integer, Float> entry : attacker.magicDamage.entrySet()) {
|
||||
int magicId = entry.getKey();
|
||||
if (magicController.getMagic(magicId) != null) {
|
||||
float attackMagic = entry.getValue();
|
||||
// No defender, so effective magic equals attack magic.
|
||||
float effectiveMagic = attackMagic;
|
||||
|
||||
float boostMagic = attacker.magicBoost.getOrDefault(magicId, 0.0f);
|
||||
// No resistance present.
|
||||
float effectiveBoost = boostMagic;
|
||||
|
||||
float magicDamageForMagic = effectiveMagic * (effectiveBoost + 1);
|
||||
magicTotal += Math.max(0, magicDamageForMagic);
|
||||
}
|
||||
}
|
||||
return neutralTotal + magicTotal;
|
||||
}
|
||||
|
||||
public static float calculateOutgoing(EntityPlayer entityPlayer, float baseDamage) {
|
||||
PlayerAttributeTracker attacker = getTracker(entityPlayer);
|
||||
|
||||
float mainAttack = attacker.getAttributeValue(ModAttributes.MAIN_ATTACK);
|
||||
float mainBoost = attacker.getAttributeValue(ModAttributes.MAIN_BOOST) + 1;
|
||||
float physicalDamage = (baseDamage * mainBoost) + mainAttack;
|
||||
return attacker.maximumOutput + physicalDamage;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user