louisthird Posted August 6, 2020 Share Posted August 6, 2020 Given you have an ObjectReference that you know is an Actor (i.e. matched in a RefCollectionAlias), is there a way to get actor values? Link to comment Share on other sites More sharing options...
DieFeM Posted August 6, 2020 Share Posted August 6, 2020 (edited) If you need to call a function that is in the scope of the actor script on an object reference, and you know it is an actor, you just need to cast the reference as an actor, for example: Actor theActor = ref As Actor theActor.EnableAI(false)Or, if you are going to use the cast only once, then you can cast it and call the function all in one, like this: (ref As Actor).EnableAI(false)But the function that you are looking for is GetValue, which is part of ObjectReference Script, so you can get an actor value directly from a reference. PS: You can pass the actor value from an ActorValue property but, for the most common ones, you can retrieve them from functions of the game script, like Game.GetHealthAV(), so you can use them like that: float fRefHealth = ref.GetValue(Game.GetHealthAV()) Edited August 6, 2020 by DieFeM Link to comment Share on other sites More sharing options...
Deleted67409046User Posted August 6, 2020 Share Posted August 6, 2020 You get ActorValues directly from the ObjectReference. Use the ObjectReference.GetValue(actorvalue) function, e.g. ActorValue Property Health Auto Const Float CurrentHealth = akRef.GetValue(Health) Link to comment Share on other sites More sharing options...
SKKmods Posted August 6, 2020 Share Posted August 6, 2020 Something that is often inferred but never really explained is inheritance. GetValue() is an ObjectReference script function. It gets the value of an ActorValue which can be attached to many base forms and all ObjectReferences ... not just actors ! An Actor (actually it should probably be called an ActorReference for clarity but is not) is an extension of an ObjectReference. Sometimes confusing as an Actor is also a database form, but that's actually referred to as ActorBase. So you can call GetValue on any ObjectReference or an Actor as it inherits from ObjectReference: ThisObjectReference.GetValue(pHealth) ThisActor.GetValue(pHealth) (ThisActor as ObjectReference).GetValue(pHealth) All part of the merry confusion that is non commercial software development kits. Quality test quiz question: based on this quick explainer would you infer that GetValue() can be called on an ActorBase form that has ActorValues set ? Link to comment Share on other sites More sharing options...
louisthird Posted August 6, 2020 Author Share Posted August 6, 2020 (edited) Excellent answers. I wondered if Papyrus had casting. Something like a reinterpret_cast or dynamic_cast in C++. Thanks for the answers and I will give the casting a try. Just for your reference of my outside-of-modding experience: BSCS/MBA Professional full-stack software developer since 1994 working mostly in C++, Java, Spring, Angular. Only through a good community have you guys been able to pull all this off. Thanks for that. Edited August 6, 2020 by louisthird Link to comment Share on other sites More sharing options...
louisthird Posted August 6, 2020 Author Share Posted August 6, 2020 Compiles fine now. Used TriOxin's technique. Link to comment Share on other sites More sharing options...
Recommended Posts