Starsector API
Loading...
Searching...
No Matches
DisplacerGlowScript.java
Go to the documentation of this file.
1package com.fs.starfarer.api.impl.combat.threat;
2
3import java.awt.Color;
4
5import com.fs.starfarer.api.combat.MutableShipStatsAPI;
6import com.fs.starfarer.api.combat.ShipAPI;
7import com.fs.starfarer.api.combat.ShipwideAIFlags.AIFlags;
8import com.fs.starfarer.api.util.Misc;
9
11
12 public void applyImpl(ShipAPI ship, MutableShipStatsAPI stats, String id, State state, float effectLevel) {
13 if (state != State.IDLE && state != State.OUT) return;
14
15 float ammo = ship.getSystem().getAmmo();
16 float maxAmmo = ship.getSystem().getMaxAmmo();
17
18 if (ammo <= 0 && (state == State.IDLE || state == State.OUT)) return;
19
20 if (ship.isHulk()) return;
21
22 //float jitterLevel = effectLevel;
23 float jitterLevel = ammo / maxAmmo;
24 jitterLevel = 0.5f + 0.5f * jitterLevel;
25 if (state == State.OUT) {
26 jitterLevel *= jitterLevel;
27 }
28// float maxRangeBonus = 50f;
29// float jitterRangeBonus = jitterLevel * maxRangeBonus;
30
32 Color underColor = Misc.setAlpha(base, 255);
33 Color overColor = Misc.setAlpha(base, 255);;
34 ship.setJitterUnder(this, underColor, jitterLevel, 7, 4f, 4f);
35 ship.setJitter(this, overColor, jitterLevel, 2, 0f, 4f);
36
37 ship.setJitterShields(false);
38 ship.setCircularJitter(true);
39 }
40
41 @Override
42 public void hitWithEnergyLash(ShipAPI overseer, ShipAPI ship) {
43 if (ship.getSystem() == null) return;
44
45 ship.getSystem().setAmmo(ship.getSystem().getMaxAmmo());
46 }
47
48 @Override
49 public float getCurrentUsefulnessLevel(ShipAPI overseer, ShipAPI ship) {
50 float ammo = ship.getSystem().getAmmo();
51 float maxAmmo = ship.getSystem().getMaxAmmo();
52 if (ammo >= maxAmmo) return 0f;
53
54 if (maxAmmo < 1) maxAmmo = 1f;
55 float f = ammo / maxAmmo;
56
57 float mult = 0.5f;
58 if (ship.getAIFlags().hasFlag(AIFlags.BACKING_OFF) ||
59 ship.getAIFlags().hasFlag(AIFlags.NEEDS_HELP)) {
60 mult += 0.5f;
61 }
62
63 float fluxFactor = Math.min(0.25f, ship.getFluxLevel() * 0.25f);
64
65 return fluxFactor + 0.75f * (1f - f) * mult;
66 }
67}
68
69
70
71
72
73
74
75
void applyImpl(ShipAPI ship, MutableShipStatsAPI stats, String id, State state, float effectLevel)
static Color setAlpha(Color color, int alpha)
Definition Misc.java:1316
void setCircularJitter(boolean circular)
void setJitterUnder(Object source, Color color, float intensity, int copies, float range)
void setJitterShields(boolean jitterShields)
void setJitter(Object source, Color color, float intensity, int copies, float range)