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

Units AutoDeploy/DeployBlock on Ammo change #1086

Merged
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
33c8a68
Update YRpp
Fryone Jun 17, 2023
5891e00
OnAmmoDepletion Actions
Fryone Jun 17, 2023
c711f4c
Code Fixes and Improvements
Fryone Jun 17, 2023
3c142b4
Revert "Update YRpp"
Fryone Jun 17, 2023
25a495f
Update src/Ext/Techno/Body.Update.cpp
Fryone Jun 17, 2023
d7ab3eb
Update src/Ext/Techno/Body.Update.cpp
Fryone Jun 17, 2023
079790e
Update src/Ext/Techno/Body.Update.cpp
Fryone Jun 17, 2023
b88a8b7
Update src/Ext/Techno/Body.Update.cpp
Fryone Jun 17, 2023
119848a
Update src/Ext/TechnoType/Body.cpp
Fryone Jun 17, 2023
6d5e67a
Update src/Ext/TechnoType/Body.cpp
Fryone Jun 17, 2023
8233a83
Update src/Ext/TechnoType/Body.h
Fryone Jun 17, 2023
992affa
Update src/Ext/TechnoType/Body.h
Fryone Jun 17, 2023
0d1f25d
Update src/Ext/TechnoType/Body.h
Fryone Jun 17, 2023
5d2e54f
Refactoring code
Fryone Jun 17, 2023
8e33a8e
Merge branch 'Phobos-developers:develop' into develop
Fryone Jun 17, 2023
76653bf
Documentation Changes
Fryone Jun 17, 2023
7c6b86c
Merge branch 'develop' of https://github.com/Fryone/Phobos into develop
Fryone Jun 17, 2023
8a5ab9a
Credits and Changelog
Fryone Jun 17, 2023
2a6441d
Update src/Ext/Techno/Body.Update.cpp
Fryone Jun 18, 2023
5055093
Feature Update
Fryone Jun 18, 2023
aaa6850
Update Body.Update.cpp
Fryone Jun 18, 2023
2e7e550
efficient refactoring
Fryone Jun 18, 2023
8aa35e0
Hooks.Unload
Fryone Jun 19, 2023
40691e3
Apply suggestions from code review
MortonPL Jul 8, 2023
bf453ca
Manually apply last suggestion
MortonPL Jul 8, 2023
5548261
Update src/Ext/TechnoType/Body.cpp
MortonPL Jul 8, 2023
e09f27d
Merge branch 'develop' into fryone/ammodepletion_deploy
MortonPL Jul 8, 2023
de7da16
Make linter happy
MortonPL Jul 8, 2023
920cfc7
Added VoiceCantDeploy
Fryone Jul 8, 2023
41434de
Merge branch 'develop' into fryone/ammodepletion_deploy
Fryone Jul 8, 2023
df48f9b
Update Hooks.Unload.cpp
Fryone Jul 14, 2023
faf1b3a
Merge branch 'develop' into fryone/ammodepletion_deploy
Fryone Jul 14, 2023
face7ec
Update Fixed-or-Improved-Logics.md
Fryone Jul 14, 2023
603d0ba
Merge branch 'fryone/ammodepletion_deploy' of https://github.com/Fryo…
Fryone Jul 14, 2023
3e099c8
Update Hooks.Unload.cpp
Fryone Jul 14, 2023
b46b6cd
Feature Extended
Fryone Jul 14, 2023
40fc7ac
Merge branch 'develop' into fryone/ammodepletion_deploy
Fryone Jul 16, 2023
8f23db2
Ammo change on deploy
Fryone Jul 16, 2023
7263b1c
Update Hooks.Unload.cpp
Fryone Jul 16, 2023
9d3a41b
Ammo changing on deploy fixes
Fryone Jul 23, 2023
23ab2bb
Merge branch 'develop' into fryone/ammodepletion_deploy
Fryone Aug 22, 2023
56a18e2
Improve documentation and fix a bug
MortonPL Aug 31, 2023
2af9379
Merge remote-tracking branch 'Phobos-Developers/develop' into fryone/…
MortonPL Aug 31, 2023
a79e236
Add full min/max support
MortonPL Aug 31, 2023
e731212
Merge branch 'develop' into fryone/ammodepletion_deploy
MortonPL Aug 31, 2023
fc296ad
Make 'em bools
MortonPL Aug 31, 2023
8c3aae3
Apply suggestions from code review
MortonPL Aug 31, 2023
0c8334c
Trailing whitespace
MortonPL Aug 31, 2023
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 @@ -475,6 +475,7 @@ This page lists all the individual contributions to the project by their author.
- `TurretOffset` support for SHP vehicles
- **Fryone**
- Customizable ElectricBolt Arcs
- Auto-deploy/Deploy block on ammo change
- **ZivDero**
- Allow giving ownership of buildings to players in Skirmish and MP using <Player @ A-H>
- **Ares developers**
Expand Down
1 change: 1 addition & 0 deletions Phobos.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
<ClCompile Include="src\Ext\Unit\Hooks.DeployFire.cpp" />
<ClCompile Include="src\Ext\Unit\Hooks.DisallowMoving.cpp" />
<ClCompile Include="src\Ext\Unit\Hooks.Jumpjet.cpp" />
<ClCompile Include="src\Ext\Unit\Hooks.Unload.cpp" />
<ClCompile Include="src\Ext\WarheadType\Detonate.cpp" />
<ClCompile Include="src\Ext\Tiberium\Body.cpp" />
<ClCompile Include="src\Ext\Tiberium\Hooks.cpp" />
Expand Down
29 changes: 29 additions & 0 deletions docs/Fixed-or-Improved-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ In `rulesmd.ini`:
[SOMETECHNO] ; TechnoType
JumpjetRotateOnCrash=true ; boolean
```

```{warning}
This may subject to further changes.
```
Expand Down Expand Up @@ -747,6 +748,34 @@ In `artmd.ini`:
TurretShadow= ; boolean
```

