Skip to content

Commit

Permalink
Have CPU ships auto-repair
Browse files Browse the repository at this point in the history
  • Loading branch information
daid committed Feb 22, 2025
1 parent 7c3d699 commit 06db87f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions scripts/api/entity/shiptemplatebasedobject.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,19 @@ function Entity:setTemplate(template_name)
if comp.shields and template.__type ~= "station" then
comp.shields.frequency = irandom(0, 20)
end
if comp.internal_rooms == nil then -- No internal rooms, so auto-repair
if comp.beam_weapons then comp.beam_weapons.auto_repair_per_second = 0.005; end
if comp.missile_tubes then comp.missile_tubes.auto_repair_per_second = 0.005 end
if comp.maneuvering_thrusters then comp.maneuvering_thrusters.auto_repair_per_second = 0.005 end
if comp.impulse_engine then comp.impulse_engine.auto_repair_per_second = 0.005 end
if comp.warp_drive then comp.warp_drive.auto_repair_per_second = 0.005 end
if comp.jump_drive then comp.jump_drive.auto_repair_per_second = 0.005 end
if comp.shields then
comp.shields.front_auto_repair_per_second = 0.005
comp.shields.rear_auto_repair_per_second = 0.005
end
if comp.reactor then comp.reactor.auto_repair_per_second = 0.005 end
end
return self
end
--- [DEPRECATED]
Expand Down
2 changes: 1 addition & 1 deletion src/components/shipsystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ShipSystem
float coolant_change_rate_per_second = default_coolant_rate_per_second;
float heat_add_rate_per_second = default_add_heat_rate_per_second;
float power_change_rate_per_second = default_power_rate_per_second;
float auto_repair_per_second = 0.0f; // TODO = 0.005f; for CPU ships
float auto_repair_per_second = 0.0f;

float getSystemEffectiveness();
void addHeat(float amount);
Expand Down
2 changes: 1 addition & 1 deletion src/screens/gm/tweak.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class GuiVectorTweak : public GuiSelector {
auto label = new GuiLabel(row, "", LABEL, 20); \
label->setAlignment(sp::Alignment::CenterRight)->setSize(GuiElement::GuiSizeMax, 30); \
auto ui = new GuiTextTweak(row); \
ui->update_func = [this]() -> string { auto v = entity.getComponent<COMPONENT>(); if (v) return string(v->VALUE); return ""; }; \
ui->update_func = [this]() -> string { auto v = entity.getComponent<COMPONENT>(); if (v) return string(v->VALUE, 3); return ""; }; \
ui->callback([this](string text) { auto v = entity.getComponent<COMPONENT>(); if (v) v->VALUE = text.toFloat(); }); \
} while(0)
#define ADD_BOOL_TWEAK(LABEL, COMPONENT, VALUE) do { \
Expand Down

0 comments on commit 06db87f

Please sign in to comment.