HasTakenDamage Equivalent for Shield?

jkaczmar

Member
I am using HasTakenDamage in BD Pro to indicate when an NPC has taken damage. It works great for those NPCs that don't have a shield. If I shoot them in the back, they immediately turn towards the player and start doing their thing. It's not an issue if the player is in front of the NPC because I'm using sight detection.

However, it doesn't work as cleanly with shield as HasTakenDamage doesn't trigger until I've burned through the Shield and actually damaged the character's Health attribute. What's a good way around this so that the character reacts when their shield has been hit? I know I can do workarounds like CanDetectObject using Sound, but I would much rather have the character react on hit.
 
Update--I was able to make an PM FSM that checks current shield vs max shield and sets Alert status based on whether there is a difference. It gets called repeatedly until Alert is set and then it assumes the NPC is permanently alert and doesn't call the code again.

That said, I would rather called something native to UCC. I tried using OnObjectImpact rather than OnDamageHealth, but couldn't get it work. I'm using Hitscan rather than a projectile so perhaps that is the reason.

Please let me know if there are better, more elegant ways than an FSM callout.
 
HasTakenDamage is only for the character but the shield has an OnShieldImpact that you can subscribe to:
Code:
                EventHandler.ExecuteEvent<ShieldAction, ImpactCallbackContext>(m_Character, "OnShieldImpact", this, ctx);

With this event you will not need to poll the health every frame.
 
Back
Top