Advertisement
HR_Shaft

Vehicle Leap & Emergency Brake 2.0 for Sapp

Aug 13th, 2016
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 14.73 KB | None | 0 0
  1. -- Vehicle Leap & Emergency Brake 2.0
  2. -- by H® Shaft for SAPP
  3.  
  4. -- Allows drivers to activate a vehicle leap (brake key/space bar) and will notify them by message: Vehicle Leap Activated!
  5. -- Allows drivers to activate an emergency brake (crouch key) and will notify them by message: Emergency Brake Activated! this halts forward/reverse and lateral movement
  6. -- Editable parameters allow admins to enable/disable leap/brake per-map, and velocity of the leap
  7. -- Emergency Brake: Can cause the appearance of a lag twich if crouch is pressed and held down, but does not cause any lag whatsoever
  8. -- Supports all stock maps for Halo PC/CE, and you can add your own to the tables below, and should be added to all 3 tables (see bottom)
  9. -- Designed for movable ground vehicles only! Does not work properly for flying vehicles
  10.  
  11. -- Added most CE maps listed here (vehicle races):
  12. -- Complete List of Halo CE Race Maps: http://halorace.org/forum/index.php?topic=499.msg1673#msg1673
  13.  
  14. -- SAPP api version --
  15. api_version = "1.9.0.0"
  16.  
  17. -- do not touch --
  18. brakes = {}
  19. jumps = {}
  20.  
  21. function OnScriptLoad()
  22.     register_callback(cb['EVENT_TICK'],"OnTick")
  23.     register_callback(cb['EVENT_JOIN'],"OnPlayerJoin")
  24.     register_callback(cb['EVENT_LEAVE'],"OnPlayerLeave")
  25.     register_callback(cb['EVENT_GAME_START'],"OnNewGame")
  26.     OnNewGame()
  27. end
  28.  
  29. function OnScriptUnload()
  30. end
  31.  
  32. function OnNewGame()
  33.     map_name = get_var(1,"$map")
  34.     LoadDefaults()
  35.     enable_vehicle_leap[map_name] = enable_vehicle_leap[map_name] or false
  36.     vehicle_velocity[map_name] = vehicle_velocity[map_name] or 0
  37.     emergency_brake[map_name] = emergency_brake[map_name] or false
  38. end
  39.            
  40. function OnTick()
  41.     for i=1,16 do
  42.         local player_dyn = get_dynamic_player(i)
  43.         local name = get_var(i,"$name")
  44.         if (player_dyn ~= 0) then
  45.             local vehicle_objectid = read_dword(player_dyn + 0x11C)
  46.             local vehicle_object = get_object_memory(vehicle_objectid)             
  47.             if (vehicle_object ~= 0) then
  48.                 if PlayerIsDriver(i) then
  49.                     if brakes[i] > 0 then brakes[i] = brakes[i] - 1 end
  50.                     if jumps[i] > 0 then jumps[i] = jumps[i] - 1 end
  51.                     if enable_vehicle_leap[map_name] then
  52.                         -- activated on brake key/space bar
  53.                         if (jumps[i] == 0) and (read_bit(player_dyn + 0x208, 1) == 1) then
  54.                             local vel = (vehicle_velocity[map_name] / 10)
  55.                             jumps[i] = math.floor(4*30)                    
  56.                             say(i, name .. ":  You Activated Vehicle Leap!")
  57.                             write_float(vehicle_object + 0x70, vel)        
  58.                         end
  59.                     end
  60.                     if emergency_brake[map_name] then
  61.                         -- activated on crouch key
  62.                         if (brakes[i] == 0) and (bit.band(read_dword(player_dyn + 0x208),7) == 1) then
  63.                             brakes[i] = math.floor(1.25*30)
  64.                             say(i, name .. ":  You Activated Emergency Brake!")
  65.                             write_float(vehicle_object + 0x68, read_float(vehicle_object + 0x68)*0.05)
  66.                             write_float(vehicle_object + 0x6C, read_float(vehicle_object + 0x6C)*0.05)             
  67.                         end
  68.                     end
  69.                 end
  70.             end
  71.         end
  72.     end
  73. end
  74.  
  75. function OnPlayerJoin(PlayerIndex)
  76.     if player_present(PlayerIndex) then
  77.         brakes[PlayerIndex] = 0
  78.         jumps[PlayerIndex] = 0 
  79.     end
  80. end
  81.  
  82. function OnPlayerLeave(PlayerIndex)
  83.     if player_present(PlayerIndex) then
  84.         brakes[PlayerIndex] = {}
  85.         jumps[PlayerIndex] = {}
  86.     end
  87. end
  88.  
  89. -- Thanks to 002 for this piece:
  90. function PlayerIsDriver(PlayerIndex)
  91.     if (player_present(PlayerIndex) == false) then return false end
  92.     local player_object = get_dynamic_player(PlayerIndex)
  93.     local player_object_id = read_dword(get_player(PlayerIndex) + 0x34)
  94.     local vehicleId = read_dword(player_object + 0x11C)
  95.     if (vehicleId == 0xFFFFFFFF) then return false end
  96.     local obj_id = get_object_memory(vehicleId)
  97.     return read_dword(obj_id + 0x324) == player_object_id
  98. end
  99.  
  100. function LoadDefaults()
  101.     -- Adding a map?   add to tables: enable_vehicle_leap, vehicle_velocity, emergency_brake  You should include the map name in all THREE sections below (yes, tedious)
  102.     -- If the boolean is true for the map then vehicle leap will be enabled for the map, activated by brake key (space bar)
  103.     -- Enable/Disable Leap Table: ensure each line separated by a comma between each line
  104.     -- NOTE: SAPP may not be case sensitive, but LUA IS case sensitive!
  105.     -- The map names shown should be exactly the same as the map's FILE name.  Example: "Bigass" is not the same as "bigass"
  106.     --Note: enclose the 'map name' like ["this"] in the tables below:
  107.     --Example: ["Classic Coagulation"] = true   OR  ["[h3]_sandtrap_race"] = true  
  108.     enable_vehicle_leap = {
  109.     ["beavercreek"] = false,
  110.     ["bloodgulch"] = true,
  111.     ["boardingaction"] = false,
  112.     ["carousel"] = false,
  113.     ["chillout"] = false,
  114.     ["damnation"] = false,
  115.     ["dangercanyon"] = true,
  116.     ["deathisland"] = true,
  117.     ["gephyrophobia"] = true,
  118.     ["hangemhigh"] = false,
  119.     ["icefields"] = true,
  120.     ["infinity"] = true,
  121.     ["longest"] = false,
  122.     ["prisoner"] = false,
  123.     ["putput"] = false,
  124.     ["ratrace"] = false,
  125.     ["sidewinder"] = true,
  126.     ["timberland"] = true,
  127.     ["wizard"] = false,
  128.    
  129.     ["atephobia__V2"] = true,
  130.     ["baconsracetrack"] = true,
  131.     ["bc_raceway_mp"] = true,
  132.     ["bc_raceway_final_bfm_mp"] = true,
  133.     ["Beryl_Rescue"] = true,
  134.     ["Bigass"] = true,
  135.     ["bigassv2,104"] = true,
  136.     ["blizzard"] = true,
  137.     ["Blockfort__Race"] = true,
  138.     ["broadsword_race"] = true,
  139.     ["Camtrack-Arena-FX"] = true,
  140.     ["Camtrack-Arena-Race"] = true,
  141.     ["casualty_isle__V2"] = true,  
  142.     ["Cityscape-Adrenaline"] = true,
  143.     ["ChaosGulchv2"] = true,
  144.     ["Classic Coagulation"] = true,
  145.     ["Celebration_Island"] = true,
  146.     ["Chronopolis_C3_Public_Beta0.2"] = true,
  147.     ["cliffhanger"] = true,
  148.     ["cmt_Snow_Grove"] = false,
  149.     ["CMT_Fragment_v3"] = true,
  150.     ["cmt_g3_vestigial"] = true,
  151.     ["coldsnap"] = true,
  152.     ["coldgulch"] = true,
  153.     ["concealed"] = true,
  154.     ["Crimson_Woods"] = true,
  155.     ["DeathIsland_Race"] = true,
  156.     ["death_karts"] = true,
  157.     ["decoy"] = true,
  158.     ["decoy_race"] = true,
  159.     ["Devils_Drop_Race"] = true,
  160.     ["Equinox_V2"] = true,
  161.     ["extinction"] = true, 
  162.     ["fates_gulch"] = true,
  163.     ["Freezing_Point"] = true,
  164.     ["Gallows"] = true,
  165.     ["Gauntlet_Race"] = true,
  166.     ["Greenvalley_Canyon"] = true,
  167.     ["grove_final"] = true,
  168.     ["h3 foundry"] = true,
  169.     ["halo_hq_race"] = true,
  170.     ["highlow_race"] = true,
  171.     ["Hillbilly Mudbog"] = true,
  172.     ["hogracing_day"] = true,
  173.     ["hogracing_night"] = true,
  174.     ["Hornets_Nest"] = true,
  175.     ["Hypothermia_Race"] = true,
  176.     ["infested"] = true,
  177.     ["islandthunder_race"] = true,
  178.     ["Lake-Natalie"] = true,
  179.     ["Launch_Bay_X"] = true,
  180.     ["Launch Bay"] = true,
  181.     ["LostCove_Race"] = true,
  182.     ["luigi_raceway"] = true,
  183.     ["Massacre_Mountain_Race"] = true,
  184.     ["Mayan_Sacrifice"] = true,
  185.     ["MeatLocker_Race"] = true,
  186.     ["Mongoose_Point"] = true,
  187.     ["Mombasa_Race"] = true,
  188.     ["mudwinder"] = true,
  189.     ["mystic_mod"] = true,
  190.     ["neophobia_beta2"] = true,
  191.     ["Nervous_Canyon_Race"] = true,
  192.     ["Nervous_King"] = true,
  193.     ["nervousking"] = true,
  194.     ["New_Mombasa_Race"] = true,
  195.     ["nightcamp"] = true,
  196.     ["nightcamp_ce"] = true,   
  197.     ["Outpost_Rio_Classic"] = true,
  198.     ["pandora_swamp"] = true,
  199.     ["Phantom"] = true,
  200.     ["pit_race"] = true,
  201.     ["pit_v2"] = true,
  202.     ["pit_v2_top_race"] = true,
  203.     ["portent"] = true,
  204.     ["Prime_C3_Race"] = true,
  205.     ["Quagmire_Daylight"] = true,
  206.     ["siege"] = true,
  207.     ["skullcanyon"] = true,
  208.     ["SkyHarbor [FINAL]"] = true,
  209.     ["snowgrove_1"] = true,
  210.     ["snowtorn_cove"] = true,
  211.     ["starcanyon"] = true,
  212.     ["storm"] = true,
  213.     ["starwars-beta_904"] = true,
  214.     ["the_great_war"] = true,
  215.     ["TLSstronghold"] = true,
  216.     ["Train.Station"] = true,
  217.     ["TrainStation"] = true,
  218.     ["Tusken_Raid"] = true,
  219.     ["twist_beta"] = true,
  220.     ["V993_Down"] = true,
  221.     ["vendetta"] = true,
  222.     ["vestige"] = true,
  223.     ["winder_pass"] = true,
  224.     ["wpitest1_race"] = true,
  225.     ["Yoyorast_Island"] = true,
  226.     ["Yoyorast Island V2"] = true,
  227.     ["[h3] core"] = true,
  228.     ["[h3]_sandtrap_race"] = true, 
  229.     }  
  230.  
  231.     -- Specify the upward leap velocity value for each map that you want
  232.     -- Leap Velocity Table: ensure each line separated by a comma between each line
  233.     vehicle_velocity = {
  234.     ["beavercreek"]             =       0,
  235.     ["bloodgulch"]              =       1.85,
  236.     ["boardingaction"]          =       0,
  237.     ["carousel"]                =       0,
  238.     ["chillout"]                =       0,
  239.     ["damnation"]               =       0,
  240.     ["dangercanyon"]            =       1.65,
  241.     ["deathisland"]             =       2,
  242.     ["gephyrophobia"]           =       1.9,
  243.     ["hangemhigh"]              =       0,
  244.     ["icefields"]               =       1.8,
  245.     ["infinity"]                =       1.85,
  246.     ["longest"]                 =       0,
  247.     ["prisoner"]                =       0,
  248.     ["putput"]                  =       0,
  249.     ["ratrace"]                 =       0,
  250.     ["sidewinder"]              =       2.2,
  251.     ["timberland"]              =       1.8,
  252.     ["wizard"]                  =       0,
  253.    
  254.     ["atephobia__V2"]           =       2,
  255.     ["baconsracetrack"]         =       2,
  256.     ["Bacons_race_track_v2"]    =       1.9,
  257.     ["bc_raceway_mp"]           =       1.8,
  258.     ["bc_raceway_final_bfm_mp"] =       1.8,
  259.     ["Beryl_Rescue"]            =       1.8,
  260.     ["bigassv2,104"]            =       1.9,
  261.     ["Bigass"]                  =       1.9,
  262.     ["blizzard"]                =       1.8,
  263.     ["Blockfort__Race"]         =       1.8,
  264.     ["broadsword_race"]         =       1.8,
  265.     ["Camtrack-Arena-FX"]       =       1.8,
  266.     ["Camtrack-Arena-Race"]     =       1.8,
  267.     ["Chronopolis_C3_Public_Beta0.2"]   =   1.8,   
  268.     ["Classic Coagulation"]     =       1.8,
  269.     ["casualty_isle__V2"]       =       1.8,
  270.     ["celebration_island"]      =       1.8,
  271.     ["Cityscape-Adrenaline"]    =       1.8,
  272.     ["ChaosGulchv2"]            =       1.8,
  273.     ["cliffhanger"]             =       1.8,
  274.     ["CMT_Fragment_v3"]         =       1.8,
  275.     ["cmt_g3_vestigial"]        =       1.8,
  276.     ["cmt_snow_grove"]          =       1.8,
  277.     ["coldgulch"]               =       1.8,
  278.     ["concealed"]               =       1.8,
  279.     ["Crimson_Woods"]           =       1.8,
  280.     ["death_karts"]             =       1.8,
  281.     ["DeathIsland_Race"]        =       1.8,
  282.     ["decoy"]                   =       1.8,
  283.     ["decoy_race"]              =       1.8,
  284.     ["Devils_Drop_Race"]        =       1.8,
  285.     ["Equinox_V2"]              =       1.8,
  286.     ["Facing_WorldsRX"]         =       1.8,
  287.     ["fates_gulch"]             =       1.8,
  288.     ["Freezing_Point"]          =       1.8,
  289.     ["Gallows"]                 =       1.8,
  290.     ["Gauntlet_Race"]           =       1.8,
  291.     ["Greenvalley_Canyon"]      =       1.8,
  292.     ["grove_final"]             =       1.8,
  293.     ["h3 foundry"]              =       1.8,
  294.     ["halo_hq_race"]            =       1.8,
  295.     ["highlow_race"]            =       1.8,
  296.     ["Hillbilly Mudbog"]        =       1.8,
  297.     ["hogracing_day"]           =       2.5,
  298.     ["hogracing_night"]         =       2.5,
  299.     ["Hornets_Nest"]            =       1.8,
  300.     ["Hypothermia_Race"]        =       1.8,
  301.     ["infested"]                =       1.8,
  302.     ["islandthunder_race"]      =       1.8,
  303.     ["Lake-Natalie"]            =       1.8,
  304.     ["Launch_Bay_X"]            =       2,
  305.     ["Launch Bay"]              =       2,
  306.     ["LostCove_Race"]           =       2,
  307.     ["luigi_raceway"]           =       1.8,
  308.     ["Massacre_Mountain_Race"]  =       2,
  309.     ["Mayan_Sacrifice"]         =       1.8,
  310.     ["MeatLocker_Race"]         =       1.8,
  311.     ["Mongoose_Point"]          =       1.8,
  312.     ["Mombasa_Race"]            =       1.8,
  313.     ["Mudwinder"]               =       1.8,
  314.     ["mystic_mod"]              =       2,
  315.     ["neophobia_beta2"]         =       1.8,
  316.     ["Nervous_Canyon_Race"]     =       1.8,
  317.     ["Nervous_King"]            =       1.8,
  318.     ["New_Mombasa_Race"]        =       2.5,
  319.     ["nightglow_v2"]            =       1.8,
  320.     ["nightcamp"]               =       1.8,
  321.     ["nightcamp_ce"]            =       1.8,
  322.     ["Outpost_Rio_Classic"]     =       2.5,
  323.     ["pandora_swamp"]           =       1.8,
  324.     ["Phantom"]                 =       1.8,
  325.     ["pit_v2"]                  =       1.5,
  326.     ["pit_v2_top_race"]         =       2, 
  327.     ["portent"]                 =       1.8,
  328.     ["Prime_C3_Race"]           =       1.8,
  329.     ["Quagmire_Daylight"]       =       1.8,
  330.     ["revelations"]             =       1.8,
  331.     ["siege"]                   =       1.8,
  332.     ["SkyHarbor [FINAL]"]       =       1.8,
  333.     ["skullcanyon"]             =       1.9,
  334.     ["snowtorn_cove"]           =       2,
  335.     ["starcanyon"]              =       1.8,
  336.     ["storm"]                   =       1.8,
  337.     ["TLSstronghold"]           =       1.8,
  338.     ["Train.Station"]           =       1.8,
  339.     ["TrainStation"]            =       1.8,
  340.     ["Tusken_Raid"]             =       1.8,
  341.     ["twist_beta"]              =       1.8,
  342.     ["vendetta"]                =       1.8,
  343.     ["wpitest1_race"]           =       1.8,
  344.     ["nightglow_v2"]            =       1.8,
  345.     ["Yoyorast_Island"]         =       2.5,
  346.     ["Yoyorast Island V2"]      =       1.8,
  347.     ["[h3] core"]               =       1.8,
  348.     ["[h3]_sandtrap_race"]      =       1.8,
  349.     }
  350.  
  351.     -- Specify if you want emergency brake enabled each map, activated by crouch key
  352.     -- Enable/Disable Brake Table: ensure each line separated by a comma between each line
  353.     emergency_brake = {
  354.     ["beavercreek"] = false,
  355.     ["bloodgulch"] = true,
  356.     ["boardingaction"] = false,
  357.     ["carousel"] = false,
  358.     ["chillout"] = false,
  359.     ["damnation"] = false,
  360.     ["dangercanyon"] = true,
  361.     ["deathisland"] = true,
  362.     ["gephyrophobia"] = true,
  363.     ["hangemhigh"] = false,
  364.     ["icefields"] = true,
  365.     ["infinity"] = true,
  366.     ["longest"] = false,
  367.     ["prisoner"] = false,
  368.     ["putput"] = false,
  369.     ["ratrace"] = false,
  370.     ["sidewinder"] = true,
  371.     ["timberland"] = true,
  372.     ["wizard"] = false,
  373.    
  374.     ["atephobia__V2"] = true,
  375.     ["baconsracetrack"] = true,
  376.     ["bc_raceway_mp"] = true,
  377.     ["bc_raceway_final_bfm_mp"] = true,
  378.     ["Beryl_Rescue"] = true,
  379.     ["Bigass"] = true,
  380.     ["bigassv2,104"] = true,
  381.     ["blizzard"] = true,
  382.     ["Blockfort__Race"] = true,
  383.     ["broadsword_race"] = true,
  384.     ["Camtrack-Arena-FX"] = true,
  385.     ["Camtrack-Arena-Race"] = true,
  386.     ["casualty_isle__V2"] = true,  
  387.     ["Cityscape-Adrenaline"] = true,
  388.     ["ChaosGulchv2"] = true,
  389.     ["Classic Coagulation"] = true,
  390.     ["Celebration_Island"] = true,
  391.     ["Chronopolis_C3_Public_Beta0.2"] = true,
  392.     ["cliffhanger"] = true,
  393.     ["cmt_Snow_Grove"] = false,
  394.     ["CMT_Fragment_v3"] = true,
  395.     ["cmt_g3_vestigial"] = true,
  396.     ["coldsnap"] = true,
  397.     ["coldgulch"] = true,
  398.     ["concealed"] = true,
  399.     ["Crimson_Woods"] = true,
  400.     ["DeathIsland_Race"] = true,
  401.     ["death_karts"] = true,
  402.     ["decoy"] = true,
  403.     ["decoy_race"] = true,
  404.     ["Devils_Drop_Race"] = true,
  405.     ["Equinox_V2"] = true,
  406.     ["extinction"] = true, 
  407.     ["fates_gulch"] = true,
  408.     ["Freezing_Point"] = true,
  409.     ["Gallows"] = true,
  410.     ["Gauntlet_Race"] = true,
  411.     ["Greenvalley_Canyon"] = true,
  412.     ["grove_final"] = true,
  413.     ["h3 foundry"] = true,
  414.     ["halo_hq_race"] = true,
  415.     ["highlow_race"] = true,
  416.     ["Hillbilly Mudbog"] = true,
  417.     ["hogracing_day"] = true,
  418.     ["hogracing_night"] = true,
  419.     ["Hornets_Nest"] = true,
  420.     ["Hypothermia_Race"] = true,
  421.     ["infested"] = true,
  422.     ["islandthunder_race"] = true,
  423.     ["Launch_Bay_X"] = true,
  424.     ["Launch Bay"] = true,
  425.     ["LostCove_Race"] = true,
  426.     ["luigi_raceway"] = true,
  427.     ["Massacre_Mountain_Race"] = true,
  428.     ["Mayan_Sacrifice"] = true,
  429.     ["MeatLocker_Race"] = true,
  430.     ["Mongoose_Point"] = true,
  431.     ["Mombasa_Race"] = true,
  432.     ["mudwinder"] = true,
  433.     ["mystic_mod"] = true,
  434.     ["neophobia_beta2"] = true,
  435.     ["Nervous_Canyon_Race"] = true,
  436.     ["Nervous_King"] = true,
  437.     ["nervousking"] = true,
  438.     ["New_Mombasa_Race"] = true,
  439.     ["nightcamp"] = true,
  440.     ["nightcamp_ce"] = true,   
  441.     ["Outpost_Rio_Classic"] = true,
  442.     ["pandora_swamp"] = true,
  443.     ["Phantom"] = true,
  444.     ["pit_race"] = true,
  445.     ["pit_v2"] = true,
  446.     ["pit_v2_top_race"] = true,
  447.     ["portent"] = true,
  448.     ["Prime_C3_Race"] = true,
  449.     ["Quagmire_Daylight"] = true,
  450.     ["siege"] = true,
  451.     ["skullcanyon"] = true,
  452.     ["SkyHarbor [FINAL]"] = true,
  453.     ["snowgrove_1"] = true,
  454.     ["snowtorn_cove"] = true,
  455.     ["starcanyon"] = true,
  456.     ["storm"] = true,
  457.     ["starwars-beta_904"] = true,
  458.     ["the_great_war"] = true,
  459.     ["TLSstronghold"] = true,
  460.     ["Train.Station"] = true,
  461.     ["TrainStation"] = true,
  462.     ["Tusken_Raid"] = true,
  463.     ["twist_beta"] = true,
  464.     ["V993_Down"] = true,
  465.     ["vendetta"] = true,
  466.     ["vestige"] = true,
  467.     ["winder_pass"] = true,
  468.     ["wpitest1_race"] = true,
  469.     ["Yoyorast_Island"] = true,
  470.     ["Yoyorast Island V2"] = true,
  471.     ["[h3] core"] = true,
  472.     ["[h3]_sandtrap_race"] = true, 
  473.     }
  474. end
  475.  
  476. function OnError(Message)
  477.     print(debug.traceback())
  478. end
  479.  
  480. -- Created by H® Shaft
  481. -- Visit http://halorace.org
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement