Advertisement
HR_Shaft

Team Race Spawning v1.1 for Phasor v2

Nov 9th, 2013
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 12.06 KB | None | 0 0
  1. --[[ ###  -- Team Race Spawning -- ###]]--
  2. --[[ ###        by H® Shaft        ###]]--
  3. --[[ ###    v 1.1 for Phasor v2    ###]]--
  4.  
  5. -- All players spawn at their own teams base (eliminates random spawning with opposing team which normally instigates slayer-play).  Added thanks to Oxide for spawn view vector update
  6. -- Designed for Team Race
  7.  
  8. -- Designed for these maps only:
  9. -- bloodgulch
  10. -- dangercanyon
  11. -- deathisland
  12. -- gephyrophobia
  13. -- infinity
  14. -- icefields
  15. -- sidewinder
  16. -- timberland
  17.  
  18. red_spawn_coord = {}
  19. blu_spawn_coord = {}
  20. team_play = false
  21.  
  22. function GetRequiredVersion()
  23.     return 200
  24. end
  25.  
  26. function OnScriptLoad(process, game, persistent)
  27.     if game == true or game == "PC" then
  28.         GAME = "PC"
  29.         map_name = readstring(0x698F21)
  30.         gametype_base = 0x671340
  31.     else
  32.         GAME = "CE"
  33.         map_name = readstring(0x61D151)
  34.         gametype_base = 0x5F5498
  35.     end
  36.     team_play = getteamplay()
  37.     LoadCoords()
  38.  
  39. end
  40.  
  41. function OnNewGame(map)
  42.     if GAME == "PC" then
  43.         map_name = readstring(0x698F21)
  44.         gametype_base = 0x671340
  45.     elseif GAME == "CE" then
  46.         map_name = readstring(0x61D151)
  47.         gametype_base = 0x5F5498
  48.     end
  49.     team_play = getteamplay()
  50.     LoadCoords()
  51.    
  52.     if map_name == "bloodgulch" then
  53.         red_rot = createobject(gettagid("scen", "scenery\\flag_base\\flag_base"), 0, 0, false, 60.987, -121.606, 0.274)
  54.         blue_rot = createobject(gettagid("scen", "scenery\\flag_base\\flag_base"), 0, 0, false, 60.987, -121.606, 0.274)
  55.     elseif map_name == "dangercanyon" then
  56.         red_rot = createobject(gettagid("scen", "scenery\\flag_base\\flag_base"), 0, 0, false, -37.219, 0.058, -2.172)
  57.         blue_rot = createobject(gettagid("scen", "scenery\\flag_base\\flag_base"), 0, 0, false, 37.756, 0.404, -2.172) 
  58.     elseif map_name == "deathisland" then
  59.         red_rot = createobject(gettagid("scen", "scenery\\flag_base\\flag_base"), 0, 0, false, -61.327, -9.832, 1.843)
  60.         blue_rot = createobject(gettagid("scen", "scenery\\flag_base\\flag_base"), 0, 0, false, 55.415, 13.656, 1.775)
  61.     elseif map_name == "gephyrophobia" then
  62.         red_rot = createobject(gettagid("scen", "scenery\\flag_base\\flag_base"), 0, 0, false, 26.831, -72.683, -10.699)
  63.         blue_rot = createobject(gettagid("scen", "scenery\\flag_base\\flag_base"), 0, 0, false, 26.831, -72.683, -10.699)
  64.     elseif map_name == "infinity" then
  65.         red_rot = createobject(gettagid("scen", "scenery\\flag_base\\flag_base"), 0, 0, false, 0.676, -164.567, 15.049)
  66.         blue_rot = createobject(gettagid("scen", "scenery\\flag_base\\flag_base"), 0, 0, false, 0.676, -164.567, 15.049)
  67.     elseif map_name == "icefields" then
  68.         red_rot = createobject(gettagid("scen", "scenery\\flag_base\\flag_base"), 0, 0, false, 19.573, -2.920, 0.791)
  69.         blue_rot = createobject(gettagid("scen", "scenery\\flag_base\\flag_base"), 0, 0, false, -72.611, 67.428, 0.781)
  70.     elseif map_name == "sidewinder" then
  71.         red_rot = createobject(gettagid("scen", "scenery\\flag_base\\flag_base"), 0, 0, false, 2.708, 55.001, -2.791)
  72.         blue_rot = createobject(gettagid("scen", "scenery\\flag_base\\flag_base"), 0, 0, false, 2.708, 55.001, -2.791)
  73.     elseif map_name == "timberland" then
  74.         red_rot = createobject(gettagid("scen", "scenery\\flag_base\\flag_base"), 0, 0, false, 16.607, -31.762, -15.401)
  75.         blue_rot = createobject(gettagid("scen", "scenery\\flag_base\\flag_base"), 0, 0, false, -15.884, 31.805, -15.291)
  76.     end
  77. end
  78.  
  79. function getteamplay()
  80.     if readbyte(gametype_base + 0x34) == 1 then
  81.         return true
  82.     else
  83.         return false
  84.     end
  85. end
  86.  
  87. function OnPlayerSpawn(player, m_objectId)
  88.  
  89.     if team_play then
  90.         local team = getteam(player)
  91.         local m_object = getobject(m_objectId)
  92.        
  93.         if team == 0 then
  94.             local redcoord = SelectRedSpawnCoord()
  95.             if redcoord then       
  96.                 movobjectcoords(m_objectId, red_spawn_coord[redcoord][1], red_spawn_coord[redcoord][2], red_spawn_coord[redcoord][3])
  97.                 local fx, fy, fz = getobjectcoords(red_rot)
  98.                 local px, py, pz = getobjectcoords(m_objectId)
  99.                 local vx = fx - px
  100.                 local vy = fy - py
  101.                 local vz = fz - pz
  102.                 -- normalize it
  103.                 local magnitude = math.sqrt(vx*vx + vy*vy + vz*vz)
  104.                 vx = vx / magnitude
  105.                 vy = vy / magnitude
  106.                 vz = vz / magnitude    
  107.                 writefloat(m_object + 0x74, vx)
  108.                 writefloat(m_object + 0x78, vy)
  109.                 writefloat(m_object + 0x7c, vz)                
  110.             end
  111.            
  112.         elseif team == 1 then
  113.             local blucoord = SelectBluSpawnCoord()
  114.             if blucoord then       
  115.                 movobjectcoords(m_objectId, blu_spawn_coord[blucoord][1], blu_spawn_coord[blucoord][2], blu_spawn_coord[blucoord][3])
  116.                 local fx, fy, fz = getobjectcoords(blue_rot)
  117.                 local px, py, pz = getobjectcoords(m_objectId)
  118.                 local vx = fx - px
  119.                 local vy = fy - py
  120.                 local vz = fz - pz
  121.                 -- normalize it
  122.                 local magnitude = math.sqrt(vx*vx + vy*vy + vz*vz)
  123.                 vx = vx / magnitude
  124.                 vy = vy / magnitude
  125.                 vz = vz / magnitude    
  126.                 writefloat(m_object + 0x74, vx)
  127.                 writefloat(m_object + 0x78, vy)
  128.                 writefloat(m_object + 0x7c, vz)                
  129.             end
  130.         end
  131.        
  132.     end        
  133. end
  134.  
  135. function SelectRedSpawnCoord(arg)
  136.     local redspawncount = #red_spawn_coord
  137.     if redspawncount > 0 then
  138.         return getrandomnumber(1, redspawncount+1)
  139.     end
  140.     return nil 
  141. end
  142.  
  143. function SelectBluSpawnCoord(arg)
  144.     local bluspawncount = #blu_spawn_coord
  145.     if bluspawncount > 0 then
  146.         return getrandomnumber(1, bluspawncount+1)
  147.     end
  148.     return nil 
  149. end
  150.  
  151. function LoadCoords()
  152.     if map_name == "bloodgulch" then
  153.         red_spawn_coord[1] = {68.911, -173.686, 1.815}
  154.         red_spawn_coord[2] = {74.323, -173.370, 0.817}
  155.         red_spawn_coord[3] = {79.380, -173.402, 0.410}
  156.         red_spawn_coord[4] = {84.011, -173.499, 0.307}
  157.         red_spawn_coord[5] = {89.487, -173.463, 0.344}
  158.         red_spawn_coord[6] = {95.069, -173.863, 0.718}
  159.         red_spawn_coord[7] = {100.525, -174.038, 0.813}
  160.         red_spawn_coord[8] = {105.292, -173.656, 0.229}
  161.         blu_spawn_coord[1] = {61.292, -65.713, 1.693}
  162.         blu_spawn_coord[2] = {57.520, -65.796, 1.233}
  163.         blu_spawn_coord[3] = {53.473, -66.050, 0.927}
  164.         blu_spawn_coord[4] = {49.578, -66.108, 0.848}
  165.         blu_spawn_coord[5] = {32.593, -65.859, 0.447}
  166.         blu_spawn_coord[6] = {29.079, -65.796, 0.793}
  167.         blu_spawn_coord[7] = {26.038, -65.906, 1.243}
  168.         blu_spawn_coord[8] = {23.010, -65.879, 1.813}
  169.        
  170.     elseif map_name == "dangercanyon" then
  171.    
  172.         red_spawn_coord[1] = {-16.254, -1.222, -4.030}
  173.         red_spawn_coord[2] = {-16.235, -5.483, -4.030}
  174.         red_spawn_coord[3] = {-15.767, 2.010, -4.000}
  175.         red_spawn_coord[4] = {-14.096, -7.125, -4.000}
  176.         red_spawn_coord[5] = {-6.198, -0.202, -4.028}
  177.         red_spawn_coord[6] = {-8.746, -7.146, -4.025}
  178.         red_spawn_coord[7] = {-3.195, -6.566, -4.022}
  179.         red_spawn_coord[8] = {-3.244, -1.144, -4.028}
  180.         blu_spawn_coord[1] = {16.140, -1.544, -4.030}
  181.         blu_spawn_coord[2] = {16.068, -5.484, -4.030}
  182.         blu_spawn_coord[3] = {15.730, 1.627, -3.990}
  183.         blu_spawn_coord[4] = {13.715, -7.029, -3.990}
  184.         blu_spawn_coord[5] = {3.785, -1.194, -4.028}
  185.         blu_spawn_coord[6] = {3.375, -6.669, -4.022}
  186.         blu_spawn_coord[7] = {5.585, -1.158, -3.998}
  187.         blu_spawn_coord[8] = {8.429, -6.587, -4.025}   
  188.        
  189.     elseif map_name == "deathisland" then
  190.    
  191.         red_spawn_coord[1] = {-36.889, -4.007, 9.417}
  192.         red_spawn_coord[2] = {-36.853, -9.937, 9.417}
  193.         red_spawn_coord[3] = {-38.445, -2.989, 5.744}
  194.         red_spawn_coord[4] = {-37.452, -11.724, 5.056}
  195.         red_spawn_coord[5] = {-39.155, -5.780, 5.225}
  196.         red_spawn_coord[6] = {-39.095, -8.268, 5.064}
  197.         red_spawn_coord[7] = {-41.475, -5.493, 4.936}
  198.         red_spawn_coord[8] = {-41.673, -8.819, 4.706}
  199.         blu_spawn_coord[1] = {40.430, 13.260, 8.050}
  200.         blu_spawn_coord[2] = {40.381, 18.714, 8.050}
  201.         blu_spawn_coord[3] = {40.268, 11.340, 4.605}
  202.         blu_spawn_coord[4] = {40.245, 20.333, 4.498}
  203.         blu_spawn_coord[5] = {42.548, 15.075, 4.772}
  204.         blu_spawn_coord[6] = {42.434, 17.335, 4.657}
  205.         blu_spawn_coord[7] = {44.715, 15.356, 4.298}
  206.         blu_spawn_coord[8] = {44.632, 17.430, 4.509}
  207.        
  208.     elseif map_name == "gephyrophobia" then
  209.    
  210.         red_spawn_coord[1] = {23.064, -126.660, -15.626}
  211.         red_spawn_coord[2] = {25.562, -125.415, -15.624}
  212.         red_spawn_coord[3] = {28.091, -125.388, -15.624}
  213.         red_spawn_coord[4] = {30.670, -126.631, -15.626}
  214.         red_spawn_coord[5] = {21.893, -123.528, -15.632}
  215.         red_spawn_coord[6] = {23.724, -124.808, -15.628}
  216.         red_spawn_coord[7] = {29.853, -124.809, -15.628}
  217.         red_spawn_coord[8] = {31.707, -123.409, -15.632}
  218.         blu_spawn_coord[1] = {23.085, -17.469, -15.626}
  219.         blu_spawn_coord[2] = {25.546, -18.771, -15.624}
  220.         blu_spawn_coord[3] = {28.144, -18.726, -15.624}
  221.         blu_spawn_coord[4] = {30.708, -17.435, -15.626}
  222.         blu_spawn_coord[5] = {21.866, -20.804, -15.632}
  223.         blu_spawn_coord[6] = {25.564, -21.533, -15.632}
  224.         blu_spawn_coord[7] = {28.048, -21.506, -15.632}
  225.         blu_spawn_coord[8] = {31.697, -20.837, -15.631}
  226.  
  227.     elseif map_name == "infinity" then
  228.    
  229.         red_spawn_coord[1] = {-4.009, -141.548, 13.948}
  230.         red_spawn_coord[2] = {-6.345, -138.274, 12.774}
  231.         red_spawn_coord[3] = {-9.914, -139.481, 12.981}
  232.         red_spawn_coord[4] = {-13.352, -137.575, 13.256}
  233.         red_spawn_coord[5] = {-11.814, -135.970, 13.288}
  234.         red_spawn_coord[6] = {-9.080, -134.124, 12.868}
  235.         red_spawn_coord[7] = {-6.184, -134.323, 12.745}
  236.         red_spawn_coord[8] = {-8.609, -137.069, 12.865}
  237.         blu_spawn_coord[1] = {15.132, -140.947, 12.237}
  238.         blu_spawn_coord[2] = {7.642, -140.089, 12.666}
  239.         blu_spawn_coord[3] = {5.193, -142.325, 13.779}
  240.         blu_spawn_coord[4] = {13.618, -138.929, 11.898}
  241.         blu_spawn_coord[5] = {16.507, -132.527, 14.684}
  242.         blu_spawn_coord[6] = {14.987, -136.355, 12.257}
  243.         blu_spawn_coord[7] = {9.523, -135.474, 12.582}
  244.         blu_spawn_coord[8] = {6.412, -133.836, 12.622}
  245.        
  246.     elseif map_name == "icefields" then
  247.    
  248.         red_spawn_coord[1] = {33.716, -30.292, 0.814}
  249.         red_spawn_coord[2] = {28.352, -33.786, 1.779}
  250.         red_spawn_coord[3] = {21.291, -33.896, 1.742}
  251.         red_spawn_coord[4] = {18.527, -33.562, 0.919}
  252.         red_spawn_coord[5] = {36.429, -26.407, 0.852}
  253.         red_spawn_coord[6] = {13.779, -25.712, 0.865}
  254.         red_spawn_coord[7] = {14.735, -26.288, 0.755}
  255.         red_spawn_coord[8] = {34.516, -25.876, 0.787}
  256.         blu_spawn_coord[1] = {-84.048, 97.797, 1.206}
  257.         blu_spawn_coord[2] = {-81.324, 98.501, 1.873}
  258.         blu_spawn_coord[3] = {-74.521, 98.328, 1.805}
  259.         blu_spawn_coord[4] = {-71.704, 97.779, 0.874}
  260.         blu_spawn_coord[5] = {-67.641, 91.366, 0.786}
  261.         blu_spawn_coord[6] = {-87.249, 91.701, 0.730}
  262.         blu_spawn_coord[7] = {-67.949, 90.537, 0.749}
  263.         blu_spawn_coord[8] = {-86.628, 90.800, 0.746}
  264.        
  265.     elseif map_name == "sidewinder" then
  266.    
  267.         red_spawn_coord[1] = {-28.435, -29.414, -3.84}
  268.         red_spawn_coord[2] = {-30.924, -28.509, -3.841}
  269.         red_spawn_coord[3] = {-33.996, -28.264, -3.835}
  270.         red_spawn_coord[4] = {-36.305, -28.492, -3.744}
  271.         red_spawn_coord[5] = {-41.707, -28.023, -3.745}
  272.         red_spawn_coord[6] = {-35.948, -24.355, -3.607}
  273.         red_spawn_coord[7] = {-27.586, -27.538, -3.841}
  274.         red_spawn_coord[8] = {-23.380, -28.505, -3.841}
  275.         blu_spawn_coord[1] = {33.463, -33.008, -3.841}
  276.         blu_spawn_coord[2] = {31.670, -32.148, -3.815}
  277.         blu_spawn_coord[3] = {29.094, -32.326, -3.803}
  278.         blu_spawn_coord[4] = {27.602, -32.158, -3.776}
  279.         blu_spawn_coord[5] = {38.559, -30.418, -3.839}
  280.         blu_spawn_coord[6] = {34.422, -27.695, -3.648}
  281.         blu_spawn_coord[7] = {26.203, -27.890, -3.658}
  282.         blu_spawn_coord[8] = {21.464, -30.625, -3.841}
  283.        
  284.     elseif map_name == "timberland" then
  285.    
  286.         red_spawn_coord[1] = {24.903, -49.360, -17.249}
  287.         red_spawn_coord[2] = {23.912, -45.946, -17.514}
  288.         red_spawn_coord[3] = {20.483, -48.143, -17.734}
  289.         red_spawn_coord[4] = {20.946, -50.218, -17.584}
  290.         red_spawn_coord[5] = {18.867, -45.628, -18.047}
  291.         red_spawn_coord[6] = {15.356, -45.680, -17.951}
  292.         red_spawn_coord[7] = {13.913, -48.065, -17.71}
  293.         red_spawn_coord[8] = {10.964, -48.303, -17.250}
  294.        
  295.         blu_spawn_coord[1] = {-23.846, 50.052, -17.228}
  296.         blu_spawn_coord[2] = {-19.738, 48.242, -17.692}
  297.         blu_spawn_coord[3] = {-17.530, 46.434, -17.954}
  298.         blu_spawn_coord[4] = {-15.200, 46.523, -17.872}
  299.         blu_spawn_coord[5] = {-13.178, 48.048, -17.714}
  300.         blu_spawn_coord[6] = {-7.965, 47.485, -17.085}
  301.         blu_spawn_coord[7] = {-12.055, 49.968, -17.395}
  302.         blu_spawn_coord[8] = {-20.413, 50.131, -17.395}
  303.        
  304.     end
  305. end
  306.  
  307. -- Created by H® Shaft thank you to Oxide, AelitePrime, Nugget & Wizard.
  308. -- Visit http://halorace.org/forum/index.php?topic=514.0 or
  309. -- Visit http://pastebin.com/u/HR_Shaft for more phasor scripts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement