Skip to content
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3392074
Initial commit
FS-21 May 12, 2025
54a141e
More code
FS-21 May 12, 2025
2398e31
Small additions
FS-21 May 14, 2025
c69bb45
- Now AI-controlled super weapons managed by Ares dll will obey the p…
FS-21 May 15, 2025
d440d4e
Documentation and bugfixes
FS-21 May 15, 2025
6f78cd0
small fix
FS-21 May 16, 2025
fb8f5f0
doc tweaks
FS-21 May 16, 2025
4a5d9dd
Merge remote-tracking branch 'origin/develop' into feature/batte-points
FS-21 May 16, 2025
b65fb81
tweak
FS-21 May 16, 2025
bc96d8f
renamed tag
FS-21 May 17, 2025
384ee39
bugfix
FS-21 May 17, 2025
a58c346
By mistake I interted the sign of the operations
FS-21 May 17, 2025
762cbd5
Merge remote-tracking branch 'origin/develop' into feature/batte-points
FS-21 May 18, 2025
b4edaaf
Merge remote-tracking branch 'origin/develop' into feature/batte-points
FS-21 May 18, 2025
655e2ec
Code improvements
FS-21 May 19, 2025
fd57aef
Code tweaks
FS-21 May 19, 2025
5c81621
Merge branch 'develop' into feature/batte-points
FS-21 May 23, 2025
e74c242
Merge branch 'develop' into feature/batte-points
FS-21 May 29, 2025
2837e63
Merge branch 'develop' into feature/batte-points
FS-21 May 30, 2025
44df416
Merge branch 'develop' into feature/batte-points
FS-21 Jun 7, 2025
db1560f
Merge branch 'develop' into feature/batte-points
FS-21 Jun 8, 2025
f448d09
Merge branch 'develop' into feature/batte-points
FS-21 Jul 5, 2025
0cba2bd
Merge branch 'develop' into feature/batte-points
FS-21 Aug 7, 2025
2c23dca
Merge branch 'develop' into feature/batte-points
FS-21 Sep 2, 2025
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 @@ -141,6 +141,7 @@ This page lists all the individual contributions to the project by their author.
- Map Events 604 & 605 for checking if a specific Techno enters in a cell
- Warhead that can not kill
- `Pips.HideIfNoStrength` and `SelfHealing.EnabledBy` additions for shields
- Battle Points economy for super weapons
- **Starkku**:
- Misc. minor bugfixes & improvements
- AI script actions:
Expand Down
2 changes: 2 additions & 0 deletions Phobos.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<ClCompile Include="src\Blowfish\blowfish.cpp" />
<ClCompile Include="src\Blowfish\Hooks.Blowfish.cpp" />
<ClCompile Include="src\Ext\Cell\Body.cpp" />
<ClCompile Include="src\Ext\HouseType\Body.cpp" />
<ClCompile Include="src\Ext\House\Hooks.ForceEnemy.cpp" />
<ClCompile Include="src\Ext\TechnoType\Hooks.MatrixOp.cpp" />
<ClCompile Include="src\Ext\Techno\Hooks.Airstrike.cpp" />
Expand Down Expand Up @@ -199,6 +200,7 @@
<ClInclude Include="src\New\Type\Affiliated\CreateUnitTypeClass.h" />
<ClInclude Include="src\Blowfish\blowfish.h" />
<ClInclude Include="src\Ext\Cell\Body.h" />
<ClInclude Include="src\Ext\HouseType\Body.h" />
<ClInclude Include="src\New\Entity\AttachEffectClass.h" />
<ClInclude Include="src\New\Type\Affiliated\TiberiumEaterTypeClass.h" />
<ClInclude Include="src\New\Type\AttachEffectTypeClass.h" />
Expand Down
48 changes: 48 additions & 0 deletions docs/New-or-Enhanced-Logics.md
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,54 @@ In `rulesmd.ini`:
AISuperWeaponDelay= ; integer, game frames
```

### Battle Points economy for super weapons
- This system displayes a new currency to be used (optionally) in Super Weapons.
- The new currency will be modified by the kills against other players and the system is enabled.
- If set `BattlePointsCollector` in any structure then the system will be enabled if the structure is built.
- If set `BattlePoints` in houses they will have the system enabled by default.
- If set [General] -> `BattlePoints` enables/disables the system for every player in the scenario, overriding the country preferences & `BattlePointsCollector` setting.
- If set [General] -> `BattlePoints.DefaultValue` and the enemy destroyed object doesn't have a value then this generic value will be used instead.
- If set [General] -> `BattlePoints.DefaultFriendlyValue` and the friendly destroyed object doesn't have a value then this generic value will be used instead. This tag doesn't work with the own objects of the player.
- If is set `BattlePoints.CanUseStandardPoints` and the destroyed object doesn't have the `BattlePoints` value then the points are obtained from the `Points` tag of the destroyed object. If `BattlePoints.DefaultValue` is present then this will be ignored.
- If set `BattlePoints` in the destroyed object the calculation is made with this value. Self-Kills done by the own player doesn't count in this system.
- If `BattlePoints.Amount` is set with a value different from `0` then the super weapon is influenced by this system. If the value is positive then this super weapon won't be launched until the affected player gathered the required ammount.

In `uimd.ini`:
```ini
[Sidebar]
BattlePointsSidebar.Label=<none> ; CSF entry key `★ <VALUE>`, code U+2605
BattlePointsSidebar.Label.InvertPosition=false ; bool, `<VALUE> ★`, code U+2605

[ToolTips]
BattlePoints.Label=<none> ; CSF entry key, default to `★: <VALUE>`, code U+2605
```

In `rulesmd.ini`:
```ini
[General]
BattlePoints= ; bool
BattlePoints.DefaultValue= ; int
BattlePoints.DefaultFriendlyValue= ; int

[SOMESIDE] ; Side
Sidebar.BattlePoints.Offset=0,0 ; X,Y, pixels relative to default
Sidebar.BattlePoints.Color= ; integer - R,G,B
Sidebar.BattlePoints.Align=Left ; Left, Right, Center/Centre

[SOMECOUNTRY] ; HouseType
BattlePoints=false ; bool
BattlePoints.CanUseStandardPoints=false ; bool

[SOMEBUILDING] ; BuildingType
BattlePointsCollector= ; bool

[SOMETECHNO] ; TechnoType
BattlePoints= ; int

[SOMESW]
BattlePoints.Amount=0 ; int
```

### Convert TechnoType

- Warheads can now change TechnoTypes of affected units to other Types in the same category (infantry to infantry, vehicles to vehicles, aircraft to aircraft).
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ New:
- [Tiberium eater logic](New-or-Enhanced-Logics.md#tiberium-eater) (by NetsuNegi)
- [Customize the damage taken when falling from a bridge](Fixed-or-Improved-Logics.md#customize-bridge-falling-down-damage) (by FlyStar)
- Dehardcoded 255 limit of `OverlayType` (by secsome)
- Battle Points economy for super weapons (by FS-21)

Vanilla fixes:
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)
Expand Down
3 changes: 3 additions & 0 deletions src/Ext/BuildingType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ void BuildingTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
}
}

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

// Ares tag
this->SpyEffect_Custom.Read(exINI, pSection, "SpyEffect.Custom");
if (SuperWeaponTypeClass::Array.Count > 0)
Expand Down Expand Up @@ -305,6 +307,7 @@ void BuildingTypeExt::ExtData::Serialize(T& Stm)
.Process(this->BarracksExitCell)
.Process(this->Overpower_KeepOnline)
.Process(this->Overpower_ChargeWeapon)
.Process(this->BattlePointsCollector)
;
}

Expand Down
3 changes: 3 additions & 0 deletions src/Ext/BuildingType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ class BuildingTypeExt
Valueable<int> Overpower_KeepOnline;
Valueable<int> Overpower_ChargeWeapon;

Nullable<bool> BattlePointsCollector;

ExtData(BuildingTypeClass* OwnerObject) : Extension<BuildingTypeClass>(OwnerObject)
, PowersUp_Owner { AffectedHouse::Owner }
, PowersUp_Buildings {}
Expand Down Expand Up @@ -135,6 +137,7 @@ class BuildingTypeExt
, BarracksExitCell {}
, Overpower_KeepOnline { 2 }
, Overpower_ChargeWeapon { 1 }
, BattlePointsCollector {}
{ }

// Ares 0.A functions
Expand Down
51 changes: 51 additions & 0 deletions src/Ext/House/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <Ext/SWType/Body.h>
#include <Ext/TechnoType/Body.h>
#include <Ext/Techno/Body.h>
#include <Ext/HouseType/Body.h>

#include <ScenarioClass.h>

Expand Down Expand Up @@ -653,6 +654,7 @@ void HouseExt::ExtData::Serialize(T& Stm)
.Process(this->SuspendedEMPulseSWs)
.Process(this->SuperExts)
.Process(this->ForceEnemyIndex)
.Process(this->BattlePoints)
;
}

Expand Down Expand Up @@ -1084,3 +1086,52 @@ bool HouseExt::ReachedBuildLimit(const HouseClass* pHouse, const TechnoTypeClass
return false;
}
#pragma endregion

void HouseExt::ExtData::UpdateBattlePoints(int modifier)
{
this->BattlePoints += modifier;
this->BattlePoints = this->BattlePoints < 0 ? 0 : this->BattlePoints;
}

bool HouseExt::ExtData::AreBattlePointsEnabled()
{
const auto pThis = this->OwnerObject();
const auto pOwnerTypeExt = HouseTypeExt::ExtMap.Find(pThis->Type);
bool enabledBattlePoints = false;

for (const auto pBuilding : pThis->Buildings)
{
const auto pBuildingTypeExt = BuildingTypeExt::ExtMap.Find(pBuilding->Type);
if (pBuildingTypeExt->BattlePointsCollector.isset() && pBuildingTypeExt->BattlePointsCollector.Get())
{
enabledBattlePoints = true;
break;
}
}

enabledBattlePoints |= pOwnerTypeExt->BattlePoints;

if (RulesExt::Global()->BattlePoints.isset())
enabledBattlePoints = RulesExt::Global()->BattlePoints.Get();

return enabledBattlePoints;
}

int HouseExt::ExtData::CalculateBattlePoints(TechnoClass* pTechno)
{
if (!pTechno)
return 0;

const auto pThis = this->OwnerObject();
const auto pThisTypeExt = HouseTypeExt::ExtMap.Find(pThis->Type);
const auto pTechnoTypeExt = TechnoTypeExt::ExtMap.Find(pTechno->GetTechnoType());

int defaultValue = RulesExt::Global()->BattlePoints_DefaultValue.isset() ? RulesExt::Global()->BattlePoints_DefaultValue.Get() : 0;
int defaultFriendlyValue = RulesExt::Global()->BattlePoints_DefaultFriendlyValue.isset() ? RulesExt::Global()->BattlePoints_DefaultFriendlyValue.Get() : 0;

int points = pThis->IsAlliedWith(pTechno)? defaultFriendlyValue : defaultValue;
points = pTechnoTypeExt->BattlePoints.isset() ? pTechnoTypeExt->BattlePoints.Get() : points;
points = points == 0 && pThisTypeExt->BattlePoints_CanUseStandardPoints ? pTechno->GetTechnoType()->Points : points;

return points;
}
7 changes: 7 additions & 0 deletions src/Ext/House/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class HouseExt

int ForceEnemyIndex;

int BattlePoints;

ExtData(HouseClass* OwnerObject) : Extension<HouseClass>(OwnerObject)
, PowerPlantEnhancers {}
, OwnedLimboDeliveredBuildings {}
Expand Down Expand Up @@ -94,6 +96,7 @@ class HouseExt
, SuspendedEMPulseSWs {}
, SuperExts(SuperWeaponTypeClass::Array.Count)
, ForceEnemyIndex(-1)
, BattlePoints(0)
{ }

bool OwnsLimboDeliveredBuilding(BuildingClass* pBuilding);
Expand All @@ -115,6 +118,10 @@ class HouseExt

void UpdateVehicleProduction();

void UpdateBattlePoints(int modifier);
bool AreBattlePointsEnabled();
int CalculateBattlePoints(TechnoClass* pTechno);

virtual void LoadFromStream(PhobosStreamReader& Stm) override;
virtual void SaveToStream(PhobosStreamWriter& Stm) override;

Expand Down
141 changes: 141 additions & 0 deletions src/Ext/HouseType/Body.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
#include "Body.h"

#include <Utilities/GeneralUtils.h>

static constexpr DWORD Canary = 0x1111111A;
HouseTypeExt::ExtContainer HouseTypeExt::ExtMap;

void HouseTypeExt::ExtData::Initialize()
{
}

// =============================
// load / save

void HouseTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
{
auto pThis = this->OwnerObject();
const char* pSection = pThis->ID;

if (!pINI->GetSection(pSection))
return;

INI_EX exINI(pINI);

this->BattlePoints.Read(exINI, pSection, "BattlePoints");
this->BattlePoints_CanUseStandardPoints.Read(exINI, pSection, "BattlePoints.CanUseStandardPoints");
}

void HouseTypeExt::ExtData::CompleteInitialization()
{
auto const pThis = this->OwnerObject();
UNREFERENCED_PARAMETER(pThis);
}

template <typename T>
void HouseTypeExt::ExtData::Serialize(T& Stm)
{
Stm
.Process(this->BattlePoints)
.Process(this->BattlePoints_CanUseStandardPoints)
;
}

void HouseTypeExt::ExtData::LoadFromStream(PhobosStreamReader& Stm)
{
Extension<HouseTypeClass>::LoadFromStream(Stm);
this->Serialize(Stm);
}

void HouseTypeExt::ExtData::SaveToStream(PhobosStreamWriter& Stm)
{
Extension<HouseTypeClass>::SaveToStream(Stm);
this->Serialize(Stm);
}

bool HouseTypeExt::ExtContainer::Load(HouseTypeClass* pThis, IStream* pStm)
{
HouseTypeExt::ExtData* pData = this->LoadKey(pThis, pStm);
return pData != nullptr;
};

bool HouseTypeExt::LoadGlobals(PhobosStreamReader& Stm)
{
return Stm.Success();
}

bool HouseTypeExt::SaveGlobals(PhobosStreamWriter& Stm)
{
return Stm.Success();
}

// =============================
// container

HouseTypeExt::ExtContainer::ExtContainer() : Container("HouseTypeClass") { }

HouseTypeExt::ExtContainer::~ExtContainer() = default;

// =============================
// container hooks

DEFINE_HOOK(0x511635, HouseTypeClass_CTOR_1, 0x5)
{
GET(HouseTypeClass*, pItem, EAX);

HouseTypeExt::ExtMap.Allocate(pItem);

return 0;
}

DEFINE_HOOK(0x511643, HouseTypeClass_CTOR_2, 0x5)
{
GET(HouseTypeClass*, pItem, EAX);

HouseTypeExt::ExtMap.Allocate(pItem);

return 0;
}

DEFINE_HOOK(0x5127CF, HouseTypeClass_DTOR, 0x6)
{
GET(HouseTypeClass*, pItem, ESI);

HouseTypeExt::ExtMap.Remove(pItem);

return 0;
}

DEFINE_HOOK_AGAIN(0x512480, HouseTypeClass_SaveLoad_Prefix, 0x5)
DEFINE_HOOK(0x512290, HouseTypeClass_SaveLoad_Prefix, 0x5)
{
GET_STACK(HouseTypeClass*, pItem, 0x4);
GET_STACK(IStream*, pStm, 0x8);

HouseTypeExt::ExtMap.PrepareStream(pItem, pStm);

return 0;
}

DEFINE_HOOK(0x51246D, HouseTypeClass_Load_Suffix, 0x5)
{
HouseTypeExt::ExtMap.LoadStatic();
return 0;
}

DEFINE_HOOK(0x51255C, HouseTypeClass_Save_Suffix, 0x5)
{
HouseTypeExt::ExtMap.SaveStatic();
return 0;
}

DEFINE_HOOK_AGAIN(0x51215A, HouseTypeClass_LoadFromINI, 0x5)
DEFINE_HOOK(0x51214F, HouseTypeClass_LoadFromINI, 0x5)
{
GET(HouseTypeClass*, pItem, EBX);
GET_BASE(CCINIClass*, pINI, 0x8);

HouseTypeExt::ExtMap.LoadFromINI(pItem, pINI);

return 0;
}
Loading