Getting an actor reference by faction

Post » Mon Jun 18, 2012 6:26 pm

I'm new to the whole Papyrus Scripting and Skyrim modding in general. I come from a Web development background so I'm not unfamiliar with learning new programming languages, however, the Skyrim API does appear to be lacking in clarity (Atleast the wiki is) and finding what I want for such a simple task is proving difficult.
I would like, through scripting, to find either a random Actor, or the Nth Actor based on their membership within a faction.

So for example MyActor = GetActorsInFaction(MyFaction)[0] or MyActor = GetRandomActorInFaction(MyFaction)

All the FindActor scripts on the wiki seem to be based on Distance from the player, wheras I don't care if this specific actor is being physically rendered or is even alive (actually, I do care about that, but for the purposes of the request I don't).


I plan on using it to create, well, a shape-shifter. Take on the apperence of another actor. Like a random stormpike, or the players Husband/Wife/Spouse/Life Partner/Galley Slave but I'm utterly stumped as to how to get a reference to an actor by faction.

Any help would be appreciated.
User avatar
Nana Samboy
 
Posts: 3424
Joined: Thu Sep 14, 2006 4:29 pm

Post » Mon Jun 18, 2012 9:31 pm

bump, i'm also intrested in that
User avatar
Verity Hurding
 
Posts: 3455
Joined: Sat Jul 22, 2006 1:29 pm

Post » Mon Jun 18, 2012 6:27 pm

I assume you'd like to find an actor that is in the same cell as player? Or at least within player's vicinity?
Here is some kind of psuedo function that take 2 parameters: Faction and the rank you want to search, then return the correct Actor within 1000 unit from player.
Whenever you want to search for such Actor in your script, just call this function

bool isFoundActor myActorfloat Property searchRadius AutoActor Function findActorByRank (Faction factionREF, int iRank)   myActor = Game.GetPlayer()   while (isFound == False)	  myActor = Game.FindRandomActorFromRef(myActor, searchRadius)	  if (iRank == myActor.GetFactionRank(factionREF))		 isFound = TRUE	  endif   endWhile   return myActorendFunction
User avatar
Lifee Mccaslin
 
Posts: 3369
Joined: Fri Jun 01, 2007 1:03 am

Post » Mon Jun 18, 2012 11:33 am

Unfortunately I actually want to find it in the whole game space. I guess any iterating function is too costly...and all find functions require a radius.
Eg: in my personal case I want to get a reference to the player's wife/husband whichever is that on current game (cause I noticed they are added to a faction) and wherever they are on the whole world.
User avatar
FirDaus LOVe farhana
 
Posts: 3369
Joined: Thu Sep 13, 2007 3:42 am

Post » Mon Jun 18, 2012 5:17 pm

Well, in that case, the best way is to create a Quest, and a new Reference Alias of that quest. You can try to make the game look for certain type of Reference based on conditions. If I remember correctly, it is 'Find Matching Reference', and you can create new conditions for Factions, rank in the box right below.
And last, you might want to start that quest whenever you want to search for that Reference.

If you set up correctly, the engine will attempt to find matching ref no matter where they are in the world.
User avatar
Sista Sila
 
Posts: 3381
Joined: Fri Mar 30, 2007 12:25 pm


Return to V - Skyrim