Skip to content

[Vanilla Enhancement] Crush level system #1616

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 16 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 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
1 change: 1 addition & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ This page lists all the individual contributions to the project by their author.
- Fix an issue that teleport units board transport vehicles on the bridge will create an impassable invisible barrier, which may cause the game to freeze or even crash
- Fix wrong shadow when a vehicle has hover locomotor and is being lifted by `IsLocomotor=yes` warhead
- Fix the bug that a unit can overlap with `Teleport` units after it's been damaged by a fallen unit lifted by `IsLocomotor=yes` warheads
- Crush level system
- **Apollo** - Translucent SHP drawing patches
- **ststl**:
- Customizable `ShowTimer` priority of superweapons
Expand Down
33 changes: 33 additions & 0 deletions docs/Fixed-or-Improved-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,39 @@ ProneSpeed.NoCrawls=1.5 ; floating point value, multiplier
ProneSpeed= ; floating point value, multiplier, by default, use the corresponding global value according to Crawls
```

## Unit

### Crush level system

- It's possible to customize crush level and crushable level for now. Rolling is only allowed when the CrushLevel of the compactor is greater than the CrushableLevel of the crushed object.

In `rulesmd.ini`
```ini
[General]
CrusherLevel=5 ; integer
CrushableLevel=5 ; integer
OmniCrusherLevel=10 ; integer
OmniCrushResistantLevel=10 ; integer

[WallModel]
WallCrushableLevel=10 ; integer

[SOMEUNIT] ; Crusher
CrushLevel= ; integer
CrushLevel.Veteran= ; integer
CrushLevel.Elite= ; integer

[SOMETECHNO] ; infantry, unit, aircraft
CrushableLevel= ; integer
CrushableLevel.Veteran= ; integer
CrushableLevel.Elite= ; integer

[SOMEINFANTRY]
DeployedCrushableLevel= ; integer
DeployedCrushableLevel.Veteran= ; integer
DeployedCrushableLevel.Elite= ; integer
```

## Particle systems

### Fire particle target coordinate adjustment when firer rotates
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ New:
- [Jumpjet Tilts While Moving](New-or-Enhanced-Logics.md#jumpjet-tilts-while-moving) (by CrimRecya)
- [Spawned aircraft facing to match turret toggle](New-or-Enhanced-Logics.md#aircraft-spawner-customizations) (by Starkku)
- [Removed dependency on `blowfish.dll`](Miscellanous.md#blowfish-dependency) (by ZivDero)
- Crush level system (by NetsuNegi)

Vanilla fixes:
- Prevent the units with locomotors that cause problems from entering the tank bunker (by TaranDahl)
Expand Down
20 changes: 20 additions & 0 deletions src/Ext/Rules/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,11 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)

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

this->CrusherLevel.Read(exINI, GameStrings::General, "CrusherLevel");
this->CrushableLevel.Read(exINI, GameStrings::General, "CrushableLevel");
this->OmniCrusherLevel.Read(exINI, GameStrings::General, "OmniCrusherLevel");
this->OmniCrushResistantLevel.Read(exINI, GameStrings::General, "OmniCrushResistantLevel");

// Section AITargetTypes
int itemsCount = pINI->GetKeyCount("AITargetTypes");
for (int i = 0; i < itemsCount; ++i)
Expand Down Expand Up @@ -464,6 +469,11 @@ void RulesExt::ExtData::Serialize(T& Stm)
.Process(this->ProneSpeed_Crawls)
.Process(this->ProneSpeed_NoCrawls)
.Process(this->DamagedSpeed)
.Process(this->CrusherLevel)
.Process(this->CrushableLevel)
.Process(this->OmniCrusherLevel)
.Process(this->OmniCrushResistantLevel)
.Process(this->WallCrushableLevel)
;
}

Expand Down Expand Up @@ -647,3 +657,13 @@ DEFINE_HOOK(0x6744E4, RulesClass_ReadJumpjetControls_Extra, 0x7)

// skip vanilla JumpjetControls and make it earlier load
// DEFINE_JUMP(LJMP, 0x668EB5, 0x668EBD); // RulesClass_Process_SkipJumpjetControls // Really necessary? won't hurt to read again

DEFINE_HOOK(0x66D242, RulesClass_ReadWallModel_CrushableLevel, 0x5)
{
GET(CCINIClass*, pINI, EDI);
INI_EX exINI(pINI);

RulesExt::Global()->WallCrushableLevel.Read(exINI, "WallModel", "WallCrushableLevel");

return 0;
}
12 changes: 12 additions & 0 deletions src/Ext/Rules/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@ class RulesExt

Valueable<double> DamagedSpeed;

Valueable<int> CrusherLevel;
Valueable<int> CrushableLevel;
Valueable<int> OmniCrusherLevel;
Valueable<int> OmniCrushResistantLevel;
Valueable<int> WallCrushableLevel;

ExtData(RulesClass* OwnerObject) : Extension<RulesClass>(OwnerObject)
, Storage_TiberiumIndex { -1 }
, InfantryGainSelfHealCap {}
Expand Down Expand Up @@ -362,6 +368,12 @@ class RulesExt
, ProneSpeed_NoCrawls { 1.5 }

, DamagedSpeed { 0.75 }

, CrusherLevel { 5 }
, CrushableLevel { 5 }
, OmniCrusherLevel { 10 }
, OmniCrushResistantLevel { 10 }
, WallCrushableLevel { 10 }
{ }

virtual ~ExtData() = default;
Expand Down
89 changes: 89 additions & 0 deletions src/Ext/Techno/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,95 @@ bool TechnoExt::IsTypeImmune(TechnoClass* pThis, TechnoClass* pSource)
return false;
}

int TechnoExt::GetCrushLevel(FootClass* pThis)
{
const auto pTypeExt = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType());

switch (pThis->Veterancy.GetRemainingLevel())
{
case Rank::Elite:
if (pTypeExt->Elite_CrushLevel.isset())
return pTypeExt->Elite_CrushLevel.Get();

case Rank::Veteran:
if (pTypeExt->Vet_CrushLevel.isset())
return pTypeExt->Vet_CrushLevel.Get();

default:
if (pTypeExt->CrushLevel.isset())
return pTypeExt->CrushLevel.Get();
}

const auto pType = pThis->GetTechnoType();

if (pType->OmniCrusher)
return RulesExt::Global()->OmniCrusherLevel;

if (pType->Crusher || pThis->HasAbility(Ability::Crusher))
return RulesExt::Global()->CrusherLevel;

return 0;
}

int TechnoExt::GetCrushableLevel(FootClass* pThis)
{
const auto pTypeExt = TechnoTypeExt::ExtMap.Find(pThis->GetTechnoType());

const auto rank = pThis->Veterancy.GetRemainingLevel();
const auto pInfantry = specific_cast<InfantryClass*>(pThis);

if (pInfantry && pInfantry->IsDeployed())
{
switch (rank)
{
case Rank::Elite:
if (pTypeExt->Elite_DeployedCrushableLevel.isset())
return pTypeExt->Elite_DeployedCrushableLevel.Get();

case Rank::Veteran:
if (pTypeExt->Vet_DeployedCrushableLevel.isset())
return pTypeExt->Vet_DeployedCrushableLevel.Get();

default:
if (pTypeExt->DeployedCrushableLevel.isset())
return pTypeExt->DeployedCrushableLevel.Get();
}

if (pInfantry->Type->OmniCrushResistant)
return RulesExt::Global()->OmniCrushResistantLevel;

if (!pInfantry->Type->DeployedCrushable)
return RulesExt::Global()->CrushableLevel;
}
else
{
switch (rank)
{
case Rank::Elite:
if (pTypeExt->Elite_CrushableLevel.isset())
return pTypeExt->Elite_CrushableLevel.Get();

case Rank::Veteran:
if (pTypeExt->Vet_CrushableLevel.isset())
return pTypeExt->Vet_CrushableLevel.Get();

default:
if (pTypeExt->CrushableLevel.isset())
return pTypeExt->CrushableLevel.Get();
}

const auto pType = pThis->GetTechnoType();

if (pType->OmniCrushResistant)
return RulesExt::Global()->OmniCrushResistantLevel;

if (!pType->Crushable)
return RulesExt::Global()->CrushableLevel;
}

return 0;
}

/// <summary>
/// Gets whether or not techno has listed AttachEffect types active on it
/// </summary>
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 @@ -197,6 +197,8 @@ class TechnoExt
static bool ConvertToType(FootClass* pThis, TechnoTypeClass* toType);
static bool CanDeployIntoBuilding(UnitClass* pThis, bool noDeploysIntoDefaultValue = false);
static bool IsTypeImmune(TechnoClass* pThis, TechnoClass* pSource);
static int GetCrushLevel(FootClass* pThis);
static int GetCrushableLevel(FootClass* pThis);
static int GetTintColor(TechnoClass* pThis, bool invulnerability, bool airstrike, bool berserk);
static int GetCustomTintColor(TechnoClass* pThis);
static int GetCustomTintIntensity(TechnoClass* pThis);
Expand Down
20 changes: 20 additions & 0 deletions src/Ext/TechnoType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,16 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
this->DamagedSpeed.Read(exINI, pSection, "DamagedSpeed");
this->ProneSpeed.Read(exINI, pSection, "ProneSpeed");

this->CrushLevel.Read(exINI, pSection, "CrushLevel");
this->Vet_CrushLevel.Read(exINI, pSection, "CrushLevel.Veteran");
this->Elite_CrushLevel.Read(exINI, pSection, "CrushLevel.Elite");
this->CrushableLevel.Read(exINI, pSection, "CrushableLevel");
this->Vet_CrushableLevel.Read(exINI, pSection, "CrushableLevel.Veteran");
this->Elite_CrushableLevel.Read(exINI, pSection, "CrushableLevel.Elite");
this->DeployedCrushableLevel.Read(exINI, pSection, "DeployedCrushableLevel");
this->Vet_DeployedCrushableLevel.Read(exINI, pSection, "DeployedCrushableLevel.Veteran");
this->Elite_DeployedCrushableLevel.Read(exINI, pSection, "DeployedCrushableLevel.Elite");

this->SuppressKillWeapons.Read(exINI, pSection, "SuppressKillWeapons");
this->SuppressKillWeapons_Types.Read(exINI, pSection, "SuppressKillWeapons.Types");

Expand Down Expand Up @@ -965,6 +975,16 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm)
.Process(this->DamagedSpeed)
.Process(this->ProneSpeed)

.Process(this->CrushLevel)
.Process(this->Vet_CrushLevel)
.Process(this->Elite_CrushLevel)
.Process(this->CrushableLevel)
.Process(this->Vet_CrushableLevel)
.Process(this->Elite_CrushableLevel)
.Process(this->DeployedCrushableLevel)
.Process(this->Vet_DeployedCrushableLevel)
.Process(this->Elite_DeployedCrushableLevel)

.Process(this->SuppressKillWeapons)
.Process(this->SuppressKillWeapons_Types)

Expand Down
22 changes: 21 additions & 1 deletion src/Ext/TechnoType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,20 @@ class TechnoTypeExt
Valueable<int> SinkSpeed;

Nullable<double> ProneSpeed;
Nullable<double> DamagedSpeed;
Nullable<double> DamagedSpeed;

Nullable<AnimTypeClass*> Promote_VeteranAnimation;
Nullable<AnimTypeClass*> Promote_EliteAnimation;

Nullable<int> CrushLevel;
Nullable<int> Vet_CrushLevel;
Nullable<int> Elite_CrushLevel;
Nullable<int> CrushableLevel;
Nullable<int> Vet_CrushableLevel;
Nullable<int> Elite_CrushableLevel;
Nullable<int> DeployedCrushableLevel;
Nullable<int> Vet_DeployedCrushableLevel;
Nullable<int> Elite_DeployedCrushableLevel;

struct LaserTrailDataEntry
{
Expand Down Expand Up @@ -590,6 +600,16 @@ class TechnoTypeExt
, ProneSpeed { }
, DamagedSpeed { }

, CrushLevel {}
, Vet_CrushLevel {}
, Elite_CrushLevel {}
, CrushableLevel {}
, Vet_CrushableLevel {}
, Elite_CrushableLevel {}
, DeployedCrushableLevel {}
, Vet_DeployedCrushableLevel {}
, Elite_DeployedCrushableLevel {}

, SuppressKillWeapons { false }
, SuppressKillWeapons_Types { }

Expand Down
Loading