- --[[ ### Random Weapons for Revolution ###]]--
- --[[ ### by H® Shaft for Phasor v2 ###]]--
- -- gametype MUST have weapons set to generic
- -- specifically for revolution maps by Nex *ONLY* find various maps in thread: http://opencarnage.net/index.php?/topic/2239-halo-revolution/
- team_play = false
- game_started = false
- weapons = {}
- mybattery = {}
- needler_clip = 40
- shotgun_clip = 12
- assault_clip = 60
- nlaunch_clip = 5
- pistol_clip = 12
- rocket_clip = 2
- sniper_clip = 4
- carbine_clip = 18
- rocket_ammo = 4
- function GetRequiredVersion()
- return 200
- end
- function OnScriptLoad(process, game, persistent)
- if game == true or game == "PC" then
- GAME = "PC"
- gametype_base = 0x671340
- map_name = readstring(0x698F21)
- else
- GAME = "CE"
- gametype_base = 0x5F5498
- map_name = readstring(0x61D151)
- end
- for i=0,15 do
- if getplayer(i) then
- mybattery[i] = 0
- weapons[i] = {}
- end
- end
- gametype = readbyte(gametype_base + 0x30)
- team_play = getteamplay()
- end
- function OnNewGame(map)
- if GAME == "PC" then
- gametype_base = 0x671340
- map_name = readstring(0x698F21)
- elseif GAME == "CE" then
- gametype_base = 0x5F5498
- map_name = readstring(0x61D151)
- end
- for i=0,15 do
- if getplayer(i) then
- mybattery[i] = 0
- weapons[i] = {}
- end
- end
- game_started = true
- gametype = readbyte(gametype_base + 0x30)
- team_play = getteamplay()
- end
- function getteamplay()
- if readbyte(gametype_base + 0x34) == 1 then
- return true
- else
- return false
- end
- end
- function OnPlayerJoin(player)
- if getplayer(player) then
- mybattery[player] = 0
- weapons[player] = nil
- welcome = registertimer(9000, "Welcome", player)
- end
- end
- function ApplyHP(id, count, player)
- if count == 1 then
- if player and game_started then
- local name = getname(player)
- local m_playerObjId = getplayerobjectid(player)
- if m_playerObjId ~= nil then
- local m_object = getobject(m_playerObjId)
- local obj_health = readfloat(m_object + 0xE0)
- if obj_health < 1 then
- writefloat(m_object + 0xE0, 1)
- sendconsoletext(player, "Bonus: Your health has been restored.", 5, 0)
- end
- end
- end
- end
- return false
- end
- function Welcome(id, count, player)
- if count == 1 then
- if getplayer(player) then
- sendconsoletext(player, "Welcome to Random Weapons for Revolution!", 10, 0)
- sendconsoletext(player, "Each time you spawn, you will be given a random weapon.", 10, 0)
- end
- end
- return false
- end
- function OnPlayerKill(killer, victim, mode)
- local response = nil
- if getplayer(victim) then
- weapons[victim] = nil
- mybattery[victim] = 0
- if mode == 0 then
- response = false
- else
- response = true
- end
- end
- return response
- end
- function OnPlayerLeave(player)
- if getplayer(player) then
- weapons[player] = nil
- mybattery[player] = nil
- end
- end
- function OnTeamChange(player, old_team, new_team, relevant)
- if getplayer(player) then
- weapons[player] = nil
- mybattery[player] = 1
- end
- return nil
- end
- function OnPlayerSpawnEnd(player, m_objectId)
- if getplayer(player) then
- weapons[player] = nil
- mybattery[player] = 0
- ChangeFFAColor(player)
- local m_objectId = getplayerobjectid(player)
- if m_objectId then
- gameweap = registertimer(0, "AssignGameWeapons", player)
- end
- end
- end
- function ChangeFFAColor(player)
- if getplayer(player) then
- local m_objectId = getplayerobjectid(player)
- if m_objectId then
- local m_object = getobject(m_objectId)
- if m_object then
- local m_player = getplayer(player)
- local color = getrandomnumber(1, 18)
- writeword(m_player + 0x60, color)
- end
- end
- end
- end
- function AssignGameWeapons(id, count, player)
- if getplayer(player) and game_started then
- local m_objectId = getplayerobjectid(player)
- local m_object = getobject(m_objectId)
- local clip = 0
- local ammo = 9999
- local battery = 0
- if m_objectId then
- for i = 0,3 do
- local weapID = readdword(getobject(m_objectId), 0x2F8 + i*4)
- if weapID ~= 0xFFFFFFFF then
- destroyobject(weapID)
- end
- end
- local randomweap = getrandomnumber(1, 11)
- local randomclip = getrandomnumber(1, 20)
- if randomweap == 1 then
- weapons[player] = "revolution\\weapons\\plasma pistol\\plasma pistol" -- Plasma Pistol - 1
- sendconsoletext(player, "Plasma Pistol", 5, 0)
- elseif randomweap == 2 then
- if randomclip > 19 then
- clip = 9999
- sendconsoletext(player, "Bottomless Clip: No Reload!", 5, 0)
- else
- clip = needler_clip
- end
- weapons[player] = "revolution\\weapons\\needler\\needler" -- Needler - 2
- sendconsoletext(player, "Needler", 5, 0)
- elseif randomweap == 3 then
- if randomclip > 19 then
- clip = 9999
- sendconsoletext(player, "Bottomless Clip: No Reload!", 5, 0)
- else
- clip = shotgun_clip
- end
- weapons[player] = "revolution\\weapons\\shotgun\\revolution shotgun" -- Shotgun - 3
- sendconsoletext(player, "Shotgun", 5, 0)
- elseif randomweap == 4 then
- weapons[player] = "revolution\\weapons\\plasma rifle\\plasma rifle" -- Plasma Rifle - 4
- sendconsoletext(player, "Plasma Rifle", 5, 0)
- elseif randomweap == 5 then
- if randomclip > 19 then
- clip = 9999
- sendconsoletext(player, "Bottomless Clip: No Reload!", 5, 0)
- else
- clip = assault_clip
- end
- weapons[player] = "revolution\\weapons\\assault rifle\\revolution assault rifle" -- Assault Rifle - 5
- sendconsoletext(player, "Assault Rifle", 5, 0)
- elseif randomweap == 6 then
- if randomclip > 19 then
- clip = 9999
- sendconsoletext(player, "Bottomless Clip: No Reload!", 5, 0)
- else
- clip = nlaunch_clip
- end
- weapons[player] = "revolution\\weapons\\grenade launcher\\nade_launcher" -- Nade Launcher - 6
- sendconsoletext(player, "Nade Launcher", 5, 0)
- elseif randomweap == 7 then
- if randomclip > 19 then
- clip = 9999
- sendconsoletext(player, "Bottomless Clip: No Reload!", 5, 0)
- else
- clip = pistol_clip
- end
- weapons[player] = "revolution\\weapons\\pistol\\rev pistol" -- Pistol - 7
- sendconsoletext(player, "Pistol", 5, 0)
- elseif randomweap == 8 then
- if randomclip > 19 then
- clip = 9999
- sendconsoletext(player, "Bottomless Clip: No Reload!", 5, 0)
- else
- clip = rocket_clip
- end
- weapons[player] = "revolution\\weapons\\rocket launcher\\rocket launcher" -- Rocket Launcher - 8
- sendconsoletext(player, "Rocket Launcher", 5, 0)
- elseif randomweap == 9 then
- if randomclip > 19 then
- clip = 9999
- sendconsoletext(player, "Bottomless Clip: No Reload!", 5, 0)
- else
- clip = sniper_clip
- end
- weapons[player] = "revolution\\weapons\\sniper\\revolution sniper" -- Sniper Rifle - 9
- sendconsoletext(player, "Sniper Rifle", 5, 0)
- elseif randomweap == 10 then
- weapons[player] = "revolution\\weapons\\plasma cannon\\plasma_cannon" -- Plasma Cannon - 10
- sendconsoletext(player, "Plasma Cannon", 5, 0)
- elseif randomweap == 11 then
- if randomclip > 19 then
- clip = 9999
- sendconsoletext(player, "Bottomless Clip: No Reload!", 5, 0)
- else
- clip = bruteshot_clip
- end
- weapons[player] = "revolution\\weapons\\carbine\\carbine" -- Carbine -11
- sendconsoletext(player, "Carbine", 5, 0)
- end
- local m_weaponId = createobject(gettagid("weap", weapons[player]), 0, 10, false, 0, 0, 0)
- assignweapon(player, m_weaponId)
- local m_weapon = getobject(m_weaponId)
- if randomweap == 1 or randomweap == 4 or randomweap == 10 then
- if m_weapon then
- writefloat(m_weapon + 0x240, battery)
- updateammo(m_weaponId)
- infbattery = registertimer(1000, "InfBattery", {m_weapon, player})
- mybattery[player] = 1
- end
- elseif randomclip <= 19 then
- if m_weapon then
- if randomweap == 8 then ammo = rocket_ammo clip = rocket_clip end -- rocket launcher
- writeword(m_weapon + 0x2B6, ammo)
- if randomweap ~= 11 then
- writeword(m_weapon + 0x2B8, clip) -- carbine has no clip?
- end
- updateammo(m_weaponId)
- end
- else
- if m_weapon then
- if randomweap == 8 then ammo = rocket_ammo clip = rocket_clip end
- writeword(m_weapon + 0x2B6, ammo)
- writeword(m_weapon + 0x2B8, clip)
- updateammo(m_weaponId)
- end
- end
- local random_nade = getrandomnumber(1, 7)
- if m_object then
- writebyte(m_object, 0x31E, 0)
- writebyte(m_object, 0x31F, 0)
- if random_nade == 1 then
- writebyte(m_object, 0x31E, 2)
- writebyte(m_object, 0x31F, 2)
- sendconsoletext(player, "Grenades: 2 of each.", 5, 0)
- elseif random_nade == 2 then
- writebyte(m_object, 0x31E, 1)
- writebyte(m_object, 0x31F, 1)
- sendconsoletext(player, "Grenades: 1 of each.", 5, 0)
- elseif random_nade == 3 then
- writebyte(m_object, 0x31E, 1)
- writebyte(m_object, 0x31F, 0)
- sendconsoletext(player, "Grenades: 1 frag.", 5, 0)
- elseif random_nade == 4 then
- writebyte(m_object, 0x31E, 0)
- writebyte(m_object, 0x31F, 1)
- sendconsoletext(player, "Grenades: 1 Plasma.", 5, 0)
- elseif random_nade == 5 then
- writebyte(m_object, 0x31E, 2)
- writebyte(m_object, 0x31F, 0)
- sendconsoletext(player, "Grenades: 2 Frags.", 5, 0)
- elseif random_nade == 6 then
- writebyte(m_object, 0x31E, 0)
- writebyte(m_object, 0x31F, 2)
- sendconsoletext(player, "Grenades: 2 Plasma.", 5, 0)
- elseif random_nade == 7 then
- writebyte(m_object, 0x31E, 0)
- writebyte(m_object, 0x31F, 0)
- else
- writebyte(m_object, 0x31E, 0)
- writebyte(m_object, 0x31F, 0)
- end
- end
- local random_camo = getrandomnumber(1, 30)
- local id = resolveplayer(player)
- if random_camo > 29 then
- svcmd("sv_invis " .. id)
- sendconsoletext(player, "You are Invisible!", 5, 0)
- end
- local random_os = getrandomnumber(1, 30)
- if random_os > 29 then
- if readfloat(m_object + 0xE4) <= 1 then
- local x,y,z = getobjectcoords(m_objectId)
- local os = createobject(gettagid("eqip", "powerups\\over shield"), 0, 0, false, x, y, z+0.5)
- if os ~= nil then writefloat(getobject(os) + 0x70, -2) end
- else
- writefloat(m_object + 0xE4, 3)
- end
- sendconsoletext(player, "You have an Overshield!", 5, 0)
- end
- if gametype ~= 5 then
- local random_speed = getrandomnumber(1, 30)
- if random_speed >= 29 then
- setspeed(player, 1.5)
- sendconsoletext(player, "150% Speed!", 5, 0)
- elseif random_speed >= 1 and random_speed < 3 then
- setspeed(player, 1.25)
- sendconsoletext(player, "125% Speed!", 5, 0)
- end
- end
- end
- end
- return false
- end
- function OnWeaponReload(player, weapon)
- local reload = nil
- if getplayer(player) then
- local m_player = getplayer(player)
- local m_objectId = readdword(m_player + 0x34)
- local m_object = getobject(m_objectId)
- if m_object then
- local m_weaponId = readdword(m_object + 0x118)
- if m_weaponId then
- local m_weapon = getobject(m_weaponId)
- if m_weapon then
- local weapname = gettaginfo(readdword(m_weapon))
- if weapname == "revolution\\weapons\\needler\\needler" then
- writeword(getobject(weapon) + 0x2B8, needler_clip)
- updateammo(weapon)
- reload = false
- elseif weapname == "revolution\\weapons\\grenade launcher\\nade_launcher" then
- writeword(getobject(weapon) + 0x2B8, nlaunch_clip)
- updateammo(weapon)
- reload = false
- else
- reload = true
- end
- end
- end
- end
- end
- return reload
- end
- function InfBattery(id, count, arg)
- local m_weapon = arg[1]
- local player = arg[2]
- if m_weapon and game_started then
- if readfloat(m_weapon + 0x240) == 1 and mybattery[player] == 1 then
- destroyplayerweaps(player)
- replaceplasmaweap = registertimer(0, "ReplacePlasmaWeap", {player, m_weapon})
- mybattery[player] = 0
- end
- end
- return true
- end
- function ReplacePlasmaWeap(id, count, arg)
- local player = arg[1]
- local m_weapon = arg[2]
- if count == 1 then
- if player and game_started then
- local m_weaponId = createobject(gettagid("weap", weapons[player]), 0, 10, false, 0, 0, 0)
- assignweapon(player, m_weaponId)
- privatesay(player, "Battery recharged.")
- end
- mybattery[player] = 0
- end
- return false
- end
- function getweaponobjectid(player, slot)
- local m_objectId = getplayerobjectid(player)
- if m_objectId then return readdword(getobject(m_objectId) + 0x2F8 + slot*4) end
- end
- function destroyplayerweaps(player)
- for i=0,3 do
- local weap_id = getweaponobjectid(player, i)
- if weap_id ~= 0xFFFFFFFF then destroyobject(weap_id) end
- end
- end
- function OnObjectCreationAttempt(mapId, parentId, player)
- local response = nil
- local name, type = gettaginfo(mapId)
- if game_started then
- -- block
- if mapId == gettagid("eqip", "revolution\\weapons\\frag grenade\\frag grenade") or -- frags
- mapId == gettagid("eqip", "revolution\\weapons\\plasma grenade\\plasma grenade") then -- plasma
- response = false
- end
- elseif not game_started then
- -- allow
- if mapId == gettagid("bipd", "revolution\\biped\\cyborg") then -- m biped
- response = true
- end
- -- block
- if mapId == gettagid("eqip", "revolution\\weapons\\frag grenade\\frag grenade") or -- frags
- mapId == gettagid("eqip", "revolution\\weapons\\plasma grenade\\plasma grenade") then -- plasma
- response = false
- end
- else
- response = false
- end
- return response
- end
- function OnDamageLookup(receiving, causing, tagid)
- -- looks up and sets damage variables
- if receiving and causing and receiving ~= causing then
- local tagname, tagtype = gettaginfo(tagid)
- local melee = string.find(tagname, "melee")
- local ppistol = string.find(tagname, "cmt\\weapons\\covenant\\plasma_pistol\\bolt\\bolt")
- local needler1 = string.find(tagname, "revolution\\weapons\\needler\\impact damage")
- local needler2 = string.find(tagname, "weapons\\needler\\shock wave")
- local plasrifle = string.find(tagname, "cmt\\weapons\\covenant\\plasma_rifle\\bolt")
- -- increase damage of melee to instant kill, increase plasma pistol, needler and plasma rifle to balance game play
- if c_player and r_player then
- if melee then odl_multiplier(9999) end
- if ppistol then odl_multiplier(1.85) end
- if needler1 or needler2 then odl_multiplier(1.75) end
- if plasrifle then odl_multiplier(1.35) end
- end
- end
- return nil
- end
- function OnObjectInteraction(player, objId, mapId)
- local Pass = nil
- local name, type = gettaginfo(mapId)
- if type == "weap" then
- if gametype == 1 or gametype == 3 then
- if name == "revolution\\weapons\\flag\\flag" or name == "revolution\\weapons\\ball\\ball" then
- Pass = true
- elseif weapons[player] ~= nil then
- if name ~= weapons[player] then
- Pass = false
- end
- end
- else
- if weapons[player] ~= nil then
- if name ~= weapons[player] then
- Pass = false
- end
- end
- end
- elseif type == "eqip" then
- if name == "revolution\\weapons\\frag grenade\\frag grenade" or name == "revolution\\weapons\\plasma grenade\\plasma grenade" then
- Pass = false
- end
- end
- return Pass
- end
- function OnGameEnd(stage)
- if stage == 1 then
- game_started = false
- if gameweap then
- gameweap = nil
- end
- if infbattery then
- infbattery = nil
- end
- if replaceplasmaweap then
- replaceplasmaweap = nil
- end
- elseif stage == 3 then
- for i = 0, 15 do
- if getplayer(i) then
- privatesay(i, "Thank you for playing Random Weapons for Revolution!")
- privatesay(i, "by H\174 Shaft")
- end
- end
- end
- end
- -- Start sendconsoletext overloaded by Nugget
- console = {}
- console.__index = console
- consoletimer = registertimer(100, "ConsoleTimer")
- phasor_sendconsoletext = sendconsoletext
- function sendconsoletext(player, message, time, order, align, height, func)
- if player then
- console[player] = console[player] or {}
- local temp = {}
- temp.player = player
- temp.id = nextid(player, order)
- temp.message = message or ""
- temp.time = time or 0.7
- temp.remain = temp.time
- temp.align = align or "left"
- temp.height = height or 0
- if type(func) == "function" then
- temp.func = func
- elseif type(func) == "string" then
- temp.func = _G[func]
- end
- console[player][temp.id] = temp
- setmetatable(console[player][temp.id], console)
- return console[player][temp.id]
- end
- end
- function nextid(player, order)
- if not order then
- local x = 0
- for k,v in pairs(console[player]) do
- if k > x + 1 then
- return x + 1
- end
- x = x + 1
- end
- return x + 1
- else
- local original = order
- while console[player][order] do
- order = order + 0.001
- if order == original + 0.999 then break end
- end
- return order
- end
- end
- function getmessage(player, order)
- if console[player] then
- if order then
- return console[player][order]
- end
- end
- end
- function getmessages(player)
- return console[player]
- end
- function getmessageblock(player, order)
- local temp = {}
- for k,v in opairs(console[player]) do
- if k >= order and k < order + 1 then
- table.insert(temp, console[player][k])
- end
- end
- return temp
- end
- function console:getmessage()
- return self.message
- end
- function console:append(message, reset)
- if console[self.player] then
- if console[self.player][self.id] then
- if getplayer(self.player) then
- if reset then
- if reset == true then
- console[self.player][self.id].remain = console[self.player][self.id].time
- elseif tonumber(reset) then
- console[self.player][self.id].time = tonumber(reset)
- console[self.player][self.id].remain = tonumber(reset)
- end
- end
- console[self.player][self.id].message = message or ""
- return true
- end
- end
- end
- end
- function console:shift(order)
- local temp = console[self.player][self.id]
- console[self.player][self.id] = console[self.player][order]
- console[self.player][order] = temp
- end
- function console:pause(time)
- console[self.player][self.id].pausetime = time or 5
- end
- function console:delete()
- console[self.player][self.id] = nil
- end
- function ConsoleTimer(id, count)
- for i,_ in opairs(console) do
- if tonumber(i) then
- if getplayer(i) then
- for k,v in opairs(console[i]) do
- if console[i][k].pausetime then
- console[i][k].pausetime = console[i][k].pausetime - 0.1
- if console[i][k].pausetime <= 0 then
- console[i][k].pausetime = nil
- end
- else
- if console[i][k].func then
- if not console[i][k].func(i) then
- console[i][k] = nil
- end
- end
- if console[i][k] then
- console[i][k].remain = console[i][k].remain - 0.1
- if console[i][k].remain <= 0 then
- console[i][k] = nil
- end
- end
- end
- end
- if table.len(console[i]) > 0 then
- local paused = 0
- for k,v in pairs(console[i]) do
- if console[i][k].pausetime then
- paused = paused + 1
- end
- end
- if paused < table.len(console[i]) then
- local str = ""
- for i = 0,30 do
- str = str .. " \n"
- end
- phasor_sendconsoletext(i, str)
- for k,v in opairs(console[i]) do
- if not console[i][k].pausetime then
- if console[i][k].align == "right" or console[i][k].align == "center" then
- phasor_sendconsoletext(i, consolecenter(string.sub(console[i][k].message, 1, 78)))
- else
- phasor_sendconsoletext(i, string.sub(console[i][k].message, 1, 78))
- end
- end
- end
- end
- end
- else
- console[i] = nil
- end
- end
- end
- return true
- end
- function consolecenter(text)
- if text then
- local len = string.len(text)
- for i = len + 1, 78 do
- text = " " .. text
- end
- return text
- end
- end
- function opairs(t)
- local keys = {}
- for k,v in pairs(t) do
- table.insert(keys, k)
- end
- table.sort(keys,
- function(a,b)
- if type(a) == "number" and type(b) == "number" then
- return a < b
- end
- an = string.lower(tostring(a))
- bn = string.lower(tostring(b))
- if an ~= bn then
- return an < bn
- else
- return tostring(a) < tostring(b)
- end
- end)
- local count = 1
- return function()
- if table.unpack(keys) then
- local key = keys[count]
- local value = t[key]
- count = count + 1
- return key,value
- end
- end
- end
- function table.len(t)
- local count = 0
- for k,v in pairs(t) do
- count = count + 1
- end
- return count
- end
- -- Stop sendconsoletext overloaded
- -- Created by H® Shaft.
- -- Thanks to Oxide, AelitePrime, Nugget & Wizard - and 002!
- -- Visit http://halorace.org/forum/index.php?topic=514.0 or
- -- Visit http://pastebin.com/u/HR_Shaft for more phasor scripts
Recent Pastes