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

Offline power plant indicator #1104

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a847b76
Initial commit
Fryone Jul 16, 2023
f576228
Update Whats-New.md
Fryone Jul 16, 2023
12edf3c
Updated conditions
Fryone Jul 18, 2023
03bd804
Added disabler
Fryone Jul 21, 2023
9ee1837
Merge branch 'develop' into fryone/lowpower_sign
Fryone Aug 7, 2023
183e5da
Update src/Ext/Building/Hooks.cpp
Fryone Aug 8, 2023
12f6034
Update src/Ext/Building/Hooks.cpp
Fryone Aug 8, 2023
cd450a8
Update src/Ext/Building/Hooks.cpp
Fryone Aug 8, 2023
f50a97a
Fixes
Fryone Aug 8, 2023
25562b3
Update Whats-New.md
Fryone Aug 8, 2023
bd7cc59
Merge branch 'develop' into fryone/lowpower_sign
Fryone Aug 19, 2023
441b00e
Merge branch 'develop' into fryone/lowpower_sign
Fryone Aug 24, 2023
3b4a132
Update src/Ext/Building/Hooks.cpp
Fryone Aug 26, 2023
1d61437
Update src/Ext/Techno/Hooks.cpp
Fryone Aug 26, 2023
11fa48c
Update src/Ext/Building/Hooks.cpp
Fryone Aug 26, 2023
36f6538
Update src/Ext/Building/Hooks.cpp
Fryone Aug 26, 2023
a0430ba
Update src/Ext/Building/Hooks.cpp
Fryone Aug 26, 2023
0b3a160
Update src/Ext/Building/Hooks.cpp
Fryone Aug 26, 2023
9633056
Update docs/Fixed-or-Improved-Logics.md
Fryone Aug 26, 2023
c30ebc9
Merge branch 'fryone/lowpower_sign' of https://github.com/Fryone/Phob…
Fryone Aug 26, 2023
9d2f4cd
Custom shape param
Fryone Aug 27, 2023
afa3759
Small fixes
Fryone Aug 28, 2023
7c34a27
Merge branch 'develop' into fryone/lowpower_sign
Fryone Aug 31, 2023
b20c487
Merge branch 'develop' into fryone/lowpower_sign
Fryone Sep 6, 2023
95e429b
Merge branch 'develop' into fryone/lowpower_sign
Fryone Sep 13, 2023
8a24c05
Merge branch 'develop' into fryone/lowpower_sign
Fryone Sep 14, 2023
08a6267
Merge branch 'develop' into fryone/lowpower_sign
Fryone Sep 26, 2023
9c6abbd
Merge branch 'develop' into fryone/lowpower_sign
Fryone Sep 27, 2023
8ee35b5
Merge branch 'develop' into fryone/lowpower_sign
Fryone Sep 29, 2023
12f70f4
Merge remote-tracking branch 'upstream/develop' into fryone/lowpower_…
Fryone Oct 2, 2023
ae4fce0
Merge remote-tracking branch 'upstream/develop' into fryone/lowpower_…
Fryone Oct 7, 2023
047f17a
Update Hooks.cpp
Fryone Oct 7, 2023
e260985
Merge remote-tracking branch 'upstream/develop' into fryone/lowpower_…
Fryone May 17, 2024
64bbaa8
rework update
Fryone May 18, 2024
99c82c2
Update Hooks.cpp
Fryone May 18, 2024
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
1 change: 1 addition & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ This page lists all the individual contributions to the project by their author.
- Vehicle voxel turret shadows & body multi-section shadows
- **Fryone**
- Customizable ElectricBolt Arcs
- Offline power plant indicator
- **Ares developers**
- YRpp and Syringe which are used, save/load, project foundation and generally useful code from Ares
- unfinished RadTypes code
Expand Down
16 changes: 16 additions & 0 deletions docs/Fixed-or-Improved-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,22 @@ In `rulesmd.ini`:
SellBuildupLength=23 ; integer, number of buildup frames to play
```

### Offline power plant indicator

- If `DrawPowerOffline` is set, `POWEROFF.SHP` indicator will appear on power plants when being offline, for example, drained by floating disk, infiltrated or disabled when using ForceShield.
- `DrawPowerOffline.Offset` is used to vertically adjust position of indicator.
- `DisablePowerOfflineIcon` is used to disable indicator per building type.

In `rulesmd.ini`:
```ini
[AudioVisual]
DrawPowerOffline=false ; boolean
DrawPowerOffline.Offset=0 ; integer, vertical offset,

