Jump to content

How to deal percentage demage to target in script?


Recommended Posts

Posted

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? 

Posted

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

 

Posted
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.

Posted

health.jpg.c8160a2c364385aafa322d71985778f0.jpg

 

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.

Posted
1 hour ago, Merope said:

health.jpg.c8160a2c364385aafa322d71985778f0.jpg

 

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.

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...