Skip to content

New EVA voice after deploying a building #1682

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 10 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 @@ -144,6 +144,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
- New EVA voice after deploying a building
- **Starkku**:
- Misc. minor bugfixes & improvements
- AI script actions:
Expand Down
2 changes: 1 addition & 1 deletion YRpp
Submodule YRpp updated 2 files
+1 −0 EBolt.h
+1 −1 HouseClass.h
18 changes: 18 additions & 0 deletions docs/User-Interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,24 @@ IngameScore.WinTheme= ; Soundtrack theme ID
IngameScore.LoseTheme= ; Soundtrack theme ID
```

### New EVA voice after deploying a building

- You can now replace the current EVA voice when a specific structure is placed/deployed.
- `NewEVAVoice.Index` is the index of the new EVA voice. Ares is hightly recomended because these indexes are readed the new section `[EVATypes]` at `evamd.ini` created by Ares. Look at Ares documentation for more information.
- In case of multiple structures with different EVA voices `NewEVAVoice.Priority` establish a priority queue, being the highest value the selected one.
- `NewEVAVoice.RecheckOnDeath` re-checks a new EVA voice after the destruction/undeployment of of of these buildings.
- `NewEVAVoice.InitialMessage` plays an EVA message to the player when a different EVA has been selected.

In `rulesmd.ini`:
```ini
[SOMEBUILDING] ; BuildingType
NewEVAVoice= ; boolean
NewEVAVoice.Index=0 ; integer
Comment on lines +41 to +42
Copy link
Contributor

Choose a reason for hiding this comment

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

Get rid of the bool and use Nullable or negative default value index.

