Skip to content

Commit

Permalink
- fixed dmg calculations
Browse files Browse the repository at this point in the history
  • Loading branch information
Grzybol committed Jun 27, 2024
1 parent 75b0175 commit 8788100
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>betterbox.mine.game</groupId>
<artifactId>BetterElo</artifactId>
<version>4.3.44-SNAPSHOT</version>
<version>4.3.47-SNAPSHOT</version>
<packaging>jar</packaging>

<name>BetterElo</name>
Expand Down
16 changes: 14 additions & 2 deletions src/main/java/betterbox/mine/game/betterelo/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -1187,16 +1187,28 @@ public void customEntityDamageEvent(EntityDamageByEntityEvent event){
if (event.getEntity().hasMetadata("defense")) {
List<MetadataValue> 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;

}
Expand Down

0 comments on commit 8788100

Please sign in to comment.