Detecting actors

Post » Wed Jun 20, 2012 1:30 am

Hi I am trying to make a script which searches an area around the player for an actor who is a certain race.

In ES4 CS I made the same script however it used the GetFirstRef function which I dont think works in papyrus.

Below is the script I used previously
ref curActorshort cantWait; set to 1 if we find a hostile actorshort doOncebegin gameMode	set cantWait to 0	set curActor to GetFirstRef 69 ; find the first actor within the player's area	Label 10; use a loop to iterate over all actors in the area	  if (curActor); did we get a valid actor?		if (curActor.GetDead == 0)		  if (curActor.getAV aggression > 5 && curActor.getDisposition player < curActor.getAV aggression && curActor.GetDistance player <= 2000 ); is true if actor is hostile			set cantWait to 1		  endif	   endif			if (cantWait == 0); if we didn't find any hostile actors yet...		  set curActor to GetNextRef; then get next actor...		  Goto 10; and go to top of loop		endif	  endif   ; end of loop	if cantWait == 1if doOnce == 0  if ((player.getequipped sting == 1) && (player.isweaponout == 1) && ((getcurrenttime < 5) || (getcurrenttime > 19)) || (player.IsInInterior == 1) || (IsRaining == 1))   Player.PlayMagicShaderVisuals effectFrostShield, 3   set doOnce to 1	  endif	 endif	else	   Player.StopMagicShaderVisuals effectFrostShield  set doOnce to 0	endif

Is there a way to search for actors within an area using papyrus?

Any help would be much appreciated.

Thanks
User avatar
Lil'.KiiDD
 
Posts: 3566
Joined: Mon Nov 26, 2007 11:41 am

Post » Wed Jun 20, 2012 4:44 am

I think you could use this: http://www.gamesas.com/topic/1349649-dynamically-attaching-scripts-to-actors-near-the-player/

Basically, getting closest actor, race whatever you need using reference alias search and condition functions and adding a getdistance limitation if needed.
User avatar
jessica breen
 
Posts: 3524
Joined: Thu Aug 03, 2006 1:04 am

Post » Tue Jun 19, 2012 4:37 pm

Thanks very much, taking a look at that now.
User avatar
Maya Maya
 
Posts: 3511
Joined: Wed Jul 05, 2006 7:35 pm

Post » Wed Jun 20, 2012 6:25 am

You could use the Detect Life Effect and process the results to obtain nearby actor race.
User avatar
Marine x
 
Posts: 3327
Joined: Thu Mar 29, 2007 4:54 am


Return to V - Skyrim