Advertisement
HR_Shaft

Replace Plasma Grenades with Frags v1.2 for SAPP

Aug 5th, 2015
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.32 KB | None | 0 0
  1. -- Replace Plasma Grenades with Frags v1.2 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 plasma grenade equipment and projectile with the frag grenade equipment and projectiles
  6.  
  7. -- If you would like to do the opposite; replace Frag Grenades with Plasma, see other script.
  8.  
  9. -- set grenade counts to what you want them. I suggest leaving 'plasma'_count to 0 (zero)
  10. -- Note: plasma count will show, but only frags will be thrown/picked up.
  11.  
  12. frag_count = 2
  13. plasma_count = 0
  14.  
  15. -- sapp api version
  16. api_version = "1.8.0.0"
  17.  
  18. function OnScriptLoad()
  19.     register_callback(cb['EVENT_GAME_START'],"OnNewGame")
  20.     register_callback(cb['EVENT_SPAWN'],"OnPlayerSpawn")
  21.     register_callback(cb['EVENT_OBJECT_SPAWN'],"OnObjectSpawn")
  22.     if get_var(0, "$gt") ~= "n/a" then
  23.         GetMetaIDs()
  24.     end
  25. end
  26.  
  27. function OnScriptUnload() end
  28.  
  29. function OnNewGame()
  30.     GetMetaIDs()
  31. end
  32.  
  33. function OnPlayerSpawn(PlayerIndex)
  34.     -- set grenade counts as they are set above
  35.     if (player_alive(PlayerIndex) == true) then
  36.         local player_object = get_dynamic_player(PlayerIndex)
  37.         safe_write(true)
  38.         write_word(player_object + 0x31E, frag_count)
  39.         write_word(player_object + 0x31F, plasma_count)
  40.         safe_write(false)
  41.     end
  42. end
  43.  
  44. function OnObjectSpawn(PlayerIndex, MapID, ParentID, ObjectID)
  45.     -- Note: you cannot replace one object type for another, they must be the same type.
  46.     -- obj_types: vehi, weap, bipd, eqip, proj
  47.    
  48.     -- replace plasma grenade eqip/equipment with frag grenades:
  49.     if MapID == eqip_plasma_metaid then
  50.         return true, eqip_frag_metaid
  51.     end
  52.  
  53.     -- replace plasma grenade proj/projectiles with frag projectiles (doesn't happen until you throw):
  54.     if MapID == proj_plasma_nade_metaid then
  55.         return true, proj_frag_nade_metaid
  56.     end
  57.    
  58.     -- end --
  59.     return true
  60. end
  61.  
  62. function GetMetaIDs()
  63.     eqip_frag_metaid = read_dword(lookup_tag("eqip", "weapons\\frag grenade\\frag grenade") + 12)
  64.     eqip_plasma_metaid = read_dword(lookup_tag("eqip", "weapons\\plasma grenade\\plasma grenade") + 12)
  65.     proj_plasma_nade_metaid = read_dword(lookup_tag("proj", "weapons\\plasma grenade\\plasma grenade") + 12)
  66.     proj_frag_nade_metaid = read_dword(lookup_tag("proj", "weapons\\frag grenade\\frag grenade") + 12)
  67. end
  68.  
  69. -- Created by H® Shaft
  70. -- Visit http://halorace.org/forum/index.php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement