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)
|
||||
{
|
||||
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())
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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. -->
|
||||
|
|
Loading…
Reference in a new issue