Skip to content

Commit

Permalink
Update src/ to 0.95.1a-RC6
Browse files Browse the repository at this point in the history
  • Loading branch information
jaghaimo committed Dec 21, 2021
1 parent 7196f23 commit 0c4bf75
Show file tree
Hide file tree
Showing 43 changed files with 470 additions and 108 deletions.
6 changes: 6 additions & 0 deletions src/com/fs/starfarer/api/campaign/listeners/ListenerUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,12 @@ public static void reportCargoScreenOpened() {
}
}

public static void reportSubmarketCargoAndShipsUpdated(SubmarketAPI submarket) {
for (SubmarketUpdateListener x : Global.getSector().getListenerManager().getListeners(SubmarketUpdateListener.class)) {
x.reportSubmarketCargoAndShipsUpdated(submarket);
}
}

public static void reportPlayerLeftCargoPods(SectorEntityToken entity) {
for (CargoScreenListener x : Global.getSector().getListenerManager().getListeners(CargoScreenListener.class)) {
x.reportPlayerLeftCargoPods(entity);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.fs.starfarer.api.campaign.listeners;

import com.fs.starfarer.api.campaign.econ.SubmarketAPI;

public interface SubmarketUpdateListener {
void reportSubmarketCargoAndShipsUpdated(SubmarketAPI submarket);

}
4 changes: 4 additions & 0 deletions src/com/fs/starfarer/api/combat/ShipSystemAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,8 @@ public static enum SystemState {
Vector2f getTargetLoc();

void forceState(SystemState state, float progress);

float getAmmoPerSecond();

float getAmmoReloadProgress();
}
5 changes: 5 additions & 0 deletions src/com/fs/starfarer/api/combat/ShipwideAIFlags.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public static enum AIFlags {
HAS_INCOMING_DAMAGE,
KEEP_SHIELDS_ON,
DO_NOT_BACK_OFF,

/**
* To function reliably, requires DO_NOT_BACK_OFF to be set, also.
*/
DO_NOT_BACK_OFF_EVEN_WHILE_VENTING,
BACK_OFF,
BACK_OFF_MIN_RANGE,
STANDING_OFF_VS_SHIP_ON_MAP_BORDER,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public void updateEntityFacts(SectorEntityToken entity, MemoryAPI memory) {

if (entity.getStarSystem() != null &&
entity.getStarSystem().hasTag(Tags.SYSTEM_CUT_OFF_FROM_HYPER)) {
memory.set("$systemCutOffFromHyper", true);
memory.set("$systemCutOffFromHyper", true, 0);
}


Expand Down
7 changes: 4 additions & 3 deletions src/com/fs/starfarer/api/impl/campaign/CoreScript.java
Original file line number Diff line number Diff line change
Expand Up @@ -883,12 +883,13 @@ public void doCustomProduction() {
//cargo.initMothballedShips(Factions.PLAYER);
CargoAPI cargo = data.getCargo("Heavy Industry - Custom Production");

float quality = 0f;
float quality = -1f;
for (MarketAPI market : Global.getSector().getEconomy().getMarketsCopy()) {
if (!market.isPlayerOwned()) continue;
//quality = Math.max(quality, ShipQuality.getShipQuality(market, Factions.PLAYER));
quality = market.getStats().getDynamic().getMod(Stats.PRODUCTION_QUALITY_MOD).computeEffective(0f);
quality += market.getStats().getDynamic().getMod(Stats.FLEET_QUALITY_MOD).computeEffective(0f);
float currQuality = market.getStats().getDynamic().getMod(Stats.PRODUCTION_QUALITY_MOD).computeEffective(0f);
currQuality += market.getStats().getDynamic().getMod(Stats.FLEET_QUALITY_MOD).computeEffective(0f);
quality = Math.max(quality, currQuality);
}
quality -= Global.getSector().getFaction(Factions.PLAYER).getDoctrine().getShipQualityContribution();
quality += 4f * Global.getSettings().getFloat("doctrineFleetQualityPerPoint");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,7 @@ public void applyAfterBattleEffectsIfThereWasABattle() {
// List<CampaignFleetAPI> losers = battle.getSideFor(getLoserData().getFleet());
List<CampaignFleetAPI> winners = battle.getSnapshotSideFor(getWinnerData().getFleet());
List<CampaignFleetAPI> losers = battle.getSnapshotSideFor(getLoserData().getFleet());
if (winners == null || losers == null) return;

for (CampaignFleetAPI loser : losers) {
for (FleetMemberAPI member : loser.getFleetData().getMembersListCopy()) {
Expand Down Expand Up @@ -2204,6 +2205,7 @@ protected void generatePlayerLoot(List<FleetMemberAPI> recoveredShips, boolean w
loot.addFuel((int) Math.round(fuel * (fuelMult - 1f)));
}

if (getBattle().getSnapshotSideFor(loser.getFleet()) == null) return;

List<DropData> dropRandom = new ArrayList<DropData>();
List<DropData> dropValue = new ArrayList<DropData>();
Expand Down Expand Up @@ -2348,6 +2350,8 @@ protected void handleCargoLooting(List<FleetMemberAPI> recoveredShips, boolean t


List<CampaignFleetAPI> losers = battle.getSnapshotSideFor(loser.getFleet());
if (losers == null) return;

List<LootableCargoStack> stacks = new ArrayList<LootableCargoStack>();
for (CampaignFleetAPI curr : losers) {
for (CargoStackAPI stack : curr.getCargo().getStacksCopy()) {
Expand Down Expand Up @@ -3023,7 +3027,7 @@ public void calculateAndApplyCrewLosses(EngagementResultForFleetAPI result, bool

DataForEncounterSide data = getDataFor(result.getFleet());
CrewCompositionAPI recoverable = data.getRecoverableCrewLosses();
recoverable.removeAllCrew();
//recoverable.removeAllCrew();

List<FleetMemberAPI> all = new ArrayList<FleetMemberAPI>();
all.addAll(result.getDisabled());
Expand Down Expand Up @@ -3124,10 +3128,10 @@ public void calculateAndApplyCrewLosses(EngagementResultForFleetAPI result, bool
if (maxCrew + playerCapacityLost > 0) {
total *= playerCapacityLost / (maxCrew + playerCapacityLost);
}
if (!wonBattle) {
total = totalCrew + marines;
recoverableTotal = 0f;
}
// if (!wonBattle) {
// total = totalCrew + marines;
// recoverableTotal = 0f;
// }
//if (total > playerOvercapLosses) total = playerOvercapLosses;
if (total > maxCrew) {
//float toLose = Math.min(maxExtraLoss, total - maxCrew);
Expand Down
40 changes: 40 additions & 0 deletions src/com/fs/starfarer/api/impl/campaign/GateExplosionScript.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,48 @@
import com.fs.starfarer.api.impl.campaign.ids.Entities;
import com.fs.starfarer.api.impl.campaign.ids.Factions;
import com.fs.starfarer.api.impl.campaign.ids.Tags;
import com.fs.starfarer.api.util.IntervalUtil;
import com.fs.starfarer.api.util.Misc;

public class GateExplosionScript implements EveryFrameScript {

public static class SystemCutOffRemoverScript implements EveryFrameScript {
public StarSystemAPI system;
public IntervalUtil interval = new IntervalUtil(0.5f, 1.5f);
public boolean done;
public float elapsed = 0f;

public SystemCutOffRemoverScript(StarSystemAPI system) {
super();
this.system = system;
}
public boolean isDone() {
return done;
}
public boolean runWhilePaused() {
return false;
}

public void advance(float amount) {
if (done) return;

float days = Global.getSector().getClock().convertToDays(amount);
elapsed += days;
interval.advance(days);
if (interval.intervalElapsed() && elapsed > 10f) { // make sure gate's already exploded
boolean allJPUsable = true;
for (SectorEntityToken jp : system.getJumpPoints()) {
allJPUsable &= !jp.getMemoryWithoutUpdate().getBoolean(JumpPointInteractionDialogPluginImpl.UNSTABLE_KEY);
}
if (allJPUsable) {
system.removeTag(Tags.SYSTEM_CUT_OFF_FROM_HYPER);
done = true;
}
}
}

}

public static float UNSTABLE_DAYS_MIN = 200;
public static float UNSTABLE_DAYS_MAX = 400;

Expand All @@ -39,9 +77,11 @@ public GateExplosionScript(SectorEntityToken gate) {
StarSystemAPI system = gate.getStarSystem();
if (system != null) {
system.addTag(Tags.SYSTEM_CUT_OFF_FROM_HYPER);
system.addScript(new SystemCutOffRemoverScript(system));
}

delay = 1.2f; // plus approximately 2 seconds from how long plugin.jitter() takes to build up

}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,53 @@ public class OfficerLevelupPluginImpl implements OfficerLevelupPlugin {
//public static float XP_MULT = 5f;
public static float XP_MULT = Global.getSettings().getFloat("officerXPRequiredMult");

public static float EXPONENT_BEYOND_MAX_SPECIFIED_LEVEL = 1.1f;

public static long [] XP_PER_LEVEL = new long [] {
0, // level 1
12000,
20000,
35000,
45000, // level 5
50000,
50000,
50000,
50000,
50000,
};

public static long [] TOTAL_XP_PER_LEVEL = new long [XP_PER_LEVEL.length];

static {
long total = 0;
for (int i = 0; i < XP_PER_LEVEL.length; i++) {
total += XP_PER_LEVEL[i];
TOTAL_XP_PER_LEVEL[i] = total;
}
}

public long getXPForLevel(int level) {

if (level <= 1) return 0;

float p1 = 10;
float p2 = 35;

float f1 = 1f;
float f2 = Math.min(1, Math.max(0, level - p1) / 5f);
float f3 = Math.max(0, level - p2);

float p1level = Math.max(0, level - p1 + 1);
float p2level = Math.max(0, level - p2 + 1);
float mult1 = (1f + (float) level) * 0.5f * (float) level * 1f;
float mult2 = (1f + (float) p1level) * 0.5f * (float) p1level * 0.25f;
float mult3 = (1f + (float) p2level) * 0.5f * (float) p2level * 2f;

float base = 1500;

float r = f1 * mult1 * base +
f2 * mult2 * base +
f3 * mult3 * base;

r *= XP_MULT;
if (level - 1 < TOTAL_XP_PER_LEVEL.length) {
return (long) (TOTAL_XP_PER_LEVEL[level - 1] * XP_MULT);
}

return (long) r * 6;
int maxSpecified = TOTAL_XP_PER_LEVEL.length;
long curr = TOTAL_XP_PER_LEVEL[maxSpecified - 1];
long last = XP_PER_LEVEL[maxSpecified - 1];
for (int i = maxSpecified; i < level; i++) {
last *= EXPONENT_BEYOND_MAX_SPECIFIED_LEVEL;
curr += last;
}

return (long) (curr * XP_MULT);
}

public static void main(String[] args) {
for (int i = 1; i <= 6; i++) {
System.out.println("Level " + i + ": " + new OfficerLevelupPluginImpl().getXPForLevel(i));
}
}

public int getMaxLevel(PersonAPI person) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected void activateImpl() {
}

entity.setTransponderOn(true);

entity.getMemoryWithoutUpdate().set(MemFlags.JUST_TOGGLED_TRANSPONDER, true, 0.1f);

// AbilityPlugin goDark = entity.getAbility(Abilities.GO_DARK);
// if (goDark != null && goDark.isActive()) {
Expand All @@ -81,7 +81,8 @@ protected void applyEffect(float amount, float level) {
public void deactivate() {
super.deactivate();
if (entity.isTransponderOn()) {
entity.setTransponderOn(false); // failsafe in case deactivation failed to actuall deactivate transponder
entity.setTransponderOn(false); // failsafe in case deactivation failed to actually deactivate transponder
entity.getMemoryWithoutUpdate().set(MemFlags.JUST_TOGGLED_TRANSPONDER, true, 0.1f);
}
}

Expand All @@ -90,7 +91,7 @@ public void deactivate() {
@Override
protected void deactivateImpl() {
entity.setTransponderOn(false);

entity.getMemoryWithoutUpdate().set(MemFlags.JUST_TOGGLED_TRANSPONDER, true, 0.1f);
//cleanupImpl();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public static Pair<SectorEntityToken, Float> getNearestCryosleeper(Vector2f locI
for (SectorEntityToken entity : Global.getSector().getCustomEntitiesWithTag(Tags.CRYOSLEEPER)) {
if (!usable || entity.getMemoryWithoutUpdate().contains("$usable")) {
float dist = Misc.getDistanceLY(locInHyper, entity.getLocationInHyperspace());
if (Math.round(dist * 10f) <= MAX_BONUS_DIST_LY * 10f) {
if (dist > MAX_BONUS_DIST_LY && Math.round(dist * 10f) <= MAX_BONUS_DIST_LY * 10f) {
dist = MAX_BONUS_DIST_LY;
}
if (dist < minDist) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,8 @@ public static Pair<SectorEntityToken, Float> getNearestCoronalTap(Vector2f locIn
for (SectorEntityToken entity : Global.getSector().getCustomEntitiesWithTag(Tags.CORONAL_TAP)) {
if (!usable || entity.getMemoryWithoutUpdate().contains("$usable")) {
float dist = Misc.getDistanceLY(locInHyper, entity.getLocationInHyperspace());
if (Math.round(dist * 10f) <= ItemEffectsRepo.CORONAL_TAP_LIGHT_YEARS * 10f) {
if (dist > ItemEffectsRepo.CORONAL_TAP_LIGHT_YEARS &&
Math.round(dist * 10f) <= ItemEffectsRepo.CORONAL_TAP_LIGHT_YEARS * 10f) {
dist = ItemEffectsRepo.CORONAL_TAP_LIGHT_YEARS;
}
if (dist < minDist) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void advance(float amount) {
CampaignFleetAPI pf = Global.getSector().getPlayerFleet();
if (pf == null) return;
float days = Global.getSector().getClock().convertToDays(amount);

//days *= 1000f;
pointTimeout.advance(days);
creatorTimeout.advance(days);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public void createEncounter(EncounterManager manager, EncounterPoint point) {
Vector2f spawnLoc = Misc.getPointWithinRadius(point.loc, 1000f);
SectorEntityToken e = point.where.createToken(spawnLoc);
fleet.addAssignment(FleetAssignment.ORBIT_AGGRESSIVE, e, 30f * random.nextFloat(), "laying in wait");
fleet.removeScriptsOfClass(MissionFleetAutoDespawn.class);
fleet.addScript(new MissionFleetAutoDespawn(null, fleet));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public void createEncounter(EncounterManager manager, EncounterPoint point) {
Vector2f spawnLoc = Misc.getPointWithinRadius(point.loc, 1000f);
SectorEntityToken e = point.where.createToken(spawnLoc);
fleet.addAssignment(FleetAssignment.ORBIT_AGGRESSIVE, e, 30f * random.nextFloat(), "laying in wait");
fleet.removeScriptsOfClass(MissionFleetAutoDespawn.class);
fleet.addScript(new MissionFleetAutoDespawn(null, fleet));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public void createEncounter(EncounterManager manager, EncounterPoint point) {
Vector2f spawnLoc = Misc.getPointWithinRadius(point.loc, 1000f);
SectorEntityToken e = point.where.createToken(spawnLoc);
fleet.addAssignment(FleetAssignment.ORBIT_AGGRESSIVE, e, 30f * random.nextFloat(), "laying in wait");
fleet.removeScriptsOfClass(MissionFleetAutoDespawn.class);
fleet.addScript(new MissionFleetAutoDespawn(null, fleet));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public void createEncounter(EncounterManager manager, EncounterPoint point) {
Vector2f spawnLoc = Misc.getPointWithinRadius(point.loc, 1000f);
SectorEntityToken e = point.where.createToken(spawnLoc);
fleet.addAssignment(FleetAssignment.ORBIT_AGGRESSIVE, e, 30f * random.nextFloat(), "waiting");
fleet.removeScriptsOfClass(MissionFleetAutoDespawn.class);
fleet.addScript(new MissionFleetAutoDespawn(null, fleet));
fleet.addScript(new ScavengerPiracyScript(fleet));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.fs.starfarer.api.campaign.InteractionDialogAPI;
import com.fs.starfarer.api.input.InputEventAPI;
import com.fs.starfarer.api.ui.CustomPanelAPI;
import com.fs.starfarer.api.ui.LabelAPI;
import com.fs.starfarer.api.ui.PositionAPI;
import com.fs.starfarer.api.ui.TooltipMakerAPI;
import com.fs.starfarer.api.util.FaderUtil;
Expand Down Expand Up @@ -73,8 +74,10 @@ public void showNext() {
} else if (curr == TutStage.ATTACK) {
info.addPara("Press SPACE to attack.", 0f, h, "SPACE");
} else if (curr == TutStage.BLOCK) {
info.addPara("Press UP to block or parry. "
LabelAPI label = info.addPara("Press UP to block or parry. "
+ "A skilled fighter can also execute a quick attack, or a \"riposte\", by attacking immediately after deflecting their opponent's attack.", 0f, h, "UP");
label.setHighlightColors(h, Misc.getStoryOptionColor());
label.setHighlight("UP", "skilled fighter");
} else if (curr == TutStage.LEAVE) {
info.addPara("Your health is in the top left of the screen.\n\n"
+ "Make a few practice moves, then press ESCAPE to continue.", 0f, h, "ESCAPE");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public class SensorGhostManager implements EveryFrameScript {
}


public static float GHOST_SPAWN_RATE_MULT = 0.75f;

public static float SB_ATTRACT_GHOSTS_PROBABILITY = 0.5f;
public static float SB_FAILED_TO_ATTRACT_TIMEOUT_MULT = 0.25f;
public static float MIN_SB_TIMEOUT = 5f;
Expand Down Expand Up @@ -115,7 +117,7 @@ public void advance(float amount) {
checkSensorBursts();
}

timeoutRemaining -= days;
timeoutRemaining -= days * GHOST_SPAWN_RATE_MULT;
if (timeoutRemaining <= 0f) {
spawnGhost();
spawnTriggeredBySensorBurst = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ public CampaignFleetAPI createOtherFleet(SensorGhostManager manager, Vector2f lo
}

if (fleet == null) return null;
fleet.removeScriptsOfClass(MissionFleetAutoDespawn.class);
fleet.addScript(new MissionFleetAutoDespawn(null, fleet));

return fleet;
Expand Down
1 change: 1 addition & 0 deletions src/com/fs/starfarer/api/impl/campaign/ids/MemFlags.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class MemFlags {

public static final String GLOBAL_SENSOR_BURST_JUST_USED_IN_CURRENT_LOCATION = "$sensorBurstJustUsed";
public static final String JUST_DID_SENSOR_BURST = "$justDidSensorBurst";
public static final String JUST_TOGGLED_TRANSPONDER = "$justToggledTransponder";

public static final String GLOBAL_INTERDICTION_PULSE_JUST_USED_IN_CURRENT_LOCATION = "$interdictionPulseJustUsed";
public static final String JUST_DID_INTERDICTION_PULSE = "$justDidInterdictionPulse";
Expand Down
Loading

0 comments on commit 0c4bf75

Please sign in to comment.