package data.hullmods;
import java.util.HashMap;
import java.util.Map;
import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
public class PT_CenturionDrive extends BaseHullMod {
public static final float EMP_REDUCTION = 25f;
public static final float ENGINE_HEALTH_BONUS = 125f;
// public static final float ZERO_FLUX_SPEED_CAPITAL = 15f;
// public static final float ZERO_FLUX_SPEED_CRUISER = 20f;
// public static final float ZERO_FLUX_SPEED_DESTROYER = 25f;
// public static final float ZERO_FLUX_SPEED_FRIGATE = 35f;
// public static final float ZERO_FLUX_BONUS_CAPITAL = 0.05f;
// public static final float ZERO_FLUX_BONUS_CRUISER = 0.1f;
// public static final float ZERO_FLUX_BONUS_DESTROYER = 0.15f;
// public static final float ZERO_FLUX_BONUS_FRIGATE = 0.2f;
public static final float WEAPON_HEALTH_BONUS = 75f;
private static final Map ZeroFluxBonus = new HashMap();
static {
ZeroFluxBonus.put(HullSize.FRIGATE, 0.2f);
ZeroFluxBonus.put(HullSize.DESTROYER, 0.15f);
ZeroFluxBonus.put(HullSize.CRUISER, 0.1f);
ZeroFluxBonus.put(HullSize.CAPITAL_SHIP, 0.05f);
}
private static final Map ZeroFluxSpeed = new HashMap();
static {
ZeroFluxSpeed.put(HullSize.FRIGATE, 35f);
ZeroFluxSpeed.put(HullSize.DESTROYER, 25f);
ZeroFluxSpeed.put(HullSize.CRUISER, 20f);
ZeroFluxSpeed.put(HullSize.CAPITAL_SHIP, 15f);
}
@Override
public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
stats.getZeroFluxMinimumFluxLevel().modifyFlat(id, (Float) ZeroFluxBonus.get(hullSize));
stats.getZeroFluxSpeedBoost().modifyFlat(id, (Float) ZeroFluxSpeed.get(hullSize));
// if (hullSize == HullSize.FRIGATE || hullSize == HullSize.FIGHTER) {
// stats.getZeroFluxMinimumFluxLevel().modifyFlat(id, ZERO_FLUX_BONUS_FRIGATE);
// stats.getZeroFluxSpeedBoost().modifyFlat(id, ZERO_FLUX_SPEED_FRIGATE);
// } else if (hullSize == HullSize.DESTROYER) {
// stats.getZeroFluxMinimumFluxLevel().modifyFlat(id, ZERO_FLUX_BONUS_DESTROYER);
// stats.getZeroFluxSpeedBoost().modifyFlat(id, ZERO_FLUX_SPEED_DESTROYER);
// } else if (hullSize == HullSize.CRUISER) {
// stats.getZeroFluxMinimumFluxLevel().modifyFlat(id, ZERO_FLUX_BONUS_CRUISER);
// stats.getZeroFluxSpeedBoost().modifyPercent(id, ZERO_FLUX_SPEED_CRUISER);
// } else if (hullSize == HullSize.CAPITAL_SHIP) {
// stats.getZeroFluxMinimumFluxLevel().modifyFlat(id, ZERO_FLUX_BONUS_CAPITAL);
// stats.getZeroFluxSpeedBoost().modifyFlat(id, ZERO_FLUX_SPEED_CAPITAL);
// }
stats.getEmpDamageTakenMult().modifyPercent(id, -EMP_REDUCTION);
stats.getEngineHealthBonus().modifyPercent(id, ENGINE_HEALTH_BONUS);
stats.getWeaponHealthBonus().modifyPercent(id, WEAPON_HEALTH_BONUS);
}
@Override
public String getDescriptionParam(int index, HullSize hullSize) {
if (index == 0) return "" + ((Float) ZeroFluxBonus.get(HullSize.FRIGATE)).intValue();
if (index == 1) return "" + ((Float) ZeroFluxBonus.get(HullSize.DESTROYER)).intValue();
if (index == 2) return "" + ((Float) ZeroFluxBonus.get(HullSize.CRUISER)).intValue();
if (index == 3) return "" + ((Float) ZeroFluxBonus.get(HullSize.CAPITAL_SHIP)).intValue();
if (index == 4) return "" + ((Float) ZeroFluxSpeed.get(HullSize.FRIGATE)).intValue();
if (index == 5) return "" + ((Float) ZeroFluxSpeed.get(HullSize.DESTROYER)).intValue();
if (index == 6) return "" + ((Float) ZeroFluxSpeed.get(HullSize.CRUISER)).intValue();
if (index == 7) return "" + ((Float) ZeroFluxSpeed.get(HullSize.CAPITAL_SHIP)).intValue();
// if (index == 0) {
// return "" + (int) ZERO_FLUX_BONUS_FRIGATE + "/" + (int) ZERO_FLUX_BONUS_DESTROYER + "/" + (int) ZERO_FLUX_BONUS_CRUISER + "/" + (int) ZERO_FLUX_BONUS_CAPITAL;
// } if (index == 1) {
// return "" + (int) ZERO_FLUX_SPEED_FRIGATE + "/" + (int) ZERO_FLUX_SPEED_DESTROYER + "/" + (int) ZERO_FLUX_SPEED_CRUISER + "/" + (int) ZERO_FLUX_SPEED_CAPITAL;
if (index == 8) return "" + (int) EMP_REDUCTION + "%";
if (index == 9) return "" + (int) ENGINE_HEALTH_BONUS + "%";
if (index == 10) return "" + (int) WEAPON_HEALTH_BONUS + "%";
return null;
}
}
if (hullSize.equals(HullSize.CRUISER)) {}
if (hullSize == HullSize.CRUISER) {}
Well, I'm kinda shy asking the forums themselves for information that I need to get stuff done, but I'm starting to get a little bothered with this error I got, despite of having Netbeans to work with the hullmod.
I received after adding the hullmod into my... mod.
This is what I get:
Fatal: Error compiling [data.hullmods.pt_centuriondrive]
Cause: Parsing compilation unit "com.fs.starfarer.loading.A$1@1a7e777"
I tried using two separate numeral techniques for the Zero Flux attribute but it doesn't to work for some reason.
This is the code I have.SpoilerQuotepackage data.hullmods;
import java.util.HashMap;
import java.util.Map;
import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
public class PT_CenturionDrive extends BaseHullMod {
public static final float EMP_REDUCTION = 25f;
public static final float ENGINE_HEALTH_BONUS = 125f;
// public static final float ZERO_FLUX_SPEED_CAPITAL = 15f;
// public static final float ZERO_FLUX_SPEED_CRUISER = 20f;
// public static final float ZERO_FLUX_SPEED_DESTROYER = 25f;
// public static final float ZERO_FLUX_SPEED_FRIGATE = 35f;
// public static final float ZERO_FLUX_BONUS_CAPITAL = 0.05f;
// public static final float ZERO_FLUX_BONUS_CRUISER = 0.1f;
// public static final float ZERO_FLUX_BONUS_DESTROYER = 0.15f;
// public static final float ZERO_FLUX_BONUS_FRIGATE = 0.2f;
public static final float WEAPON_HEALTH_BONUS = 75f;
private static final Map ZeroFluxBonus = new HashMap();
static {
ZeroFluxBonus.put(HullSize.FRIGATE, 0.2f);
ZeroFluxBonus.put(HullSize.DESTROYER, 0.15f);
ZeroFluxBonus.put(HullSize.CRUISER, 0.1f);
ZeroFluxBonus.put(HullSize.CAPITAL_SHIP, 0.05f);
}
private static final Map ZeroFluxSpeed = new HashMap();
static {
ZeroFluxSpeed.put(HullSize.FRIGATE, 35f);
ZeroFluxSpeed.put(HullSize.DESTROYER, 25f);
ZeroFluxSpeed.put(HullSize.CRUISER, 20f);
ZeroFluxSpeed.put(HullSize.CAPITAL_SHIP, 15f);
}
@Override
public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
stats.getZeroFluxMinimumFluxLevel().modifyFlat(id, (Float) ZeroFluxBonus.get(hullSize));
stats.getZeroFluxSpeedBoost().modifyFlat(id, (Float) ZeroFluxSpeed.get(hullSize));
// if (hullSize == HullSize.FRIGATE || hullSize == HullSize.FIGHTER) {
// stats.getZeroFluxMinimumFluxLevel().modifyFlat(id, ZERO_FLUX_BONUS_FRIGATE);
// stats.getZeroFluxSpeedBoost().modifyFlat(id, ZERO_FLUX_SPEED_FRIGATE);
// } else if (hullSize == HullSize.DESTROYER) {
// stats.getZeroFluxMinimumFluxLevel().modifyFlat(id, ZERO_FLUX_BONUS_DESTROYER);
// stats.getZeroFluxSpeedBoost().modifyFlat(id, ZERO_FLUX_SPEED_DESTROYER);
// } else if (hullSize == HullSize.CRUISER) {
// stats.getZeroFluxMinimumFluxLevel().modifyFlat(id, ZERO_FLUX_BONUS_CRUISER);
// stats.getZeroFluxSpeedBoost().modifyPercent(id, ZERO_FLUX_SPEED_CRUISER);
// } else if (hullSize == HullSize.CAPITAL_SHIP) {
// stats.getZeroFluxMinimumFluxLevel().modifyFlat(id, ZERO_FLUX_BONUS_CAPITAL);
// stats.getZeroFluxSpeedBoost().modifyFlat(id, ZERO_FLUX_SPEED_CAPITAL);
// }
stats.getEmpDamageTakenMult().modifyPercent(id, -EMP_REDUCTION);
stats.getEngineHealthBonus().modifyPercent(id, ENGINE_HEALTH_BONUS);
stats.getWeaponHealthBonus().modifyPercent(id, WEAPON_HEALTH_BONUS);
}
@Override
public String getDescriptionParam(int index, HullSize hullSize) {
if (index == 0) return "" + ((Float) ZeroFluxBonus.get(HullSize.FRIGATE)).intValue();
if (index == 1) return "" + ((Float) ZeroFluxBonus.get(HullSize.DESTROYER)).intValue();
if (index == 2) return "" + ((Float) ZeroFluxBonus.get(HullSize.CRUISER)).intValue();
if (index == 3) return "" + ((Float) ZeroFluxBonus.get(HullSize.CAPITAL_SHIP)).intValue();
if (index == 4) return "" + ((Float) ZeroFluxSpeed.get(HullSize.FRIGATE)).intValue();
if (index == 5) return "" + ((Float) ZeroFluxSpeed.get(HullSize.DESTROYER)).intValue();
if (index == 6) return "" + ((Float) ZeroFluxSpeed.get(HullSize.CRUISER)).intValue();
if (index == 7) return "" + ((Float) ZeroFluxSpeed.get(HullSize.CAPITAL_SHIP)).intValue();
// if (index == 0) {
// return "" + (int) ZERO_FLUX_BONUS_FRIGATE + "/" + (int) ZERO_FLUX_BONUS_DESTROYER + "/" + (int) ZERO_FLUX_BONUS_CRUISER + "/" + (int) ZERO_FLUX_BONUS_CAPITAL;
// } if (index == 1) {
// return "" + (int) ZERO_FLUX_SPEED_FRIGATE + "/" + (int) ZERO_FLUX_SPEED_DESTROYER + "/" + (int) ZERO_FLUX_SPEED_CRUISER + "/" + (int) ZERO_FLUX_SPEED_CAPITAL;
if (index == 8) return "" + (int) EMP_REDUCTION + "%";
if (index == 9) return "" + (int) ENGINE_HEALTH_BONUS + "%";
if (index == 10) return "" + (int) WEAPON_HEALTH_BONUS + "%";
return null;
}
}[close]
So, yeah.
Edit: I didn't expect the Emoticon to pop out of the index.
Not sure if it was an artifact of copy/pasting through these forums, but there were a number of illegal white space characters in your source. (no-break spaces)
package data.hullmods.pt_centuriondrive;
import java.util.HashMap;
import java.util.Map;
import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
public class PT_CenturionDrive extends BaseHullMod {
public static final float EMP_REDUCTION = 25f;
public static final float ENGINE_HEALTH_BONUS = 125f;
// public static final float ZERO_FLUX_SPEED_CAPITAL = 15f;
// public static final float ZERO_FLUX_SPEED_CRUISER = 20f;
// public static final float ZERO_FLUX_SPEED_DESTROYER = 25f;
// public static final float ZERO_FLUX_SPEED_FRIGATE = 35f;
// public static final float ZERO_FLUX_BONUS_CAPITAL = 0.05f;
// public static final float ZERO_FLUX_BONUS_CRUISER = 0.1f;
// public static final float ZERO_FLUX_BONUS_DESTROYER = 0.15f;
// public static final float ZERO_FLUX_BONUS_FRIGATE = 0.2f;
public static final float WEAPON_HEALTH_BONUS = 75f;
private static final Map ZeroFluxBonus = new HashMap();
static {
ZeroFluxBonus.put(HullSize.FRIGATE, 0.2f);
ZeroFluxBonus.put(HullSize.DESTROYER, 0.15f);
ZeroFluxBonus.put(HullSize.CRUISER, 0.1f);
ZeroFluxBonus.put(HullSize.CAPITAL_SHIP, 0.05f);
}
private static final Map ZeroFluxSpeed = new HashMap();
static {
ZeroFluxSpeed.put(HullSize.FRIGATE, 35f);
ZeroFluxSpeed.put(HullSize.DESTROYER, 25f);
ZeroFluxSpeed.put(HullSize.CRUISER, 20f);
ZeroFluxSpeed.put(HullSize.CAPITAL_SHIP, 15f);
}
@Override
public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
// stats.getZeroFluxMinimumFluxLevel().modifyFlat(id, (Float) ZeroFluxBonus.get(hullSize));
// stats.getZeroFluxSpeedBoost().modifyFlat(id, (Float) ZeroFluxSpeed.get(hullSize));
// if (hullSize == HullSize.FRIGATE || hullSize == HullSize.FIGHTER) {
// stats.getZeroFluxMinimumFluxLevel().modifyFlat(id, ZERO_FLUX_BONUS_FRIGATE);
// stats.getZeroFluxSpeedBoost().modifyFlat(id, ZERO_FLUX_SPEED_FRIGATE);
// } else if (hullSize == HullSize.DESTROYER) {
// stats.getZeroFluxMinimumFluxLevel().modifyFlat(id, ZERO_FLUX_BONUS_DESTROYER);
// stats.getZeroFluxSpeedBoost().modifyFlat(id, ZERO_FLUX_SPEED_DESTROYER);
// } else if (hullSize == HullSize.CRUISER) {
// stats.getZeroFluxMinimumFluxLevel().modifyFlat(id, ZERO_FLUX_BONUS_CRUISER);
// stats.getZeroFluxSpeedBoost().modifyPercent(id, ZERO_FLUX_SPEED_CRUISER);
// } else if (hullSize == HullSize.CAPITAL_SHIP) {
// stats.getZeroFluxMinimumFluxLevel().modifyFlat(id, ZERO_FLUX_BONUS_CAPITAL);
// stats.getZeroFluxSpeedBoost().modifyFlat(id, ZERO_FLUX_SPEED_CAPITAL);
// }
stats.getEmpDamageTakenMult().modifyPercent(id, -EMP_REDUCTION);
stats.getEngineHealthBonus().modifyPercent(id, ENGINE_HEALTH_BONUS);
stats.getWeaponHealthBonus().modifyPercent(id, WEAPON_HEALTH_BONUS);
}
@Override
public String getDescriptionParam(int index, HullSize hullSize) {
if (index == 0) return "" + (int) EMP_REDUCTION + "%";
if (index == 1) return "" + (int) ENGINE_HEALTH_BONUS + "%";
if (index == 2) return "" + (int) WEAPON_HEALTH_BONUS + "%";
// if (index == 0) return "" + ((int) ZeroFluxBonus.get(HullSize.FRIGATE)).intValue();
// if (index == 1) return "" + ((int) ZeroFluxBonus.get(HullSize.DESTROYER)).intValue();
// if (index == 2) return "" + ((int) ZeroFluxBonus.get(HullSize.CRUISER)).intValue();
// if (index == 3) return "" + ((int) ZeroFluxBonus.get(HullSize.CAPITAL_SHIP)).intValue();
// if (index == 4) return "" + ((int) ZeroFluxSpeed.get(HullSize.FRIGATE)).intValue();
// if (index == 5) return "" + ((int) ZeroFluxSpeed.get(HullSize.DESTROYER)).intValue();
// if (index == 6) return "" + ((int) ZeroFluxSpeed.get(HullSize.CRUISER)).intValue();
// if (index == 7) return "" + ((int) ZeroFluxSpeed.get(HullSize.CAPITAL_SHIP)).intValue();
// if (index == 0) {
// return "" + (int) ZERO_FLUX_BONUS_FRIGATE + "/" + (int) ZERO_FLUX_BONUS_DESTROYER + "/" + (int) ZERO_FLUX_BONUS_CRUISER + "/" + (int) ZERO_FLUX_BONUS_CAPITAL;
// } if (index == 1) {
// return "" + (int) ZERO_FLUX_SPEED_FRIGATE + "/" + (int) ZERO_FLUX_SPEED_DESTROYER + "/" + (int) ZERO_FLUX_SPEED_CRUISER + "/" + (int) ZERO_FLUX_SPEED_CAPITAL;
// if (index == 8) return "" + (int) EMP_REDUCTION + "%";
// if (index == 9) return "" + (int) ENGINE_HEALTH_BONUS + "%";
// if (index == 10) return "" + (int) WEAPON_HEALTH_BONUS + "%";
return null;
}
}
Syntax-wise your code is fine.
Suggestions:
1) You're using annotations ("@Override"); does the version of janino currently being used by Starfarer support them?
2) Does the file name of the .java file precisely match the class name? (the error message "data.hullmods.pt_centuriondrive" suggests that the case might be wrong)