Advertisement
HR_Shaft

Atomic Grenades for SAPP

Aug 16th, 2015
413
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.48 KB | None | 0 0
  1. -- Atomic Grenades by H® Shaft for SAPP
  2.  
  3. -- This script will:
  4. -- Set Frag and Plasma Grenade counts to what you specify
  5. -- Replace both the frag grenade equipment with the plasma grenade equipment,  and plasma grenade projectile with tank shell projectiles
  6. -- Note: the atomic grenade will go exactly where you aim your weapon - then throw!
  7.  
  8. -- set grenade counts to what you want them. I suggest leaving 'frag' count to 0 (zero)
  9. -- Note: plasma count will show, but only tank shells will be thrown.
  10.  
  11. frag_count = 0
  12. plasma_count = 4
  13.  
  14. -- sapp api version
  15. api_version = "1.8.0.0"
  16. -- do not edit below unless you know what you are doing --
  17. game_started = false
  18.  
  19. function OnScriptLoad()
  20.     register_callback(cb['EVENT_GAME_START'],"OnNewGame")
  21.     register_callback(cb['EVENT_GAME_END'],"OnGameEnd")
  22.     register_callback(cb['EVENT_SPAWN'],"OnPlayerSpawn")
  23.     register_callback(cb['EVENT_OBJECT_SPAWN'],"OnObjectSpawn")
  24.     if get_var(0, "$gt") ~= "n/a" then
  25.         GetMetaIDs()
  26.     end
  27. end
  28.  
  29. function OnScriptUnload() end
  30.  
  31. function OnPlayerSpawn(PlayerIndex)
  32.     if (game_started == true) then
  33.         -- set grenade counts as they are set above
  34.         if (player_alive(PlayerIndex) == true) then
  35.             local player_object = get_dynamic_player(PlayerIndex)
  36.             safe_write(true)
  37.             write_word(player_object + 0x31E, frag_count)
  38.             write_word(player_object + 0x31F, plasma_count)
  39.             safe_write(false)
  40.         end
  41.        
  42.     end
  43. end
  44.  
  45. function OnObjectSpawn(PlayerIndex, MapID, ParentID, ObjectID)
  46.     if game_started then
  47.         -- replace frag grenade equipment with plasma grenades:
  48.         if MapID == eqip_frag_metaid then
  49.             return true, eqip_plasma_metaid
  50.         end        
  51.        
  52.         -- replace plasma grenade proj/projectiles with tank shell projectiles (doesn't happen until you throw):
  53.         if MapID == proj_plasma_nade_metaid then
  54.             return true, proj_tank_shell_metaid
  55.         end
  56.  
  57.         return true
  58.     else
  59.         return false
  60.     end
  61. end
  62.    
  63. function OnNewGame()
  64.     game_started = true
  65.     GetMetaIDs()
  66. end
  67.    
  68. function OnGameEnd()
  69.     game_started = false
  70. end
  71.  
  72. function GetMetaIDs()
  73.     eqip_frag_metaid = read_dword(lookup_tag("eqip", "weapons\\frag grenade\\frag grenade") + 12)
  74.     eqip_plasma_metaid = read_dword(lookup_tag("eqip", "weapons\\plasma grenade\\plasma grenade") + 12)
  75.     proj_plasma_nade_metaid = read_dword(lookup_tag("proj", "weapons\\plasma grenade\\plasma grenade") + 12)
  76.     proj_tank_shell_metaid = read_dword(lookup_tag("proj", "vehicles\\scorpion\\tank shell") + 12)
  77. end
  78.  
  79. -- Created by H® Shaft
  80. -- Visit http://halorace.org/forum/index.php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement