Advertisement
HR_Shaft

Block or Replace Object Creation v1.2 for SAPP

Aug 5th, 2015
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.13 KB | None | 0 0
  1. -- Block or Replace Object Creation v1.2 by H® Shaft
  2.  
  3. -- This script will:
  4. -- Help you with replacing one object with another, or blocking it from being created, and using the best method for doing so.
  5. -- Note: Not intended as a game script, but a sample script to illustrate replacing one object with another, or blocking it from being created
  6.  
  7. -- Advantage to replacing or blocking an object:
  8. -- You could disable a weapon with execute_command("disable_object weapons\\plasma_cannon\\plasma_cannon") or in events using disable_object, BUT,
  9. -- instead, why not replace it with a weapon/vehicle/equipment/projectile you WANT? Or, block it from being created?
  10.  
  11. -- sapp api version
  12. api_version = "1.8.0.0"
  13.  
  14. function OnScriptLoad()
  15.     register_callback(cb['EVENT_GAME_START'], "OnNewGame")
  16.     register_callback(cb['EVENT_OBJECT_SPAWN'], "OnObjectSpawn")
  17.     if get_var(0, "$gt") ~= "n/a" then
  18.         GetMetaIDs()
  19.     end    
  20. end
  21.  
  22. function OnScriptUnload() end
  23.  
  24. function OnNewGame()
  25.     GetMetaIDs()
  26. end
  27.  
  28. function OnObjectSpawn(PlayerIndex, MapID, ParentID, ObjectID)
  29.     -- note: vehicles, flag/oddball can be ONLY be replaced/blocked using get_tag_info (Examine both below to see the difference).
  30.     -- Weapons, Equipment, Bipeds and Projectiles can use both metaid replacement or get_tag_info methods.
  31.    
  32.     -- replace chain warthog with banshee
  33.     if MapID == get_tag_info("vehi", "vehicles\\warthog\\mp_warthog") then
  34.         return true, get_tag_info("vehi", "vehicles\\banshee\\banshee_mp")
  35.     end
  36.    
  37.     -- replace rocket warthog with banshee
  38.     if MapID == get_tag_info("vehi", "vehicles\\rwarthog\\rwarthog") then
  39.         return true, get_tag_info("vehi", "vehicles\\banshee\\banshee_mp")
  40.     end
  41.        
  42.     -- replace ghost vehicle with a banshee
  43.     if MapID == get_tag_info("vehi", "vehicles\\ghost\\ghost_mp") then
  44.         return true, get_tag_info("vehi", "vehicles\\banshee\\banshee_mp")
  45.     end    
  46.  
  47.     -- replace the active camo with an overshield  
  48.     if MapID == eqip_camo_metaid then
  49.         return true, eqip_overshield_metaid
  50.     end    
  51.    
  52.     -- replace the fuel rod gun with a flame-thrower
  53.     if MapID == weap_fuel_rod_gun_metaid then
  54.         return true, weap_flamer_metaid
  55.     end
  56.    
  57.     -- replace the flame thrower projectile with covie turret bolt - Very anti-banshee flamer- (you will still see the flames, but are shooting the bolt)
  58.     if MapID == proj_flame_metaid then  
  59.         return true, proj_turret_bolt_metaid
  60.     end
  61.    
  62.     -- replace the rocket launcher with a sniper rifle
  63.     if MapID == weap_rocket_launcher_metaid then
  64.         return true, weap_sniper_rifle_metaid
  65.     end
  66.  
  67.     -- replace the pistol with a flame thrower
  68.     if MapID == weap_pistol_metaid then
  69.         return true, weap_flamer_metaid
  70.     end
  71.        
  72.     -- replace frag grenade equipment with plasma grenades:
  73.     if MapID == eqip_frag_metaid then
  74.         return true, eqip_plasma_metaid
  75.     end
  76.    
  77.     -- replace frag grenade projectiles with plasma projectiles (doesn't happen until you throw):
  78.     if MapID == proj_frag_nade_metaid then
  79.         return true, proj_plasma_nade_metaid
  80.     end
  81.    
  82.     -- block the creation of the banshees fuel rod (alternate fire) projectile (you will still see it, but it won't be there, no damage)
  83.     if MapID == proj_banshee_fuelrod_metaid then  
  84.         return false
  85.     end
  86.  
  87.     -- block the creation of scorpion tank
  88.     if MapID == get_tag_info("vehi", "vehicles\\scorpion\\scorpion_mp") then
  89.         return false
  90.     end
  91.    
  92.     -- block the creation of covenant turret
  93.     if MapID == get_tag_info("vehi", "vehicles\\c gun turret\\c gun turret_mp") then
  94.         return false
  95.     end    
  96.    
  97.     return true
  98. end
  99.  
  100. function get_tag_info(obj_type, obj_name)
  101.     local tag_id = lookup_tag(obj_type, obj_name)
  102.     return tag_id ~= 0 and read_dword(tag_id + 0xC) or nil
  103. end
  104.  
  105. -- items commented out here with "--" are still valid, but not used in THIS script, simply remove the "--" to use them in YOUR script
  106. function GetMetaIDs()
  107.     vehi_cov_turret_metaid = read_dword(lookup_tag("vehi", "vehicles\\c gun turret\\c gun turret_mp") + 12)
  108.     vehi_tank_metaid = read_dword(lookup_tag("vehi", "vehicles\\scorpion\\scorpion_mp") + 12)
  109.     vehi_ghost_metaid = read_dword(lookup_tag("vehi", "vehicles\\ghost\\ghost_mp") + 12)
  110.     vehi_banshee_metaid = read_dword(lookup_tag("vehi", "vehicles\\banshee\\banshee_mp") + 12)
  111.     vehi_rocket_hog_metaid = read_dword(lookup_tag("vehi", "vehicles\\rwarthog\\rwarthog") + 12)
  112.     vehi_chain_hog_metaid = read_dword(lookup_tag("vehi", "vehicles\\warthog\\mp_warthog") + 12)
  113.     weap_fuel_rod_gun_metaid = read_dword(lookup_tag("weap", "weapons\\plasma_cannon\\plasma_cannon") + 12)
  114.     weap_rocket_launcher_metaid = read_dword(lookup_tag("weap", "weapons\\rocket launcher\\rocket launcher") + 12)
  115.     weap_sniper_rifle_metaid = read_dword(lookup_tag("weap", "weapons\\sniper rifle\\sniper rifle") + 12)
  116.     --weap_plasma_pistol_metaid = read_dword(lookup_tag("weap", "weapons\\plasma pistol\\plasma pistol") + 12)
  117.     --weap_flag_metaid = read_dword(lookup_tag("weap", "weapons\\flag\\flag") + 12)
  118.     --weap_plasma_rifle_metaid = read_dword(lookup_tag("weap", "weapons\\plasma rifle\\plasma rifle") + 12)
  119.     --weap_assault_rifle_metaid = read_dword(lookup_tag("weap", "weapons\\assault rifle\\assault rifle") + 12)
  120.     weap_flamer_metaid = read_dword(lookup_tag("weap", "weapons\\flamethrower\\flamethrower") + 12)
  121.     --weap_needler_metaid = read_dword(lookup_tag("weap", "weapons\\needler\\mp_needler") + 12)
  122.     weap_pistol_metaid = read_dword(lookup_tag("weap", "weapons\\pistol\\pistol") + 12)
  123.     --weap_shotgun_metaid = read_dword(lookup_tag("weap", "weapons\\shotgun\\shotgun") + 12)   
  124.     eqip_frag_metaid = read_dword(lookup_tag("eqip", "weapons\\frag grenade\\frag grenade") + 12)
  125.     eqip_plasma_metaid = read_dword(lookup_tag("eqip", "weapons\\plasma grenade\\plasma grenade") + 12)
  126.     eqip_camo_metaid = read_dword(lookup_tag("eqip", "powerups\\active camouflage") + 12)
  127.     eqip_overshield_metaid = read_dword(lookup_tag("eqip", "powerups\\over shield") + 12)
  128.     --eqip_health_metaid = read_dword(lookup_tag("eqip", "powerups\\health pack") + 12)
  129.     proj_plasma_nade_metaid = read_dword(lookup_tag("proj", "weapons\\plasma grenade\\plasma grenade") + 12)
  130.     proj_frag_nade_metaid = read_dword(lookup_tag("proj", "weapons\\frag grenade\\frag grenade") + 12)
  131.     proj_banshee_fuelrod_metaid = read_dword(lookup_tag("proj", "vehicles\\banshee\\mp_banshee fuel rod") + 12)
  132.     --proj_banshee_bolt_metaid = read_dword(lookup_tag("proj", "vehicles\\banshee\\banshee bolt") + 12)
  133.     proj_turret_bolt_metaid = read_dword(lookup_tag("proj", "vehicles\\c gun turret\\mp gun turret") + 12)
  134.     --proj_ghost_bolt_metaid = read_dword(lookup_tag("proj", "vehicles\\ghost\\ghost bolt") + 12)
  135.     --proj_tank_bullet_metaid = read_dword(lookup_tag("proj", "vehicles\\scorpion\\bullet") + 12)
  136.     --proj_tank_shell_metaid = read_dword(lookup_tag("proj", "vehicles\\scorpion\\tank shell") + 12)
  137.     --proj_warthog_bullet_metaid = read_dword(lookup_tag("proj", "vehicles\\warthog\\bullet") + 12)
  138.     --proj_assault_bullet_metaid = read_dword(lookup_tag("proj", "weapons\\assault rifle\\bullet") + 12)
  139.     proj_flame_metaid = read_dword(lookup_tag("proj", "weapons\\flamethrower\\flame") + 12)
  140.     --proj_needle_metaid = read_dword(lookup_tag("proj", "weapons\\needler\\mp_needle") + 12)
  141.     --proj_pistol_bullet_metaid = read_dword(lookup_tag("proj", "weapons\\pistol\\bullet") + 12)
  142.     --proj_plasma_pistol_bolt_metaid = read_dword(lookup_tag("proj", "weapons\\plasma pistol\\bolt") + 12)
  143.     --proj_plasma_pistol_charge_metaid = read_dword(lookup_tag("proj", "weapons\\plasma rifle\\charged bolt") + 12)
  144.     --proj_plasma_rifle_bolt_metaid = read_dword(lookup_tag("proj", "weapons\\plasma rifle\\bolt") + 12)
  145.     --proj_fuelrod_metaid = read_dword(lookup_tag("proj", "weapons\\plasma_cannon\\plasma_cannon") + 12)
  146.     --proj_rocket_metaid = read_dword(lookup_tag("proj", "weapons\\rocket launcher\\rocket") + 12)
  147.     --proj_shotgun_pellet_metaid = read_dword(lookup_tag("proj", "weapons\\shotgun\\pellet") + 12)
  148.     --proj_sniper_bullet_metaid = read_dword(lookup_tag("proj", "weapons\\sniper rifle\\sniper bullet") + 12)
  149.     --bipd_campaign_biped_metaid = read_dword(lookup_tag("bipd", "characters\\cyborg\\cyborg") + 12)
  150.     --bipd_mp_biped_metaid = read_dword(lookup_tag("bipd", "characters\\cyborg_mp\\cyborg_mp") + 12)   
  151. end
  152.  
  153. -- Created by H® Shaft with thanks to sehé°° and 002
  154. -- Visit http://halorace.org/forum/index.php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement