Skip to content

Commit 38f5ef2

Browse files
OtamaaTaranDahlCoroniaNetsuNegiCrimRecya
authored andcommitted
Various Building properties Deharcoded (#550)
### Customizable garrison and bunker properties - You can now customize damage or ROF multipliers of a garrison or tank bunker building. - You can now customize enter or exit sound of a tank bunker building. In `rulesmd.ini`: ```ini [SOMEBUILDING] ; BuildingType OccupyDamageMultiplier= ; floating point value, default to [CombatDamage] -> OccupyDamageMultiplier OccupyROFMultiplier= ; floating point value, default to [CombatDamage] -> OccupyROFMultiplier BunkerDamageMultiplier= ; floating point value, default to [CombatDamage] -> BunkerDamageMultiplier BunkerROFMultMultiplier= ; floating point value, default to [CombatDamage] -> BunkerROFMultMultiplier BunkerWallsUpSound= ; Sound entry, default to [AudioVisual] -> BunkerWallsUpSound BunkerWallsDownSound= ; Sound entry, default to [AudioVisual] -> BunkerWallsDownSound ``` ### Disable DamageSound - Now you can disable `DamageSound` of a building. In `rulesmd.ini`: ```ini [SOMEBUILDING] ; BuildingType DisableDamageSound=false ; boolean ``` ### Power plant damage factor - It is possible to customize the power decrement of a power plant when it's damaged. The actual power output for this plant will be: `Power` minuses the product of original power decrement and `Powerplant.DamageFactor`. Can't reduce power output lower than 0. - Specifically, if the factor is set to 0.0, power output won't be decreased by losing health for this power plant. In `rulesmd.ini`: ```ini [SOMEBUILDING] ; BuildingType PowerPlant.DamageFactor=1.0 ; floating point value ``` --------- Co-authored-by: TaranDahl <[email protected]> Co-authored-by: 航味麻酱 <[email protected]> Co-authored-by: Coronia <[email protected]> Co-authored-by: NetsuNegi39 <[email protected]> Co-authored-by: Netsu_Negi <[email protected]> Co-authored-by: CrimRecya <[email protected]>
1 parent 69f1084 commit 38f5ef2

File tree

6 files changed

+290
-31
lines changed

6 files changed

+290
-31
lines changed

CREDITS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ This page lists all the individual contributions to the project by their author.
121121
- Help with custom locomotors
122122
- Extension class optimization
123123
- Overload characteristic dehardcoded
124+
- Customizable garrison and bunker properties
125+
- Disable DamageSound for buildings
126+
- Power plant damage factor
124127
- **FS-21**:
125128
- Dump Object Info enhancements
126129
- `Powered.KillSpawns`
@@ -490,6 +493,7 @@ This page lists all the individual contributions to the project by their author.
490493
- Passenger-based insignias
491494
- Use `InsigniaType` to set the properties of insignia in a batch
492495
- Allowed player's self-healing effects to be benefited by allied or `PlayerControl=true` houses
496+
- Power plant damage factor
493497
- **NaotoYuuki** - Vertical & meteor trajectory projectile prototypes
494498
- **handama** - AI script action to `16005 Jump Back To Previous Script`
495499
- **TaranDahl (航味麻酱)**:

docs/Fixed-or-Improved-Logics.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,22 @@ In `rulesmd.ini`:
477477
BarracksExitCell= ; X,Y - cell offset
478478
```
479479

480+
### Customizable garrison and bunker properties
481+
482+
- You can now customize damage or ROF multipliers of a garrison or tank bunker building.
483+
- You can now customize enter or exit sound of a tank bunker building.
484+
485+
In `rulesmd.ini`:
486+
```ini
487+
[SOMEBUILDING] ; BuildingType
488+
OccupyDamageMultiplier= ; floating point value, default to [CombatDamage] -> OccupyDamageMultiplier
489+
OccupyROFMultiplier= ; floating point value, default to [CombatDamage] -> OccupyROFMultiplier
490+
BunkerDamageMultiplier= ; floating point value, default to [CombatDamage] -> BunkerDamageMultiplier
491+
BunkerROFMultMultiplier= ; floating point value, default to [CombatDamage] -> BunkerROFMultMultiplier
492+
BunkerWallsUpSound= ; Sound entry, default to [AudioVisual] -> BunkerWallsUpSound
493+
BunkerWallsDownSound= ; Sound entry, default to [AudioVisual] -> BunkerWallsDownSound
494+
```
495+
480496
### Customizable selling buildup sequence length for buildings that can undeploy
481497

482498
- By default buildings with `UndeploysInto` will only play 23 frames of their buildup sequence (in reverse starting from last frame) when being sold as opposed to being undeployed. This can now be customized via `SellBuildupLength`.
@@ -534,6 +550,16 @@ Overpower.ChargeWeapon=1 ; integer, negative values mean that weapons can never
534550
Ares' [Battery Super Weapon](https://ares-developers.github.io/Ares-docs/new/superweapons/types/battery.html) won't be affected by this.
535551
```
536552

553+
### Disable DamageSound
554+
555+
- Now you can disable `DamageSound` of a building.
556+
557+
In `rulesmd.ini`:
558+
```ini
559+
[SOMEBUILDING] ; BuildingType
560+
DisableDamageSound=false ; boolean
561+
```
562+
537563
### Exclude Factory from providing multiple factory bonus
538564

539565
- It is now possible to exclude a building with `Factory` from counting towards `MultipleFactory` bonus.
@@ -544,6 +570,17 @@ In `rulesmd.ini`:
544570
ExcludeFromMultipleFactoryBonus=false ; boolean
545571
```
546572

573+
### Power plant damage factor
574+
575+
- It is possible to customize the power decrement of a power plant when it's damaged. The actual power output for this plant will be: `Power` minuses the product of original power decrement and `Powerplant.DamageFactor`. Can't reduce power output lower than 0.
576+
- Specifically, if the factor is set to 0.0, power output won't be decreased by losing health for this power plant.
577+
578+
In `rulesmd.ini`:
579+
```ini
580+
[SOMEBUILDING] ; BuildingType
581+
PowerPlant.DamageFactor=1.0 ; floating point value
582+
```
583+
547584
### Skip anim delay for burst fire
548585

549586
- In Red Alert 1, the tesla coil will attack multiple times after charging animation. This is not possible in Red Alert 2, where the building must play the charge animation every time it fires.

docs/Whats-New.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,9 @@ New:
383383
- Allowed player's self-healing effects to be benefited by allied or `PlayerControl=true` houses (by Ollerus)
384384
- Exclusive SuperWeapon Sidebar (by NetsuNegi & CrimRecya)
385385
- Customize the scatter caused by aircraft attack mission (by TaranDahl)
386+
- [Customizable garrison and bunker properties](Fixed-or-Improved-Logics.md#customizable-garrison-and-bunker-properties) (by Otamaa)
387+
- [Disable DamageSound for buildings](Fixed-or-Improved-Logics.md#disable-damagesound) (by Otamaa)
388+
- [Power plant damage factor](New-or-Enhanced-Logics.md#power-plant-damage-factor) (by Otamaa and Ollerus)
386389
387390
Vanilla fixes:
388391
- Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya)

src/Ext/BuildingType/Body.cpp

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ int BuildingTypeExt::ExtData::GetSuperWeaponCount() const
1515

1616
int BuildingTypeExt::ExtData::GetSuperWeaponIndex(const int index, HouseClass* pHouse) const
1717
{
18-
auto idxSW = this->GetSuperWeaponIndex(index);
18+
const int idxSW = this->GetSuperWeaponIndex(index);
1919

20-
if (auto pSuper = pHouse->Supers.GetItemOrDefault(idxSW))
20+
if (const auto pSuper = pHouse->Supers.GetItemOrDefault(idxSW))
2121
{
22-
auto pExt = SWTypeExt::ExtMap.Find(pSuper->Type);
22+
const auto pExt = SWTypeExt::ExtMap.Find(pSuper->Type);
2323

2424
if (!pExt->IsAvailable(pHouse))
2525
return -1;
@@ -50,7 +50,8 @@ int BuildingTypeExt::GetEnhancedPower(BuildingClass* pBuilding, HouseClass* pHou
5050

5151
for (const auto& [bTypeIdx, nCount] : pHouseExt->PowerPlantEnhancers)
5252
{
53-
auto bTypeExt = BuildingTypeExt::ExtMap.Find(BuildingTypeClass::Array[bTypeIdx]);
53+
auto const bTypeExt = BuildingTypeExt::ExtMap.Find(BuildingTypeClass::Array[bTypeIdx]);
54+
5455
if (bTypeExt->PowerPlantEnhancer_Buildings.Contains(pBuilding->Type))
5556
{
5657
fFactor *= std::powf(bTypeExt->PowerPlantEnhancer_Factor, static_cast<float>(nCount));
@@ -61,6 +62,17 @@ int BuildingTypeExt::GetEnhancedPower(BuildingClass* pBuilding, HouseClass* pHou
6162
return static_cast<int>(std::round(pBuilding->GetPowerOutput() * fFactor)) + nAmount;
6263
}
6364

65+
void BuildingTypeExt::PlayBunkerSound(BuildingClass const* pThis, bool buildUp)
66+
{
67+
auto const pTypeExt = BuildingTypeExt::ExtMap.Find(pThis->Type);
68+
auto const nSound = buildUp
69+
? pTypeExt->BunkerWallsUpSound.Get(RulesClass::Instance->BunkerWallsUpSound)
70+
: pTypeExt->BunkerWallsDownSound.Get(RulesClass::Instance->BunkerWallsDownSound);
71+
72+
if (nSound != -1)
73+
VocClass::PlayAt(nSound, pThis->Location);
74+
}
75+
6476
int BuildingTypeExt::CountOwnedNowWithDeployOrUpgrade(BuildingTypeClass* pType, HouseClass* pHouse)
6577
{
6678
const auto upgrades = BuildingTypeExt::GetUpgradesAmount(pType, pHouse);
@@ -78,7 +90,7 @@ int BuildingTypeExt::GetUpgradesAmount(BuildingTypeClass* pBuilding, HouseClass*
7890
{
7991
int result = 0;
8092
bool isUpgrade = false;
81-
auto pPowersUp = pBuilding->PowersUpBuilding;
93+
auto const pPowersUp = pBuilding->PowersUpBuilding;
8294

8395
auto checkUpgrade = [pHouse, pBuilding, &result, &isUpgrade](BuildingTypeClass* pTPowersUp)
8496
{
@@ -102,7 +114,7 @@ int BuildingTypeExt::GetUpgradesAmount(BuildingTypeClass* pBuilding, HouseClass*
102114
checkUpgrade(pTPowersUp);
103115
}
104116

105-
if (auto pBuildingExt = BuildingTypeExt::ExtMap.Find(pBuilding))
117+
if (auto const pBuildingExt = BuildingTypeExt::ExtMap.Find(pBuilding))
106118
{
107119
for (auto pTPowersUp : pBuildingExt->PowersUp_Buildings)
108120
checkUpgrade(pTPowersUp);
@@ -132,6 +144,7 @@ void BuildingTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
132144

133145
this->PowersUp_Owner.Read(exINI, pSection, "PowersUp.Owner");
134146
this->PowersUp_Buildings.Read(exINI, pSection, "PowersUp.Buildings");
147+
this->PowerPlant_DamageFactor.Read(exINI, pSection, "PowerPlant.DamageFactor");
135148
this->PowerPlantEnhancer_Buildings.Read(exINI, pSection, "PowerPlantEnhancer.PowerPlants");
136149
this->PowerPlantEnhancer_Amount.Read(exINI, pSection, "PowerPlantEnhancer.Amount");
137150
this->PowerPlantEnhancer_Factor.Read(exINI, pSection, "PowerPlantEnhancer.Factor");
@@ -179,6 +192,15 @@ void BuildingTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
179192
this->Overpower_KeepOnline.Read(exINI, pSection, "Overpower.KeepOnline");
180193
this->Overpower_ChargeWeapon.Read(exINI, pSection, "Overpower.ChargeWeapon");
181194

195+
this->DisableDamageSound.Read(exINI, pSection, "DisableDamageSound");
196+
197+
this->BuildingOccupyDamageMult.Read(exINI, pSection, "OccupyDamageMultiplier");
198+
this->BuildingOccupyROFMult.Read(exINI, pSection, "OccupyROFMultiplier");
199+
this->BuildingBunkerDamageMult.Read(exINI, pSection, "BunkerDamageMultiplier");
200+
this->BuildingBunkerROFMult.Read(exINI, pSection, "BunkerROFMultMultiplier");
201+
this->BunkerWallsUpSound.Read(exINI, pSection, "BunkerWallsUpSound");
202+
this->BunkerWallsDownSound.Read(exINI, pSection, "BunkerWallsDownSound");
203+
182204
if (pThis->NumberOfDocks > 0)
183205
{
184206
this->AircraftDockingDirs.clear();
@@ -256,6 +278,7 @@ void BuildingTypeExt::ExtData::Serialize(T& Stm)
256278
Stm
257279
.Process(this->PowersUp_Owner)
258280
.Process(this->PowersUp_Buildings)
281+
.Process(this->PowerPlant_DamageFactor)
259282
.Process(this->PowerPlantEnhancer_Buildings)
260283
.Process(this->PowerPlantEnhancer_Amount)
261284
.Process(this->PowerPlantEnhancer_Factor)
@@ -305,6 +328,11 @@ void BuildingTypeExt::ExtData::Serialize(T& Stm)
305328
.Process(this->BarracksExitCell)
306329
.Process(this->Overpower_KeepOnline)
307330
.Process(this->Overpower_ChargeWeapon)
331+
.Process(this->DisableDamageSound)
332+
.Process(this->BuildingOccupyDamageMult)
333+
.Process(this->BuildingOccupyROFMult)
334+
.Process(this->BuildingBunkerDamageMult)
335+
.Process(this->BuildingBunkerROFMult)
308336
;
309337
}
310338

src/Ext/BuildingType/Body.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class BuildingTypeExt
2222
ValueableVector<BuildingTypeClass*> PowersUp_Buildings;
2323
ValueableIdxVector<SuperWeaponTypeClass> SuperWeapons;
2424

25+
Valueable<double> PowerPlant_DamageFactor;
2526
ValueableVector<BuildingTypeClass*> PowerPlantEnhancer_Buildings;
2627
Valueable<int> PowerPlantEnhancer_Amount;
2728
Nullable<float> PowerPlantEnhancer_Factor;
@@ -84,9 +85,18 @@ class BuildingTypeExt
8485
Valueable<int> Overpower_KeepOnline;
8586
Valueable<int> Overpower_ChargeWeapon;
8687

88+
Valueable<bool> DisableDamageSound;
89+
Nullable<float> BuildingOccupyDamageMult;
90+
Nullable<float> BuildingOccupyROFMult;
91+
Nullable<float> BuildingBunkerDamageMult;
92+
Nullable<float> BuildingBunkerROFMult;
93+
NullableIdx<VocClass> BunkerWallsUpSound;
94+
NullableIdx<VocClass> BunkerWallsDownSound;
95+
8796
ExtData(BuildingTypeClass* OwnerObject) : Extension<BuildingTypeClass>(OwnerObject)
8897
, PowersUp_Owner { AffectedHouse::Owner }
8998
, PowersUp_Buildings {}
99+
, PowerPlant_DamageFactor { 1.0 }
90100
, PowerPlantEnhancer_Buildings {}
91101
, PowerPlantEnhancer_Amount { 0 }
92102
, PowerPlantEnhancer_Factor { 1.0 }
@@ -135,6 +145,13 @@ class BuildingTypeExt
135145
, BarracksExitCell {}
136146
, Overpower_KeepOnline { 2 }
137147
, Overpower_ChargeWeapon { 1 }
148+
, DisableDamageSound { false }
149+
, BuildingOccupyDamageMult {}
150+
, BuildingOccupyROFMult {}
151+
, BuildingBunkerDamageMult {}
152+
, BuildingBunkerROFMult {}
153+
, BunkerWallsUpSound {}
154+
, BunkerWallsDownSound {}
138155
{ }
139156

140157
// Ares 0.A functions
@@ -171,6 +188,8 @@ class BuildingTypeExt
171188
static bool LoadGlobals(PhobosStreamReader& Stm);
172189
static bool SaveGlobals(PhobosStreamWriter& Stm);
173190

191+
static void PlayBunkerSound(BuildingClass const* pThis, bool buildUp = false);
192+
174193
static int GetEnhancedPower(BuildingClass* pBuilding, HouseClass* pHouse);
175194
static bool CanUpgrade(BuildingClass* pBuilding, BuildingTypeClass* pUpgradeType, HouseClass* pUpgradeOwner);
176195
static int CountOwnedNowWithDeployOrUpgrade(BuildingTypeClass* pBuilding, HouseClass* pHouse);

0 commit comments

Comments
 (0)