Skip to content

[Highly Customized] New AdvancedDrive locomotor #1622

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 34 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6d0a072
Core
CrimRecya Apr 10, 2025
c3e87b0
Missing part
CrimRecya Apr 10, 2025
cf6502e
...
CrimRecya Apr 10, 2025
ebe9a83
Update YRpp
CrimRecya Apr 15, 2025
2c66b9b
Merge remote-tracking branch 'upstream/develop' into develop-SkilledLoco
CrimRecya Apr 15, 2025
fea9843
Update YRpp
CrimRecya Apr 15, 2025
e74d2a0
Reverse when delivering ore
CrimRecya Apr 16, 2025
b4d7747
Merge remote-tracking branch 'upstream/develop' into develop-SkilledLoco
CrimRecya Apr 16, 2025
4d0a7d9
Some optimize
CrimRecya Apr 16, 2025
738d0f5
Rename
CrimRecya Apr 16, 2025
a3110e0
Fix AI
CrimRecya Apr 17, 2025
c05abde
Merge remote-tracking branch 'upstream/develop' into develop-SkilledLoco
CrimRecya Apr 17, 2025
7e9b9ca
Fix 0 speed crash
CrimRecya Apr 24, 2025
ac1378f
Merge branch 'develop' into develop-SkilledLoco
CrimRecya Apr 24, 2025
769a628
Update YRpp
CrimRecya Apr 24, 2025
d39b6f6
Doc
CrimRecya Apr 25, 2025
c737326
Fix piggyback stuck
CrimRecya Apr 26, 2025
10cf0b3
Merge remote-tracking branch 'upstream/develop' into develop-SkilledLoco
CrimRecya Apr 26, 2025
9f0414b
Fix reverse tilt when crush
CrimRecya May 8, 2025
6fc3a41
Merge remote-tracking branch 'upstream/develop' into develop-SkilledLoco
CrimRecya May 8, 2025
70fec73
Use `locomotion_cast`
CrimRecya May 9, 2025
1de63ef
Merge remote-tracking branch 'upstream/develop' into develop-SkilledLoco
CrimRecya May 9, 2025
3db4bc2
Fix merge
CrimRecya May 9, 2025
a213432
最小自动倒车距离
CrimRecya May 15, 2025
1c5528f
Merge remote-tracking branch 'upstream/develop' into develop-SkilledLoco
CrimRecya May 15, 2025
466b161
Fix the permanent deceleration caused by crushing
CrimRecya May 21, 2025
eafc793
Merge remote-tracking branch 'upstream/develop' into develop-SkilledLoco
CrimRecya May 21, 2025
8020e2a
Readability
CrimRecya May 21, 2025
3512e94
Merge remote-tracking branch 'upstream/develop' into develop-SkilledLoco
CrimRecya May 21, 2025
a880866
Fix `AdvancedDrive.FaceTargetRange`
CrimRecya Jun 9, 2025
ce79863
Merge remote-tracking branch 'upstream/develop' into develop-SkilledLoco
CrimRecya Jun 9, 2025
e65b2b9
Update YRpp
CrimRecya Jun 9, 2025
6a8276c
Fix typo
CrimRecya Aug 11, 2025
3579c3e
Merge remote-tracking branch 'upstream/develop' into develop-SkilledLoco
CrimRecya Aug 11, 2025
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
1 change: 1 addition & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ This page lists all the individual contributions to the project by their author.
- Burst without delay
- Fix an issue that if the garrison unload occupants when there is no open space around it would result in the disappearance of the occupants
- Fix an issue where Ares' `Convert.Deploy` triggers repeatedly when the unit is turning or moving
- New AdvancedDrive locomotor
- **Ollerus**:
- Build limit group enhancement
- Customizable rocker amplitude
Expand Down
2 changes: 2 additions & 0 deletions Phobos.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
<ClCompile Include="src\Ext\Trigger\Hooks.cpp" />
<ClCompile Include="src\Ext\Unit\Hooks.Crushing.cpp" />
<ClCompile Include="src\Locomotion\TestLocomotionClass.cpp" />
<ClCompile Include="src\Locomotion\AdvancedDriveLocomotionClass.cpp" />
<ClCompile Include="src\Misc\Hooks.Gamespeed.cpp" />
<ClCompile Include="src\Misc\Hooks.Ares.cpp" />
<ClCompile Include="src\Misc\Hooks.Crates.cpp" />
Expand Down Expand Up @@ -248,6 +249,7 @@
<ClInclude Include="src\Ext\Team\Body.h" />
<ClInclude Include="src\Ext\TEvent\Body.h" />
<ClInclude Include="src\Locomotion\TestLocomotionClass.h" />
<ClInclude Include="src\Locomotion\AdvancedDriveLocomotionClass.h" />
<ClInclude Include="src\Misc\BlittersFix.h" />
<ClInclude Include="src\Ext\CaptureManager\Body.h" />
<ClInclude Include="src\Misc\FlyingStrings.h" />
Expand Down
27 changes: 14 additions & 13 deletions docs/Miscellanous.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,20 @@ SaveVariablesOnScenarioEnd=false ; boolean

