Skip to content

Commit 66d09bb

Browse files
committed
Add improvements for airstrike flare visuals
1 parent 2c5c071 commit 66d09bb

File tree

9 files changed

+94
-3
lines changed

9 files changed

+94
-3
lines changed

CREDITS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ This page lists all the individual contributions to the project by their author.
260260
- Vehicles keeping target on move command
261261
- `IsSonic` wave drawing crash fix
262262
- Customizable electric bolt duration and electric bolt-related fixes
263+
- Airstrike flare visual customizations
263264
- **Morton (MortonPL)**:
264265
- `XDrawOffset` for animations
265266
- Shield passthrough & absorption

docs/Fixed-or-Improved-Logics.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
224224
- Fixed the bug that 'AllowAirstrike=no' cannot completely prevent air strikes from being launched against it.
225225
- Fixed the issue where computer players did not search for new enemies after defeating them or forming alliances with them.
226226
- Fixed an issue that spawned `Strafe` aircraft on aircraft carriers may not be able to return normally if aircraft carriers moved a short distance when the aircraft is landing.
227+
- Fixed an issue where airstrike flare line drawn to target at lower elevation would clip.
227228

228229
## Fixes / interactions with other extensions
229230

@@ -703,6 +704,22 @@ BallisticScatter.Max= ; floating point value, distance in cells
703704

704705
## Technos
705706

707+
### Airstrike flare customizations
708+
709+
- 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.
710+
- `LaserTargetColor` can be used to set the index of color from `[ColorAdd]` defaults to `[AudioVisual]` -> `LaserTargetColor`.
711+
- `AirstrikeLineColor` sets the color of the line and dot drawn from firer to target, defaults to `[AudioVisual]` -> `AirstrikeLineColor`.
712+
713+
In `rulesmd.ini`:
714+
```ini
715+
[AudioVisual]
716+
AirstrikeLineColor=255,0,0 ; integer - Red,Green,Blue
717+
718+
[SOMETECHNO] ; TechnoType
719+
LaserTargetColor= ; integer - [ColorAdd] index
720+
AirstrikeLineColor= ; integer - Red,Green,Blue
721+
```
722+
706723
### Alternate FLH customizations
707724

708725
- `AlternateFLH.OnTurret` can be used to customize whether or not `AlternateFLHN` used for `OpenTopped` transport firing coordinates, multiple mind control link offsets etc. is calculated relative to the unit's turret if available or body.

docs/Whats-New.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ New:
372372
- Amphibious access vehicle (by CrimRecya)
373373
- Allow miners do area guard (by TaranDahl)
374374
- Make harvesters do addtional scan after unload (by TaranDahl)
375+
- [Customizable airstrike flare colors](Fixed-or-Improved-Logics.md#airstrike-flare-customizations) (by Starkku)
375376
376377
Vanilla fixes:
377378
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)
@@ -393,6 +394,7 @@ Vanilla fixes:
393394
- Separated the AirstrikeClass pointer between the attacker/aircraft and the target to avoid erroneous overwriting issues (by NetsuNegi)
394395
- Fixed the bug that buildings will always be tinted as airstrike owner (by NetsuNegi)
395396
- Fixed the issue where computer players did not search for new enemies after defeating them or forming alliances with them (by FlyStar)
397+
- Fixed an issue where airstrike flare line drawn to target at lower elevation would clip (by Starkku)
396398
397399
Phobos fixes:
398400
- Fixed an issue that MCV will self-destruct when using trigger 107 to teleport (by CrimRecya)

src/Ext/Rules/Body.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)
169169
this->IronCurtain_ExtraTintIntensity.Read(exINI, GameStrings::AudioVisual, "IronCurtain.ExtraTintIntensity");
170170
this->ForceShield_ExtraTintIntensity.Read(exINI, GameStrings::AudioVisual, "ForceShield.ExtraTintIntensity");
171171
this->ColorAddUse8BitRGB.Read(exINI, GameStrings::AudioVisual, "ColorAddUse8BitRGB");
172+
this->AirstrikeLineColor.Read(exINI, GameStrings::AudioVisual, "AirstrikeLineColor");
172173

173174
this->CrateOnlyOnLand.Read(exINI, GameStrings::CrateRules, "CrateOnlyOnLand");
174175
this->UnitCrateVehicleCap.Read(exINI, GameStrings::CrateRules, "UnitCrateVehicleCap");
@@ -410,6 +411,7 @@ void RulesExt::ExtData::Serialize(T& Stm)
410411
.Process(this->ForceShield_ExtraTintIntensity)
411412
.Process(this->AllowWeaponSelectAgainstWalls)
412413
.Process(this->ColorAddUse8BitRGB)
414+
.Process(this->AirstrikeLineColor)
413415
.Process(this->ROF_RandomDelay)
414416
.Process(this->ToolTip_Background_Color)
415417
.Process(this->ToolTip_Background_Opacity)

src/Ext/Rules/Body.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ class RulesExt
127127
Valueable<double> IronCurtain_ExtraTintIntensity;
128128
Valueable<double> ForceShield_ExtraTintIntensity;
129129
Valueable<bool> ColorAddUse8BitRGB;
130+
Valueable<ColorStruct> AirstrikeLineColor;
130131

131132
Valueable<PartialVector2D<int>> ROF_RandomDelay;
132133
Valueable<ColorStruct> ToolTip_Background_Color;
@@ -305,6 +306,7 @@ class RulesExt
305306
, ForceShield_ExtraTintIntensity { 0.0 }
306307
, AllowWeaponSelectAgainstWalls { false }
307308
, ColorAddUse8BitRGB { false }
309+
, AirstrikeLineColor { { 255, 0, 0 } }
308310
, ROF_RandomDelay { { 0 ,2 } }
309311
, ToolTip_Background_Color { { 0, 0, 0 } }
310312
, ToolTip_Background_Opacity { 100 }

