Skip to content

Commit 2a59b6a

Browse files
committed
Add improvements for airstrike flare visuals
1 parent 5c73877 commit 2a59b6a

File tree

8 files changed

+86
-1
lines changed

8 files changed

+86
-1
lines changed

docs/Fixed-or-Improved-Logics.md

+17
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
195195
- Fixed an issue that caused `IsSonic=true` wave drawing to crash the game if the wave traveled over a certain distance.
196196
- Buildings with foundation bigger than 1x1 can now recycle spawner correctly.
197197
- Electric bolts that are supposed to update their position based on units current firing coords (by default, those fired by vehicles) now do so correctly for more than one concurrent electric bolt.
198+
- Fixed an issue where airstrike flare line drawn to target at lower elevation would clip.
198199

199200
## Fixes / interactions with other extensions
200201

@@ -626,6 +627,22 @@ BallisticScatter.Max= ; floating point value, distance in cells
626627

627628
## Technos
628629

630+
### Airstrike flare customizations
631+
632+
- It is now possible to customize color of airstrike flare tint on target on the TechnoType calling in the airstrike as well as customize the color of the line drawn to target.
633+
- `LaserTargetColor` can be used to set the index of color from `[ColorAdd]` defaults to `[AudioVisual]` -> `LaserTargetColor`.
634+
- `AirstrikeLineColor` sets the color of the line and dot drawn from firer to target, defaults to `[AudioVisual]` -> `AirstrikeLineColor`.
635+
636+
In `rulesmd.ini`:
637+
```ini
638+
[AudioVisual]
639+
AirstrikeLineColor=255,0,0 ; integer - Red,Green,Blue
640+
641+
[SOMETECHNO] ; TechnoType
642+
LaserTargetColor= ; integer - [ColorAdd] index
643+
AirstrikeLineColor= ; integer - Red,Green,Blue
644+
```
645+
629646
### Building-provided self-healing customization
630647

631648
- It is now possible to set a global cap for the effects of `InfantryGainSelfHeal` and `UnitsGainSelfHeal` by setting `InfantryGainSelfHealCap` & `UnitsGainSelfHealCap` under `[General]`, respectively.

docs/Whats-New.md

+2
Original file line numberDiff line numberDiff line change
@@ -346,12 +346,14 @@ New:
346346
- Projectile subject to ground check before firing (by CrimRecya)
347347
- Delay automatic attack on the controlled unit (by CrimRecya)
348348
- `BombParachute` deglobalization (by TaranDahl)
349+
- [Customizable airstrike flare colors](Fixed-or-Improved-Logics.md#airstrike-flare-customizations) (by Starkku)
349350
350351
Vanilla fixes:
351352
- Prevent the units with locomotors that cause problems from entering the tank bunker (by TaranDahl)
352353
- Fixed an issue that harvesters with amphibious movement zone can not automatically return to refineries with `WaterBound` on water surface (by NetsuNegi)
353354
- Buildings with foundation bigger than 1x1 can now recycle spawned correctly (by TaranDahl)
354355
- Electric bolts that are supposed to update their position based on units current firing coords (by default, those fired by vehicles) now do so correctly for more than one concurrent electric bolt (by Starkku)
356+
- Fixed an issue where airstrike flare line drawn to target at lower elevation would clip (by Starkku)
355357
356358
Fixes / interactions with other extensions:
357359
- Allowed `AuxBuilding` and Ares' `SW.Aux/NegBuildings` to count building upgrades (by Ollerus)

src/Ext/Rules/Body.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)
162162
this->IronCurtain_ExtraTintIntensity.Read(exINI, GameStrings::AudioVisual, "IronCurtain.ExtraTintIntensity");
163163
this->ForceShield_ExtraTintIntensity.Read(exINI, GameStrings::AudioVisual, "ForceShield.ExtraTintIntensity");
164164
this->ColorAddUse8BitRGB.Read(exINI, GameStrings::AudioVisual, "ColorAddUse8BitRGB");
165+
this->AirstrikeLineColor.Read(exINI, GameStrings::AudioVisual, "AirstrikeLineColor");
165166

166167
this->CrateOnlyOnLand.Read(exINI, GameStrings::CrateRules, "CrateOnlyOnLand");
167168
this->UnitCrateVehicleCap.Read(exINI, GameStrings::CrateRules, "UnitCrateVehicleCap");
@@ -382,6 +383,7 @@ void RulesExt::ExtData::Serialize(T& Stm)
382383
.Process(this->ForceShield_ExtraTintIntensity)
383384
.Process(this->AllowWeaponSelectAgainstWalls)
384385
.Process(this->ColorAddUse8BitRGB)
386+
.Process(this->AirstrikeLineColor)
385387
.Process(this->ROF_RandomDelay)
386388
.Process(this->ToolTip_Background_Color)
387389
.Process(this->ToolTip_Background_Opacity)

src/Ext/Rules/Body.h

+2
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ class RulesExt
121121
Valueable<double> IronCurtain_ExtraTintIntensity;
122122
Valueable<double> ForceShield_ExtraTintIntensity;
123123
Valueable<bool> ColorAddUse8BitRGB;
124+
Valueable<ColorStruct> AirstrikeLineColor;
124125

125126
Valueable<PartialVector2D<int>> ROF_RandomDelay;
126127
Valueable<ColorStruct> ToolTip_Background_Color;
@@ -278,6 +279,7 @@ class RulesExt
278279
, ForceShield_ExtraTintIntensity { 0.0 }
279280
, AllowWeaponSelectAgainstWalls { false }
280281
, ColorAddUse8BitRGB { false }
282+
, AirstrikeLineColor { { 255, 0, 0 } }
281283
, ROF_RandomDelay { { 0 ,2 } }
282284
, ToolTip_Background_Color { { 0, 0, 0 } }
283285
, ToolTip_Background_Opacity { 100 }

src/Ext/Techno/Body.Internal.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,19 @@ int TechnoExt::GetTintColor(TechnoClass* pThis, bool invulnerability, bool airst
164164
if (pThis)
165165
{
166166
if (invulnerability && pThis->IsIronCurtained())
167+
{
167168
tintColor |= GeneralUtils::GetColorFromColorAdd(pThis->ForceShielded ? RulesClass::Instance->ForceShieldColor : RulesClass::Instance->IronCurtainColor);
169+
}
168170
if (airstrike && pThis->Airstrike && pThis->Airstrike->Target == pThis)
169-
tintColor |= GeneralUtils::GetColorFromColorAdd(RulesClass::Instance->LaserTargetColor);
171+
{
172+
auto const pTypeExt = TechnoTypeExt::ExtMap.Find(pThis->Airstrike->Owner->GetTechnoType());
173+
auto index = pTypeExt->LaserTargetColor.Get(RulesClass::Instance->LaserTargetColor);
174+
tintColor |= GeneralUtils::GetColorFromColorAdd(index);
175+
}
170176
if (berserk && pThis->Berzerk)
177+
{
171178
tintColor |= GeneralUtils::GetColorFromColorAdd(RulesClass::Instance->BerserkColor);
179+
}
172180
}
173181

174182
return tintColor;

src/Ext/Techno/Hooks.cpp

+44
Original file line numberDiff line numberDiff line change
@@ -723,3 +723,47 @@ DEFINE_HOOK(0x465D40, BuildingClass_Is1x1AndUndeployable_BuildingMassSelectable,
723723

724724
#pragma endregion
725725

726+
#pragma region DrawAirstrikeFlare
727+
728+
namespace DrawAirstrikeFlareTemp
729+
{
730+
TechnoClass* pTechno = nullptr;
731+
}
732+
733+
DEFINE_HOOK(0x705860, TechnoClass_DrawAirstrikeFlare_SetContext, 0x8)
734+
{
735+
GET(TechnoClass*, pThis, ECX);
736+
737+
// This is not used in vanilla function so ECX gets overwritten later.
738+
DrawAirstrikeFlareTemp::pTechno = pThis;
739+
740+
return 0;
741+
}
742+
743+
DEFINE_HOOK(0x7058F6, TechnoClass_DrawAirstrikeFlare, 0x5)
744+
{
745+
enum { SkipGameCode = 0x705976 };
746+
747+
GET(int, zSrc, EBP);
748+
GET(int, zDest, EBX);
749+
REF_STACK(ColorStruct, color, STACK_OFFSET(0x70, -0x60));
750+
751+
// Fix depth buffer value.
752+
int zValue = Math::min(zSrc, zDest);
753+
R->EBP(zValue);
754+
R->EBX(zValue);
755+
756+
// Allow custom colors.
757+
auto const pThis = DrawAirstrikeFlareTemp::pTechno;
758+
auto const baseColor = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType())->AirstrikeLineColor.Get(RulesExt::Global()->AirstrikeLineColor);
759+
double percentage = Randomizer::Global->RandomRanged(745, 1000) / 1000.0;
760+
color = { (BYTE)(baseColor.R * percentage), (BYTE)(baseColor.G * percentage), (BYTE)(baseColor.B * percentage) };
761+
R->ESI(Drawing::RGB_To_Int(baseColor));
762+
763+
return SkipGameCode;
764+
}
765+
766+
// Skip setting color for the dot, it is already done in previous hook.
767+
DEFINE_JUMP(LJMP, 0x705986, 0x7059C7);
768+
769+
#pragma endregion

src/Ext/TechnoType/Body.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,10 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
296296

297297
this->ReloadInTransport.Read(exINI, pSection, "ReloadInTransport");
298298
this->ForbidParallelAIQueues.Read(exINI, pSection, "ForbidParallelAIQueues");
299+
300+
this->LaserTargetColor.Read(exINI, pSection, "LaserTargetColor");
301+
this->AirstrikeLineColor.Read(exINI, pSection, "AirstrikeLineColor");
302+
299303
this->ShieldType.Read<true>(exINI, pSection, "ShieldType");
300304

301305
this->Ammo_AddOnDeploy.Read(exINI, pSection, "Ammo.AddOnDeploy");
@@ -690,6 +694,8 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm)
690694
.Process(this->InitialStrength)
691695
.Process(this->ReloadInTransport)
692696
.Process(this->ForbidParallelAIQueues)
697+
.Process(this->LaserTargetColor)
698+
.Process(this->AirstrikeLineColor)
693699
.Process(this->ShieldType)
694700
.Process(this->PassengerDeletionType)
695701

src/Ext/TechnoType/Body.h

+4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ class TechnoTypeExt
5555
Nullable<int> InitialStrength;
5656
Valueable<bool> ReloadInTransport;
5757
Valueable<bool> ForbidParallelAIQueues;
58+
Nullable<int> LaserTargetColor;
59+
Nullable<ColorStruct> AirstrikeLineColor;
5860

5961
Valueable<ShieldTypeClass*> ShieldType;
6062
std::unique_ptr<PassengerDeletionTypeClass> PassengerDeletionType;
@@ -319,6 +321,8 @@ class TechnoTypeExt
319321
, InitialStrength {}
320322
, ReloadInTransport { false }
321323
, ForbidParallelAIQueues { false }
324+
, LaserTargetColor {}
325+
, AirstrikeLineColor {}
322326
, ShieldType {}
323327
, PassengerDeletionType { nullptr }
324328

0 commit comments

Comments
 (0)