Advertisement
HR_Shaft

Block or Replace Object Creation for SAPP

Jul 19th, 2015
399
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.30 KB | None | 0 0
  1. -- Block or Replace Object Creation by H® Shaft for SAPP
  2.  
  3. -- This script will:
  4. -- Help you with replacing one object with another, or blocking it from being created
  5. -- You could disable a weapon with execute_command("disable_object weapons\\plasma_cannon\\plasma_cannon") or in events using disable_object, BUT,
  6. -- why not replace it with a weapon/vehicle/equipment you want?
  7.  
  8. -- Shown at the bottom (approx line 117) is a list of object types and tag names you can use in the OnObjectSpawn function (approx line 48)
  9.  
  10. -- sapp api version
  11. api_version = "1.8.0.0"
  12. -- do not edit --
  13. game_started = false
  14.  
  15. function OnScriptLoad()
  16.     register_callback(cb['EVENT_GAME_START'],"OnNewGame")
  17.     register_callback(cb['EVENT_GAME_END'],"OnGameEnd")
  18.     register_callback(cb['EVENT_SPAWN'],"OnPlayerSpawn")
  19.     register_callback(cb['EVENT_OBJECT_SPAWN'],"OnObjectSpawn")
  20. end
  21.  
  22. function OnScriptUnload() end
  23.  
  24. function OnNewGame()
  25.     game_started = true
  26. end
  27.    
  28. function OnGameEnd()
  29.     game_started = false
  30. end
  31.  
  32. function OnPlayerSpawn(PlayerIndex)
  33.     if game_started then   
  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.             -- do stuff with biped or teams, etc
  38.         end
  39.     end
  40. end
  41.  
  42. -- note: calls to this function must provide both arguments of obj_type & obj_name separated by comma
  43. function get_tag_info(obj_type, obj_name)
  44.     local tag_id = lookup_tag(obj_type, obj_name)
  45.     return tag_id ~= 0 and read_dword(tag_id + 0xC) or nil
  46. end
  47.    
  48. function OnObjectSpawn(PlayerIndex, MapID, ParentID, ObjectID)
  49.     if game_started then -- we only want to replace/block items if there is a game running
  50.    
  51.         -- Note: you cannot replace one object type for another, they must be the same "type."
  52.         -- obj_types: vehi = vehicle, weap = weapon, bipd = biped, eqip = Equipment, proj = Projectiles
  53.         -- obj_names: example: "weapons\\plasma grenade\\plasma grenade" is the obj_name (tag name) for the plasma grenade 
  54.        
  55.         -- Example object replacements:
  56.        
  57.         -- replace frag grenade eqip/equipment with plasma grenades:
  58.         if MapID == get_tag_info("eqip", "weapons\\frag grenade\\frag grenade") then
  59.             return true, get_tag_info("eqip", "weapons\\plasma grenade\\plasma grenade")
  60.         end
  61.  
  62.         -- replace frag grenade proj/projectiles with plasma projectiles (doesn't happen until you throw):
  63.         if MapID == get_tag_info("proj", "weapons\\frag grenade\\frag grenade") then
  64.             return true, get_tag_info("proj", "weapons\\plasma grenade\\plasma grenade")
  65.         end
  66.        
  67.         -- replace chain warthog vehicle with a banshee
  68.         if MapID == get_tag_info("vehi", "vehicles\\rwarthog\\rwarthog") then
  69.             return true, get_tag_info("vehi", "vehicles\\banshee\\banshee_mp")
  70.         end
  71.  
  72.         -- replace rocket warthog vehicle with a banshee
  73.         if MapID == get_tag_info("vehi", "vehicles\\warthog\\mp_warthog") then
  74.             return true, get_tag_info("vehi", "vehicles\\banshee\\banshee_mp")
  75.         end
  76.  
  77.         -- replace the flag (weapon) with a plasma pistol (prevents flag pickup and scoring in CTF)
  78.         if MapID == get_tag_info("weap", "weapons\\flag\\flag") then
  79.             return true, get_tag_info("weap", "weapons\\plasma pistol\\plasma pistol")
  80.         end
  81.  
  82.         -- replace both the rocket launcher and fuel rod gun with a sniper rifle
  83.         if MapID == get_tag_info("weap", "weapons\\plasma_cannon\\plasma_cannon") or  
  84.             MapID == get_tag_info("weap", "weapons\\rocket launcher\\rocket launcher") then
  85.             return true, get_tag_info("weap", "weapons\\sniper rifle\\sniper rifle")
  86.         end    
  87.        
  88.         -- Example block object creation:
  89.        
  90.         -- block the creation of ghost vehicle
  91.         if MapID == get_tag_info("vehi", "vehicles\\ghost\\ghost_mp") then
  92.             return false
  93.         end
  94.  
  95.         -- block the creation of scorpion/tank vehicle
  96.         if MapID == get_tag_info("vehi", "vehicles\\scorpion\\scorpion_mp") then
  97.             return false
  98.         end
  99.        
  100.         -- block the creation of covenant turret
  101.         if MapID == get_tag_info("vehi", "vehicles\\c gun turret\\c gun turret_mp") then
  102.             return false
  103.         end
  104.  
  105.         -- block the creation of the banshees fuel rod (alternate fire) projectile
  106.         -- You will still see it, but it won't actually be there, nor cause damage! (could confuse players)
  107.         if MapID == get_tag_info("proj", "vehicles\\banshee\\mp_banshee fuel rod") then
  108.             return false
  109.         end    
  110.        
  111.  
  112.         -- end --
  113.         return game_started
  114.     end
  115. end
  116. -- --------------------------- OBJECT TYPES AND TAG NAMES ---------------------------------------
  117. -- Legend: | "OBJECT TYPE", "TAG NAME" -- COMMON NAME OR DESCRIPTION  Usage: ("Object Type", "Tag Name")
  118.  
  119. -- BIPD: Biped Object Types and Tag Names for tags available in stock 'Multiplayer' maps
  120.     -- "bipd", "characters\\cyborg\\cyborg" -- Cyborg  (solo/campaign biped - green)
  121.     -- "bipd", "characters\\cyborg_mp\\cyborg_mp" -- Multiplayer Cyborg -- NOTE!! If you block this biped, players won't spawn!    
  122.  
  123. -- EQIP: Equipment Object Types and Tag Names for tags available in stock 'Multiplayer' maps
  124.     -- "eqip", "powerups\\active camouflage" -- Active Camouflage
  125.     -- "eqip", "powerups\\health pack" -- Health Pack
  126.     -- "eqip", "powerups\\over shield" -- Overshield
  127.     -- "eqip", "weapons\\frag grenade\\frag grenade" -- Frag Grenade
  128.     -- "eqip", "weapons\\plasma grenade\\plasma grenade" -- Plasma Grenade
  129.    
  130. -- WEAP: Weapon Object Types and Tag Names for tags available in stock 'Multiplayer' maps  
  131.     -- "weap", "weapons\\assault rifle\\assault rifle" -- Assault Rifle
  132.     -- "weap", "weapons\\ball\\ball" -- Oddball or Skull
  133.     -- "weap", "weapons\\flag\\flag" -- Flag
  134.     -- "weap", "weapons\\flamethrower\\flamethrower" -- Flamethrower
  135.     -- "weap", "weapons\\needler\\mp_needler" -- Needler
  136.     -- "weap", "weapons\\pistol\\pistol" -- Pistol
  137.     -- "weap", "weapons\\plasma pistol\\plasma pistol" -- Plasma Pistol
  138.     -- "weap", "weapons\\plasma rifle\\plasma rifle" -- Plasma Rifle
  139.     -- "weap", "weapons\\plasma_cannon\\plasma_cannon" -- Fuel Rod Gun/Plasma Cannon
  140.     -- "weap", "weapons\\rocket launcher\\rocket launcher" -- Rocket Launcher
  141.     -- "weap", "weapons\\shotgun\\shotgun" -- Shotgun
  142.     -- "weap", "weapons\\sniper rifle\\sniper rifle" -- Sniper Rifle
  143.    
  144. -- VEHI: Vehicle Object Types and Tag Names for tags available in stock 'Multiplayer' maps
  145.     -- "vehi", "vehicles\\banshee\\banshee_mp" -- Banshee
  146.     -- "vehi", "vehicles\\c gun turret\\c gun turret_mp" -- Covenant Turret
  147.     -- "vehi", "vehicles\\ghost\\ghost_mp" -- Ghost
  148.     -- "vehi", "vehicles\\rwarthog\\rwarthog" -- Rocket Warthog
  149.     -- "vehi", "vehicles\\scorpion\\scorpion_mp" -- Scorpion
  150.     -- "vehi", "vehicles\\warthog\\mp_warthog" -- Warthog
  151.    
  152. -- PROJ: Projectile Object Types and Tag Names for tags available in stock 'Multiplayer' maps
  153. -- Note: All projectiles except for Frag and Plasma grenades are created 'client side', and will not sync visually: players will see the original projectile, not a replacement
  154.  
  155.     -- "proj", "vehicles\\banshee\\banshee bolt" -- Banshee Bolt
  156.     -- "proj", "vehicles\\banshee\\mp_banshee fuel rod" -- Banshee Fuel Rod
  157.     -- "proj", "vehicles\\c gun turret\\mp gun turret" -- Covenant Turret Bolt
  158.     -- "proj", "vehicles\\ghost\\ghost bolt" -- Ghost Bolt
  159.     -- "proj", "vehicles\\scorpion\\bullet" -- Scorpion Bullet
  160.     -- "proj", "vehicles\\scorpion\\tank shell" -- Scorpion Shell
  161.     -- "proj", "vehicles\\warthog\\bullet" -- Warthog Bullet
  162.     -- "proj", "weapons\\assault rifle\\bullet" -- Assault Rifle Bullet
  163.     -- "proj", "weapons\\flamethrower\\flame" -- Flamethrower Flame
  164.     -- "proj", "weapons\\frag grenade\\frag grenade" -- Frag Grenade Projectile
  165.     -- "proj", "weapons\\needler\\mp_needle" -- Needler Needle
  166.     -- "proj", "weapons\\pistol\\bullet" -- Pistol Bullet
  167.     -- "proj", "weapons\\plasma grenade\\plasma grenade" -- Plasma Grenade Projectile
  168.     -- "proj", "weapons\\plasma pistol\\bolt" -- Plasma Pistol Bolt
  169.     -- "proj", "weapons\\plasma rifle\\bolt" -- Plasma Rifle Bolt
  170.     -- "proj", "weapons\\plasma rifle\\charged bolt" -- Plasma Pistol Charged Bolt
  171.     -- "proj", "weapons\\plasma_cannon\\plasma_cannon" -- Fuel Rod Projectile
  172.     -- "proj", "weapons\\rocket launcher\\rocket" -- Rocket Launcher Rocket
  173.     -- "proj", "weapons\\shotgun\\pellet" -- Shotgun Pellet
  174.     -- "proj", "weapons\\sniper rifle\\sniper bullet" -- Sniper Rifle Bullet
  175.    
  176. -- Note 2: Frag and Plasma grenade projectiles have a ZERO velocity property, if you attempt replacement of them with a pistol bullet, the grenade projectile will land at your feet
  177.  
  178. -- Created by H® Shaft
  179. -- Visit http://halorace.org/forum/index.php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement