Advertisement
HR_Shaft

Invisible Koth v1 for Phasor v2

Mar 30th, 2014
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.07 KB | None | 0 0
  1. --[[ ###  Invisible Koth v1  ###]]--
  2. --[[ ###    by H® Shaft      ###]]--
  3. --[[ ###   for Phasor v2     ###]]--
  4.  
  5. -- if player is in the hill for 10 seconds or longer, they become invisible
  6. -- if player is in the hill they move at 50% normal speed
  7. -- if player is in the hill for 40 seconds, they are given a bonus overshield
  8. -- if player is in the hill and in a vehicle, they are ejected, cannot re-enter while in the hill
  9. -- if player is not in the hill they move at 150% normal speed
  10.  
  11. inhill_time = {}
  12. map_reset_boolean = false
  13.  
  14. function GetRequiredVersion()
  15.     return 200
  16. end
  17.  
  18. function OnScriptLoad(process, game, persistent)
  19.     if game == true or game == "PC" then
  20.         GAME = "PC"
  21.         gametype_base = 0x671340
  22.         koth_globals = 0x639BD0
  23.     else
  24.         GAME = "CE"
  25.         gametype_base = 0x5F5498
  26.         koth_globals = 0x5BDBF0
  27.     end
  28.     gametype = readbyte(gametype_base + 0x30)
  29.     if kothtimer == nil then
  30.         kothtimer = registertimer(1000, "KothTimer")
  31.     end
  32.     if giveortake == nil then
  33.         giveortake = registertimer(1000, "GiveCamoNos")
  34.     end    
  35.     for i = 0,15 do
  36.         if getplayer(i) then
  37.             local hash = gethash(i)
  38.             inhill_time[hash] = 0
  39.         end
  40.     end    
  41. end
  42.  
  43. function OnNewGame(map)
  44.     if GAME == "PC" then
  45.         gametype_base = 0x671340
  46.         koth_globals = 0x639BD0
  47.     elseif GAME == "CE" then
  48.         gametype_base = 0x5F5498
  49.         koth_globals = 0x5BDBF0
  50.     end
  51.     gametype = readbyte(gametype_base + 0x30)
  52.     if map_reset_boolean == true then
  53.         kothtimer = registertimer(1000, "KothTimer")
  54.         giveortake = registertimer(1000, "GiveCamoNos")
  55.         for i = 0,15 do
  56.             if getplayer(i) then
  57.                 local hash = gethash(i)
  58.                 inhill_time[hash] = 0
  59.             end
  60.         end        
  61.     end
  62.     for i = 0,15 do
  63.         if getplayer(i) then
  64.             local hash = gethash(i)
  65.             inhill_time[hash] = 0
  66.         end
  67.     end    
  68. end
  69.  
  70. function OnGameEnd(stage)
  71.     if stage == 1 then
  72.         if kothtimer then
  73.             removetimer(kothtimer)
  74.             kothtimer = nil
  75.         end
  76.         if giveortake then
  77.             removetimer(giveortake)
  78.             giveortake = nil
  79.         end    
  80.     end
  81. end
  82.  
  83. function OnPlayerJoin(player)
  84.     if getplayer(player) then
  85.         local hash = gethash(player)
  86.         inhill_time[hash] = 0
  87.     end
  88. end
  89.  
  90. function OnPlayerKill(killer, victim, mode)
  91.     if getplayer(victim) then
  92.         local hash = gethash(victim)
  93.         inhill_time[hash] = 0
  94.     end
  95. end
  96.  
  97. function OnPlayerLeave(player)
  98.     if getplayer(player) then
  99.         local hash = gethash(player)
  100.         inhill_time[hash] = nil
  101.     end
  102. end
  103.  
  104. function KothTimer(id, count)
  105.     if map_reset_boolean == true then
  106.         map_reset_boolean = false
  107.     end
  108.     for i = 0,15 do
  109.         if getplayer(i) then
  110.             local hash = gethash(i)
  111.             local m_objectId = getplayerobjectid(i)
  112.             if gametype == 4 then
  113.                 local m_objectId = getplayerobjectid(i)
  114.                 if m_objectId then
  115.                     local m_object = getobject(m_objectId)
  116.                     if PlayerInHill(i) and m_object then
  117.                         inhill_time[hash] = inhill_time[hash] + 1
  118.                         setspeed(i, 0.5)
  119.                         if isinvehicle(i) then exitvehicle(i) end
  120.                     elseif not PlayerInHill(i) and m_object then
  121.                         inhill_time[hash] = 0
  122.                         setspeed(i, 1.5)
  123.                     end
  124.                 end
  125.             end
  126.         end
  127.     end
  128.     return true
  129. end
  130.  
  131. function PlayerInHill(player)
  132.     player = tonumber(player)
  133.     local bool = false
  134.     local m_player = getplayer(player)
  135.     if m_player then
  136.         local InHill = readbyte(koth_globals + player + 0x80)
  137.         if InHill == 1 then
  138.             bool = true
  139.         end
  140.     end
  141.     return bool
  142. end            
  143.  
  144. function GiveCamoNos(id, count)
  145.     for x = 0,15 do
  146.         if getplayer(x) then
  147.             local hash = gethash(x)
  148.             local m_player = getplayer(x)
  149.             if m_player then
  150.                 local m_playerObjId = readdword(m_player + 0x34)
  151.                 local m_object = getobject(m_playerObjId)
  152.                 if m_object then
  153.                     -- apply camo at 10 sec +
  154.                     local camoFlag = readdword(m_object + 0x204)
  155.                     if camoFlag ~= 0x51 then
  156.                         if inhill_time[hash] >= 10 then
  157.                             applycamo(x, 10)
  158.                         end
  159.                     end
  160.                     -- apply os at 40 sec
  161.                     if inhill_time[hash] == 40 then
  162.                         if readfloat(m_object + 0xE4) <= 1 then
  163.                             local x,y,z = getobjectcoords(m_playerObjId)
  164.                             local ovs = createobject(gettagid("eqip", "powerups\\over shield"), 0, 0, false, x, y, z+0.5)
  165.                             if ovs ~= nil then writefloat(getobject(ovs) + 0x70, -2) end
  166.                         end
  167.                     end
  168.                 end    
  169.             end            
  170.         end
  171.     end
  172.     return true
  173. end
  174.  
  175. function OnObjectCreationAttempt(mapId, parentId, player)
  176.     if mapId == gettagid("eqip", "powerups\\active camouflage") then
  177.         return gettagid("eqip", "powerups\\over shield")
  178.     end
  179.     return nil
  180. end
  181.  
  182. function OnVehicleEntry(player, m_vehicleId, seat, mapId, relevant)
  183.     if getplayer(player) then
  184.         if PlayerInHill(player) then
  185.             return false
  186.         else
  187.             return true
  188.         end
  189.     end
  190.     return nil
  191. end
  192.  
  193. function OnServerCommand(player, command)
  194.     local allow = nil
  195.     local cmd = tokenizecmdstring(command)
  196.     local tokencount = #cmd
  197.     if tokencount > 0 then
  198.         if cmd[1] == "sv_map_reset" or cmd[1] == "sv_script_reload" then
  199.             map_reset_boolean = true
  200.         end
  201.     end
  202.     return allow
  203. end
  204.  
  205. -- Created by H® Shaft thank you to Oxide, AelitePrime, Nugget & Wizard.
  206. -- Visit http://halorace.org/forum/index.php?topic=514.0 or
  207. -- Visit http://pastebin.com/u/HR_Shaft for more phasor scripts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement