Guest User

Untitled

a guest
Sep 2nd, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. // -- Getting an AI --
  2. // getAIOfUnitType(integer id)
  3.  
  4. library AIList initializer onInit
  5. globals
  6. public AI whichAI
  7. private AI array ais
  8. private integer count = 0
  9. endglobals
  10.  
  11. private function createAI takes integer id, string behavior, string inspect returns nothing
  12. set ais[count] = AI.create(id,behavior,inspect)
  13. set count = count + 1
  14. endfunction
  15.  
  16. private function onInit takes nothing returns nothing
  17. endfunction
  18.  
  19. public function getAIOfUnitType takes integer id returns Action
  20. local integer i = 0
  21. local AI returnAI = 0
  22. local AI temp = 0
  23. loop
  24. exitwhen i>count
  25. set temp = ais[i]
  26. if(temp!=0)then
  27. if(temp.getId()==id)then
  28. set returnAI = ais[i]
  29. endif
  30. endif
  31. set i = i + 1
  32. endloop
  33. return returnAI
  34. endfunction
  35. endlibrary
Add Comment
Please, Sign In to add comment