Skip to content

Commit 02f017a

Browse files
authored
[Minor] Turretless vehicles with Voxel=no use FireUp (#1684)
`Voxel=no` turretless vehicles now support the use of `FireUp`. `FireUp.ResetInRetarget` determines whether a vehicle's FireUp count is reset when its target changes. Defaults to `yes`. forced to be `yes` when there is no target. In `artmd.ini`: ```ini [SOMEVEHICLE] FireUp= ; integer FireUp.ResetInRetarget= ; boolean ``` --------- `Voxel=no`的无炮塔载具支持使用`FireUp`。 `FireUp.ResetInRetarget`决定目标改变时是否重置车辆的FireUp计数。默认为`yes`。没有目标时强制为`yes`。 In `artmd.ini`: ```ini [SOMEVEHICLE] FireUp= ; integer FireUp.ResetInRetarget= ; boolean ```
1 parent a6a6792 commit 02f017a

File tree

11 files changed

+169
-2
lines changed

11 files changed

+169
-2
lines changed

CREDITS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ This page lists all the individual contributions to the project by their author.
368368
- Fixed an issue where a portion of Ares's trigger event 75/77 was determined unsuccessfully
369369
- Second weapon with `ElectricAssault=yes` will not unconditionally attack your building with `Overpowerable=yes`
370370
- Fixed some units of Ares crashing after deployment conversion
371+
- Turretless vehicles with `Voxel=no` support use `FireUp` like infantry.
371372
- **NetsuNegi**:
372373
- Forbidding parallel AI queues by type
373374
- Jumpjet crash speed fix when crashing onto building

Phobos.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
</ProjectConfiguration>
1919
</ItemGroup>
2020
<ItemGroup>
21+
<ClCompile Include="src\Ext\Unit\Hooks.Firing.cpp" />
2122
<ClCompile Include="src\New\Type\Affiliated\CreateUnitTypeClass.cpp" />
2223
<ClCompile Include="src\Blowfish\blowfish.cpp" />
2324
<ClCompile Include="src\Blowfish\Hooks.Blowfish.cpp" />

docs/New-or-Enhanced-Logics.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1849,6 +1849,18 @@ JumpjetTilt.SidewaysRotationFactor=1.0 ; floating point value
18491849
JumpjetTilt.SidewaysSpeedFactor=1.0 ; floating point value
18501850
```
18511851

1852+
### Turretless Shape Vehicle FireUp
1853+
1854+
- `Voxel=no` turretless vehicles now support the use of `FireUp`.
1855+
- `FireUp.ResetInRetarget` determines whether a vehicle's FireUp count is reset when its target changes. Defaults to `yes`. forced to be `yes` when there is no target.
1856+
1857+
In `artmd.ini`:
1858+
```ini
1859+
[SOMEVEHICLE]
1860+
FireUp= ; integer
1861+
FireUp.ResetInRetarget=true ; boolean
1862+
```
1863+
18521864
## Warheads
18531865

18541866
```{hint}
@@ -2214,7 +2226,7 @@ AreaFire.Target=base ; AreaFire Target Enumeration (base|self|random)
22142226
- `Burst.Delays` allows specifying weapon-specific burst shot delays. Takes precedence over the old `BurstDelayX` logic available on VehicleTypes, functions with Infantry & BuildingType weapons (AircraftTypes are not supported due to their weapon firing system being completely different) and allows every shot of `Burst` to have a separate delay instead of only first four shots.
22152227
- If no delay is defined for a shot, it falls back to last delay value defined (f.ex `Burst=3` and `Burst.Delays=10` would use 10 as delay for all shots).
22162228
- Using `-1` as delay reverts back to old logic (`BurstDelay0-3` for VehicleTypes if available or random value between 3-5 otherwise) for that shot.
2217-
- `Burst.FireWithinSequence` is only used if the weapon is fired by InfantryTypes, and setting it to true allows infantry to fire multiple `Burst` shots within same firing sequence.
2229+
- `Burst.FireWithinSequence` is only used if the weapon is fired by InfantryType or `Voxel=no` turretless VehicleType, and setting it to true allows infantry/vehicle to fire multiple `Burst` shots within same firing sequence.
22182230
- First shot is always fired at sequence frame determined by firing frame controls on InfantryType image (`FireUp` et al).
22192231
- Following shots come at intervals determined by `Burst.Delays` (with minimum delay of 1 frame) or random delay between 3 to 5 frames if not defined. Note that if next shot would be fired at a frame that is beyond the firing sequence's length, burst shot count is reset and weapon starts reloading.
22202232
- Burst shot counter is not immediately reset if firing is ceased mid-sequence after at least one shot, but the frame at which each burst shot is fired will not be influenced by this (in other words, resuming firing afterward without weapon reload taking place would restart firing sequence but no firing will take place until the frame at which next burst shot should be fired is hit).

docs/Whats-New.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ New:
388388
- [Power plant damage factor](Fixed-or-Improved-Logics#power-plant-damage-factor) (by Otamaa and Ollerus)
389389
- Customize whether `Crater=yes` animation would destroy tiberium (by TaranDahl)
390390
- Weapon target filtering by health percentage (by NetsuNegi)
391+
- Turretless vehicles with `Voxel=no` support use `FireUp` like infantry (by FlyStar)
391392
392393
Vanilla fixes:
393394
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)

docs/locale/zh_CN/LC_MESSAGES/New-or-Enhanced-Logics.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7843,7 +7843,7 @@ msgid ""
78437843
"InfantryTypes, and setting it to true allows infantry to fire multiple "
78447844
"`Burst` shots within same firing sequence."
78457845
msgstr ""
7846-
"`Burst.FireWithinSequence` 仅在步兵发射武器时使用,将其设为 true 以允许步兵在同一射击序列内射出多发 "
7846+
"`Burst.FireWithinSequence` 仅在步兵或`Voxel=no`的无炮塔载具发射武器时使用,将其设为 true 以允许步兵/载具在同一射击序列内射出多发 "
78477847
"`Burst`。"
78487848

78497849
#: ../../New-or-Enhanced-Logics.md:2204

src/Ext/Techno/Body.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,7 @@ void TechnoExt::ExtData::Serialize(T& Stm)
620620
.Process(this->LastSensorsMapCoords)
621621
.Process(this->TiberiumEater_Timer)
622622
.Process(this->AirstrikeTargetingMe)
623+
.Process(this->FiringAnimationTimer)
623624
;
624625
}
625626

