Skip to content

Commit

Permalink
Merge pull request #42 from Goosius1/remove_leadership_aura
Browse files Browse the repository at this point in the history
Remove leadership aura feature
  • Loading branch information
Goosius1 authored Jan 16, 2021
2 parents b0476c8 + 7b1cd2f commit 6abc704
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 138 deletions.
19 changes: 0 additions & 19 deletions src/main/java/com/gmail/goosius/siegewar/settings/ConfigNodes.java
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,6 @@ public enum ConfigNodes {
"16",
"",
"# This is the vertical distance a soldier must be from the banner to get banner control."),
WAR_SIEGE_LEADERSHIP_AURA_RADIUS_BLOCKS(
"war.siege.distances.leadership_aura_radius_blocks",
"50",
"",
"# This setting determines the size of the 'Military Leadership Aura'.",
"# The aura emanates from kings, generals, and captains.",
"# The aura decreases death point losses for nearby nation/allied soldiers in a siege.",
"# The aura increases death point gains for nearby enemy soldiers in a siege."),

//Siege points
WAR_SIEGE_POINTS_FOR_ATTACKER_OCCUPATION(
Expand Down Expand Up @@ -329,17 +321,6 @@ public enum ConfigNodes {
"# Configuration Outcomes:",
"# Value HIGH --> If the value is high, then PVP will be DISCOURAGED",
"# Value LOW --> If the value is low, then PVP will be ENCOURAGED"),
WAR_SIEGE_POINTS_PERCENTAGE_ADJUSTMENT_FOR_LEADER_PROXIMITY(
"war.siege.scoring.percentage_adjustment_for_leader_proximity",
"10",
"",
"# If a friendly military leader is nearby when a soldier dies in a siege, then points loss is reduced by this percentage.",
"# If an enemy military leader is nearby when a soldier dies in a siege, then points loss is increased by this percentage."),
WAR_SIEGE_POINTS_PERCENTAGE_ADJUSTMENT_FOR_LEADER_DEATH(
"war.siege.scoring.percentage_adjustment_for_leader_death",
"50",
"",
"# If a military leader dies in a siege, then points loss in increased by this percentage."),
WAR_SIEGE_POPULATION_QUOTIENT_FOR_MAX_POINTS_BOOST(
"war.siege.scoring.population_quotient_for_max_points_boost",
"3.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,18 +169,6 @@ public static int getWarSiegeExtraMoneyPercentagePerTownLevel() {
return Settings.getInt(ConfigNodes.WAR_SIEGE_EXTRA_MONEY_PERCENTAGE_PER_TOWN_LEVEL);
}

public static double getWarSiegePointsPercentageAdjustmentForLeaderProximity() {
return Settings.getInt(ConfigNodes.WAR_SIEGE_POINTS_PERCENTAGE_ADJUSTMENT_FOR_LEADER_PROXIMITY);
}

public static double getWarSiegePointsPercentageAdjustmentForLeaderDeath() {
return Settings.getInt(ConfigNodes.WAR_SIEGE_POINTS_PERCENTAGE_ADJUSTMENT_FOR_LEADER_DEATH);
}

public static int getWarSiegeLeadershipAuraRadiusBlocks() {
return Settings.getInt(ConfigNodes.WAR_SIEGE_LEADERSHIP_AURA_RADIUS_BLOCKS);
}

public static boolean getWarSiegeTacticalVisibilityEnabled() {
return Settings.getBoolean(ConfigNodes.WAR_SIEGE_TACTICAL_VISIBILITY_ENABLED);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,6 @@ public static boolean isInSiegeZone(Entity entity, Siege siege) {
return areLocationsCloseHorizontally(entity.getLocation(), siege.getFlagLocation(), SiegeWarSettings.getWarSiegeZoneRadiusBlocks());
}

public static boolean isCloseToLeader(Player player1, Player player2) {
return areLocationsClose(player1.getLocation(), player2.getLocation(), SiegeWarSettings.getWarSiegeLeadershipAuraRadiusBlocks());
}

public static boolean isInTimedPointZone(Entity entity, Siege siege) {
return areLocationsClose(entity.getLocation(), siege.getFlagLocation(), SiegeWarSettings.getBannerControlHorizontalDistanceBlocks(), SiegeWarSettings.getBannerControlVerticalDistanceBlocks());
}
Expand Down Expand Up @@ -183,13 +179,6 @@ private static boolean areCoordsClose(TownyWorld world1, Coord coord1, TownyWorl
return distanceTownblocks < radiusTownblocks;
}

private static boolean areLocationsClose(Location location1, Location location2, int radius) {
if(!location1.getWorld().getName().equalsIgnoreCase(location2.getWorld().getName()))
return false;

return location1.distance(location2) < radius;
}

private static boolean areLocationsClose(Location location1, Location location2, int maxHorizontalDistance, int maxVerticalDistance) {
if(!location1.getWorld().getName().equalsIgnoreCase(location2.getWorld().getName()))
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,11 @@ public static void awardPenaltyPoints(boolean residentIsAttacker,
if (residentIsAttacker) {
siegePoints = -SiegeWarSettings.getWarSiegePointsForAttackerDeath();
siegePoints = adjustSiegePointPenaltyForBannerControl(true, siegePoints, siege);
siegePoints = adjustSiegePenaltyPointsForMilitaryLeadership(true, siegePoints, player, resident, siege);
siegePoints = adjustSiegePointsForPopulationQuotient(false, siegePoints, siege);
siege.adjustSiegePoints(siegePoints);
} else {
siegePoints = SiegeWarSettings.getWarSiegePointsForDefenderDeath();
siegePoints = adjustSiegePointPenaltyForBannerControl(false, siegePoints, siege);
siegePoints = adjustSiegePenaltyPointsForMilitaryLeadership(false, siegePoints, player, resident, siege);
siegePoints = adjustSiegePointsForPopulationQuotient(true, siegePoints, siege);
siege.adjustSiegePoints(siegePoints);
}
Expand All @@ -103,100 +101,6 @@ public static void awardPenaltyPoints(boolean residentIsAttacker,
SiegeWarNotificationUtil.informSiegeParticipants(siege, message);
}

private static int adjustSiegePenaltyPointsForMilitaryLeadership(boolean residentIsAttacker,
double siegePoints,
Player player,
Resident resident,
Siege siege) {
try {
TownyUniverse universe = TownyUniverse.getInstance();

//Resident town has nation
if(resident.getTown().hasNation()) {

if(universe.getPermissionSource().testPermission(resident.getPlayer(), SiegeWarPermissionNodes.SIEGEWAR_NATION_SIEGE_LEADERSHIP.getNode())) {
//Player is Leader. Apply points increase
double modifier = 1 + (SiegeWarSettings.getWarSiegePointsPercentageAdjustmentForLeaderDeath() / 100);
return (int)(siegePoints * modifier);

} else {
//Player is not leader
if(player == null) {
//Player is null. Apply points increase regardless of player location/online/offline, to avoid exploits
double modifier = 1 + (SiegeWarSettings.getWarSiegePointsPercentageAdjustmentForLeaderProximity() / 100);
return (int)(siegePoints * modifier);
} else {
//Player is online. Look for nearby friendly/hostile leaders
Resident otherResident;
boolean friendlyLeaderNearby = false;
boolean hostileLeaderNearby = false;

for (Player otherPlayer : BukkitTools.getOnlinePlayers()) {
if (friendlyLeaderNearby && hostileLeaderNearby)
break;

otherResident = universe.getResident(otherPlayer.getUniqueId());
if (otherResident == null)
continue;

//Look for friendly military leader
if (!friendlyLeaderNearby) {
if (otherResident.hasTown()
&& otherResident.hasNation()
&& universe.getPermissionSource().testPermission(otherResident.getPlayer(), SiegeWarPermissionNodes.SIEGEWAR_NATION_SIEGE_LEADERSHIP.getNode())
&& (otherResident.getTown().getNation() == resident.getTown().getNation() || otherResident.getTown().getNation().hasMutualAlly(resident.getTown().getNation()))
&& SiegeWarDistanceUtil.isCloseToLeader(player, otherPlayer)) {
friendlyLeaderNearby = true;
continue;
}
}

//As attacker, look for hostile military leader
if (!hostileLeaderNearby && residentIsAttacker) {
if (otherResident.hasTown()
&& otherResident.getTown().hasNation()
&& siege.getDefendingTown().hasNation()
&& universe.getPermissionSource().testPermission(otherResident.getPlayer(), SiegeWarPermissionNodes.SIEGEWAR_NATION_SIEGE_LEADERSHIP.getNode())
&& (otherResident.getTown().getNation() == siege.getDefendingTown().getNation() || otherResident.getTown().getNation().hasMutualAlly(siege.getDefendingTown().getNation()))
&& SiegeWarDistanceUtil.isCloseToLeader(player, otherPlayer)) {
hostileLeaderNearby = true;
continue;
}
}

//As defender, look for hostile military leader
if (!hostileLeaderNearby && !residentIsAttacker) {
if (otherResident.hasTown()
&& otherResident.getTown().hasNation()
&& universe.getPermissionSource().testPermission(otherResident.getPlayer(), SiegeWarPermissionNodes.SIEGEWAR_NATION_SIEGE_LEADERSHIP.getNode())
&& (otherResident.getTown().getNation() == siege.getAttackingNation() || otherResident.getTown().getNation().hasMutualAlly(siege.getAttackingNation()))
&& SiegeWarDistanceUtil.isCloseToLeader(player, otherPlayer)) {
hostileLeaderNearby = true;
continue;
}
}
}

if (friendlyLeaderNearby && !hostileLeaderNearby) {
//Friendly leader nearby. Apply points decrease
double modifier = 1 - (SiegeWarSettings.getWarSiegePointsPercentageAdjustmentForLeaderProximity() / 100);
return (int) (siegePoints * modifier);
} else if (hostileLeaderNearby && !friendlyLeaderNearby) {
//Enemy leader nearby. Apply points increase
double modifier = 1 + (SiegeWarSettings.getWarSiegePointsPercentageAdjustmentForLeaderProximity() / 100);
return (int) (siegePoints * modifier);
}
}
}
}
} catch (Exception e) {
System.out.println("Problem adjusting siege point penalty for military leadership");
e.printStackTrace();
}

return (int)siegePoints;
}

public static void updatePopulationBasedSiegePointModifiers() {
Map<Nation,Integer> nationSidePopulationsCache = new HashMap<>();
for (Siege siege : SiegeController.getSieges()) {
Expand Down

0 comments on commit 6abc704

Please sign in to comment.