Skip to content

Commit

Permalink
Showing 6 changed files with 99 additions and 23 deletions.
42 changes: 22 additions & 20 deletions GameData/RP-0/CrewTrainingTimes.cfg
Original file line number Diff line number Diff line change
@@ -21,15 +21,17 @@ TRAININGTIMES
XPlane = 30
Suborbital = 30, XPlane // 60
Orbital = 50, Suborbital // 110
Maneuvering = 25, BasicCapsules // 135
Rendezvous = 25, Maneuvering // 160
Docking = 50, Rendezvous // 210
Landing = 100, Docking // 310
Maneuvering = 50, BasicCapsules // 210
Rendezvous = 90, Maneuvering // 300
Docking = 50, Rendezvous // 350
Landing = 100, Maneuvering // 310
EVA = 100
BasicCapsules = 50, Orbital // 200
SecondGenCapsules = 50, Maneuvering, Rendezvous, Docking // 350
MatureCapsules = 50, SecondGenCapsules // 400
ImprovedCapsules = 50, SecondGenCapsules // 400
BasicCapsules = 50, Orbital // 160
BasicCapsuleEVA = EVA, BasicCapsules // 260
SecondGenCapsules = 50, Docking, EVA // 500
MatureCapsules = 25, SecondGenCapsules // 525
ImprovedCapsules = 25, MatureCapsules // 550
//**********************************************************************************
@@ -60,36 +62,36 @@ TRAININGTIMES
// Capsules
//**********************************************************************************
// Mercury
Mercury = 100, BasicCapsules // 300
Mercury = 100, BasicCapsules // 260
FASAMercuryPod = Mercury
mk1pod = Mercury
orbitaiespod = Mercury
Mercury-Mission = 75
// Gemini
Gemini = 200, SecondGenCapsules // 550
Gemini = 25, SecondGenCapsules // 525
FASAGeminiPod2 = Gemini
FASAGeminiPod2White = Gemini
K2Pod = Gemini
moduldesspod = Gemini
Gemini-Mission = 60
Gemini-Mission = 120
// Apollo
Apollo = 200, MatureCapsules // 600
Apollo = 75, MatureCapsules // 600
bluedog-Apollo-Block2-Capsule = Apollo
FASAApollo-CM = Apollo
SSTU-SC-B-CM = Apollo
Mark1-2Pod = Apollo
Apollo-Mission = 60
Apollo-Mission = 150
// Advanced Apollo 650
SSTU-SC-B-CMX = 50, Apollo
bluedog-Apollo-Block3-Capsule = 50, Apollo
// Orion
Orion = 200, MatureCapsules // 600
Orion = 50, ImprovedCapsules // 600
SSTU-SC-C-CM = Orion
Orion-Mission = 60
Orion-Mission = 200
// Advanced Orion 650
SSTU-SC-C-CMX = 50, Orion
@@ -111,20 +113,20 @@ TRAININGTIMES
// Vostok
Vostok = 50, BasicCapsules // 300
Vostok = 50, BasicCapsules // 210
IronVostok-Crew-A = Vostok
rn-vostok-sc = Vostok
Vostok-Mission = 60
// Voskhod
Voskhod = 200, Vostok // 500
Voskhod = 50, BasicCapsuleEVA // 310
Voskhod-Crew-A = Voskhod
rn-voskhod-sc = Voskhod
rn-voskhod-airlock = Voskhod
Voskhod-Mission = 60
Voskhod-Mission = 90
// Soyuz
Soyuz = 200, MatureCapsules // 600
Soyuz = 25, MatureCapsules // 550
SSTU-SC-A-DM = Soyuz
SSTU-SC-A-OM = Soyuz
rn-zond-sa = Soyuz
@@ -135,6 +137,6 @@ TRAININGTIMES
rn-lok-bo = Soyuz
t-bo = Soyuz
t-af-bo = Soyuz
Soyuz-Mission = 60
Soyuz-Mission = 135
}
6 changes: 5 additions & 1 deletion GameData/RP-0/MaintenanceSettings.cfg
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
MAINTENANCESETTINGS
{
facilityLevelCostMult = 0.0000005
facilityLevelCostMult = 0.00002
facilityLevelCostPow = 1
kctBPMult = 20
kctResearchMult = 8640000
nautYearlyUpkeepAdd = 5000
nautYearlyUpkeepBase = 500
nautInFlightDailyRate = 100
nautOrbitProficiencyDailyRate = 20
freeCoursesPerLevel = 0.5
courseMultiplierDivisor = 3
}
Binary file modified GameData/RP-0/Plugins/RP0.dll
Binary file not shown.
21 changes: 21 additions & 0 deletions Source/Crew/TrainingDatabase.cs
Original file line number Diff line number Diff line change
@@ -50,6 +50,17 @@ public double GetTime()
return c;
}

public bool HasName(string name)
{
if (this.name == name)
return true;
foreach (string s in children)
if (TrainingDatabase.holders[s].HasName(name))
return true;

return false;
}

#endregion
}

@@ -118,6 +129,16 @@ protected static double _GetTime(string name)
return 0d;
}

public static bool HasName(string training, string name)
{
// Don't have to guard against repeats because we're not summing,
// just getting existence.
if (holders.TryGetValue(training, out var h))
return h.HasName(name);

return false;
}

public static string SynonymReplace(string name)
{
name = Sanitize(name);
39 changes: 38 additions & 1 deletion Source/Maintenance/MaintenanceHandler.cs
Original file line number Diff line number Diff line change
@@ -155,10 +155,47 @@ public void updateUpkeep()

// AC
if (facilityLevelCosts.TryGetValue(SpaceCenterFacility.AstronautComplex, out costs))
acCost = settings.facilityLevelCostMult * Math.Pow(costs[(int)(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.AstronautComplex) * (costs.Length - 0.95f))], settings.facilityLevelCostPow);
{
float lvl = ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.AstronautComplex);
int lvlInt = (int)(lvl * (costs.Length - 0.95f));
acCost = settings.facilityLevelCostMult * Math.Pow(costs[lvlInt], settings.facilityLevelCostPow);
if (RP0.Crew.CrewHandler.Instance != null && RP0.Crew.CrewHandler.Instance.ActiveCourses != null)
{
double courses = RP0.Crew.CrewHandler.Instance.ActiveCourses.Count;
if (courses > 0)
{
courses -= lvlInt * settings.freeCoursesPerLevel;
if (courses > 0d)
acCost *= 1d + (courses * (settings.courseMultiplierDivisor / (settings.courseMultiplierDivisor + lvlInt)));
}
}
}

nautYearlyUpkeep = settings.nautYearlyUpkeepBase + ((double)ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.AstronautComplex) * settings.nautYearlyUpkeepAdd);
nautUpkeep = HighLogic.CurrentGame.CrewRoster.GetActiveCrewCount() * nautYearlyUpkeep * (1d / 365d);
for (int i = HighLogic.CurrentGame.CrewRoster.Count; i-- > 0;)
{
var k = HighLogic.CurrentGame.CrewRoster[i];
if (k.rosterStatus == ProtoCrewMember.RosterStatus.Dead || k.rosterStatus == ProtoCrewMember.RosterStatus.Missing)
continue;

if (k.rosterStatus == ProtoCrewMember.RosterStatus.Assigned)
nautUpkeep += settings.nautInFlightDailyRate;
else
{
// TODO we really should track this independently, in crewhandler, for fast
// use since this runs every frame or so.
for (int j = k.flightLog.Count; j-- > 0;)
{
var e = k.flightLog[j];
if (e.type == "TRAINING_proficiency" && Crew.TrainingDatabase.HasName(e.target, "Orbit"))
{
nautUpkeep += settings.nautOrbitProficiencyDailyRate;
break;
}
}
}
}

researchUpkeep = kctResearchRate * settings.kctResearchMult;

14 changes: 13 additions & 1 deletion Source/Maintenance/MaintenanceSettings.cs
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ namespace RP0
public class MaintenanceSettings : IConfigNode
{
[Persistent]
public double facilityLevelCostMult = 0.0000005d;
public double facilityLevelCostMult = 0.00002d;

[Persistent]
public double facilityLevelCostPow = 1d;
@@ -27,6 +27,18 @@ public class MaintenanceSettings : IConfigNode
[Persistent]
public double nautYearlyUpkeepBase = 500d;

[Persistent]
public double nautInFlightDailyRate = 100d;

[Persistent]
public double nautOrbitProficiencyDailyRate = 20d;

[Persistent]
public double freeCoursesPerLevel = 0.5d;

[Persistent]
public double courseMultiplierDivisor = 3d;

public void Load(ConfigNode node)
{
ConfigNode.LoadObjectFromConfig(this, node);

0 comments on commit 4ae905d

Please sign in to comment.