Skip to content

Commit 47b4713

Browse files
committed
Add customization for laser Z-adjust
1 parent 56a9f18 commit 47b4713

7 files changed

Lines changed: 38 additions & 2 deletions

File tree

docs/Fixed-or-Improved-Logics.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2755,6 +2755,19 @@ Bolt.FollowFLH= ; boolean
27552755
Due to technical constraints, these features do not work with electric bolts created from support weapon of [Ares' Prism Forwarding](https://ares-developers.github.io/Ares-docs/new/buildings/prismforwarding.html) or those from `AirburstWeapon`.
27562756
```
27572757

2758+
### Laser Z-adjust
2759+
2760+
- It is now possible to change the Z-adjust for weapon laser drawing via `LaserZAdjust` per weapon, defaults to `[AudioVisual]` -> `LaserZAdjust`. Note that this is not available on prism support weapons.
2761+
2762+
In `rulesmd.ini`:
2763+
```ini
2764+
[AudioVisual]
2765+
LaserZAdjust=0 ; integer
2766+
2767+
[SOMEWEAPON] ; WeaponType
2768+
LaserZAdjust= ; integer
2769+
```
2770+
27582771
### Single-color lasers
27592772

27602773
![image](_static/images/issinglecolor.gif)

docs/Whats-New.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,7 @@ New:
575575
- Framework for dynamic sight (by TaranDahl)
576576
- Customize `HarvesterLoadRate` (by Noble_Fish)
577577
- [Toggle to prevent `ShrapnelWeapon` from targeting buildings multiple times](Fixed-or-Improved-Logics.md#shrapnel-enhancements) (by Starkku)
578+
- [Laser drawing Z-adjust customization](Fixed-or-Improved-Logics.md#laser-z-adjust) (by Starkku)
578579
579580
Vanilla fixes:
580581
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)

src/Ext/Rules/Body.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)
197197
this->AirstrikeLineColor.Read(exINI, GameStrings::AudioVisual, "AirstrikeLineColor");
198198
this->AirstrikeLineZAdjust.Read(exINI, GameStrings::AudioVisual, "AirstrikeLineZAdjust");
199199

200+
this->LaserZAdjust.Read(exINI, GameStrings::AudioVisual, "LaserZAdjust");
201+
200202
this->CrateOnlyOnLand.Read(exINI, GameStrings::CrateRules, "CrateOnlyOnLand");
201203
this->UnitCrateVehicleCap.Read(exINI, GameStrings::CrateRules, "UnitCrateVehicleCap");
202204
this->FreeMCV_CreditsThreshold.Read(exINI, GameStrings::CrateRules, "FreeMCV.CreditsThreshold");
@@ -564,6 +566,7 @@ void RulesExt::ExtData::Serialize(T& Stm)
564566
.Process(this->ColorAddUse8BitRGB)
565567
.Process(this->AirstrikeLineColor)
566568
.Process(this->AirstrikeLineZAdjust)
569+
.Process(this->LaserZAdjust)
567570
.Process(this->ROF_RandomDelay)
568571
.Process(this->ToolTip_Background_Color)
569572
.Process(this->ToolTip_Background_Opacity)

src/Ext/Rules/Body.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ class RulesExt
143143
Valueable<ColorStruct> AirstrikeLineColor;
144144
Valueable<int> AirstrikeLineZAdjust;
145145

146+
Valueable<int> LaserZAdjust;
147+
146148
Valueable<PartialVector2D<int>> ROF_RandomDelay;
147149
Valueable<ColorStruct> ToolTip_Background_Color;
148150
Valueable<int> ToolTip_Background_Opacity;
@@ -449,6 +451,7 @@ class RulesExt
449451
, ColorAddUse8BitRGB { false }
450452
, AirstrikeLineColor { { 255, 0, 0 } }
451453
, AirstrikeLineZAdjust { 0 }
454+
, LaserZAdjust { 0 }
452455
, ROF_RandomDelay { { 0 ,2 } }
453456
, ToolTip_Background_Color { { 0, 0, 0 } }
454457
, ToolTip_Background_Opacity { 100 }

src/Ext/WeaponType/Body.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "Body.h"
1+
#include "Body.h"
22
#include <Ext/Bullet/Body.h>
33
#include <Ext/Techno/Body.h>
44

@@ -117,6 +117,7 @@ void WeaponTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
117117
this->AreaFire_Target.Read(exINI, pSection, "AreaFire.Target");
118118
this->FeedbackWeapon.Read<true>(exINI, pSection, "FeedbackWeapon");
119119
this->Laser_IsSingleColor.Read(exINI, pSection, "IsSingleColor");
120+
this->LaserZAdjust.Read(exINI, pSection, "LaserZAdjust");
120121
this->VisualScatter.Read(exINI, pSection, "VisualScatter");
121122
this->ROF_RandomDelay.Read(exINI, pSection, "ROF.RandomDelay");
122123
this->ChargeTurret_Delays.Read(exINI, pSection, "ChargeTurret.Delays");
@@ -213,6 +214,7 @@ void WeaponTypeExt::ExtData::Serialize(T& Stm)
213214
.Process(this->AreaFire_Target)
214215
.Process(this->FeedbackWeapon)
215216
.Process(this->Laser_IsSingleColor)
217+
.Process(this->LaserZAdjust)
216218
.Process(this->VisualScatter)
217219
.Process(this->ROF_RandomDelay)
218220
.Process(this->ChargeTurret_Delays)

src/Ext/WeaponType/Body.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#pragma once
1+
#pragma once
22
#include <Utilities/Container.h>
33
#include <Utilities/TemplateDef.h>
44

@@ -45,6 +45,7 @@ class WeaponTypeExt
4545
Valueable<AreaFireTarget> AreaFire_Target;
4646
Valueable<WeaponTypeClass*> FeedbackWeapon;
4747
Valueable<bool> Laser_IsSingleColor;
48+
Nullable<int> LaserZAdjust;
4849
Valueable<bool> VisualScatter;
4950
Nullable<PartialVector2D<int>> ROF_RandomDelay;
5051
ValueableVector<int> ChargeTurret_Delays;
@@ -131,6 +132,7 @@ class WeaponTypeExt
131132
, AreaFire_Target { AreaFireTarget::Base }
132133
, FeedbackWeapon {}
133134
, Laser_IsSingleColor { false }
135+
, LaserZAdjust {}
134136
, VisualScatter { false }
135137
, ROF_RandomDelay {}
136138
, ChargeTurret_Delays {}

src/Misc/Hooks.LaserDraw.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include <Ext\WeaponType\Body.h>
12
#include <Helpers/Macro.h>
23
#include <Utilities/GeneralUtils.h>
34

@@ -41,3 +42,14 @@ DEFINE_HOOK(0x550F47, LaserDrawClass_DrawInHouseColor_BetterDrawing, 0x0)
4142

4243
return 0x550F9D;
4344
}
45+
46+
DEFINE_HOOK(0x6FD3FD, TechnoClass_LaserZap_ZAdjust, 0x5)
47+
{
48+
GET_STACK(WeaponTypeClass*, pWeapon, STACK_OFFSET(0x6C, 0xC));
49+
GET(int, zAdjust, EAX);
50+
51+
zAdjust += WeaponTypeExt::ExtMap.Find(pWeapon)->LaserZAdjust.Get(RulesExt::Global()->LaserZAdjust);
52+
R->EAX(zAdjust);
53+
54+
return 0;
55+
}

0 commit comments

Comments
 (0)