### `IsSimpleDeployer` vehicle auto-deploy / deploy block on ammo change

- Vehicle deployment can now be affected by ammo count.
- `Ammo.AutoDeployAmount` determines the minimal number of ammo at which a vehicle converts/deploys automatically.
- `Ammo.DeployUnlockAmount` determines the minimal number of ammo that unlocks issuing vehicle converting/deploying command.

In `rulesmd.ini`:
```ini
[SOMEVEHICLE] ; VehicleType
Ammo.DeployUnlockAmount=-1 ; integer
Ammo.AutoDeployAmount=-1 ; integer
```

```{warning}
`Ammo.AutoDeployAmount` feature requires `Convert.Deploy` from [Ares’ Type Conversion](https://ares-developers.github.io/Ares-docs/new/typeconversion.html) to change type. Unit without it will constantly use deploy command on self until ammo is changed.
```

### `IsSimpleDeployer` vehicle ammo change on deploy

- `Ammo.AddOnDeploy` determines the number of ammo added or substracted on unit deploy.

In `rulesmd.ini`:
```ini
[SOMEVEHICLE] ; VehicleType
Ammo.AddOnDeploy=0 ; integer
```

MortonPL marked this conversation as resolved.
Show resolved Hide resolved

## VoxelAnims

### Customizable debris & meteor impact and warhead detonation behaviour
Expand Down
3 changes: 2 additions & 1 deletion docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,12 @@ New:
- Vehicle voxel turret shadows & body multi-section shadows (by TwinkleStar)
- Crushing tilt and slowdown customization (by Starkku)
- Extra warhead detonations on weapon (by Starkku)
- Customizable ElectricBolt Arcs (by Fryone, Kerbiter)
- Chrono sparkle animation display customization and improvements (by Starkku)
- Script action to Chronoshift teams to enemy base (by Starkku)
- Customizable ElectricBolt Arcs (by Fryone, Kerbiter)
- Digital display of HP and SP (by ststl, FlyStar, Saigyouji, JunJacobYoung)
- PipScale pip customizations (size, ammo / spawn / tiberium frames or offsets) (by Starkku)
- Auto-deploy/Deploy block on ammo change (by Fryone)
- `AltPalette` lighting toggle (by Starkku)
- Unhardcoded timer blinking color scheme (by Starkku)
- Customizing shield self-healing timer restart when shield is damaged (by Starkku)
Expand Down
20 changes: 20 additions & 0 deletions src/Ext/Techno/Body.Update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,26 @@ void TechnoExt::ExtData::ApplyInterceptor()
}
}

void TechnoExt::ExtData::DepletedAmmoActions()
{
auto const pThis = this->OwnerObject();
auto const pType = pThis->GetTechnoType();
if ((pThis->WhatAmI() != AbstractType::Unit) || (pType->Ammo <= 0))
return;

auto const pTypeExt = this->TypeExtData;
if (!(pTypeExt->Ammo_AutoDeployAmount < 0))
return;

auto const pUnit = abstract_cast<UnitClass*>(pThis);

if (!pUnit->Type->IsSimpleDeployer)
return;
if (pThis->Ammo == pTypeExt->Ammo_AutoDeployAmount)
pThis->QueueMission(Mission::Unload, true);
return;
}

// TODO : Merge into new AttachEffects
bool TechnoExt::ExtData::CheckDeathConditions(bool isInLimbo)
{
Expand Down
1 change: 1 addition & 0 deletions src/Ext/Techno/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class TechnoExt

void ApplyInterceptor();
bool CheckDeathConditions(bool isInLimbo = false);
void DepletedAmmoActions();
void EatPassengers();
void UpdateShield();
void UpdateOnTunnelEnter();
Expand Down
1 change: 1 addition & 0 deletions src/Ext/Techno/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ DEFINE_HOOK(0x6F9E50, TechnoClass_AI, 0x5)
pExt->UpdateShield();
pExt->ApplySpawnLimitRange();
pExt->UpdateLaserTrails();
pExt->DepletedAmmoActions();

TechnoExt::ApplyMindControlRangeLimit(pThis);

Expand Down
11 changes: 11 additions & 0 deletions src/Ext/TechnoType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)

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

this->Ammo_AddOnDeploy.Read(exINI, pSection, "Ammo.AddOnDeploy");
this->Ammo_AutoDeployAmount.Read(exINI, pSection, "Ammo.AutoDeployAmount");
this->Ammo_DeployUnlockAmount.Read(exINI, pSection, "Ammo.DeployUnlockAmount");

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

this->AutoDeath_Behavior.Read(exINI, pSection, "AutoDeath.Behavior");
this->AutoDeath_VanishAnimation.Read(exINI, pSection, "AutoDeath.VanishAnimation");
this->AutoDeath_OnAmmoDepletion.Read(exINI, pSection, "AutoDeath.OnAmmoDepletion");
Expand Down Expand Up @@ -424,6 +430,11 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm)
.Process(this->ShieldType)
.Process(this->PassengerDeletionType)

.Process(this->Ammo_AddOnDeploy)
.Process(this->Ammo_AutoDeployAmount)
.Process(this->Ammo_DeployUnlockAmount)
.Process(this->VoiceCantDeploy)

.Process(this->AutoDeath_Behavior)
.Process(this->AutoDeath_VanishAnimation)
.Process(this->AutoDeath_OnAmmoDepletion)
Expand Down
9 changes: 9 additions & 0 deletions src/Ext/TechnoType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ class TechnoTypeExt
Valueable<ShieldTypeClass*> ShieldType;
std::unique_ptr<PassengerDeletionTypeClass> PassengerDeletionType;

Nullable<int> Ammo_AddOnDeploy;
Valueable<int> Ammo_AutoDeployAmount;
Valueable<int> Ammo_DeployUnlockAmount;
NullableIdx<VocClass> VoiceCantDeploy;

Nullable<AutoDeathBehavior> AutoDeath_Behavior;
Nullable<AnimTypeClass*> AutoDeath_VanishAnimation;
Valueable<bool> AutoDeath_OnAmmoDepletion;
Expand Down Expand Up @@ -265,6 +270,10 @@ class TechnoTypeExt
, DeployingAnim_ReverseForUndeploy { true }
, DeployingAnim_UseUnitDrawer { true }

, Ammo_AddOnDeploy { }
, Ammo_AutoDeployAmount { -1 }
, Ammo_DeployUnlockAmount { -1 }

, AutoDeath_Behavior { }
, AutoDeath_VanishAnimation {}
, AutoDeath_OnAmmoDepletion { false }
Expand Down
93 changes: 93 additions & 0 deletions src/Ext/Unit/Hooks.Unload.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#include <UnitClass.h>
#include <TechnoClass.h>

#include <Ext/TechnoType/Body.h>
#include <Utilities/EnumFunctions.h>
#include <Utilities/GeneralUtils.h>
#include <Utilities/Macro.h>

DEFINE_HOOK(0x73FFE6, UnitClass_WhatAction_RemoveDeploying, 0xA)
{
enum { Continue = 0x73FFF0 };

GET(UnitClass*, pThis, ESI);
auto const pThisType = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType());

R->AL(pThis->CanDeploySlashUnload());
MortonPL marked this conversation as resolved.
Show resolved Hide resolved
if(pThis->CanDeploySlashUnload())
{
if(pThisType->Ammo_DeployUnlockAmount != 0 && pThis->Ammo < pThisType->Ammo_DeployUnlockAmount)
R->AL(false);
}

return Continue;
}

DEFINE_HOOK(0x730C70, DeployClass_Execute_RemoveDeploying, 0xA)
{
enum { Continue = 0x730C7A };

GET(TechnoClass*, pThis, ESI);
auto const pThisType = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType());

R->AL(pThis->CanDeploySlashUnload());
if(pThis->CanDeploySlashUnload())
{
if(pThisType->Ammo_DeployUnlockAmount != 0 && pThis->Ammo < pThisType->Ammo_DeployUnlockAmount)
R->AL(false);
}

return Continue;
}

DEFINE_HOOK(0x739C74, UnitClass_ToggleDeployState_ChangeAmmo, 0x6) //deploying
{
enum { Continue = 0x739C7A };

GET(UnitClass*, pThis, ECX);
auto const pThisExt = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType());
MortonPL marked this conversation as resolved.
Show resolved Hide resolved

if (pThis->Deployed && !pThis->Deploying && pThisExt->Ammo_AddOnDeploy)
{
int ammoCalc = (pThis->Ammo + pThisExt->Ammo_AddOnDeploy) < 0 ? 0 : (pThis->Ammo + pThisExt->Ammo_AddOnDeploy);
pThis->Ammo = ammoCalc > pThis->Type->Ammo ? pThis->Type->Ammo : ammoCalc;
}

R->EAX(pThis->GetTechnoType());
return Continue;
}

DEFINE_HOOK(0x739E5A, UnitClass_ToggleSimpleDeploy_ChangeAmmo, 0x6) //undeploying
{
enum { Continue = 0x739E60 };

GET(UnitClass*, pThis, ECX);
auto const pThisExt = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType());

if (!pThis->Deployed && !pThis->Undeploying && pThisExt->Ammo_AddOnDeploy)
{
int ammoCalc = (pThis->Ammo + pThisExt->Ammo_AddOnDeploy) < 0 ? 0 : (pThis->Ammo + pThisExt->Ammo_AddOnDeploy);
pThis->Ammo = ammoCalc > pThis->Type->Ammo ? pThis->Type->Ammo : ammoCalc;
}

R->AL(pThis->IsDisguised());
return Continue;
}

DEFINE_HOOK(0x73DE78, UnitClass_Unload_ChangeAmmo, 0x6) //converters
{
enum { Continue = 0x73DE7E };

GET(TechnoClass*, pThis, ESI);
auto const pThisExt = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType());
auto pUnit = abstract_cast<UnitClass*>(pThis);

if (pUnit->Type->IsSimpleDeployer && pThisExt->Ammo_AddOnDeploy && (pUnit->Type->UnloadingClass == nullptr))
{
int ammoCalc = (pUnit->Ammo + pThisExt->Ammo_AddOnDeploy) < 0 ? 0 : (pUnit->Ammo + pThisExt->Ammo_AddOnDeploy);
pUnit->Ammo = ammoCalc > pUnit->Type->Ammo ? pUnit->Type->Ammo : ammoCalc;
}

R->AL(pUnit->Deployed);
return Continue;
}
Loading