[SOMEBUILDING]
DisablePowerOfflineIcon=false ; boolean
```

## Projectiles

### Cluster scatter distance customization
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ New:
- Unhardcoded timer blinking color scheme (by Starkku)
- Customizing shield self-healing timer restart when shield is damaged (by Starkku)
- Customizing minimum & maximum amount of damage shield can take from a single hit (by Starkku)
- Offline power plant indicator (by Fryone)

Vanilla fixes:
- Allow AI to repair structures built from base nodes/trigger action 125/SW delivery in single player missions (by Trsdy)
Expand Down
45 changes: 45 additions & 0 deletions src/Ext/Building/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,3 +430,48 @@ DEFINE_HOOK(0x4511D6, BuildingClass_AnimationAI_SellBuildup, 0x7)

return pTypeExt->SellBuildupLength == pThis->Animation.Value ? Continue : Skip;
}

//Addition to Ares' Extras
DEFINE_HOOK(0x6F5347, TechnoClass_DrawExtras_OfflinePlants, 0x7)
{
GET(TechnoClass*, pThis, EBP);
GET_STACK(RectangleStruct*, pRect, 0xA0);

if(auto pBld = abstract_cast<BuildingClass*>(pThis))
{
if (!RulesExt::Global()->DrawPowerOffline)
{
R->ESI(pRect);
return 0x6F534E;
}

const auto pBldExt = BuildingTypeExt::ExtMap.Find(pBld->Type);
bool showLowPower = (pBldExt->DisablePowerOfflineIcon == false)
&& FileSystem::POWEROFF_SHP
&& (pBld->Type->PowerBonus > 0)
&& (pBld->Factory == nullptr)
&& (pBld->IsPowerOnline() == false || pBld->IsBeingDrained())
&& (pBld->IsBeingWarpedOut() == false)
&& (pBld->WarpingOut == false)
&& ((pBld->GetCurrentMission() != Mission::Selling) && (pBld->GetCurrentMission() != Mission::Construction))
&& (pBld->CloakState == CloakState::Uncloaked);

if (!showLowPower || MapClass::Instance->GetCellAt(pBld->GetMapCoords())->IsShrouded())
{
R->ESI(pRect);
return 0x6F534E;
}

Point2D nPoint;
TacticalClass::Instance->CoordsToClient(pBld->GetRenderCoords(), &nPoint);

nPoint.Y += 22; // wrench offset
nPoint.Y -= RulesExt::Global()->DrawPowerOffline_Offset;

const int speed = Math::max(GameOptionsClass::Instance->GetAnimSpeed(14) / 4, 2);
const int frame = (FileSystem::POWEROFF_SHP->Frames * (Unsorted::CurrentFrame % speed)) / speed;
DSurface::Temp->DrawSHP(FileSystem::MOUSE_PAL, FileSystem::POWEROFF_SHP, frame, &nPoint, pRect, BlitterFlags(0xE00), 0, 0, ZGradient::Ground, 1000, 0, 0, 0, 0, 0);
}
R->ESI(pRect);
return 0x6F534E;
}
2 changes: 2 additions & 0 deletions src/Ext/BuildingType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ void BuildingTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)

this->ConsideredVehicle.Read(exINI, pSection, "ConsideredVehicle");
this->SellBuildupLength.Read(exINI, pSection, "SellBuildupLength");
this->DisablePowerOfflineIcon.Read(exINI, pSection, "DisablePowerOfflineIcon");

// Ares tag
this->SpyEffect_Custom.Read(exINI, pSection, "SpyEffect.Custom");
Expand Down Expand Up @@ -234,6 +235,7 @@ void BuildingTypeExt::ExtData::Serialize(T& Stm)
.Process(this->ConsideredVehicle)
.Process(this->ZShapePointMove_OnBuildup)
.Process(this->SellBuildupLength)
.Process(this->DisablePowerOfflineIcon)
;
}

Expand Down
2 changes: 2 additions & 0 deletions src/Ext/BuildingType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class BuildingTypeExt
Nullable<bool> ConsideredVehicle;
Valueable<bool> ZShapePointMove_OnBuildup;
Valueable<int> SellBuildupLength;
Valueable<bool> DisablePowerOfflineIcon;

ExtData(BuildingTypeClass* OwnerObject) : Extension<BuildingTypeClass>(OwnerObject)
, PowersUp_Owner { AffectedHouse::Owner }
Expand Down Expand Up @@ -96,6 +97,7 @@ class BuildingTypeExt
, ConsideredVehicle {}
, ZShapePointMove_OnBuildup { false }
, SellBuildupLength { 23 }
, DisablePowerOfflineIcon { false }
{ }

// Ares 0.A functions
Expand Down
5 changes: 5 additions & 0 deletions src/Ext/Rules/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)
this->AnimRemapDefaultColorScheme.Read(exINI, GameStrings::AudioVisual, "AnimRemapDefaultColorScheme");
this->TimerBlinkColorScheme.Read(exINI, GameStrings::AudioVisual, "TimerBlinkColorScheme");

this->DrawPowerOffline.Read(exINI, GameStrings::AudioVisual, "DrawPowerOffline");
this->DrawPowerOffline_Offset.Read(exINI, GameStrings::AudioVisual, "DrawPowerOffline.Offset");

this->AllowParallelAIQueues.Read(exINI, "GlobalControls", "AllowParallelAIQueues");
this->ForbidParallelAIQueues_Aircraft.Read(exINI, "GlobalControls", "ForbidParallelAIQueues.Infantry");
this->ForbidParallelAIQueues_Building.Read(exINI, "GlobalControls", "ForbidParallelAIQueues.Building");
Expand Down Expand Up @@ -249,6 +252,8 @@ void RulesExt::ExtData::Serialize(T& Stm)
.Process(this->CrateOnlyOnLand)
.Process(this->RadialIndicatorVisibility)
.Process(this->DrawTurretShadow)
.Process(this->DrawPowerOffline)
.Process(this->DrawPowerOffline_Offset)
.Process(this->AnimRemapDefaultColorScheme)
.Process(this->TimerBlinkColorScheme)
.Process(this->Buildings_DefaultDigitalDisplayTypes)
Expand Down
5 changes: 5 additions & 0 deletions src/Ext/Rules/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ class RulesExt
ValueableIdx<ColorScheme> AnimRemapDefaultColorScheme;
ValueableIdx<ColorScheme> TimerBlinkColorScheme;

Valueable<bool> DrawPowerOffline;
Valueable<int> DrawPowerOffline_Offset;

ValueableVector<DigitalDisplayTypeClass*> Buildings_DefaultDigitalDisplayTypes;
ValueableVector<DigitalDisplayTypeClass*> Infantry_DefaultDigitalDisplayTypes;
ValueableVector<DigitalDisplayTypeClass*> Vehicles_DefaultDigitalDisplayTypes;
Expand Down Expand Up @@ -147,6 +150,8 @@ class RulesExt
, CrateOnlyOnLand { false }
, RadialIndicatorVisibility { AffectedHouse::Allies }
, DrawTurretShadow { false }
, DrawPowerOffline { false }
, DrawPowerOffline_Offset { 0 }
, AnimRemapDefaultColorScheme { 0 }
, TimerBlinkColorScheme { 5 }
, Buildings_DefaultDigitalDisplayTypes {}
Expand Down
4 changes: 3 additions & 1 deletion src/Ext/Techno/Hooks.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include <ScenarioClass.h>

#include <GameOptionsClass.h>
#include <TacticalClass.h>
#include "Body.h"

#include <Ext/WarheadType/Body.h>
Expand Down