Skip to content

Commit

Permalink
Update src/ to 0.96a-RC9
Browse files Browse the repository at this point in the history
  • Loading branch information
jaghaimo committed May 15, 2023
1 parent 669b008 commit 9773785
Show file tree
Hide file tree
Showing 42 changed files with 586 additions and 157 deletions.
46 changes: 24 additions & 22 deletions src/com/fs/starfarer/api/impl/campaign/ExplosionEntityPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -416,28 +416,30 @@ public void applyDamageToFleet(CampaignFleetAPI fleet, float damageMult) {
strikeDamage = HyperspaceTerrainPlugin.STORM_MAX_STRIKE_DAMAGE;
}

float currCR = member.getRepairTracker().getBaseCR();
float crDamage = Math.min(currCR, strikeDamage);

if (crDamage > 0) {
member.getRepairTracker().applyCREvent(-crDamage, "explosion_" + entity.getId(),
"Damaged by explosion");
}

float hitStrength = member.getStats().getArmorBonus().computeEffective(member.getHullSpec().getArmorRating());
//hitStrength *= strikeDamage / crPerDep;
int numHits = (int) (strikeDamage / 0.1f);
if (numHits < 1) numHits = 1;
for (int j = 0; j < numHits; j++) {
member.getStatus().applyDamage(hitStrength);
}
//member.getStatus().applyHullFractionDamage(1f);
if (member.getStatus().getHullFraction() < 0.01f) {
member.getStatus().setHullFraction(0.01f);
picker.remove(member);
} else {
float w = picker.getWeight(member);
picker.setWeight(picker.getItems().indexOf(member), w * 0.5f);
if (strikeDamage > 0) {
float currCR = member.getRepairTracker().getBaseCR();
float crDamage = Math.min(currCR, strikeDamage);

if (crDamage > 0) {
member.getRepairTracker().applyCREvent(-crDamage, "explosion_" + entity.getId(),
"Damaged by explosion");
}

float hitStrength = member.getStats().getArmorBonus().computeEffective(member.getHullSpec().getArmorRating());
//hitStrength *= strikeDamage / crPerDep;
int numHits = (int) (strikeDamage / 0.1f);
if (numHits < 1) numHits = 1;
for (int j = 0; j < numHits; j++) {
member.getStatus().applyDamage(hitStrength);
}
//member.getStatus().applyHullFractionDamage(1f);
if (member.getStatus().getHullFraction() < 0.01f) {
member.getStatus().setHullFraction(0.01f);
picker.remove(member);
} else {
float w = picker.getWeight(member);
picker.setWeight(picker.getItems().indexOf(member), w * 0.5f);
}
}
//picker.remove(member);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3195,11 +3195,12 @@ public void calculateAndApplyCrewLosses(EngagementResultForFleetAPI result, bool
crewLosses.addCrew((f1 - 1) * c.getCrew());
}

float lost = c.getCrew() * f1;
// both fighters and normal ships
c.transfer(c.getCrew() * f1, crewLosses);
c.transfer(lost, crewLosses);

