From 003771396e77501b6a4834c42691e9117568a787 Mon Sep 17 00:00:00 2001 From: Kex Date: Mon, 10 Feb 2025 17:30:58 +0100 Subject: [PATCH 1/2] Add ability to bury mines --- .../Game/ACE_Core/Global/ACE_SurfaceHelper.c | 28 +++++++ .../UserActions/ACE_GadgetUserAction.c | 39 +++++---- .../ACEExplosivesLocalization.cs_cz.conf | 8 -- .../ACEExplosivesLocalization.de_de.conf | 8 -- .../ACEExplosivesLocalization.en_us.conf | 8 -- .../ACEExplosivesLocalization.es_es.conf | 8 -- .../ACEExplosivesLocalization.fr_fr.conf | 8 -- .../ACEExplosivesLocalization.it_it.conf | 8 -- .../ACEExplosivesLocalization.ja_jp.conf | 8 -- .../ACEExplosivesLocalization.ko_kr.conf | 8 -- .../ACEExplosivesLocalization.pl_pl.conf | 8 -- .../ACEExplosivesLocalization.pt_br.conf | 8 -- .../ACEExplosivesLocalization.ru_ru.conf | 8 -- .../ACEExplosivesLocalization.uk_ua.conf | 8 -- .../ACEExplosivesLocalization.zh_cn.conf | 8 -- .../ACE_Explosives_Localization.cs_cz.conf | 14 ++++ .../ACE_Explosives_Localization.de_de.conf | 14 ++++ .../ACE_Explosives_Localization.en_us.conf | 14 ++++ .../ACE_Explosives_Localization.es_es.conf | 14 ++++ .../ACE_Explosives_Localization.fr_fr.conf | 14 ++++ .../ACE_Explosives_Localization.it_it.conf | 14 ++++ .../ACE_Explosives_Localization.ja_jp.conf | 14 ++++ .../ACE_Explosives_Localization.ko_kr.conf | 14 ++++ .../ACE_Explosives_Localization.pl_pl.conf | 14 ++++ .../ACE_Explosives_Localization.pt_br.conf | 14 ++++ .../ACE_Explosives_Localization.ru_ru.conf | 14 ++++ .../Language/ACE_Explosives_Localization.st | 40 +++++++++- .../ACE_Explosives_Localization.uk_ua.conf | 14 ++++ .../ACE_Explosives_Localization.zh_cn.conf | 14 ++++ .../Prefabs/Weapons/Core/Mine_base.et | 16 +++- addons/explosives/addon.gproj | 54 ++++++------- .../Items/SCR_MineInventoryItemComponent.c | 17 ++++ .../ACE_Explosives_DisarmUserAction.c | 22 ++++- .../ACE_Explosives_ToggleBuryUserAction.c | 80 +++++++++++++++++++ .../UserActions/SCR_MineEquipHolsterAction.c | 14 ++++ .../UserActions/SCR_MineEquipWeaponAction.c | 14 ++++ .../UserActions/SCR_MinePickUpItemAction.c | 14 ++++ .../Weapon/SCR_MineWeaponComponent.c | 36 +++++++++ 38 files changed, 501 insertions(+), 159 deletions(-) create mode 100644 addons/core/scripts/Game/ACE_Core/Global/ACE_SurfaceHelper.c delete mode 100644 addons/explosives/Language/ACEExplosivesLocalization.cs_cz.conf delete mode 100644 addons/explosives/Language/ACEExplosivesLocalization.de_de.conf delete mode 100644 addons/explosives/Language/ACEExplosivesLocalization.en_us.conf delete mode 100644 addons/explosives/Language/ACEExplosivesLocalization.es_es.conf delete mode 100644 addons/explosives/Language/ACEExplosivesLocalization.fr_fr.conf delete mode 100644 addons/explosives/Language/ACEExplosivesLocalization.it_it.conf delete mode 100644 addons/explosives/Language/ACEExplosivesLocalization.ja_jp.conf delete mode 100644 addons/explosives/Language/ACEExplosivesLocalization.ko_kr.conf delete mode 100644 addons/explosives/Language/ACEExplosivesLocalization.pl_pl.conf delete mode 100644 addons/explosives/Language/ACEExplosivesLocalization.pt_br.conf delete mode 100644 addons/explosives/Language/ACEExplosivesLocalization.ru_ru.conf delete mode 100644 addons/explosives/Language/ACEExplosivesLocalization.uk_ua.conf delete mode 100644 addons/explosives/Language/ACEExplosivesLocalization.zh_cn.conf create mode 100644 addons/explosives/scripts/Game/ACE_Explosives/Inventory/Items/SCR_MineInventoryItemComponent.c rename addons/explosives/scripts/Game/ACE_Explosives/{Demining => }/UserActions/ACE_Explosives_DisarmUserAction.c (69%) create mode 100644 addons/explosives/scripts/Game/ACE_Explosives/UserActions/ACE_Explosives_ToggleBuryUserAction.c create mode 100644 addons/explosives/scripts/Game/ACE_Explosives/UserActions/SCR_MineEquipHolsterAction.c create mode 100644 addons/explosives/scripts/Game/ACE_Explosives/UserActions/SCR_MineEquipWeaponAction.c create mode 100644 addons/explosives/scripts/Game/ACE_Explosives/UserActions/SCR_MinePickUpItemAction.c create mode 100644 addons/explosives/scripts/Game/ACE_Explosives/Weapon/SCR_MineWeaponComponent.c diff --git a/addons/core/scripts/Game/ACE_Core/Global/ACE_SurfaceHelper.c b/addons/core/scripts/Game/ACE_Core/Global/ACE_SurfaceHelper.c new file mode 100644 index 00000000..a693a111 --- /dev/null +++ b/addons/core/scripts/Game/ACE_Core/Global/ACE_SurfaceHelper.c @@ -0,0 +1,28 @@ +//------------------------------------------------------------------------------------------------ +class ACE_SurfaceHelper +{ + protected static ref const array DIGGABLE_PHYSMAT_RES_NAMES = { + "{99CE88C5B1865216}Common/Materials/Physics/dirt.physmat", + "{2B4B89135A4F0637}Common/Materials/Physics/grass.physmat", + "{8AEE78000E7E1346}Common/Materials/Physics/gravel.physmat", + "{C2004DDEB7A62E05}Common/Materials/Physics/sand.physmat", + "{EFF6CC81E77B1860}Common/Materials/Physics/snow.physmat", + "{B0F2C4F345C4894C}Common/Materials/Physics/soil.physmat" + }; + + //------------------------------------------------------------------------------------------------ + //! Returns the when the terrain surface at the given position is diggable + static bool IsDiggableSurface(notnull SurfaceProperties props) + { + ResourceName resName; + props.Get("Physics material", resName); + + foreach (ResourceName diggablePhysMatResName : DIGGABLE_PHYSMAT_RES_NAMES) + { + if (diggablePhysMatResName == resName) + return true; + } + + return false; + } +} diff --git a/addons/core/scripts/Game/ACE_Core/UserActions/ACE_GadgetUserAction.c b/addons/core/scripts/Game/ACE_Core/UserActions/ACE_GadgetUserAction.c index 144ce6b4..8d66ed60 100644 --- a/addons/core/scripts/Game/ACE_Core/UserActions/ACE_GadgetUserAction.c +++ b/addons/core/scripts/Game/ACE_Core/UserActions/ACE_GadgetUserAction.c @@ -9,8 +9,9 @@ class ACE_GadgetUserAction : ScriptedUserAction //------------------------------------------------------------------------------------------------ //! Stop animation when action is completed - override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity) + override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity) { + super.PerformAction(pOwnerEntity, pUserEntity); CancelPlayerAnimation(pUserEntity); } @@ -34,7 +35,7 @@ class ACE_GadgetUserAction : ScriptedUserAction params.SetAllowMovementDuringAction(false); params.SetKeepInHandAfterSuccess(true); params.SetCommandID(itemActionId); - params.SetCommandIntArg(m_iAnimationIndex); + params.SetCommandIntArg(GetAnimationIndex()); charController.TryUseItemOverrideParams(params); } @@ -47,20 +48,7 @@ class ACE_GadgetUserAction : ScriptedUserAction override void OnActionCanceled(IEntity pOwnerEntity, IEntity pUserEntity) { super.OnActionCanceled(pOwnerEntity, pUserEntity); - - ChimeraCharacter character = ChimeraCharacter.Cast(pUserEntity); - if (!character) - return; - - CharacterControllerComponent charController = character.GetCharacterController(); - if (charController) - { - CharacterAnimationComponent pAnimationComponent = charController.GetAnimationComponent(); - int itemActionId = pAnimationComponent.BindCommand("CMD_Item_Action"); - CharacterCommandHandlerComponent cmdHandler = CharacterCommandHandlerComponent.Cast(pAnimationComponent.GetCommandHandler()); - if (cmdHandler) - cmdHandler.FinishItemUse(true); - } + CancelPlayerAnimation(pUserEntity); } //------------------------------------------------------------------------------------------------ @@ -75,12 +63,15 @@ class ACE_GadgetUserAction : ScriptedUserAction return; CharacterControllerComponent charController = character.GetCharacterController(); - if (charController) - { - CharacterAnimationComponent pAnimationComponent = charController.GetAnimationComponent(); - CharacterCommandHandlerComponent cmdHandler = CharacterCommandHandlerComponent.Cast(pAnimationComponent.GetCommandHandler()); + if (!charController) + return; + CharacterAnimationComponent animationComponent = charController.GetAnimationComponent(); + if (!animationComponent) + return; + + CharacterCommandHandlerComponent cmdHandler = CharacterCommandHandlerComponent.Cast(animationComponent.GetCommandHandler()); + if (cmdHandler) cmdHandler.FinishItemUse(true); - } } //------------------------------------------------------------------------------------------------ @@ -94,6 +85,12 @@ class ACE_GadgetUserAction : ScriptedUserAction return gadgetManager.GetHeldGadget(); } + //------------------------------------------------------------------------------------------------ + int GetAnimationIndex() + { + return m_iAnimationIndex; + } + //------------------------------------------------------------------------------------------------ //! Destructor - End Gadget animation void ~ACE_GadgetUserAction() diff --git a/addons/explosives/Language/ACEExplosivesLocalization.cs_cz.conf b/addons/explosives/Language/ACEExplosivesLocalization.cs_cz.conf deleted file mode 100644 index 93ad1ff3..00000000 --- a/addons/explosives/Language/ACEExplosivesLocalization.cs_cz.conf +++ /dev/null @@ -1,8 +0,0 @@ -StringTableRuntime { - Ids { - "ACE-Explosives_DisarmUserAction_Name" - } - Texts { - "Disarm" - } -} \ No newline at end of file diff --git a/addons/explosives/Language/ACEExplosivesLocalization.de_de.conf b/addons/explosives/Language/ACEExplosivesLocalization.de_de.conf deleted file mode 100644 index 2d5f4147..00000000 --- a/addons/explosives/Language/ACEExplosivesLocalization.de_de.conf +++ /dev/null @@ -1,8 +0,0 @@ -StringTableRuntime { - Ids { - "ACE-Explosives_DisarmUserAction_Name" - } - Texts { - "Entschärfen" - } -} \ No newline at end of file diff --git a/addons/explosives/Language/ACEExplosivesLocalization.en_us.conf b/addons/explosives/Language/ACEExplosivesLocalization.en_us.conf deleted file mode 100644 index 93ad1ff3..00000000 --- a/addons/explosives/Language/ACEExplosivesLocalization.en_us.conf +++ /dev/null @@ -1,8 +0,0 @@ -StringTableRuntime { - Ids { - "ACE-Explosives_DisarmUserAction_Name" - } - Texts { - "Disarm" - } -} \ No newline at end of file diff --git a/addons/explosives/Language/ACEExplosivesLocalization.es_es.conf b/addons/explosives/Language/ACEExplosivesLocalization.es_es.conf deleted file mode 100644 index 93ad1ff3..00000000 --- a/addons/explosives/Language/ACEExplosivesLocalization.es_es.conf +++ /dev/null @@ -1,8 +0,0 @@ -StringTableRuntime { - Ids { - "ACE-Explosives_DisarmUserAction_Name" - } - Texts { - "Disarm" - } -} \ No newline at end of file diff --git a/addons/explosives/Language/ACEExplosivesLocalization.fr_fr.conf b/addons/explosives/Language/ACEExplosivesLocalization.fr_fr.conf deleted file mode 100644 index 93ad1ff3..00000000 --- a/addons/explosives/Language/ACEExplosivesLocalization.fr_fr.conf +++ /dev/null @@ -1,8 +0,0 @@ -StringTableRuntime { - Ids { - "ACE-Explosives_DisarmUserAction_Name" - } - Texts { - "Disarm" - } -} \ No newline at end of file diff --git a/addons/explosives/Language/ACEExplosivesLocalization.it_it.conf b/addons/explosives/Language/ACEExplosivesLocalization.it_it.conf deleted file mode 100644 index 93ad1ff3..00000000 --- a/addons/explosives/Language/ACEExplosivesLocalization.it_it.conf +++ /dev/null @@ -1,8 +0,0 @@ -StringTableRuntime { - Ids { - "ACE-Explosives_DisarmUserAction_Name" - } - Texts { - "Disarm" - } -} \ No newline at end of file diff --git a/addons/explosives/Language/ACEExplosivesLocalization.ja_jp.conf b/addons/explosives/Language/ACEExplosivesLocalization.ja_jp.conf deleted file mode 100644 index 93ad1ff3..00000000 --- a/addons/explosives/Language/ACEExplosivesLocalization.ja_jp.conf +++ /dev/null @@ -1,8 +0,0 @@ -StringTableRuntime { - Ids { - "ACE-Explosives_DisarmUserAction_Name" - } - Texts { - "Disarm" - } -} \ No newline at end of file diff --git a/addons/explosives/Language/ACEExplosivesLocalization.ko_kr.conf b/addons/explosives/Language/ACEExplosivesLocalization.ko_kr.conf deleted file mode 100644 index 93ad1ff3..00000000 --- a/addons/explosives/Language/ACEExplosivesLocalization.ko_kr.conf +++ /dev/null @@ -1,8 +0,0 @@ -StringTableRuntime { - Ids { - "ACE-Explosives_DisarmUserAction_Name" - } - Texts { - "Disarm" - } -} \ No newline at end of file diff --git a/addons/explosives/Language/ACEExplosivesLocalization.pl_pl.conf b/addons/explosives/Language/ACEExplosivesLocalization.pl_pl.conf deleted file mode 100644 index 93ad1ff3..00000000 --- a/addons/explosives/Language/ACEExplosivesLocalization.pl_pl.conf +++ /dev/null @@ -1,8 +0,0 @@ -StringTableRuntime { - Ids { - "ACE-Explosives_DisarmUserAction_Name" - } - Texts { - "Disarm" - } -} \ No newline at end of file diff --git a/addons/explosives/Language/ACEExplosivesLocalization.pt_br.conf b/addons/explosives/Language/ACEExplosivesLocalization.pt_br.conf deleted file mode 100644 index 93ad1ff3..00000000 --- a/addons/explosives/Language/ACEExplosivesLocalization.pt_br.conf +++ /dev/null @@ -1,8 +0,0 @@ -StringTableRuntime { - Ids { - "ACE-Explosives_DisarmUserAction_Name" - } - Texts { - "Disarm" - } -} \ No newline at end of file diff --git a/addons/explosives/Language/ACEExplosivesLocalization.ru_ru.conf b/addons/explosives/Language/ACEExplosivesLocalization.ru_ru.conf deleted file mode 100644 index 93ad1ff3..00000000 --- a/addons/explosives/Language/ACEExplosivesLocalization.ru_ru.conf +++ /dev/null @@ -1,8 +0,0 @@ -StringTableRuntime { - Ids { - "ACE-Explosives_DisarmUserAction_Name" - } - Texts { - "Disarm" - } -} \ No newline at end of file diff --git a/addons/explosives/Language/ACEExplosivesLocalization.uk_ua.conf b/addons/explosives/Language/ACEExplosivesLocalization.uk_ua.conf deleted file mode 100644 index 93ad1ff3..00000000 --- a/addons/explosives/Language/ACEExplosivesLocalization.uk_ua.conf +++ /dev/null @@ -1,8 +0,0 @@ -StringTableRuntime { - Ids { - "ACE-Explosives_DisarmUserAction_Name" - } - Texts { - "Disarm" - } -} \ No newline at end of file diff --git a/addons/explosives/Language/ACEExplosivesLocalization.zh_cn.conf b/addons/explosives/Language/ACEExplosivesLocalization.zh_cn.conf deleted file mode 100644 index 93ad1ff3..00000000 --- a/addons/explosives/Language/ACEExplosivesLocalization.zh_cn.conf +++ /dev/null @@ -1,8 +0,0 @@ -StringTableRuntime { - Ids { - "ACE-Explosives_DisarmUserAction_Name" - } - Texts { - "Disarm" - } -} \ No newline at end of file diff --git a/addons/explosives/Language/ACE_Explosives_Localization.cs_cz.conf b/addons/explosives/Language/ACE_Explosives_Localization.cs_cz.conf index 44c509a5..4837e5b8 100644 --- a/addons/explosives/Language/ACE_Explosives_Localization.cs_cz.conf +++ b/addons/explosives/Language/ACE_Explosives_Localization.cs_cz.conf @@ -1,2 +1,16 @@ StringTableRuntime { + Ids { + "ACE-Explosives_FailReason_Buried" + "ACE-Explosives_FailReason_HardSurface" + "ACE-Explosives_UserAction_Bury_Name" + "ACE-Explosives_UserAction_Disarm_Name" + "ACE-Explosives_UserAction_Unbury_Name" + } + Texts { + "Buried" + "Hard surface" + "Bury" + "Disarm" + "Unbury" + } } \ No newline at end of file diff --git a/addons/explosives/Language/ACE_Explosives_Localization.de_de.conf b/addons/explosives/Language/ACE_Explosives_Localization.de_de.conf index 44c509a5..f8c9b04b 100644 --- a/addons/explosives/Language/ACE_Explosives_Localization.de_de.conf +++ b/addons/explosives/Language/ACE_Explosives_Localization.de_de.conf @@ -1,2 +1,16 @@ StringTableRuntime { + Ids { + "ACE-Explosives_FailReason_Buried" + "ACE-Explosives_FailReason_HardSurface" + "ACE-Explosives_UserAction_Bury_Name" + "ACE-Explosives_UserAction_Disarm_Name" + "ACE-Explosives_UserAction_Unbury_Name" + } + Texts { + "Eingegraben" + "Harte Oberfläche" + "Eingraben" + "Entschärfen" + "Ausgraben" + } } \ No newline at end of file diff --git a/addons/explosives/Language/ACE_Explosives_Localization.en_us.conf b/addons/explosives/Language/ACE_Explosives_Localization.en_us.conf index 44c509a5..4837e5b8 100644 --- a/addons/explosives/Language/ACE_Explosives_Localization.en_us.conf +++ b/addons/explosives/Language/ACE_Explosives_Localization.en_us.conf @@ -1,2 +1,16 @@ StringTableRuntime { + Ids { + "ACE-Explosives_FailReason_Buried" + "ACE-Explosives_FailReason_HardSurface" + "ACE-Explosives_UserAction_Bury_Name" + "ACE-Explosives_UserAction_Disarm_Name" + "ACE-Explosives_UserAction_Unbury_Name" + } + Texts { + "Buried" + "Hard surface" + "Bury" + "Disarm" + "Unbury" + } } \ No newline at end of file diff --git a/addons/explosives/Language/ACE_Explosives_Localization.es_es.conf b/addons/explosives/Language/ACE_Explosives_Localization.es_es.conf index 44c509a5..4837e5b8 100644 --- a/addons/explosives/Language/ACE_Explosives_Localization.es_es.conf +++ b/addons/explosives/Language/ACE_Explosives_Localization.es_es.conf @@ -1,2 +1,16 @@ StringTableRuntime { + Ids { + "ACE-Explosives_FailReason_Buried" + "ACE-Explosives_FailReason_HardSurface" + "ACE-Explosives_UserAction_Bury_Name" + "ACE-Explosives_UserAction_Disarm_Name" + "ACE-Explosives_UserAction_Unbury_Name" + } + Texts { + "Buried" + "Hard surface" + "Bury" + "Disarm" + "Unbury" + } } \ No newline at end of file diff --git a/addons/explosives/Language/ACE_Explosives_Localization.fr_fr.conf b/addons/explosives/Language/ACE_Explosives_Localization.fr_fr.conf index 44c509a5..4837e5b8 100644 --- a/addons/explosives/Language/ACE_Explosives_Localization.fr_fr.conf +++ b/addons/explosives/Language/ACE_Explosives_Localization.fr_fr.conf @@ -1,2 +1,16 @@ StringTableRuntime { + Ids { + "ACE-Explosives_FailReason_Buried" + "ACE-Explosives_FailReason_HardSurface" + "ACE-Explosives_UserAction_Bury_Name" + "ACE-Explosives_UserAction_Disarm_Name" + "ACE-Explosives_UserAction_Unbury_Name" + } + Texts { + "Buried" + "Hard surface" + "Bury" + "Disarm" + "Unbury" + } } \ No newline at end of file diff --git a/addons/explosives/Language/ACE_Explosives_Localization.it_it.conf b/addons/explosives/Language/ACE_Explosives_Localization.it_it.conf index 44c509a5..4837e5b8 100644 --- a/addons/explosives/Language/ACE_Explosives_Localization.it_it.conf +++ b/addons/explosives/Language/ACE_Explosives_Localization.it_it.conf @@ -1,2 +1,16 @@ StringTableRuntime { + Ids { + "ACE-Explosives_FailReason_Buried" + "ACE-Explosives_FailReason_HardSurface" + "ACE-Explosives_UserAction_Bury_Name" + "ACE-Explosives_UserAction_Disarm_Name" + "ACE-Explosives_UserAction_Unbury_Name" + } + Texts { + "Buried" + "Hard surface" + "Bury" + "Disarm" + "Unbury" + } } \ No newline at end of file diff --git a/addons/explosives/Language/ACE_Explosives_Localization.ja_jp.conf b/addons/explosives/Language/ACE_Explosives_Localization.ja_jp.conf index 44c509a5..4837e5b8 100644 --- a/addons/explosives/Language/ACE_Explosives_Localization.ja_jp.conf +++ b/addons/explosives/Language/ACE_Explosives_Localization.ja_jp.conf @@ -1,2 +1,16 @@ StringTableRuntime { + Ids { + "ACE-Explosives_FailReason_Buried" + "ACE-Explosives_FailReason_HardSurface" + "ACE-Explosives_UserAction_Bury_Name" + "ACE-Explosives_UserAction_Disarm_Name" + "ACE-Explosives_UserAction_Unbury_Name" + } + Texts { + "Buried" + "Hard surface" + "Bury" + "Disarm" + "Unbury" + } } \ No newline at end of file diff --git a/addons/explosives/Language/ACE_Explosives_Localization.ko_kr.conf b/addons/explosives/Language/ACE_Explosives_Localization.ko_kr.conf index 44c509a5..4837e5b8 100644 --- a/addons/explosives/Language/ACE_Explosives_Localization.ko_kr.conf +++ b/addons/explosives/Language/ACE_Explosives_Localization.ko_kr.conf @@ -1,2 +1,16 @@ StringTableRuntime { + Ids { + "ACE-Explosives_FailReason_Buried" + "ACE-Explosives_FailReason_HardSurface" + "ACE-Explosives_UserAction_Bury_Name" + "ACE-Explosives_UserAction_Disarm_Name" + "ACE-Explosives_UserAction_Unbury_Name" + } + Texts { + "Buried" + "Hard surface" + "Bury" + "Disarm" + "Unbury" + } } \ No newline at end of file diff --git a/addons/explosives/Language/ACE_Explosives_Localization.pl_pl.conf b/addons/explosives/Language/ACE_Explosives_Localization.pl_pl.conf index 44c509a5..4837e5b8 100644 --- a/addons/explosives/Language/ACE_Explosives_Localization.pl_pl.conf +++ b/addons/explosives/Language/ACE_Explosives_Localization.pl_pl.conf @@ -1,2 +1,16 @@ StringTableRuntime { + Ids { + "ACE-Explosives_FailReason_Buried" + "ACE-Explosives_FailReason_HardSurface" + "ACE-Explosives_UserAction_Bury_Name" + "ACE-Explosives_UserAction_Disarm_Name" + "ACE-Explosives_UserAction_Unbury_Name" + } + Texts { + "Buried" + "Hard surface" + "Bury" + "Disarm" + "Unbury" + } } \ No newline at end of file diff --git a/addons/explosives/Language/ACE_Explosives_Localization.pt_br.conf b/addons/explosives/Language/ACE_Explosives_Localization.pt_br.conf index 44c509a5..4837e5b8 100644 --- a/addons/explosives/Language/ACE_Explosives_Localization.pt_br.conf +++ b/addons/explosives/Language/ACE_Explosives_Localization.pt_br.conf @@ -1,2 +1,16 @@ StringTableRuntime { + Ids { + "ACE-Explosives_FailReason_Buried" + "ACE-Explosives_FailReason_HardSurface" + "ACE-Explosives_UserAction_Bury_Name" + "ACE-Explosives_UserAction_Disarm_Name" + "ACE-Explosives_UserAction_Unbury_Name" + } + Texts { + "Buried" + "Hard surface" + "Bury" + "Disarm" + "Unbury" + } } \ No newline at end of file diff --git a/addons/explosives/Language/ACE_Explosives_Localization.ru_ru.conf b/addons/explosives/Language/ACE_Explosives_Localization.ru_ru.conf index 44c509a5..4837e5b8 100644 --- a/addons/explosives/Language/ACE_Explosives_Localization.ru_ru.conf +++ b/addons/explosives/Language/ACE_Explosives_Localization.ru_ru.conf @@ -1,2 +1,16 @@ StringTableRuntime { + Ids { + "ACE-Explosives_FailReason_Buried" + "ACE-Explosives_FailReason_HardSurface" + "ACE-Explosives_UserAction_Bury_Name" + "ACE-Explosives_UserAction_Disarm_Name" + "ACE-Explosives_UserAction_Unbury_Name" + } + Texts { + "Buried" + "Hard surface" + "Bury" + "Disarm" + "Unbury" + } } \ No newline at end of file diff --git a/addons/explosives/Language/ACE_Explosives_Localization.st b/addons/explosives/Language/ACE_Explosives_Localization.st index 924cf4ac..455ac0ec 100644 --- a/addons/explosives/Language/ACE_Explosives_Localization.st +++ b/addons/explosives/Language/ACE_Explosives_Localization.st @@ -1,13 +1,45 @@ StringTable { ItemClassName "CustomStringTableItem" Items { + CustomStringTableItem "{649378D01FD98890}" { + Id "ACE-Explosives_FailReason_Buried" + Target_en_us "Buried" + Target_de_de "Eingegraben" + Modified 1687423940 + Author "Kex" + LastChanged "Kex" + } + CustomStringTableItem "{649378D2BB5531A1}" { + Id "ACE-Explosives_FailReason_HardSurface" + Target_en_us "Hard surface" + Target_de_de "Harte Oberfläche" + Modified 1687424525 + Author "Kex" + LastChanged "Kex" + } + CustomStringTableItem "{64933B9C7DC48AD7}" { + Id "ACE-Explosives_UserAction_Bury_Name" + Target_en_us "Bury" + Target_de_de "Eingraben" + Modified 1687384945 + Author "Kex" + LastChanged "Kex" + } CustomStringTableItem "{61B80DDD1907B555}" { - Id "ACE-Explosives_DisarmUserAction_Name" + Id "ACE-Explosives_UserAction_Disarm_Name" Target_en_us "Disarm" Target_de_de "Entschärfen" - Modified 1639514968 - Author "sebas" - LastChanged "sebas" + Modified 1687384761 + Author "Kex" + LastChanged "Kex" + } + CustomStringTableItem "{64933B9C711A2AC1}" { + Id "ACE-Explosives_UserAction_Unbury_Name" + Target_en_us "Unbury" + Target_de_de "Ausgraben" + Modified 1687384951 + Author "Kex" + LastChanged "Kex" } } } \ No newline at end of file diff --git a/addons/explosives/Language/ACE_Explosives_Localization.uk_ua.conf b/addons/explosives/Language/ACE_Explosives_Localization.uk_ua.conf index 44c509a5..4837e5b8 100644 --- a/addons/explosives/Language/ACE_Explosives_Localization.uk_ua.conf +++ b/addons/explosives/Language/ACE_Explosives_Localization.uk_ua.conf @@ -1,2 +1,16 @@ StringTableRuntime { + Ids { + "ACE-Explosives_FailReason_Buried" + "ACE-Explosives_FailReason_HardSurface" + "ACE-Explosives_UserAction_Bury_Name" + "ACE-Explosives_UserAction_Disarm_Name" + "ACE-Explosives_UserAction_Unbury_Name" + } + Texts { + "Buried" + "Hard surface" + "Bury" + "Disarm" + "Unbury" + } } \ No newline at end of file diff --git a/addons/explosives/Language/ACE_Explosives_Localization.zh_cn.conf b/addons/explosives/Language/ACE_Explosives_Localization.zh_cn.conf index 44c509a5..4837e5b8 100644 --- a/addons/explosives/Language/ACE_Explosives_Localization.zh_cn.conf +++ b/addons/explosives/Language/ACE_Explosives_Localization.zh_cn.conf @@ -1,2 +1,16 @@ StringTableRuntime { + Ids { + "ACE-Explosives_FailReason_Buried" + "ACE-Explosives_FailReason_HardSurface" + "ACE-Explosives_UserAction_Bury_Name" + "ACE-Explosives_UserAction_Disarm_Name" + "ACE-Explosives_UserAction_Unbury_Name" + } + Texts { + "Buried" + "Hard surface" + "Bury" + "Disarm" + "Unbury" + } } \ No newline at end of file diff --git a/addons/explosives/Prefabs/Weapons/Core/Mine_base.et b/addons/explosives/Prefabs/Weapons/Core/Mine_base.et index 02323c1a..7d424679 100644 --- a/addons/explosives/Prefabs/Weapons/Core/Mine_base.et +++ b/addons/explosives/Prefabs/Weapons/Core/Mine_base.et @@ -7,10 +7,22 @@ GenericEntity : "{CD00FFBAFD036BE2}Prefabs/Weapons/Core/Explosives_base.et" { ParentContextList { "default" } - UIInfo UIInfo "{61B846BBC1A7E295}" { - Name "#ACE-Explosives_DisarmUserAction_Name" + UIInfo SCR_ActionUIInfo "{61B846BBC1A7E295}" { + Name "#ACE-Explosives_UserAction_Disarm_Name" + m_sIconName "repair" } Duration 6 + "Sort Priority" -3 + } + ACE_Explosives_ToggleBuryUserAction "{64933B9AAC846215}" { + ParentContextList { + "default" + } + UIInfo SCR_ActionUIInfo "{64933B9A1108ED2E}" { + m_sIconName "building-construction" + } + Duration 6 + "Sort Priority" -3 } } } diff --git a/addons/explosives/addon.gproj b/addons/explosives/addon.gproj index 79ae8ed5..1b031b1d 100644 --- a/addons/explosives/addon.gproj +++ b/addons/explosives/addon.gproj @@ -9,60 +9,60 @@ GameProject { GameProjectConfig PC { WidgetManagerSettings WidgetManagerSettings "{AC4BE58770485E02}" { StringTables { - StringTableDefinition "{61B80DDC6ED33EB8}" { + StringTableDefinition "{6494F6254129D69A}" { StringTableSource "{AB4674C708AC6E13}Language/ACE_Explosives_Localization.st" Languages { - LanguageDefinition "{61B80DDC60A0B696}" { + LanguageDefinition "{6494F6254670F382}" { Code "cs_cz" - StringTableRuntime "{D40B97B841EA0481}Language/ACEExplosivesLocalization.cs_cz.conf" + StringTableRuntime "{01CEF1C177795397}Language/ACE_Explosives_Localization.cs_cz.conf" } - LanguageDefinition "{61B80DDC60A0B648}" { + LanguageDefinition "{6494F6254670F3C0}" { Code "de_de" - StringTableRuntime "{01758D8B524915A1}Language/ACEExplosivesLocalization.de_de.conf" + StringTableRuntime "{D4B0EBF264DA42B7}Language/ACE_Explosives_Localization.de_de.conf" } - LanguageDefinition "{61B80DDC60A0B678}" { + LanguageDefinition "{6494F6254670F330}" { Code "en_us" - StringTableRuntime "{5F8507C038BA10A0}Language/ACEExplosivesLocalization.en_us.conf" + StringTableRuntime "{8A4061B90E2947B6}Language/ACE_Explosives_Localization.en_us.conf" } - LanguageDefinition "{61B80DDC60A0B669}" { + LanguageDefinition "{6494F6254670F321}" { Code "es_es" - StringTableRuntime "{9AC94A49D6B87BBF}Language/ACEExplosivesLocalization.es_es.conf" + StringTableRuntime "{4F0C2C30E02B2CA9}Language/ACE_Explosives_Localization.es_es.conf" } - LanguageDefinition "{61B80DDC60A0B618}" { + LanguageDefinition "{6494F6254670F171}" { Code "fr_fr" - StringTableRuntime "{2161BF7E303B98BD}Language/ACEExplosivesLocalization.fr_fr.conf" + StringTableRuntime "{F4A4D90706A8CFAB}Language/ACE_Explosives_Localization.fr_fr.conf" } - LanguageDefinition "{61B80DDC60A0B608}" { + LanguageDefinition "{6494F6254670F163}" { Code "it_it" - StringTableRuntime "{A17D304A9D191B44}Language/ACEExplosivesLocalization.it_it.conf" + StringTableRuntime "{74B85633AB8A4C52}Language/ACE_Explosives_Localization.it_it.conf" } - LanguageDefinition "{61B80DDC60A0B638}" { + LanguageDefinition "{6494F6254670F16E}" { Code "ja_jp" - StringTableRuntime "{B1668DD8A3682BEF}Language/ACEExplosivesLocalization.ja_jp.conf" + StringTableRuntime "{64A3EBA195FB7CF9}Language/ACE_Explosives_Localization.ja_jp.conf" } - LanguageDefinition "{61B80DDC60A0B636}" { + LanguageDefinition "{6494F6254670F159}" { Code "ko_kr" - StringTableRuntime "{11D8A574304528D0}Language/ACEExplosivesLocalization.ko_kr.conf" + StringTableRuntime "{C41DC30D06D67FC6}Language/ACE_Explosives_Localization.ko_kr.conf" } - LanguageDefinition "{61B80DDC60A0B627}" { + LanguageDefinition "{6494F6254670F144}" { Code "pl_pl" - StringTableRuntime "{4DA9038E8EAAB4AC}Language/ACEExplosivesLocalization.pl_pl.conf" + StringTableRuntime "{986C65F7B839E3BA}Language/ACE_Explosives_Localization.pl_pl.conf" } - LanguageDefinition "{61B80DDC60A0A9D5}" { + LanguageDefinition "{6494F6254670F0B5}" { Code "pt_br" - StringTableRuntime "{98DE9942B5547E16}Language/ACEExplosivesLocalization.pt_br.conf" + StringTableRuntime "{4D1BFF3B83C72900}Language/ACE_Explosives_Localization.pt_br.conf" } - LanguageDefinition "{61B80DDC60A0A95A}" { + LanguageDefinition "{6494F6254670F0AE}" { Code "ru_ru" - StringTableRuntime "{CD9F8DEA282D1B60}Language/ACEExplosivesLocalization.ru_ru.conf" + StringTableRuntime "{185AEB931EBE4C76}Language/ACE_Explosives_Localization.ru_ru.conf" } - LanguageDefinition "{61B80DDC60A0A940}" { + LanguageDefinition "{6494F6254670F09C}" { Code "uk_ua" - StringTableRuntime "{47C7D81C4403A535}Language/ACEExplosivesLocalization.uk_ua.conf" + StringTableRuntime "{9202BE657290F223}Language/ACE_Explosives_Localization.uk_ua.conf" } - LanguageDefinition "{61B80DDC60A0A97E}" { + LanguageDefinition "{6494F6254670F088}" { Code "zh_cn" - StringTableRuntime "{9D77B6217DA37528}Language/ACEExplosivesLocalization.zh_cn.conf" + StringTableRuntime "{48B2D0584B30223E}Language/ACE_Explosives_Localization.zh_cn.conf" } } } diff --git a/addons/explosives/scripts/Game/ACE_Explosives/Inventory/Items/SCR_MineInventoryItemComponent.c b/addons/explosives/scripts/Game/ACE_Explosives/Inventory/Items/SCR_MineInventoryItemComponent.c new file mode 100644 index 00000000..3ebfb111 --- /dev/null +++ b/addons/explosives/scripts/Game/ACE_Explosives/Inventory/Items/SCR_MineInventoryItemComponent.c @@ -0,0 +1,17 @@ +//------------------------------------------------------------------------------------------------ +modded class SCR_MineInventoryItemComponent : SCR_PlaceableInventoryItemComponent +{ + //------------------------------------------------------------------------------------------------ + //! Mine should not be shown in inventory menu when buried + override bool ShouldHideInVicinity() + { + if (super.ShouldHideInVicinity()) + return true; + + SCR_MineWeaponComponent weaponComponent = SCR_MineWeaponComponent.Cast(GetOwner().FindComponent(SCR_MineWeaponComponent)); + if (!weaponComponent) + return false; + + return weaponComponent.ACE_Exposives_IsBuried(); + } +} diff --git a/addons/explosives/scripts/Game/ACE_Explosives/Demining/UserActions/ACE_Explosives_DisarmUserAction.c b/addons/explosives/scripts/Game/ACE_Explosives/UserActions/ACE_Explosives_DisarmUserAction.c similarity index 69% rename from addons/explosives/scripts/Game/ACE_Explosives/Demining/UserActions/ACE_Explosives_DisarmUserAction.c rename to addons/explosives/scripts/Game/ACE_Explosives/UserActions/ACE_Explosives_DisarmUserAction.c index 4a0a0c02..3d08050f 100644 --- a/addons/explosives/scripts/Game/ACE_Explosives/Demining/UserActions/ACE_Explosives_DisarmUserAction.c +++ b/addons/explosives/scripts/Game/ACE_Explosives/UserActions/ACE_Explosives_DisarmUserAction.c @@ -1,15 +1,20 @@ //------------------------------------------------------------------------------------------------ //! Explosive disarm user action class ACE_Explosives_DisarmUserAction : ACE_WrenchUserAction -{ +{ + [Attribute(defvalue: "#ACE-Explosives_FailReason_Buried", desc: "String for when mine is buried")] + protected LocalizedString m_sBuried; + protected SCR_ExplosiveChargeComponent m_pChargeComponent; protected SCR_PressureTriggerComponent m_pTriggerComponent; + protected SCR_MineWeaponComponent m_pMineWeaponComponent; //------------------------------------------------------------------------------------------------ override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent) { m_pChargeComponent = SCR_ExplosiveChargeComponent.Cast(pOwnerEntity.FindComponent(SCR_ExplosiveChargeComponent)); m_pTriggerComponent = SCR_PressureTriggerComponent.Cast(pOwnerEntity.FindComponent(SCR_PressureTriggerComponent)); + m_pMineWeaponComponent = SCR_MineWeaponComponent.Cast(pOwnerEntity.FindComponent(SCR_MineWeaponComponent)); } //------------------------------------------------------------------------------------------------ @@ -44,4 +49,19 @@ class ACE_Explosives_DisarmUserAction : ACE_WrenchUserAction return true; } + + //------------------------------------------------------------------------------------------------ + override bool CanBePerformedScript(IEntity user) + { + if (!super.CanBePerformedScript(user)) + return false; + + if (m_pMineWeaponComponent && m_pMineWeaponComponent.ACE_Exposives_IsBuried()) + { + SetCannotPerformReason(m_sBuried); + return false; + } + + return true; + } } diff --git a/addons/explosives/scripts/Game/ACE_Explosives/UserActions/ACE_Explosives_ToggleBuryUserAction.c b/addons/explosives/scripts/Game/ACE_Explosives/UserActions/ACE_Explosives_ToggleBuryUserAction.c new file mode 100644 index 00000000..aed74647 --- /dev/null +++ b/addons/explosives/scripts/Game/ACE_Explosives/UserActions/ACE_Explosives_ToggleBuryUserAction.c @@ -0,0 +1,80 @@ +//------------------------------------------------------------------------------------------------ +class ACE_Explosives_ToggleBuryUserAction : ACE_ShovelUserAction +{ + [Attribute(defvalue: "#ACE-Explosives_UserAction_Bury_Name", desc: "String for bury action")] + protected LocalizedString m_sBury; + + [Attribute(defvalue: "#ACE-Explosives_UserAction_Unbury_Name", desc: "String for unbury action")] + protected LocalizedString m_sUnbury; + + [Attribute(defvalue: "#ACE-Explosives_FailReason_HardSurface", desc: "String for hard surface")] + protected LocalizedString m_sHardSurface; + + protected SCR_MineWeaponComponent m_pWeaponComponent; + protected vector m_vOwnerPos; + protected bool m_bOnDiggableSurface = false; + + //------------------------------------------------------------------------------------------------ + override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent) + { + m_pWeaponComponent = SCR_MineWeaponComponent.Cast(pOwnerEntity.FindComponent(SCR_MineWeaponComponent)); + } + + //------------------------------------------------------------------------------------------------ + override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity) + { + super.PerformAction(pOwnerEntity, pUserEntity); + m_pWeaponComponent.ACE_Exposives_ToggleBurial(!m_pWeaponComponent.ACE_Exposives_IsBuried()); + } + + //------------------------------------------------------------------------------------------------ + override bool GetActionNameScript(out string outName) + { + if (m_pWeaponComponent.ACE_Exposives_IsBuried()) + outName = m_sUnbury; + else + outName = m_sBury; + + return true; + } + + //------------------------------------------------------------------------------------------------ + override int GetAnimationIndex() + { + return 1 + m_pWeaponComponent.ACE_Exposives_IsBuried(); + } + + //------------------------------------------------------------------------------------------------ + override bool CanBePerformedScript(IEntity user) + { + if (!super.CanBePerformedScript(user)) + return false; + + // Always allow unburying + if (m_pWeaponComponent.ACE_Exposives_IsBuried()) + return true; + + // Only allow burying when surface is diggable + vector pos = GetOwner().GetOrigin(); + + if (m_vOwnerPos != pos) + { + TraceParam params = new TraceParam(); + params.Flags = TraceFlags.WORLD | TraceFlags.ENTS; + params.Start = pos + 0.01 * vector.Up; + params.End = pos - 0.01 * vector.Up; + params.Exclude = GetOwner(); + GetGame().GetWorld().TraceMove(params, null); + m_bOnDiggableSurface = ACE_SurfaceHelper.IsDiggableSurface(params.SurfaceProps); + m_vOwnerPos = pos; + } + + if (!m_bOnDiggableSurface) + { + SetCannotPerformReason(m_sHardSurface); + return false; + } + + return true; + } +} diff --git a/addons/explosives/scripts/Game/ACE_Explosives/UserActions/SCR_MineEquipHolsterAction.c b/addons/explosives/scripts/Game/ACE_Explosives/UserActions/SCR_MineEquipHolsterAction.c new file mode 100644 index 00000000..79bc6e45 --- /dev/null +++ b/addons/explosives/scripts/Game/ACE_Explosives/UserActions/SCR_MineEquipHolsterAction.c @@ -0,0 +1,14 @@ +//------------------------------------------------------------------------------------------------ +modded class SCR_MineEquipHolsterAction : SCR_EquipWeaponHolsterAction +{ + //------------------------------------------------------------------------------------------------ + //! Mine cannot be picked up while buried + override bool CanBeShownScript(IEntity user) + { + SCR_MineWeaponComponent mineWeaponComponent = SCR_MineWeaponComponent.Cast(GetOwner().FindComponent(SCR_MineWeaponComponent)); + if (mineWeaponComponent && mineWeaponComponent.ACE_Exposives_IsBuried()) + return false; + + return super.CanBeShownScript(user); + } +} diff --git a/addons/explosives/scripts/Game/ACE_Explosives/UserActions/SCR_MineEquipWeaponAction.c b/addons/explosives/scripts/Game/ACE_Explosives/UserActions/SCR_MineEquipWeaponAction.c new file mode 100644 index 00000000..0baa9e74 --- /dev/null +++ b/addons/explosives/scripts/Game/ACE_Explosives/UserActions/SCR_MineEquipWeaponAction.c @@ -0,0 +1,14 @@ +//------------------------------------------------------------------------------------------------ +modded class SCR_MineEquipWeaponAction : SCR_EquipWeaponAction +{ + //------------------------------------------------------------------------------------------------ + //! Mine cannot be picked up while buried + override bool CanBeShownScript(IEntity user) + { + SCR_MineWeaponComponent mineWeaponComponent = SCR_MineWeaponComponent.Cast(GetOwner().FindComponent(SCR_MineWeaponComponent)); + if (mineWeaponComponent && mineWeaponComponent.ACE_Exposives_IsBuried()) + return false; + + return super.CanBeShownScript(user); + } +} diff --git a/addons/explosives/scripts/Game/ACE_Explosives/UserActions/SCR_MinePickUpItemAction.c b/addons/explosives/scripts/Game/ACE_Explosives/UserActions/SCR_MinePickUpItemAction.c new file mode 100644 index 00000000..03b78d25 --- /dev/null +++ b/addons/explosives/scripts/Game/ACE_Explosives/UserActions/SCR_MinePickUpItemAction.c @@ -0,0 +1,14 @@ +//------------------------------------------------------------------------------------------------ +modded class SCR_MinePickUpItemAction : SCR_PickUpItemAction +{ + //------------------------------------------------------------------------------------------------ + //! Mine cannot be picked up while buried + override bool CanBeShownScript(IEntity user) + { + SCR_MineWeaponComponent mineWeaponComponent = SCR_MineWeaponComponent.Cast(GetOwner().FindComponent(SCR_MineWeaponComponent)); + if (mineWeaponComponent && mineWeaponComponent.ACE_Exposives_IsBuried()) + return false; + + return super.CanBeShownScript(user); + } +} diff --git a/addons/explosives/scripts/Game/ACE_Explosives/Weapon/SCR_MineWeaponComponent.c b/addons/explosives/scripts/Game/ACE_Explosives/Weapon/SCR_MineWeaponComponent.c new file mode 100644 index 00000000..34667c6a --- /dev/null +++ b/addons/explosives/scripts/Game/ACE_Explosives/Weapon/SCR_MineWeaponComponent.c @@ -0,0 +1,36 @@ +//------------------------------------------------------------------------------------------------ +modded class SCR_MineWeaponComponent : WeaponComponent +{ + [Attribute(defvalue: "0 -0.09 0", desc: "Local offset vector applied when buried")] + protected vector m_vACE_Explosives_BurialOffset; + + [RplProp(onRplName: "ACE_Exposives_OnToggleBurial")] + protected bool m_bACE_Explosives_IsBuried; + + //------------------------------------------------------------------------------------------------ + bool ACE_Exposives_IsBuried() + { + return m_bACE_Explosives_IsBuried; + } + + //------------------------------------------------------------------------------------------------ + void ACE_Exposives_ToggleBurial(bool bury) + { + RplComponent rpl = RplComponent.Cast(GetOwner().FindComponent(RplComponent)); + if (!rpl || rpl.IsProxy()) + return; + + m_bACE_Explosives_IsBuried = bury; + ACE_Exposives_OnToggleBurial(); + Replication.BumpMe(); + } + + //------------------------------------------------------------------------------------------------ + protected void ACE_Exposives_OnToggleBurial() + { + IEntity mine = GetOwner(); + float sign = 2 * m_bACE_Explosives_IsBuried - 1; + mine.SetOrigin(mine.GetOrigin() + sign * mine.VectorToParent(m_vACE_Explosives_BurialOffset)); + mine.Update(); + } +} From cc3603bd46446d35eba35615d9cb5326c802f3df Mon Sep 17 00:00:00 2001 From: Kex Date: Mon, 10 Feb 2025 18:44:55 +0100 Subject: [PATCH 2/2] Register diggable surfaces via surface label config --- .../core/Configs/ACE/ACE_SurfaceLabels.conf | 15 ++++++ .../Configs/ACE/ACE_SurfaceLabels.conf.meta | 17 ++++++ .../ACE_Core/Configs/ACE_SurfaceTypesConfig.c | 53 +++++++++++++++++++ .../Game/ACE_Core/Global/ACE_ESurfaceLabel.c | 6 +++ .../Game/ACE_Core/Global/ACE_SurfaceHelper.c | 32 +++++------ .../ACE_Explosives_ToggleBuryUserAction.c | 2 +- 6 files changed, 105 insertions(+), 20 deletions(-) create mode 100644 addons/core/Configs/ACE/ACE_SurfaceLabels.conf create mode 100644 addons/core/Configs/ACE/ACE_SurfaceLabels.conf.meta create mode 100644 addons/core/scripts/Game/ACE_Core/Configs/ACE_SurfaceTypesConfig.c create mode 100644 addons/core/scripts/Game/ACE_Core/Global/ACE_ESurfaceLabel.c diff --git a/addons/core/Configs/ACE/ACE_SurfaceLabels.conf b/addons/core/Configs/ACE/ACE_SurfaceLabels.conf new file mode 100644 index 00000000..b3cf11ad --- /dev/null +++ b/addons/core/Configs/ACE/ACE_SurfaceLabels.conf @@ -0,0 +1,15 @@ +ACE_SurfaceLabelsConfig { + m_aEntries { + ACE_SurfaceLabelConfigEntry "{6494FEBC9AF3C9AC}" { + m_eLabel DIGGABLE + m_aPhysMatResNames { + "{99CE88C5B1865216}Common/Materials/Physics/dirt.physmat" + "{2B4B89135A4F0637}Common/Materials/Physics/grass.physmat" + "{8AEE78000E7E1346}Common/Materials/Physics/gravel.physmat" + "{C2004DDEB7A62E05}Common/Materials/Physics/sand.physmat" + "{EFF6CC81E77B1860}Common/Materials/Physics/snow.physmat" + "{B0F2C4F345C4894C}Common/Materials/Physics/soil.physmat" + } + } + } +} \ No newline at end of file diff --git a/addons/core/Configs/ACE/ACE_SurfaceLabels.conf.meta b/addons/core/Configs/ACE/ACE_SurfaceLabels.conf.meta new file mode 100644 index 00000000..af7baab4 --- /dev/null +++ b/addons/core/Configs/ACE/ACE_SurfaceLabels.conf.meta @@ -0,0 +1,17 @@ +MetaFileClass { + Name "{4E2AF3E9D54A29B4}Configs/ACE/ACE_SurfaceTypes.conf" + Configurations { + CONFResourceClass PC { + } + CONFResourceClass XBOX_ONE : PC { + } + CONFResourceClass XBOX_SERIES : PC { + } + CONFResourceClass PS4 : PC { + } + CONFResourceClass PS5 : PC { + } + CONFResourceClass HEADLESS : PC { + } + } +} \ No newline at end of file diff --git a/addons/core/scripts/Game/ACE_Core/Configs/ACE_SurfaceTypesConfig.c b/addons/core/scripts/Game/ACE_Core/Configs/ACE_SurfaceTypesConfig.c new file mode 100644 index 00000000..02d23d4b --- /dev/null +++ b/addons/core/scripts/Game/ACE_Core/Configs/ACE_SurfaceTypesConfig.c @@ -0,0 +1,53 @@ +//---------------------------------------------------------------------------------------- +[BaseContainerProps(configRoot: true)] +class ACE_SurfaceLabelsConfig +{ + [Attribute(desc: "Registered surface labels")] + protected ref array m_aEntries; + + //---------------------------------------------------------------------------------------- + bool HasLabel(BaseContainer gameMatContainer, ACE_ESurfaceLabel label) + { + foreach (ACE_SurfaceLabelConfigEntry entry : m_aEntries) + { + if (label != entry.GetLabel()) + continue; + + return entry.HasLabel(gameMatContainer); + } + + return false; + } +} + +//---------------------------------------------------------------------------------------- +[BaseContainerProps(), SCR_BaseContainerCustomTitleEnum(ACE_ESurfaceLabel, "m_eLabel")] +class ACE_SurfaceLabelConfigEntry +{ + [Attribute(uiwidget: UIWidgets.SearchComboBox, enums: ParamEnumArray.FromEnum(ACE_ESurfaceLabel), desc: "A property label for surfaces")] + protected ACE_ESurfaceLabel m_eLabel; + + [Attribute(desc: "Physical materials that have this label", uiwidget: UIWidgets.ResourceNamePicker, params: "physmat")] + protected ref array m_aPhysMatResNames; + + //---------------------------------------------------------------------------------------- + ACE_ESurfaceLabel GetLabel() + { + return m_eLabel; + } + + //---------------------------------------------------------------------------------------- + bool HasLabel(BaseContainer gameMatContainer) + { + ResourceName resName; + gameMatContainer.Get("Physics material", resName); + + foreach (ResourceName whitelistedResName : m_aPhysMatResNames) + { + if (whitelistedResName == resName) + return true; + } + + return false; + } +} diff --git a/addons/core/scripts/Game/ACE_Core/Global/ACE_ESurfaceLabel.c b/addons/core/scripts/Game/ACE_Core/Global/ACE_ESurfaceLabel.c new file mode 100644 index 00000000..e90439c0 --- /dev/null +++ b/addons/core/scripts/Game/ACE_Core/Global/ACE_ESurfaceLabel.c @@ -0,0 +1,6 @@ +//---------------------------------------------------------------------------------------- +enum ACE_ESurfaceLabel +{ + NONE, + DIGGABLE +} diff --git a/addons/core/scripts/Game/ACE_Core/Global/ACE_SurfaceHelper.c b/addons/core/scripts/Game/ACE_Core/Global/ACE_SurfaceHelper.c index a693a111..2f11fba0 100644 --- a/addons/core/scripts/Game/ACE_Core/Global/ACE_SurfaceHelper.c +++ b/addons/core/scripts/Game/ACE_Core/Global/ACE_SurfaceHelper.c @@ -1,28 +1,22 @@ //------------------------------------------------------------------------------------------------ class ACE_SurfaceHelper { - protected static ref const array DIGGABLE_PHYSMAT_RES_NAMES = { - "{99CE88C5B1865216}Common/Materials/Physics/dirt.physmat", - "{2B4B89135A4F0637}Common/Materials/Physics/grass.physmat", - "{8AEE78000E7E1346}Common/Materials/Physics/gravel.physmat", - "{C2004DDEB7A62E05}Common/Materials/Physics/sand.physmat", - "{EFF6CC81E77B1860}Common/Materials/Physics/snow.physmat", - "{B0F2C4F345C4894C}Common/Materials/Physics/soil.physmat" - }; + protected static ref ACE_SurfaceLabelsConfig s_SurfaceLabelsConfig; + protected static const ResourceName SURFACE_LABELS_CONFIG_NAME = "{4E2AF3E9D54A29B4}Configs/ACE/ACE_SurfaceLabels.conf"; //------------------------------------------------------------------------------------------------ - //! Returns the when the terrain surface at the given position is diggable - static bool IsDiggableSurface(notnull SurfaceProperties props) + protected static void Init() { - ResourceName resName; - props.Get("Physics material", resName); - - foreach (ResourceName diggablePhysMatResName : DIGGABLE_PHYSMAT_RES_NAMES) - { - if (diggablePhysMatResName == resName) - return true; - } + s_SurfaceLabelsConfig = SCR_ConfigHelperT.GetConfigObject(SURFACE_LABELS_CONFIG_NAME); + } + + //------------------------------------------------------------------------------------------------ + //! Returns true when the surface has the given label + static bool HasLabel(notnull SurfaceProperties props, ACE_ESurfaceLabel label) + { + if (!s_SurfaceLabelsConfig) + Init(); - return false; + return s_SurfaceLabelsConfig.HasLabel(props, label); } } diff --git a/addons/explosives/scripts/Game/ACE_Explosives/UserActions/ACE_Explosives_ToggleBuryUserAction.c b/addons/explosives/scripts/Game/ACE_Explosives/UserActions/ACE_Explosives_ToggleBuryUserAction.c index aed74647..90e093c1 100644 --- a/addons/explosives/scripts/Game/ACE_Explosives/UserActions/ACE_Explosives_ToggleBuryUserAction.c +++ b/addons/explosives/scripts/Game/ACE_Explosives/UserActions/ACE_Explosives_ToggleBuryUserAction.c @@ -65,7 +65,7 @@ class ACE_Explosives_ToggleBuryUserAction : ACE_ShovelUserAction params.End = pos - 0.01 * vector.Up; params.Exclude = GetOwner(); GetGame().GetWorld().TraceMove(params, null); - m_bOnDiggableSurface = ACE_SurfaceHelper.IsDiggableSurface(params.SurfaceProps); + m_bOnDiggableSurface = ACE_SurfaceHelper.HasLabel(params.SurfaceProps, ACE_ESurfaceLabel.DIGGABLE); m_vOwnerPos = pos; }