- It's now possible to write locomotor aliases instead of their CLSIDs in the `Locomotor` tag value. Use the table below to find the needed alias for a locomotor.

| *Alias* | *CLSID* |
|--------:|:----------------------------------------:|
|Drive | `{4A582741-9839-11d1-B709-00A024DDAFD1}` |
|Hover | `{4A582742-9839-11d1-B709-00A024DDAFD1}` |
|Tunnel | `{4A582743-9839-11d1-B709-00A024DDAFD1}` |
|Walk | `{4A582744-9839-11d1-B709-00A024DDAFD1}` |
|DropPod | `{4A582745-9839-11d1-B709-00A024DDAFD1}` |
|Fly | `{4A582746-9839-11d1-B709-00A024DDAFD1}` |
|Teleport | `{4A582747-9839-11d1-B709-00A024DDAFD1}` |
|Mech | `{55D141B8-DB94-11d1-AC98-006008055BB5}` |
|Ship | `{2BEA74E1-7CCA-11d3-BE14-00104B62A16C}` |
|Jumpjet | `{92612C46-F71F-11d1-AC9F-006008055BB5}` |
|Rocket | `{B7B49766-E576-11d3-9BD9-00104B972FE8}` |
| *Alias* | *CLSID* |
|------------:|:----------------------------------------:|
|Drive | `{4A582741-9839-11d1-B709-00A024DDAFD1}` |
|Hover | `{4A582742-9839-11d1-B709-00A024DDAFD1}` |
|Tunnel | `{4A582743-9839-11d1-B709-00A024DDAFD1}` |
|Walk | `{4A582744-9839-11d1-B709-00A024DDAFD1}` |
|DropPod | `{4A582745-9839-11d1-B709-00A024DDAFD1}` |
|Fly | `{4A582746-9839-11d1-B709-00A024DDAFD1}` |
|Teleport | `{4A582747-9839-11d1-B709-00A024DDAFD1}` |
|Mech | `{55D141B8-DB94-11d1-AC98-006008055BB5}` |
|Ship | `{2BEA74E1-7CCA-11d3-BE14-00104B62A16C}` |
|Jumpjet | `{92612C46-F71F-11d1-AC9F-006008055BB5}` |
|Rocket | `{B7B49766-E576-11d3-9BD9-00104B972FE8}` |
|AdvancedDrive| `{4A582751-9839-11d1-B709-00A024DDAFD1}` |

```{note}
`Chrono` is not a standard Alias, but since the default behavior of using `Teleport` will be triggered when the value of `Locomotor` is incorrect, the result of the operation will appear as if `Chrono` has taken effect.
Expand Down
25 changes: 25 additions & 0 deletions docs/New-or-Enhanced-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,31 @@ In `artmd.ini`:
OnlyUseLandSequences=false ; boolean
```

## Locomotor

### AdvancedDrive Locomotor

