-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
…ation and fixes.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
Status: AncientDeveloper | ||
Visible To: Nobody | ||
|
||
EnableModifier(SupportCapModule::SupportCapacityFactor(1.05)) | ||
EnableModifier(SupportCapModule::MassFactor(1.25)) | ||
ModEmpireAttribute(EmpireSupportCapacityMassFactor, Multiply, 1.25) | ||
ModEmpireAttribute(EmpireSupportCapacityFactor, Multiply, 1.05) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ import research; | |
import empire_effects; | ||
import repeat_hooks; | ||
import planet_types; | ||
import ancient_buffs; | ||
#section server | ||
import object_creation; | ||
from components.ObjectManager import getDefenseDesign; | ||
|
@@ -5003,68 +5004,104 @@ class AddBonusShield : GenericEffect { | |
#section all | ||
}; | ||
|
||
class SupportCapacityData { | ||
double multiplier = 1; | ||
any data; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
DaloLorn
Author
Member
|
||
} | ||
|
||
class AddBonusSupportCapPct : GenericEffect { | ||
Document doc("Add a percentage bonus support capacity to this fleet."); | ||
Argument percentage(AT_Decimal, "0", doc="Percentage of maximum support cap to add."); | ||
|
||
#section server | ||
void enable(Object& obj, any@ data) const override { | ||
const Design@ dsg = null; | ||
data.store(@dsg); | ||
SupportCapacityData info; | ||
info.data.store(@dsg); | ||
if(obj.owner !is null) | ||
info.multiplier = obj.owner.EmpireSupportCapacityFactor; | ||
data.store(@info); | ||
} | ||
|
||
void tick(Object& obj, any@ data, double time) const override { | ||
Ship@ ship = cast<Ship>(obj); | ||
if(ship is null) | ||
return; | ||
|
||
SupportCapacityData@ info; | ||
const Design@ newDesign = ship.blueprint.design; | ||
const Design@ oldDesign; | ||
data.retrieve(@oldDesign); | ||
data.retrieve(@info); | ||
info.data.retrieve(@oldDesign); | ||
|
||
// Account for Developer changes. | ||
int given = 0, newGiven = 0; | ||
if(obj.owner !is null) { | ||
if(info.multiplier != obj.owner.EmpireSupportCapacityFactor) { | ||
const Design@ dsg = oldDesign !is null ? oldDesign : newDesign; | ||
given = dsg.total(SV_SupportCapacity) * percentage.decimal * info.multiplier; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
DaloLorn
Author
Member
|
||
newGiven = getSupportCommandFor(dsg, obj.owner) * percentage.decimal; | ||
|
||
if(given != newGiven) | ||
ship.modSupplyCapacity(newGiven - given); | ||
} | ||
info.multiplier = obj.owner.EmpireSupportCapacityFactor; | ||
} | ||
|
||
if(oldDesign !is newDesign) { | ||
int given = 0; | ||
if(oldDesign !is null) | ||
given = oldDesign.total(SV_SupportCapacity) * percentage.decimal; | ||
given = getSupportCommandFor(oldDesign, obj.owner) * percentage.decimal; | ||
This comment has been minimized.
Sorry, something went wrong.
DaloLorn
Author
Member
|
||
int newGiven = 0; | ||
if(newDesign !is null) | ||
newGiven = newDesign.total(SV_SupportCapacity) * percentage.decimal; | ||
newGiven = getSupportCommandFor(newDesign, obj.owner) * percentage.decimal; | ||
|
||
if(given != newGiven) | ||
ship.modSupplyCapacity(newGiven - given); | ||
data.store(@newDesign); | ||
info.data.store(@newDesign); | ||
} | ||
data.store(@info); | ||
} | ||
|
||
void disable(Object& obj, any@ data) const override { | ||
Ship@ ship = cast<Ship>(obj); | ||
if(ship is null) | ||
return; | ||
|
||
SupportCapacityData@ info; | ||
const Design@ oldDesign; | ||
data.retrieve(@oldDesign); | ||
data.retrieve(@info); | ||
info.data.retrieve(@oldDesign); | ||
|
||
int given = 0; | ||
if(oldDesign !is null) | ||
given = oldDesign.total(SV_SupportCapacity) * percentage.decimal; | ||
given = getSupportCommandFor(oldDesign, obj.owner) * percentage.decimal; | ||
if(given != 0.0) { | ||
ship.modSupplyCapacity(-given); | ||
|
||
@oldDesign = null; | ||
data.store(@oldDesign); | ||
info.data.store(@oldDesign); | ||
} | ||
info.multiplier = 1; | ||
data.store(@info); | ||
} | ||
|
||
void save(any@ data, SaveFile& file) const override { | ||
SupportCapacityData@ info; | ||
const Design@ dsg; | ||
data.retrieve(@dsg); | ||
data.retrieve(@info); | ||
info.data.retrieve(@dsg); | ||
file << dsg; | ||
file << info.multiplier; | ||
} | ||
|
||
void load(any@ data, SaveFile& file) const override { | ||
SupportCapacityData info; | ||
const Design@ dsg; | ||
file >> dsg; | ||
data.store(@dsg); | ||
info.data.store(@dsg); | ||
file >> info.multiplier; | ||
data.store(@info); | ||
} | ||
#section all | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ import empire_ai.weasel.WeaselAI; | |
|
||
import util.design_export; | ||
import util.random_designs; | ||
import ancient_buffs; | ||
|
||
interface RaceDesigns { | ||
bool preCompose(DesignTarget@ target); | ||
|
@@ -173,7 +174,7 @@ tidy final class DesignTarget { | |
|
||
//Value support capacity where appropriate | ||
if(purpose == DP_Combat) { | ||
double supCap = dsg.total(SV_SupportCapacity); | ||
double supCap = getSupportCommandFor(dsg, ai.empire); | ||
This comment has been minimized.
Sorry, something went wrong.
Skeletonxf
Member
|
||
double avgHP = 0, avgDPS = 0, avgDrain = 0.0; | ||
cast<Designs>(ai.designs).getSupportAverages(avgHP, avgDPS, avgDrain); | ||
|
||
|
@@ -591,7 +592,7 @@ final class Designs : AIComponent { | |
return DP_Miner; | ||
if(dsg.size == 16.0 && dsg.total(SV_DPS) < 2.0) | ||
return DP_Scout; | ||
if(dps > 0.1 * dsg.size || dsg.total(SV_SupportCapacity) > 0) | ||
if(dps > 0.1 * dsg.size || getSupportCommandFor(dsg, ai.empire) > 0) | ||
return DP_Combat; | ||
return defaultPurpose; | ||
} | ||
|
1 comment
on commit 025c638
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Skeletonxf You will want to review the diffs for Constructible
, ShipConstructible
, and generic_effects
. The other files are less relevant, to varying degrees: For instance, I'll be extremely surprised if BasicAI sees use at all, much less in a context where my changes will have an effect on it, but something like, say, WeaselAI or the Remnant ship spawner, could conceivably be put in a position where there was a measurable difference in support capacity.
(Also, I've fixed my mass updating oversight now. I think.)
shouldn't this be
const Design@
instead of any?otherwise looks good, I'll be porting this back