Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 17 additions & 0 deletions docs/Fixed-or-Improved-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -2766,6 +2766,23 @@ Bolt.FollowFLH= ; boolean
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`.
```

### Electric bolt Z-adjust

- It is now possible to change the Z-adjust for weapon EBolt drawing via `EBoltZAdjust` per weapon.
- In vanilla, the EBolt effect fired by BuildingType takes `min(the Z-depth obtained from coordinate transformation, 0)`, this is to ensure that the EBolt effect is not blocked by other images such as tiles in some cases, and now this processing can be turned off to meet some specific needs.
- This only determines whether the Z-depth of the EBolt effect created by BuildingType can be positive; `EBoltZAdjust` can always be normally added to it.

In `rulesmd.ini`:
```ini
[AudioVisual]
EBoltZAdjust=0 ; integer
EBoltZAdjust.ClampInitialDepthForBuilding=true ; boolean

[SOMEWEAPON] ; WeaponType
EBoltZAdjust= ; integer, defaults to [AudioVisual] -> EBoltZAdjust
EBoltZAdjust.ClampInitialDepthForBuilding= ; boolean, defaults to [AudioVisual] -> EBoltZAdjust.ClampInitialDepthForBuilding
```

### Laser Z-adjust

- 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.
Expand Down
1 change: 1 addition & 0 deletions docs/New-or-Enhanced-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ Bolt.Color2= ; integer - Red,Green,Blue
Bolt.Disable2=false ; boolean
Bolt.Color3= ; integer - Red,Green,Blue
Bolt.Disable3=false ; boolean
Bolt.ZAdjust=0 ; integer
; radbeam
Beam.Color= ; integer - Red,Green,Blue
Beam.Amplitude=40.0 ; floating point value
Expand Down
3 changes: 3 additions & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,9 @@ New:
- [Laser drawing Z-adjust customization](Fixed-or-Improved-Logics.md#laser-z-adjust) (by Starkku)
- Customize `HarvesterDumpRate` (by Noble_Fish)
- Allow users to define the time interval of `DisplayIncome` (by Noble_Fish)
- [Electric bolt Z-adjust](Fixed-or-Improved-Logics.md#electric-bolt-z-adjust) (by Noble_Fish)
- Allow disabling the processing of the Z-depth of EBolt drawn by BuildingType being clamped to non-positive numbers (by Noble_Fish)
- Add the `Bolt.ZAdjust` setting item to the LaserTrailType with `DrawType=ebolt` (by Noble_Fish)

Vanilla fixes:
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)
Expand Down
13 changes: 12 additions & 1 deletion src/Ext/Bullet/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,18 @@ inline void BulletExt::SimulatedFiringElectricBolt(BulletClass* pBullet)
pBolt->AlternateColor = pWeapon->IsAlternateColor;

const auto targetCoords = pBullet->Type->Inviso ? pBullet->Location : pBullet->TargetCoords;
pBolt->Fire(pBullet->SourceCoords, targetCoords, 0);
const auto pWeaponExt = WeaponTypeExt::ExtMap.Find(pWeapon);
int zAdjust = pWeaponExt->EBoltZAdjust.Get(RulesExt::Global()->EBoltZAdjust);

const auto pOwner = pBullet->Owner;
if (pOwner && pOwner->WhatAmI() == AbstractType::Building)
{
const bool clamp = pWeaponExt->EBoltZAdjust_ClampInitialDepthForBuilding.Get(RulesExt::Global()->EBoltZAdjust_ClampInitialDepthForBuilding);
if (clamp && zAdjust > 0)
zAdjust = 0;
}

pBolt->Fire(pBullet->SourceCoords, targetCoords, zAdjust);

if (const auto particle = WeaponTypeExt::ExtMap.Find(pWeapon)->Bolt_ParticleSystem.Get(RulesClass::Instance->DefaultSparkSystem))
GameCreate<ParticleSystemClass>(particle, targetCoords, nullptr, nullptr, CoordStruct::Empty, nullptr);
Expand Down
34 changes: 34 additions & 0 deletions src/Ext/EBolt/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,37 @@ DEFINE_HOOK(0x4C2A02, EBolt_DestroyVector, 0x6)
return SkipGameCode;
}
#pragma endregion

