Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds UI checkbox to toggle local defense gen on and off #32

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions OpenSR/data/components/leader_ai.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ restricted local:
safe bool get_autoBuySupports() const;
safe bool get_autoFillSupports() const;
safe bool get_allowFillFrom() const;
safe bool get_autoBuildSupports() const;

restricted remote:
void addGotoOrder(Object& target, bool append = false);
Expand Down Expand Up @@ -94,6 +95,7 @@ restricted remote:
void set_autoBuySupports(bool value);
void set_autoFillSupports(bool value);
void set_allowFillFrom(bool value);
void set_autoBuildSupports(bool value);

void addExperience(double amount);
void resetLevelExperience(bool resetLevels = false);
Expand Down
6 changes: 5 additions & 1 deletion OpenSR/locales/english/CP_gui.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ STATUS_SHIPLEVEL_DESC: <<
The crew of this flagship consists of seasoned veterans, increasing its health and combat effectiveness by 20%, its support command by 10%, and its shield capacity by 30% for every veterancy level.

Destroy enemy flagships or use a simulator to train your crew to increase a ship's veterancy level.
>>
>>
AUTO_LOCAL_DEFENSE_GEN: Auto Build
TT_AUTO_LOCAL_DEFENSE_GEN: <<
When checked, the fleet will automatically build new support ships if it has local defense generation until the fleet is full.
>>
10 changes: 10 additions & 0 deletions OpenSR/scripts/definitions/generic_effects.as
Original file line number Diff line number Diff line change
Expand Up @@ -3629,6 +3629,11 @@ class AddLocalDefense : GenericEffect {
if(disable_in_combat.boolean && obj.inCombat)
tickDefense = 0;

if (obj.hasLeaderAI && !obj.autoBuildSupports) {
// Don't build if user said not to
tickDefense = 0;
}

// Loop while have defense for this tick to build with
// Fixes vanilla issue blowing all labor on the first support
// even when labor would be leftover
Expand Down Expand Up @@ -3772,6 +3777,11 @@ class AddLocalDefenseAdjacentFlags : GenericEffect {
if(disable_in_combat.boolean && obj.inCombat)
tickDefense = 0;

if (obj.hasLeaderAI && !obj.autoBuildSupports) {
// Don't build if user said not to
tickDefense = 0;
}

if(dat.design is null) {
@dat.design = getDefenseDesign(obj.owner, secondDefense);
if(dat.design !is null)
Expand Down
Loading