Jump to content

Is there any Script to set NPCs Health in GECK?


Recommended Posts

I tried to set NPCs Health by GECK Script. But It doesn't work well. This is core of my code.

foreach (aEntry <- GLTA 42)
let rForm := *aEntry
let fVal := rForm.GetBaseAV Health
if (iNum >= 1 && iNum <= 150)
rForm.SetAV Health 100
endif
loop

 

And It caused NULL reference exception. I know it's stupid, but I'm not really good at GECK scripting. Can you help me please?

Link to comment
Share on other sites

According to 'TIP Get Actor Health functions' under the "Scripting" section of of the wiki "Getting started creating mods using GECK" article, "AV Health" is a calculated value of 'the current, modified health value (not the maximum). It takes into consideration permanent effects (e.g. perks) as they contribute to your "health pool".'

My guess would be the problem is attempting to directly modify "AV Health" (the end result of a multi-step calculation), is why you are getting a "Null reference". What would be a better choice depends upon just what you are intending to be the result (e.g. which "pool" is affected). See the "ActorValue" page of the GECKWiki.

BTW: ">=" and "<=" are each dual operators, meaning they have to check for both the relative and the equals conditions. Combined on the same statement line means that line is making four checks each time because it has to evaluate the entire statement before it can determine if it needs to be executed. It would be more efficient if you simply change the test values so relative checks were all that were needed (i.e. "> 0" and "<151"), as well as splitting them into separate lines, depending upon which condition you think is the more likely to filter out the most unnecessary checks, as in:

if iNum < 151
   if iNum > 0

-Dubious-

Link to comment
Share on other sites

According to 'TIP Get Actor Health functions' under the "Scripting" section of of the wiki "Getting started creating mods using GECK" article, "AV Health" is a calculated value of 'the current, modified health value (not the maximum). It takes into consideration permanent effects (e.g. perks) as they contribute to your "health pool".'

 

My guess would be the problem is attempting to directly modify "AV Health" (the end result of a multi-step calculation), is why you are getting a "Null reference". What would be a better choice depends upon just what you are intending to be the result (e.g. which "pool" is affected). See the "ActorValue" page of the GECKWiki.

 

BTW: ">=" and "<=" are each dual operators, meaning they have to check for both the relative and the equals conditions. Combined on the same statement line means that line is making four checks each time because it has to evaluate the entire statement before it can determine if it needs to be executed. It would be more efficient if you simply change the test values so relative checks were all that were needed (i.e. "> 0" and "<151"), as well as splitting them into separate lines, depending upon which condition you think is the more likely to filter out the most unnecessary checks, as in:

if iNum < 151
   if iNum > 0

-Dubious-

 

Thank you for your answer. I wanted to change NPCs 'Base Health'. I'm looking at scripts and functions, but they don't seem to have the ability to change their Base Health. Maybe I should have to edit the value one by one.

 

Anyway, thank you again for your answer.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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