DEFINE_HOOK(0x6FD4E4, TechnoClass_FireEBolt_Building_ClampPositive, 0x9)
{
GET_STACK(WeaponTypeClass*, pWeapon, STACK_OFFSET(0x30, 0x8));
GET(CoordStruct*, pV13, EAX);
GET(int, Y, ESI);

int zAdjust = Y - pV13->Y;

const auto pWeaponExt = WeaponTypeExt::ExtMap.Find(pWeapon);
const bool clamp = pWeaponExt->EBoltZAdjust_ClampInitialDepthForBuilding.Get(RulesExt::Global()->EBoltZAdjust_ClampInitialDepthForBuilding);

if (clamp && zAdjust > 0)
zAdjust = 0;

R->ESI(zAdjust);

return 0x6FD4ED;
}

DEFINE_HOOK(0x6FD4ED, TechnoClass_FireEBolt_ZAdjust, 0x7)
{
GET_STACK(TechnoClass*, pTarget, STACK_OFFSET(0x30, 0x4));
GET_STACK(WeaponTypeClass*, pWeapon, STACK_OFFSET(0x30, 0x8));
GET(int, zAdjust, ESI);

const auto pWeaponExt = WeaponTypeExt::ExtMap.Find(pWeapon);
zAdjust += pWeaponExt->EBoltZAdjust.Get(RulesExt::Global()->EBoltZAdjust);

R->ESI(zAdjust);
R->ECX(pTarget);

return (pTarget ? 0x6FD4F5 : 0x6FD50A);
}
4 changes: 4 additions & 0 deletions src/Ext/Rules/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)
this->AirstrikeLineZAdjust.Read(exINI, GameStrings::AudioVisual, "AirstrikeLineZAdjust");

this->LaserZAdjust.Read(exINI, GameStrings::AudioVisual, "LaserZAdjust");
this->EBoltZAdjust.Read(exINI, GameStrings::AudioVisual, "EBoltZAdjust");
this->EBoltZAdjust_ClampInitialDepthForBuilding.Read(exINI, GameStrings::AudioVisual, "EBoltZAdjust.ClampInitialDepthForBuilding");

this->CrateOnlyOnLand.Read(exINI, GameStrings::CrateRules, "CrateOnlyOnLand");
this->UnitCrateVehicleCap.Read(exINI, GameStrings::CrateRules, "UnitCrateVehicleCap");
Expand Down Expand Up @@ -573,6 +575,8 @@ void RulesExt::ExtData::Serialize(T& Stm)
.Process(this->AirstrikeLineColor)
.Process(this->AirstrikeLineZAdjust)
.Process(this->LaserZAdjust)
.Process(this->EBoltZAdjust)
.Process(this->EBoltZAdjust_ClampInitialDepthForBuilding)
.Process(this->ROF_RandomDelay)
.Process(this->ToolTip_Background_Color)
.Process(this->ToolTip_Background_Opacity)
Expand Down
4 changes: 4 additions & 0 deletions src/Ext/Rules/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ class RulesExt
Valueable<int> AirstrikeLineZAdjust;

Valueable<int> LaserZAdjust;
Valueable<int> EBoltZAdjust;
Valueable<bool> EBoltZAdjust_ClampInitialDepthForBuilding;

