Advertisement
Guest User

goomba_stomp.lua

a guest
Jan 22nd, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.56 KB | None | 0 0
  1. -- Config
  2.  
  3. -- The amount to add to a player's kill count on goomba stomp
  4. GOOMBA_KILL_VALUE = 2
  5.  
  6. -- Message to display on goomba stomp
  7. GOOMBA_MESSAGE = "$killer goomba stomped $victim."
  8.  
  9. -- End of config
  10.  
  11. stand_height = nil
  12. crouch_height = nil
  13. biped_collision_radius = nil
  14. game_info_pointer = nil
  15. stats_base = nil
  16.  
  17. api_version = '1.9.0.0'
  18.  
  19. function OnScriptLoad()
  20.     GOOMBA_KILL_VALUE = GOOMBA_KILL_VALUE - 1
  21.     if(halo_type == "CE") then
  22.         game_info_pointer = 0x5F559C
  23.         stats_base = 0x5BD898
  24.         if(read_word(0x6C7964) ~= 0) then
  25.             OnGameStart()
  26.         end
  27.     else
  28.         game_info_pointer = 0x671400
  29.         stats_base = 0x639878
  30.         if(read_word(0x745B84) ~= 0) then
  31.             OnGameStart()
  32.         end
  33.     end
  34.    
  35.     register_callback(cb['EVENT_GAME_START'], 'OnGameStart')
  36.     register_callback(cb['EVENT_TICK'], 'OnTick')
  37. end
  38.  
  39. function OnGameStart()
  40.     stand_height = nil
  41.     crouch_height = nil
  42.     biped_collision_radius = nil
  43.    
  44.     local globals_tag = lookup_tag("matg", "globals\\globals")
  45.     local globals_data = read_dword(globals_tag + 0x14)
  46.     local mp_info_data = read_dword(globals_data + 0x168)
  47.     local player_unit_type = read_dword(mp_info_data + 0x10)
  48.     if(player_unit_type == 0x62697064) then -- checks if unit type is biped
  49.         local biped_metaid = read_dword(mp_info_data + 0x1C)
  50.         if(biped_metaid ~= 0xFFFFFFFF) then
  51.             local biped_tag = lookup_tag(biped_metaid)
  52.             local biped_data = read_dword(biped_tag + 0x14)
  53.            
  54.             stand_height = read_float(biped_data + 0x400) - 0.25
  55.             crouch_height = read_float(biped_data + 0x404) - 0.25
  56.             biped_collision_radius = read_float(biped_data + 0x42C)
  57.         end
  58.     end
  59. end
  60.  
  61. function OnTick()
  62.     if(stand_height == nil) then return end
  63.    
  64.     for i=1,16 do
  65.         if(player_alive(i)) then
  66.             local player = get_dynamic_player(i)
  67.             if(read_bit(player + 0x10, 1) == 1 and read_char(player + 0x500) == -15) then  
  68.                 local bumped_objectid = read_dword(player + 0x4FC)
  69.                 for j=1,16 do
  70.                     if(player_alive(j)) then
  71.                         if(bumped_objectid == read_dword(get_player(j) + 0x34)) then
  72.                             local ffa = get_var(0, "$ffa")
  73.                             local team1 = get_var(i, "$team")
  74.                             local team2 = get_var(j, "$team")
  75.                             if(ffa == "1" or team1 ~= team2) then
  76.                                 local player2 = get_dynamic_player(j)
  77.                            
  78.                                 local x1, y1, z1 = read_vector3d(player + 0x5C)
  79.                                 local x2, y2, z2 = read_vector3d(player2 + 0x5C)
  80.                            
  81.                                 local cs = read_float(player2 + 0x50C)
  82.                                 local h = stand_height - (cs * (stand_height - crouch_height))
  83.                            
  84.                                 local distance = math.sqrt(((x1-x2)*(x1-x2)) + ((y1-y2)*(y1-y2)))
  85.                                
  86.                                 if(z1 > z2+h and distance <= biped_collision_radius*2) then
  87.                                     execute_command(string.format("kills %s +%s", i, GOOMBA_KILL_VALUE))
  88.                                     if(get_var(0, "$gt") == "slayer") then
  89.                                         execute_command(string.format("score %s +%s", i, GOOMBA_KILL_VALUE))
  90.                                         if(ffa == "0") then
  91.                                             execute_command(string.format("team_score %s +%s", team1, GOOMBA_KILL_VALUE))
  92.                                         end
  93.                                     end
  94.                                
  95.                                     local message = GOOMBA_MESSAGE:gsub("$killer", get_var(i,"$name")):gsub("$victim", get_var(j,"$name"))
  96.                                     say_all(message)
  97.                                    
  98.                                     write_dword(player2 + 0x430, read_dword(read_dword(game_info_pointer) + 0xC))
  99.                                     write_float(player2 + 0x434, 9999)
  100.                                     write_dword(player2 + 0x438, read_dword(get_player(i) + 0x34))
  101.                                     write_dword(player2 + 0x43C, read_dword(stats_base + to_real_index(i)*48 + 0x4))
  102.                                    
  103.                                     kill(j)
  104.                                 end
  105.                            
  106.                                 break
  107.                             end
  108.                         end
  109.                     end
  110.                 end
  111.             end
  112.         end
  113.     end
  114. end
  115.  
  116. function OnScriptUnload() end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement