Jump to content

Closet Actor


pitvenin

Recommended Posts

Finally! Here it is

 


ref rTarget
ref rClosestRef

float Distance
float maxdistance

begin GameMode

	if iEnableSearch == 1                                             ;this is a global variable (make sure to define it)
                       set maxdistance to 1000                                ;define de maxium range for searching

		set rTarget to GetFirstRef 200 0 0
		set rClosestRef to rTarget
		set Distance to rTarget.GetDistance player
		set iActorCount To GetNumRefs 200 0             ;this is a global variable (make sure to define it)
Label 1
		if rTarget.getDead == 1 && iActorCount >=1
				set rTarget to Pencil01 
                       	set rTarget to GetNextRef
				set rClosestRef to rTarget
				set  Distance to rTarget.GetDistance Player
				set iActorCount to iActorCount - 1
				goto 1
		endif

               if rTarget  &&  Distance <= maxdistance && iActorCount >= 1
                      	if rTarget.GetDistance Player < Distance
                               	set rClosestRef to rTarget
                               	set  Distance to rClosestRef.GetDistance Player
				endif
                       	set rTarget to Pencil01 
                       	set rTarget to GetNextRef
				set iActorCount to iActorCount - 1
				goto 1
		endif

			if rClosestRef
                                       ;do something to the closest actor
				rClosestRef.killActor ; Die *censored*, your in my space!
			endif

		if iActorCount <= 0
					set iEnableSearch to 0
		endif
	endif
end

 

Each time iEnableSearch is set to 1, this code will get you the closest alive actor in a 1000 range units...and kill it :P

 

Special thanks to rickerhk, it's based on he's script. Also thanks to the rest for making things clear :P

Edited by pitvenin
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...