Skip to content

Commit 55437f9

Browse files
committed
Add improvements for airstrike flare visuals
1 parent bd9b373 commit 55437f9

File tree

9 files changed

+88
-1
lines changed

9 files changed

+88
-1
lines changed

CREDITS.md

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

docs/Fixed-or-Improved-Logics.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
216216
- Fixed an issue that MCV will self-destruct when using trigger 107 to teleport
217217
- Fixed an issue that moving MCV with Teleport locomotion will cause reconnection error
218218
- Fixed wrong shadow when a vehicle has hover locomotor and is being lifted by `IsLocomotor=yes` warhead
219+
- Fixed an issue where airstrike flare line drawn to target at lower elevation would clip.
219220

220221
## Fixes / interactions with other extensions
221222

@@ -690,6 +691,22 @@ BallisticScatter.Max= ; floating point value, distance in cells
690691

691692
## Technos
692693

694+
### Airstrike flare customizations
695+
696+
- 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.
697+
- `LaserTargetColor` can be used to set the index of color from `[ColorAdd]` defaults to `[AudioVisual]` -> `LaserTargetColor`.
698+
- `AirstrikeLineColor` sets the color of the line and dot drawn from firer to target, defaults to `[AudioVisual]` -> `AirstrikeLineColor`.
699+
700+
In `rulesmd.ini`:
701+
```ini
702+
[AudioVisual]
703+
AirstrikeLineColor=255,0,0 ; integer - Red,Green,Blue
704+
705+
[SOMETECHNO] ; TechnoType
706+
LaserTargetColor= ; integer - [ColorAdd] index
707+
AirstrikeLineColor= ; integer - Red,Green,Blue
708+
```
709+
693710
### Alternate FLH customizations
694711

695712
- `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
@@ -359,6 +359,7 @@ New:
359359
- Enhanced reveal & gap warhead (by NetsuNegi)
360360
- Forcing specific weapon by range (by Ollerus)
361361
- Jumpjet Tilts While Moving (by CrimRecya)
362+
- [Customizable airstrike flare colors](Fixed-or-Improved-Logics.md#airstrike-flare-customizations) (by Starkku)
362363
363364
Vanilla fixes:
364365
- Prevent the units with locomotors that cause problems from entering the tank bunker (by TaranDahl)
@@ -374,6 +375,7 @@ Vanilla fixes:
374375
- Fixed an issue that teleport units board transport vehicles on the bridge will create an impassable invisible barrier, which may cause the game to freeze or even crash (by NetsuNegi)
375376
- Fixed an issue that moving MCV with Teleport locomotion will cause reconnection error (by CrimRecya)
376377
- Fixed wrong shadow when a vehicle has hover locomotor and is being lifted by `IsLocomotor=yes` warhead (by NetsuNegi)
378+
- Fixed an issue where airstrike flare line drawn to target at lower elevation would clip (by Starkku)
377379
378380
Phobos fixes:
379381
- 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
@@ -164,6 +164,7 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)
164164
this->IronCurtain_ExtraTintIntensity.Read(exINI, GameStrings::AudioVisual, "IronCurtain.ExtraTintIntensity");
165165
this->ForceShield_ExtraTintIntensity.Read(exINI, GameStrings::AudioVisual, "ForceShield.ExtraTintIntensity");
166166
this->ColorAddUse8BitRGB.Read(exINI, GameStrings::AudioVisual, "ColorAddUse8BitRGB");
167+
this->AirstrikeLineColor.Read(exINI, GameStrings::AudioVisual, "AirstrikeLineColor");
167168

168169
this->CrateOnlyOnLand.Read(exINI, GameStrings::CrateRules, "CrateOnlyOnLand");
169170
this->UnitCrateVehicleCap.Read(exINI, GameStrings::CrateRules, "UnitCrateVehicleCap");
@@ -394,6 +395,7 @@ void RulesExt::ExtData::Serialize(T& Stm)
394395
.Process(this->ForceShield_ExtraTintIntensity)
395396
.Process(this->AllowWeaponSelectAgainstWalls)
396397
.Process(this->ColorAddUse8BitRGB)
398+
.Process(this->AirstrikeLineColor)
397399
.Process(this->ROF_RandomDelay)
398400
.Process(this->ToolTip_Background_Color)
399401
.Process(this->ToolTip_Background_Opacity)

src/Ext/Rules/Body.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ class RulesExt
123123
Valueable<double> IronCurtain_ExtraTintIntensity;
124124
Valueable<double> ForceShield_ExtraTintIntensity;
125125
Valueable<bool> ColorAddUse8BitRGB;
126+
Valueable<ColorStruct> AirstrikeLineColor;
126127

127128
Valueable<PartialVector2D<int>> ROF_RandomDelay;
128129
Valueable<ColorStruct> ToolTip_Background_Color;
@@ -290,6 +291,7 @@ class RulesExt
290291
, ForceShield_ExtraTintIntensity { 0.0 }
291292
, AllowWeaponSelectAgainstWalls { false }
292293
, ColorAddUse8BitRGB { false }
294+
, AirstrikeLineColor { { 255, 0, 0 } }
293295
, ROF_RandomDelay { { 0 ,2 } }
294296
, ToolTip_Background_Color { { 0, 0, 0 } }
295297
, ToolTip_Background_Opacity { 100 }

src/Ext/Techno/Body.Internal.cpp

Lines changed: 9 additions & 1 deletion
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

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,3 +744,48 @@ DEFINE_HOOK(0x4B3DF0, LocomotionClass_Process_DamagedSpeedMultiplier, 0x6)// Dri
744744

745745
return R->Origin() + 0x6;
746746
}
747+
748+
#pragma region DrawAirstrikeFlare
749+
750+
namespace DrawAirstrikeFlareTemp
751+
{
752+
TechnoClass* pTechno = nullptr;
753+
}
754+
755+
DEFINE_HOOK(0x705860, TechnoClass_DrawAirstrikeFlare_SetContext, 0x8)
756+
{
757+
GET(TechnoClass*, pThis, ECX);
758+
759+
// This is not used in vanilla function so ECX gets overwritten later.
760+
DrawAirstrikeFlareTemp::pTechno = pThis;
761+
762+
return 0;
763+
}
764+
765+
DEFINE_HOOK(0x7058F6, TechnoClass_DrawAirstrikeFlare, 0x5)
766+
{
767+
enum { SkipGameCode = 0x705976 };
768+
769+
GET(int, zSrc, EBP);
770+
GET(int, zDest, EBX);
771+
REF_STACK(ColorStruct, color, STACK_OFFSET(0x70, -0x60));
772+
773+
// Fix depth buffer value.
774+
int zValue = Math::min(zSrc, zDest);
775+
R->EBP(zValue);
776+
R->EBX(zValue);
777+
778+
// Allow custom colors.
779+
auto const pThis = DrawAirstrikeFlareTemp::pTechno;
780+
auto const baseColor = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType())->AirstrikeLineColor.Get(RulesExt::Global()->AirstrikeLineColor);
781+
double percentage = Randomizer::Global.RandomRanged(745, 1000) / 1000.0;
782+
color = { (BYTE)(baseColor.R * percentage), (BYTE)(baseColor.G * percentage), (BYTE)(baseColor.B * percentage) };
783+
R->ESI(Drawing::RGB_To_Int(baseColor));
784+
785+
return SkipGameCode;
786+
}
787+
788+
// Skip setting color for the dot, it is already done in previous hook.
789+
DEFINE_JUMP(LJMP, 0x705986, 0x7059C7);
790+
791+
#pragma endregion

src/Ext/TechnoType/Body.cpp

Lines changed: 6 additions & 0 deletions
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");
@@ -722,6 +726,8 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm)
722726
.Process(this->InitialStrength)
723727
.Process(this->ReloadInTransport)
724728
.Process(this->ForbidParallelAIQueues)
729+
.Process(this->LaserTargetColor)
730+
.Process(this->AirstrikeLineColor)
725731
.Process(this->ShieldType)
726732
.Process(this->PassengerDeletionType)
727733

src/Ext/TechnoType/Body.h

Lines changed: 4 additions & 0 deletions
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;
@@ -350,6 +352,8 @@ class TechnoTypeExt
350352
, InitialStrength {}
351353
, ReloadInTransport { false }
352354
, ForbidParallelAIQueues { false }
355+
, LaserTargetColor {}
356+
, AirstrikeLineColor {}
353357
, ShieldType {}
354358
, PassengerDeletionType { nullptr }
355359

0 commit comments

Comments
 (0)