Advertisement
HR_Shaft

Immured Setup for CE Map: immured, sapp

May 26th, 2017
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.05 KB | None | 0 0
  1. -- Immured Setup for CE Map: immured - DL link http://www.mediafire.com/file/9i78q49ynun78pf/immured.zip
  2. -- by H® Shaft
  3.  
  4. -- Sets up Multi-Bipeds based on FFA/Team games:
  5. -- Team Games:
  6. -- Red Team are Grunts
  7. -- Blue Team are Cyborgs
  8. -- FFA Games: Random Player Selection of Cyborg, Grunt or Flood
  9. -- Zombies (team): Use your favorite zombie script, this script will set the Zombie Biped based on your gametype name/mode (see line 176)
  10.  
  11. -- Editable defaults: see Line 124: LoadDefaults() section
  12.  
  13. -- don't edit below --
  14. api_version = "1.9.0.0"
  15.  
  16. function OnScriptLoad()
  17.     register_callback(cb['EVENT_OBJECT_SPAWN'], "OnObjectSpawn")
  18.     register_callback(cb['EVENT_GAME_START'], "OnNewGame")
  19.     register_callback(cb['EVENT_GAME_END'], "OnGameEnd")
  20.     if get_var(0, "$gt") ~= "n/a" then
  21.         OnNewGame()
  22.     end
  23. end
  24.  
  25. function OnNewGame()
  26.     map_name = get_var(0,"$map")
  27.     if map_name ~= "immured" then return end
  28.     LoadDefaults()
  29.     team_play = getteamplay()
  30. end
  31.  
  32. function OnGameEnd()
  33.     OnScriptUnload()
  34. end
  35.  
  36. function OnScriptUnload()
  37.     DEFAULT_BIPED = nil
  38. end
  39.  
  40. function OnObjectSpawn(PlayerIndex, MapID, ParentID, ObjectID)
  41.     if not player_present(PlayerIndex) then return true end
  42.     if map_name ~= "immured" then return true end
  43.     if (DEFAULT_BIPED == nil) then
  44.         local tag_array = read_dword(0x40440000)
  45.         for i=0,read_word(0x4044000C)-1 do
  46.             local tag = tag_array + i * 0x20
  47.             if(read_dword(tag) == 1835103335 and read_string(read_dword(tag + 0x10)) == "globals\\globals") then
  48.                 local tag_data = read_dword(tag + 0x14)
  49.                 local mp_info = read_dword(tag_data + 0x164 + 4)
  50.                 for j=0,read_dword(tag_data + 0x164)-1 do
  51.                     DEFAULT_BIPED = read_dword(mp_info + j * 160 + 0x10 + 0xC)
  52.                 end
  53.             end
  54.         end
  55.     end
  56.  
  57.     if (MapID == DEFAULT_BIPED) then
  58.         local team = get_var(PlayerIndex,"$team")
  59.         local game_mode = get_var(0, "$mode")
  60.         if team_play then
  61.             if game_mode ~= Zombie_Gametype_Name then
  62.                 if team == "red" then
  63.                     return true, grunt_mp_id
  64.                 else
  65.                     return true, cyborg_mp_id
  66.                 end
  67.             else
  68.                 if team == "red" then
  69.                     return true, altis_flood_id
  70.                 else
  71.                     return true, grunt_mp_id
  72.                 end
  73.             end    
  74.         else
  75.             local randbiped = rand(1,4)
  76.             if randbiped == 1 then
  77.                 return true, grunt_mp_id
  78.             elseif randbiped == 2 then
  79.                 return true, cyborg_mp_id
  80.             elseif randbiped == 3 and get_var(0, "$gt") ~= "oddball" and get_var(0, "$gt") ~= "ctf" then
  81.                 return true, altis_flood_id
  82.             else
  83.                 return true, cyborg_mp_id
  84.             end
  85.         end
  86.     end
  87.    
  88.     if get_var(0, "$gt") == "race" then
  89.         if not team_play then
  90.             -- FFA RACE
  91.             -- replace chain_hog_id with with default vehicle (chain hog slot) for FFA Race
  92.             if MapID == chain_hog_id then
  93.                 return true, default_ffa_race_vehicle_1
  94.             end
  95.             --replace ghost_id with with default vehicle (ghost slot) for FFA Race
  96.             if MapID == ghost_id then
  97.                 return true, default_ffa_race_vehicle_2
  98.             end        
  99.             -- replace rocket_hog_id with with default vehicle (rocket hog slot) for FFA Race
  100.             if MapID == rocket_hog_id then
  101.                 return true, default_ffa_race_vehicle_3
  102.             end
  103.            
  104.         elseif team_play then
  105.             -- TEAM RACE
  106.             -- replace chain_hog_id with with default vehicle (chain hog slot) for TEAM Race
  107.             if MapID == chain_hog_id then
  108.                 return true, default_team_race_vehicle_1
  109.             end
  110.             --replace ghost_id with with default vehicle (ghost slot) for TEAM Race
  111.             if MapID == ghost_id then
  112.                 return true, default_team_race_vehicle_2
  113.             end        
  114.             -- replace rocket_hog_id with with default vehicle (rocket hog slot) for TEAM Race
  115.             if MapID == rocket_hog_id then
  116.                 return true, default_team_race_vehicle_3
  117.             end        
  118.         end    
  119.     end
  120.    
  121.     return true
  122. end
  123.  
  124. function LoadDefaults()
  125.  
  126.     --Vehicles:
  127.     chain_hog_id = get_tag_info("vehi", "vehicles\\warthog\\mp_warthog")
  128.     ghost_id  = get_tag_info("vehi", "vehicles\\ghost\\ghost_mp")
  129.     rocket_hog_id = get_tag_info("vehi", "vehicles\\rwarthog\\rwarthog")
  130.     wasp_id = get_tag_info("vehi", "vehicles\\wasp\\wasp_mp")
  131.     turret_id = get_tag_info("vehi", "vehicles\\laag_turret\\laag_turret")
  132.     hoverboard_id = get_tag_info("vehi", "vehicles\\hoverboard\\hoverboard")
  133.     banshee_id = get_tag_info("vehi", "vehicles\\banshee\\banshee_mp")
  134.    
  135.     --Bipeds:
  136.     cyborg_mp_id = get_tag_info("bipd", "nervebooger\\cyborg\\cyborg_mp")
  137.     grunt_mp_id = get_tag_info("bipd", "nervebooger\\grunt\\grunt_mp")
  138.     altis_flood_id = get_tag_info("bipd", "altis\\characters\\flood_human\\altis_flood")
  139.    
  140.     -- VEHICLE IDS: RACE vehicle setup: set the vehicle ID's you prefer for FFA Race and Team Race from these ID's
  141.     -- chain_hog_id, ghost_id, rocket_hog_id, wasp_id, turret_id, hoverboard_id, banshee_id
  142.     -- Note: hoverboard_id, banshee_id (hoverboard/banshee don't spawn by gametype, only by script) flood cannot drive hoverboard
  143.  
  144.     -- Vehicle replacement slots for gametype setup in the lobby:
  145.     -- Warthog:    Spawns Chain Hog
  146.     -- Ghost:      Spawns a Wasp
  147.     -- Scorpion:   Spawns a Ghost
  148.     -- Banshee:    Spawns a Banshee
  149.     -- Turret:     Spawns a Human Turret (Chain-gun)
  150.     -- Rocket hog: Spawns a Rocket Hog
  151.    
  152.     -- Note: This replaces vehicle 1, 2 or 3 with the vehicle you specify, it does NOT re-order their spawn order
  153.     -- set to nil to disable replacing the specified vehicle   
  154.      
  155.     -- ----- FFA RACE -----
  156.     -- default FFA race vehicle 1 (normally the chain hog slot)
  157.     default_ffa_race_vehicle_1 = wasp_id
  158.  
  159.     -- default FFA race vehicle 2 (normally the ghost slot)
  160.     default_ffa_race_vehicle_2 = wasp_id
  161.  
  162.     -- default FFA race vehicle 3 (normally the rocket hog slot)
  163.     default_ffa_race_vehicle_3 = ghost_id
  164.  
  165.     -- ----- TEAM RACE -----
  166.     -- default TEAM race vehicle 1 (normally the chain hog slot)
  167.     default_team_race_vehicle_1 = chain_hog_id
  168.  
  169.     -- default TEAM race vehicle 2 (normally the ghost slot)
  170.     default_team_race_vehicle_2 = wasp_id
  171.  
  172.     -- default TEAM race vehicle 3 (normally the rocket hog slot)
  173.     default_team_race_vehicle_3 = rocket_hog_id
  174.  
  175.     -- Enter your zombie gametype/mode name (CASE sensitive) - only for Zombie biped selection, nothing else, (use your own zombie script)
  176.     Zombie_Gametype_Name = "ZOMBIES"   
  177. end
  178.  
  179. function get_tag_info(tagclass,tagname) -- Thanks to 002, return metaid
  180.     local tagarray = read_dword(0x40440000)
  181.     for i=0,read_word(0x4044000C)-1 do
  182.         local tag = tagarray + i * 0x20
  183.         local class = string.reverse(string.sub(read_string(tag),1,4))
  184.         if (class == tagclass) then
  185.             if (read_string(read_dword(tag + 0x10)) == tagname) then
  186.                 return read_dword(tag + 0xC)
  187.             end
  188.         end
  189.     end
  190.     return nil
  191. end
  192.  
  193. function getteamplay()
  194.     if get_var(0,"$ffa") == "0" then
  195.         return true
  196.     else
  197.         return false
  198.     end
  199. end
  200.  
  201. function OnError(Message)
  202.     print(debug.traceback())
  203. end
  204.  
  205.  
  206. -- Created by H® Shaft
  207. -- Visit http://halorace.org/forum/index.php
  208.  
  209. -- The player -db-GoNe/Juhleek - a well spoken liar, cheat.
  210. -- -db- is: "diverging from the believable" - How ironic. A race clan where admins use rcon to favor themselves to win.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement