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 all 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 @@ -383,6 +383,7 @@ This page lists all the individual contributions to the project by their author.
- Separate the AirstrikeClass pointer between the attacker/aircraft and the target to avoid erroneous overwriting issues
- Fix the bug that buildings will always be tinted as airstrike owner
- Fix the bug that 'AllowAirstrike=no' cannot completely prevent air strikes from being launched against it
- 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 @@ -584,6 +584,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 @@ -367,6 +367,7 @@ New:
- Customize airstrike targets (by NetsuNegi)
- Aggressive attack move mission (by CrimRecya)
- Amphibious access vehicle (by CrimRecya)
- Crush level system (by NetsuNegi)

Vanilla fixes:
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)
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 @@ -262,6 +262,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 @@ -482,6 +487,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 @@ -665,3 +675,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 @@ -217,6 +217,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 }
, HarvesterDumpAmount { 0.0f }
Expand Down Expand Up @@ -379,6 +385,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
87 changes: 87 additions & 0 deletions src/Ext/Techno/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,93 @@ bool TechnoExt::IsTypeImmune(TechnoClass* pThis, TechnoClass* pSource)
return false;
}

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

switch (pThis->Veterancy.GetRemainingLevel())
{
case Rank::Elite:
if (pTypeExt->CrushLevel.Elite >= 0)
return pTypeExt->CrushLevel.Elite;

case Rank::Veteran:
if (pTypeExt->CrushLevel.Veteran >= 0)
return pTypeExt->CrushLevel.Veteran;

default:
if (pTypeExt->CrushLevel.Rookie >= 0)
return pTypeExt->CrushLevel.Rookie;
}

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 pType = pThis->GetTechnoType();
const auto pTypeExt = TechnoTypeExt::ExtMap.Find(pType);

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

if (pInfantry && pInfantry->Uncrushable)
{
switch (rank)
{
case Rank::Elite:
if (pTypeExt->DeployedCrushableLevel.Elite >= 0)
return pTypeExt->DeployedCrushableLevel.Elite;

case Rank::Veteran:
if (pTypeExt->DeployedCrushableLevel.Veteran >= 0)
return pTypeExt->DeployedCrushableLevel.Veteran;

default:
if (pTypeExt->DeployedCrushableLevel.Rookie >= 0)
return pTypeExt->DeployedCrushableLevel.Rookie;
}

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

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

case Rank::Veteran:
if (pTypeExt->CrushableLevel.Veteran >= 0)
return pTypeExt->CrushableLevel.Veteran;

default:
if (pTypeExt->CrushableLevel.Rookie >= 0)
return pTypeExt->CrushableLevel.Rookie;
}

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 @@ -200,6 +200,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
8 changes: 8 additions & 0 deletions src/Ext/TechnoType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,10 @@ 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.%s");
this->CrushableLevel.Read(exINI, pSection, "CrushableLevel.%s");
this->DeployedCrushableLevel.Read(exINI, pSection, "DeployedCrushableLevel.%s");

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

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

.Process(this->CrushLevel)
.Process(this->CrushableLevel)
.Process(this->DeployedCrushableLevel)

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

Expand Down
8 changes: 8 additions & 0 deletions src/Ext/TechnoType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,10 @@ class TechnoTypeExt

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

Promotable<int> CrushLevel;
Promotable<int> CrushableLevel;
Promotable<int> DeployedCrushableLevel;

Nullable<AffectedHouse> RadarInvisibleToHouse;

Expand Down Expand Up @@ -627,6 +631,10 @@ class TechnoTypeExt
, ProneSpeed { }
, DamagedSpeed { }

, CrushLevel { -1 }
, CrushableLevel { -1 }
, DeployedCrushableLevel { -1 }

, SuppressKillWeapons { false }
, SuppressKillWeapons_Types { }

Expand Down
Loading