Looking for help: I want to make Ballistic Range Finder work for small ships too
I have extracted the .class and changed it to a java and added frigate to the classes of ship that can use the ballistic range finder. When I try to load the game I get an error message
Spoiler
package data.hullmods;
import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.WeaponAPI;
//myone removed import com.fs.starfarer.api.impl.hullmods.BallisticRangefinder;
import com.fs.starfarer.api.loading.WeaponSlotAPI;
import com.fs.starfarer.api.ui.Alignment;
import com.fs.starfarer.api.ui.TooltipMakerAPI;
import com.fs.starfarer.api.util.Misc;
import java.awt.Color;
public class BallisticRangefinder extends BaseHullMod {
public static float BONUS_MAX_1 = 800.0F;
public static float BONUS_MAX_2 = 800.0F;
public static float BONUS_MAX_3 = 900.0F;
public static float BONUS_SMALL_1 = 100.0F;
public static float BONUS_SMALL_2 = 100.0F;
public static float BONUS_SMALL_3 = 200.0F;
public static float BONUS_MEDIUM_3 = 100.0F;
public static float HYBRID_MULT = 2.0F;
public static float HYBRID_BONUS_MIN = 100.0F;
public void applyEffectsBeforeShipCreation(ShipAPI.HullSize hullSize, MutableShipStatsAPI stats, String id) {}
public static WeaponAPI.WeaponSize getLargestBallisticSlot(ShipAPI ship) {
if (ship == null)
return null;
WeaponAPI.WeaponSize largest = null;
for (WeaponSlotAPI slot : ship.getHullSpec().getAllWeaponSlotsCopy()) {
if (!slot.isDecorative() &&
slot.getWeaponType() == WeaponAPI.WeaponType.BALLISTIC && (
largest == null || largest.ordinal() < slot.getSlotSize().ordinal()))
largest = slot.getSlotSize();
}
return largest;
}
public void applyEffectsAfterShipCreation(ShipAPI ship, String id) {
WeaponAPI.WeaponSize largest = getLargestBallisticSlot(ship);
if (largest == null)
return;
float small = 0.0F;
float medium = 0.0F;
float max = 0.0F;
switch (largest) {
case null:
small = BONUS_SMALL_3;
medium = BONUS_MEDIUM_3;
max = BONUS_MAX_3;
break;
case MEDIUM:
small = BONUS_SMALL_2;
max = BONUS_MAX_2;
break;
case SMALL:
small = BONUS_SMALL_1;
max = BONUS_MAX_1;
break;
}
ship.addListener(new RangefinderRangeModifier(small, medium, max));
}
public String getDescriptionParam(int index, ShipAPI.HullSize hullSize) {
return null;
}
public boolean shouldAddDescriptionToTooltip(ShipAPI.HullSize hullSize, ShipAPI ship, boolean isForModSpec) {
return false;
}
public void addPostDescriptionSection(TooltipMakerAPI tooltip, ShipAPI.HullSize hullSize, ShipAPI ship, float width, boolean isForModSpec) {
float pad = 3.0F;
float opad = 10.0F;
Color h = Misc.getHighlightColor();
Color bad = Misc.getNegativeHighlightColor();
Color t = Misc.getTextColor();
Color g = Misc.getGrayColor();
WeaponAPI.WeaponSize largest = getLargestBallisticSlot(ship);
tooltip.addPara("Utilizes targeting data from the ship's largest ballistic slot to benefit certain weapons, extending the base range of typical ballistic weapons to match similar but larger weapons. Also benefits hybrid weapons. Point-defense weapons are unaffected.",
opad, h, new String[] { "ship's largest ballistic slot", "base range" });
tooltip.addPara("The range bonus is based on the size of the largest ballistic slot, and the increased base range is capped, but still subject to other modifiers.",
opad);
tooltip.addSectionHeading("Ballistic weapon range", Alignment.MID, opad);
tooltip.addPara("Affects small and medium ballistic weapons.", opad);
float col1W = 120.0F;
float colW = (int)((width - col1W - 12.0F) / 3.0F);
float lastW = colW;
tooltip.beginTable(Misc.getBasePlayerColor(), Misc.getDarkPlayerColor(), Misc.getBrightPlayerColor(),
20.0F, true, true,
new Object[] { "Largest b. slot", Float.valueOf(col1W), "Small wpn", Float.valueOf(colW), "Medium wpn", Float.valueOf(colW), "Range cap", Float.valueOf(lastW) });
Color c = null;
if (largest == WeaponAPI.WeaponSize.SMALL) {
c = h;
} else if (largest == WeaponAPI.WeaponSize.MEDIUM) {
c = h;
} else {
c = g;
}
tooltip.addRow(new Object[] {
Alignment.MID, c, "Small / Medium",
Alignment.MID, c, "+" + (int)BONUS_SMALL_1,
Alignment.MID, g, "---",
Alignment.MID,
c, (int)BONUS_MAX_1 });
if (largest == WeaponAPI.WeaponSize.LARGE) {
c = h;
} else {
c = g;
}
tooltip.addRow(new Object[] {
Alignment.MID, c, "Large",
Alignment.MID, c, "+" + (int)BONUS_SMALL_3,
Alignment.MID, c, "+" + (int)BONUS_MEDIUM_3,
Alignment.MID,
c, (int)BONUS_MAX_3 });
tooltip.addTable("", 0, opad);
tooltip.addSectionHeading("Hybrid weapon range", Alignment.MID, opad + 7.0F);
tooltip.addPara("Affects hybrid weapons (those that can fit into both ballistic and energy slots) of all sizes.",
opad);
col1W = 120.0F;
colW = (int)((width - col1W - lastW - 15.0F) / 3.0F);
tooltip.beginTable(Misc.getBasePlayerColor(), Misc.getDarkPlayerColor(), Misc.getBrightPlayerColor(),
20.0F, true, true,
new Object[] { "Largest b. slot", Float.valueOf(col1W), "Small", Float.valueOf(colW), "Medium", Float.valueOf(colW), "Large", Float.valueOf(colW), "Range cap", Float.valueOf(lastW) });
c = null;
if (largest == WeaponAPI.WeaponSize.SMALL) {
c = h;
} else if (largest == WeaponAPI.WeaponSize.MEDIUM) {
c = h;
} else {
c = g;
}
tooltip.addRow(new Object[] {
Alignment.MID, c, "Small / Medium",
Alignment.MID, c, "+" + (int)(BONUS_SMALL_1 * HYBRID_MULT),
Alignment.MID, c, "+" + (int)HYBRID_BONUS_MIN,
Alignment.MID,
c, "+" + (int)HYBRID_BONUS_MIN,
Alignment.MID, c, (int)BONUS_MAX_1 });
if (largest == WeaponAPI.WeaponSize.LARGE) {
c = h;
} else {
c = g;
}
tooltip.addRow(new Object[] {
Alignment.MID, c, "Large",
Alignment.MID, c, "+" + (int)(BONUS_SMALL_3 * HYBRID_MULT),
Alignment.MID, c, "+" + (int)(BONUS_MEDIUM_3 * HYBRID_MULT),
Alignment.MID,
c, "+" + (int)HYBRID_BONUS_MIN,
Alignment.MID, c, (int)BONUS_MAX_3 });
tooltip.addTable("", 0, opad);
tooltip.addSectionHeading("Interactions with other modifiers", Alignment.MID, opad + 7.0F);
tooltip.addPara("Since the base range is increased, this modifier - unlike most other flat modifiers - is increased by percentage modifiers from other hullmods and skills.",
opad);
}
public float getTooltipWidth() {
return 412.0F;
}
public boolean isApplicableToShip(ShipAPI ship) {
WeaponAPI.WeaponSize largest = getLargestBallisticSlot(ship);
if (ship != null && largest == null)
return false;
return (getUnapplicableReason(ship) == null);
}
public String getUnapplicableReason(ShipAPI ship) {
WeaponAPI.WeaponSize largest = getLargestBallisticSlot(ship);
if (ship != null && largest == null)
return "Ship has no ballistic weapon slots";
if (ship != null &&
ship.getHullSize() != ShipAPI.HullSize.CAPITAL_SHIP &&
ship.getHullSize() != ShipAPI.HullSize.DESTROYER &&
ship.getHullSize() != ShipAPI.HullSize.CRUISER &&
ship.getHullSize() != ShipAPI.HullSize.FRIGATE)
return "Can only be installed on destroyer-class hulls and larger";
return null;
}
}
Also I want to make a hullmod that regenerates ammo. Maybe 25% per 3 minutes or a set amount. No idea how to do this. Anyone able to help me?