Advertisement
Nuor

remove unwanted helis

Oct 30th, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. --edit to debug_cmd_list.script
  2.  
  3. function cmd.heli(me,txt,owner,p)
  4. local wrd = check_and_set_help(me,txt,owner,"[spawn|move|mount|dismount|clean_big|clean_small]")
  5. if not (wrd) then return end
  6.  
  7. if (wrd == "spawn") then
  8. local se_heli = stpk_utils.spawn_heli()
  9. if (se_heli) then
  10. heli_id = se_heli.id
  11. return "heli:= Spawned at actor position"
  12. end
  13. return "heli:= Spawning failed"
  14. end
  15.  
  16. if (wrd == "move") then
  17. local str
  18. if (string.find(txt,"pos:")) then
  19. for s in string.gmatch(txt,"pos:(.%S+)") do
  20. str = s
  21. end
  22. end
  23.  
  24. if (str and str ~= "") then
  25. str = str_explode(str,",")
  26. str.x = tonumber(str[1])
  27. str.y = tonumber(str[2])
  28. str.z = tonumber(str[3])
  29. end
  30.  
  31. local obj = level.object_by_id(heli_id)
  32. local heli = obj and obj:get_helicopter()
  33. if (heli) then
  34. local pos = str or db.actor:position()
  35. heli:SetDestPosition(vector():set(pos.x,pos.y,pos.z))
  36. return "heli:= destination set to actor position"
  37. end
  38. return "heli:= move failed"
  39. end
  40.  
  41. if (wrd == "mount") then
  42. local heli
  43. for id,o in pairs(db.heli) do
  44. heli = o
  45. break
  46. end
  47. if (heli) then
  48. db.actor:attach_vehicle(heli)
  49. return "heli:= mounted"
  50. end
  51. return "heli:= not found"
  52. elseif (wrd == "dismount") then
  53. db.actor:detach_vehicle()
  54. return "heli:= dismounted"
  55. end
  56.  
  57. if (wrd == "clean_big") or wrd == "clean_small" then
  58. local sim = alife()
  59. for id=1,65534 do
  60. if (story_objects.story_id_by_object_id[id] == nil) then
  61. local squad = sim:object(id)
  62. local sec = squad and squad:section_name()
  63. if sec and ((wrd == "clean_big" and sec == "simulation_helicopter_strong") or (wrd == "clean_small" and sec == "simulation_helicopter_weak")) then
  64. if (sim:level_name(game_graph():vertex(squad.m_game_vertex_id):level_id()) == level.name()) then
  65. sim:release(squad, true)
  66. --squad:remove_squad()
  67. end
  68. end
  69. end
  70. end
  71. return (wrd == "clean_big" and "heli:= removed all strong heli") or (wrd == "clean_small" and "heli:= removed all weak heli")
  72. end
  73.  
  74. return "heli:= type heli help for list of sub commands"
  75. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement