]> git.seodisparate.com - TurnBasedMinecraftMod/commitdiff
bug fixes and add MinimumHitPercentage to config
authorStephen Seo <seo.disparate@gmail.com>
Thu, 13 Sep 2018 05:52:48 +0000 (14:52 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Thu, 13 Sep 2018 05:52:48 +0000 (14:52 +0900)
src/main/java/com/seodisparate/TurnBasedMinecraft/common/Battle.java
src/main/java/com/seodisparate/TurnBasedMinecraft/common/Config.java
src/main/java/com/seodisparate/TurnBasedMinecraft/common/networking/PacketBattleMessage.java
src/main/resources/assets/TurnBasedMinecraft/TBM_Config.xml

index 3e9ba4048df99b5ce1a25be4e56c77c3f716dc29..19380dca3ad070383425cb91240f2e1cccaf2355 100644 (file)
@@ -550,6 +550,9 @@ public class Battle
                         next = turnOrderQueue.poll();
                         continue;
                     }
+                    
+                    next.remainingDefenses = 0;
+                    
                     switch(next.decision)
                     {
                     case UNDECIDED:
@@ -580,9 +583,9 @@ public class Battle
                             {
                                 hitChance -= target.entityInfo.evasion;
                             }
-                            if(hitChance < 1)
+                            if(hitChance < TurnBasedMinecraftMod.config.getMinimumHitPercentage())
                             {
-                                hitChance = 1;
+                                hitChance = TurnBasedMinecraftMod.config.getMinimumHitPercentage();
                             }
                             if((int)(Math.random() * 100) < hitChance)
                             {
@@ -667,9 +670,9 @@ public class Battle
                             {
                                 hitChance -= target.entityInfo.evasion;
                             }
-                            if(hitChance < 1)
+                            if(hitChance < TurnBasedMinecraftMod.config.getMinimumHitPercentage())
                             {
-                                hitChance = 1;
+                                hitChance = TurnBasedMinecraftMod.config.getMinimumHitPercentage();
                             }
                             if((int)(Math.random() * 100) < hitChance)
                             {
index e3534c80929e0da8306657f77c9f50425b89e63a..00961c7394b180718cf3eaadfd34e528e7af4089 100644 (file)
@@ -33,6 +33,7 @@ public class Config
     private int defenseDuration = 1;
     private int fleeGoodProbability = 90;
     private int fleeBadProbability = 40;
+    private int minimumHitPercentage = 1;
     
     public Config(Logger logger)
     {
@@ -206,6 +207,14 @@ public class Config
                 {
                     fleeBadProbability = Integer.parseInt(xmlReader.getElementText());
                 }
+                else if(xmlReader.getLocalName().equals("MinimumHitPercentage"))
+                {
+                    minimumHitPercentage = Integer.parseInt(xmlReader.getElementText());
+                    if(minimumHitPercentage < 1)
+                    {
+                        minimumHitPercentage = 1;
+                    }
+                }
                 else if(xmlReader.getLocalName().equals("EntityStats"))
                 {
                     do
@@ -455,4 +464,9 @@ public class Config
     {
         return ignoreBattleTypes.contains(type);
     }
+    
+    public int getMinimumHitPercentage()
+    {
+        return minimumHitPercentage;
+    }
 }
index d3898c9f95043948f4c545406998fead08d2410c..e15b93185cf73cd87e3e4265f701083d96126790 100644 (file)
@@ -327,12 +327,12 @@ public class PacketBattleMessage implements IMessage
                 if(message.amount != 0)
                 {
                     Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new TextComponentString(
-                            to + " switched to a different item!"));
+                            from + " switched to a different item!"));
                 }
                 else
                 {
                     Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new TextComponentString(
-                            to + " switched to a different item but failed because it was invalid!"));
+                            from + " switched to a different item but failed because it was invalid!"));
                 }
                 break;
             case WAS_AFFECTED:
index 39d328b8e76b0558004de8e93be7f2bd49a60a04..b5f3db3523aeeeb7a78344876d4bc355b9feb9ea 100644 (file)
@@ -1,6 +1,6 @@
 <TurnBasedMinecraftConfig>
        <!-- If the mod has a newer version config, it will rename the existing config and place the new config -->
-       <Version>1</Version>
+       <Version>2</Version>
        <!-- Types that will not initiate battle with player. They are listed as "Category" per EntiytStats entity.
                 Note that items listed in "IgnoreBattleTypes" and "Category" are converted to lowercase before being compared. -->
        <IgnoreBattleTypes>
@@ -19,6 +19,8 @@
        <!-- Probability of escaping battle. If entity's speed is greater than the enemy team's speediest entity, then good probability is used. -->
        <FleeGoodProbability>90</FleeGoodProbability>
        <FleeBadProbability>40</FleeBadProbability>
+       <!-- Minimum hit percentage for every entity. If less than 1, it will be stored as 1 anyways. -->
+       <MinimumHitPercentage>4</MinimumHitPercentage>
        <!-- Battle stats for entities should be specified here. If an entity is not listed it cannot enter battle. -->
        <EntityStats>
                <!-- AttackPower: How much damage an entity does per attack. Usually has a "Probability" attribute between 0 and 100. Also may have a "Variance" attribute that varies the attack power by the specified amount randomly. -->