src/Ext/Techno/Body.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ class TechnoExt
7171

7272
AirstrikeClass* AirstrikeTargetingMe;
7373

74+
CDTimerClass FiringAnimationTimer;
75+
7476
ExtData(TechnoClass* OwnerObject) : Extension<TechnoClass>(OwnerObject)
7577
, TypeExtData { nullptr }
7678
, Shield {}
@@ -115,6 +117,7 @@ class TechnoExt
115117
, LastSensorsMapCoords { CellStruct::Empty }
116118
, TiberiumEater_Timer {}
117119
, AirstrikeTargetingMe { nullptr }
120+
, FiringAnimationTimer {}
118121
{ }
119122

120123
void OnEarlyUpdate();

src/Ext/Techno/Hooks.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,3 +929,29 @@ DEFINE_HOOK(0x5F4032, ObjectClass_FallingDown_ToDead, 0x6)
929929
}
930930

931931
#pragma endregion
932+
933+
DEFINE_HOOK(0x6FCF8C, TechnoClass_SetTarget_After, 0x6)
934+
{
935+
GET(TechnoClass*, pThis, ESI);
936+
937+
if (const auto pUnit = abstract_cast<UnitClass*, true>(pThis))
938+
{
939+
const auto pUnitType = pUnit->Type;
940+
941+
if (!pUnitType->Turret && !pUnitType->Voxel)
942+
{
943+
const auto pTarget = pThis->Target;
944+
const auto pExt = TechnoExt::ExtMap.Find(pThis);
945+
const auto pTypeExt = pExt->TypeExtData;
946+
947+
if (!pTarget || pTypeExt->FireUp < 0 || pTypeExt->FireUp_ResetInRetarget
948+
|| !pThis->IsCloseEnough(pTarget, pThis->SelectWeapon(pTarget)))
949+
{
950+
pUnit->CurrentFiringFrame = -1;
951+
pExt->FiringAnimationTimer.Stop();
952+
}
953+
}
954+
}
955+
956+
return 0;
957+
}

src/Ext/TechnoType/Body.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,26 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
874874

875875
if (GeneralUtils::IsValidString(pThis->PaletteFile) && !pThis->Palette)
876876
Debug::Log("[Developer warning] [%s] has Palette=%s set but no palette file was loaded (missing file or wrong filename). Missing palettes cause issues with lighting recalculations.\n", pArtSection, pThis->PaletteFile);
877+
878+
this->LoadFromINIByWhatAmI(exArtINI, pArtSection);
879+
}
880+
881+
void TechnoTypeExt::ExtData::LoadFromINIByWhatAmI(INI_EX& exArtINI, const char* pArtSection)
882+
{
883+
AbstractType abs = this->OwnerObject()->WhatAmI();
884+
885+
switch (abs)
886+
{
887+
case AbstractType::UnitType:
888+
{
889+
this->FireUp.Read(exArtINI, pArtSection, "FireUp");
890+
this->FireUp_ResetInRetarget.Read(exArtINI, pArtSection, "FireUp.ResetInRetarget");
891+
//this->SecondaryFire.Read(exArtINI, pArtSection, "SecondaryFire");
892+
break;
893+
}
894+
default:
895+
break;
896+
}
877897
}
878898

879899
template <typename T>
@@ -1199,6 +1219,10 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm)
11991219
.Process(this->FallingDownDamage_Water)
12001220

12011221
.Process(this->FiringForceScatter)
1222+
1223+
.Process(this->FireUp)
1224+
.Process(this->FireUp_ResetInRetarget)
1225+
//.Process(this->SecondaryFire)
12021226
;
12031227
}
12041228
void TechnoTypeExt::ExtData::LoadFromStream(PhobosStreamReader& Stm)

src/Ext/TechnoType/Body.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,10 @@ class TechnoTypeExt
364364

365365
Valueable<bool> FiringForceScatter;
366366

367+
Valueable<int> FireUp;
368+
Valueable<bool> FireUp_ResetInRetarget;
369+
//Nullable<int> SecondaryFire;
370+
367371
ExtData(TechnoTypeClass* OwnerObject) : Extension<TechnoTypeClass>(OwnerObject)
368372
, HealthBar_Hide { false }
369373
, UIDescription {}
@@ -678,6 +682,10 @@ class TechnoTypeExt
678682
, FallingDownDamage_Water {}
679683

680684
, FiringForceScatter { true }
685+
686+
, FireUp { -1 }
687+
, FireUp_ResetInRetarget { true }
688+
//, SecondaryFire {}
681689
{ }
682690

683691
virtual ~ExtData() = default;
@@ -690,6 +698,7 @@ class TechnoTypeExt
690698
virtual void SaveToStream(PhobosStreamWriter& Stm) override;
691699

692700
void ApplyTurretOffset(Matrix3D* mtx, double factor = 1.0);
701+
void LoadFromINIByWhatAmI(INI_EX& exArtINI, const char* pArtSection);
693702

694703
int SelectForceWeapon(TechnoClass* pThis, AbstractClass* pTarget);
695704

0 commit comments

Comments
 (0)