vinniewryan Posted May 30, 2014 Share Posted May 30, 2014 (edited) Hello, I'm trying to use the following function to obtain an Actor property from the ObjectReference returned by the function. Here's what I have: Event OnCrosshairRefChange(ObjectReference o) Actor a = o.GetBaseObject() as Actor Debug.Notification("Target: " + o) Debug.Notification("Target: " + a)EndEventThis returns: Target: [Form Target: None I'm trying to turn 'a' into the Actor which 'o' is referencing. Any ideas on how I can do this?I also know that none of these are working because in another function, I checked the race of the target Actor / ObjectReference against every race in the game, and it returns False on any target NPC. Thanks! Edited May 30, 2014 by vinniewryan Link to comment Share on other sites More sharing options...
steelfeathers Posted May 30, 2014 Share Posted May 30, 2014 I have problems with this sometimes as well. Try initializing the actor before the event. Also try using 'GetBaseActor' instead of 'GetBaseObject'. Actor a Event OnCrosshairRefChange(ObjectReference o)a = o.GetBaseActor()......EndEvent Link to comment Share on other sites More sharing options...
IsharaMeradin Posted May 30, 2014 Share Posted May 30, 2014 Actor extends object reference which means you do not need to get the base to get the actor reference.Event OnCrosshairRefChange(ObjectReference O) Actor A = O as Actor ;... other stuff EndEventFrom there you can use GetActorBase or GetLeveledActorBase as needed. @steelfeathersGetBaseActor does not exist. I think you meant GetActorBase but that is called on an actor and not an object reference. The compiler would complain about that one. Link to comment Share on other sites More sharing options...
vinniewryan Posted May 30, 2014 Author Share Posted May 30, 2014 (edited) Thank you for the ideas. @ IsharaMeradin, when using the method you've provided, the debug text still returns incorrect data. Sometimes it returns the name of the Actor's attached script, other times it just says "[Actor", or "[ObjectReference" if run on an object. Shouldn't this return the Actor's name? Actor A = O as Actor debug.Notification("Target: " + A)Anyway, even when I try to use:if (a.GetRace() == "BretonRace" || a.GetRace() == "NordRace") - for every single race, they all return "False". GetRace is a member of the Actor script so it seems that that information simply isn't transferring when I use "a = o as Actor" Edit: I tried debug.Notification("Target: " + a.GetBaseObject().GetName())and now it's returning the Actor's name properly. As for GetRace, I had to import a Race property for each Race I wanted to check, and useRace Property SkyrimRace Auto Race r = SkyrimRace Actor a = o as Actor if a.GetRace() == rand now it works :) Edited May 30, 2014 by vinniewryan Link to comment Share on other sites More sharing options...
IsharaMeradin Posted May 30, 2014 Share Posted May 30, 2014 You cannot return an actor's name without using SKSE's GetName() functionGetRace() does not return a string. So your comparisons will always be false. You need to compare it to the desired race records thus you fill properties in the CK with your desired values. Try something like this instead. It requires SKSE if it was not obvious: Reveal hidden contents This should work, but I have not actually tested it.Race Property BretonRace Auto {Variable name same as race record -- auto fill it.} Race Property NordRace Auto {Variable name same as race record -- auto fill it.} Actor TargetActor Event OnCrosshairRefChange(ObjectReference O) If O ;a valid reference If O as Actor ;is an actor TargetActor == O as Actor Debug.Trace("Target Actor: "+TargetActor.GetActorBase().GetName()) If TargetActor.GetActorBase().GetRace() == BretonRace Debug.Trace("Target Actor is a Breton") ElseIf TargetActor.GetActorBase().GetRace() == NordRace Debug.Trace("Target Actor is a Nord") Else Debug.Trace("Target Actor is of some other race") EndIf Endif EndIf EndEvent eh.. you edited while I was typing... saw when I switched to full edit mode. Oh well, leaving it all. Link to comment Share on other sites More sharing options...
Recommended Posts