From 8788100669b277a4a5a13b5fe9d0e9007d27feed Mon Sep 17 00:00:00 2001 From: Grzybol Date: Thu, 27 Jun 2024 23:58:35 +0200 Subject: [PATCH] - fixed dmg calculations --- pom.xml | 2 +- .../betterbox/mine/game/betterelo/Event.java | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index af4c3ae..b46aed8 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ betterbox.mine.game BetterElo - 4.3.44-SNAPSHOT + 4.3.47-SNAPSHOT jar BetterElo diff --git a/src/main/java/betterbox/mine/game/betterelo/Event.java b/src/main/java/betterbox/mine/game/betterelo/Event.java index c011986..fe2e76d 100644 --- a/src/main/java/betterbox/mine/game/betterelo/Event.java +++ b/src/main/java/betterbox/mine/game/betterelo/Event.java @@ -1187,16 +1187,28 @@ public void customEntityDamageEvent(EntityDamageByEntityEvent event){ if (event.getEntity().hasMetadata("defense")) { List values = event.getEntity().getMetadata("defense"); defense = values.get(0).asDouble(); // Uzyskanie wartoĊ›ci defense + pluginLogger.log(PluginLogger.LogLevel.CUSTOM_MOBS, "Event.customEntityDamageEvent defense from metadata: "+defense); if (defense>=100){ + pluginLogger.log(PluginLogger.LogLevel.WARNING, "Damage event: Mob has defense higher than 100! setting def=0:"); defense=0; } + }else{ + pluginLogger.log(PluginLogger.LogLevel.CUSTOM_MOBS, "Event.customEntityDamageEvent defense metadata not found for mob: "+event.getEntity().getMetadata("MobName")); + } + CustomMobs.CustomMob customMob = null; + customMob = betterElo.getCustomMobFromEntity(event.getEntity()); + if(customMob!=null) + { + defense = customMob.defense; + pluginLogger.log(PluginLogger.LogLevel.CUSTOM_MOBS, "Event.customEntityDamageEvent defense from customMob object: "+defense); } - double finalDamage =((totalDamage-armor)*(1-(0.01*defense))); + double defDmgReduction= (1-(0.01*defense)); + double finalDamage =((totalDamage-armor)*defDmgReduction); if(finalDamage<=0) finalDamage=0; event.setDamage(finalDamage); - pluginLogger.log(PluginLogger.LogLevel.CUSTOM_MOBS, "Event.customEntityDamageEvent totalDamage: " + totalDamage+", bonusDamage: "+bonusDamage); + pluginLogger.log(PluginLogger.LogLevel.CUSTOM_MOBS, "Event.customEntityDamageEvent finalDamage: "+finalDamage+", totalDamage: " + totalDamage+", bonusDamage: "+bonusDamage+", defDmgReduction(1-(0.01*defense)): "+defDmgReduction+", armor: "+armor); return; }