-
Notifications
You must be signed in to change notification settings - Fork 68
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
Active modules now typically consume capacitor charge on initial cycle #293
Merged
jdhirst
merged 2 commits into
EvEmu-Project:staging
from
charles-m-knox:fix-initial-module-cycle-capacitor-usage
Sep 16, 2024
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
#include "StatisticMgr.h" | ||
#include "exploration/Probes.h" | ||
#include "exploration/Scan.h" | ||
#include "inventory/AttributeEnum.h" | ||
#include "ship/Missile.h" | ||
#include "ship/modules/ActiveModule.h" | ||
#include "ship/modules/ModuleItem.h" | ||
|
@@ -541,6 +542,30 @@ uint32 ActiveModule::DoCycle() | |
} | ||
} | ||
|
||
// check if ship has sufficient capacitor capacity - if not, abort the cycle | ||
if (m_modRef->HasAttribute(AttrCapacitorNeed)) { | ||
float remainingCapacitorCharge = m_shipRef->GetAttribute(AttrCapacitorCharge).get_float(); | ||
float requiredCapacitorCharge = GetAttribute(AttrCapacitorNeed).get_float(); | ||
|
||
float newCap = remainingCapacitorCharge - requiredCapacitorCharge; | ||
|
||
if (newCap < 0) { | ||
m_shipRef->GetPilot()->SendNotifyMsg( | ||
"This module requires %.0f GJ, but your capacitor only has %.0f GJ remaining.", | ||
requiredCapacitorCharge, | ||
remainingCapacitorCharge | ||
); | ||
|
||
AbortCycle(); | ||
|
||
return 0; | ||
} | ||
|
||
float shipTotalCapacitor = m_shipRef->GetAttribute(AttrCapacitorCapacity).get_float(); | ||
|
||
m_shipRef->SetShipCapacitorLevel(newCap / shipTotalCapacitor); | ||
} | ||
Comment on lines
+548
to
+569
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Consider extracting the capacitor check logic into a separate method The capacitor check logic is duplicated in both DoCycle() and CanActivate(). Extracting this into a separate method would improve maintainability and reduce the risk of inconsistencies.
|
||
|
||
// not sure if this is entirely accurate...wip | ||
charles-m-knox marked this conversation as resolved.
Show resolved
Hide resolved
|
||
switch (m_modRef->groupID()) { | ||
case EVEDB::invGroups::Projectile_Weapon: | ||
|
@@ -1045,6 +1070,21 @@ bool ActiveModule::CanActivate() | |
} | ||
} | ||
|
||
if (m_modRef->HasAttribute(AttrCapacitorNeed)) { | ||
float remainingCapacitorCharge = m_shipRef->GetAttribute(AttrCapacitorCharge).get_float(); | ||
float requiredCapacitorCharge = GetAttribute(AttrCapacitorNeed).get_float(); | ||
|
||
if (requiredCapacitorCharge > remainingCapacitorCharge) { | ||
m_shipRef->GetPilot()->SendNotifyMsg( | ||
"This module requires %.0f GJ, but your capacitor only has %.0f GJ remaining.", | ||
requiredCapacitorCharge, | ||
remainingCapacitorCharge | ||
); | ||
|
||
return false; | ||
} | ||
} | ||
|
||
// check distance for targetable actions | ||
if (m_targetSE != nullptr) { | ||
// weapons use ships AttrMaxTargetRange which is checked in TargetMgr | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
suggestion: Consider rephrasing the error message to use percentage values
Using percentage values instead of absolute GJ values in the error message could be more intuitive for players who may not be familiar with the unit 'GJ'.