Jump to content

Returning player cureent health and base health.


TommInfinite

Recommended Posts

Recently I found out that I can use PlayerRef.GetAV Health to return current health status and PlayerRef.GetBaseAV Health to return player's full health (considering all current effects on player).

Is this method reliable?

Has anyone got more experience with these functions?

 

{I am asking because I can't simply use GetHealthPercentage because it's unreliable and sometimes returns values over 100%}

Edited by TommInfinite
Link to comment
Share on other sites

GetBaseAV returns the base value with no consideration for permanent (eg. Life Giver perk) or temporary effects (eg. Buffout).

 

You can use GetPermAV to include permanent effects, but no function that I know of can return the max value with temporary effects.

Link to comment
Share on other sites

According to the Commuity GECK site, "Player is used to describe several things, sometimes simultaneously." Among them is: "A scripting keyword that is effectively a global reference variable that resolves to the Actor reference described above."

 

The "Ref Variable" page only uses "PlayerREF" for checking that a locally defined ref variable is that specific Actor "formid" reference. It cautions regarding using a base form reference: "Beware that this is still a base form and may not be used as the calling reference to functions that allows this syntax, although it may be passed as the target if the function permits this.

 

The combination of those statements suggest to me that it is a poor practice to assume the variable "Player" refers to the PC Actor formid at any given moment without checking first. And "[PlayerRef].< function >" syntax implies that "[PlayerRef]" is an abstraction of a locally initialized (i.e. "set myPlayerRef = PlayerREF") variable.

 

But that is interpretation rather than practical experience, so I'm looking forward to hearing from those practitioners.

Clarifying this seems like something that we need to add to the "Getting started creating mods using GECK" article. So far I haven't found a complete explanation of the proper use of "Player" and "PlayerREF" on the GECK sites, and this has to be one of the most common variables used.

 

-Dubious-

 

Link to comment
Share on other sites

Hmmm ... maybe it's as if there is no player base form , atleast in equivalence to all the rest of them ?

More like it's the singularity point that all references revolve around with maybe say ... half the engines mass so to speak ...

Forming it's existence ??? Ouch that hurt my brain :wacko: LOL

Link to comment
Share on other sites

And I'm not sure ... but when you use "PlayerRef" Does that not cause problems getting the base numbers ?

Hence should just be "Player" ?

But that is interpretation rather than practical experience, so I'm looking forward to hearing from those practitioners.

Clarifying this seems like something that we need to add to the "Getting started creating mods using GECK" article. So far I haven't found a complete explanation of the proper use of "Player" and "PlayerREF" on the GECK sites, and this has to be one of the most common variables used.

 

-Dubious-

On the surface, the relation between player and playerref is the same as that between any base form and a reference of it. An instance of the NPC base form with editorID "Player" (formID xx000007) was placed in the world (albeit in a NULL cell if you can believe it - literally in the world but not in any part of it), becoming a reference and receiving formid xx000014, and given the editorID string "playerref". Everything that happens to the PC happens to the playerref. The base form is really just a container of some intel, most if which is still subject to change during gameplay and chargen.

 

Because there can be only one, "player" is indeed a shortcut to mean playerref in many vanilla scripts and scriptlets where a reference function is used on it, which in any other case would cause a script to fail. In addition, "player" is still the editorID of the base form, so is used to refer to the base form when functions demand a base form, such as GetIsID condition checks. I don't quite see why that is done. Using "playerref" for playerref is just as easy, and keeps things clear. People make enough mistakes confusing forms and refs as it is, and ref vars being called that but still being able to hold base forms, and "player" being sometimes player and sometimes playerref doesn't help.

 

On the whole, in practice, it's simply best to use "playerref" for playerref, and only use "player" for the player base form. Because all vanilla GetAV variants are reference functions, playerref is preferable, and definitely doesn't cause GetBaseAV not to work. GetBaseAV cannot be called on a base form at all, including Player (xx000007). The only reason player.GetBaseAV will work is because it's interpreted as the shortcut to playerref there. If you were to pass the Player base form to a ref var and then call rSomeRef.GetBaseAV your script wouldn't work.

Link to comment
Share on other sites

@DoctaSax: Thanks, that explanation really helps clarify things.

 

Sort of a side-note question: formid "xx000007" (Player) is found in "FalloutNV.esm", so that would appear to actually always be formid "00000007". That can be searched on and found in xEdit.

 

OTOH, forimid "xx000014" (PlayerREF) can't be found with a mod index of 00. I couldn't find the EditorID "PlayerREF" in any variation of capitalization after loading my entire "load order". One would expect that "xx" would refer to "FF" as a generated instance in the "save game" file, but that doesn't seem to be possible to load into xEdit (or at least I don't know how) to verify. Can you shed any light on where the "PlayerREF" formid might reside and how you determined that?

 

-Dubious-

Edited by dubiousintent
Link to comment
Share on other sites

@DoctaSax: Thanks, that explanation really helps clarify things.

 

Sort of a side-note question: formid "xx000007" (Player) is found in "FalloutNV.esm", so that would appear to actually always be formid "00000007". That can be searched on and found in xEdit.

 

OTOH, forimid "xx000014" (PlayerREF) can't be found with a mod index of 00. I couldn't find the EditorID "PlayerREF" in any variation of capitalization after loading my entire "load order". One would expect that "xx" would refer to "FF" as a generated instance in the "save game" file, but that doesn't seem to be possible to load into xEdit (or at least I don't know how) to verify. Can you shed any light on where the "PlayerREF" formid might reside and how you determined that?

 

-Dubious-

 

Yes, Player's formid's modindex part is 00, and the same goes for playerref. I just have a habit of using xx most of the time for the mod index part.

Playerref's formid can be found by using any script function on it that returns the formid:

GetFormIDString playerref

printc "%i" playerref

 

If you open the geck, load up fnv.esm, and open the "find text" window in the "edit" menu, type in "playerref" and check the results in the "Objects" tab, you'll find this:

"REFR Form 'PlayerRef' (00000014) to NPC_form 'Player' (00000007) in Cell (null)"

 

So it's really placed in the world albeit not exactly anywhere, rather than created during the game (FF). IIRC, at game start it's just moveto'd to goodsprings cemetary for that scene, from wherever it is.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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