SHARE
TWEET

Closest Enemy

a guest Sep 17th, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @createlist 'enemies'
  2. @clearlist 'enemies'
  3.  
  4. //
  5. // Scan for targets
  6. //
  7. for 0 to 20
  8.     if murderer 'self'
  9.         @getenemy 'murderer' 'innocent' 'enemy' 'criminal' 'gray' 'humanoid' 'next'
  10.     else
  11.         @getenemy 'murderer' 'enemy' 'criminal' 'gray' 'humanoid' 'next'
  12.     endif
  13.     if @findobject 'enemy'
  14.         @pushlist! 'enemies' 'enemy'
  15.     endif
  16. endfor
  17.  
  18. //
  19. // Create a distances list, seeding from 1
  20. //
  21. @createlist 'distances'
  22. @clearlist 'distances'
  23. pushlist 'distances' 1
  24. pushlist 'distances' 2
  25. pushlist 'distances' 3
  26. pushlist 'distances' 4
  27. pushlist 'distances' 5
  28. pushlist 'distances' 6
  29. pushlist 'distances' 7
  30. pushlist 'distances' 8
  31. pushlist 'distances' 9
  32. pushlist 'distances' 10
  33. pushlist 'distances' 11
  34. pushlist 'distances' 12
  35. pushlist 'distances' 13
  36. pushlist 'distances' 14
  37. pushlist 'distances' 15
  38.  
  39. //
  40. // Sort by distance
  41. //  
  42. @createlist 'closest'
  43. @clearlist 'closest'
  44. for 0 to 'distances'
  45.     if list 'closest' == 0
  46.         for 0 to 'enemies'
  47.             if @inrange enemies[] distances[] and not dead enemies[]
  48.                 pushlist 'closest' 'enemies[]'
  49.                 break
  50.             endif
  51.         endfor
  52.     else
  53.         break
  54.     endif
  55. endfor
  56.  
  57. //
  58. // check if no targets
  59. //
  60. if list 'closest' > 0
  61.     setalias 'enemy' 'closest[0]'
  62.     setalias 'last' 'closest[0]'
  63. else
  64.     headmsg "No targets" 44
  65.     stop
  66. endif
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top