Change how silly music is triggered

Can now specify in config what minimum percentage of silly entities
trigger silly music in battle.
This commit is contained in:
Stephen Seo 2018-09-28 12:02:39 +09:00
parent c2c19f6af2
commit bb8ebf561b
5 changed files with 41 additions and 2 deletions

View file

@ -181,7 +181,21 @@ public class ClientProxy extends CommonProxy
private void checkBattleTypes() private void checkBattleTypes()
{ {
if(battleMusicCount <= 1 && sillyMusicCount > 0) float percentage = 0.0f;
if(sillyMusicCount == 0 && battleMusicCount == 0)
{
percentage = 0.0f;
}
else if(battleMusicCount == 0)
{
percentage = 100.0f;
}
else
{
percentage = 100.0f * (float)sillyMusicCount / (float)(sillyMusicCount + battleMusicCount);
}
if(percentage >= (float)TurnBasedMinecraftMod.getConfig().getSillyMusicThreshold())
{ {
if(battleMusic.isPlaying()) if(battleMusic.isPlaying())
{ {

View file

@ -142,7 +142,7 @@ public class BattleManager
// battle limit reached, cannot add to battle // battle limit reached, cannot add to battle
return true; return true;
} }
if(battle.hasCombatantInSideA(inBattle.getEntityId())) else if(battle.hasCombatantInSideA(inBattle.getEntityId()))
{ {
battle.addCombatantToSideB(notInBattle); battle.addCombatantToSideB(notInBattle);
} }

View file

@ -38,6 +38,7 @@ public class Config
private Set<String> musicBattleTypes; private Set<String> musicBattleTypes;
private Set<String> musicSillyTypes; private Set<String> musicSillyTypes;
private boolean freezeCombatantsInBattle = false; private boolean freezeCombatantsInBattle = false;
private int sillyMusicThreshold = 40;
public Config(Logger logger) public Config(Logger logger)
{ {
@ -277,6 +278,18 @@ public class Config
TurnBasedMinecraftMod.setBattleDurationSeconds(TurnBasedMinecraftMod.BATTLE_DECISION_DURATION_NANO_DEFAULT / 1000000000L); TurnBasedMinecraftMod.setBattleDurationSeconds(TurnBasedMinecraftMod.BATTLE_DECISION_DURATION_NANO_DEFAULT / 1000000000L);
} }
} }
else if(xmlReader.getLocalName().equals("SillyMusicThreshold"))
{
sillyMusicThreshold = Integer.parseInt(xmlReader.getElementText());
if(sillyMusicThreshold < 0)
{
sillyMusicThreshold = 0;
}
else if(sillyMusicThreshold > 100)
{
sillyMusicThreshold = 100;
}
}
else if(xmlReader.getLocalName().equals("EntityEntry")) else if(xmlReader.getLocalName().equals("EntityEntry"))
{ {
EntityInfo eInfo = new EntityInfo(); EntityInfo eInfo = new EntityInfo();
@ -521,4 +534,9 @@ public class Config
{ {
return freezeCombatantsInBattle; return freezeCombatantsInBattle;
} }
public int getSillyMusicThreshold()
{
return sillyMusicThreshold;
}
} }

View file

@ -165,4 +165,9 @@ public class TurnBasedMinecraftMod
BATTLE_DECISION_DURATION_NANOSECONDS = BATTLE_DECISION_DURATION_NANO_MAX; BATTLE_DECISION_DURATION_NANOSECONDS = BATTLE_DECISION_DURATION_NANO_MAX;
} }
} }
public static Config getConfig()
{
return config;
}
} }

View file

@ -40,6 +40,8 @@
<MinimumHitPercentage>4</MinimumHitPercentage> <MinimumHitPercentage>4</MinimumHitPercentage>
<!-- Number of seconds to wait in battle for all players to make a decision. Minimum of 5 and maximum of 60. --> <!-- Number of seconds to wait in battle for all players to make a decision. Minimum of 5 and maximum of 60. -->
<BattleTurnTimeSeconds>15</BattleTurnTimeSeconds> <BattleTurnTimeSeconds>15</BattleTurnTimeSeconds>
<!-- Minimum percentage of silly entities in battle to use silly music -->
<SillyMusicThreshold>40</SillyMusicThreshold>
<!-- Battle stats for entities should be specified here. If an entity is not listed it cannot enter battle. --> <!-- Battle stats for entities should be specified here. If an entity is not listed it cannot enter battle. -->
<!-- Name: The full class name of an entity. --> <!-- Name: The full class name of an entity. -->