]> git.seodisparate.com - TurnBasedMinecraftMod/commitdiff
Minor fixes/changes
authorStephen Seo <seo.disparate@gmail.com>
Thu, 13 Sep 2018 05:12:04 +0000 (14:12 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Thu, 13 Sep 2018 05:12:04 +0000 (14:12 +0900)
src/main/java/com/seodisparate/TurnBasedMinecraft/common/AttackEventHandler.java
src/main/java/com/seodisparate/TurnBasedMinecraft/common/Battle.java
src/main/java/com/seodisparate/TurnBasedMinecraft/common/BattleManager.java
src/main/java/com/seodisparate/TurnBasedMinecraft/common/Combatant.java
src/main/java/com/seodisparate/TurnBasedMinecraft/common/Config.java
src/main/java/com/seodisparate/TurnBasedMinecraft/common/EntityInfo.java
src/main/resources/assets/TurnBasedMinecraft/TBM_Config.xml

index fccbce537484a89195e10ffc683dd9752ddc4f25..485e8ee6452711d70c9fc579b16ff54361c48cb6 100644 (file)
@@ -10,7 +10,6 @@ public class AttackEventHandler
     {
         if(event.getEntity().world.isRemote)
         {
-            TurnBasedMinecraftMod.logger.debug("isRemote");
             return;
         }
         else if(TurnBasedMinecraftMod.battleManager == null)
@@ -20,12 +19,12 @@ public class AttackEventHandler
         
         if(!(event.getSource().getTrueSource() == null || event.getSource().getTrueSource().equals(TurnBasedMinecraftMod.attackingEntity)) && TurnBasedMinecraftMod.battleManager.checkAttack(event))
         {
-            TurnBasedMinecraftMod.logger.debug("Canceled LivingAttackEvent between " + TurnBasedMinecraftMod.attackingEntity + " and " + event.getEntity());
+//            TurnBasedMinecraftMod.logger.debug("Canceled LivingAttackEvent between " + TurnBasedMinecraftMod.attackingEntity + " and " + event.getEntity());
             event.setCanceled(true);
         }
         else
         {
-            TurnBasedMinecraftMod.logger.debug("Did not cancel attack");
+//            TurnBasedMinecraftMod.logger.debug("Did not cancel attack");
         }
         if(TurnBasedMinecraftMod.attackingDamage < (int) event.getAmount())
         {
index 242cc8e9be8af496f752e49bb8b32908d0c28cee..3e9ba4048df99b5ce1a25be4e56c77c3f716dc29 100644 (file)
@@ -580,6 +580,10 @@ public class Battle
                             {
                                 hitChance -= target.entityInfo.evasion;
                             }
+                            if(hitChance < 1)
+                            {
+                                hitChance = 1;
+                            }
                             if((int)(Math.random() * 100) < hitChance)
                             {
                                 if(target.remainingDefenses <= 0)
@@ -663,6 +667,10 @@ public class Battle
                             {
                                 hitChance -= target.entityInfo.evasion;
                             }
+                            if(hitChance < 1)
+                            {
+                                hitChance = 1;
+                            }
                             if((int)(Math.random() * 100) < hitChance)
                             {
                                 if(target.remainingDefenses <= 0)
index aa6a026f9c1625d58abc2964a2ccf10347fa6de1..d0a902a86bf61e0686222d11aac8b727fdc9434f 100644 (file)
@@ -52,11 +52,11 @@ public class BattleManager
             {
                 if(b.hasCombatant(event.getSource().getTrueSource().getEntityId()))
                 {
-                    logger.debug("Attack Canceled: attacked ignores battle but attacker in battle");
+//                    logger.debug("Attack Canceled: attacked ignores battle but attacker in battle");
                     return true;
                 }
             }
-            logger.debug("Attack Not Canceled: attacked ignores battle");
+//            logger.debug("Attack Not Canceled: attacked ignores battle");
             return false;
         }
         entityInfo = TurnBasedMinecraftMod.config.getMatchingEntityInfo(event.getSource().getTrueSource());
@@ -67,11 +67,11 @@ public class BattleManager
             {
                 if(b.hasCombatant(event.getEntity().getEntityId()))
                 {
-                    logger.debug("Attack Canceled: attacker ignores battle but attacked in battle");
+//                    logger.debug("Attack Canceled: attacker ignores battle but attacked in battle");
                     return true;
                 }
             }
-            logger.debug("Attack Not Canceled: attacker ignores battle");
+//            logger.debug("Attack Not Canceled: attacker ignores battle");
             return false;
         }
         
@@ -87,7 +87,7 @@ public class BattleManager
                 if(inBattle != null)
                 {
                     // both combatants are in battle
-                    logger.debug("Attack Canceled: both are in battle");
+//                    logger.debug("Attack Canceled: both are in battle");
                     return true;
                 }
                 else
@@ -102,7 +102,7 @@ public class BattleManager
                 if(inBattle != null)
                 {
                     // both combatants are in battle
-                    logger.debug("Attack Canceled: both are in battle");
+//                    logger.debug("Attack Canceled: both are in battle");
                     return true;
                 }
                 else
@@ -125,11 +125,11 @@ public class BattleManager
                 sideA.add(event.getEntity());
                 sideB.add(event.getSource().getTrueSource());
                 createBattle(sideA, sideB);
-                logger.debug("Attack Not Canceled: new battle created");
+//                logger.debug("Attack Not Canceled: new battle created");
             }
             else
             {
-                logger.debug("Attack Not Canceled: neither are in battle or players");
+//                logger.debug("Attack Not Canceled: neither are in battle or players");
             }
             return false;
         }
@@ -144,7 +144,7 @@ public class BattleManager
             battle.addCombatantToSideA(notInBattle);
         }
 
