haohao69869 Posted April 10, 2018 Share Posted April 10, 2018 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 More sharing options...
werr92 Posted April 10, 2018 Share Posted April 10, 2018 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 More sharing options...
payl0ad Posted April 10, 2018 Share Posted April 10, 2018 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 PlayerIt 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 More sharing options...
haohao69869 Posted April 11, 2018 Author Share Posted April 11, 2018 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 PlayerIt 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 More sharing options...
LeahTheUnknown Posted April 11, 2018 Share Posted April 11, 2018 Game.GetPlayer().DamageActorValue("Health", Game.GetPlayer().GetActorValue("Health") - 25) I think that should do it. But don't quote me. ~GKX Link to comment Share on other sites More sharing options...
Evangela Posted April 11, 2018 Share Posted April 11, 2018 (edited) Zap. Edited April 12, 2018 by Rasikko Link to comment Share on other sites More sharing options...
payl0ad Posted April 11, 2018 Share Posted April 11, 2018 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 More sharing options...
dagobaking Posted April 11, 2018 Share Posted April 11, 2018 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 More sharing options...
Evangela Posted April 12, 2018 Share Posted April 12, 2018 Oops totally forgot this was the fallout 4 section x_x, yeah DamageAV/ForceAV/SetAV don't exist in the game, two of which were changed. Link to comment Share on other sites More sharing options...
Recommended Posts