src/Ext/Techno/Body.Internal.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,22 @@ 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);
168-
if (airstrike && TechnoExt::ExtMap.Find(pThis)->AirstrikeTargetingMe)
169-
tintColor |= GeneralUtils::GetColorFromColorAdd(RulesClass::Instance->LaserTargetColor);
169+
}
170+
if (airstrike)
171+
{
172+
if (auto const pAirstrike = TechnoExt::ExtMap.Find(pThis)->AirstrikeTargetingMe)
173+
{
174+
auto const pTypeExt = TechnoTypeExt::ExtMap.Find(pAirstrike->Owner->GetTechnoType());
175+
auto index = pTypeExt->LaserTargetColor.Get(RulesClass::Instance->LaserTargetColor);
176+
tintColor |= GeneralUtils::GetColorFromColorAdd(index);
177+
}
178+
}
170179
if (berserk && pThis->Berzerk)
180+
{
171181
tintColor |= GeneralUtils::GetColorFromColorAdd(RulesClass::Instance->BerserkColor);
182+
}
172183
}
173184

174185
return tintColor;

src/Ext/Techno/Hooks.cpp

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,4 +781,50 @@ DEFINE_HOOK(0x655DDD, RadarClass_ProcessPoint_RadarInvisible, 0x6)
781781
return GoOtherChecks;
782782
}
783783

784-
#pragma endregion
784+
#pragma endregion
785+
786+
#pragma region DrawAirstrikeFlare
787+
788+
namespace DrawAirstrikeFlareTemp
789+
{
790+
TechnoClass* pTechno = nullptr;
791+
}
792+
793+
DEFINE_HOOK(0x705860, TechnoClass_DrawAirstrikeFlare_SetContext, 0x8)
794+
{
795+
GET(TechnoClass*, pThis, ECX);
796+
797+
// This is not used in vanilla function so ECX gets overwritten later.
798+
DrawAirstrikeFlareTemp::pTechno = pThis;
799+
800+
return 0;
801+
}
802+
803+
DEFINE_HOOK(0x7058F6, TechnoClass_DrawAirstrikeFlare, 0x5)
804+
{
805+
enum { SkipGameCode = 0x705976 };
806+
807+
GET(int, zSrc, EBP);
808+
GET(int, zDest, EBX);
809+
REF_STACK(ColorStruct, color, STACK_OFFSET(0x70, -0x60));
810+
811+
// Fix depth buffer value.
812+
int zValue = Math::min(zSrc, zDest);
813+
R->EBP(zValue);
814+
R->EBX(zValue);
815+
816+
// Allow custom colors.
817+
auto const pThis = DrawAirstrikeFlareTemp::pTechno;
818+
auto const baseColor = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType())->AirstrikeLineColor.Get(RulesExt::Global()->AirstrikeLineColor);
819+
double percentage = Randomizer::Global.RandomRanged(745, 1000) / 1000.0;
820+
color = { (BYTE)(baseColor.R * percentage), (BYTE)(baseColor.G * percentage), (BYTE)(baseColor.B * percentage) };
821+
R->ESI(Drawing::RGB_To_Int(baseColor));
822+
823+
return SkipGameCode;
824+
}
825+
826+
// Skip setting color for the dot, it is already done in previous hook.
827+
DEFINE_JUMP(LJMP, 0x705986, 0x7059C7);
828+
829+
#pragma endregion
830+

src/Ext/TechnoType/Body.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,10 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
298298

299299
this->ReloadInTransport.Read(exINI, pSection, "ReloadInTransport");
300300
this->ForbidParallelAIQueues.Read(exINI, pSection, "ForbidParallelAIQueues");
301+
302+
this->LaserTargetColor.Read(exINI, pSection, "LaserTargetColor");
303+
this->AirstrikeLineColor.Read(exINI, pSection, "AirstrikeLineColor");
304+
301305
this->ShieldType.Read<true>(exINI, pSection, "ShieldType");
302306

303307
this->HarvesterDumpAmount.Read(exINI, pSection, "HarvesterDumpAmount");
@@ -751,6 +755,8 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm)
751755
.Process(this->InitialStrength)
752756
.Process(this->ReloadInTransport)
753757
.Process(this->ForbidParallelAIQueues)
758+
.Process(this->LaserTargetColor)
759+
.Process(this->AirstrikeLineColor)
754760
.Process(this->ShieldType)
755761
.Process(this->PassengerDeletionType)
756762

src/Ext/TechnoType/Body.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ class TechnoTypeExt
5858
Nullable<int> InitialStrength;
5959
Valueable<bool> ReloadInTransport;
6060
Valueable<bool> ForbidParallelAIQueues;
61+
Nullable<int> LaserTargetColor;
62+
Nullable<ColorStruct> AirstrikeLineColor;
6163

6264
Valueable<ShieldTypeClass*> ShieldType;
6365
std::unique_ptr<PassengerDeletionTypeClass> PassengerDeletionType;
@@ -379,6 +381,8 @@ class TechnoTypeExt
379381
, InitialStrength {}
380382
, ReloadInTransport { false }
381383
, ForbidParallelAIQueues { false }
384+
, LaserTargetColor {}
385+
, AirstrikeLineColor {}
382386
, ShieldType {}
383387
, PassengerDeletionType { nullptr }
384388

0 commit comments

Comments
 (0)