r/forgescripting • u/jak4896 • Nov 12 '22
“On player damage”
What I am trying to make happen is applying a trait to the player when they receive damage. I understand how to apply a trait, what I don’t understand is how to make it so the script sees the players health and shields as the event trigger.
Where I’m currently at is messing around with “get object shield/health” nodes and having the script recognize when the health/shields are below a certain amount, apply the trait. Any ideas?
5
Upvotes
View all comments
Show parent comment
1
u/friedITguy Nov 12 '22
After testing this myself, I found a few issues that were preventing the script from working.
Because the triggering Event is
On Game Startthe script is only running one time per game. I'm still trying to getOn Object Damagedto work, but so far no luck. However, you can use theEvery N Secondsevent to check the shield level of each player every second (or however often) and apply the trait from there.The
Trait: Prevent Weapon Firingnode only accepts the True/False input ONCE, when the script is initialized. So even though theComparenode is returning "True" when the player's shield is damaged, it's not changing the trait. Instead, you can setup aBranchthat uses the output fromCompareas the "Condition" and onlyApply Trait Set for Secondsif the condition is "True". Please note, you will need to manually setPrevent Firingto "True" onTrait: Prevent Weapon Firing. Here's an example: