Advertisement
HR_Shaft

Fling Race v2 for Sapp

Apr 14th, 2016
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 21.03 KB | None | 0 0
  1. -- Fling Race v2  - for bloodgulch, gephyrophobia, deathisland, dangercanyon & sidewinder PC/CE stock maps
  2. -- by H® Shaft for SAPP
  3.  
  4. -- A fun bloodgulch, gephyrophobia, deathisland, dangercanyon & sidewinder PC/CE race variant which flings players in vehicles from one location to another, or launches them
  5. -- Note: Best results: the race gametype should have race navs in "Normal Order" - NOT "Any Order" or "Rally" but - will still work regardless
  6. -- if script is loaded on a gametype other than race, it will skip to next map, and log error in the sapp log
  7.  
  8. -- NOte: for best experience - sidewinder race navs should be set to In-Order, NOT any-order
  9.  
  10. -- sapp api version
  11. api_version = "1.9.0.0"
  12.  
  13. function OnScriptLoad()
  14.     register_callback(cb['EVENT_TICK'],"OnTick")
  15.     register_callback(cb['EVENT_GAME_START'], "OnNewGame")
  16.     register_callback(cb['EVENT_JOIN'],"OnPlayerJoin")
  17.     if get_var(0, "$gt") ~= "n/a" then
  18.         if get_var(0, "$gt") == "race" then
  19.             CreateMarkers()
  20.         else
  21.             cprint("This script is intended for RACE gametypes only.")
  22.         end            
  23.     end
  24. end
  25.  
  26. function OnNewGame()
  27.     map_name = get_var(0,"$map")
  28.     if get_var(0, "$gt") == "race" then
  29.         CreateMarkers()
  30.     else
  31.         cprint("This script is intended for RACE gametypes only.")
  32.         local data = string.format("%s on %s: fling-race script is intended for RACE gametypes only.", tostring(map_name), tostring(get_var(0, "$gt")))
  33.         execute_command("log_note \""..data.."\"")
  34.         execute_command("sv_map_next")
  35.         return
  36.     end
  37. end
  38.  
  39. function OnPlayerJoin(PlayerIndex)
  40.     announce = timer(12000, "timedannounce", PlayerIndex)
  41. end
  42.  
  43. function timedannounce(PlayerIndex)
  44.     if player_present(PlayerIndex) then
  45.         rprint(PlayerIndex, "|c CAUTION: Wormholes detected and marked with flags!")
  46.     end
  47.     return false   
  48. end
  49.  
  50. function CreateMarkers()
  51.     map_name = get_var(0,"$map") -- if reloaded after game started, ensure map name is read
  52.     if map_name == "gephyrophobia" then
  53.         execute_command("disable_object weapons\\flag\\flag")
  54.         execute_command("disable_object powerups\\full-spectrum vision")       
  55.         --nav 0
  56.         local marker1 = spawn_object("eqip", "powerups\\full-spectrum vision", 42.081, -71.723, -12.681)
  57.         --nav 1
  58.         local marker2 = spawn_object("eqip", "powerups\\full-spectrum vision", 26.811, -42.343, -14.451)
  59.         --nav2
  60.         local marker3 = spawn_object("eqip", "powerups\\full-spectrum vision", 11.582, -71.646, -12.681)
  61.         --nav3 - throws player thru center tower hole to lower level
  62.         local marker4 = spawn_object("weap", "weapons\\flag\\flag", 26.822, -101.771, -14.441)
  63.         --nav4 - throws player thru center tower hole back to
  64.         local marker5 = spawn_object("weap", "weapons\\flag\\flag", 26.810, -45.347, -18.321)
  65.         --nav5
  66.         local marker6 = spawn_object("eqip", "powerups\\full-spectrum vision", 26.799, -98.932, -18.321)
  67.         -- below red base teleport to top
  68.         local marker7 = spawn_object("eqip", "powerups\\full-spectrum vision", 26.787, -124.054, -18.315)
  69.         local marker8 = spawn_object("weap", "weapons\\flag\\flag", 26.787, -124.054, -18.315)
  70.         --  below blue base teleport to top
  71.         local marker9 = spawn_object("eqip", "powerups\\full-spectrum vision", 26.80, -20.015, -18.32)
  72.         local marker10 = spawn_object("weap", "weapons\\flag\\flag", 26.80, -20.015, -18.32)           
  73.    
  74.     elseif map_name == "sidewinder" then
  75.         execute_command("disable_object weapons\\flag\\flag")
  76.         execute_command("disable_object powerups\\full-spectrum vision")
  77.         --nav 0
  78.         --local marker1 = spawn_object("eqip", "powerups\\full-spectrum vision", 1.849, 54.577, -2.571)
  79.         --local marker1a = spawn_object("weap", "weapons\\flag\\flag", 1.849, 54.577, -2.571)
  80.         --nav 1
  81.         local marker2 = spawn_object("eqip", "powerups\\full-spectrum vision", -40.485, 32.898, 0.319)
  82.         local marker2a = spawn_object("weap", "weapons\\flag\\flag", -40.485, 32.898, 0.319)
  83.         --nav2
  84.         local marker3 = spawn_object("eqip", "powerups\\full-spectrum vision", 39.157, 29.981, 0.329)
  85.         local marker3a = spawn_object("weap", "weapons\\flag\\flag", 39.157, 29.981, 0.329)
  86.         --nav3
  87.         local marker4 = spawn_object("eqip", "powerups\\full-spectrum vision",  30.345, -46.087, -3.591)
  88.         local marker4a = spawn_object("weap", "weapons\\flag\\flag", 30.345, -46.087, -3.591)
  89.         --nav4
  90.         local marker5 = spawn_object("eqip", "powerups\\full-spectrum vision", 60.645, -150.747, 6.292)
  91.         local marker5a = spawn_object("weap", "weapons\\flag\\flag", -32.035, -42.080, -3.601)
  92.    
  93.     elseif map_name == "bloodgulch" then
  94.         execute_command("disable_object weapons\\flag\\flag")
  95.         execute_command("disable_object powerups\\full-spectrum vision")   
  96.         --nav 0
  97.         local marker1 = spawn_object("eqip", "powerups\\full-spectrum vision", 59.785, -121.995, 0.268)
  98.         local marker1a = spawn_object("weap", "weapons\\flag\\flag", 59.785, -121.995, 0.268)
  99.         --nav 1
  100.         local marker2 = spawn_object("eqip", "powerups\\full-spectrum vision", 95.514, -171.713, 0.329)
  101.         local marker2a = spawn_object("weap", "weapons\\flag\\flag", 95.514, -171.713, 0.329)
  102.         --nav2
  103.         local marker3 = spawn_object("eqip", "powerups\\full-spectrum vision", 40.367, -66.605, 0.640)
  104.         local marker3a = spawn_object("weap", "weapons\\flag\\flag", 40.367, -66.605, 0.640)
  105.         --nav3
  106.         local marker4 = spawn_object("eqip", "powerups\\full-spectrum vision", 71.166, -92.553, 4.665)
  107.         local marker4a = spawn_object("weap", "weapons\\flag\\flag", 71.166, -92.553, 4.665)
  108.         --nav4
  109.         local marker5 = spawn_object("eqip", "powerups\\full-spectrum vision", 60.645, -150.747, 6.292)
  110.         local marker5a = spawn_object("weap", "weapons\\flag\\flag", 60.645, -150.747, 6.292)
  111.    
  112.     elseif map_name == "deathisland" then
  113.         execute_command("disable_object weapons\\flag\\flag")
  114.         local marker1 = spawn_object("weap", "weapons\\flag\\flag", 1.499, -55.629, 1.645)
  115.         local marker2 = spawn_object("weap", "weapons\\flag\\flag", -31.086, 53.225, 10.655)
  116.         local marker3 = spawn_object("weap", "weapons\\flag\\flag", 27.119, 62.588, 1.621)     
  117.    
  118.     elseif map_name == "dangercanyon" then
  119.         execute_command("disable_object weapons\\flag\\flag")
  120.         execute_command("disable_object powerups\\full-spectrum vision")   
  121.         local redbase = spawn_object("weap", "weapons\\flag\\flag", -12.141, -3.438, -1.010)
  122.         local bluebase = spawn_object("weap", "weapons\\flag\\flag", 12.017, -3.437, -0.960)
  123.         local center = spawn_object("weap", "weapons\\flag\\flag", -0.104, 52.28, -0.2)
  124.         local centera = spawn_object("eqip", "powerups\\full-spectrum vision", -0.104, 52.28, -0.2)        
  125.        
  126.     end
  127. end
  128.    
  129. function OnTick()
  130.     for PlayerIndex=1,16 do
  131.         if player_alive(PlayerIndex) then
  132.             local player_object = get_dynamic_player(PlayerIndex)
  133.             local player_obj_id = read_dword(get_player(PlayerIndex) + 0x34)
  134.             local vehicleId = read_dword(player_object + 0x11C)
  135.             local vehicle_object = get_object_memory(vehicleId)
  136.            
  137.             if (player_object ~= 0) then
  138.                 if isinvehicle(PlayerIndex) and PlayerIsDriver(PlayerIndex) then
  139.                     player_obj_id = vehicleId
  140.                    
  141.                     -- bloodgulch specific settings
  142.                     if map_name == "bloodgulch" then
  143.                         local nav1 = inSphere(player_obj_id, 59.785, -121.995, 0.268, 2)
  144.                         local nav2 = inSphere(player_obj_id, 95.514, -171.713, 0.329, 2)
  145.                         local nav3 = inSphere(player_obj_id, 40.367, -66.605, 0.640, 2)
  146.                         local nav4 = inSphere(player_obj_id, 71.166, -92.553, 4.665, 2)
  147.                         local nav5 = inSphere(player_obj_id, 60.645, -150.747, 6.292, 2)   
  148.  
  149.                         if nav1 then
  150.                             moveobject(player_obj_id, 59.818, -121.994, 2.224)
  151.                             write_float(vehicle_object + 0x6C, -0.35)
  152.                             write_float(vehicle_object + 0x68, 0.15)
  153.                             write_float(vehicle_object + 0x70, 0.25)
  154.                             write_float(vehicle_object + 0x8C, 0)
  155.                             write_float(vehicle_object + 0x90, 0)
  156.                             write_float(vehicle_object + 0x94, -0.2)
  157.                             local grunt = generategrunt(grunt)
  158.                             if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end                             
  159.                         end
  160.                        
  161.                         if nav2 then
  162.                             moveobject(player_obj_id, 95.504, -171.680, 2.224)
  163.                             write_float(vehicle_object + 0x6C, 0.89)
  164.                             write_float(vehicle_object + 0x68, -0.388)
  165.                             write_float(vehicle_object + 0x70, 0.265)
  166.                             write_float(vehicle_object + 0x8C, 0)
  167.                             write_float(vehicle_object + 0x90, 0)
  168.                             write_float(vehicle_object + 0x94, -0.2)
  169.                             local grunt = generategrunt(grunt)
  170.                             if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end 
  171.                         end
  172.  
  173.                         if nav3 then
  174.                             moveobject(player_obj_id, 40.427, -66.627, 2.224)
  175.                             write_float(vehicle_object + 0x6C, -0.35)
  176.                             write_float(vehicle_object + 0x68, 0.15)
  177.                             write_float(vehicle_object + 0x70, 0.3)
  178.                             write_float(vehicle_object + 0x8C, 0)
  179.                             write_float(vehicle_object + 0x90, 0)
  180.                             write_float(vehicle_object + 0x94, -0.2)
  181.                             local grunt = generategrunt(grunt)
  182.                             if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end                             
  183.                         end
  184.  
  185.                         if nav4 then
  186.                             moveobject(player_obj_id, 70.608, -96.019, 6.444)
  187.                             write_float(vehicle_object + 0x6C, -0.30)
  188.                             write_float(vehicle_object + 0x68, -0.15)
  189.                             write_float(vehicle_object + 0x70, 0.25)
  190.                             write_float(vehicle_object + 0x8C, 0)
  191.                             write_float(vehicle_object + 0x90, 0)
  192.                             write_float(vehicle_object + 0x94, -0.2)
  193.                             local grunt = generategrunt(grunt)
  194.                             if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end                                 
  195.                         end
  196.  
  197.                         if nav5 then
  198.                             moveobject(player_obj_id, 60.312, -149.034, 7.904)
  199.                             write_float(vehicle_object + 0x6C, 0.25)
  200.                             write_float(vehicle_object + 0x68, 0.11)
  201.                             write_float(vehicle_object + 0x70, 0.20)
  202.                             write_float(vehicle_object + 0x8C, 0)
  203.                             write_float(vehicle_object + 0x90, 0)
  204.                             write_float(vehicle_object + 0x94, -0.2)
  205.                             local grunt = generategrunt(grunt)
  206.                             if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end     
  207.                         end                    
  208.                     end -- end bloodgulch specific settings
  209.                    
  210.                     -- gephyrophobia specific settings
  211.                     if map_name == "gephyrophobia" then
  212.                         local nav3 = inSphere(player_obj_id, 26.797, -101.776, -13.213, 2)
  213.                         local nav5 = inSphere(player_obj_id, 26.804, -45.347, -17.465, 2)
  214.                         local bottomsupred = inSphere(player_obj_id, 26.787, -124.054, -18.315, 2)
  215.                         local bottomsupblu = inSphere(player_obj_id, 26.80, -20.015, -18.32, 2)                    
  216.                         if nav3 then
  217.                             moveobject(player_obj_id, 26.797, -101.776, -10.583)
  218.                             write_float(vehicle_object + 0x6C, 0)
  219.                             write_float(vehicle_object + 0x68, 0)
  220.                             write_float(vehicle_object + 0x6C, 0.52)
  221.                             write_float(vehicle_object + 0x70, 0.15)
  222.                             write_float(vehicle_object + 0x8C, 0)
  223.                             write_float(vehicle_object + 0x90, 0)
  224.                             write_float(vehicle_object + 0x94, 0.2)
  225.                             local grunt = generategrunt(grunt)
  226.                             if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end                             
  227.                         end
  228.                        
  229.                         if nav5 then
  230.                             moveobject(player_obj_id, 26.804, -45.347, -10.445)
  231.                             write_float(vehicle_object + 0x6C, 0)
  232.                             write_float(vehicle_object + 0x68, 0)
  233.                             write_float(vehicle_object + 0x6C, -0.52)
  234.                             write_float(vehicle_object + 0x70, 0.15)
  235.                             write_float(vehicle_object + 0x8C, 0)
  236.                             write_float(vehicle_object + 0x90, 0)
  237.                             write_float(vehicle_object + 0x94, -0.23)
  238.                             local grunt = generategrunt(grunt)
  239.                             if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end                                 
  240.                         end
  241.                        
  242.                         if bottomsupred then -- teleport up
  243.                             moveobject(player_obj_id, 14.227, -93.119, -13.975)
  244.                             local grunt = generategrunt(grunt)
  245.                             if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end                             
  246.                         end
  247.                        
  248.                         if bottomsupblu then -- teleport up
  249.                             moveobject(player_obj_id, 39.58, -51.50, -13.975)
  250.                             local grunt = generategrunt(grunt)
  251.                             if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end                             
  252.                         end
  253.                        
  254.                     end -- end gephyrophobia specific settings
  255.                    
  256.                     -- sidewinder specific settings
  257.                     if map_name == "sidewinder" then
  258.                         local nav1 = inSphere(player_obj_id, 1.849, 54.577, -2.571, 2)
  259.                         local nav2 = inSphere(player_obj_id, -40.485, 32.898, 0.319, 2)
  260.                         local nav3 = inSphere(player_obj_id, 39.157, 29.981, 0.329, 2)
  261.                         local nav4 = inSphere(player_obj_id, 30.345, -46.087, -3.591, 2)
  262.                         local nav5 = inSphere(player_obj_id, -32.035, -42.080, -3.601, 2)
  263.                        
  264.                         -- not used, drivers will be at a pitch angle that is hard to recover from, to enable - remove block comment brackets "--[["   and   "]]--"
  265.                         --[[if nav1 then
  266.                             moveobject(player_obj_id, -1.834, 54.433, -2.181) -- fling0 towards 2nd nav
  267.                             write_float(vehicle_object + 0x6C, -0.17)
  268.                             write_float(vehicle_object + 0x68, -0.30)
  269.                             write_float(vehicle_object + 0x70, 0.15)
  270.                             write_float(vehicle_object + 0x8C, 0)
  271.                             write_float(vehicle_object + 0x90, 0)
  272.                             local grunt = generategrunt(grunt)
  273.                             if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end
  274.                         end]]--
  275.                        
  276.                         if nav2 then
  277.                             moveobject(player_obj_id, -35.444, 35.780, 0.999) -- fling1 towards 3rd nav
  278.                             write_float(vehicle_object + 0x6C, 0.10) -- y
  279.                             write_float(vehicle_object + 0x68, 0.40) -- x
  280.                             write_float(vehicle_object + 0x70, 0.20)
  281.                             write_float(vehicle_object + 0x8C, 0)
  282.                             write_float(vehicle_object + 0x90, 0)
  283.                             write_float(vehicle_object + 0x94, 0.2)
  284.                             local grunt = generategrunt(grunt)
  285.                             if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end                         
  286.                         end
  287.  
  288.                         if nav3 then
  289.                             moveobject(player_obj_id, 39.680, 26.583, 1.419) -- fling2 towards 4th nav
  290.                             write_float(vehicle_object + 0x6C, -0.25)  -- 0.40 + -0.10 towards 1st
  291.                             write_float(vehicle_object + 0x68, -0.02)
  292.                             write_float(vehicle_object + 0x70, 0.20)
  293.                             write_float(vehicle_object + 0x8C, 0)
  294.                             write_float(vehicle_object + 0x90, 0)
  295.                             write_float(vehicle_object + 0x94, 0.2)
  296.                             local grunt = generategrunt(grunt)
  297.                             if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end                         
  298.                         end
  299.  
  300.                         if nav4 then
  301.                             moveobject(player_obj_id, 32.497, -32.823, -1.221) -- fling3 towards 1st nav   
  302.                             write_float(vehicle_object + 0x6C, 0.40)
  303.                             write_float(vehicle_object + 0x68, -0.10)
  304.                             write_float(vehicle_object + 0x70, 0.25)
  305.                             write_float(vehicle_object + 0x8C, 0)
  306.                             write_float(vehicle_object + 0x90, 0)
  307.                             write_float(vehicle_object + 0x94, -0.2)
  308.                             local grunt = generategrunt(grunt)
  309.                             if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end                         
  310.                         end
  311.  
  312.                         if nav5 then
  313.                             moveobject(player_obj_id, -37.935, -29.914, -2.091) -- fling4 towards 1st nav  
  314.                             write_float(vehicle_object + 0x6C, 0.35)
  315.                             write_float(vehicle_object + 0x68, 0.11)
  316.                             write_float(vehicle_object + 0x70, 0.23)
  317.                             write_float(vehicle_object + 0x8C, 0)
  318.                             write_float(vehicle_object + 0x90, 0)
  319.                             write_float(vehicle_object + 0x94, -0.2)
  320.                             local grunt = generategrunt(grunt)
  321.                             if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end                         
  322.                         end
  323.                            
  324.                     end -- end sidewinder specific settings
  325.                    
  326.                     -- deathisland specific settings -- only launches, doesn't fling in a specific direction
  327.                     if map_name == "deathisland" then
  328.                    
  329.                         local nav0 = inSphere(player_obj_id, 1.499, -55.629, 1.645, 2)
  330.                         local nav1 = inSphere(player_obj_id, -24.667, -59.929, 1.645, 2)
  331.                         local nav2 = inSphere(player_obj_id, -48.867, -49.267, 1.645, 2)
  332.                         local nav3 = inSphere(player_obj_id, -55.439, -21.230, 1.762, 2)
  333.                         local nav4 = inSphere(player_obj_id, -61.979, 4.219, 2.491, 2)
  334.                         local nav5 = inSphere(player_obj_id, -68.167, 34.964, 2.688, 2)
  335.                         local nav6 = inSphere(player_obj_id, -51.014, 51.562, 6.718, 2)
  336.                         local nav7 = inSphere(player_obj_id, -31.086, 53.225, 10.655, 2) -- large jump
  337.                         local nav8 = inSphere(player_obj_id, -5.238, 57.429, 2.103, 2)
  338.                         local nav9 = inSphere(player_obj_id, 27.119, 62.588, 1.621, 2)
  339.                         local nav10 = inSphere(player_obj_id, 51.606, 42.879, 1.978, 2)
  340.                         local nav11 = inSphere(player_obj_id, 50.571, 8.179, 2.966, 2)
  341.                         local nav12 = inSphere(player_obj_id, 36.759, -18.843, 4.130, 2)
  342.                         local nav13 = inSphere(player_obj_id, 28.260, -43.767, 2.407, 2)
  343.                        
  344.                         if nav0 then -- traditional lap nav in-order
  345.                             moveobject(player_obj_id, 1.499, -55.629, 5.645)               
  346.                             write_float(vehicle_object + 0x70, 0.24) -- upward velocity
  347.                             write_float(vehicle_object + 0x8C, -0.11) -- roll
  348.                             local grunt = generategrunt(grunt)
  349.                             if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end
  350.                         end    
  351.                            
  352.                         if nav9 then -- in blue base sandy corner
  353.                             moveobject(player_obj_id, 27.119, 62.588, 4.645)               
  354.                             write_float(vehicle_object + 0x70, 0.24) -- upward velocity
  355.                             write_float(vehicle_object + 0x8C, -0.11)   -- roll
  356.                             local grunt = generategrunt(grunt)
  357.                             if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end
  358.                         end    
  359.                        
  360.                         if nav7 then -- large jump
  361.                             moveobject(player_obj_id, -31.086, 53.225, 15.805) -- move directly up a bit tp prevent hitting canyon walls                   
  362.                             write_float(vehicle_object + 0x70, 0.25) -- upward velocity
  363.                             write_float(vehicle_object + 0x94, 0.4) -- spin/yaw neg # is opposite direction
  364.                             local grunt = generategrunt(grunt)
  365.                             if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end                         
  366.                         end                    
  367.                     end -- end deathisland specific settings       
  368.                    
  369.                     -- dangercanyon specific settings
  370.                     if map_name == "dangercanyon" then
  371.                    
  372.                         local redbase = inSphere(player_obj_id, -12.141, -3.438, -1.010, 2)
  373.                         local bluebase = inSphere(player_obj_id, 12.017, -3.437, -0.960, 2)
  374.                         local center = inSphere(player_obj_id, -0.104, 52.28, -8.41, 2)
  375.                        
  376.                         if redbase then -- nav 5 redbase bounceback
  377.                             moveobject(player_obj_id, -12.141, -3.438, 6.270)          
  378.                             write_float(vehicle_object + 0x6C, -0.015)
  379.                             write_float(vehicle_object + 0x68, -0.25)
  380.                             write_float(vehicle_object + 0x70, 0.08)
  381.                             write_float(vehicle_object + 0x8C, 0)
  382.                             write_float(vehicle_object + 0x90, 0)
  383.                             write_float(vehicle_object + 0x94, -0.13)
  384.                             local grunt = generategrunt(grunt)
  385.                             if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end
  386.                         end    
  387.                            
  388.                         if bluebase then -- nav 2 redbase bounceback
  389.                             moveobject(player_obj_id, 12.017, -3.437, 6.270)           
  390.                             write_float(vehicle_object + 0x6C, 0.015)
  391.                             write_float(vehicle_object + 0x68, 0.25)
  392.                             write_float(vehicle_object + 0x70, 0.08)
  393.                             write_float(vehicle_object + 0x8C, 0)
  394.                             write_float(vehicle_object + 0x90, 0)
  395.                             write_float(vehicle_object + 0x94, 0.13)
  396.                             local grunt = generategrunt(grunt)
  397.                             if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end
  398.                         end    
  399.                        
  400.                         if center then -- nav 0 center
  401.                             moveobject(player_obj_id, 0.006, 41.710, -1.709) -- move directly up a bit over center ramps                   
  402.                             write_float(vehicle_object + 0x70, 0.08) -- upward velocity
  403.                             write_float(vehicle_object + 0x94, 0.15) -- spin/yaw    neg # is opposite direction
  404.                             local grunt = generategrunt(grunt)
  405.                             if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end                         
  406.                         end
  407.                     end -- dangercanyon specific settings
  408.    
  409.                 end
  410.             end
  411.         end
  412.     end
  413. end
  414.        
  415. function isinvehicle(PlayerIndex)
  416.     local player_object = get_dynamic_player(PlayerIndex)
  417.     local vehicleId = read_dword(player_object + 0x11C)
  418.     if vehicleId == 0xFFFFFFFF then
  419.         return false
  420.     else
  421.         return true
  422.     end
  423. end
  424.  
  425. function PlayerIsDriver(PlayerIndex)
  426.     if (player_alive(PlayerIndex) == false) then return false end
  427.     local player_object = get_dynamic_player(PlayerIndex)
  428.     local player_object_id = read_dword(get_player(PlayerIndex) + 0x34)
  429.     local vehicleId = read_dword(player_object + 0x11C)
  430.     if (vehicleId == 0xFFFFFFFF) then return false end
  431.     local obj_id = get_object_memory(vehicleId)
  432.     return read_dword(obj_id + 0x324) == player_object_id
  433. end
  434.        
  435. function moveobject(ObjectID, x, y, z)
  436.     local object = get_object_memory(ObjectID)
  437.     if get_object_memory(ObjectID) ~= 0 then
  438.         local veh_obj = get_object_memory(read_dword(object + 0x11C))
  439.         write_vector3d((veh_obj ~= 0 and veh_obj or object) + 0x5C, x, y, z)
  440.     end
  441. end
  442.  
  443. function inSphere(ObjectID, X, Y, Z, R)
  444.     if get_object_memory(ObjectID) ~= 0 then
  445.         local x,y,z = getobjectcoords(ObjectID)
  446.         if (X - x)^2 + (Y - y)^2 + (Z - z)^2 <= R then
  447.             return true
  448.         else
  449.             return false
  450.         end
  451.     end
  452. end
  453.    
  454. function getobjectcoords(ObjectID)
  455.     local object = get_object_memory(ObjectID)
  456.     if get_object_memory(ObjectID) ~= 0 then
  457.         local veh_obj = get_object_memory(read_dword(object + 0x11C))
  458.         if veh_obj ~= 0 then
  459.             object = veh_obj
  460.         end
  461.     end
  462.     return read_vector3d(object + 0x5C)
  463. end
  464.  
  465. function generategrunt(grunt)
  466.     local grunt = {"WEEEE!", "Whoa!", "Holy Crap!", "WTF!", "Fuuuh!", "Efff!", "Nuhuh!", "Arrg!", "GEEEZ!", "Who Flung Poo?!"}
  467.     local rand_grunt = rand(1, #grunt+1)
  468.     local grunt_type = string.format("%s",  grunt[rand_grunt])
  469.     if grunt_type ~= nil then
  470.         return grunt_type
  471.     end
  472. end
  473.  
  474. function OnError(Message)
  475.     print(debug.traceback())
  476. end
  477.    
  478. -- Created by H® Shaft
  479. -- Visit http://halorace.org/forum/index.php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement