001package com.fs.starfarer.api.impl.hullmods; 002 003import com.fs.starfarer.api.combat.BaseHullMod; 004import com.fs.starfarer.api.combat.MutableShipStatsAPI; 005import com.fs.starfarer.api.combat.ShipAPI; 006import com.fs.starfarer.api.combat.ShipAPI.HullSize; 007import com.fs.starfarer.api.impl.campaign.ids.Tags; 008 009public class DefensiveTargetingArray extends BaseHullMod { 010 011 public static float PD_DAMAGE_BONUS = 50f; 012 public static float SMOD_RANGE_BONUS = 100f; 013 014 015 @Override 016 public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) { 017 stats.getFighterWingRange().modifyMult(id, 0f); 018 } 019 020 @Override 021 public void applyEffectsToFighterSpawnedByShip(ShipAPI fighter, ShipAPI ship, String id) { 022 fighter.getMutableStats().getDamageToFighters().modifyFlat(id, PD_DAMAGE_BONUS / 100f); 023 fighter.getMutableStats().getDamageToMissiles().modifyFlat(id, PD_DAMAGE_BONUS / 100f); 024 025 boolean sMod = isSMod(ship); 026 if (sMod) { 027 fighter.getMutableStats().getBallisticWeaponRangeBonus().modifyFlat(id, SMOD_RANGE_BONUS); 028 fighter.getMutableStats().getEnergyWeaponRangeBonus().modifyFlat(id, SMOD_RANGE_BONUS); 029 } 030 031 if (fighter.getWing() != null && fighter.getWing().getSpec() != null) { 032 if (fighter.getWing().getSpec().isRegularFighter() || 033 fighter.getWing().getSpec().isAssault() || 034 fighter.getWing().getSpec().isBomber() || 035 fighter.getWing().getSpec().isInterceptor()) { 036 fighter.addTag(Tags.WING_STAY_IN_FRONT_OF_SHIP); 037 } 038 } 039 } 040 041 public String getSModDescriptionParam(int index, HullSize hullSize) { 042 if (index == 0) return "" + (int) SMOD_RANGE_BONUS + ""; 043 return null; 044 } 045 046 public String getDescriptionParam(int index, HullSize hullSize) { 047 if (index == 0) return "" + (int) PD_DAMAGE_BONUS + "%"; 048 return null; 049 } 050 051 public boolean isApplicableToShip(ShipAPI ship) { 052 int bays = (int) ship.getMutableStats().getNumFighterBays().getModifiedValue(); 053 return ship != null && bays > 0; 054 } 055 056 public String getUnapplicableReason(ShipAPI ship) { 057 return "Ship does not have fighter bays"; 058 } 059} 060 061 062 063