--[[ Infection script for Phasor 2.0+ ]]-- --[[ By: Skylace, AElite, & Wizard]]-- --[[ Thanks to the people who helped me make this script]]-- -- Fixed a rare bug that caused the camouflage when crouch to not work. -- Notes: I did not remove any useless or redundant code due to the fact that I didn't have people to test my re-write and the game might hang if a player quits as last man (not sure if I fixed this or not.) -- Infection Settings killtimer = {} -- Global Variable default_script_prefix = "" -- Its recommended that you DO NOT CHANGE THIS human_team = 0 -- 0 is red, 1 is blue join_team = zombie_team -- the team that people will join if a game is currently running max_zombie_count = 2 -- this caps what the zombie count would be w/ ratio (nil is disable) time_invis = 0.5 -- In seconds, how long the zombie/human should be invis when they crouch. zombie_count = 1 -- if value is less than 1 is it used as a percentage, more than or equal to one is absolute count zombie_team = 1 -- 0 is red, 1 is blue speed_boost = 2.5 -- time extra speed lasts boost_amount = 0.5 -- Speed added to players current speed when the flashlight is activated. -- Alpha Zombie Variables alphazombie_frag_count = 0 -- number of frag nades they spawn with alphazombie_plasma_count = 0 -- number of plasma nades they spawn with alphazombie_clip_count = 0 -- number of shots in clip (loaded ammo) alphazombie_ammo_count = 0 -- backpack ammo they get (unloaded ammo) alphazombie_battery_count = 0 -- stored as a percent (0 to 1, do NOT go over or under) -- Zombie Variables zombie_ammo_count = 0 -- backpack ammo zombies once there are not only alpha zombies (unloaded ammo) zombie_clip_count = 0 -- number of shots in clip for zombies once there are not only alpha zombies (loaded ammo) zombie_battery_count = 0 -- stored as a percent (0 to 1, do NOT go over or under) zombie_frag_count = 0 -- number of frag nades they spawn with zombie_plasma_count = 0 -- number of plasma nades they spawn with zombie_spawn_time = 2 -- spawn time for zombies in seconds. Leave "default" for default spawn time of gametype zombie_speed = 1.75 -- zombie speed small_zombie_speed = 1.5 -- for small maps large_zombie_speed = 2.0 -- for large maps only_zombie_speed = 2.25 -- only zombie speed human_again = 4 -- kills zombies have to get to become a human again --Zombie weapons. -- Note: If you decide the player holds a flag or a ball, make sure the secondary, tertiary, and quarternary fields are "". -- DO NOT make zombies hold multiple weapons if you want them to hold an oddball or a flag. If you do it will not work right, and it's entirely your fault. zombie_weapon = {} -- don't touch this zombie_weapon[1] = "weapons\\ball\\ball" -- Primary weapon for zombies zombie_weapon[2] = "" -- Secondary weapon for zombies. zombie_weapon[3] = "" -- Tertiary weapon for zombies. zombie_weapon[4] = "" -- Quarternary weapon for zombies. -- Human Weapons -- Do not set human weapons to ball or flag! human_weapon = {} -- don't touch this human_weapon[1] = "weapons\\assault rifle\\assault rifle" -- Primary weapon for humans human_weapon[2] = "" -- Secondary weapon for humans. human_weapon[3] = "" -- Tertiary weapon for humans human_weapon[4] = "" -- Quarternary weapon for humans. -- Human Variables human_dmgmodifier = 1.55 -- damage modifier for humans. human_speed = 1.0 -- speed when not infected human_spawn_time = 2 -- spawn time for humans in seconds. Leave "default" for default spawn time of gametype -- Last Man Variables lastman_dmgmodifier = 1.75 -- damage modifier for the last man lastman_invistime = 20 -- in seconds lastman_invulnerable = 10 -- time (in seconds) the last man is invulnerable for: replace with nil to disable lastman_speed = 1.5 -- last man speed small_lastman_speed = 1.25 -- for small maps large_lastman_speed = 2.0 -- for large maps -- Booleans humans_allowed_in_vehis = false -- if this is set to false then humans cannot enter vehicles humans_invisible_on_crouch = false -- if this is set to true then humans will become invisible when they crouch. infect_on_fall = true -- if this is set to true then people who die from fall damage will become zombies. infect_on_guardians = true -- if this is set to true then people who get killed by the guardians will become zombies. infect_on_suicide = true -- if this is set to true then people who kill themselves will become a zombie. infect_on_betray = false -- if this is set to true then people who betray their teammates will become a zombie. last_man_next_zombie = true -- if this value is true the last man standing becomes the next zombie, if not it's random zombies_allowed_in_vehis = false -- if this is set to false then zombies cannot enter vehicles. zombies_invisible_on_crouch = true -- if this is set to true then zombies will be invisible when they crouch. kill_humanss_in_water = true -- for deathisland -- Death / Infect messages blockteamchange_message = "Autobalance: You're not allowed to change team." falling_infected_message = " fell..." falling_death_message = " fell..." kill_infected_message = " infected " suicide_infected_message = " lost the will to live..." suicide_message = " made mistakes..." teammate_infected_message = " was infected for betraying " guardian_infected_message = " was infected by nothing?!?!?" in_hill_too_long_msg = " was infected because they were in the hill too long!" human_kill_message = " killed " killed_in_water_msg = " died from going into the water!" --Hint Messages teamkill_message = "Don't team kill..." nozombiesleftmessage = "There are no zombies left. Someone needs to change team or be forced to." lastman_message = "%s is the last human alive and is invisible for %.0f seconds!" rejoin_message = "Please don't leave and rejoin. You've been put back onto your last team." zombieinvis_message = "The zombies are invisible for 30 seconds!" -- Complement Messages timer_team_change_msg = "Thank you. The game will now continue!" --zombie_backtap_message = "Nice backtap!" -- New Team Messages human_message = "YOUR A HUMAN!!! KILL THE FILTHY ZOMBIES!" zombie_message = "YOUR A ZOMBIE!!! KILL ALL HUMANS!" --Additional Messages welcome_message = "Welcome to Zombie Zone Infection!" koth_additional_welcome_msg = "The hill is a safezone! Use it for quick getaways!" -- Don't modify below variables unless you know what you're doing cur_zombie_count = 0 cur_zombie_count = 0 cur_human_count = 0 alpha_zombie_count = 0 human_time = {} cur_players = 0 cur_last_man = nil last_man_name = 0 processid = 0 game_started = false allow_change = false map_reset_boolean = false flagball_weap = {} last_hill_time = {} name_table = {} inhill_time = {} outsidemap = {} zkills = {} deathcoords = {} usedFlashlight = {} warned = {} last_damage = {} cur_map = "" phasor_say = say phasor_privatesay = privatesay function GetRequiredVersion() return 200 end function OnScriptLoad(process, game, persistent) GAME = game GetGameAddresses(game) processid = process Persistent = persistent ScriptLoad() end function OnScriptUnload() writedword(ctf_score_patch, 0xFFFDE9E8) writebyte(ctf_score_patch1, 0xFF) writebyte(slayer_score_patch, 0x74) writebyte(slayer_score_patch2, 0x75) writedword(koth_score_patch, 0xDA850F) writebyte(koth_score_patch2, 0x75) killtimer = false end function OnNewGame(map) killtimer = true if Persistent then ScriptLoad() end LoadTags() -- reset our variables cur_zombie_count = 0 cur_human_count = 0 cur_players = 0 resptime = 5 cur_map = map name_table = {} -- the game hasn't started yet, will once timer runs down game_started = false if new_game_timer == nil then new_game_timer = registertimer(7500, "NewGameTimer") end if map == "putput" or map == "longest" or map == "beavercreek" or map == "carousel" or map == "wizard" or map == "ratrace" then zombie_speed = small_zombie_speed lastman_speed = small_lastman_speed elseif map == "gephyrophobia" or map == "infinity" or map == "icefields" then zombie_speed = large_zombie_speed lastman_speed = large_lastman_speed end end function OnGameEnd(stage) killtimer = false game_started = false if stage == 1 then if humantimer then removetimer(humantimer) humantimer = nil end if new_game_timer then removetimer(new_game_timer) new_game_timer = nil end if speedtimer then removetimer(speedtimer) speedtimer = nil end end end function OnServerCommand(player, command) local allow = nil local cmd = tokenizecmdstring(command) local tokencount = #cmd if tokencount > 0 then if cmd[1] == "sv_map_reset" or (cmd[1] == "sv_script_reload" and cmd[2] == "infection") then map_reset_boolean = true for i = 0,15 do if getplayer(i) then local m_objectId = getplayerobjectid(i) if m_objectId and getteam(i) == zombie_team then destroyobject(m_objectId) end end end end end return allow end function OnPlayerJoin(player) spawnonspot[player] = false local team = getteam(player) outsidemap[player] = true -- update the player counts cur_players = cur_players + 1 local team = getteam(player) -- onteamdecision isn't called for ffa gametypes if not team_play then -- initialize the destination team as the join team local dest_team = join_team -- make sure the game is started if game_started then -- if no zombies make them human if cur_human_count == 0 then dest_team = human_team end end -- we need to overwrite the 'team' variable being passed to onplayerjoin team = dest_team end local thisTeamSize = 0 -- used so we don't create empty teams for rejoining players local thisTeamSize = 0 -- used so we don't create empty teams for rejoining players if team == zombie_team then cur_zombie_count = cur_zombie_count + 1 thisTeamSize = cur_zombie_count else cur_human_count = cur_human_count + 1 thisTeamSize = cur_human_count end alpha_zombie_count = getalphacount() local thisNAME = getname(player) local alreadyExists = false -- add team entry for this ip if alreadyExists == false then name_table[thisNAME] = team end -- make sure the game is started if game_started == true then -- check if the player is a zombie if team == zombie_team then --we don't need to update the counters since they're already on the zombieteam makezombie(player, false, true) --send them the zombie message privatesay(player, zombie_message) else -- if we're at last man, make this player a zombie if cur_last_man then --make this person a zombie (they're currently a human) makezombie(player, true) --send them the zombie message privatesay(player, zombie_message) else --make this person a human (they're currently a zombie) makehuman(player, false, true) --send them the human message privatesay(player, human_message) end end --send the player the welcome message privatesay(player, welcome_message) if gametype == "KOTH" then privatesay(player, koth_additional_welcome_msg) elseif gametype == "Slayer" and gametype_indicator == 1 then end registertimer(200,"checkgamestate",-1) else registertimer(10000, "MsgTimer", player) end end function OnPlayerLeave(player) local team = getteam(player) --check if they're a zombie if game_started and team == zombie_team then -- gets rid of any weapons a zombie is holding --destroyweapons(player) --take one away from the current zombie count cur_zombie_count = cur_zombie_count - 1 elseif game_started and team ~= zombie_team then --take one away from the current human count cur_human_count = cur_human_count - 1 end -- if last man is leaving, reset it if cur_last_man == player then cur_last_man = nil end --minus one from current players cur_players = cur_players - 1 --check the current game state (the player that left might have been the last man or the only zombie) registertimer(1000,"checkgamestate",-1) -- update team within table local thisNAME = getname(player) name_table[thisNAME] = team end function protect(idk, id1, objId) local m_object = getobject(objId) writebit(m_object + 0x10, 0, 1) registertimer(1000, "RemoveLastmanProtection", m_object) end spawnonspot = {} function OnPlayerSpawn(player) if killtimer then local m_player = getplayer(player) local objId = readdword(m_player, 0x34) movobjectcoords(objId, 0, 0, -1500) outsidemap[player] = true spawnonspot[player] = false end if outsidemap[player] ~= true then if spawnonspot[player] ~= false then spawnonspot[player] = false outsidemap[player] = false said[player] = false local m_player = getplayer(player) local objId = readdword(m_player, 0x34) if deathcoords[player] then sendconsoletext(player, "You will spawn were you last died!") movobjectcoords(objId, deathcoords[player].x, deathcoords[player].y, deathcoords[player].z) registertimer(0, "protect", objId) end end end usedFlashlight[player] = false local team = getteam(player) --get the player's team local team = getteam(player) --check if the player is a zombie if team == zombie_team then --get the player's object ID --make sure the player is alive (off chance that there's a glitch in phasor) local m_objectId = getplayerobjectid(player) if m_objectId == nil then return end --get the player's object struct local m_object = getobject(m_objectId) -- set nade counts writebyte(m_object + 0x31E, zombie_frag_count) writebyte(m_object + 0x31F, zombie_plasma_count) -- set the ammo local clipcount = alphazombie_clip_count local ammocount = alphazombie_ammo_count local batterycount = alphazombie_battery_count -- set ammo counts for zombies when others have been infected if cur_zombie_count > alpha_zombie_count then clipcount = zombie_clip_count ammocount = zombie_ammo_count batterycount = zombie_battery_count else -- set alpha nades writebyte(m_object + 0x31E, alphazombie_frag_count) writebyte(m_object + 0x31F, alphazombie_plasma_count) end table1 = {player, clipcount, ammocount, batterycount} registertimer(0, "AssignZombieWeapons", table1) elseif team == human_team then local m_objectId = getplayerobjectid(player) if m_objectId == nil then return end setspeed(player, human_speed) local m_object = getobject(m_objectId) -- set nade counts writebyte(m_object + 0x31E, 0) writebyte(m_object + 0x31F, 2) local clipcount = 60 local ammocount = 120 local batterycount = 1 registertimer(0, "AssignHumanWeapons", player) end --check if the type is slayer if gametype == "Slayer" then local m_player = getplayer(player) --check if we're at the last_man if m_player == nil then return end if cur_last_man then --write the navpoint to the current last man writeword(m_player, 0x88, cur_last_man) else writeword(m_player, 0x88, player) --there is no last man so put a nav above this player's head end end end function OnObjectCreationAttempt(mapId, parentId, player) if gametype == "CTF" and mapId == flag_tag_id and parentId == nil then registertimer(0, "PutUnderMap", readdword(ctf_globals + 0x8)) end return nil end invimsg = false function setfalse() invimsg = false end function OnObjectInteraction(player, objId, mapId) local response = false if game_started == true then if mapId ~= oddball_tag_id and mapId ~= flag_tag_id then if getteam(player) == zombie_team then if mapId == camouflage_tag_id then response = nil if getplayer(player) then local m_playerObjId = getplayerobjectid(player) if m_playerObjId then if readdword(getobject(m_playerObjId) + 0x204) ~= 0x51 then local doInvis = getrandomnumber(1, 11) if doInvis > 5 then -- make the whole zombie team invis for 30 seconds for x = 0,15 do if getplayer(x) and getteam(x) == zombie_team then applycamo(x, 30.00) registertimer(30000, "setfalse") end end if not invimsg then invimsg = true say(zombieinvis_message) end end end end end elseif mapId == overshield_tag_id or mapId == healthpack_tag_id then response = nil elseif mapId == fragnade_tag_id or mapId == plasmanade_tag_id then response = false end else response = nil end end end return response end function OnKillMultiplier(player, multiplier) local name = getname(player) if multiplier == 7 or multiplier == 16 then human_time[name] = tonumber(human_time[name]) + 5 elseif multiplier == 9 or multiplier == 17 then human_time[name] = tonumber(human_time[name]) + 10 elseif multiplier == 10 or multiplier == 14 then human_time[name] = tonumber(human_time[name]) + 15 end end died = {} function OnPlayerKill(killer, victim, mode) if victim and mode ~= 6 then local m_victim = getplayer(victim) local objId = readdword(m_victim, 0x34) local x, y, z = getobjectcoords(objId) deathcoords[victim] = {} deathcoords[victim].x = x deathcoords[victim].y = y deathcoords[victim].z = z end local response = false -- make sure this kill doesn't add to the score so that the game won't end prematurely if gametype == "Slayer" and killer and getplayer(killer) then writedword(slayer_globals + 0x40 + killer*4, 0) end -- make sure the game is started if game_started then -- get the victim's team local team = getteam(victim) if victim and team == zombie_team then -- gets rid of any weapons a zombie is holding destroyweapons(victim) end if victim then if resptime then writedword(getplayer(victim) + 0x2c, resptime * 33) elseif tonumber(human_spawn_time) and team ~= zombie_team then writedword(getplayer(victim) + 0x2C, tonumber(human_spawn_time) * 33) elseif tonumber(zombie_spawn_time) and team == zombie_team then writedword(getplayer(victim) + 0x2C, tonumber(zombie_spawn_time) * 33) end end if mode == 0 then -- server kill spawnonspot[victim] = false return false elseif mode == 1 and not map_reset_boolean then -- fall damage spawnonspot[victim] = false -- if this is true then a person who dies from falling will be infected if infect_on_fall then if tonumber(team) and team ~= zombie_team then response = false say(tostring(getname(victim)) .. falling_infected_message) registertimer(100, "makezombiedelay", {victim, true}) elseif tonumber(team) and team ~= human_team then response = false say(tostring(getname(victim)) .. falling_death_message) end responce = false else response = false say(tostring(getname(victim)) .. falling_death_message) end elseif mode == 2 then -- killed by guardians spawnonspot[victim] = true if infect_on_guardians then if tonumber(team) and team ~= zombie_team then response = false say(tostring(getname(victim)) .. guardian_infected_message) registertimer(100, "makezombiedelay", {victim, true}) end else response = false say(tostring(getname(victim)) .. guardian_infected_message) end elseif mode == 3 then -- killed by vehicle spawnonspot[victim] = false elseif mode == 4 then -- killed by another player local killer_team = getteam(killer) if tonumber(killer_team) and killer_team == zombie_team and tonumber(team) and team ~= zombie_team then response = false for i = 0,15 do if getplayer(i) ~= nil then if i ~= killer then privatesay(i, tostring(getname(killer)) .. kill_infected_message .. tostring(getname(victim))) end end end spawnonspot[victim] = true registertimer(100, "makezombiedelay", {victim, true}) privatesay(victim, zombie_message) local name = getname(killer) human_time[name] = tonumber(human_time[name]) + 10 countupzombiekils(killer) elseif killer_team ~= zombie_team and team == zombie_team then response = false spawnonspot[victim] = false for i = 0,15 do if getplayer(i) ~= nil then if i ~= killer then privatesay(i, tostring(getname(killer)) .. human_kill_message .. tostring(getname(victim))) end end end local name = getname(killer) human_time[name] = tonumber(human_time[name]) + 5 dropammoforhumans(victim) end elseif mode == 5 then -- betrayed if infect_on_betray then local killer_team = getteam(killer) if tonumber(killer_team) and killer_team ~= zombie_team then response = false for i = 0,15 do if getplayer(i) ~= nil then if i ~= killer then privatesay(i, tostring(getname(killer)) .. teammate_infected_message .. tostring(getname(victim))) end end end registertimer(100, "makezombiedelay", {killer, true}) elseif tonumber(killer_team) and killer_team ~= human_team then response = false for i = 0,15 do if getplayer(i) ~= nil then if i ~= killer then privatesay(i, tostring(getname(killer)) .. " betrayed " .. tostring(getname(victim))) end end end end elseif infect_on_betray == false then response = false for i = 0,15 do if getplayer(i) ~= nil then if i ~= killer then privatesay(i, tostring(getname(killer)) .. " betrayed " .. tostring(getname(victim))) end end end end elseif mode == 6 then -- suicide if infect_on_suicide then if tonumber(team) and team ~= zombie_team then response = false say(tostring(getname(victim)) .. suicide_infected_message) registertimer(100, "makezombiedelay", {victim, true}) elseif tonumber(team) and team ~= human_team then say(tostring(getname(victim)) .. " found himself tasty...") end elseif infect_on_suicide == false then response = false say(tostring(getname(victim)) .. suicide_message) end end -- this next block of code gets rid of any weapons a zombie is holding if tonumber(team) and team == zombie_team then destroyweapons(victim) end end registertimer(200,"checkgamestate", victim) return response end function countupzombiekils(killer) if zkills[killer] then zkills[killer] = zkills[killer] + 1 if zkills[killer] >= human_again then spawnonspot[killer] = true sendconsoletext(killer, "You are to full and have become a human again!") registertimer(100, "makehumandelay", {killer, true}) kill(killer) zkills[killer] = 0 end else zkills[killer] = 1 end end function dropammoforhumans(victim) local x = readfloat(getplayer(victim) + 0xF8) local y = readfloat(getplayer(victim) + 0xFC) local z = readfloat(getplayer(victim) + 0x100) if last_damage[gethash(victim)] == "weapons\\assault rifle\\bullet" then createobject(gettagid("eqip", "powerups\\assault rifle ammo\\assault rifle ammo"), 0, 30, false, x, y, z + 0.5) elseif last_damage[gethash(victim)] == "weapons\\flamethrower\\burning" or last_damage[gethash(victim)] == "weapons\\flamethrower\\explosion" or last_damage[gethash(victim)] == "weapons\\flamethrower\\impact damage" then createobject(gettagid("eqip", "powerups\\flamethrower ammo\\flamethrower ammo"), 0, 30, false, x, y, z + 0.5) elseif last_damage[gethash(victim)] == "weapons\\needler\\detonation damage" or last_damage[gethash(victim)] == "weapons\\needler\\explosion" or last_damage[vhash] == "weapons\\needler\\impact damage" then createobject(gettagid("eqip", "powerups\\needler ammo\\needler ammo"), 0, 30, false, x, y, z + 0.5) elseif last_damage[gethash(victim)] == "weapons\\pistol\\bullet" then createobject(gettagid("eqip", "powerups\\pistol ammo\\pistol ammo"), 0, 30, false, x, y, z + 0.5) elseif last_damage[gethash(victim)] == "weapons\\rocket launcher\\explosion" then createobject(gettagid("eqip", "powerups\\rocket launcher ammo\\rocket launcher ammo"), 0, 30, false, x, y, z + 0.5) elseif last_damage[gethash(victim)] == "weapons\\shotgun\\pellet" then createobject(gettagid("eqip", "powerups\\shotgun ammo\\shotgun ammo"), 0, 30, false, x, y, z + 0.5) elseif last_damage[gethash(victim)] == "weapons\\sniper rifle\\sniper bullet" then createobject(gettagid("eqip", "powerups\\sniper rifle ammo\\sniper rifle ammo"), 0, 30, false, x, y, z + 0.5) end end function OnTeamDecision(team) local dest_team = join_team if game_started then if cur_players == 0 then -- if no zombies make them human dest_team = human_team elseif cur_zombie_count > 0 and cur_human_count == 0 then dest_team = human_team end end return dest_team end function OnTeamChange(player, old_team, dest_team, voluntary) if voluntary then if not allow_change then privatesay(player, blockteamchange_message) elseif allow_change and old_team == zombie_team then -- this is so memory is updated for processing -- when voluntary is 0 OnTeamChange is called once the changes -- have been committed setspeed(player, zombie_speed) changeteam(player, true) end -- we don't let people change team elseif not voluntary then -- we can't stop the person changing teams, bein done by an admin -- update team counts if dest_team == zombie_team then cur_human_count = cur_human_count - 1 cur_zombie_count = cur_zombie_count + 1 elseif dest_team ~= zombie_team then cur_human_count = cur_human_count + 1 cur_zombie_count = cur_zombie_count - 1 end -- they're allowed to change if the timer is active, if it is disable it if allow_change == true and dest_team == zombie_team then allow_change = false --remove change timer if player_change_timer then removetimer(player_change_timer) player_change_timer = nil end say(timer_team_change_msg) end -- check if the game has started yet if game_started == true then -- set attributes if dest_team == zombie_team then makezombie(player, true) elseif dest_team ~= zombie_team then makehuman(player, true) end registertimer(200,"checkgamestate",player) end -- update team local thisNAME = getname(player) name_table[thisNAME] = team end registertimer(200,"checkgamestate",-1) return allow_change end function OnDamageApplication(receiving, causing, tagid, hit, backtap) if receiving then local player = objidtoplayer(receiving) if player then if not backtap then local tagname,tagtype = gettaginfo(tagid) last_damage[gethash(player)] = tagname else last_damage[gethash(player)] = "backtap" end end end end function OnDamageLookup(receiving, causing, mapId, tagdata) if causing and receiving then local causer = objidtoplayer(causing) local receiver = objidtoplayer(receiving) if causer and receiver then local c_team = getteam(causer) local r_team = getteam(receiver) if not team_play and r_team == c_team and causer ~= receiver then return false end -- if it's a human causing the damage if c_team ~= zombie_team then if cur_last_man then modifier = lastman_dmgmodifier else modifier = human_dmgmodifier end odl_multiplier(modifier) -- It's a zombie causing the damage elseif c_team == zombie_team then local tagname, tagtype = gettaginfo(mapId) -- check if it is melee damage if string.find(tagname, "melee", -5) then odl_multiplier(9999) end end end end end function objidtoplayer(objectId) local m_object = getobject(objectId) if m_object then local playerId = readword(m_object + 0xC0) local m_player = getplayer(playerId) if m_player then return playerId end end end function OnVehicleEntry(player, m_vehicleId, seat, mapId, relevant) if game_started and relevant == true then local team = getteam(player) if (team == zombie_team and zombies_allowed_in_vehis) or (team ~= zombie_team and humans_allowed_in_vehis) then return true end end return false end function haveSpeedTimer(useless1, useless2, player) if getplayer(player) ~= nil then local team = getteam(player) sendconsoletext(player, "Your speed boost has been removed.") if team == zombie_team then setspeed(player, zombie_speed) else setspeed(player, human_speed) end else say("reset_spd_failed " .. player .. " is nil") end return 0 end said = {} function OnClientUpdate(player) local m_objectId = getplayerobjectid(player) if m_objectId == nil then return end local m_object = getobject(m_objectId) local team = getteam(player) local flashlight = readbyte(m_object, 0x206) if flashlight == 8 and not usedFlashlight[player] then usedFlashlight[player] = true warned[player] = false registertimer(speed_boost * 1000, "haveSpeedTimer", player) if team ~= human_team then setspeed(player, boost_amount + zombie_speed) elseif team ~= zombie_team and not cur_last_man then setspeed(player, boost_amount + human_speed) elseif team ~= zombie_team and cur_last_man then setspeed(player, boost_amount + lastman_speed) end elseif flashlight == 8 and usedFlashlight[player] and not warned[player] then sendconsoletext(player, "You have been given a speed boost!") warned[player] = true end if readbyte(m_object + 0x2A0) == 3 then if getteam(player) == zombie_team then applycamo(player, 1) end end -- this block of code disables them the ability to drop the oddball_or_flag if oddball_or_flag and team == zombie_team and flagball_weap[player] then if game_started and readbit(m_object + 0x209, 3) == true or readbit(m_object + 0x209, 4) == true then assignweapon(player, flagball_weap[player]) end end local name = getname(player) -- this block of code sets the player's score according to what it should be. if tonumber(human_time[name]) then local m_player = getplayer(player) if gametype == "KOTH" then writewordsigned(m_player, 0xC4, human_time[name]*30) elseif gametype == "CTF" then writedwordsigned(m_player, 0xC8, human_time[name]) elseif gametype == "Slayer" then writedwordsigned(slayer_globals, 0x40 + player * 4, human_time[name]) end else human_time[name] = 0 end --this makes sure that people won't camp in unreachable places. and doesnt work local x,y,z = getobjectcoords(m_objectId) outsidemap[player] = false if kill_humanss_in_water then if not isinvehicle(player) then if z < 1.65 and cur_map == "deathisland" then outsidemap[player] = true if m_objectId then if team ~= zombie_team then kill(player) if not said[player] then said[player] = true say(getname(player) .. killed_in_water_msg, false) end if team == human_team and not cur_last_man then registertimer(100, "makezombiedelay", {player, true}) registertimer(200,"checkgamestate", player) end end end elseif z < -22 and cur_map == "gephyrophobia" then outsidemap[player] = true if m_objectId then if game_started then if team ~= zombie_team then kill(player) if not said[player] then say(getname(player) .. falling_infected_message, false) end if team == human_team and not cur_last_man then registertimer(100, "makezombiedelay", {player, true}) registertimer(200,"checkgamestate", player) end elseif team == zombie_team then kill(player) say(getname(player) .. falling_death_message, false) registertimer(200,"checkgamestate", player) end end end elseif z < -6 and cur_map == "boardingaction" then outsidemap[player] = true if m_objectId then if game_started then if team ~= zombie_team then kill(player) if not said[player] then say(getname(player) .. falling_infected_message, false) end if team == human_team and not cur_last_man then registertimer(100, "makezombiedelay", {player, true}) registertimer(200,"checkgamestate", player) end elseif team == zombie_team then kill(player) say(getname(player) .. falling_death_message, false) registertimer(200,"checkgamestate", player) end end end elseif z < -1 and cur_map == "damnation" then outsidemap[player] = true if m_objectId then if game_started then if team ~= zombie_team then kill(player) if not said[player] then say(getname(player) .. falling_infected_message, false) end if cur_last_man ~= nil then registertimer(100, "makezombiedelay", {player, true}) registertimer(200,"checkgamestate", player) end elseif team == zombie_team then kill(player) say(getname(player) .. falling_death_message, false) registertimer(200,"checkgamestate", player) end end end end end end if cur_map == "damnation" and team ~= zombie_team then elseif cur_map == "sidewinder" and team ~= zombie_team then if object_in_sphere(m_objectId, -4.76, -7.51, 2.96, 1.5) or object_in_sphere(m_objectId, -4.78, -5.07, 2.96, 1.5) or object_in_sphere(m_objectId, 3.11, -7.31, 2.96, 2) or object_in_sphere(m_objectId, 3.11, 7.31, 2.96, 2) then -- DP Entrances sendconsoletext(player, "You are not allowed to go there...") say(getname(player) .. " found a blocked spot...", false) kill(player) elseif object_in_sphere(m_objectId, 2.93, -13.03, 2.56, 1.5) or object_in_sphere(m_objectId, 5.56, -13.03, 2.56, 1.5) or object_in_sphere(m_objectId, -7.36, -13.02, 2.56, 1.5) or object_in_sphere(m_objectId, -4.72, -13.02, 2.56, 1.5) then -- tun exits tp dp sendconsoletext(player, "You are not allowed to go there...") say(getname(player) .. " found a blocked spot...", false) kill(player) elseif object_in_sphere(m_objectId, -5.8, -33.46, 2.29, 5) then -- vents cur only red side sendconsoletext(player, "You are not allowed to go there...") say(getname(player) .. " found a blocked spot...", false) kill(player) elseif object_in_sphere(m_objectId, -32.2, -32.48, 3, 1.25) then -- ledge above red base sendconsoletext(player, "You are not allowed to go there...") say(getname(player) .. " found a blocked spot...", false) kill(player) end elseif cur_map == "dangercanyon" and team ~= zombie_team then if object_in_sphere(m_objectId, 3.78, 32.84, 4.05, 1.5) or object_in_sphere(m_objectId, 9.94, -9.93, 0.03, 1.5) or object_in_sphere(m_objectId, -9.92, 9.95, 0.03, 1.5) or object_in_sphere(m_objectId, -9.95, -9.92, 0.03, 1.5) then -- Ledges inside of blue base sendconsoletext(player, "You are not allowed to go there...") say(getname(player) .. " found a blocked spot...", false) kill(player) elseif object_in_sphere(m_objectId, 3.78, 32.66, 4.05, 1.25) then -- ledge above red base sendconsoletext(player, "You are not allowed to go there...") say(getname(player) .. " found a blocked spot...", false) kill(player) end -- These are finished. elseif cur_map == "wizard" and team ~= zombie_team then if object_in_sphere(m_objectId, 9.94, -9.93, 0.03, 1.5) or object_in_sphere(m_objectId, 9.94, -9.93, 0.03, 1.5) or object_in_sphere(m_objectId, -9.92, 9.95, 0.03, 1.5) or object_in_sphere(m_objectId, -9.95, -9.92, 0.03, 1.5) then -- Ledges inside of blue base sendconsoletext(player, "You are not allowed to go there...") say(getname(player) .. " found a blocked spot...", false) kill(player) end elseif cur_map == "gephyrophobia" and team ~= zombie_team then if object_in_sphere(m_objectId, 74.78, -73.89, 7.43, 9) then -- Cliff Hanger sendconsoletext(player, "You are not allowed to go here...") say(getname(player) .. " found a blocked spot...", false) kill(player) elseif object_in_sphere(m_objectId, 26.9, -129.32, -5.19, 1.5) or object_in_sphere(m_objectId, 26.8, -15.32, -5.26, 1.5)then -- Above wires sendconsoletext(player, "You are not allowed to go here...") say(getname(player) .. " found a blocked spot...", false) kill(player) end elseif cur_map == "boardingaction" and team ~= zombie_team then if object_in_sphere(m_objectId, 3, -21.37, 7.22, 1.5) or object_in_sphere(m_objectId, 16.67, 21.19, 7.22, 1.5) then -- Ledges inside of blue base sendconsoletext(player, "You are not allowed to go there...") say(getname(player) .. " found a blocked spot...", false) kill(player) end elseif cur_map == "deathisland" and team ~= zombie_team then if object_in_sphere(m_objectId, 29.89, 15.29, 10.28, 2) or object_in_sphere(m_objectId, 29.89, 16.76, 10.28, 2.5) then -- Ledges inside of blue base sendconsoletext(player, "You are not allowed to go there...") say(getname(player) .. " found a blocked spot...", false) kill(player) elseif object_in_sphere(m_objectId, -26.51, -7.72, 11.65, 2) or object_in_sphere(m_objectId, -26.51, -6.25, 11.65, 2.5) then -- Ledges inside of red base sendconsoletext(player, "You are not allowed to go there...") say(getname(player) .. " found a blocked spot...", false) kill(player) elseif object_in_sphere(m_objectId, 16.82, -22.79, 8.72, 7) then -- Hole in the wall sendconsoletext(player, "You are not allowed to go there...") say(getname(player) .. " found a blocked spot...", false) kill(player) elseif object_in_sphere(m_objectId, 20.83, 50.92, 7.49, 5) then -- Island (the one not connected to the portal) (this only covers the landing!) sendconsoletext(player, "You are not allowed to go there...") say(getname(player) .. " found a blocked spot...", false) kill(player) end elseif cur_map == "infinity" and team ~= zombie_team then if object_in_sphere(m_objectId, 1.11, -141.68, 20.49, 1.5) or object_in_sphere(m_objectId, 0.09, -141.68, 20.49, 1.5) then -- Tower on red side sendconsoletext(player, "You are not allowed to go there...") say(getname(player) .. " found a blocked spot...", false) kill(player) elseif object_in_sphere(m_objectId, -2.33, 24.78, 18.61, 1.5) or object_in_sphere(m_objectId, -1.3, 24.78, 18.61, 1.5) then -- Tower on blue side sendconsoletext(player, "You are not allowed to go there...") say(getname(player) .. " found a blocked spot...", false) kill(player) elseif object_in_sphere(m_objectId, -52.73, -19.67, 17.4, 2) then sendconsoletext(player, "You are not allowed to go there...") say(getname(player) .. " found a blocked spot...", false) kill(player) elseif object_in_sphere(m_objectId, -53.29, -8.32, 21.01, 6) then sendconsoletext(player, "You are not allowed to go there...") say(getname(player) .. " found a blocked spot...", false) kill(player) end elseif cur_map == "bloodgulch" and team ~= zombie_team then if object_in_sphere(m_objectId, 80.96, -149.33, 3.1, 4) or object_in_sphere(m_objectId, 39.21, -96.36, 1.76, 4) then -- Trees sendconsoletext(player, "You are not allowed to go there...") say(getname(player) .. " found a blocked spot...", false) kill(player) elseif object_in_sphere(m_objectId, 92.38, -93.65, 9.33, 6) then -- Rock Tower (by os cave) sendconsoletext(player, "You are not allowed to go there...") say(getname(player) .. " found a blocked spot...", false) kill(player) end elseif cur_map == "icefields" and team ~= zombie_team then if object_in_sphere(m_objectId, 77.91, 98.62, 3.81, 1.5) or object_in_sphere(m_objectId, 24.83, -34.22, 3.82, 1.5) then -- Top of teleporters sendconsoletext(player, "You are not allowed to go there...") say(getname(player) .. " found a blocked spot...", false) kill(player) elseif object_in_sphere(m_objectId, 19.42, -8.84, 3.63, 4) or object_in_sphere(m_objectId, -72.18, 74.3, 3.15, 2) then -- Clifs infront of bases sendconsoletext(player, "You are not allowed to go there...") say(getname(player) .. " found a blocked spot...", false) kill(player) elseif object_in_sphere(m_objectId, 32.81, -32.56, 5.67, 5) or object_in_sphere(m_objectId, -85.74, 96.96, 5.62, 5) then -- Clifs behind of bases (by portal) sendconsoletext(player, "You are not allowed to go there...") say(getname(player) .. " found a blocked spot...", false) kill(player) elseif object_in_sphere(m_objectId, -17.66, 19.91, 11.58, 4) then -- Clif at bridge (unreachable one) sendconsoletext(player, "You are not allowed to go there...") say(getname(player) .. " found a blocked spot...", false) kill(player) end elseif cur_map == "hangemhigh" and team ~= zombie_team then if object_in_sphere(m_objectId, 7.38, 2.02, -3.16, 3) then -- Back room and shotgun room sendconsoletext(player, "You are not allowed to go there...") say(getname(player) .. " found a blocked spot...", false) kill(player) end elseif cur_map == "putput" and team ~= zombie_team then if object_in_sphere(m_objectId, -4.59, -20.67, 3.3, 1.5) or object_in_sphere(m_objectId, -2.78, -20.84, 3.3, 1.5) then -- Above power up spawn sendconsoletext(player, "You are not allowed to go there...") say(getname(player) .. " found a blocked spot...", false) kill(player) end elseif cur_map == "chillout" and team ~= zombie_team then if object_in_sphere(m_objectId, 11.26, 8.82, 3.16, 2) or object_in_sphere(m_objectId, -7.16, 7.8, 4.34, 3) then -- Back room and shotgun room sendconsoletext(player, "You are not allowed to go there...") say(getname(player) .. " found a blocked spot...", false) kill(player) end end end function all_players_zombies(player) if player ~= nil and player ~= -1 and getplayer(player) then last_man_name = getname(player) local file = io.open("lastname_" .. processid .. ".tmp", "w") if (file ~= nil) then file:write(tostring(last_man_name)) file:close() end end svcmd("sv_map_next") end function AssignZombieWeapons(id, count, table) local player = table[1] local clipcount = table[2] local ammocount = table[3] local batterycount = table[4] if getplayer(player) == nil then return end local m_objectId = getplayerobjectid(player) if m_objectId then local m_object = getobject(m_objectId) --count is increased everytime the timer is called if count == 1 then -- gets rid of any weapons a zombie is holding destroyweapons(player) end local i = count if zombie_weapon and zombie_weapon[i] and zombie_weapon[i] ~= "" then local m_weaponId = createobject(gettagid("weap", zombie_weapon[i]), 0, 0, false, 1, 1, 1) if m_weaponId and m_weaponId ~= 0xFFFFFFFF then assignweapon(player, m_weaponId) if oddball_or_flag == readdword(getobject(m_weaponId)) then flagball_weap[player] = m_weaponId else local m_weapon = getobject(m_weaponId) if m_weapon then -- set the ammo writeword(m_weapon, 0x2B6, ammocount) writeword(m_weapon, 0x2B8, clipcount) writefloat(m_weapon, 0x240, 1) -- force it to sync updateammo(m_weaponId) end end end end if count < 4 then return true else return false end end return false end function AssignHumanWeapons(id, count, player) if getplayer(player) == nil then return end local m_objectId = getplayerobjectid(player) if m_objectId then local m_object = getobject(m_objectId) --count is increased everytime the timer is called if count == 1 then -- gets rid of any weapons a zombie is holding destroyweapons(player) end local i = count if human_weapon and human_weapon[i] and human_weapon[i] ~= "" then local m_weaponId = createobject(gettagid("weap", human_weapon[i]), 0, 0, false, 1, 1, 1) if m_weaponId and m_weaponId ~= 0xFFFFFFFF then assignweapon(player, m_weaponId) end end if count < 4 then return true else return false end end return false end function checkgamestate(id, count, player) -- check if the game has started yet if game_started == true then local human_count, zombie_count = getteamsizes() -- if no humans, but there are zombies, end the game if human_count == 0 and zombie_count > 0 then all_players_zombies(player) elseif human_count > 1 and zombie_count == 0 then noZombiesLeft() elseif human_count == 1 and zombie_count > 0 and not cur_last_man then onlastman() elseif cur_last_man and zombie_count == 0 then if getplayer(cur_last_man) then makehuman(cur_last_man, false) end cur_last_man = nil elseif cur_last_man and human_count > 1 then if gametype == "Slayer" then takenavsaway(cur_last_man) end if getplayer(cur_last_man) then makehuman(cur_last_man, false) end cur_last_man = nil end end return false end function ChooseRandomPlayer(excludeTeam) -- loop through all 16 possible spots and add to table local t = getplayertable(excludeTeam) if #t > 0 then -- generate a random number that we will use to select a player local r = getrandomnumber(1, #t+1) return tonumber(t[r]) else return nil end end function destroyweapons(player) for i = 0,3 do -- loop through the player's weapons (primary to quartenary) local m_weaponId = getweaponobjectid(player, i) if m_weaponId ~= 0xFFFFFFFF then destroyobject(m_weaponId) end end end function DelayWriteCoords(id, count) writefloat(readdword(ctf_globals + 0x0), 0x8, readfloat(readdword(ctf_globals + 0x0), 0x8) - 100) writefloat(readdword(ctf_globals + 0x4), 0x8, readfloat(readdword(ctf_globals + 0x4), 0x8) - 100) return false end function getalphacount() -- recalculate how many "alpha" zombies there are if zombie_count < 1 then alpha_zombie_count = round((cur_players * zombie_count) + 0.5) else alpha_zombie_count = zombie_count end if alpha_zombie_count > max_zombie_count then alpha_zombie_count = max_zombie_count end return alpha_zombie_count end function GetGameAddresses(game) if game == "PC" then map_pointer = 0x63525c ctf_globals = 0x639B98 flag_respawn_addr = 0x488A7E gametype_base = 0x671340 slayer_globals = 0x63A0E8 team_koth_score_array = 0x639BD0 ctf_score_patch = 0x488602 ctf_score_patch1 = 0x488606 slayer_score_patch = 0x48F428 slayer_score_patch2 = 0x48F23E koth_score_patch = 0x48A798 koth_score_patch2 = 0x48A76D else map_pointer = 0x5B927C ctf_globals = 0x5BDBB8 flag_respawn_addr = 0x4638EE gametype_base = 0x5F5498 slayer_globals = 0x5BE108 team_koth_score_array = 0x5BDBF0 ctf_score_patch = 0x463472 ctf_score_patch1 = 0x463476 slayer_score_patch = 0x469CF8 slayer_score_patch2 = 0x4691CE koth_score_patch = 0x465458 koth_score_patch2 = 0x46542D end end function getplayertable(excludeTeam) local players = "" for i=0,15 do if getplayer(i) and getteam(i) ~= excludeTeam then if players == nil then players = i .. "," else players = players .. i .. "," end end end return tokenizestring(players, ",") end function getteamplay() local team_play = readbyte(gametype_base + 0x34) if team_play == 1 then return true else return false end end function getteamsizes() local human_size = 0 local zombie_size = 0 human_size = getteamsize(0) zombie_size = getteamsize(1) return human_size,zombie_size 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 HumanTimer(id, count) if map_reset_boolean == true then map_reset_boolean = false end if game_started == true then for i = 0,15 do if getplayer(i) then local m_player = getplayer(i) local name = getname(i) local team = getteam(i) local m_objectId = getplayerobjectid(i) if m_objectId then local m_object = getobject(m_objectId) if m_object then if tonumber(human_time[name]) then human_time[name] = tonumber(human_time[name]) + 0.1 else human_time[name] = 1 end end end if gametype == "KOTH" then local m_objectId = getplayerobjectid(i) if m_objectId then local m_object = getobject(m_objectId) if PlayerInHill(i) == true and m_object then if inhill_time[name] == nil then inhill_time[name] = 0 writebit(m_object + 0x10, 0, 1) if team ~= zombie_team then say(getname(i) .. " must leave the hill in 10 seconds or they will be infected!") else say(getname(i) .. " must leave the hill in 10 seconds or they will be killed!") end elseif inhill_time[name] >= 10 then if team ~= zombie_team then makezombie(i, true) say(getname(i) .. in_hill_too_long_msg) else kill(i) say(getname(i) .. " has been killed because they were in the hill too long!") end inhill_time[name] = nil elseif team ~= zombie_team then privatesay(i, "You have " .. math.abs(inhill_time[name] - 10) .. " seconds to leave the hill!") inhill_time[name] = inhill_time[name] + 1 end elseif m_object then inhill_time[name] = nil writebit(m_object + 0x10, 0, 0) end end end end end end return true end function LoadTags() for i = 1,4 do if zombie_weapon[i] == "weapons\\ball\\ball" or zombie_weapon[i] == "weapons\\flag\\flag" then oddball_or_flag = gettagid("weap", zombie_weapon[i]) end end camouflage_tag_id = gettagid("eqip", "powerups\\active camouflage") healthpack_tag_id = gettagid("eqip", "powerups\\health pack") overshield_tag_id = gettagid("eqip", "powerups\\over shield") fragnade_tag_id = gettagid("eqip", "weapons\\frag grenade\\frag grenade") plasmanade_tag_id = gettagid("eqip", "weapons\\plasma grenade\\plasma grenade") fragnade_tag_id = gettagid("eqip", "weapons\\frag grenade\\frag grenade") plasmanade_tag_id = gettagid("eqip", "weapons\\plasma grenade\\plasma grenade") oddball_tag_id = gettagid("weap", "weapons\\ball\\ball") flag_tag_id = gettagid("weap", "weapons\\flag\\flag") end function makehuman(player, forcekill, updatecounters) if getplayer(player) then if gametype == "Slayer" then writebyte(getplayer(player) + 0x20, human_team) end -- change the player's speed setspeed(player, human_speed) if getteam(player) == zombie_team then changeteam(player, forcekill) if not team_play then OnFFATeamChange(player, getteam(player), updatecounters) end end end end function makezombie(player, forcekill, updatecounters) if getplayer(player) ~= nil then if gametype == "Slayer" then writebyte(getplayer(player) + 0x20, zombie_team) end -- change the player's speed setspeed(player, zombie_speed) if getteam(player) ~= zombie_team then changeteam(player, forcekill) if not team_play then OnFFATeamChange(player, getteam(player), updatecounters) end end else say("Makezombie got nil") end end function makezombiedelay(id, count, arg) makezombie(arg[1], arg[2]) end function makehumandelay(id, count, arg) makehuman(arg[1], arg[2]) end function MsgTimer(id, count, player) if getplayer(player) then privatesay(player, welcome_message) if gametype == "KOTH" then privatesay(player, koth_additional_welcome_msg) elseif gametype == "Slayer" then --local msg = tokenizestring(slayer_additional_welcome_msg, "\n") --privatesay(player, msg[1]) --privatesay(player, msg[2]) end end return false end function NewGameTimer(id, count) if cur_players ~= 0 then local newgame_zombie_count = 0 -- by default make all players human for x=0,15 do if getplayer(x) then local thisTeam = getteam(x) local name = getname(x) if thisTeam then if thisTeam == zombie_team then changeteam(x, 0) end human_time[name] = 0 end end end local possible_count = cur_players -- make players zombie until the count has been met local finalZombies = 0 if zombie_count >= 1 then finalZombies = zombie_count else finalZombies = round((possible_count * zombie_count) + 0.5) end -- make last man zombie local last_man_index = -1 -- check if the last man is to be made a zombie -- if so find who was last man if last_man_next_zombie == true and cur_players > 1 then -- loop through all IP's and check if any match the last man readlastman() for i=0,15 do if getplayer(i) then local name = getname(i) if last_man_name == name then -- make them a zombie and save their info makezombie(i, true) newgame_zombie_count = 1 last_man_index = i break end end end end -- reset last man last_man_name = 0 if finalZombies == cur_players then -- if 0 players they will be human finalZombies = finalZombies - 1 elseif finalZombies > possible_count then -- fix the count finalZombies = possible_count elseif max_zombie_count and finalZombies > max_zombie_count then -- cap the zombie count finalZombies = max_zombie_count elseif finalZombies < 0 then finalZombies = 0 end -- set counters such that ChangeTeam wont end the game cur_zombie_count = 16 cur_human_count = 16 -- loop through the players, randomly selecting ones to become -- zombies while (newgame_zombie_count < finalZombies) do -- randomly choose a player local newzomb = ChooseRandomPlayer(zombie_team) if newzomb == nil then break elseif newzomb ~= last_man_index then makezombie(newzomb, true) newgame_zombie_count = newgame_zombie_count + 1 end end -- fix the team counters cur_zombie_count = newgame_zombie_count cur_human_count = cur_players - finalZombies -- reset the map killtimer = false svcmd("sv_map_reset") hprintf("Game started") say("The game has started") -- loop through and tell players which team they're on for i=0,15 do if getplayer(i) then local pteam = getteam(i) if pteam then -- check if they're a zombie if pteam == zombie_team then privatesay(i, zombie_message) else if not team_play then makehuman(i) end privatesay(i, human_message) end end end end end game_started = true killtimer = false new_game_timer = nil resptime = nil return false -- remove timer end function noZombiesLeft() if team_play then if player_change_timer == nil then allow_change = true say(nozombiesleftmessage) player_change_timer = registertimer(1000, "PlayerChangeTimer") end else -- pick a human and make them zombie. local newZomb = ChooseRandomPlayer(zombie_team) if newZomb then makezombie(newZomb, true) privatesay(newZomb, zombie_message) end end end function object_in_sphere(m_objectId, X, Y, Z, R) local Pass = false if getobject(m_objectId) then local x,y,z = getobjectcoords(m_objectId) if (X - x)^2 + (Y - y)^2 + (Z - z)^2 <= R then Pass = true end end return Pass end function OnFFATeamChange(player, dest_team, updatecounters) -- update team counts if not updatecounters then if dest_team == zombie_team then cur_human_count = cur_human_count - 1 cur_zombie_count = cur_zombie_count + 1 elseif dest_team ~= zombie_team then cur_human_count = cur_human_count + 1 cur_zombie_count = cur_zombie_count - 1 end end -- check if the game has started yet if game_started == true then registertimer(200,"checkgamestate",player) end -- update team with local thisNAME = getname(player) name_table[thisNAME] = team end function onlastman() -- lookup the last man for x=0,15 do if getplayer(x) then local team = getteam(x) if team ~= zombie_team and team then cur_last_man = x if gametype == "Slayer" then WriteNavsToZombies(x) end -- give the last man speed and extra ammo setspeed(x, lastman_speed) -- find the last man's weapons local m_player = getplayer(x) if m_player then local m_ObjId = readdword(m_player + 0x34) if m_ObjId then -- find the player's object local m_object = getobject(m_ObjId) if m_object then if lastman_invulnerable and lastman_invulnerable > 0 then -- setup the invulnerable timer writebit(m_object + 0x10, 0, 1) registertimer(lastman_invulnerable * 1000, "RemoveLastmanProtection", m_object) end -- give all weapons 600 ammo for i=0,3 do local m_weaponId = readdword(m_object + 0x2F8 + (i*4)) if m_weaponId ~= 0xffffffff then -- get the weapons memory address local m_weapon = getobject(m_weaponId) if m_weapon then -- set the ammo writeword(m_weapon, 0x2B6, 132) writeword(m_weapon, 0x2B8, 100) --lastman clipcount updateammo(m_weaponId) end end end end end end end end end if cur_last_man then local lastman_name = getname(cur_last_man) local msg = string.format(lastman_message, tostring(lastman_name), lastman_invistime) say(msg) applycamo(cur_last_man, lastman_invistime) end end function PlayerChangeTimer(id, count) if count ~= 6 and team_play then local zombsize = cur_zombie_count if allow_change == false or zombsize > 0 then allow_change = false say("Thank you, the game can continue.") player_change_timer = nil return false end say("In " .. 6 - count .. " seconds a player will be forced to become a zombie.") return true else -- timer up, force team change allow_change = false -- pick a human and make them zombie. local newZomb = ChooseRandomPlayer(zombie_team) if newZomb ~= nil then makezombie(newZomb, true) kill(newZomb) say(getname(newZomb) .. " is now the new zombie!", false) privatesay(newZomb, zombie_message) else say("PlayerChangeTimer got nil") end player_change_timer = nil return false end end function PlayerInHill(player) player = tonumber(player) local bool = false local m_player = getplayer(player) if m_player then local InHill = readbyte(team_koth_score_array + player + 0x80) if InHill == 1 then bool = true end end return bool end function PutUnderMap(id, count, m_objectId) local m_object = getobject(m_objectId) if m_object then local x,y,z = getobjectcoords(m_objectId) movobjectcoords(m_objectId, x, y, z - 20) end return false end function privatesay(player, message, script_prefix) if GAME == "PC" then phasor_privatesay(player, (script_prefix or default_script_prefix) .. message, false) else phasor_privatesay(player, message, false) end end function say(message, script_prefix) if GAME == "PC" then phasor_say((script_prefix or default_script_prefix) .. message, false) else phasor_say(message, false) end end function sendresponse(message, player) if message == "" then return end player = tonumber(player) if tonumber(player) and player ~= nil and player ~= -1 and player >= 0 and player < 16 then sendconsoletext(player, message) else hprintf(message) end end function ScriptLoad() if Persistent then cur_zombie_count = 0 cur_human_count = 0 alpha_zombie_count = 0 human_time = {} cur_players = 0 cur_last_man = nil last_man_name = 0 processid = 0 game_started = false allow_change = false flagball_weap = {} last_hill_time = {} name_table = {} inhill_time = {} end gametype = readbyte(gametype_base + 0x30) gametype_indicator = readbyte(gametype_base + 0x3C) writedword(ctf_score_patch, 0x90909090) writebyte(ctf_score_patch1, 0x90) writebyte(slayer_score_patch, 0xEB) writebyte(slayer_score_patch2, 0xEB) writedword(koth_score_patch, 0xF3E9) writebyte(koth_score_patch2, 0xEB) -- recalculate team counters cur_human_count, cur_zombie_count = getteamsizes() cur_players = cur_zombie_count + cur_human_count -- recalculate how many "alpha" zombies there are alpha_zombie_count = getalphacount() team_play = getteamplay() if gametype == 1 then gametype = "CTF" writedword(flag_respawn_addr + 0x0, 0xFFFFFFFF) registertimer(0, "DelayWriteCoords") join_team = zombie_team elseif gametype == 2 then gametype = "Slayer" join_team = zombie_team if speedtimer == nil then speedtimer = registertimer(750, "SpeedTimer") end for player=0,15 do if getplayer(player) then cur_players = cur_players + 1 local team = getteam(player) -- onteamdecision isn't called for ffa gametypes if not team_play then -- initialize the destination team as the join team local dest_team = join_team -- if no zombies make them human if cur_human_count == 0 then dest_team = human_team end -- we need to overwrite the 'team' variable being passed to onplayerjoin team = dest_team end if team == zombie_team then cur_zombie_count = cur_zombie_count + 1 --we don't need to update the counters since they're already on the zombieteam makezombie(player, false, true) --send them the zombie message privatesay(player, zombie_message) else cur_human_count = cur_human_count + 1 --make this person a human (they're currently a zombie) makehuman(player, false, true) --send them the human message privatesay(player, human_message) end end end elseif gametype == 4 then gametype = "KOTH" join_team = zombie_team else join_team = zombie_team hprintf("Incompatible gametype!") end -- assume a game is running game_started = true if humantimer == nil then humantimer = registertimer(1000, "HumanTimer") end LoadTags() registertimer(200,"checkgamestate",-1) end function readlastman() local file = io.open("lastname_" .. processid .. ".tmp", "r") if file then -- read the ip last_man_name = file:read("*line") file:close() -- delete the file os.remove("lastname_" .. processid .. ".tmp") end end function SpeedTimer(id, count) if gametype == "Slayer" then for i = 0,15 do local m_player = getplayer(i) if m_player then local speed = readfloat(m_player, 0x6C) if getteam(i) == zombie_team and speed < zombie_speed then setspeed(i, zombie_speed) elseif getteam(i) ~= zombie_team and cur_last_man and speed < lastman_speed then setspeed(i, lastman_speed) elseif getteam(i) ~= zombie_team and not cur_last_man and speed < human_speed then setspeed(i, human_speed) end end end return true end return false end function RemoveLastmanProtection(id, count, m_object) writebit(m_object + 0x10, 0, 0) return false end function round(val, decimal) return math.floor((val * 10^(tonumber(decimal) or 0) + 0.5)) / (10^(tonumber(decimal) or 0)) end function takenavsaway(lastman) for i = 0,15 do local m_player = getplayer(i) if m_player then writeword(m_player, 0x88, i) end end end function WriteNavsToZombies(cur_last_man) for i = 0,15 do if getplayer(i) ~= nil then local team = getteam(i) if team == zombie_team then local m_player = getplayer(i) if m_player then local slayer_target = readword(m_player, 0x88) if slayer_target < 16 and slayer_target > -1 then writeword(m_player, 0x88, cur_last_man) end end end end end end function writewordsigned(address, offset, value) if tonumber(value) and value > 0x7FFF then local difference = 0xFFFF - value value = -1 - difference end writeword(address + offset, value) end function writedwordsigned(address, offset, value) if value and value > 0x7FFFFFFF then local difference = 0xFFFFFFFF - value value = -1 - difference end writedword(address + offset, value) end