Minor fixes/changes
This commit is contained in:
parent
24ca95cc99
commit
0ea3dfd98a
7 changed files with 32 additions and 59 deletions
|
@ -10,7 +10,6 @@ public class AttackEventHandler
|
||||||
{
|
{
|
||||||
if(event.getEntity().world.isRemote)
|
if(event.getEntity().world.isRemote)
|
||||||
{
|
{
|
||||||
TurnBasedMinecraftMod.logger.debug("isRemote");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if(TurnBasedMinecraftMod.battleManager == null)
|
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))
|
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);
|
event.setCanceled(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TurnBasedMinecraftMod.logger.debug("Did not cancel attack");
|
// TurnBasedMinecraftMod.logger.debug("Did not cancel attack");
|
||||||
}
|
}
|
||||||
if(TurnBasedMinecraftMod.attackingDamage < (int) event.getAmount())
|
if(TurnBasedMinecraftMod.attackingDamage < (int) event.getAmount())
|
||||||
{
|
{
|
||||||
|
|
|
@ -580,6 +580,10 @@ public class Battle
|
||||||
{
|
{
|
||||||
hitChance -= target.entityInfo.evasion;
|
hitChance -= target.entityInfo.evasion;
|
||||||
}
|
}
|
||||||
|
if(hitChance < 1)
|
||||||
|
{
|
||||||
|
hitChance = 1;
|
||||||
|
}
|
||||||
if((int)(Math.random() * 100) < hitChance)
|
if((int)(Math.random() * 100) < hitChance)
|
||||||
{
|
{
|
||||||
if(target.remainingDefenses <= 0)
|
if(target.remainingDefenses <= 0)
|
||||||
|
@ -663,6 +667,10 @@ public class Battle
|
||||||
{
|
{
|
||||||
hitChance -= target.entityInfo.evasion;
|
hitChance -= target.entityInfo.evasion;
|
||||||
}
|
}
|
||||||
|
if(hitChance < 1)
|
||||||
|
{
|
||||||
|
hitChance = 1;
|
||||||
|
}
|
||||||
if((int)(Math.random() * 100) < hitChance)
|
if((int)(Math.random() * 100) < hitChance)
|
||||||
{
|
{
|
||||||
if(target.remainingDefenses <= 0)
|
if(target.remainingDefenses <= 0)
|
||||||
|
|
|
@ -52,11 +52,11 @@ public class BattleManager
|
||||||
{
|
{
|
||||||
if(b.hasCombatant(event.getSource().getTrueSource().getEntityId()))
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logger.debug("Attack Not Canceled: attacked ignores battle");
|
// logger.debug("Attack Not Canceled: attacked ignores battle");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
entityInfo = TurnBasedMinecraftMod.config.getMatchingEntityInfo(event.getSource().getTrueSource());
|
entityInfo = TurnBasedMinecraftMod.config.getMatchingEntityInfo(event.getSource().getTrueSource());
|
||||||
|
@ -67,11 +67,11 @@ public class BattleManager
|
||||||
{
|
{
|
||||||
if(b.hasCombatant(event.getEntity().getEntityId()))
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logger.debug("Attack Not Canceled: attacker ignores battle");
|
// logger.debug("Attack Not Canceled: attacker ignores battle");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ public class BattleManager
|
||||||
if(inBattle != null)
|
if(inBattle != null)
|
||||||
{
|
{
|
||||||
// both combatants are in battle
|
// both combatants are in battle
|
||||||
logger.debug("Attack Canceled: both are in battle");
|
// logger.debug("Attack Canceled: both are in battle");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -102,7 +102,7 @@ public class BattleManager
|
||||||
if(inBattle != null)
|
if(inBattle != null)
|
||||||
{
|
{
|
||||||
// both combatants are in battle
|
// both combatants are in battle
|
||||||
logger.debug("Attack Canceled: both are in battle");
|
// logger.debug("Attack Canceled: both are in battle");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -125,11 +125,11 @@ public class BattleManager
|
||||||
sideA.add(event.getEntity());
|
sideA.add(event.getEntity());
|
||||||
sideB.add(event.getSource().getTrueSource());
|
sideB.add(event.getSource().getTrueSource());
|
||||||
createBattle(sideA, sideB);
|
createBattle(sideA, sideB);
|
||||||
logger.debug("Attack Not Canceled: new battle created");
|
// logger.debug("Attack Not Canceled: new battle created");
|
||||||
}
|
}
|
||||||
else
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ public class BattleManager
|
||||||
battle.addCombatantToSideA(notInBattle);
|
battle.addCombatantToSideA(notInBattle);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug("Attack Canceled: one is in battle");
|
// logger.debug("Attack Canceled: one is in battle");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class Combatant
|
||||||
boolean isSlow = false;
|
boolean isSlow = false;
|
||||||
for(PotionEffect e : c0Entity.getActivePotionEffects())
|
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;
|
isHaste = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,12 +20,10 @@ import javax.xml.stream.XMLStreamReader;
|
||||||
|
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import com.seodisparate.TurnBasedMinecraft.common.EntityInfo.Category;
|
|
||||||
|
|
||||||
public class Config
|
public class Config
|
||||||
{
|
{
|
||||||
private Map<String, EntityInfo> entityInfoMap;
|
private Map<String, EntityInfo> entityInfoMap;
|
||||||
private Set<EntityInfo.Category> ignoreBattleTypes;
|
private Set<String> ignoreBattleTypes;
|
||||||
private Logger logger;
|
private Logger logger;
|
||||||
private int playerSpeed = 50;
|
private int playerSpeed = 50;
|
||||||
private int playerHasteSpeed = 80;
|
private int playerHasteSpeed = 80;
|
||||||
|
@ -39,7 +37,7 @@ public class Config
|
||||||
public Config(Logger logger)
|
public Config(Logger logger)
|
||||||
{
|
{
|
||||||
entityInfoMap = new HashMap<String, EntityInfo>();
|
entityInfoMap = new HashMap<String, EntityInfo>();
|
||||||
ignoreBattleTypes = new HashSet<EntityInfo.Category>();
|
ignoreBattleTypes = new HashSet<String>();
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
|
|
||||||
int internalVersion = 0;
|
int internalVersion = 0;
|
||||||
|
@ -162,7 +160,7 @@ public class Config
|
||||||
xmlReader.next();
|
xmlReader.next();
|
||||||
if(xmlReader.isStartElement())
|
if(xmlReader.isStartElement())
|
||||||
{
|
{
|
||||||
ignoreBattleTypes.add(Category.fromString(xmlReader.getLocalName()));
|
ignoreBattleTypes.add(xmlReader.getLocalName().toLowerCase());
|
||||||
}
|
}
|
||||||
} while(!(xmlReader.isEndElement() && xmlReader.getLocalName().equals("IgnoreBattleTypes")));
|
} while(!(xmlReader.isEndElement() && xmlReader.getLocalName().equals("IgnoreBattleTypes")));
|
||||||
}
|
}
|
||||||
|
@ -272,7 +270,7 @@ public class Config
|
||||||
}
|
}
|
||||||
else if(xmlReader.getLocalName().equals("Category"))
|
else if(xmlReader.getLocalName().equals("Category"))
|
||||||
{
|
{
|
||||||
eInfo.category = Category.fromString(xmlReader.getElementText());
|
eInfo.category = xmlReader.getElementText().toLowerCase();
|
||||||
}
|
}
|
||||||
else if(xmlReader.getLocalName().equals("Conflicts"))
|
else if(xmlReader.getLocalName().equals("Conflicts"))
|
||||||
{
|
{
|
||||||
|
@ -453,7 +451,7 @@ public class Config
|
||||||
return configVersion;
|
return configVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIgnoreBattleType(Category type)
|
public boolean isIgnoreBattleType(String type)
|
||||||
{
|
{
|
||||||
return ignoreBattleTypes.contains(type);
|
return ignoreBattleTypes.contains(type);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,45 +21,11 @@ public class EntityInfo
|
||||||
public int defenseDamageProbability;
|
public int defenseDamageProbability;
|
||||||
public int evasion;
|
public int evasion;
|
||||||
public int speed;
|
public int speed;
|
||||||
public Category category;
|
public String category;
|
||||||
public int decisionAttack;
|
public int decisionAttack;
|
||||||
public int decisionDefend;
|
public int decisionDefend;
|
||||||
public int decisionFlee;
|
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
|
public enum Effect
|
||||||
{
|
{
|
||||||
SPEED,
|
SPEED,
|
||||||
|
@ -355,7 +321,7 @@ public class EntityInfo
|
||||||
defenseDamageProbability = 0;
|
defenseDamageProbability = 0;
|
||||||
evasion = 15;
|
evasion = 15;
|
||||||
speed = 50;
|
speed = 50;
|
||||||
category = Category.UNKNOWN;
|
category = "unknown";
|
||||||
decisionAttack = 70;
|
decisionAttack = 70;
|
||||||
decisionDefend = 20;
|
decisionDefend = 20;
|
||||||
decisionFlee = 10;
|
decisionFlee = 10;
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
<TurnBasedMinecraftConfig>
|
<TurnBasedMinecraftConfig>
|
||||||
<!-- If the mod has a newer version config, it will rename the existing config and place the new config -->
|
<!-- If the mod has a newer version config, it will rename the existing config and place the new config -->
|
||||||
<Version>1</Version>
|
<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>
|
<IgnoreBattleTypes>
|
||||||
<Passive></Passive>
|
<Passive></Passive>
|
||||||
<Boss></Boss>
|
<Boss></Boss>
|
||||||
</IgnoreBattleTypes>
|
</IgnoreBattleTypes>
|
||||||
<PlayerStats>
|
<PlayerStats>
|
||||||
<Speed>50</Speed>
|
<Speed>50</Speed>
|
||||||
<HasteSpeed>80</HasteSpeed>
|
<HasteSpeed>80</HasteSpeed> <!-- Speed used if the player entity has "speed" or "haste" effects -->
|
||||||
<SlowSpeed>20</SlowSpeed>
|
<SlowSpeed>20</SlowSpeed> <!-- Speed used if the player entity has "slow" effect -->
|
||||||
<AttackProbability>90</AttackProbability>
|
<AttackProbability>90</AttackProbability>
|
||||||
<Evasion>10</Evasion>
|
<Evasion>10</Evasion>
|
||||||
</PlayerStats>
|
</PlayerStats>
|
||||||
|
@ -24,6 +25,7 @@
|
||||||
<!-- AttackEffect: (Optional) Applies effect to target entity with "Probability" success rate. -->
|
<!-- AttackEffect: (Optional) Applies effect to target entity with "Probability" success rate. -->
|
||||||
<!-- DefenseDamage: (Optional) Applies damage to an attacker when attacked 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. -->
|
<!-- 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). -->
|
<!-- 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. -->
|
<!-- 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. -->
|
<!-- Category: Sets the type of the entity, used by "IgnoreBattleTypes" to determine what types ignore battle. -->
|
||||||
|
|
Loading…
Reference in a new issue