-        logger.debug("Attack Canceled: one is in battle");
+//        logger.debug("Attack Canceled: one is in battle");
         return true;
     }
     
index 9092485cd9283307d1b4a5a40a6a57d1a6b09f36..6490e26a9da7543530c239cdfb3da4b0aaf8b4a3 100644 (file)
@@ -50,7 +50,7 @@ public class Combatant
                 boolean isSlow = false;
                 for(PotionEffect e : c0Entity.getActivePotionEffects())
                 {
-                    if(e.getEffectName().equals(MobEffects.HASTE.getName()))
+                    if(e.getEffectName().equals(MobEffects.HASTE.getName()) || e.getEffectName().equals(MobEffects.SPEED.getName()))
                     {
                         isHaste = true;
                     }
index 41c3a5fd7e72b6912d0fbcf7ba697a522ad66d91..e3534c80929e0da8306657f77c9f50425b89e63a 100644 (file)
@@ -20,12 +20,10 @@ import javax.xml.stream.XMLStreamReader;
 
 import org.apache.logging.log4j.Logger;
 
-import com.seodisparate.TurnBasedMinecraft.common.EntityInfo.Category;
-
 public class Config
 {
     private Map<String, EntityInfo> entityInfoMap;
-    private Set<EntityInfo.Category> ignoreBattleTypes;
+    private Set<String> ignoreBattleTypes;
     private Logger logger;
     private int playerSpeed = 50;
     private int playerHasteSpeed = 80;
@@ -39,7 +37,7 @@ public class Config
     public Config(Logger logger)
     {
         entityInfoMap = new HashMap<String, EntityInfo>();
-        ignoreBattleTypes = new HashSet<EntityInfo.Category>();
+        ignoreBattleTypes = new HashSet<String>();
         this.logger = logger;
         
         int internalVersion = 0;
@@ -162,7 +160,7 @@ public class Config
                         xmlReader.next();
                         if(xmlReader.isStartElement())
                         {
-                            ignoreBattleTypes.add(Category.fromString(xmlReader.getLocalName()));
+                            ignoreBattleTypes.add(xmlReader.getLocalName().toLowerCase());
                         }
                     } while(!(xmlReader.isEndElement() && xmlReader.getLocalName().equals("IgnoreBattleTypes")));
                 }
@@ -272,7 +270,7 @@ public class Config
                                     }
                                     else if(xmlReader.getLocalName().equals("Category"))
                                     {
-                                        eInfo.category = Category.fromString(xmlReader.getElementText());
+                                        eInfo.category = xmlReader.getElementText().toLowerCase();
                                     }
                                     else if(xmlReader.getLocalName().equals("Conflicts"))
                                     {
@@ -453,7 +451,7 @@ public class Config
         return configVersion;
     }
     
