Starsector API
Loading...
Searching...
No Matches
DamagedWeaponMounts.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.hullmods;
2
3import com.fs.starfarer.api.combat.BaseHullMod;
4import com.fs.starfarer.api.combat.MutableShipStatsAPI;
5import com.fs.starfarer.api.combat.ShipAPI;
6import com.fs.starfarer.api.combat.ShipAPI.HullSize;
7import com.fs.starfarer.api.impl.campaign.ids.Stats;
8
9@SuppressWarnings("unchecked")
10public class DamagedWeaponMounts extends BaseHullMod {
11
12 public static float ROTATE_MULT = 0.75f;
13 public static float RECOIL_PERCENT = 30f;
14
15 public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
16 float effect = stats.getDynamic().getValue(Stats.DMOD_EFFECT_MULT);
17 float rotMult = ROTATE_MULT + (1f - ROTATE_MULT) * (1f - effect);
18
19 stats.getWeaponTurnRateBonus().modifyMult(id, rotMult);
20 stats.getBeamWeaponTurnRateBonus().modifyMult(id, rotMult);
21 stats.getMaxRecoilMult().modifyPercent(id, RECOIL_PERCENT * effect);
22 stats.getRecoilPerShotMult().modifyPercent(id, RECOIL_PERCENT * effect);
23
24 CompromisedStructure.modifyCost(hullSize, stats, id);
25 }
26
27 public String getDescriptionParam(int index, HullSize hullSize, ShipAPI ship) {
28 float effect = 1f;
29 if (ship != null) effect = ship.getMutableStats().getDynamic().getValue(Stats.DMOD_EFFECT_MULT);
30
31 float rotMult = ROTATE_MULT + (1f - ROTATE_MULT) * (1f - effect);
32
33 if (index == 0) return "" + (int)Math.round((1f - rotMult) * 100f) + "%";
34 if (index == 1) return "" + (int) Math.round(RECOIL_PERCENT * effect) + "%";
35 if (index >= 2) return CompromisedStructure.getCostDescParam(index, 2);
36 return null;
37 }
38
39
40}
void modifyPercent(String source, float value)
void modifyMult(String source, float value)
static String getCostDescParam(int index, int startIndex)
static void modifyCost(HullSize hullSize, MutableShipStatsAPI stats, String id)
String getDescriptionParam(int index, HullSize hullSize, ShipAPI ship)
void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id)
MutableShipStatsAPI getMutableStats()