- `AdvancedDrive` locomotor (`{4A582751-9839-11d1-B709-00A024DDAFD1}`) is an improved `Drive` locomotor (`{4A582741-9839-11d1-B709-00A024DDAFD1}`) that can serve as a complete upper level replacement for it.
- It fixes the issue where `Drive` cannot correctly crush objects during rapid turns.
- It has smoother uphill and downhill dynamic visual effects.
- It has the function of driving the unit backwards.
- `AdvancedDrive.ReverseSpeed` controls the speed ratio when reversing.
- `AdvancedDrive.FaceTargetRange` controls how close the unit is to its target, allowing reversing.
- `AdvancedDrive.MinimumDistance` controls how close the unit is to its destination, allowing reversing.
- `AdvancedDrive.ConfrontEnemies` controls whether to maitain the frontal movement towards the enemy within `AdvancedDrive.FaceTargetRange` and no longer automatically selects by the current orientation.
- `AdvancedDrive.RetreatDuration` controls how long since the unit was last injured, allowing reversing.

In `rulesmd.ini`:
```ini
[SOMEVEHICLE] ; VehicleType
Locomotor=AdvancedDrive ; Locomotor
AdvancedDrive.ReverseSpeed=0.85 ; floating point value
AdvancedDrive.FaceTargetRange=16.0 ; floating point value
AdvancedDrive.MinimumDistance=2.5 ; floating point value
AdvancedDrive.ConfrontEnemies=true ; boolean
AdvancedDrive.RetreatDuration=150 ; integer, game frames
```

## Projectiles

### Parabombs
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ New:
- [Units can customize the attack voice that plays when using more weapons](New-or-Enhanced-Logics.md#multi-voiceattack) (by FlyStar)
- Customize squid grapple animation (by NetsuNegi)
- [Auto deploy for GI-like infantry](Fixed-or-Improved-Logics.md#auto-deploy-for-gi-like-infantry) (by TaranDahl)
- New AdvancedDrive locomotor (by CrimRecya)

Vanilla fixes:
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)
Expand Down
1 change: 1 addition & 0 deletions src/Ext/Techno/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,7 @@ void TechnoExt::ExtData::Serialize(T& Stm)
.Process(this->FiringObstacleCell)
.Process(this->IsDetachingForCloak)
.Process(this->BeControlledThreatFrame)
.Process(this->LastHurtFrame)
.Process(this->LastTargetID)
.Process(this->AccumulatedGattlingValue)
.Process(this->ShouldUpdateGattlingValue)
Expand Down
2 changes: 2 additions & 0 deletions src/Ext/Techno/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class TechnoExt
CellClass* FiringObstacleCell; // Set on firing if there is an obstacle cell between target and techno, used for updating WaveClass target etc.
bool IsDetachingForCloak; // Used for checking animation detaching, set to true before calling Detach_All() on techno when this anim is attached to and to false after when cloaking only.
int BeControlledThreatFrame;
int LastHurtFrame;
DWORD LastTargetID;
int AccumulatedGattlingValue;
bool ShouldUpdateGattlingValue;
Expand Down Expand Up @@ -122,6 +123,7 @@ class TechnoExt
, FiringObstacleCell {}
, IsDetachingForCloak { false }
, BeControlledThreatFrame { 0 }
, LastHurtFrame { 0 }
, LastTargetID { 0xFFFFFFFF }
, AccumulatedGattlingValue { 0 }
, ShouldUpdateGattlingValue { false }
Expand Down
20 changes: 12 additions & 8 deletions src/Ext/Techno/Hooks.ReceiveDamage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ DEFINE_HOOK(0x701900, TechnoClass_ReceiveDamage_Shield, 0x6)
return 0;
}

const auto pRules = RulesExt::Global();
const auto pExt = TechnoExt::ExtMap.Find(pThis);
const auto pTypeExt = pExt->TypeExtData;
const auto pType = pTypeExt->OwnerObject();
const auto pSourceHouse = args->SourceHouse;
const auto pTargetHouse = pThis->Owner;

Expand Down Expand Up @@ -61,7 +64,7 @@ DEFINE_HOOK(0x701900, TechnoClass_ReceiveDamage_Shield, 0x6)
}

