Starsector API
Loading...
Searching...
No Matches
GhostFrequencies.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.campaign.ghosts;
2
3import org.lwjgl.util.vector.Vector2f;
4
5import com.fs.starfarer.api.Global;
6import com.fs.starfarer.api.fleet.FleetMemberAPI;
7import com.fs.starfarer.api.impl.campaign.ghosts.types.NoGhostCreator;
8import com.fs.starfarer.api.impl.campaign.ghosts.types.ZigguratGhost;
9import com.fs.starfarer.api.util.Misc;
10
11public class GhostFrequencies {
12 public static String ZIGGURAT = "ziggurat";
13
14 public static float getNoGhostFrequency(SensorGhostManager manager) {
15 if (manager.isSpawnTriggeredBySensorBurst()) return 0f;
16
17 float total = 0f;
19 if (!(c instanceof NoGhostCreator)) {
20 float f = c.getFrequency(manager);
21 //System.out.println(c.getClass().getSimpleName() + ": " + f);
22 total += f;
23 }
24 }
25 float mult = 0.5f + getCoreFactor() * 5f;
26 return Math.max(10f, total) * mult;
27 //return 10f;
28 }
29 public static float getAbyssalDrifterFrequency(SensorGhostManager manager) {
30 return 30;
31 }
32 public static float getChargerFrequency(SensorGhostManager manager) {
33 return 10f * getNotInCoreFactor() * getSBFactor(manager, 1f, 2f);
34 }
36 return 10f * getNotInCoreFactor() * (0.5f + 0.5f * getFringeFactor()) * getSBFactor(manager, 1f, 2f);
37 }
38 public static float getEchoFrequency(SensorGhostManager manager) {
39 return 5f * getSBFactor(manager, 1f, 5f);
40 }
41 public static float getGuideFrequency(SensorGhostManager manager) {
42 return 10f * getNotInCoreFactor() * getSBFactor(manager, 1f, 2f);
43 }
44 public static float getLeviathanCalfFrequency(SensorGhostManager manager) {
45 return 5f * (getNotInCoreFactor() + getFringeFactor()) * getSBFactor(manager, 1f, 0f);
46 }
47 public static float getLeviathanFrequency(SensorGhostManager manager) {
48 return 5f * (getNotInCoreFactor() + getFringeFactor()) * getSBFactor(manager, 1f, 0f);
49 }
50 public static float getMinnowFrequency(SensorGhostManager manager) {
51 return 10f * getNotInCoreFactor() * (0.5f + 0.5f * getFringeFactor()) * getSBFactor(manager, 1f, 0f);
52 }
53 public static float getRacerFrequency(SensorGhostManager manager) {
54 return 10f * getNotInCoreFactor();
55 }
56 public static float getRemnantFrequency(SensorGhostManager manager) {
57 return 1f * getFringeFactor();
58 }
59 public static float getRemoraFrequency(SensorGhostManager manager) {
60 return 10f * getNotInCoreFactor() * (0.25f + 0.75f * getFringeFactor()) * getSBFactor(manager, 1f, 4f);
61 }
62 public static float getShipFrequency(SensorGhostManager manager) {
63 return 2f * getFringeFactor();
64 }
65 public static float getStormcallerFrequency(SensorGhostManager manager) {
66 return 5f * getNotInCoreFactor() * (0.5f + 0.5f * getFringeFactor()) * getSBFactor(manager, 1f, 0f);
67 }
68 public static float getStormTricksterFrequency(SensorGhostManager manager) {
69 return 5f * getNotInCoreFactor() * (0.25f + 0.75f * getFringeFactor()) * getSBFactor(manager, 1f, 2f);
70 }
71 public static float getZigguratFrequency(SensorGhostManager manager) {
72 if (manager.hasGhostOfClass(ZigguratGhost.class)) {
73 return 0f;
74 }
75 String id = ZIGGURAT;
76 boolean found = false;
77 for (FleetMemberAPI member : Global.getSector().getPlayerFleet().getFleetData().getMembersListCopy()) {
78 if (member.getHullSpec().getBaseHullId().equals(id)) {
79 found = true;
80 break;
81 }
82 }
83 if (!found) return 0f;
84 return 10000f;
85 }
86
87
88
89
90 public static float getFringeFactor() {
91 Vector2f loc = Global.getSector().getPlayerFleet().getLocationInHyperspace();
92 float sw = Global.getSettings().getFloat("sectorWidth");
93 float sh = Global.getSettings().getFloat("sectorHeight");
94 float f = 0.8f;
95 float a = sw * 0.5f * f;
96 float b = sh * 0.5f * f;
97 float x = loc.x;
98 float y = loc.y;
99
100 float test = (x * x) / (a * a) + (y * y)/ (b * b);
101 //System.out.println("Test: " + test);
102 float result = 0f;
103 if (test >= 1f) {
104 result = 1f;
105 } else if (test <= 0.75f) {
106 result = 0f;
107 } else {
108 result = (test - 0.75f) / 0.25f;
109 }
110 return result;
111 }
112
113 public static float getSBFactor(SensorGhostManager manager, float factorIfNoBurst, float factorIfBurst) {
114 if (manager.isSpawnTriggeredBySensorBurst()) return factorIfBurst;
115 return factorIfNoBurst;
116 }
117
118 public static boolean isInsideCore() {
119 return getCoreFactor() >= 1f;
120 }
121
122 public static float getNotInFringeFactor() {
123 return 1f - getFringeFactor();
124 }
125
126 public static float getNotInCoreFactor() {
127 return 1f - getCoreFactor();
128 }
129 public static float getCoreFactor() {
130 Vector2f loc = Global.getSector().getPlayerFleet().getLocationInHyperspace();
131
132 Vector2f min = Misc.getCoreMin();
133 Vector2f max = Misc.getCoreMax();
134 Vector2f center = Misc.getCoreCenter();
135
136 float f = 1.4f;
137 float a = (max.x - min.x) * 0.5f * f;
138 float b = (max.y - min.y) * 0.5f * f;
139 float x = loc.x - center.x;
140 float y = loc.y - center.y;
141
142 float test = (x * x) / (a * a) + (y * y)/ (b * b);
143 //System.out.println("Test: " + test);
144 float result = 0f;
145 if (test >= 1f) {
146 result = 0f;
147 } else if (test <= 0.75f) {
148 result = 1f;
149 } else {
150 result = 1f - (test - 0.75f) / 0.25f;
151 }
152 return result;
153 }
154
155}
156
157
158
159
160
161
162
163
164
165
static SettingsAPI getSettings()
Definition Global.java:51
static SectorAPI getSector()
Definition Global.java:59
static float getStormcallerFrequency(SensorGhostManager manager)
static float getAbyssalDrifterFrequency(SensorGhostManager manager)
static float getRacerFrequency(SensorGhostManager manager)
static float getEncounterTricksterFrequency(SensorGhostManager manager)
static float getSBFactor(SensorGhostManager manager, float factorIfNoBurst, float factorIfBurst)
static float getRemoraFrequency(SensorGhostManager manager)
static float getNoGhostFrequency(SensorGhostManager manager)
static float getMinnowFrequency(SensorGhostManager manager)
static float getZigguratFrequency(SensorGhostManager manager)
static float getStormTricksterFrequency(SensorGhostManager manager)
static float getChargerFrequency(SensorGhostManager manager)
static float getEchoFrequency(SensorGhostManager manager)
static float getRemnantFrequency(SensorGhostManager manager)
static float getLeviathanFrequency(SensorGhostManager manager)
static float getGuideFrequency(SensorGhostManager manager)
static float getShipFrequency(SensorGhostManager manager)
static float getLeviathanCalfFrequency(SensorGhostManager manager)