cold steel Posted May 30, 2019 Posted May 30, 2019 Hello third time dear modders. Can someone help me to understand how can I write a script to deal percentage damage to enemy health? Here is my current script: float NPCTargetPercentageHealth = NPCTarget.GetValuePercentage(HealthAV) float NPCTargetHealth = NPCTarget.GetValue(HealthAV) float MaxHealth = ((1 / NPCTargetPercentageHealth) * NPCTargetHealth) float DamageHealthAmount = ((MaxHealth / 100) * 10) NPCTarget.DamageValue(HealthAV, DamageHealthAmount) According to my calculations this simple script should deal 10% of damage to NPCTarget, but for some reason it doesn't work correctly. Maybe that is because on wiki GetValue(HealthAV) example are in integer?
Carabosse Posted May 30, 2019 Posted May 30, 2019 Health as the actor value not HealthAV. You should use floats when applying changes to actor values. float fPercent = 10.0 float fDamageVal = (NPCTarget.GetValue(Health) / 100) * fPercent NPCTarget.DamageValue(Health, fDamageVal) if you want to work out the amount to damage against their base health value, use GetBaseValue() instead of GetValue() which returns their current health (including damage taken, penalties etc). float fDamageVal = (NPCTarget.GetBaseValue(Health) / 100) * fPercent
cold steel Posted May 30, 2019 Author Posted May 30, 2019 39 minutes ago, Merope said: Health as the actor value not HealthAV. You should use floats when applying changes to actor values. float fPercent = 10.0 float fDamageVal = (NPCTarget.GetValue(Health) / 100) * fPercent NPCTarget.DamageValue(Health, fDamageVal) if you want to work out the amount to damage against their base health value, use GetBaseValue() instead of GetValue() which returns their current health (including damage taken, penalties etc). float fDamageVal = (NPCTarget.GetBaseValue(Health) / 100) * fPercent Thanks, but unfortunately I am getting error: "variable Health is undefined". So, I don't think there is variable Health as Actor Value, only HealthAV.
Carabosse Posted May 30, 2019 Posted May 30, 2019 HealthAV was the name of the ActorValue form in Skyrim and previous Fallouts (I believe). As you can see it's now just Health in the F4 CK. It's referred to as HealthAV on the F4 wiki but that's because, as with many pages on the F4 wiki, some mentalist just copied over the entry from the Skyrim wiki without accounting for the differences. Of course it doesn't really matter what you call it in your script, only that it references the correct form.
cold steel Posted May 30, 2019 Author Posted May 30, 2019 1 hour ago, Merope said: HealthAV was the name of the ActorValue form in Skyrim and previous Fallouts (I believe). As you can see it's now just Health in the F4 CK. It's referred to as HealthAV on the F4 wiki but that's because, as with many pages on the F4 wiki, some mentalist just copied over the entry from the Skyrim wiki without accounting for the differences. Of course it doesn't really matter what you call it in your script, only that it references the correct form. Now I understood, thank you.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.