Skip to content
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

Techno attachment logic #352

Draft
wants to merge 107 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 92 commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
cf33e39
WIP Techno Attachment logic
Metadorius Nov 11, 2021
774bfa5
Restrict commandability of attached technos
Metadorius Nov 12, 2021
b64eb0b
Implement InheritsCommands pt. 1
Metadorius Nov 12, 2021
01dd1cd
Fix command inheritance crashing in waypoint mode
Metadorius Nov 15, 2021
58c7c0a
Filter movement commands
Metadorius Nov 15, 2021
facba8c
Proper implementation of command inheritance
Metadorius Nov 20, 2021
9d6ca0d
Merge branch 'develop' into feature/techno-attachment
Metadorius Apr 21, 2022
2754e67
Merge branch 'develop' into feature/techno-attachment
Metadorius Apr 21, 2022
d736a5e
Merge branch 'develop' into feature/techno-attachment
Metadorius Apr 21, 2022
ac910db
Init docs
Metadorius Apr 22, 2022
43b679f
Stop command handling
Metadorius Apr 22, 2022
2ebec58
Merge branch 'develop'
Metadorius Jul 10, 2022
645820a
Fix YRpp
Metadorius Jul 10, 2022
c703dff
Another pass at techno attachment
Metadorius Jul 12, 2022
580d9c8
Fix scatter hook incompatibility with Ares; handle IsLocomotor
Metadorius Jul 12, 2022
1796b3f
Merge branch 'develop' into feature/techno-attachment
Metadorius Jul 12, 2022
cec6eab
Fixed stuff
Metadorius Jul 13, 2022
39158ba
Add sanity check
Metadorius Jul 13, 2022
db9f830
Fix re(tard)factoring
Metadorius Jul 13, 2022
81f52da
Merge branch 'develop' into feature/techno-attachment
Metadorius Jul 14, 2022
7ddae7e
Add failsafe check
Metadorius Jul 19, 2022
5b44a9f
Add ShipLoco support
Metadorius Jul 19, 2022
7e74eb4
Attempt to fix lag
Metadorius Sep 17, 2022
b85f751
Update YRpp
Metadorius Sep 19, 2022
f240be5
BROKEN attempt at rendering from parent's origin
Metadorius Sep 24, 2022
fa93012
Fix partially
Metadorius Sep 25, 2022
799ed8c
Use multiplication, adjust post draw rect calculation
Metadorius Oct 1, 2022
289618e
forgot MakeIdentity
Metadorius Oct 1, 2022
13b6516
it WORKS!
Metadorius Oct 21, 2022
3f7501b
Move the lasertrail's type-convertion aftermath into TechnoClass_AI
chaserli Oct 22, 2022
6d9a0e4
Add YSort handling, fix warnings
Starkku Oct 22, 2022
1c8cc13
Fix shadow drawing, support AircraftClass drawing
Metadorius Oct 22, 2022
b95048e
Merge branch 'develop' into feature/techno-attachment
Metadorius Oct 22, 2022
5502999
Fit to develop changes
Metadorius Oct 22, 2022
61e29be
Fix debug attach task not working
Metadorius Oct 22, 2022
786f279
Merge branch 'develop' into feature/techno-attachment
Metadorius Oct 22, 2022
8ae84db
Revert random ass edit of LaserTrail stuff
Metadorius Oct 22, 2022
5616076
Shut up EditorConfig
Metadorius Oct 22, 2022
60c8321
Handle TunnelLoco
Metadorius Oct 22, 2022
c83d293
Calculate physical location the same way as visual
Metadorius Oct 22, 2022
81495a6
Fix wrong transform being used for location
Metadorius Oct 22, 2022
94d5b67
Fix wrong selectable coords
Metadorius Oct 23, 2022
1ced9ca
Revert to the original function
Metadorius Oct 23, 2022
c9abb2f
use AttachChild in CreateChild
Metadorius Oct 23, 2022
4bc4470
Fix a potential problem with cell passability hook causing unbreaking…
Starkku Oct 23, 2022
c412bfd
I am stupid
Metadorius Oct 23, 2022
d38ca17
Add voxel visual offset code
Metadorius Mar 25, 2023
3cc53f9
Disable prototype jitterless drawing
Metadorius May 23, 2023
0e56afe
Merge develop
Metadorius May 23, 2023
a03299b
Fix stop command crash with Kratos
Metadorius May 24, 2023
0be061c
Merge branch 'develop' into feature/techno-attachment
Metadorius Jun 15, 2023
d5e31a7
Implement custom attachment locomotion
Metadorius Jun 18, 2023
dce5b85
Disable layer checking that prevented picking up objects that changed…
Metadorius Jun 24, 2023
2493840
Handle layer changes in loco
Metadorius Jun 24, 2023
d94c3c4
Make InheritDestruction actually kill the object, not vanish
Metadorius Jun 24, 2023
88ecf1f
Adjust enabled tags & fix docs
Metadorius Jun 24, 2023
6f7d8c4
Fix Kill call signature
Metadorius Jun 24, 2023
f58077f
Merge remote-tracking branch 'origin/develop' into feature/techno-att…
Metadorius Jun 24, 2023
c6d05fe
Mention loco in the doc
Metadorius Jun 24, 2023
81c5bc4
Fix destruction crashing bugs
Metadorius Jun 25, 2023
48702a3
Tentative fix for waypoint mode command inheritance
Starkku Jun 25, 2023
bd185a0
Fix turret drawing & shadow height
Metadorius Jun 26, 2023
efce95c
Revert to draw shadows as for individual units
Metadorius Jun 26, 2023
42411aa
Merge remote-tracking branch 'origin/develop' into feature/techno-att…
Metadorius Jun 26, 2023
2436e2a
Handle airborne attachments
Metadorius Jun 26, 2023
fc749fe
Fix AttachmentLoco destruction crash
Metadorius Jun 27, 2023
e9dbd24
Improve death handling for children, fix Crashable=yes death issues
Metadorius Jun 27, 2023
a063723
Minor fix for crashable units which don't have correct source set
Metadorius Jun 27, 2023
7178452
Allow negative DirType in parsing
Metadorius Jun 27, 2023
e33bb19
Implement RotationAdjust
Metadorius Jun 27, 2023
2a402fe
Improve syncing
Metadorius Jun 28, 2023
e80572a
WIP OccupiesCell impl. + built techno shouldn't occupy bib with child…
Metadorius Jul 6, 2023
c2cb8a4
OccupiesCell pt. 2
Metadorius Jul 6, 2023
c885934
Finished initial OccupiesCell implementation
Metadorius Jul 7, 2023
40e0022
Merge remote-tracking branch 'origin/develop' into feature/techno-att…
Metadorius Jul 7, 2023
28fc477
Merge remote-tracking branch 'origin/develop' into feature/techno-att…
Metadorius Jul 8, 2023
fa16ca2
Clean up a bit, add InheritLayerStatus and custom layer calculation, …
Metadorius Jul 9, 2023
f8d096b
Merge branch 'develop' into feature/techno-attachment
Metadorius Jul 9, 2023
10d929f
Fixed waypointing with InheritCommands, temp. disable actions override
Metadorius Jul 14, 2023
64711e7
Merge remote-tracking branch 'origin/develop' into feature/techno-att…
Metadorius Jul 14, 2023
33327f7
que?
Metadorius Jul 14, 2023
3b1a8e7
Merge remote-tracking branch 'origin/develop' into feature/techno-att…
Metadorius Jul 15, 2023
451a083
Attempt to fix crashes
Metadorius Jul 19, 2023
8f224e5
Implement RespawnTimer and TransparentToMouse, re-enable RespawnAtCre…
Metadorius Jul 19, 2023
a4c9bb6
Merge remote-tracking branch 'origin/develop' into feature/techno-att…
Metadorius Jul 19, 2023
6a793b4
Added missed doc edit for TransparentToMouse
Metadorius Jul 20, 2023
c02f8f9
Try to fix AircraftTracker crash one more time
Metadorius Jul 20, 2023
85e3ea9
Fix TransparentToMouse undesired behavior
Metadorius Jul 20, 2023
eb4439b
(hope)Fully fix pathfinding
Metadorius Aug 5, 2023
57483ae
Remove experimental/commented out stuff
Metadorius Aug 5, 2023
2391209
Minor cleanups
Metadorius Aug 5, 2023
014b4df
Merge remote-tracking branch 'origin/develop' into feature/techno-att…
Metadorius Aug 5, 2023
ff5e9c9
Sensors for attachment loco
Metadorius Sep 7, 2023
2a3d473
(Hacky?) sight for attachment loco
Metadorius Sep 7, 2023
00b221c
Handle CellClass::Incoming properly
Metadorius Sep 7, 2023
39d46d4
Merge remote-tracking branch 'origin/develop' into feature/techno-att…
Metadorius Sep 8, 2023
85025e9
Fix *Layer tags type
Metadorius Sep 8, 2023
1def3aa
Implement building upgrades support
Metadorius Sep 9, 2023
a3b084a
Fix AreRelatives
Metadorius Sep 9, 2023
6f25f1d
Fix passenger loading for multiple technos on cell
Metadorius Apr 17, 2024
76f7bcd
Merge remote-tracking branch 'origin/develop' into feature/techno-att…
Metadorius Apr 17, 2024
64e3fbe
Post-merge fix
Metadorius Apr 17, 2024
d903654
Merge remote-tracking branch 'origin/develop' into feature/techno-att…
Metadorius May 5, 2024
fd7197a
Post-merge fix
Metadorius May 5, 2024
250b4c3
Fix transports not working properly when there's multiple technos on …
Metadorius May 5, 2024
22299b2
Merge branch 'develop' into feature/techno-attachment
Metadorius Sep 19, 2024
6448ac3
InheritCommands.DeployCommand & StopCommand as separate key
Metadorius Sep 19, 2024
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 @@ -36,6 +36,7 @@ This page lists all the individual contributions to the project by their author.
- Recursive transport killer fix
- Custom locomotors example implementation and piggybacking test warheads
- Jumpjet initial facing fix
- Techno Attachment logic
- Migration utility
- GitHub Actions setup
- Official docs
Expand Down
12 changes: 10 additions & 2 deletions Phobos.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
<ClCompile Include="src\Ext\TEvent\Body.cpp" />
<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\TestLocomotionClass.cpp"/>
<ClCompile Include="src\Locomotion\AttachmentLocomotionClass.cpp"/>
<ClCompile Include="src\Misc\Hooks.Gamespeed.cpp" />
<ClCompile Include="src\Misc\Hooks.Ares.cpp" />
<ClCompile Include="src\Misc\PhobosToolTip.cpp" />
Expand All @@ -62,7 +63,9 @@
<ClCompile Include="src\New\Type\LaserTrailTypeClass.cpp" />
<ClCompile Include="src\New\Type\Affiliated\InterceptorTypeClass.cpp" />
<ClCompile Include="src\New\Type\Affiliated\PassengerDeletionTypeClass.cpp" />
<ClCompile Include="src\New\Type\AttachmentTypeClass.cpp" />
<ClCompile Include="src\New\Entity\LaserTrailClass.cpp" />
<ClCompile Include="src\New\Entity\AttachmentClass.cpp" />
<ClCompile Include="src\Ext\Aircraft\Body.cpp" />
<ClCompile Include="src\Ext\Aircraft\Hooks.cpp" />
<ClCompile Include="src\Ext\AnimType\Body.cpp" />
Expand Down Expand Up @@ -107,6 +110,7 @@
<ClCompile Include="src\Ext\Techno\Hooks.Transport.cpp" />
<ClCompile Include="src\Ext\Techno\Hooks.Disguise.cpp" />
<ClCompile Include="src\Ext\Techno\Hooks.DeploysInto.cpp" />
<ClCompile Include="src\Ext\Techno\Hooks.TechnoAttachment.cpp" />
<ClCompile Include="src\Ext\TerrainType\Body.cpp" />
<ClCompile Include="src\Ext\TerrainType\Hooks.cpp" />
<ClCompile Include="src\Ext\TerrainType\Hooks.Passable.cpp" />
Expand All @@ -124,6 +128,7 @@
<ClCompile Include="src\Ext\WeaponType\Hooks.cpp" />
<ClCompile Include="src\Ext\WeaponType\Hooks.DiskLaserRadius.cpp" />
<ClCompile Include="src\Misc\BlittersFix.cpp" />
<ClCompile Include="src\Misc\Hooks.AI.cpp" />
<ClCompile Include="src\Misc\Hooks.Blowfish.cpp" />
<ClCompile Include="src\Misc\Selection.cpp" />
<ClCompile Include="src\Utilities\Anchor.cpp" />
Expand Down Expand Up @@ -177,7 +182,8 @@
<ClInclude Include="src\Ext\TAction\Body.h" />
<ClInclude Include="src\Ext\Team\Body.h" />
<ClInclude Include="src\Ext\TEvent\Body.h" />
<ClInclude Include="src\Locomotion\TestLocomotionClass.h" />
<ClInclude Include="src\Locomotion\TestLocomotionClass.h"/>
<ClInclude Include="src\Locomotion\AttachmentLocomotionClass.h"/>
<ClInclude Include="src\Misc\BlittersFix.h" />
<ClInclude Include="src\Ext\CaptureManager\Body.h" />
<ClInclude Include="src\Misc\FlyingStrings.h" />
Expand All @@ -190,8 +196,10 @@
<ClInclude Include="src\New\Type\LaserTrailTypeClass.h" />
<ClInclude Include="src\New\Type\Affiliated\InterceptorTypeClass.h" />
<ClInclude Include="src\New\Type\Affiliated\PassengerDeletionTypeClass.h" />
<ClInclude Include="src\New\Type\AttachmentTypeClass.h" />
<ClInclude Include="src\New\Entity\LaserTrailClass.h" />
<ClInclude Include="src\New\Entity\ShieldClass.h" />
<ClInclude Include="src\New\Entity\AttachmentClass.h" />
<ClInclude Include="src\Utilities\Anchor.h" />
<ClInclude Include="src\Utilities\Enumerable.h" />
<ClInclude Include="src\Ext\Aircraft\Body.h" />
Expand Down
2 changes: 1 addition & 1 deletion docs/Contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ ExtData(TerrainTypeClass* OwnerObject) : Extension<TerrainTypeClass>(OwnerObject
- Class fields that can be set via INI tags should be named exactly like ini tags with dots replaced with underscores.
- Pointer type declarations always have pointer sign `*` attached to the type declaration.
- Non-static class extension methods faked by declaring a static method with `pThis` as a first argument are only to be placed in the extension class for the class instance of which `pThis` is.
- If it's crucial to fake `__thiscall` you may use `__fastcall` and use `void*` or `void* _` as a second argument to discard value passed through `EDX` register. Such methods are to be used for call replacement.
- If it's crucial to fake `__thiscall` you may use `__fastcall` and use `discard_t` or `discard_t _` as a second argument to discard value passed through `EDX` register. Such methods are to be used for call replacement.
- Hooks have to be named using a following scheme: `HookedFunction_HookPurpose`, or `ClassName_HookedMethod_HookPurpose`. Defined-again hooks are exempt from this scheme due to impossibility to define different names for the same hook.
- Return addresses should use anonymous enums to make it clear what address means what, if applicable. The enum has to be placed right at the function start and include all addresses that are used in this hook:
```cpp
Expand Down
31 changes: 17 additions & 14 deletions docs/Miscellanous.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,28 @@ SkirmishUnlimitedColors=false ; boolean
### Frame Step In

- There's a new hotkey to execute the game frame by frame for development usage.
- You can switch to frame by frame mode and then use frame step in command to forward 1, 5, 10, 15, 30 or 60 frames by one hit.
- You can switch to frame by frame mode and then use frame step in command to forward 1, 5, 10, 15, 30 or 60 frames by one hit.

### Semantic locomotor aliases

- 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.
- The feature is also supported for Phobos locomotors.

| *Alias* | *CLSID* |
| -------: | :--------------------------------------: |
Drive | `{4A582741-9839-11d1-B709-00A024DDAFD1}` |
Jumpjet | `{92612C46-F71F-11d1-AC9F-006008055BB5}` |
Hover | `{4A582742-9839-11d1-B709-00A024DDAFD1}` |
Rocket | `{B7B49766-E576-11d3-9BD9-00104B972FE8}` |
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}` |
Attachment | `{C5D54B98-8C98-4275-8CE4-EF75CB0CBE3E}` |

| *Alias*| *CLSID* |
| -----: | :--------------------------------------: |
Drive | `{4A582741-9839-11d1-B709-00A024DDAFD1}` |
Jumpjet | `{92612C46-F71F-11d1-AC9F-006008055BB5}` |
Hover | `{4A582742-9839-11d1-B709-00A024DDAFD1}` |
Rocket | `{B7B49766-E576-11d3-9BD9-00104B972FE8}` |
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}` |

## Game Speed

Expand Down
51 changes: 51 additions & 0 deletions docs/New-or-Enhanced-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,57 @@ This page describes all the engine features that are either new and introduced b

## New types / ingame entities

### Attachments

![Unit Attachment](your image here)
*Attachments used in [mod name](link)*

```{warning}
This feature is not final and is under development.
```

- Technos now can be attached one to another in a tree like way. The attached units won't process any locomotion code and act like a part of a parent unit in a configurable.
- Currently the attached techno may only be a vehicle.
- When attached, the special `Attachment` (`{C5D54B98-8C98-4275-8CE4-EF75CB0CBE3E}`) locomotor is automatically casted on a unit. You may also specify it in the child unit types manually if the unit is not intended to move without a parent (f. ex. a turret).

In `rulesmd.ini`:
```ini
[AttachmentTypes]
0=MNT ; (example)

[MNT]
RespawnAtCreation=true ; boolean
RespawnDelay=-1 ; integer, non-negative values enable the respawn timer
InheritOwner=true ; boolean, whether the child inherits owner of the parent while it's attached
InheritStateEffects=true ; boolean (state effects = chaos, iron curtain etc.)
InheritCommands=true ; boolean
LowSelectionPriority=true ; boolean, whether the child is low priority while attached
TransparentToMouse=false ; boolean, can't click on attached techno if set
YSortPosition=default ; Attachment YSort position enumeration - default|underparent|overparent
InheritDestruction=true ; boolean
InheritHeightStatus=true ; boolean, whether the layer and InAir/OnGround/IsSurfaced inherited from parent
OccupiesCell=true ; boolean
DestructionWeapon.Child= ; WeaponType, detonated on child when parent is destroyed
DestructionWeapon.Parent= ; WeaponType, detonated on parent when child is destroyed
ParentDestructionMission= ; MissionType, queued to child when parent is destroyed
ParentDetachmentMission= ; MissionType, queued to child when it's detached from parent

[SOMETECHNO] ; TechnoTypeClass
; used when this techno is attached
AttachmentTopLayerMinHeight= ; integer
AttachmentUndergroundLayerMaxHeight= ; integer
; used for attaching other technos
AttachmentX.Type=MNT ; AttachmentType (example)
AttachmentX.TechnoType= ; TechnoType that can be attached, currently only units are supported
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you can see this tag is not on the attachment but on the techno that the attachment is strapped upon. The reason for this is because AttachmentType is meant to be defining the kind of linkage mod makers would want (for example, a virtual unit, a physical unit, maybe a mount on a hovercraft w/e) and then attach stuff to it.

What I wonder about is where do you draw the line between "instance-specific" tags and type-specific? Like if you see above there's RespawnAtCreation and RespawnDelay which are on the AttachmentType and I wonder if they really should be there considering they work with TechnoType defined here. I also wonder about tags like PassengerAsAttachment or AmmoAsAttachment etc.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the perspective of this semantic distinction that you've made where AttachmentType controls how the attachment and parent link together and any controls regarding what get attached are on the parent's type, RespawnAtCreation and RespawnDelay are technically type-agnostic and would still fall under controlling the link itself (in essence it is how it gets restored if severed). However it falls under things that people would likely want to adjust per parent type even in cases where a lot of the other properties are reused. DestructionWeapon etc. would likely fall under that same umbrella.

If you want to stick with the semantic distinction you've made, then they stay on the attachment type. If you are willing to relent and consider modder usability, you'll allow defining or overriding atleast the previously mentioned things on the parent's type.

AttachmentX.FLH=0,0,0 ; integer - Forward, Lateral, Height
AttachmentX.IsOnTurret=false ; boolean
AttachmentX.RotationAdjust=0 ; rotation in DirType, from -255 to 255

[General]
AttachmentTopLayerMinHeight=500 ; integer,
AttachmentUndergroundLayerMaxHeight=-256 ; integer
```

### Custom Radiation Types

![image](_static/images/radtype-01.png)
Expand Down
9 changes: 9 additions & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,15 @@ You can use the migration utility (can be found on [Phobos supplementaries repo]

## Changelog

### 0.4

<details>
<summary>Click to show</summary>

New:
- Techno Attachment logic (by Kerbiter)
</details>

### Version TBD (develop branch nightly builds)

<details open>
Expand Down
7 changes: 7 additions & 0 deletions src/Ext/Rules/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <New/Type/ShieldTypeClass.h>
#include <New/Type/LaserTrailTypeClass.h>
#include <New/Type/DigitalDisplayTypeClass.h>
#include <New/Type/AttachmentTypeClass.h>

std::unique_ptr<RulesExt::ExtData> RulesExt::Data = nullptr;

Expand All @@ -32,6 +33,7 @@ void RulesExt::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)
RadTypeClass::LoadFromINIList(pINI);
ShieldTypeClass::LoadFromINIList(pINI);
LaserTrailTypeClass::LoadFromINIList(&CCINIClass::INI_Art.get());
AttachmentTypeClass::LoadFromINIList(pINI);

Data->LoadBeforeTypeData(pThis, pINI);
}
Expand Down Expand Up @@ -130,6 +132,9 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)
this->Vehicles_DefaultDigitalDisplayTypes.Read(exINI, GameStrings::AudioVisual, "Vehicles.DefaultDigitalDisplayTypes");
this->Aircraft_DefaultDigitalDisplayTypes.Read(exINI, GameStrings::AudioVisual, "Aircraft.DefaultDigitalDisplayTypes");

this->AttachmentTopLayerMinHeight.Read(exINI, GameStrings::General, "AttachmentTopLayerMinHeight");
this->AttachmentUndergroundLayerMaxHeight.Read(exINI, GameStrings::General, "AttachmentUndergroundLayerMaxHeight");

// Section AITargetTypes
int itemsCount = pINI->GetKeyCount(sectionAITargetTypes);
for (int i = 0; i < itemsCount; ++i)
Expand Down Expand Up @@ -255,6 +260,8 @@ void RulesExt::ExtData::Serialize(T& Stm)
.Process(this->Infantry_DefaultDigitalDisplayTypes)
.Process(this->Vehicles_DefaultDigitalDisplayTypes)
.Process(this->Aircraft_DefaultDigitalDisplayTypes)
.Process(this->AttachmentTopLayerMinHeight)
.Process(this->AttachmentUndergroundLayerMaxHeight)
;
}

Expand Down
5 changes: 5 additions & 0 deletions src/Ext/Rules/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@
ValueableVector<DigitalDisplayTypeClass*> Vehicles_DefaultDigitalDisplayTypes;
ValueableVector<DigitalDisplayTypeClass*> Aircraft_DefaultDigitalDisplayTypes;

Valueable<bool> AttachmentTopLayerMinHeight;
Valueable<bool> AttachmentUndergroundLayerMaxHeight;
Metadorius marked this conversation as resolved.
Show resolved Hide resolved

ExtData(RulesClass* OwnerObject) : Extension<RulesClass>(OwnerObject)
, Storage_TiberiumIndex { -1 }
, InfantryGainSelfHealCap {}
Expand Down Expand Up @@ -153,7 +156,9 @@
, Infantry_DefaultDigitalDisplayTypes {}
, Vehicles_DefaultDigitalDisplayTypes {}
, Aircraft_DefaultDigitalDisplayTypes {}
, AttachmentTopLayerMinHeight { 500 }
, AttachmentUndergroundLayerMaxHeight { -256 }
{ }

Check warning on line 161 in src/Ext/Rules/Body.h

View workflow job for this annotation

GitHub Actions / build

'argument': truncation from 'int' to 'T' [D:\a\Phobos\Phobos\Phobos.vcxproj]

Check warning on line 161 in src/Ext/Rules/Body.h

View workflow job for this annotation

GitHub Actions / build

with [D:\a\Phobos\Phobos\Phobos.vcxproj]

Check warning on line 161 in src/Ext/Rules/Body.h

View workflow job for this annotation

GitHub Actions / build

[ [D:\a\Phobos\Phobos\Phobos.vcxproj]

Check warning on line 161 in src/Ext/Rules/Body.h

View workflow job for this annotation

GitHub Actions / build

T=bool [D:\a\Phobos\Phobos\Phobos.vcxproj]

Check warning on line 161 in src/Ext/Rules/Body.h

View workflow job for this annotation

GitHub Actions / build

] [D:\a\Phobos\Phobos\Phobos.vcxproj]

Check warning on line 161 in src/Ext/Rules/Body.h

View workflow job for this annotation

GitHub Actions / build

{ } [D:\a\Phobos\Phobos\Phobos.vcxproj]

Check warning on line 161 in src/Ext/Rules/Body.h

View workflow job for this annotation

GitHub Actions / build

^ (compiling source file src\Commands\NextIdleHarvester.cpp) [D:\a\Phobos\Phobos\Phobos.vcxproj]

Check warning on line 161 in src/Ext/Rules/Body.h

View workflow job for this annotation

GitHub Actions / build

'argument': truncation from 'int' to 'T' [D:\a\Phobos\Phobos\Phobos.vcxproj]

Check warning on line 161 in src/Ext/Rules/Body.h

View workflow job for this annotation

GitHub Actions / build

with [D:\a\Phobos\Phobos\Phobos.vcxproj]

Check warning on line 161 in src/Ext/Rules/Body.h

View workflow job for this annotation

GitHub Actions / build

[ [D:\a\Phobos\Phobos\Phobos.vcxproj]

virtual ~ExtData() = default;

Expand Down
47 changes: 33 additions & 14 deletions src/Ext/Techno/Body.Internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <BitFont.h>

#include <Ext/WeaponType/Body.h>
#include <Misc/FlyingStrings.h>
#include <Utilities/EnumFunctions.h>

Expand Down Expand Up @@ -41,23 +42,26 @@ void TechnoExt::ObjectKilledBy(TechnoClass* pVictim, TechnoClass* pKiller)
}
}

// reversed from 6F3D60
CoordStruct TechnoExt::GetFLHAbsoluteCoords(TechnoClass* pThis, CoordStruct pCoord, bool isOnTurret)
Matrix3D TechnoExt::GetTransform(TechnoClass* pThis, VoxelIndexKey* pKey, bool isShadow)
{
auto const pType = pThis->GetTechnoType();
auto const pFoot = abstract_cast<FootClass*>(pThis);
Matrix3D mtx;

// Step 1: get body transform matrix
if (pFoot && pFoot->Locomotor)
mtx = pFoot->Locomotor->Draw_Matrix(nullptr);
if ((pThis->AbstractFlags & AbstractFlags::Foot) && ((FootClass*)pThis)->Locomotor)
mtx = isShadow ? ((FootClass*)pThis)->Locomotor->Shadow_Matrix(pKey) : ((FootClass*)pThis)->Locomotor->Draw_Matrix(pKey);
else // no locomotor means no rotation or transform of any kind (f.ex. buildings) - Kerbiter
mtx.MakeIdentity();

// Steps 2-3: turret offset and rotation
return mtx;
}

Matrix3D TechnoExt::TransformFLHForTurret(TechnoClass* pThis, Matrix3D mtx, bool isOnTurret, double factor)
{
auto const pType = pThis->GetTechnoType();

// turret offset and rotation
if (isOnTurret && pThis->HasTurret())
{
TechnoTypeExt::ApplyTurretOffset(pType, &mtx);
TechnoTypeExt::ApplyTurretOffset(pType, &mtx, factor);

double turretRad = pThis->TurretFacing().GetRadian<32>();
double bodyRad = pThis->PrimaryFacing.Current().GetRadian<32>();
Expand All @@ -66,17 +70,32 @@ CoordStruct TechnoExt::GetFLHAbsoluteCoords(TechnoClass* pThis, CoordStruct pCoo
mtx.RotateZ(angle);
}

// Step 4: apply FLH offset
mtx.Translate((float)pCoord.X, (float)pCoord.Y, (float)pCoord.Z);
return mtx;
}

auto result = mtx * Vector3D<float>::Empty;
Matrix3D TechnoExt::GetFLHMatrix(TechnoClass* pThis, CoordStruct pCoord, bool isOnTurret, double factor, bool isShadow)
{
Matrix3D transform = TechnoExt::GetTransform(pThis, nullptr, isShadow);
Matrix3D mtx = TechnoExt::TransformFLHForTurret(pThis, transform, isOnTurret, factor);

CoordStruct scaledCoord = pCoord * factor;
// apply FLH offset
mtx.Translate((float)scaledCoord.X, (float)scaledCoord.Y, (float)scaledCoord.Z);

return mtx;
}

// reversed from 6F3D60
CoordStruct TechnoExt::GetFLHAbsoluteCoords(TechnoClass* pThis, CoordStruct pCoord, bool isOnTurret)
{
auto result = TechnoExt::GetFLHMatrix(pThis, pCoord, isOnTurret) * Vector3D<float>::Empty;

// Resulting coords are mirrored along X axis, so we mirror it back
result.Y *= -1;

// Step 5: apply as an offset to global object coords
// apply as an offset to global object coords
CoordStruct location = pThis->GetCoords();
location += { (int)result.X, (int)result.Y, (int)result.Z };
location += { std::lround(result.X), std::lround(result.Y), std::lround(result.Z) };

return location;
}
Expand Down
30 changes: 20 additions & 10 deletions src/Ext/Techno/Body.Update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,19 +589,29 @@ void TechnoExt::KillSelf(TechnoClass* pThis, AutoDeathBehavior deathOption, Anim
}

default: //must be AutoDeathBehavior::Kill
if (IS_ARES_FUN_AVAILABLE(SpawnSurvivors))
TechnoExt::Kill(pThis, nullptr, pThis->Owner);
}
}

void TechnoExt::Kill(TechnoClass* pThis, ObjectClass* pAttacker, HouseClass* pAttackingHouse)
{
if (IS_ARES_FUN_AVAILABLE(SpawnSurvivors))
{
switch (pThis->WhatAmI())
{
switch (pThis->WhatAmI())
{
case AbstractType::Unit:
case AbstractType::Aircraft:
AresFunctions::SpawnSurvivors(static_cast<FootClass*>(pThis), nullptr, false, false);
default:break;
}
case AbstractType::Unit:
case AbstractType::Aircraft:
AresFunctions::SpawnSurvivors(abstract_cast<FootClass*>(pThis), abstract_cast<TechnoClass*>(pAttacker), false, false);
default: break;
}
pThis->ReceiveDamage(&pThis->Health, 0, RulesClass::Instance->C4Warhead, nullptr, true, false, pThis->Owner);
return;
}

pThis->ReceiveDamage(&pThis->Health, 0, RulesClass::Instance->C4Warhead, pAttacker, true, false, pAttackingHouse);
}

void TechnoExt::Kill(TechnoClass* pThis, TechnoClass* pAttacker)
{
TechnoExt::Kill(pThis, pAttacker, pAttacker ? pAttacker->Owner : nullptr);
}

void TechnoExt::UpdateSharedAmmo(TechnoClass* pThis)
Expand Down
Loading
Loading