-    public boolean isIgnoreBattleType(Category type)
+    public boolean isIgnoreBattleType(String type)
     {
         return ignoreBattleTypes.contains(type);
     }
index 19286294de74e52f204e651d076b4c50c752ae86..11240683219d7ff54a47566519990b15478036a1 100644 (file)
@@ -21,45 +21,11 @@ public class EntityInfo
     public int defenseDamageProbability;
     public int evasion;
     public int speed;
-    public Category category;
+    public String category;
     public int decisionAttack;
     public int decisionDefend;
     public int decisionFlee;
     
-    public enum Category
-    {
-        MONSTER,
-        PASSIVE,
-        ANIMAL,
-        BOSS,
-        UNKNOWN;
-        
-        public static Category fromString(String c)
-        {
-            c = c.toLowerCase();
-            if(c.equals("monster"))
-            {
-                return MONSTER;
-            }
-            else if(c.equals("passive"))
-            {
-                return PASSIVE;
-            }
-            else if(c.equals("animal"))
-            {
-                return ANIMAL;
-            }
-            else if(c.equals("boss"))
-            {
-                return BOSS;
-            }
-            else
-            {
-                return UNKNOWN;
-            }
-        }
-    }
-    
     public enum Effect
     {
         SPEED,
@@ -355,7 +321,7 @@ public class EntityInfo
         defenseDamageProbability = 0;
         evasion = 15;
         speed = 50;
-        category = Category.UNKNOWN;
+        category = "unknown";
         decisionAttack = 70;
         decisionDefend = 20;
         decisionFlee = 10;
index 68dd90076adbf8bc2e6949aa54cc7579bd6168f8..39d328b8e76b0558004de8e93be7f2bd49a60a04 100644 (file)
@@ -1,15 +1,16 @@
 <TurnBasedMinecraftConfig>
        <!-- If the mod has a newer version config, it will rename the existing config and place the new config -->
        <Version>1</Version>
-       <!-- Types that will not initiate battle with player. They are listed as "Category" per EntiytStats entity. -->
+       <!-- 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>
                <Passive></Passive>
                <Boss></Boss>
        </IgnoreBattleTypes>
        <PlayerStats>
                <Speed>50</Speed>
-               <HasteSpeed>80</HasteSpeed>
-               <SlowSpeed>20</SlowSpeed>
+               <HasteSpeed>80</HasteSpeed> <!-- Speed used if the player entity has "speed" or "haste" effects -->
+               <SlowSpeed>20</SlowSpeed> <!-- Speed used if the player entity has "slow" effect -->
                <AttackProbability>90</AttackProbability>
                <Evasion>10</Evasion>
        </PlayerStats>
@@ -24,6 +25,7 @@
                <!-- AttackEffect: (Optional) Applies effect to target entity with "Probability" success rate. -->
                <!-- DefenseDamage: (Optional) Applies damage to an attacker when attacked with "Probability" success rate. -->
                <!-- Evasion: Determines the percentage of evading attacks between 0 and 100. -->
+               <!-- Note that if the hit probability and evasion result in a percentage less than 1%, the hit chance will be changed ti 1% -->
                <!-- Speed: Value in range of 0 to 100 that determines the order entities act in battle. Higher is sooner. Entities with same speed will take their turn as a group in random order (not at the same time). -->
                <!-- IgnoreBattle: (Optional) Per entity setting to not enter turn-based-battle if value is "true". If "true" these stats will not apply to the entity as they are only used in turn-based-battle. -->
                <!-- Category: Sets the type of the entity, used by "IgnoreBattleTypes" to determine what types ignore battle. -->