Valueable<PartialVector2D<int>> ROF_RandomDelay;
Valueable<ColorStruct> ToolTip_Background_Color;
Expand Down Expand Up @@ -453,6 +455,8 @@ class RulesExt
, AirstrikeLineColor { { 255, 0, 0 } }
, AirstrikeLineZAdjust { 0 }
, LaserZAdjust { 0 }
, EBoltZAdjust { 0 }
, EBoltZAdjust_ClampInitialDepthForBuilding { true }
, ROF_RandomDelay { { 0 ,2 } }
, ToolTip_Background_Color { { 0, 0, 0 } }
, ToolTip_Background_Opacity { 100 }
Expand Down
4 changes: 4 additions & 0 deletions src/Ext/WeaponType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ void WeaponTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
this->FeedbackWeapon.Read<true>(exINI, pSection, "FeedbackWeapon");
this->Laser_IsSingleColor.Read(exINI, pSection, "IsSingleColor");
this->LaserZAdjust.Read(exINI, pSection, "LaserZAdjust");
this->EBoltZAdjust.Read(exINI, pSection, "EBoltZAdjust");
this->EBoltZAdjust_ClampInitialDepthForBuilding.Read(exINI, pSection, "EBoltZAdjust.ClampInitialDepthForBuilding");
this->VisualScatter.Read(exINI, pSection, "VisualScatter");
this->ROF_RandomDelay.Read(exINI, pSection, "ROF.RandomDelay");
this->ChargeTurret_Delays.Read(exINI, pSection, "ChargeTurret.Delays");
Expand Down Expand Up @@ -215,6 +217,8 @@ void WeaponTypeExt::ExtData::Serialize(T& Stm)
.Process(this->FeedbackWeapon)
.Process(this->Laser_IsSingleColor)
.Process(this->LaserZAdjust)
.Process(this->EBoltZAdjust)
.Process(this->EBoltZAdjust_ClampInitialDepthForBuilding)
.Process(this->VisualScatter)
.Process(this->ROF_RandomDelay)
.Process(this->ChargeTurret_Delays)
Expand Down
4 changes: 4 additions & 0 deletions src/Ext/WeaponType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class WeaponTypeExt
Valueable<WeaponTypeClass*> FeedbackWeapon;
Valueable<bool> Laser_IsSingleColor;
Nullable<int> LaserZAdjust;
Nullable<int> EBoltZAdjust;
Nullable<bool> EBoltZAdjust_ClampInitialDepthForBuilding;
Valueable<bool> VisualScatter;
Nullable<PartialVector2D<int>> ROF_RandomDelay;
ValueableVector<int> ChargeTurret_Delays;
Expand Down Expand Up @@ -133,6 +135,8 @@ class WeaponTypeExt
, FeedbackWeapon {}
, Laser_IsSingleColor { false }
, LaserZAdjust {}
, EBoltZAdjust {}
, EBoltZAdjust_ClampInitialDepthForBuilding {}
, VisualScatter { false }
, ROF_RandomDelay {}
, ChargeTurret_Delays {}
Expand Down
2 changes: 1 addition & 1 deletion src/New/Entity/LaserTrailClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ bool LaserTrailClass::Update(CoordStruct location)
pBolt->Lifetime = 1 << (std::clamp(pType->FadeDuration.Get(17), 1, 31) - 1);
pBolt->AlternateColor = pType->IsAlternateColor;

pBolt->Fire(this->LastLocation, location, 0);
pBolt->Fire(this->LastLocation, location, pType->Bolt_ZAdjust);
}
else if (pType->DrawType == LaserTrailDrawType::RadBeam)
{
Expand Down
2 changes: 2 additions & 0 deletions src/New/Type/LaserTrailTypeClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ void LaserTrailTypeClass::LoadFromINI(CCINIClass* pINI)
}

this->Bolt_Arcs.Read(exINI, section, "Bolt.Arcs");
this->Bolt_ZAdjust.Read(exINI, section, "Bolt.ZAdjust");

this->Beam_Color.Read(exINI, section, "Beam.Color");
this->Beam_Amplitude.Read(exINI, section, "Beam.Amplitude");
Expand All @@ -60,6 +61,7 @@ void LaserTrailTypeClass::Serialize(T& Stm)
.Process(this->Bolt_Color)
.Process(this->Bolt_Disable)
.Process(this->Bolt_Arcs)
.Process(this->Bolt_ZAdjust)
.Process(this->Beam_Color)
.Process(this->Beam_Amplitude)
.Process(this->FadeDuration)
Expand Down
2 changes: 2 additions & 0 deletions src/New/Type/LaserTrailTypeClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class LaserTrailTypeClass final : public Enumerable<LaserTrailTypeClass>
Nullable<ColorStruct> Bolt_Color[3];
Valueable<bool> Bolt_Disable[3];
Valueable<int> Bolt_Arcs;
Valueable<int> Bolt_ZAdjust;
Nullable<ColorStruct> Beam_Color;
Valueable<double> Beam_Amplitude;
Nullable<int> FadeDuration;
Expand All @@ -34,6 +35,7 @@ class LaserTrailTypeClass final : public Enumerable<LaserTrailTypeClass>
, Bolt_Color {}
, Bolt_Disable { Valueable<bool>(false) }
, Bolt_Arcs { 8 }
, Bolt_ZAdjust { 0 }
, Beam_Color {}
, Beam_Amplitude { 40.0 }
, FadeDuration {}
Expand Down
Loading