Advertisement
HR_Shaft

Anti-Gravity + Super Jump for Sapp

Feb 28th, 2018
964
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.53 KB | None | 0 0
  1. -- Anti-Gravity + Super Jump
  2. -- by H® Shaft for SAPP
  3.  
  4. -- Script allows use of dev-mode super-jump in multiplayer combined with editable per-map gravity settings.
  5. -- Reduced gravity on: hangemhigh, boardingaction, prisoner (edit/add your own see gravity_setting in "function LoadDefaults()" - line 139
  6.  
  7. -- Notes:
  8. -- fall damage is off to prevent player damage when landing IF super jump is enabled see gravity_setting in "function LoadDefaults()" - line 159
  9. -- deathplane kills players who fall too far (since fall damage is removed by this script)
  10. -- players sometimes de-sync, (can't see themselves jumping high), it resolves itself shortly, or upon death
  11. -- visually it might seem laggy or twitchy - this is DE-SYNC
  12.  
  13. -- don't edit --
  14. api_version = "1.9.0.0"
  15. game_started = false
  16. gravity_default = 0.003565
  17. super_jump = false
  18. deathplane = -500
  19.  
  20. function OnScriptLoad()
  21.     register_callback(cb['EVENT_SPAWN'], "OnPlayerSpawn")
  22.     register_callback(cb['EVENT_GAME_START'], "OnNewGame")
  23.     register_callback(cb['EVENT_TICK'],"OnTick")
  24.     register_callback(cb['EVENT_GAME_END'], "OnGameEnd")
  25.     register_callback(cb['EVENT_JOIN'], "OnPlayerJoin")
  26.     if get_var(0, "$gt") ~= "n/a" then
  27.         game_started = true
  28.         map_name = get_var(0,"$map")
  29.         LoadDefaults()
  30.         for i = 1, 16 do
  31.             if player_present(i) then
  32.                 OnPlayerSpawn(i)       
  33.             end
  34.         end
  35.         -- deathplane kills players who fall too far (since fall damage is removed by this script)
  36.         if map_name == "boardingaction" then
  37.             deathplane = -10
  38.         elseif map_name == "gephyrophobia" then
  39.             deathplane = -50
  40.         elseif map_name == "damnation" then
  41.             deathplane = -10
  42.         end
  43.         execute_command("gravity " .. gravity_default or 0.003565) 
  44.     end
  45. end
  46.  
  47. function OnGameEnd()
  48.     game_started = false
  49.     gravity_default = 0.003565 
  50.     super_jump = false 
  51. end
  52.  
  53. function OnScriptUnload()
  54.     gravity_setting = {}
  55.     gravity_default = 0.003565
  56.     set_super_jump = {}
  57.     execute_command_sequence('cheat_super_jump 0;cheat_jetpack 0')
  58. end
  59.  
  60. function OnPlayerSpawn(PlayerIndex)
  61.     if (game_started == true) then
  62.         if player_alive(PlayerIndex) then
  63.             write_dword(get_player(PlayerIndex) + 0xF0, 0)
  64.             write_dword(get_player(PlayerIndex) + 0x164, 0)
  65.             if super_jump then
  66.                 execute_command_sequence('cheat_super_jump 1;cheat_jetpack 1', PlayerIndex)
  67.             else
  68.                 execute_command_sequence('cheat_super_jump 0;cheat_jetpack 0', PlayerIndex)
  69.             end
  70.         end
  71.     end
  72. end
  73.  
  74. function OnPlayerJoin(PlayerIndex)
  75.     if (game_started == true) then
  76.         if player_present(PlayerIndex) then
  77.             OnPlayerSpawn(PlayerIndex)
  78.             if gravity_default ~= 0.003565 then
  79.                 rprint(PlayerIndex, "|cANTI-GRAVITY!! - IT AFFECTS EVERYTHING!")
  80.                 if super_jump then
  81.                     rprint(PlayerIndex, "|cSUPER JUMP!! - BE CAREFUL WHEN JUMPING!")
  82.                 end
  83.                 rprint(PlayerIndex, " ")
  84.                 rprint(PlayerIndex, " ")
  85.             end    
  86.         end
  87.     end
  88. end
  89.  
  90. function OnNewGame()
  91.     game_started = true
  92.     map_name = get_var(0,"$map")
  93.     LoadDefaults()
  94.     for i = 1, 16 do
  95.         if player_present(i) then
  96.             if player_present(i) then
  97.                 OnPlayerSpawn(i)
  98.                 if gravity_default ~= 0.003565 then
  99.                     rprint(i, "|cANTI-GRAVITY!! - IT AFFECTS EVERYTHING!")
  100.                     if super_jump then
  101.                         rprint(i, "|cSUPER JUMP!! - BE CAREFUL WHEN JUMPING!")
  102.                     end
  103.                     rprint(i, " ")
  104.                     rprint(i, " ")
  105.                 end    
  106.             end    
  107.             if super_jump then
  108.                 execute_command_sequence('cheat_super_jump 1;cheat_jetpack 1', i)
  109.             else
  110.                 execute_command_sequence('cheat_super_jump 0;cheat_jetpack 0', i)
  111.             end
  112.         end
  113.     end
  114.     execute_command("gravity " .. gravity_default or 0.003565)
  115. end
  116.  
  117. function OnTick()
  118.     if (game_started == true) then
  119.         for PlayerIndex=1,16 do
  120.             if player_present(PlayerIndex) then
  121.                 if player_alive(PlayerIndex) then
  122.                     local player_object = get_dynamic_player(PlayerIndex)
  123.                     local x,y,z = read_vector3d(get_dynamic_player(PlayerIndex) + 0x5C)
  124.                     if (player_object ~= 0) then   
  125.                         write_dword(get_player(PlayerIndex) + 0xF0, 0)
  126.                         write_dword(get_player(PlayerIndex) + 0x164, 0)
  127.                         if map_name == "boardingaction" or map_name == "gephyrophobia" or map_name == "damnation" then
  128.                             if z < deathplane then kill(PlayerIndex) end
  129.                         end
  130.                     end
  131.                 end
  132.             end
  133.         end
  134.     end
  135. end
  136.  
  137. function LoadDefaults()
  138.     -- note: setting gravity to higher than 0.003565 (default gravity) can result in player deaths
  139.     gravity_setting = {
  140.         ["bloodgulch"]          =       0.003565,
  141.         ["dangercanyon"]        =       0.003565,
  142.         ["deathisland"]         =       0.003565,
  143.         ["gephyrophobia"]       =       0.003565,
  144.         ["icefields"]           =       0.003565,
  145.         ["infinity"]            =       0.003565,
  146.         ["sidewinder"]          =       0.003565,
  147.         ["timberland"]          =       0.003565,
  148.         ["hangemhigh"]          =       0.001248,
  149.         ["ratrace"]             =       0.003565,
  150.         ["beavercreek"]         =       0.003565,
  151.         ["damnation"]           =       0.003565,
  152.         ["boardingaction"]      =       0.001248,
  153.         ["carousel"]            =       0.003565,
  154.         ["putput"]              =       0.003565,
  155.         ["prisoner"]            =       0.001248,
  156.         ["wizard"]              =       0.003565
  157.     }
  158.    
  159.     set_super_jump = {
  160.         ["bloodgulch"]          =       false,
  161.         ["dangercanyon"]        =       false,
  162.         ["deathisland"]         =       false,
  163.         ["gephyrophobia"]       =       false,
  164.         ["icefields"]           =       false,
  165.         ["infinity"]            =       false,
  166.         ["sidewinder"]          =       false,
  167.         ["timberland"]          =       false,
  168.         ["hangemhigh"]          =       true,
  169.         ["ratrace"]             =       false,
  170.         ["beavercreek"]         =       false,
  171.         ["damnation"]           =       false,
  172.         ["boardingaction"]      =       true,
  173.         ["carousel"]            =       false,
  174.         ["putput"]              =       false,
  175.         ["prisoner"]            =       true,
  176.         ["wizard"]              =       false
  177.     }
  178.    
  179.     gravity_default = gravity_setting[map_name]
  180.     super_jump = set_super_jump[map_name]
  181.    
  182. end
  183.  
  184. -- Created by H® Shaft
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement