Advertisement
HR_Shaft

Greenfall Setup v1.2 for SAPP & CE Map Greenfall_v2

May 10th, 2016
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.51 KB | None | 0 0
  1. -- Greenfall Setup v1.2 for CE Map: greenfall_v2     Link: http://www.mediafire.com/download/t2c816xht0mc1n8/greenfall_v2_release.zip
  2. -- by H® Shaft
  3.  
  4. -- V1.2 Changes: Corrected a typo and the method of replacing RACE vehicles (cannot be done by metaid for metaid)
  5.  
  6. -- Sets up Multi-Bipeds based on FFA/Team games:
  7. -- Team Games:
  8. -- Red Team are Grunts
  9. -- Blue Team are Cyborgs
  10. -- FFA Games: Random Player Selection of Cyborg or Grunt
  11. -- Zombies: Use your favorite zombie script, this script will set the Zombie Biped based on your gametype name/mode (see line 38)
  12.  
  13. -- VEHICLE IDS: RACE vehicle setup: set the vehicle ID's you prefer for FFA Race and Team Race from these ID's
  14. -- chain_hog_id, epona_horse_id, walton_pickup_id, mesa_jeep_id, glendale_sedan_id, rocket_hog_id,
  15. -- sadler_pickup_id, hogfoot_fast_id, hogfoot_normal_id, hover_bike_id, hover_board_id, zeldas_horse_id
  16.  
  17. -- ----- FFA RACE -----
  18. -- default FFA race vehicle 1 (normally the chain hog slot)
  19. default_ffa_race_vehicle_1 = "vehicles\\greenfall\\epona_horse"
  20.  
  21. -- default FFA race vehicle 1 (normally the ghost slot)
  22. default_ffa_race_vehicle_2 = "vehicles\\greenfall\\hover_board"
  23.  
  24. -- default FFA race vehicle 1 (normally the rocket hog slot)
  25. default_ffa_race_vehicle_3 = "vehicles\\greenfall\\zeldas_horse"
  26.  
  27. -- ----- TEAM RACE -----
  28. -- default TEAM race vehicle 1 (normally the chain hog slot)
  29. default_team_race_vehicle_1 = "vehicles\\greenfall\\hogfoot_fast"
  30.  
  31. -- default TEAM race vehicle 1 (normally the ghost slot)
  32. default_team_race_vehicle_2 = "vehicles\\greenfall\\walton_pickup"
  33.  
  34. -- default TEAM race vehicle 1 (normally the rocket hog slot)
  35. default_team_race_vehicle_3 = "vehicles\\greenfall\\hogfoot_fast"
  36.  
  37. -- Enter your zombie gametype/mode name (CASE sensitive) - only for Zombie biped selection, nothing else, (use your own zombie script)
  38. Zombie_Gametype_Name = "ZOMBIES"
  39.  
  40. -- don't edit below --
  41. api_version = "1.9.0.0"
  42. team_play = false
  43.  
  44. function OnScriptLoad()
  45.     register_callback(cb['EVENT_OBJECT_SPAWN'], "OnObjectSpawn")
  46.     register_callback(cb['EVENT_GAME_START'], "OnNewGame")
  47.     register_callback(cb['EVENT_GAME_END'], "OnGameEnd")
  48.     register_callback(cb['EVENT_CHAT'], "OnPlayerChat") -- delete maybe?
  49.     if get_var(0, "$gt") ~= "n/a" then
  50.         OnNewGame()
  51.     end
  52. end
  53.  
  54. function OnNewGame()
  55.     map_name = get_var(0,"$map")
  56.     if map_name ~= "greenfall_v2" then return end
  57.     GetMetaIDs()
  58.     team_play = getteamplay()
  59. end
  60.  
  61. function OnGameEnd()
  62.     OnScriptUnload()
  63. end
  64.  
  65. function OnScriptUnload()
  66.     DEFAULT_BIPED = nil
  67. end
  68.  
  69. function OnObjectSpawn(PlayerIndex, MapID, ParentID, ObjectID)
  70.     if not player_present(PlayerIndex) then return true end
  71.     if (DEFAULT_BIPED == nil) then
  72.         local tag_array = read_dword(0x40440000)
  73.         for i=0,read_word(0x4044000C)-1 do
  74.             local tag = tag_array + i * 0x20
  75.             if(read_dword(tag) == 1835103335 and read_string(read_dword(tag + 0x10)) == "globals\\globals") then
  76.                 local tag_data = read_dword(tag + 0x14)
  77.                 local mp_info = read_dword(tag_data + 0x164 + 4)
  78.                 for j=0,read_dword(tag_data + 0x164)-1 do
  79.                     DEFAULT_BIPED = read_dword(mp_info + j * 160 + 0x10 + 0xC)
  80.                 end
  81.             end
  82.         end
  83.     end
  84.  
  85.     if (MapID == DEFAULT_BIPED) then
  86.         local team = get_var(PlayerIndex,"$team")
  87.         local game_mode = get_var(0, "$mode")
  88.         if team_play then
  89.             if game_mode ~= Zombie_Gametype_Name then
  90.                 if team == "red" then
  91.                     return true, grunt_mp_id
  92.                 else
  93.                     return true, cyborg_mp_id
  94.                 end
  95.             else
  96.                 if team == "red" then
  97.                     return true, altis_flood_id
  98.                 else
  99.                     return true, grunt_mp_id
  100.                 end
  101.             end    
  102.         else
  103.             local randbiped = rand(1,11)
  104.             if randbiped > 5 then
  105.                 return true, grunt_mp_id
  106.             else
  107.                 return true, cyborg_mp_id
  108.             end
  109.         end
  110.     end
  111.    
  112.     if get_var(0, "$gt") == "race" then
  113.         if not team_play then
  114.             -- FFA RACE
  115.             -- replace chain_hog_id with with default vehicle (chain hog slot) for FFA Race
  116.             if MapID == get_tag_info("vehi", "vehicles\\greenfall\\chain_hog") then
  117.                 return true, get_tag_info("vehi", default_ffa_race_vehicle_1)
  118.             end
  119.             --replace epona_horse_id with with default vehicle (ghost slot) for FFA Race
  120.             if MapID == get_tag_info("vehi", "vehicles\\greenfall\\epona_horse") then
  121.                 return true, get_tag_info("vehi", default_ffa_race_vehicle_2)
  122.             end        
  123.             -- replace rocket_hog_id with with default vehicle (rocket hog slot) for FFA Race
  124.             if MapID == get_tag_info("vehi", "vehicles\\greenfall\\rocket_hog") then
  125.                 return true, get_tag_info("vehi", default_ffa_race_vehicle_3)
  126.             end
  127.            
  128.         else
  129.             -- TEAM RACE
  130.             -- replace chain_hog_id with with default vehicle (chain hog slot) for TEAM Race
  131.             if MapID == get_tag_info("vehi", "vehicles\\greenfall\\chain_hog") then
  132.                 return true, get_tag_info("vehi", default_team_race_vehicle_1)
  133.             end
  134.             --replace epona_horse_id with with default vehicle (ghost slot) for TEAM Race
  135.             if MapID == get_tag_info("vehi", "vehicles\\greenfall\\epona_horse") then
  136.                 return true, get_tag_info("vehi", default_team_race_vehicle_2)
  137.             end        
  138.             -- replace rocket_hog_id with with default vehicle (rocket hog slot) for TEAM Race
  139.             if MapID == get_tag_info("vehi", "vehicles\\greenfall\\rocket_hog") then
  140.                 return true, get_tag_info("vehi", default_team_race_vehicle_3)
  141.             end        
  142.         end    
  143.     end
  144.    
  145.     return true
  146. end
  147.  
  148. function get_tag_info(obj_type, obj_name)
  149.     local tag_id = lookup_tag(obj_type, obj_name)
  150.     return tag_id ~= 0 and read_dword(tag_id + 0xC) or nil
  151. end
  152.  
  153. function GetMetaIDs()
  154.     --Vehicles:
  155.     chain_hog_id = read_dword(lookup_tag("vehi", "vehicles\\greenfall\\chain_hog") + 12)
  156.     epona_horse_id = read_dword(lookup_tag("vehi", "vehicles\\greenfall\\epona_horse") + 12)
  157.     walton_pickup_id = read_dword(lookup_tag("vehi", "vehicles\\greenfall\\walton_pickup") + 12)
  158.     mesa_jeep_id = read_dword(lookup_tag("vehi", "vehicles\\greenfall\\mesa_jeep") + 12)
  159.     glendale_sedan_id = read_dword(lookup_tag("vehi", "vehicles\\greenfall\\glendale_sedan") + 12)
  160.     rocket_hog_id = read_dword(lookup_tag("vehi", "vehicles\\greenfall\\rocket_hog") + 12)
  161.     sadler_pickup_id = read_dword(lookup_tag("vehi", "vehicles\\greenfall\\sadler_pickup") + 12)
  162.     hogfoot_fast_id = read_dword(lookup_tag("vehi", "vehicles\\greenfall\\hogfoot_fast") + 12)
  163.     hogfoot_normal_id = read_dword(lookup_tag("vehi", "vehicles\\greenfall\\hogfoot_normal") + 12)
  164.     hover_bike_id = read_dword(lookup_tag("vehi", "vehicles\\greenfall\\hover_bike") + 12)
  165.     hover_board_id = read_dword(lookup_tag("vehi", "vehicles\\greenfall\\hover_board") + 12)
  166.     zeldas_horse_id = read_dword(lookup_tag("vehi", "vehicles\\greenfall\\zeldas_horse") + 12)
  167.     --Bipeds:
  168.     cyborg_mp_id = read_dword(lookup_tag("bipd", "nervebooger\\cyborg\\cyborg_mp") + 12)
  169.     grunt_mp_id = read_dword(lookup_tag("bipd", "nervebooger\\grunt\\grunt_mp") + 12)
  170.     altis_flood_id = read_dword(lookup_tag("bipd", "altis\\characters\\flood_human\\altis_flood") + 12)
  171. end
  172.  
  173. function getteamplay()
  174.     if get_var(0,"$ffa") == "0" then
  175.         return true
  176.     else
  177.         return false
  178.     end
  179. end
  180.  
  181. function OnError(Message)
  182.     print(debug.traceback())
  183. end
  184.  
  185. function OnPlayerChat(PlayerIndex, Message)
  186.     local response = nil
  187.     local name = get_var(PlayerIndex,"$name")
  188.     local Message = string.lower(Message)
  189.     local isadmin = nil
  190.     if (tonumber(get_var(PlayerIndex,"$lvl"))) >= 1 then isadmin = true else isadmin = false end       
  191.    
  192.     -- | retrieve your coordinates x,y,z and rotation (yaw) (the direction you are facing, not "aim")
  193.     if (Message == "coord") and isadmin then
  194.         if isadmin then
  195.             response = false
  196.             local player_object = get_dynamic_player(PlayerIndex)
  197.             local player_static = get_player(PlayerIndex)
  198.             local x,y,z = read_vector3d(player_object + 0x5C)
  199.             local rotation = read_float(player_static + 0x138)
  200.             local map_name = get_var(0,"$map")
  201.             local data = string.format("%s,%s,%s,%s,%s", tostring(map_name),tostring(x),tostring(y),tostring(z),tostring(rotation))
  202.             execute_command("log_note \""..data.."\"")     
  203.             say(PlayerIndex, "X: " .. x .. " Y: " .. y .. " Z: " .. z .. " R: " .. rotation)
  204.         else
  205.             response = true
  206.         end
  207.     end
  208.    
  209.     return response
  210. end
  211.  
  212.  
  213. --Vehicle replacement slots for gametype setup in the lobby:
  214. --Warthog:    Spawns Chain Hog  (Race vehicle slot)
  215. --Ghost:      Spawns Epona Horse (Race vehicle slot)
  216. --Scorpion:   Spawns Walton Pickup
  217. --Banshee:    Spawns a Mesa Jeep
  218. --Turret:     Spawns a Glendale Sedan
  219. --Rocket hog: Spawns a Rocket Hog (Race vehicle slot)
  220.  
  221. -- Created by H® Shaft
  222. -- Visit http://halorace.org/forum/index.php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement