diff --git a/CREDITS.md b/CREDITS.md index 49dee71363..4120d2999a 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -159,6 +159,7 @@ This page lists all the individual contributions to the project by their author. - Event 606: AttachEffect is attaching to a Techno - Linked superweapons - Unit & infantry auto-conversion on ammo change + - ScriptType action `Play speech` - **Starkku**: - Misc. minor bugfixes & improvements - AI script actions: diff --git a/docs/AI-Scripting-and-Mapping.md b/docs/AI-Scripting-and-Mapping.md index bfe19af168..bfeb5b59b2 100644 --- a/docs/AI-Scripting-and-Mapping.md +++ b/docs/AI-Scripting-and-Mapping.md @@ -161,6 +161,19 @@ ShowBriefing=true ; boolean ## Script Actions +### Below `10000` + +#### `24` Play speech + +- Restored functionality. +- Given a speech index, the game will play it. Just like action 24 from Tiberian Sun. + +In `aimd.ini`: +```ini +[SOMESCRIPTTYPE] ; ScriptType +x=24,n +``` + ### `10000-10999` Ingame Actions #### `10000-10049` Attack Actions diff --git a/docs/Whats-New.md b/docs/Whats-New.md index 1f1610a5ab..929fbfad66 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -656,6 +656,7 @@ HideShakeEffects=false ; boolean - [Automatic conversion based on health](New-or-Enhanced-Logics.md#automatic-conversion-based-on-health) (by obsidianus) - Add `ammo`, `health`, `mission`, `landtype` and `sequence` conditions to `DiscardOn` (by Noble_Fish) - [Berzerk / `Psychedelic` duration stacking customization](Fixed-or-Improved-Logics.md#berzerk-psychedelic-duration-stacking-customization) (by Starkku) +- ScriptType action `Play speech` (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) diff --git a/src/Ext/Script/Body.cpp b/src/Ext/Script/Body.cpp index 32ff8b06d5..8380de3b5b 100644 --- a/src/Ext/Script/Body.cpp +++ b/src/Ext/Script/Body.cpp @@ -32,6 +32,9 @@ void ScriptExt::ProcessAction(TeamClass* pTeam) switch (static_cast(action)) { + case PhobosScripts::PlaySpeech: + ScriptExt::PlaySpeech(pTeam); + break; case PhobosScripts::TimedAreaGuard: ScriptExt::ExecuteTimedAreaGuardAction(pTeam); break; @@ -1252,6 +1255,13 @@ bool ScriptExt::IsUnitAvailable(TechnoClass* pTechno, bool checkIfInTransportOrA return isAvailable; } +void ScriptExt::PlaySpeech(TeamClass* pTeam) +{ + const int index = pTeam->CurrentScript->Type->ScriptActions[pTeam->CurrentScript->CurrentMission].Argument; + VoxClass::PlayIndex(index); + pTeam->StepCompleted = true; +} + void ScriptExt::Log(const char* pFormat, ...) { va_list args; diff --git a/src/Ext/Script/Body.h b/src/Ext/Script/Body.h index 8a56ce3148..f1ce860587 100644 --- a/src/Ext/Script/Body.h +++ b/src/Ext/Script/Body.h @@ -8,6 +8,8 @@ enum class PhobosScripts : unsigned int { + PlaySpeech = 24, + // Range 10000-10999 are team (aka ingame) actions // Sub-range 10000-10049 is for "attack" actions RepeatAttackCloser = 10000, @@ -228,6 +230,7 @@ class ScriptExt final : public AbstractExt static void VariableBinaryOperationHandler(TeamClass* pTeam, int nVariable, int nVarToOperate); static bool IsUnitAvailable(TechnoClass* pTechno, bool checkIfInTransportOrAbsorbed); static void Log(const char* pFormat, ...); + static void PlaySpeech(TeamClass* pTeam); // Mission.Attack.cpp static void Mission_Attack(TeamClass* pTeam, int calcThreatMode = 0, bool repeatAction = true, int attackAITargetType = -1, int idxAITargetTypeItem = -1);