diff --git a/addons/carrying/Scripts/Game/ACE_Carrying/UserActions/ACE_Carrying_CarryUserAction.c b/addons/carrying/Scripts/Game/ACE_Carrying/UserActions/ACE_Carrying_CarryUserAction.c index ec4d7af7..4d74a07a 100755 --- a/addons/carrying/Scripts/Game/ACE_Carrying/UserActions/ACE_Carrying_CarryUserAction.c +++ b/addons/carrying/Scripts/Game/ACE_Carrying/UserActions/ACE_Carrying_CarryUserAction.c @@ -44,7 +44,7 @@ class ACE_Carrying_CarryUserAction : ScriptedUserAction // Trying to carry while unit is ragdolling will break things if (ownerChar.GetAnimationComponent().IsRagdollActive()) { - SetCannotPerformReason(ActionMenuFailReason.DEFAULT); + SetCannotPerformReason("#AR-UserActionUnavailable"); return false; } diff --git a/addons/chopping/scripts/Game/ACE_Chopping/UserActions/ACE_Chopping_UserAction.c b/addons/chopping/scripts/Game/ACE_Chopping/UserActions/ACE_Chopping_UserAction.c index 8165aff7..a63a8826 100644 --- a/addons/chopping/scripts/Game/ACE_Chopping/UserActions/ACE_Chopping_UserAction.c +++ b/addons/chopping/scripts/Game/ACE_Chopping/UserActions/ACE_Chopping_UserAction.c @@ -2,30 +2,46 @@ //! Tree deletion user action class ACE_Chopping_UserAction : ACE_ShovelUserAction { - //------------------------------------------------------------------------------------------------ - //! Request deletion of the tree - override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity) - { - SCR_PlayerController userCtrl = SCR_PlayerController.Cast(GetGame().GetPlayerController()); - if (!userCtrl) - return; - - ACE_Chopping_HelperEntity helper = ACE_Chopping_HelperEntity.Cast(GetOwner()); - if (!helper) - return; - - IEntity plant = helper.GetAssociatedPlant(); - if (!plant) - return; - - userCtrl.ACE_RequestDeleteEntity(plant); + protected static const int DELETE_FALLING_TREE_DELAY_MS = 10000; + + //------------------------------------------------------------------------------------------------ + //! Request deletion of the tree + override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity) + { + SCR_PlayerController userCtrl = SCR_PlayerController.Cast(GetGame().GetPlayerController()); + if (!userCtrl) + return; + + ACE_Chopping_HelperEntity helper = ACE_Chopping_HelperEntity.Cast(GetOwner()); + if (!helper) + return; + + Tree plant = Tree.Cast(helper.GetAssociatedPlant()); + if (!plant) + return; + + bool enabled; + BaseContainer container = plant.GetPrefabData().GetPrefab(); + + if (container && container.Get("Enabled", enabled) && enabled) + { + vector transform[4]; + pUserEntity.GetWorldTransform(transform); + userCtrl.ACE_RequestDestroyEntity(plant, EDamageType.MELEE, transform); + GetGame().GetCallqueue().CallLater(userCtrl.ACE_RequestDeleteEntity, DELETE_FALLING_TREE_DELAY_MS, false, plant); + } + else + { + userCtrl.ACE_RequestDeleteEntity(plant); + } + delete helper; - } + } - //------------------------------------------------------------------------------------------------ - //! For entities that have no RplComponent, only local scripts will work - override bool HasLocalEffectOnlyScript() - { - return true; - } + //------------------------------------------------------------------------------------------------ + //! For entities that have no RplComponent, only local scripts will work + override bool HasLocalEffectOnlyScript() + { + return true; + } } diff --git a/addons/core/scripts/Game/ACE_Core/Player/SCR_PlayerController.c b/addons/core/scripts/Game/ACE_Core/Player/SCR_PlayerController.c index 68148d42..41b9b789 100644 --- a/addons/core/scripts/Game/ACE_Core/Player/SCR_PlayerController.c +++ b/addons/core/scripts/Game/ACE_Core/Player/SCR_PlayerController.c @@ -6,6 +6,9 @@ modded class SCR_PlayerController : PlayerController //! Called from local player void ACE_RequestDeleteEntity(IEntity entity) { + if (!entity) + return; + Rpc(RpcAsk_ACE_DeleteEntityByBits, ACE_EntityIdHelper.ToInt(entity.GetID())); } @@ -19,4 +22,23 @@ modded class SCR_PlayerController : PlayerController manager.DeleteEntitiesByIdGlobal({EntityID.FromInt(bits[0], bits[1])}); } + + //------------------------------------------------------------------------------------------------ + //! Request destruction of SCR_DestructibleEntity + //! Called from local player + void ACE_RequestDestroyEntity(SCR_DestructibleEntity entity, EDamageType damageType, vector hitPosDirNorm[4]) + { + Rpc(RpcAsk_ACE_DestroyEntity, entity.GetID(), damageType, hitPosDirNorm); + } + + //------------------------------------------------------------------------------------------------ + [RplRpc(RplChannel.Reliable, RplRcver.Server)] + protected void RpcAsk_ACE_DestroyEntity(EntityID entityID, EDamageType damageType, vector hitPosDirNorm[4]) + { + SCR_DestructibleEntity entity = SCR_DestructibleEntity.Cast(GetGame().GetWorld().FindEntityByID(entityID)); + if (!entity) + return; + + entity.HandleDamage(damageType, entity.GetCurrentHealth(), hitPosDirNorm); + } } 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 b4f18137..c2ee6ff6 100644 --- a/addons/core/scripts/Game/ACE_Core/UserActions/ACE_GadgetUserAction.c +++ b/addons/core/scripts/Game/ACE_Core/UserActions/ACE_GadgetUserAction.c @@ -59,7 +59,7 @@ class ACE_GadgetUserAction : ScriptedUserAction int itemActionId = pAnimationComponent.BindCommand("CMD_Item_Action"); CharacterCommandHandlerComponent cmdHandler = CharacterCommandHandlerComponent.Cast(pAnimationComponent.GetCommandHandler()); if (cmdHandler) - cmdHandler.FinishItemUse(); + cmdHandler.FinishItemUse(true); } } @@ -79,7 +79,8 @@ class ACE_GadgetUserAction : ScriptedUserAction { CharacterAnimationComponent pAnimationComponent = charController.GetAnimationComponent(); CharacterCommandHandlerComponent cmdHandler = CharacterCommandHandlerComponent.Cast(pAnimationComponent.GetCommandHandler()); - cmdHandler.FinishItemUse(); + if (cmdHandler) + cmdHandler.FinishItemUse(true); } } diff --git a/addons/medical/scripts/Game/ACE_Medical/Components/Damage/SCR_CharacterDamageManagerComponent.c b/addons/medical/scripts/Game/ACE_Medical/Components/Damage/SCR_CharacterDamageManagerComponent.c index 5a4c3954..c4846bae 100644 --- a/addons/medical/scripts/Game/ACE_Medical/Components/Damage/SCR_CharacterDamageManagerComponent.c +++ b/addons/medical/scripts/Game/ACE_Medical/Components/Damage/SCR_CharacterDamageManagerComponent.c @@ -29,9 +29,9 @@ modded class SCR_CharacterDamageManagerComponent : SCR_DamageManagerComponent //----------------------------------------------------------------------------------------------------------- //! Initialize member variables - override void OnInit(IEntity owner) + override void OnPostInit(IEntity owner) { - super.OnInit(owner); + super.OnPostInit(owner); m_pACE_Medical_HealthHitZone = GetHitZoneByName("Health"); if (!m_pACE_Medical_HealthHitZone) diff --git a/addons/medical/scripts/Game/ACE_Medical/Components/Gadgets/ACE_Medical_ConsumableEpinephrine.c b/addons/medical/scripts/Game/ACE_Medical/Components/Gadgets/ACE_Medical_ConsumableEpinephrine.c index 0b9ed2cd..191561ef 100755 --- a/addons/medical/scripts/Game/ACE_Medical/Components/Gadgets/ACE_Medical_ConsumableEpinephrine.c +++ b/addons/medical/scripts/Game/ACE_Medical/Components/Gadgets/ACE_Medical_ConsumableEpinephrine.c @@ -19,7 +19,7 @@ class ACE_Medical_ConsumableEpinephrine : SCR_ConsumableEffectHealthItems return false; // Check if epinephrine is in the system already - array effects = damageManager.GetAllPersistentEffectsOfType(ACE_Medical_EpinephrineDamageEffect); + array effects = damageManager.GetAllPersistentEffectsOfType(ACE_Medical_EpinephrineDamageEffect); if (!effects.IsEmpty()) { failReason = SCR_EConsumableFailReason.ALREADY_APPLIED; diff --git a/addons/medical/scripts/Game/ACE_Medical/Components/Gadgets/ACE_Medical_ConsumableMorphine.c b/addons/medical/scripts/Game/ACE_Medical/Components/Gadgets/ACE_Medical_ConsumableMorphine.c index e49b3131..90fa1a96 100755 --- a/addons/medical/scripts/Game/ACE_Medical/Components/Gadgets/ACE_Medical_ConsumableMorphine.c +++ b/addons/medical/scripts/Game/ACE_Medical/Components/Gadgets/ACE_Medical_ConsumableMorphine.c @@ -21,7 +21,7 @@ class ACE_Medical_ConsumableMorphine : SCR_ConsumableEffectHealthItems return false; // Check if morphine is in the system already - array effects = damageManager.GetAllPersistentEffectsOfType(ACE_Medical_MorphineDamageEffect); + array effects = damageManager.GetAllPersistentEffectsOfType(ACE_Medical_MorphineDamageEffect); if (!effects.IsEmpty()) { failReason = SCR_EConsumableFailReason.ALREADY_APPLIED;