if (player) {
playerLosses.addCrew(c.getCrew() * f1);
playerLosses.addCrew(lost);
playerCapacityLost += member.getMaxCrew() * f1;
}
}
Expand All @@ -3223,6 +3224,9 @@ public void calculateAndApplyCrewLosses(EngagementResultForFleetAPI result, bool
float totalCrew = cargo.getTotalCrew();
float marines = cargo.getMarines();
float recoverableTotal = recoverable.getCrew() + recoverable.getMarines();

//recoverableTotal = 0f; // uncomment to let recoverable crew not be lost due to being over capacity

float total = totalCrew + marines + recoverableTotal;
if (maxCrew + playerCapacityLost > 0) {
total *= playerCapacityLost / (maxCrew + playerCapacityLost);
Expand All @@ -3236,7 +3240,8 @@ public void calculateAndApplyCrewLosses(EngagementResultForFleetAPI result, bool
//float toLose = Math.min(maxExtraLoss, total - maxCrew);
float toLose = total - maxCrew;
if (toLose > 0) {
recoverable.clear();
//recoverable.clear();
recoverable.transfer(Math.min(recoverableTotal, toLose), null);
toLose -= recoverableTotal;
total -= recoverableTotal;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public void optionSelected(String text, Object optionData) {
createInitialOptions();
break;
case DUMP_PLANETKILLER_CONT_1:
addText("At your command the planetkiller, locked in its cradle, is boosted toward the very center of the black hole, up and over the plane of the accretion disc.\n"
addText("At your command the planetkiller, locked in its cradle, is boosted toward the very center of the black hole, up and over the plane of the accretion disc.\n\n"
+ "With a flash only a little more than noise in the sensor telemetry, it is gone."); //, like tears in rain"); - OMG Alex, you're killing me -dgb
AddRemoveCommodity.addItemLossText(new SpecialItemData(Items.PLANETKILLER, null), 1, dialog.getTextPanel());
Global.getSector().getPlayerStats().addStoryPoints(1, dialog.getTextPanel(), false);
Expand Down Expand Up @@ -317,7 +317,7 @@ protected void createInitialOptions() {
// }


if (hasPK()) {
if (hasPK() && blackHole == true) {
options.addOption("Dump the planetkiller weapon into the black hole", OptionId.DUMP_PLANETKILLER, null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,12 @@ protected void spawnPlayerSensorReading(CampaignFleetAPI fleet) {

protected void respondToFalseSensorReadings(CampaignFleetAPI fleet) {
if (fleet.isStationMode()) return;
if (fleet.getAI() == null) {
return;
}
if (fleet.getAI().getAssignmentsCopy() == null) {
return;
}

MemoryAPI mem = fleet.getMemoryWithoutUpdate();
if (mem.getBoolean(MemFlags.FLEET_NOT_CHASING_GHOST)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ public class Spaceport extends BaseIndustry implements MarketImmigrationModifier

public static float UPKEEP_MULT_PER_DEFICIT = 0.1f;

public static final float BASE_ACCESSIBILITY = 0.5f;
public static final float MEGAPORT_ACCESSIBILITY = 0.8f;
public static float BASE_ACCESSIBILITY = 0.6f;
public static float MEGAPORT_ACCESSIBILITY = 0.9f;

public static final float ALPHA_CORE_ACCESSIBILITY = 0.2f;
public static final float IMPROVE_ACCESSIBILITY = 0.2f;
public static float ALPHA_CORE_ACCESSIBILITY = 0.2f;
public static float IMPROVE_ACCESSIBILITY = 0.2f;

// public static final float BASE_ACCESSIBILITY = 0f;
// public static final float MEGAPORT_ACCESSIBILITY = 0.2f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ public void unapply() {
lr.getStockpilingBonus(Commodities.FUEL).unmodifyFlat(getModId(0));
lr.getStockpilingBonus(Commodities.SUPPLIES).unmodifyFlat(getModId(0));
lr.getStockpilingBonus(Commodities.CREW).unmodifyFlat(getModId(0));
lr.getStockpilingBonus(Commodities.VOLATILES).unmodifyFlat(getModId(0));
lr.getStockpilingBonus(Commodities.RARE_METALS).unmodifyFlat(getModId(0));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@ public class LuddicPathBaseIntel extends BaseIntelPlugin implements EveryFrameSc

protected Random random = new Random();

public static LuddicPathBaseIntel getIntelFor(StarSystemAPI system) {
for (IntelInfoPlugin intel : Global.getSector().getIntelManager().getIntel(LuddicPathBaseIntel.class)) {
if (((LuddicPathBaseIntel)intel).getSystem() == system) {
return (LuddicPathBaseIntel) intel;
}
}
return null;
}

public LuddicPathBaseIntel(StarSystemAPI system, String factionId) {
this.system = system;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ public void createTooltip(TooltipMakerAPI tooltip, boolean expanded, Object tool
}
public TooltipCreator getStageTooltip(Object stageId) {
final EventStageData esd = getDataFor(stageId);
if (esd == null || (esd.randomized && esd.rollData == null)) {
if (esd == null || (esd.randomized && (esd.rollData == null || RANDOM_EVENT_NONE.equals(esd.rollData)))) {
return new TooltipCreator() {
public boolean isTooltipExpandable(Object tooltipParam) {
return false;
Expand Down Expand Up @@ -449,7 +449,7 @@ public EventStageDisplayData createDisplayData(Object stageId) {

protected String getStageIcon(Object stageId) {
EventStageData esd = getDataFor(stageId);
if (esd == null || (esd.randomized && esd.rollData == null)) {
if (esd == null || (esd.randomized && (esd.rollData == null || RANDOM_EVENT_NONE.equals(esd.rollData)))) {
if (esd.randomType == RandomizedStageType.GOOD) {
return Global.getSettings().getSpriteName("events", "stage_unknown_good");
} else if (esd.randomType == RandomizedStageType.BAD) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,27 @@ public int getMaxNumFleets(StarSystemAPI system) {
return 1000;
}

public float getEffectMagnitudeAdjustedBySuppression(StarSystemAPI system) {
float mag = getEffectMagnitude(system);
//float s = intel.computeSuppressionAmount();
// currently, keep fleets the same size when suppressed, too
// otherwise, the fights just get less fun as you're trying to suppress more
return mag;
}
// public float getEffectMagnitudeAdjustedBySuppression(StarSystemAPI system) {
// float mag = getEffectMagnitude(system);
// //float s = intel.computeSuppressionAmount();
// // currently, keep fleets the same size when suppressed, too
// // otherwise, the fights just get less fun as you're trying to suppress more
// return mag;
// }

public float getEffectMagnitude(StarSystemAPI system) {
public float getEffectMagnitude(StarSystemAPI system) {//, boolean adjustByEventProgress) {
float mag = 0f;
for (HostileActivityCause2 cause : causes) {
mag += cause.getMagnitudeContribution(system);
}
// if (adjustByEventProgress) {
// float f = intel.getProgressFraction();
// float add = f * 0.5f;
// add = Math.min(add, 1f - mag); wefwefwefewfwe
// if (mag < f) {
// mag = Misc.interpolate(mag, f, 0.5f);
// }
// }
return mag;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ protected CampaignFleetAPI spawnFleetImpl() {
if (!(factor instanceof HostileActivityFactor)) {
continue;
}
//if (factor instanceof LuddicPathHostileActivityFactor) continue;

HostileActivityFactor curr = (HostileActivityFactor) factor;
int count = 0;
for (ManagedFleetData data : active) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.fs.starfarer.api.impl.campaign.intel.events;

import com.fs.starfarer.api.ui.TooltipMakerAPI;
import com.fs.starfarer.api.ui.TooltipMakerAPI.TooltipCreator;

public class HALuddicPathDealFactor extends BaseOneTimeFactor {

public HALuddicPathDealFactor(int points) {
super(points);
}

@Override
public String getDesc(BaseEventIntel intel) {
return "Deal made with Luddic Path";
}

@Override
public TooltipCreator getMainRowTooltip() {
return new BaseFactorTooltip() {
@Override
public void createTooltip(TooltipMakerAPI tooltip, boolean expanded, Object tooltipParam) {
tooltip.addPara("You've recently reached an understanding with the Luddic Path.",
0f);
}

};
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.fs.starfarer.api.impl.campaign.intel.events;

import com.fs.starfarer.api.ui.TooltipMakerAPI;
import com.fs.starfarer.api.ui.TooltipMakerAPI.TooltipCreator;

public class HAPatherBaseDestroyedFactor extends BaseOneTimeFactor {

public HAPatherBaseDestroyedFactor(int points) {
super(points);
}

@Override
public String getDesc(BaseEventIntel intel) {
return "Luddic Path base destroyed";
}

@Override
public TooltipCreator getMainRowTooltip() {
return new BaseFactorTooltip() {
@Override
public void createTooltip(TooltipMakerAPI tooltip, boolean expanded, Object tooltipParam) {
tooltip.addPara("A Luddic Path base that was supporting Pather cells at your colonies was destroyed by "
+ "your fleet.",
0f);
}

};
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.fs.starfarer.api.impl.campaign.intel.events;

import com.fs.starfarer.api.ui.TooltipMakerAPI;
import com.fs.starfarer.api.ui.TooltipMakerAPI.TooltipCreator;

public class HAPirateBaseDestroyedFactor extends BaseOneTimeFactor {

public HAPirateBaseDestroyedFactor(int points) {
super(points);
}

@Override
public String getDesc(BaseEventIntel intel) {
return "Pirate base destroyed";
}

@Override
public TooltipCreator getMainRowTooltip() {
return new BaseFactorTooltip() {
@Override
public void createTooltip(TooltipMakerAPI tooltip, boolean expanded, Object tooltipParam) {
tooltip.addPara("A pirate base that was supporting pirate activity at your colonies was destroyed by "
+ "your fleet.",
0f);
}

};
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.fs.starfarer.api.impl.campaign.intel.events;

import com.fs.starfarer.api.ui.TooltipMakerAPI;
import com.fs.starfarer.api.ui.TooltipMakerAPI.TooltipCreator;

public class HAPirateKingDealFactor extends BaseOneTimeFactor {

public HAPirateKingDealFactor(int points) {
super(points);
}

@Override
public String getDesc(BaseEventIntel intel) {
return "Deal made with pirate king";
}

@Override
public TooltipCreator getMainRowTooltip() {
return new BaseFactorTooltip() {
@Override
public void createTooltip(TooltipMakerAPI tooltip, boolean expanded, Object tooltipParam) {
tooltip.addPara("You've recently made a deal with a pirate king in control of a nearby station.",
0f);
}

};
}

}
Loading

0 comments on commit 9773785

Please sign in to comment.