// Raise Combat Alert
if (RulesExt::Global()->CombatAlert && damage > 1)
if (*args->Damage && (MapClass::GetTotalDamage(*args->Damage, args->WH, pType->Armor, args->DistanceToEpicenter) > 0))
{
auto raiseCombatAlert = [&]()
{
Expand All @@ -72,11 +75,7 @@ DEFINE_HOOK(0x701900, TechnoClass_ReceiveDamage_Shield, 0x6)

if (pHouseExt->CombatAlertTimer.HasTimeLeft() || pWHExt->CombatAlert_Suppress.Get(!pWHExt->Malicious || pWHExt->Nonprovocative))
return;

const auto pTypeExt = pExt->TypeExtData;
const auto pType = pTypeExt->OwnerObject();

if (!pTypeExt->CombatAlert.Get(RulesExt::Global()->CombatAlert_Default.Get(!pType->Insignificant && !pType->Spawned)) || !pThis->IsInPlayfield)
else if (!pTypeExt->CombatAlert.Get(pRules->CombatAlert_Default.Get(!pType->Insignificant && !pType->Spawned)) || !pThis->IsInPlayfield)
return;

const auto pBuilding = abstract_cast<BuildingClass*>(pThis);
Expand Down Expand Up @@ -112,7 +111,12 @@ DEFINE_HOOK(0x701900, TechnoClass_ReceiveDamage_Shield, 0x6)
if (index != -1)
VoxClass::PlayIndex(index);
};
raiseCombatAlert();

if (pRules->CombatAlert)
raiseCombatAlert();

if (pWHExt->CanTargetHouse(pSourceHouse, pThis))
pExt->LastHurtFrame = Unsorted::CurrentFrame;
}

// Shield Receive Damage
Expand Down Expand Up @@ -142,7 +146,7 @@ DEFINE_HOOK(0x701900, TechnoClass_ReceiveDamage_Shield, 0x6)
if ((!pWHExt->CanKill || pExt->AE.Unkillable)
&& pThis->Health > 0 && nDamageLeft != 0
&& pWHExt->CanTargetHouse(pSourceHouse, pThis)
&& MapClass::GetTotalDamage(nDamageLeft, args->WH, pThis->GetTechnoType()->Armor, args->DistanceToEpicenter) >= pThis->Health)
&& MapClass::GetTotalDamage(nDamageLeft, args->WH, pType->Armor, args->DistanceToEpicenter) >= pThis->Health)
{
// Update remaining damage and check if the target will die and should be avoided
damage = 0;
Expand Down
12 changes: 12 additions & 0 deletions src/Ext/TechnoType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,12 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)

this->RecountBurst.Read(exINI, pSection, "RecountBurst");

this->AdvancedDrive_ReverseSpeed.Read(exINI, pSection, "AdvancedDrive.ReverseSpeed");
this->AdvancedDrive_FaceTargetRange.Read(exINI, pSection, "AdvancedDrive.FaceTargetRange");
this->AdvancedDrive_MinimumDistance.Read(exINI, pSection, "AdvancedDrive.MinimumDistance");
this->AdvancedDrive_ConfrontEnemies.Read(exINI, pSection, "AdvancedDrive.ConfrontEnemies");
this->AdvancedDrive_RetreatDuration.Read(exINI, pSection, "AdvancedDrive.RetreatDuration");

this->BuildLimitGroup_Types.Read(exINI, pSection, "BuildLimitGroup.Types");
this->BuildLimitGroup_Nums.Read(exINI, pSection, "BuildLimitGroup.Nums");
this->BuildLimitGroup_Factor.Read(exINI, pSection, "BuildLimitGroup.Factor");
Expand Down Expand Up @@ -1466,6 +1472,12 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm)

.Process(this->RecountBurst)

.Process(this->AdvancedDrive_ReverseSpeed)
.Process(this->AdvancedDrive_FaceTargetRange)
.Process(this->AdvancedDrive_MinimumDistance)
.Process(this->AdvancedDrive_ConfrontEnemies)
.Process(this->AdvancedDrive_RetreatDuration)