NewEVAVoice.Priority=1 ; integer
NewEVAVoice.RecheckOnDeath=false ; boolean
NewEVAVoice.InitialMessage= ; EVA entry
```

## Battle screen UI/UX

### Digital display
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ New:
- Customize whether `Crater=yes` animation would destroy tiberium (by TaranDahl)
- Weapon target filtering by health percentage (by NetsuNegi)
- Turretless vehicles with `Voxel=no` support use `FireUp` like infantry (by FlyStar)
- New EVA voice after deploying a building (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
87 changes: 87 additions & 0 deletions src/Ext/Building/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
#include <BitFont.h>

#include <Utilities/EnumFunctions.h>
#include <Ext/Side/Body.h>
#include <Ext/Scenario/Body.h>
#include <Ext/House/Body.h>

BuildingExt::ExtContainer BuildingExt::ExtMap;

Expand Down Expand Up @@ -446,6 +449,90 @@ const std::vector<CellStruct> BuildingExt::GetFoundationCells(BuildingClass* con
return foundationCells;
}

void BuildingExt::ExtData::UpdateMainEvaVoice()
{
const auto pTypeExt = this->TypeExtData;

if (!pTypeExt->NewEvaVoice.Get(false))
return;

const auto pThis = this->OwnerObject();
const auto pHouse = pThis->Owner;

if (!pHouse->IsControlledByCurrentPlayer())
return;

int newPriority = -1;
int newEvaIndex = VoxClass::EVAIndex;

for (const auto pBuilding : pHouse->Buildings)
{
// Special case that must be avoided here because can be the current EVA changer
if (pBuilding->CurrentMission == Mission::Selling)
continue;

auto const pBuildingTypeExt = BuildingTypeExt::ExtMap.Find(pBuilding->Type);

// The first highest priority takes precedence over lower ones
if (pBuildingTypeExt->NewEvaVoice.Get(false) && pBuildingTypeExt->NewEvaVoice_Priority > newPriority)
{
newPriority = pBuildingTypeExt->NewEvaVoice_Priority;
newEvaIndex = pBuildingTypeExt->NewEvaVoice_Index;
}
}

if (pThis->CurrentMission != Mission::Selling && pTypeExt->NewEvaVoice_Priority > newPriority)
{
newPriority = pTypeExt->NewEvaVoice_Priority;
newEvaIndex = pTypeExt->NewEvaVoice_Index;
}

if (newPriority > 0 && VoxClass::EVAIndex != newEvaIndex)
{
VoxClass::EVAIndex = newEvaIndex;

// Greeting of the new EVA voice
int idxPlay = pTypeExt->NewEvaVoice_InitialMessage.Get(-1);

if (idxPlay != -1)
VoxClass::PlayIndex(idxPlay);
}
else if (newPriority < 0)
{
// Restore the original EVA voice of the owner's side
const auto pSide = SideClass::Array.GetItem(pHouse->SideIndex);
const auto pSideExt = SideExt::ExtMap.Find(pSide);
newEvaIndex = 0; // By default is set the "Allies" EVA voice

if (pSideExt->EVA_Tag.isset())
{
const auto evaTag = pSideExt->EVA_Tag.Get();

for (size_t i = 0; i < RulesExt::Global()->EVAIndexList.size(); i++)
{
const auto item = RulesExt::Global()->EVAIndexList[i].c_str();

if (_strcmpi(item, evaTag) == 0)
{
newEvaIndex = i;
break;
}
}
}
else
{
if (pHouse->SideIndex == 0)
newEvaIndex = 0; // Allied
if (pHouse->SideIndex == 1)
newEvaIndex = 1; // Russian
else if (pHouse->SideIndex == 2)
newEvaIndex = 2; // Yuri
}

VoxClass::EVAIndex = newEvaIndex;
}
}

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

Expand Down
1 change: 1 addition & 0 deletions src/Ext/Building/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class BuildingExt
bool HasSuperWeapon(int index, bool withUpgrades) const;
bool HandleInfiltrate(HouseClass* pInfiltratorHouse, int moneybefore);
void UpdatePrimaryFactoryAI();
void UpdateMainEvaVoice();
virtual ~ExtData() = default;

// virtual void LoadFromINIFile(CCINIClass* pINI) override;
Expand Down
8 changes: 8 additions & 0 deletions src/Ext/Building/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,11 @@
{
enum { ContinueCheck = 0x440B58, SkipSetShouldRebuild = 0x440B81 };

auto const pTypeExt = BuildingTypeExt::ExtMap.Find(pThis->Type);

Check failure on line 251 in src/Ext/Building/Hooks.cpp

View workflow job for this annotation

GitHub Actions / build

^ [C:\a\Phobos\Phobos\Phobos.vcxproj]

Check failure on line 251 in src/Ext/Building/Hooks.cpp

View workflow job for this annotation

GitHub Actions / build

auto const pTypeExt = BuildingTypeExt::ExtMap.Find(pThis->Type); [C:\a\Phobos\Phobos\Phobos.vcxproj]

Check failure on line 251 in src/Ext/Building/Hooks.cpp

View workflow job for this annotation

GitHub Actions / build

'pTypeExt': const object must be initialized [C:\a\Phobos\Phobos\Phobos.vcxproj]

Check failure on line 251 in src/Ext/Building/Hooks.cpp

View workflow job for this annotation

GitHub Actions / build

^ [C:\a\Phobos\Phobos\Phobos.vcxproj]

Check failure on line 251 in src/Ext/Building/Hooks.cpp

View workflow job for this annotation

GitHub Actions / build

auto const pTypeExt = BuildingTypeExt::ExtMap.Find(pThis->Type); [C:\a\Phobos\Phobos\Phobos.vcxproj]

Check failure on line 251 in src/Ext/Building/Hooks.cpp

View workflow job for this annotation

GitHub Actions / build

'pThis': undeclared identifier [C:\a\Phobos\Phobos\Phobos.vcxproj]

if (pTypeExt->NewEvaVoice.Get(false))

Check failure on line 253 in src/Ext/Building/Hooks.cpp

View workflow job for this annotation

GitHub Actions / build

^ [C:\a\Phobos\Phobos\Phobos.vcxproj]

Check failure on line 253 in src/Ext/Building/Hooks.cpp

View workflow job for this annotation

GitHub Actions / build

if (pTypeExt->NewEvaVoice.Get(false)) [C:\a\Phobos\Phobos\Phobos.vcxproj]

Check failure on line 253 in src/Ext/Building/Hooks.cpp

View workflow job for this annotation

GitHub Actions / build

'pTypeExt': cannot be used before it is initialized [C:\a\Phobos\Phobos\Phobos.vcxproj]
BuildingExt::ExtMap.Find(pThis)->UpdateMainEvaVoice();

Check failure on line 254 in src/Ext/Building/Hooks.cpp

View workflow job for this annotation

GitHub Actions / build

'pThis': undeclared identifier [C:\a\Phobos\Phobos\Phobos.vcxproj]

if (SessionClass::IsCampaign())
{
GET(BuildingClass* const, pThis, ESI);
Expand Down Expand Up @@ -432,6 +437,9 @@
}
}

if (pTypeExt->NewEvaVoice.Get(false) && pTypeExt->NewEvaVoice_RecheckOnDeath)
BuildingExt::ExtMap.Find(pThis)->UpdateMainEvaVoice();

return 0;
}

Expand Down
11 changes: 11 additions & 0 deletions src/Ext/BuildingType/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ void BuildingTypeExt::ExtData::LoadFromINIFile(CCINIClass* const pINI)
this->BunkerWallsUpSound.Read(exINI, pSection, "BunkerWallsUpSound");
this->BunkerWallsDownSound.Read(exINI, pSection, "BunkerWallsDownSound");

this->NewEvaVoice.Read(exINI, pSection, "NewEVAVoice");
this->NewEvaVoice_Index.Read(exINI, pSection, "NewEVAVoice.Index");
this->NewEvaVoice_Priority.Read(exINI, pSection, "NewEVAVoice.Priority");
this->NewEvaVoice_RecheckOnDeath.Read(exINI, pSection, "NewEVAVoice.RecheckOnDeath");
this->NewEvaVoice_InitialMessage.Read(exINI, pSection, "NewEVAVoice.InitialMessage");

if (pThis->NumberOfDocks > 0)
{
this->AircraftDockingDirs.clear();
Expand Down Expand Up @@ -333,6 +339,11 @@ void BuildingTypeExt::ExtData::Serialize(T& Stm)
.Process(this->BuildingOccupyROFMult)
.Process(this->BuildingBunkerDamageMult)
.Process(this->BuildingBunkerROFMult)
.Process(this->NewEvaVoice)
.Process(this->NewEvaVoice_Index)
.Process(this->NewEvaVoice_Priority)
.Process(this->NewEvaVoice_RecheckOnDeath)
.Process(this->NewEvaVoice_InitialMessage)
;
}

Expand Down
11 changes: 11 additions & 0 deletions src/Ext/BuildingType/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ class BuildingTypeExt
NullableIdx<VocClass> BunkerWallsUpSound;
NullableIdx<VocClass> BunkerWallsDownSound;

Nullable<bool> NewEvaVoice;
Valueable<int> NewEvaVoice_Index;
Valueable<int> NewEvaVoice_Priority;
Valueable<bool> NewEvaVoice_RecheckOnDeath;
NullableIdx<VoxClass> NewEvaVoice_InitialMessage;

ExtData(BuildingTypeClass* OwnerObject) : Extension<BuildingTypeClass>(OwnerObject)
, PowersUp_Owner { AffectedHouse::Owner }
, PowersUp_Buildings {}
Expand Down Expand Up @@ -152,6 +158,11 @@ class BuildingTypeExt
, BuildingBunkerROFMult {}
, BunkerWallsUpSound {}
, BunkerWallsDownSound {}
, NewEvaVoice {}
, NewEvaVoice_Index { 0 }
, NewEvaVoice_Priority { 0 }
, NewEvaVoice_RecheckOnDeath { false }
, NewEvaVoice_InitialMessage { }
{ }

// Ares 0.A functions
Expand Down
51 changes: 51 additions & 0 deletions src/Ext/Rules/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)

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

// Reading Ares section [EVATypes] at evamd.ini
LoadEvaVoices();

// Section AITargetTypes
int itemsCount = pINI->GetKeyCount("AITargetTypes");
for (int i = 0; i < itemsCount; ++i)
Expand Down Expand Up @@ -313,6 +316,10 @@ void RulesExt::ExtData::LoadBeforeTypeData(RulesClass* pThis, CCINIClass* pINI)
}
}

namespace EVAIndexListTemp
{
std::vector<std::string> EVAIndexList;
}
Comment on lines +319 to +322
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this namespace actually used anywhere?

// this runs between the before and after type data loading methods for rules ini
void RulesExt::ExtData::InitializeAfterTypeData(RulesClass* const pThis)
{
Expand Down Expand Up @@ -501,6 +508,7 @@ void RulesExt::ExtData::Serialize(T& Stm)
.Process(this->DamagedSpeed)
.Process(this->HarvesterScanAfterUnload)
.Process(this->AnimCraterDestroyTiberium)
.Process(this->EVAIndexList)
;
}

Expand Down Expand Up @@ -543,6 +551,49 @@ void RulesExt::ExtData::ReplaceVoxelLightSources()
Game::DestroyVoxelCaches();
}

void RulesExt::ExtData::LoadEvaVoices()
{
CCFileClass pEvamdFile("evamd.ini");

if (pEvamdFile.Exists() && pEvamdFile.Open(FileAccessMode::Read))
{
CCINIClass iniEva;
iniEva.ReadCCFile(&pEvamdFile, true);
iniEva.CurrentSection = nullptr;
iniEva.CurrentSectionName = nullptr;
const auto pEvaSection = "EVATypes";

if (iniEva.GetSection(pEvaSection))
{
this->EVAIndexList.clear();

// Default EVA voices
this->EVAIndexList.emplace_back(GameStrings::Allied);
this->EVAIndexList.emplace_back(GameStrings::Russian);
this->EVAIndexList.emplace_back(GameStrings::Yuri);

// New EVA voices due to a new Ares section in evamd.ini
const auto count = iniEva.GetKeyCount(pEvaSection);

for (std::size_t i = 0; i < count; i++)
{
const auto pEvaKey = iniEva.GetKeyName(pEvaSection, i);

if (iniEva.ReadString(pEvaSection, pEvaKey, "", Phobos::readBuffer) > 0)
{
std::string buffer = Phobos::readBuffer;
bool found = std::find(this->EVAIndexList.begin(), this->EVAIndexList.end(), buffer) != this->EVAIndexList.end();

if (!found)
this->EVAIndexList.emplace_back(buffer);
}
}
}
}

pEvamdFile.Close();
}

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

Expand Down
5 changes: 5 additions & 0 deletions src/Ext/Rules/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ class RulesExt

Valueable<bool> AnimCraterDestroyTiberium;

std::vector<std::string> EVAIndexList;

ExtData(RulesClass* OwnerObject) : Extension<RulesClass>(OwnerObject)
, Storage_TiberiumIndex { -1 }
, HarvesterDumpAmount { 0.0f }
Expand Down Expand Up @@ -399,6 +401,8 @@ class RulesExt
, HarvesterScanAfterUnload { false }

, AnimCraterDestroyTiberium { true }

, EVAIndexList {}
{ }

virtual ~ExtData() = default;
Expand All @@ -415,6 +419,7 @@ class RulesExt
virtual void SaveToStream(PhobosStreamWriter& Stm) override;

void ReplaceVoxelLightSources();
void LoadEvaVoices();

private:
template <typename T>
Expand Down
6 changes: 6 additions & 0 deletions src/Ext/Side/Body.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ void SideExt::ExtData::LoadFromINIFile(CCINIClass* pINI)
this->SuperWeaponSidebar_TopPCX.Read(pINI, pSection, "SuperWeaponSidebar.TopPCX");
this->SuperWeaponSidebar_CenterPCX.Read(pINI, pSection, "SuperWeaponSidebar.CenterPCX");
this->SuperWeaponSidebar_BottomPCX.Read(pINI, pSection, "SuperWeaponSidebar.BottomPCX");

pINI->ReadString(pSection, "EVA.Tag", "", Phobos::readBuffer);

if (std::strlen(Phobos::readBuffer) > 0)
this->EVA_Tag = _strdup(Phobos::readBuffer);
}

// =============================
Expand Down Expand Up @@ -81,6 +86,7 @@ void SideExt::ExtData::Serialize(T& Stm)
.Process(this->SuperWeaponSidebar_TopPCX)
.Process(this->SuperWeaponSidebar_CenterPCX)
.Process(this->SuperWeaponSidebar_BottomPCX)
.Process(this->EVA_Tag)
;
}

Expand Down
2 changes: 2 additions & 0 deletions src/Ext/Side/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class SideExt
PhobosPCXFile SuperWeaponSidebar_TopPCX;
PhobosPCXFile SuperWeaponSidebar_CenterPCX;
PhobosPCXFile SuperWeaponSidebar_BottomPCX;
Nullable<char*> EVA_Tag;

ExtData(SideClass* OwnerObject) : Extension<SideClass>(OwnerObject)
, ArrayIndex { -1 }
Expand Down Expand Up @@ -68,6 +69,7 @@ class SideExt
, SuperWeaponSidebar_TopPCX {}
, SuperWeaponSidebar_CenterPCX {}
, SuperWeaponSidebar_BottomPCX {}
, EVA_Tag { }
{ }

virtual ~ExtData() = default;
Expand Down
Loading