Jump to content

How to define Actor?


Recommended Posts

I want to use "SetActorHealth(Player, 25.0) "

 

But Creation Kit says “Player” is not defined.

 

So how to define a player?

 

And I saw “playerREF" "AKactor" ....everywhere ,I guess these all mean the "PLAYER" , What is the different? Why we use various name?

Link to comment
Share on other sites

First of all, it's a property (a variable) that needs to be defined. Think of it as of a pointer to anything. In this case, if a property is of Actor type, then it is a pointer to actor. And after you declare it, you should go to 'properties' tab and fill it (assign any particular actor reference).
Link to comment
Share on other sites

The "Player" has to be an Actor type for SetActorHealth() to make any sense, so you have to at least declare it as a variable somewhere:

Actor Player

It has no value yet, so if you want to actually do something to the player you need to give "Player" a value. There are several ways to do this, the simplest way is calling Game.GetPlayer(), which returns an Actor, the reference to the Player:

Actor Player = Game.GetPlayer()

On another note, there is no function "SetActorHealth()" in Papyrus. What you actually want to do is:

someActorRef.DamageValue(someActorValueRef,Amount)

or, in reverse

someActorRef.RestoreValue(someActorValueRef,Amount)

You really should read up on programming basics and Papyrus idioms if you want to write more complex scripts. The Creation Kit wiki at https://wiki.creationkit.com/fallout4/ provides a tutorial and a Papyrus object and function reference which you should get familiar with. If you're not some programmer prodigy, not reading that stuff will make you write horrible Papyrus code that will end up breaking things. Trust me, I have written horrible Papyrus code that did break things as a newbie. Don't do that for things you want to release.

Link to comment
Share on other sites

The "Player" has to be an Actor type for SetActorHealth() to make any sense, so you have to at least declare it as a variable somewhere:

Actor Player

It has no value yet, so if you want to actually do something to the player you need to give "Player" a value. There are several ways to do this, the simplest way is calling Game.GetPlayer(), which returns an Actor, the reference to the Player:

Actor Player = Game.GetPlayer()

On another note, there is no function "SetActorHealth()" in Papyrus. What you actually want to do is:

someActorRef.DamageValue(someActorValueRef,Amount)

or, in reverse

someActorRef.RestoreValue(someActorValueRef,Amount)

You really should read up on programming basics and Papyrus idioms if you want to write more complex scripts. The Creation Kit wiki at https://wiki.creationkit.com/fallout4/ provides a tutorial and a Papyrus object and function reference which you should get familiar with. If you're not some programmer prodigy, not reading that stuff will make you write horrible Papyrus code that will end up breaking things. Trust me, I have written horrible Papyrus code that did break things as a newbie. Don't do that for things you want to release.

Thank you . And if I want to set player's health at X , how I make it ?

Link to comment
Share on other sites

Game.GetPlayer().DamageActorValue("Health", Game.GetPlayer().GetActorValue("Health") - 25)

I think that should do it. But don't quote me.

 

~GKX

 

 

Except there's no function DamageActorValue() anywhere. You mean DamageValue(). Rest seems fine - GetActorValue() obviously has to be GetValue() instead too.

 

Sorry for quoting. ;)

 

@haohao: You always want to base your calculation of how much to DamageValue() on the live value you get from playerRef.GetValue(HealthAV). Hard-coded numbers are bad. You can also get the health percentage with playerRef.GetValuePercentage(HealthAV). There's several ways how you could do this but it's just math so I'll leave that to you to figure out. ;)

Link to comment
Share on other sites

 

And I saw “playerREF" "AKactor" ....everywhere ,I guess these all mean the "PLAYER" , What is the different? Why we use various name?

 

If you use the property name "playerRef" CreationKit will auto-populate that property with the correct form. That's why most people use it.

 

You can use any other property name you like. But, then you will need to populate it manually.

 

Or, as others have pointed out, you can not use a property at all and replace with "Game.GetPlayer()" to get a reference to the same form.

 

I'm not quite sure what "akActor" stands for. I would be curious to know. But, that is usually just a Function parameter and could be renamed throughout a function without consequence.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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