.Process(this->BuildLimitGroup_Types)
.Process(this->BuildLimitGroup_Nums)
.Process(this->BuildLimitGroup_Factor)
Expand Down
12 changes: 12 additions & 0 deletions src/Ext/TechnoType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,12 @@ class TechnoTypeExt

Nullable<bool> RecountBurst;

Valueable<double> AdvancedDrive_ReverseSpeed;
Valueable<Leptons> AdvancedDrive_FaceTargetRange;
Valueable<Leptons> AdvancedDrive_MinimumDistance;
Valueable<bool> AdvancedDrive_ConfrontEnemies;
Valueable<int> AdvancedDrive_RetreatDuration;

ValueableVector<TechnoTypeClass*> BuildLimitGroup_Types;
ValueableVector<int> BuildLimitGroup_Nums;
Valueable<int> BuildLimitGroup_Factor;
Expand Down Expand Up @@ -660,6 +666,12 @@ class TechnoTypeExt

, RecountBurst {}

, AdvancedDrive_ReverseSpeed { 0.85 }
, AdvancedDrive_FaceTargetRange { Leptons(4096) }
, AdvancedDrive_MinimumDistance { Leptons(640) }
, AdvancedDrive_ConfrontEnemies { true }
, AdvancedDrive_RetreatDuration { 150 }

, BuildLimitGroup_Types {}
, BuildLimitGroup_Nums {}
, BuildLimitGroup_Factor { 1 }
Expand Down
12 changes: 9 additions & 3 deletions src/Ext/Unit/Hooks.Crushing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ DEFINE_HOOK(0x73B05B, UnitClass_PerCellProcess_TiltWhenCrushes, 0x6)
if (!pTypeExt->TiltsWhenCrushes_Overlays.Get(pType->TiltsWhenCrushes))
return SkipGameCode;

pThis->RockingForwardsPerFrame += static_cast<float>(pTypeExt->CrushOverlayExtraForwardTilt);
if (AdvancedDriveLocomotionClass::IsReversing(pThis))
pThis->RockingForwardsPerFrame -= static_cast<float>(pTypeExt->CrushOverlayExtraForwardTilt);
else
pThis->RockingForwardsPerFrame += static_cast<float>(pTypeExt->CrushOverlayExtraForwardTilt);

return SkipGameCode;
}
Expand All @@ -36,7 +39,10 @@ DEFINE_HOOK(0x741941, UnitClass_OverrunSquare_TiltWhenCrushes, 0x6)
if (!pTypeExt->TiltsWhenCrushes_Vehicles.Get(pType->TiltsWhenCrushes))
return SkipGameCode;

pThis->RockingForwardsPerFrame = static_cast<float>(pTypeExt->CrushForwardTiltPerFrame.Get(-0.050000001));
if (AdvancedDriveLocomotionClass::IsReversing(pThis))
pThis->RockingForwardsPerFrame = static_cast<float>(-pTypeExt->CrushForwardTiltPerFrame.Get(-0.05));
else
pThis->RockingForwardsPerFrame = static_cast<float>(pTypeExt->CrushForwardTiltPerFrame.Get(-0.05));

return SkipGameCode;
}
Expand Down Expand Up @@ -68,7 +74,7 @@ DEFINE_HOOK(0x4B19F7, DriveLocomotionClass_WhileMoving_CrushTilt, 0xD)

auto const pLinkedTo = pThis->LinkedTo;
auto const pTypeExt = TechnoExt::ExtMap.Find(pLinkedTo)->TypeExtData;
pLinkedTo->RockingForwardsPerFrame = static_cast<float>(pTypeExt->CrushForwardTiltPerFrame.Get(-0.050000001));
pLinkedTo->RockingForwardsPerFrame = static_cast<float>(pTypeExt->CrushForwardTiltPerFrame.Get(-0.05));

return R->Origin() == 0x4B19F7 ? SkipGameCode1 : SkipGameCode2;
}
Expand Down
Loading
Loading