Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
5 changes: 5 additions & 0 deletions src/Ext/Rules/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,9 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)

this->AdjacentWallDamage.Read(exINI, GameStrings::CombatDamage, "AdjacentWallDamage");

this->AutoTarget_NoThreatBuildings.Read(exINI, GameStrings::General, "AutoTarget.NoThreatBuildings");
this->AutoTargetAI_NoThreatBuildings.Read(exINI, GameStrings::General, "AutoTargetAI.NoThreatBuildings");

// Section AITargetTypes
int itemsCount = pINI->GetKeyCount("AITargetTypes");
for (int i = 0; i < itemsCount; ++i)
Expand Down Expand Up @@ -589,6 +592,8 @@ void RulesExt::ExtData::Serialize(T& Stm)
.Process(this->Parasite_GrappleAnim)
.Process(this->InfantryAutoDeploy)
.Process(this->AdjacentWallDamage)
.Process(this->AutoTarget_NoThreatBuildings)
.Process(this->AutoTargetAI_NoThreatBuildings)
;
}

Expand Down
8 changes: 7 additions & 1 deletion src/Ext/Rules/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,10 @@ class RulesExt
Valueable<bool> InfantryAutoDeploy;

Valueable<int> AdjacentWallDamage;


Valueable<bool> AutoTarget_NoThreatBuildings;
Valueable<bool> AutoTargetAI_NoThreatBuildings;

ExtData(RulesClass* OwnerObject) : Extension<RulesClass>(OwnerObject)
, Storage_TiberiumIndex { -1 }
, HarvesterDumpAmount { 0.0f }
Expand Down Expand Up @@ -480,6 +483,9 @@ class RulesExt
, Parasite_GrappleAnim {}
, InfantryAutoDeploy { false }
, AdjacentWallDamage { 200 }

, AutoTarget_NoThreatBuildings { false }
, AutoTargetAI_NoThreatBuildings { true }
{ }

virtual ~ExtData() = default;
Expand Down
34 changes: 34 additions & 0 deletions src/Ext/Techno/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1459,3 +1459,37 @@ DEFINE_HOOK(0x6F7E1E, TechnoClass_CanAutoTargetObject_AU, 0x6)
}

#pragma endregion

#pragma region AutoTargetExtension

namespace CanAutoTargetTemp
{
TechnoTypeExt::ExtData* TypeExtData;
WeaponTypeExt::ExtData* WeaponExt;
}

DEFINE_HOOK(0x6F7E30, TechnoClass_CanAutoTarget_SetContent, 0x6)
{
GET(TechnoClass*, pThis, EDI);
GET(WeaponTypeClass*, pWeapon, EBP);

CanAutoTargetTemp::TypeExtData = TechnoExt::ExtMap.Find(pThis)->TypeExtData;
CanAutoTargetTemp::WeaponExt = WeaponTypeExt::ExtMap.Find(pWeapon);

return 0;
}

DEFINE_HOOK(0x6F85AB, TechnoClass_CanAutoTarget_AttackFriendlies_Building, 0x6)
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now they have merged.

{
enum { CanAttack = 0x6F8604, Continue = 0x6F85BA };

GET(TechnoClass*, pThis, EDI);

const bool canAttack = CanAutoTargetTemp::WeaponExt->AttackNoThreatBuildings.Get(
CanAutoTargetTemp::TypeExtData->AutoTarget_NoThreatBuildings.Get(pThis->Owner->IsControlledByHuman()
? RulesExt::Global()->AutoTarget_NoThreatBuildings : RulesExt::Global()->AutoTargetAI_NoThreatBuildings));

return canAttack ? CanAttack : Continue;
}

#pragma endregion
4 changes: 4 additions & 0 deletions src/Ext/TechnoType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1198,6 +1198,8 @@ void TechnoTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
// VoiceIFVRepair from Ares 0.2
this->VoiceIFVRepair.Read(exINI, pSection, "VoiceIFVRepair");
this->ParseVoiceWeaponAttacks(exINI, pSection, this->VoiceWeaponAttacks, this->VoiceEliteWeaponAttacks);

this->AutoTarget_NoThreatBuildings.Read(exINI, pSection, "AutoTarget.NoThreatBuildings");
}

void TechnoTypeExt::ExtData::LoadFromINIByWhatAmI(INI_EX& exINI, const char* pSection, INI_EX& exArtINI, const char* pArtSection)
Expand Down Expand Up @@ -1609,6 +1611,8 @@ void TechnoTypeExt::ExtData::Serialize(T& Stm)
.Process(this->InfantryAutoDeploy)

.Process(this->TurretResponse)

.Process(this->AutoTarget_NoThreatBuildings)
;
}
void TechnoTypeExt::ExtData::LoadFromStream(PhobosStreamReader& Stm)
Expand Down
4 changes: 4 additions & 0 deletions src/Ext/TechnoType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,8 @@ class TechnoTypeExt

Nullable<bool> TurretResponse;

Nullable<bool> AutoTarget_NoThreatBuildings;

ExtData(TechnoTypeClass* OwnerObject) : Extension<TechnoTypeClass>(OwnerObject)
, HealthBar_Hide { false }
, HealthBar_HidePips { false }
Expand Down Expand Up @@ -812,6 +814,8 @@ class TechnoTypeExt
, InfantryAutoDeploy {}

, TurretResponse {}

, AutoTarget_NoThreatBuildings {}
{ }

virtual ~ExtData() = default;
Expand Down
2 changes: 2 additions & 0 deletions src/Ext/WeaponType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ void WeaponTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
this->DelayedFire_OnlyOnInitialBurst.Read(exINI, pSection, "DelayedFire.OnlyOnInitialBurst");
this->DelayedFire_AnimOffset.Read(exINI, pSection, "DelayedFire.AnimOffset");
this->DelayedFire_AnimOnTurret.Read(exINI, pSection, "DelayedFire.AnimOnTurret");
this->AttackNoThreatBuildings.Read(exINI, pSection, "AttackNoThreatBuildings");

// handle SkipWeaponPicking
if (this->CanTarget != AffectedTarget::All || this->CanTargetHouses != AffectedHouse::All
Expand Down Expand Up @@ -237,6 +238,7 @@ void WeaponTypeExt::ExtData::Serialize(T& Stm)
.Process(this->DelayedFire_OnlyOnInitialBurst)
.Process(this->DelayedFire_AnimOffset)
.Process(this->DelayedFire_AnimOnTurret)
.Process(this->AttackNoThreatBuildings)
;
};

Expand Down
2 changes: 2 additions & 0 deletions src/Ext/WeaponType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class WeaponTypeExt
Valueable<bool> DelayedFire_OnlyOnInitialBurst;
Nullable<CoordStruct> DelayedFire_AnimOffset;
Valueable<bool> DelayedFire_AnimOnTurret;
Nullable<bool> AttackNoThreatBuildings;

bool SkipWeaponPicking;

Expand Down Expand Up @@ -164,6 +165,7 @@ class WeaponTypeExt
, DelayedFire_OnlyOnInitialBurst { false }
, DelayedFire_AnimOffset {}
, DelayedFire_AnimOnTurret { true }
, AttackNoThreatBuildings {}
{ }

int GetBurstDelay(int burstIndex) const;
Expand Down
Loading