-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Medical - Revise visibility of bandage user action (#59)
* Hard override bandage user action - Move checks from CanbeShownScript to CanBePerformedScript - Use array of bleeding hit zones for checks * Remove blank line
- Loading branch information
Showing
1 changed file
with
59 additions
and
0 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
addons/medical/scripts/Game/UserActions/SCR_BandageUserAction.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
//------------------------------------------------------------------------------------------------ | ||
//! Hard-override of SCR_BandageUserAction | ||
class SCR_BandageUserAction : SCR_HealingUserAction | ||
{ | ||
//------------------------------------------------------------------------------------------------ | ||
//! Copy of vanilla method | ||
override void OnActionCanceled(IEntity pOwnerEntity, IEntity pUserEntity) | ||
{ | ||
ChimeraCharacter character = ChimeraCharacter.Cast(pUserEntity); | ||
if (!character) | ||
return; | ||
|
||
CharacterControllerComponent controller = character.GetCharacterController(); | ||
if (!controller) | ||
return; | ||
|
||
if (controller.GetLifeState() != ECharacterLifeState.ALIVE) | ||
return; | ||
|
||
SCR_ConsumableItemComponent consumableComponent = GetConsumableComponent(character); | ||
if (consumableComponent) | ||
consumableComponent.SetAlternativeModel(false); | ||
} | ||
|
||
//------------------------------------------------------------------------------------------------ | ||
//! We move the handling from CanBeShownScript to CanBePerformedScript | ||
//! We check the bleeding via the array of all bleeding hit zones, which should be more reliable | ||
//! than the vanilla implementation | ||
override bool CanBePerformedScript(IEntity user) | ||
{ | ||
if (!super.CanBePerformedScript(user)) | ||
return false; | ||
|
||
// Target character | ||
ChimeraCharacter char = ChimeraCharacter.Cast(GetOwner()); | ||
if (!char) | ||
return false; | ||
|
||
SCR_CharacterDamageManagerComponent damageManager = SCR_CharacterDamageManagerComponent.Cast(char.GetDamageManager()); | ||
if (!damageManager) | ||
return false; | ||
|
||
array<HitZone> bleedingHitZones = {}; | ||
damageManager.GetBleedingHitZones(bleedingHitZones); | ||
|
||
foreach (HitZone hitZone : bleedingHitZones) | ||
{ | ||
SCR_CharacterHitZone charHitZone = SCR_CharacterHitZone.Cast(hitZone); | ||
if (!charHitZone) | ||
continue; | ||
|
||
if (charHitZone.GetHitZoneGroup() == m_eHitZoneGroup) | ||
return true; | ||
} | ||
|
||
SetCannotPerformReason(m_sNotBleeding); | ||
return false; | ||
} | ||
} |