44 public void advance(
float amount, List<InputEventAPI> events) {
45 if (engine ==
null)
return;
46 if (engine.isPaused())
return;
51 ShipAPI playerShip = engine.getPlayerShip();
52 if (playerShip != prevPlayerShip) {
53 prevPlayerShip = playerShip;
63 int [] player = getTotalAndMaximum(engine.getFleetManager(0));
64 int [] enemy = getTotalAndMaximum(engine.getFleetManager(1));
67 if (player ==
null || enemy ==
null) {
73 if (engine.getFleetManager(0) ==
null || engine.getFleetManager(1) ==
null) {
81 float pTotal = player[0];
82 float pMax = player[1];
84 float eTotal = enemy[0];
85 float eMax = enemy[1];
108 int totalPenalty = (int) Math.round(Math.min(
BASE_MAXIMUM, pTotal + eTotal));
109 if (totalPenalty <= 0f)
return;
111 float ecmRatingToPenaltyMult = 1f;
113 float playerPenalty = (int) Math.min(eTotal * ecmRatingToPenaltyMult, eMax);
114 if (pTotal > 0 && playerPenalty > 0) {
115 float pMult = eTotal / (eTotal + pTotal);
116 playerPenalty *= pMult;
119 float enemyPenalty = (int) Math.min(pTotal * ecmRatingToPenaltyMult, pMax);
120 if (eTotal > 0 && enemyPenalty > 0) {
121 float eMult = pTotal / (eTotal + pTotal);
122 enemyPenalty *= eMult;
125 playerPenalty = Math.round(playerPenalty);
126 enemyPenalty = Math.round(enemyPenalty);
131 if (playerPenalty > 0) {
132 applyPenalty(engine.getFleetManager(0), playerPenalty, eMax);
135 if (eMax <= playerPenalty) sMax =
" (max)";
136 String title =
"Enemy ECM rating:" +
" " + (int) eTotal +
"%";
137 String data =
"-" + (int)playerPenalty +
"% weapon range" + sMax;
139 data =
"fully neutralized";
144 if (enemyPenalty > 0) {
145 applyPenalty(engine.getFleetManager(1), enemyPenalty, pMax);
148 if (pMax <= enemyPenalty) sMax =
" (max)";
149 String title =
"ECM rating:" +
" " + (int) pTotal +
"%";
150 String data =
"-" + (int)enemyPenalty +
"% enemy weapon range" + sMax;
152 data =
"fully neutralized";
154 engine.maintainStatusForPlayerShip(
KEY_STATUS, icon, title, data,
false);
157 if (playerPenalty > 0 && eMax > 0 && engine.getPlayerShip() !=
null) {
158 int eccm = 100 - (int) Math.round(engine.getPlayerShip().getMutableStats().getDynamic().getValue(Stats.ELECTRONIC_WARFARE_PENALTY_MOD, 100f));
159 if (eccm > 100) eccm = 100;
160 if (eccm < 0) eccm = 0;
164 engine.maintainStatusForPlayerShip(
KEY_STATUS2, icon,
"On-board ECCM",
"" + eccm +
"% enemy ecm neutralized",
false);
237 member.getShip().getMutableStats().getBallisticWeaponRangeBonus().modifyMult(
PENALTY_ID, 1f - currPenalty/100f);
238 member.getShip().getMutableStats().getEnergyWeaponRangeBonus().modifyMult(
PENALTY_ID, 1f - currPenalty/100f);
239 member.getShip().getMutableStats().getMissileWeaponRangeBonus().modifyMult(
PENALTY_ID, 1f - currPenalty/100f);
246 if (needsCleanup.contains(manager)) {
247 needsCleanup.remove(manager);
248 List<DeployedFleetMemberAPI> deployed = manager.getDeployedCopyDFM();
249 for (DeployedFleetMemberAPI member : deployed) {
250 if (member.isFighterWing())
continue;
251 if (member.getShip() ==
null)
continue;
253 member.getShip().getMutableStats().getBallisticWeaponRangeBonus().unmodify(
PENALTY_ID);
254 member.getShip().getMutableStats().getEnergyWeaponRangeBonus().unmodify(
PENALTY_ID);
255 member.getShip().getMutableStats().getMissileWeaponRangeBonus().unmodify(
PENALTY_ID);