Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ ### Shields Up! ###]]--
- --[[ ### by H® Shaft ###]]--
- --[[ ### for Phasor v2 ###]]--
- -- enables hog/ghost occupants to to activate a 10 second 'damage shield' by pressing their flashlight key
- -- Some portions made by AElitePrime, thanks!
- -- don't edit --
- calls, delay, regeneration_time, shield_duration, enable_shield, protected = {}, {}, {}, {}, {}, {}
- ------ edit below -------
- shield_limit = 5 -- | Number of times a player can activate shields during one game.
- -- Specify the amount of time between shield activations
- -- Map: Edit Time(In Seconds):
- regeneration_time. beavercreek = 30 -- battle creek
- regeneration_time. bloodgulch = 30
- regeneration_time. boardingaction = 30
- regeneration_time. carousel = 30 -- derelict
- regeneration_time. chillout = 30
- regeneration_time. damnation = 30
- regeneration_time. dangercanyon = 30
- regeneration_time. deathisland = 30
- regeneration_time. gephyrophobia = 30
- regeneration_time. hangemhigh = 30
- regeneration_time. icefields = 30
- regeneration_time. infinity = 30
- regeneration_time. longest = 30
- regeneration_time. prisoner = 30
- regeneration_time. putput = 30 -- chiron tl34
- regeneration_time. ratrace = 30
- regeneration_time. sidewinder = 30
- regeneration_time. timberland = 30
- regeneration_time. wizard = 30
- regeneration_time. Hornets_Nest = 30
- regeneration_time. Launch_Bay_X = 30
- -- Specify the amount of time the shield will last
- -- Map: Edit Time(In Seconds):
- shield_duration. beavercreek = 0 -- battle creek
- shield_duration. bloodgulch = 10
- shield_duration. boardingaction = 0
- shield_duration. carousel = 0 -- derelict
- shield_duration. chillout = 0
- shield_duration. damnation = 0
- shield_duration. dangercanyon = 10
- shield_duration. deathisland = 10
- shield_duration. gephyrophobia = 10
- shield_duration. hangemhigh = 0
- shield_duration. icefields = 10
- shield_duration. infinity = 10
- shield_duration. longest = 0
- shield_duration. prisoner = 0
- shield_duration. putput = 0 -- chiron tl310
- shield_duration. ratrace = 0
- shield_duration. sidewinder = 10
- shield_duration. timberland = 10
- shield_duration. wizard = 0
- shield_duration. Hornets_Nest = 10
- shield_duration. Launch_Bay_X = 10
- -- If the boolean is true for the map then shields up will be enabled
- -- Map: edit boolean
- enable_shield. beavercreek = false -- battle creek
- enable_shield. bloodgulch = true
- enable_shield. boardingaction = false
- enable_shield. carousel = false -- derelict
- enable_shield. chillout = false
- enable_shield. damnation = false
- enable_shield. dangercanyon = true
- enable_shield. deathisland = true
- enable_shield. gephyrophobia = true
- enable_shield. hangemhigh = false
- enable_shield. icefields = true
- enable_shield. infinity = true
- enable_shield. longest = false
- enable_shield. prisoner = false
- enable_shield. putput = false -- chiron tl3true
- enable_shield. ratrace = false
- enable_shield. sidewinder = true
- enable_shield. timberland = true
- enable_shield. wizard = false
- enable_shield. Hornets_Nest = true
- enable_shield. Launch_Bay_X = true
- function GetRequiredVersion()
- return 200
- end
- function OnScriptLoad(process, game, persistent)
- if game == "PC" then
- Map = readstring(0x698F21)
- GAME = game
- else
- Map = readstring(0x61D151)
- GAME = game
- end
- for i=0,15 do
- calls[i], delay[i] = 0, 0
- end
- end
- function OnNewGame(map)
- if GAME == "PC" then
- Map = readstring(0x698F21)
- else
- Map = readstring(0x61D151)
- end
- for i=0,15 do
- calls[i], delay[i] = 0, 0
- end
- end
- function OnPlayerJoin(player)
- calls[player], delay[player], protected[player] = 0, 0, false
- registertimer(6000, "timedannounce", player)
- end
- function OnClientUpdate(player)
- if enable_shield[Map] then
- if delay[player] > 0 then delay[player] = delay[player] - 1 end
- local m_playerObjId = getplayerobjectid(player)
- if m_playerObjId and isinvehicle(player) then
- local m_vehicle = getobject(getvehicleobjectid(player))
- if getdriverplayer(m_vehicle) == player and not protected[player] and readbit(getobject(m_playerObjId) + 0x208, 4) then
- OnShieldsUp(player, m_vehicle)
- elseif getgunnerplayer(m_vehicle) == player and not protected[player] and readbit(getobject(m_playerObjId) + 0x208, 4) then
- OnShieldsUp(player, m_vehicle)
- elseif getpassengerplayer(m_vehicle) == player and not protected[player] and readbit(getobject(m_playerObjId) + 0x208, 4) then
- OnShieldsUp(player, m_vehicle)
- end
- end
- end
- end
- function OnShieldsUp(player, m_vehicle)
- if getplayer(player) then
- local m_player = getplayer(player)
- if m_player and validvehicle(m_vehicle) then
- if not shield_limit or calls[player] < shield_limit then
- if (delay[player] or 0) == 0 then
- local m_objectId = getplayerobjectid(player)
- if m_objectId then
- local m_object = getobject(m_objectId)
- if m_object then
- if shield_duration[Map] and shield_duration[Map] > 0 then
- protected[player] = true
- registertimer(shield_duration[Map] * 1000, "RemoveShields", {m_object, player})
- end
- end
- end
- delay[player] = math.floor(regeneration_time[Map]*30)
- calls[player] = calls[player] + 1
- for i=0,15 do
- if getplayer(i) then
- sendconsoletext(i, getname(player) .. " activated temporary damage shields.")
- end
- end
- sendconsoletext(player, "**Shields Up!** You have " .. shield_limit - calls[player] .. " shield calls remaining.")
- elseif (delay[player] or 0) > 0 then
- sendconsoletext(player, "Shields regenerating! Not available yet.")
- if delay[player] > 1 then
- sendconsoletext(player, "Wait another " .. round((delay[player]/30 or 0)) .. " seconds.")
- else
- sendconsoletext(player, "Wait 1 more second.")
- end
- end
- else
- sendconsoletext(player, "**Shields** You have reached the max amount of shield calls for this game.")
- end
- else
- if delay[player] ~= 0 then
- delay[player] = 0
- end
- end
- end
- end
- function RemoveShields(id, count, arg)
- protected[arg[2]] = false
- sendconsoletext(arg[2], "Shield depleted.")
- return false
- end
- function validvehicle(m_vehicle)
- local name = gettaginfo(readdword(m_vehicle))
- if string.find(name, "warthog") or string.find(name, "ghost") then
- return true
- end
- return false
- end
- function OnPlayerLeave(player)
- protected[player] = false
- end
- function OnPlayerKill(killer, victim, mode)
- protected[victim] = false
- end
- function getplayervehicleid(player)
- local m_objectId = getplayerobjectid(player)
- if m_objectId then return readdword(getobject(m_objectId) + 0x11C) end
- end
- function getvehicleobjectid(player)
- local m_objectId = getplayerobjectid(player)
- if m_objectId then return readdword(getobject(m_objectId) + 0x11C) end
- end
- function getdriverplayer(m_vehicle)
- local m_objectId = readdword(m_vehicle + 0x324)
- if m_objectId and m_objectId ~= 0xFFFFFFFF then
- return objectidtoplayer(m_objectId)
- end
- end
- function getgunnerplayer(m_vehicle)
- local m_objectId = readdword(m_vehicle + 0x328)
- if m_objectId and m_objectId ~= 0xFFFFFFFF then
- return objectidtoplayer(m_objectId)
- end
- end
- function getpassengerplayer(m_vehicle)
- local m_objectId = readdword(m_vehicle + 0x32c)
- if m_objectId and m_objectId ~= 0xFFFFFFFF then
- return objectidtoplayer(m_objectId)
- end
- end
- function OnVehicleEntry(player, m_vehicleId, seat, mapid, relevant)
- if seat == 1 and validvehicle(getobject(m_vehicleId)) then
- local player_obj_id = getplayerobjectid(player)
- local m_object = getobject(player_obj_id)
- registertimer(0, "assignpassenger", {player_obj_id, getobject(m_vehicleId)})
- end
- return nil
- end
- function assignpassenger(id, count, arg)
- writedword(arg[2] + 0x32C, arg[1])
- return false
- end
- function OnVehicleEject(player, relevant)
- if protected[player] then
- protected[player] = false
- end
- return nil
- end
- function timedannounce(id, count, player)
- if getplayer(player) then
- if enable_shield[Map] then sendconsoletext(player, "Shields Up!: Enabled/Flashlight Button activates a temporary damage shield.") end
- end
- return false
- end
- function OnDamageLookup(receiving, causing, tagid)
- if receiving then
- local r_player = objectidtoplayer(receiving)
- if r_player and isinvehicle(r_player) then
- local m_vehicleId = getplayervehicleid(r_player)
- if m_vehicleId then
- local m_vehicle = getobject(m_vehicleId)
- local driver = getdriverplayer(m_vehicle)
- local gunner = getgunnerplayer(m_vehicle)
- local passenger = getpassengerplayer(m_vehicle)
- if driver == r_player and protected[r_player] then
- return false
- end
- if passenger == r_player and protected[r_player] then
- return false
- end
- if gunner == r_player and protected[r_player] then
- return false
- end
- end
- end
- end
- end
- function round(input, precision) -- rounds the number to the specified decimal place
- return math.floor((input * 10^(tonumber(precision) or 0) + 0.5)) / (10^(tonumber(precision) or 0))
- end
- -- Created by H® Shaft thank you to Oxide, AelitePrime, Nugget & Wizard.
- -- Visit http://halorace.org/forum/index.php?topic=514.0 or
- -- Visit http://pastebin.com/u/HR_Shaft for more phasor scripts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement