Advertisement
it300

Infection - Phasor 2.0+

Dec 15th, 2014
598
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 64.53 KB | None | 0 0
  1. --[[ Infection script for Phasor 2.0+ ]]--
  2. --[[ By: Skylace, AElite, & Wizard]]--
  3. --[[ Thanks to the people who helped me make this script]]--
  4.  
  5. -- Fixed a rare bug that caused the camouflage when crouch to not work.
  6.  
  7. -- 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.)
  8.  
  9. -- Infection Settings
  10. killtimer = {}
  11. -- Global Variable
  12. default_script_prefix = "" -- Its recommended that you DO NOT CHANGE THIS
  13. human_team = 0 -- 0 is red, 1 is blue
  14. join_team = zombie_team -- the team that people will join if a game is currently running
  15. max_zombie_count = 2 -- this caps what the zombie count would be w/ ratio (nil is disable)
  16. time_invis = 0.5 -- In seconds, how long the zombie/human should be invis when they crouch.
  17. zombie_count = 1 -- if value is less than 1 is it used as a percentage, more than or equal to one is absolute count
  18. zombie_team = 1 -- 0 is red, 1 is blue
  19. speed_boost = 2.5 -- time extra speed lasts
  20. boost_amount = 0.5 -- Speed added to players current speed when the flashlight is activated.
  21.  
  22.     -- Alpha Zombie Variables
  23. alphazombie_frag_count = 0 -- number of frag nades they spawn with
  24. alphazombie_plasma_count = 0 -- number of plasma nades they spawn with
  25. alphazombie_clip_count = 0 -- number of shots in clip (loaded ammo)
  26. alphazombie_ammo_count = 0 -- backpack ammo they get (unloaded ammo)
  27. alphazombie_battery_count = 0 -- stored as a percent (0 to 1, do NOT go over or under)
  28.  
  29.     -- Zombie Variables
  30. zombie_ammo_count = 0 -- backpack ammo zombies once there are not only alpha zombies (unloaded ammo)
  31. zombie_clip_count = 0 -- number of shots in clip for zombies once there are not only alpha zombies (loaded ammo)
  32. zombie_battery_count = 0 -- stored as a percent (0 to 1, do NOT go over or under)
  33. zombie_frag_count = 0 -- number of frag nades they spawn with
  34. zombie_plasma_count = 0 -- number of plasma nades they spawn with
  35. zombie_spawn_time = 2 -- spawn time for zombies in seconds. Leave "default" for default spawn time of gametype
  36. zombie_speed = 1.75 -- zombie speed
  37. small_zombie_speed = 1.5 -- for small maps
  38. large_zombie_speed = 2.0 -- for large maps
  39. only_zombie_speed = 2.25 -- only zombie speed
  40. human_again = 4 -- kills zombies have to get to become a human again
  41.  
  42. --Zombie weapons.
  43. -- Note: If you decide the player holds a flag or a ball, make sure the secondary, tertiary, and quarternary fields are "".
  44. -- 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.
  45. zombie_weapon = {} -- don't touch this
  46. zombie_weapon[1] = "weapons\\ball\\ball" -- Primary weapon for zombies
  47. zombie_weapon[2] = "" -- Secondary weapon for zombies.
  48. zombie_weapon[3] = "" -- Tertiary weapon for zombies.
  49. zombie_weapon[4] = "" -- Quarternary weapon for zombies.
  50.  
  51. -- Human Weapons
  52. -- Do not set human weapons to ball or flag!
  53. human_weapon = {} -- don't touch this
  54. human_weapon[1] = "weapons\\assault rifle\\assault rifle" -- Primary weapon for humans
  55. human_weapon[2] = "" -- Secondary weapon for humans.
  56. human_weapon[3] = "" -- Tertiary weapon for humans
  57. human_weapon[4] = "" -- Quarternary weapon for humans.
  58.  
  59.     -- Human Variables
  60. human_dmgmodifier = 1.55 -- damage modifier for humans.
  61. human_speed = 1.0 -- speed when not infected
  62. human_spawn_time = 2 -- spawn time for humans in seconds. Leave "default" for default spawn time of gametype
  63.  
  64.     -- Last Man Variables
  65. lastman_dmgmodifier = 1.75 -- damage modifier for the last man
  66. lastman_invistime = 20 -- in seconds
  67. lastman_invulnerable = 10 -- time (in seconds) the last man is invulnerable for: replace with nil to disable
  68. lastman_speed = 1.5 -- last man speed
  69. small_lastman_speed = 1.25 -- for small maps
  70. large_lastman_speed = 2.0 -- for large maps
  71.  
  72.     -- Booleans
  73. humans_allowed_in_vehis = false -- if this is set to false then humans cannot enter vehicles
  74. humans_invisible_on_crouch = false -- if this is set to true then humans will become invisible when they crouch.
  75. infect_on_fall = true -- if this is set to true then people who die from fall damage will become zombies.
  76. infect_on_guardians = true -- if this is set to true then people who get killed by the guardians will become zombies.
  77. infect_on_suicide = true -- if this is set to true then people who kill themselves will become a zombie.
  78. infect_on_betray = false -- if this is set to true then people who betray their teammates will become a zombie.
  79. last_man_next_zombie = true -- if this value is true the last man standing becomes the next zombie, if not it's random
  80. zombies_allowed_in_vehis = false -- if this is set to false then zombies cannot enter vehicles.
  81. zombies_invisible_on_crouch = true -- if this is set to true then zombies will be invisible when they crouch.
  82. kill_humanss_in_water = true -- for deathisland
  83.  
  84. -- Death / Infect messages
  85. blockteamchange_message = "Autobalance: You're not allowed to change team."
  86. falling_infected_message = " fell..."
  87. falling_death_message = " fell..."
  88. kill_infected_message = " infected "
  89. suicide_infected_message = " lost the will to live..."
  90. suicide_message = " made mistakes..."
  91. teammate_infected_message = " was infected for betraying "
  92. guardian_infected_message = " was infected by nothing?!?!?"
  93. in_hill_too_long_msg = " was infected because they were in the hill too long!"
  94. human_kill_message = " killed "
  95. killed_in_water_msg = " died from going into the water!"
  96.  
  97. --Hint Messages
  98. teamkill_message = "Don't team kill..."
  99. nozombiesleftmessage = "There are no zombies left. Someone needs to change team or be forced to."
  100. lastman_message = "%s is the last human alive and is invisible for %.0f seconds!"
  101. rejoin_message = "Please don't leave and rejoin. You've been put back onto your last team."
  102. zombieinvis_message = "The zombies are invisible for 30 seconds!"
  103.  
  104. -- Complement Messages
  105. timer_team_change_msg = "Thank you. The game will now continue!"
  106. --zombie_backtap_message = "Nice backtap!"
  107.  
  108. -- New Team Messages
  109. human_message = "YOUR A HUMAN!!! KILL THE FILTHY ZOMBIES!"
  110. zombie_message = "YOUR A ZOMBIE!!! KILL ALL HUMANS!"
  111.  
  112. --Additional Messages
  113. welcome_message = "Welcome to Zombie Zone Infection!"
  114. koth_additional_welcome_msg = "The hill is a safezone! Use it for quick getaways!"
  115.  
  116. -- Don't modify below variables unless you know what you're doing
  117. cur_zombie_count = 0
  118. cur_zombie_count = 0
  119. cur_human_count = 0
  120. alpha_zombie_count = 0
  121. human_time = {}
  122. cur_players = 0
  123. cur_last_man = nil
  124. last_man_name = 0
  125. processid = 0
  126. game_started = false
  127. allow_change = false
  128. map_reset_boolean = false
  129. flagball_weap = {}
  130. last_hill_time = {}
  131. name_table = {}
  132. inhill_time = {}
  133. outsidemap = {}
  134. zkills = {}
  135. deathcoords = {}
  136. usedFlashlight = {}
  137. warned = {}
  138. last_damage = {}
  139. cur_map = ""
  140.  
  141.  
  142.  
  143. phasor_say = say
  144. phasor_privatesay = privatesay
  145.  
  146. function GetRequiredVersion()
  147.     return 200
  148. end
  149.  
  150. function OnScriptLoad(process, game, persistent)
  151.     GAME = game
  152.     GetGameAddresses(game)
  153.     processid = process
  154.     Persistent = persistent
  155.     ScriptLoad()
  156. end
  157.  
  158. function OnScriptUnload()
  159.     writedword(ctf_score_patch, 0xFFFDE9E8)
  160.     writebyte(ctf_score_patch1, 0xFF)
  161.     writebyte(slayer_score_patch, 0x74)
  162.     writebyte(slayer_score_patch2, 0x75)
  163.     writedword(koth_score_patch, 0xDA850F)
  164.     writebyte(koth_score_patch2, 0x75)
  165.     killtimer = false
  166. end
  167.  
  168. function OnNewGame(map)
  169.     killtimer = true
  170.  
  171.     if Persistent then ScriptLoad() end
  172.     LoadTags()
  173.     -- reset our variables
  174.     cur_zombie_count = 0
  175.     cur_human_count = 0
  176.     cur_players = 0
  177.     resptime = 5
  178.     cur_map = map
  179.     name_table = {}
  180.     -- the game hasn't started yet, will once timer runs down
  181.     game_started = false
  182.     if new_game_timer == nil then
  183.         new_game_timer = registertimer(7500, "NewGameTimer")
  184.     end
  185.     if map == "putput" or map == "longest" or map == "beavercreek" or map == "carousel" or map == "wizard" or map == "ratrace" then
  186.         zombie_speed = small_zombie_speed
  187.         lastman_speed = small_lastman_speed
  188.     elseif map == "gephyrophobia" or map == "infinity" or map == "icefields" then
  189.         zombie_speed = large_zombie_speed
  190.         lastman_speed = large_lastman_speed
  191.     end
  192. end
  193.  
  194. function OnGameEnd(stage)
  195.     killtimer = false
  196.     game_started = false
  197.     if stage == 1 then
  198.         if humantimer then
  199.             removetimer(humantimer)
  200.             humantimer = nil
  201.         end
  202.         if new_game_timer then
  203.             removetimer(new_game_timer)
  204.             new_game_timer = nil
  205.         end
  206.         if speedtimer then
  207.             removetimer(speedtimer)
  208.             speedtimer = nil
  209.         end
  210.     end
  211. end
  212.  
  213. function OnServerCommand(player, command)
  214.     local allow = nil
  215.     local cmd = tokenizecmdstring(command)
  216.     local tokencount = #cmd
  217.     if tokencount > 0 then
  218.         if cmd[1] == "sv_map_reset" or (cmd[1] == "sv_script_reload" and cmd[2] == "infection") then
  219.             map_reset_boolean = true
  220.             for i = 0,15 do
  221.                 if getplayer(i) then
  222.                     local m_objectId = getplayerobjectid(i)
  223.                     if m_objectId and getteam(i) == zombie_team then
  224.                         destroyobject(m_objectId)
  225.                     end
  226.                 end
  227.             end
  228.         end
  229.     end
  230.     return allow
  231. end
  232.  
  233. function OnPlayerJoin(player)
  234.     spawnonspot[player] = false
  235.     local team = getteam(player)
  236.     outsidemap[player] = true
  237.     -- update the player counts
  238.     cur_players = cur_players + 1
  239.     local team = getteam(player)
  240.     -- onteamdecision isn't called for ffa gametypes
  241.     if not team_play then
  242.         -- initialize the destination team as the join team
  243.         local dest_team = join_team
  244.         -- make sure the game is started
  245.         if game_started then
  246.             -- if no zombies make them human
  247.             if cur_human_count == 0 then
  248.                 dest_team = human_team
  249.             end
  250.         end
  251.         -- we need to overwrite the 'team' variable being passed to onplayerjoin
  252.         team = dest_team
  253.     end
  254.     local thisTeamSize = 0 -- used so we don't create empty teams for rejoining players
  255.     local thisTeamSize = 0 -- used so we don't create empty teams for rejoining players
  256.     if team == zombie_team then
  257.         cur_zombie_count = cur_zombie_count + 1
  258.         thisTeamSize = cur_zombie_count
  259.     else
  260.         cur_human_count = cur_human_count + 1
  261.         thisTeamSize = cur_human_count
  262.     end
  263.     alpha_zombie_count = getalphacount()
  264.     local thisNAME = getname(player)
  265.     local alreadyExists = false
  266.     -- add team entry for this ip
  267.     if alreadyExists == false then
  268.         name_table[thisNAME] = team
  269.     end
  270.     -- make sure the game is started
  271.     if game_started == true then
  272.         -- check if the player is a zombie
  273.         if team == zombie_team then
  274.             --we don't need to update the counters since they're already on the zombieteam
  275.             makezombie(player, false, true)
  276.             --send them the zombie message
  277.             privatesay(player, zombie_message)
  278.         else
  279.             -- if we're at last man, make this player a zombie
  280.             if cur_last_man then
  281.                 --make this person a zombie (they're currently a human)
  282.                 makezombie(player, true)
  283.                 --send them the zombie message
  284.                 privatesay(player, zombie_message)
  285.             else
  286.                 --make this person a human (they're currently a zombie)
  287.                 makehuman(player, false, true)
  288.                 --send them the human message
  289.                 privatesay(player, human_message)
  290.             end
  291.         end
  292.         --send the player the welcome message
  293.         privatesay(player, welcome_message)
  294.         if gametype == "KOTH" then
  295.             privatesay(player, koth_additional_welcome_msg)
  296.         elseif gametype == "Slayer" and gametype_indicator == 1 then
  297.         end
  298.         registertimer(200,"checkgamestate",-1)
  299.     else
  300.         registertimer(10000, "MsgTimer", player)
  301.     end
  302. end
  303.  
  304. function OnPlayerLeave(player)
  305.     local team = getteam(player)
  306.     --check if they're a zombie
  307.     if game_started and team == zombie_team then
  308.         -- gets rid of any weapons a zombie is holding
  309.         --destroyweapons(player)
  310.         --take one away from the current zombie count
  311.         cur_zombie_count = cur_zombie_count - 1
  312.     elseif game_started and team ~= zombie_team then
  313.         --take one away from the current human count
  314.         cur_human_count = cur_human_count - 1
  315.     end
  316.     -- if last man is leaving, reset it
  317.     if cur_last_man == player then
  318.         cur_last_man = nil
  319.     end
  320.     --minus one from current players
  321.     cur_players = cur_players - 1
  322.     --check the current game state (the player that left might have been the last man or the only zombie)
  323.     registertimer(1000,"checkgamestate",-1)
  324.     -- update team within table
  325.     local thisNAME = getname(player)
  326.     name_table[thisNAME] = team
  327. end
  328.  
  329. function protect(idk, id1, objId)
  330.     local m_object = getobject(objId)
  331.     writebit(m_object + 0x10, 0, 1)
  332.     registertimer(1000, "RemoveLastmanProtection", m_object)
  333. end
  334.  
  335. spawnonspot = {}
  336.  
  337. function OnPlayerSpawn(player)
  338.  
  339.     if killtimer then
  340.         local m_player = getplayer(player)
  341.         local objId = readdword(m_player, 0x34)
  342.         movobjectcoords(objId, 0, 0, -1500)
  343.         outsidemap[player] = true
  344.         spawnonspot[player] = false
  345.     end
  346.  
  347.     if outsidemap[player] ~= true then
  348.         if spawnonspot[player] ~= false then
  349.             spawnonspot[player] = false
  350.             outsidemap[player] = false
  351.             said[player] = false
  352.             local m_player = getplayer(player)
  353.             local objId = readdword(m_player, 0x34)
  354.             if deathcoords[player] then
  355.                 sendconsoletext(player, "You will spawn were you last died!")
  356.                 movobjectcoords(objId, deathcoords[player].x, deathcoords[player].y, deathcoords[player].z)
  357.                 registertimer(0, "protect", objId)
  358.             end
  359.         end
  360.     end
  361.  
  362.     usedFlashlight[player] = false
  363.     local team = getteam(player)
  364.     --get the player's team
  365.  
  366.     local team = getteam(player)
  367.     --check if the player is a zombie
  368.     if team == zombie_team then
  369.  
  370.         --get the player's object ID
  371.         --make sure the player is alive (off chance that there's a glitch in phasor)
  372.         local m_objectId = getplayerobjectid(player)
  373.         if m_objectId == nil then
  374.             return
  375.         end
  376.  
  377.         --get the player's object struct
  378.         local m_object = getobject(m_objectId)
  379.  
  380.         -- set nade counts
  381.         writebyte(m_object + 0x31E, zombie_frag_count)
  382.         writebyte(m_object + 0x31F, zombie_plasma_count)
  383.  
  384.         -- set the ammo
  385.         local clipcount = alphazombie_clip_count
  386.         local ammocount = alphazombie_ammo_count
  387.         local batterycount = alphazombie_battery_count
  388.  
  389.         -- set ammo counts for zombies when others have been infected
  390.         if cur_zombie_count > alpha_zombie_count then
  391.             clipcount = zombie_clip_count
  392.             ammocount = zombie_ammo_count
  393.             batterycount = zombie_battery_count
  394.         else -- set alpha nades
  395.             writebyte(m_object + 0x31E, alphazombie_frag_count)
  396.             writebyte(m_object + 0x31F, alphazombie_plasma_count)
  397.         end
  398.  
  399.         table1 = {player, clipcount, ammocount, batterycount}
  400.         registertimer(0, "AssignZombieWeapons", table1)
  401.     elseif team == human_team then
  402.  
  403.         local m_objectId = getplayerobjectid(player)
  404.         if m_objectId == nil then
  405.             return
  406.         end
  407.  
  408.         setspeed(player, human_speed)
  409.  
  410.         local m_object = getobject(m_objectId)
  411.  
  412.         -- set nade counts
  413.         writebyte(m_object + 0x31E, 0)
  414.         writebyte(m_object + 0x31F, 2)
  415.  
  416.         local clipcount = 60
  417.         local ammocount = 120
  418.         local batterycount = 1
  419.         registertimer(0, "AssignHumanWeapons", player)
  420.     end
  421.  
  422.     --check if the type is slayer
  423.     if gametype == "Slayer" then
  424.  
  425.         local m_player = getplayer(player)
  426.         --check if we're at the last_man
  427.         if m_player == nil then
  428.             return
  429.         end
  430.  
  431.         if cur_last_man then --write the navpoint to the current last man
  432.             writeword(m_player, 0x88, cur_last_man)
  433.         else
  434.             writeword(m_player, 0x88, player) --there is no last man so put a nav above this player's head
  435.         end
  436.  
  437.     end
  438.  
  439. end
  440.  
  441. function OnObjectCreationAttempt(mapId, parentId, player)
  442.     if gametype == "CTF" and mapId == flag_tag_id and parentId == nil then
  443.         registertimer(0, "PutUnderMap", readdword(ctf_globals + 0x8))
  444.     end
  445.     return nil
  446. end
  447.  
  448. invimsg = false
  449.  
  450. function setfalse()
  451.     invimsg = false
  452. end
  453.  
  454. function OnObjectInteraction(player, objId, mapId)
  455.     local response = false
  456.     if game_started == true then
  457.         if mapId ~= oddball_tag_id and mapId ~= flag_tag_id then
  458.             if getteam(player) == zombie_team then
  459.                 if mapId == camouflage_tag_id  then
  460.                     response = nil
  461.                     if getplayer(player) then
  462.                         local m_playerObjId = getplayerobjectid(player)
  463.                         if m_playerObjId then
  464.                             if readdword(getobject(m_playerObjId) + 0x204) ~= 0x51 then
  465.                                 local doInvis = getrandomnumber(1, 11)
  466.                                 if doInvis > 5 then
  467.                                     -- make the whole zombie team invis for 30 seconds
  468.                                     for x = 0,15 do
  469.                                         if getplayer(x) and getteam(x) == zombie_team then
  470.                                             applycamo(x, 30.00)
  471.                                             registertimer(30000, "setfalse")
  472.                                         end
  473.                                     end
  474.                                     if not invimsg then
  475.                                         invimsg = true
  476.                                         say(zombieinvis_message)
  477.                                     end
  478.                                 end
  479.                             end
  480.                         end
  481.                     end
  482.                 elseif mapId == overshield_tag_id or mapId == healthpack_tag_id then
  483.                     response = nil
  484.                 elseif mapId == fragnade_tag_id or mapId == plasmanade_tag_id then
  485.                     response = false
  486.                 end
  487.             else
  488.                 response = nil
  489.             end
  490.         end
  491.     end
  492.     return response
  493. end
  494.  
  495. function OnKillMultiplier(player, multiplier)
  496.  
  497.     local name = getname(player)
  498.  
  499.     if multiplier == 7 or multiplier == 16 then
  500.         human_time[name] = tonumber(human_time[name]) + 5
  501.     elseif multiplier == 9 or multiplier == 17 then
  502.         human_time[name] = tonumber(human_time[name]) + 10
  503.     elseif multiplier == 10 or multiplier == 14 then
  504.         human_time[name] = tonumber(human_time[name]) + 15
  505.     end
  506.  
  507. end
  508.  
  509. died = {}
  510.  
  511. function OnPlayerKill(killer, victim, mode)
  512.  
  513.     if victim and mode ~= 6 then
  514.         local m_victim = getplayer(victim)
  515.         local objId = readdword(m_victim, 0x34)
  516.         local x, y, z = getobjectcoords(objId)
  517.         deathcoords[victim] = {}
  518.         deathcoords[victim].x = x
  519.         deathcoords[victim].y = y
  520.         deathcoords[victim].z = z
  521.     end
  522.  
  523.     local response = false
  524.     -- make sure this kill doesn't add to the score so that the game won't end prematurely
  525.     if gametype == "Slayer" and killer and getplayer(killer) then writedword(slayer_globals + 0x40 + killer*4, 0) end
  526.     -- make sure the game is started
  527.     if game_started then
  528.         -- get the victim's team
  529.         local team = getteam(victim)
  530.         if victim and team == zombie_team then
  531.             -- gets rid of any weapons a zombie is holding
  532.             destroyweapons(victim)
  533.         end
  534.         if victim then
  535.             if resptime then
  536.                 writedword(getplayer(victim) + 0x2c, resptime * 33)
  537.             elseif tonumber(human_spawn_time) and team ~= zombie_team then
  538.                 writedword(getplayer(victim) + 0x2C, tonumber(human_spawn_time) * 33)
  539.             elseif tonumber(zombie_spawn_time) and team == zombie_team then
  540.                 writedword(getplayer(victim) + 0x2C, tonumber(zombie_spawn_time) * 33)
  541.             end
  542.         end
  543.         if mode == 0 then -- server kill
  544.             spawnonspot[victim] = false
  545.             return false
  546.         elseif mode == 1 and not map_reset_boolean then -- fall damage
  547.             spawnonspot[victim] = false
  548.             -- if this is true then a person who dies from falling will be infected
  549.             if infect_on_fall then
  550.                 if tonumber(team) and team ~= zombie_team then
  551.                     response = false
  552.                     say(tostring(getname(victim)) .. falling_infected_message)
  553.                     registertimer(100, "makezombiedelay", {victim, true})
  554.                 elseif tonumber(team) and team ~= human_team then
  555.                     response = false
  556.                     say(tostring(getname(victim)) .. falling_death_message)
  557.                 end
  558.                 responce = false
  559.             else
  560.                 response = false
  561.                 say(tostring(getname(victim)) .. falling_death_message)
  562.             end
  563.         elseif mode == 2 then -- killed by guardians
  564.             spawnonspot[victim] = true
  565.             if infect_on_guardians then
  566.                 if tonumber(team) and team ~= zombie_team then
  567.                     response = false
  568.                     say(tostring(getname(victim)) .. guardian_infected_message)
  569.                     registertimer(100, "makezombiedelay", {victim, true})
  570.                 end
  571.             else
  572.                 response = false
  573.                 say(tostring(getname(victim)) .. guardian_infected_message)
  574.             end
  575.         elseif mode == 3 then -- killed by vehicle
  576.             spawnonspot[victim] = false
  577.         elseif mode == 4 then -- killed by another player
  578.             local killer_team = getteam(killer)
  579.             if tonumber(killer_team) and killer_team == zombie_team and tonumber(team) and team ~= zombie_team then
  580.                 response = false
  581.  
  582.                 for i = 0,15 do
  583.                     if getplayer(i) ~= nil then
  584.                         if i ~= killer then
  585.                             privatesay(i, tostring(getname(killer)) .. kill_infected_message .. tostring(getname(victim)))
  586.                         end
  587.                     end
  588.                 end
  589.  
  590.                 spawnonspot[victim] = true
  591.                 registertimer(100, "makezombiedelay", {victim, true})
  592.                 privatesay(victim, zombie_message)
  593.  
  594.                 local name = getname(killer)
  595.                 human_time[name] = tonumber(human_time[name]) + 10
  596.  
  597.                 countupzombiekils(killer)
  598.  
  599.             elseif killer_team ~= zombie_team and team == zombie_team then
  600.                 response = false
  601.                 spawnonspot[victim] = false
  602.  
  603.                 for i = 0,15 do
  604.                     if getplayer(i) ~= nil then
  605.                         if i ~= killer then
  606.                             privatesay(i, tostring(getname(killer)) .. human_kill_message .. tostring(getname(victim)))
  607.                         end
  608.                     end
  609.                 end
  610.  
  611.                 local name = getname(killer)
  612.                 human_time[name] = tonumber(human_time[name]) + 5
  613.                 dropammoforhumans(victim)
  614.             end
  615.         elseif mode == 5 then -- betrayed
  616.             if infect_on_betray then
  617.                 local killer_team = getteam(killer)
  618.                 if tonumber(killer_team) and killer_team ~= zombie_team then
  619.                     response = false
  620.                     for i = 0,15 do
  621.                         if getplayer(i) ~= nil then
  622.                             if i ~= killer then
  623.                                 privatesay(i, tostring(getname(killer)) .. teammate_infected_message .. tostring(getname(victim)))
  624.                             end
  625.                         end
  626.                     end
  627.                     registertimer(100, "makezombiedelay", {killer, true})
  628.                 elseif tonumber(killer_team) and killer_team ~= human_team then
  629.                     response = false
  630.                     for i = 0,15 do
  631.                         if getplayer(i) ~= nil then
  632.                             if i ~= killer then
  633.                                 privatesay(i, tostring(getname(killer)) .. " betrayed " .. tostring(getname(victim)))
  634.                             end
  635.                         end
  636.                     end
  637.                 end
  638.             elseif infect_on_betray == false then
  639.                 response = false
  640.                 for i = 0,15 do
  641.                     if getplayer(i) ~= nil then
  642.                         if i ~= killer then
  643.                             privatesay(i, tostring(getname(killer)) .. " betrayed " .. tostring(getname(victim)))
  644.                         end
  645.                     end
  646.                 end
  647.             end
  648.  
  649.         elseif mode == 6 then -- suicide
  650.             if infect_on_suicide then
  651.                 if tonumber(team) and team ~= zombie_team then
  652.                     response = false
  653.                     say(tostring(getname(victim)) .. suicide_infected_message)
  654.                     registertimer(100, "makezombiedelay", {victim, true})
  655.                 elseif tonumber(team) and team ~= human_team then
  656.                     say(tostring(getname(victim)) .. " found himself tasty...")
  657.                 end
  658.             elseif infect_on_suicide == false then
  659.                 response = false
  660.                 say(tostring(getname(victim)) .. suicide_message)
  661.             end
  662.         end
  663.         -- this next block of code gets rid of any weapons a zombie is holding
  664.         if tonumber(team) and team == zombie_team then
  665.             destroyweapons(victim)
  666.         end
  667.     end
  668.     registertimer(200,"checkgamestate", victim)
  669.     return response
  670. end
  671.  
  672. function countupzombiekils(killer)
  673.     if zkills[killer] then
  674.         zkills[killer] = zkills[killer] + 1
  675.         if zkills[killer] >= human_again then
  676.             spawnonspot[killer] = true
  677.             sendconsoletext(killer, "You are to full and have become a human again!")
  678.             registertimer(100, "makehumandelay", {killer, true})
  679.             kill(killer)
  680.             zkills[killer] = 0
  681.         end
  682.     else
  683.         zkills[killer] = 1
  684.     end
  685. end
  686.  
  687. function dropammoforhumans(victim)
  688.  
  689.     local x = readfloat(getplayer(victim) + 0xF8)
  690.     local y = readfloat(getplayer(victim) + 0xFC)
  691.     local z = readfloat(getplayer(victim) + 0x100)
  692.  
  693.     if last_damage[gethash(victim)] == "weapons\\assault rifle\\bullet" then
  694.         createobject(gettagid("eqip", "powerups\\assault rifle ammo\\assault rifle ammo"), 0, 30, false, x, y, z + 0.5)
  695.     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
  696.         createobject(gettagid("eqip", "powerups\\flamethrower ammo\\flamethrower ammo"), 0, 30, false, x, y, z + 0.5)
  697.     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
  698.         createobject(gettagid("eqip", "powerups\\needler ammo\\needler ammo"), 0, 30, false, x, y, z + 0.5)
  699.     elseif last_damage[gethash(victim)] == "weapons\\pistol\\bullet" then
  700.         createobject(gettagid("eqip", "powerups\\pistol ammo\\pistol ammo"), 0, 30, false, x, y, z + 0.5)
  701.     elseif last_damage[gethash(victim)] == "weapons\\rocket launcher\\explosion" then
  702.         createobject(gettagid("eqip", "powerups\\rocket launcher ammo\\rocket launcher ammo"), 0, 30, false, x, y, z + 0.5)
  703.     elseif last_damage[gethash(victim)] == "weapons\\shotgun\\pellet" then
  704.         createobject(gettagid("eqip", "powerups\\shotgun ammo\\shotgun ammo"), 0, 30, false, x, y, z + 0.5)
  705.     elseif last_damage[gethash(victim)] == "weapons\\sniper rifle\\sniper bullet" then
  706.         createobject(gettagid("eqip", "powerups\\sniper rifle ammo\\sniper rifle ammo"), 0, 30, false, x, y, z + 0.5)
  707.     end
  708. end
  709.  
  710. function OnTeamDecision(team)
  711.     local dest_team = join_team
  712.     if game_started then
  713.         if cur_players == 0  then -- if no zombies make them human
  714.             dest_team = human_team
  715.         elseif cur_zombie_count > 0 and cur_human_count == 0 then
  716.             dest_team = human_team
  717.         end
  718.     end
  719.     return dest_team
  720. end
  721.  
  722. function OnTeamChange(player, old_team, dest_team, voluntary)
  723.     if voluntary then
  724.         if not allow_change then
  725.             privatesay(player, blockteamchange_message)
  726.         elseif allow_change and old_team == zombie_team then
  727.             -- this is so memory is updated for processing
  728.             -- when voluntary is 0 OnTeamChange is called once the changes
  729.             -- have been committed
  730.             setspeed(player, zombie_speed)
  731.             changeteam(player, true)
  732.         end
  733.         -- we don't let people change team
  734.     elseif not voluntary then -- we can't stop the person changing teams, bein done by an admin
  735.         -- update team counts
  736.         if dest_team == zombie_team then
  737.             cur_human_count = cur_human_count - 1
  738.             cur_zombie_count = cur_zombie_count + 1
  739.         elseif dest_team ~= zombie_team then
  740.             cur_human_count = cur_human_count + 1
  741.             cur_zombie_count = cur_zombie_count - 1
  742.         end
  743.         -- they're allowed to change if the timer is active, if it is disable it
  744.         if allow_change == true and dest_team == zombie_team then
  745.             allow_change = false
  746.             --remove change timer
  747.             if player_change_timer then
  748.                 removetimer(player_change_timer)
  749.                 player_change_timer = nil
  750.             end
  751.             say(timer_team_change_msg)
  752.         end
  753.         -- check if the game has started yet
  754.         if game_started == true then
  755.             -- set attributes
  756.             if dest_team == zombie_team then
  757.                 makezombie(player, true)
  758.             elseif dest_team ~= zombie_team then
  759.                 makehuman(player, true)
  760.             end
  761.             registertimer(200,"checkgamestate",player)
  762.         end
  763.         -- update team
  764.         local thisNAME = getname(player)
  765.         name_table[thisNAME] = team
  766.  
  767.     end
  768.     registertimer(200,"checkgamestate",-1)
  769.     return allow_change
  770. end
  771.  
  772. function OnDamageApplication(receiving, causing, tagid, hit, backtap)
  773.     if receiving then
  774.         local player = objidtoplayer(receiving)
  775.         if player then
  776.             if not backtap then
  777.                 local tagname,tagtype = gettaginfo(tagid)
  778.                 last_damage[gethash(player)] = tagname
  779.             else
  780.                 last_damage[gethash(player)] = "backtap"
  781.             end
  782.         end
  783.     end
  784. end
  785.  
  786. function OnDamageLookup(receiving, causing, mapId, tagdata)
  787.     if causing and receiving then
  788.         local causer = objidtoplayer(causing)
  789.         local receiver = objidtoplayer(receiving)
  790.         if causer and receiver then
  791.             local c_team = getteam(causer)
  792.             local r_team = getteam(receiver)
  793.             if not team_play and r_team == c_team and causer ~= receiver then
  794.                 return false
  795.             end
  796.             -- if it's a human causing the damage
  797.             if c_team ~= zombie_team then
  798.                 if cur_last_man then
  799.                     modifier = lastman_dmgmodifier
  800.                 else
  801.                     modifier = human_dmgmodifier
  802.                 end
  803.                 odl_multiplier(modifier)
  804.             -- It's a zombie causing the damage
  805.             elseif c_team == zombie_team then
  806.                 local tagname, tagtype = gettaginfo(mapId)
  807.                 -- check if it is melee damage
  808.                 if string.find(tagname, "melee", -5) then
  809.                     odl_multiplier(9999)
  810.                 end
  811.             end
  812.         end
  813.     end
  814. end
  815.  
  816. function objidtoplayer(objectId)
  817.     local m_object = getobject(objectId)
  818.     if m_object then
  819.         local playerId = readword(m_object + 0xC0)
  820.         local m_player = getplayer(playerId)
  821.         if m_player then
  822.             return playerId
  823.         end
  824.     end
  825. end
  826.  
  827. function OnVehicleEntry(player, m_vehicleId, seat, mapId, relevant)
  828.     if game_started and relevant == true then
  829.         local team = getteam(player)
  830.         if (team == zombie_team and zombies_allowed_in_vehis) or (team ~= zombie_team and humans_allowed_in_vehis) then
  831.             return true
  832.         end
  833.     end
  834.     return false
  835. end
  836.  
  837. function haveSpeedTimer(useless1, useless2, player)
  838.     if getplayer(player) ~= nil then
  839.         local team = getteam(player)
  840.         sendconsoletext(player, "Your speed boost has been removed.")
  841.         if team == zombie_team then
  842.             setspeed(player, zombie_speed)
  843.         else
  844.             setspeed(player, human_speed)
  845.         end
  846.     else
  847.         say("reset_spd_failed " .. player .. " is nil")
  848.     end
  849.     return 0
  850. end
  851.  
  852. said = {}
  853.  
  854. function OnClientUpdate(player)
  855.     local m_objectId = getplayerobjectid(player)
  856.     if m_objectId == nil then return end
  857.     local m_object = getobject(m_objectId)
  858.     local team = getteam(player)
  859.  
  860.     local flashlight = readbyte(m_object, 0x206)
  861.     if flashlight == 8 and not usedFlashlight[player] then
  862.         usedFlashlight[player] = true
  863.         warned[player] = false
  864.         registertimer(speed_boost * 1000, "haveSpeedTimer", player)
  865.         if team ~= human_team then
  866.             setspeed(player, boost_amount + zombie_speed)
  867.         elseif team ~= zombie_team and not cur_last_man then
  868.             setspeed(player, boost_amount + human_speed)
  869.         elseif team ~= zombie_team and cur_last_man then
  870.             setspeed(player, boost_amount + lastman_speed)
  871.         end
  872.     elseif flashlight == 8 and usedFlashlight[player] and not warned[player] then
  873.         sendconsoletext(player, "You have been given a speed boost!")
  874.         warned[player] = true
  875.     end
  876.  
  877.     if readbyte(m_object + 0x2A0) == 3 then
  878.         if getteam(player) == zombie_team then
  879.             applycamo(player, 1)
  880.         end
  881.     end
  882.  
  883.     -- this block of code disables them the ability to drop the oddball_or_flag
  884.     if oddball_or_flag and team == zombie_team and flagball_weap[player] then
  885.         if game_started and readbit(m_object + 0x209, 3) == true or readbit(m_object + 0x209, 4) == true then
  886.             assignweapon(player, flagball_weap[player])
  887.         end
  888.     end
  889.  
  890.     local name = getname(player)
  891.     -- this block of code sets the player's score according to what it should be.
  892.     if tonumber(human_time[name]) then
  893.         local m_player = getplayer(player)
  894.         if gametype == "KOTH" then
  895.             writewordsigned(m_player, 0xC4, human_time[name]*30)
  896.         elseif gametype == "CTF" then
  897.             writedwordsigned(m_player, 0xC8, human_time[name])
  898.         elseif gametype == "Slayer" then
  899.             writedwordsigned(slayer_globals, 0x40 + player * 4, human_time[name])
  900.         end
  901.     else
  902.         human_time[name] = 0
  903.     end
  904.     --this makes sure that people won't camp in unreachable places. and doesnt work
  905.     local x,y,z = getobjectcoords(m_objectId)
  906.  
  907.     outsidemap[player] = false
  908.  
  909.     if kill_humanss_in_water then
  910.         if not isinvehicle(player) then
  911.             if z < 1.65 and cur_map == "deathisland" then
  912.                 outsidemap[player] = true
  913.                 if m_objectId then
  914.                     if team ~= zombie_team then
  915.                             kill(player)
  916.                         if not said[player] then
  917.                             said[player] = true
  918.                             say(getname(player) .. killed_in_water_msg, false)
  919.                         end
  920.                         if team == human_team and not cur_last_man then
  921.                             registertimer(100, "makezombiedelay", {player, true})
  922.                             registertimer(200,"checkgamestate", player)
  923.                         end
  924.                     end
  925.                 end
  926.             elseif z < -22 and cur_map == "gephyrophobia" then
  927.                 outsidemap[player] = true
  928.                 if m_objectId then
  929.                     if game_started then
  930.                         if team ~= zombie_team then
  931.                             kill(player)
  932.                             if not said[player] then
  933.                                 say(getname(player) .. falling_infected_message, false)
  934.                             end
  935.                             if team == human_team and not cur_last_man then
  936.                                 registertimer(100, "makezombiedelay", {player, true})
  937.                                 registertimer(200,"checkgamestate", player)
  938.                             end
  939.                         elseif team == zombie_team then
  940.                             kill(player)
  941.                             say(getname(player) .. falling_death_message, false)
  942.                             registertimer(200,"checkgamestate", player)
  943.                         end
  944.                     end
  945.                 end
  946.             elseif z < -6 and cur_map == "boardingaction" then
  947.                 outsidemap[player] = true
  948.                 if m_objectId then
  949.                     if game_started then
  950.                         if team ~= zombie_team then
  951.                             kill(player)
  952.                             if not said[player] then
  953.                                 say(getname(player) .. falling_infected_message, false)
  954.                             end
  955.                             if team == human_team and not cur_last_man then
  956.                                 registertimer(100, "makezombiedelay", {player, true})
  957.                                 registertimer(200,"checkgamestate", player)
  958.                             end
  959.                         elseif team == zombie_team then
  960.                             kill(player)
  961.                             say(getname(player) .. falling_death_message, false)
  962.                             registertimer(200,"checkgamestate", player)
  963.                         end
  964.                     end
  965.                 end
  966.             elseif z < -1 and cur_map == "damnation" then
  967.                 outsidemap[player] = true
  968.                 if m_objectId then
  969.                     if game_started then
  970.                         if team ~= zombie_team then
  971.                             kill(player)
  972.                             if not said[player] then
  973.                                 say(getname(player) .. falling_infected_message, false)
  974.                             end
  975.                             if cur_last_man ~= nil then
  976.                                 registertimer(100, "makezombiedelay", {player, true})
  977.                                 registertimer(200,"checkgamestate", player)
  978.                             end
  979.                         elseif team == zombie_team then
  980.                             kill(player)
  981.                             say(getname(player) .. falling_death_message, false)
  982.                             registertimer(200,"checkgamestate", player)
  983.                         end
  984.                     end
  985.                 end
  986.             end
  987.         end
  988.     end
  989.  
  990.     if cur_map == "damnation" and team ~= zombie_team then
  991.  
  992.     elseif cur_map == "sidewinder" and team ~= zombie_team then
  993.         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
  994.             sendconsoletext(player, "You are not allowed to go there...")
  995.             say(getname(player) .. " found a blocked spot...", false)
  996.             kill(player)
  997.         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
  998.             sendconsoletext(player, "You are not allowed to go there...")
  999.             say(getname(player) .. " found a blocked spot...", false)
  1000.             kill(player)
  1001.         elseif object_in_sphere(m_objectId, -5.8, -33.46, 2.29, 5) then -- vents cur only red side
  1002.             sendconsoletext(player, "You are not allowed to go there...")
  1003.             say(getname(player) .. " found a blocked spot...", false)
  1004.             kill(player)
  1005.         elseif object_in_sphere(m_objectId, -32.2, -32.48, 3, 1.25) then -- ledge above red base
  1006.             sendconsoletext(player, "You are not allowed to go there...")
  1007.             say(getname(player) .. " found a blocked spot...", false)
  1008.             kill(player)
  1009.         end
  1010.  
  1011.     elseif cur_map == "dangercanyon" and team ~= zombie_team then
  1012.         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
  1013.             sendconsoletext(player, "You are not allowed to go there...")
  1014.             say(getname(player) .. " found a blocked spot...", false)
  1015.             kill(player)
  1016.         elseif object_in_sphere(m_objectId, 3.78, 32.66, 4.05, 1.25) then -- ledge above red base
  1017.             sendconsoletext(player, "You are not allowed to go there...")
  1018.             say(getname(player) .. " found a blocked spot...", false)
  1019.             kill(player)
  1020.         end
  1021.  
  1022.     -- These are finished.
  1023.     elseif cur_map == "wizard" and team ~= zombie_team then
  1024.         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
  1025.             sendconsoletext(player, "You are not allowed to go there...")
  1026.             say(getname(player) .. " found a blocked spot...", false)
  1027.             kill(player)
  1028.         end
  1029.  
  1030.     elseif cur_map == "gephyrophobia" and team ~= zombie_team then
  1031.         if object_in_sphere(m_objectId,  74.78, -73.89, 7.43, 9) then -- Cliff Hanger
  1032.             sendconsoletext(player, "You are not allowed to go here...")
  1033.             say(getname(player) .. " found a blocked spot...", false)
  1034.             kill(player)
  1035.         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
  1036.             sendconsoletext(player, "You are not allowed to go here...")
  1037.             say(getname(player) .. " found a blocked spot...", false)
  1038.             kill(player)
  1039.         end
  1040.  
  1041.     elseif cur_map == "boardingaction" and team ~= zombie_team then
  1042.         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
  1043.             sendconsoletext(player, "You are not allowed to go there...")
  1044.             say(getname(player) .. " found a blocked spot...", false)
  1045.             kill(player)
  1046.         end
  1047.     elseif cur_map == "deathisland" and team ~= zombie_team then
  1048.         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
  1049.             sendconsoletext(player, "You are not allowed to go there...")
  1050.             say(getname(player) .. " found a blocked spot...", false)
  1051.             kill(player)
  1052.         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
  1053.             sendconsoletext(player, "You are not allowed to go there...")
  1054.             say(getname(player) .. " found a blocked spot...", false)
  1055.             kill(player)
  1056.         elseif object_in_sphere(m_objectId, 16.82, -22.79, 8.72, 7) then -- Hole in the wall
  1057.             sendconsoletext(player, "You are not allowed to go there...")
  1058.             say(getname(player) .. " found a blocked spot...", false)
  1059.             kill(player)
  1060.         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!)
  1061.             sendconsoletext(player, "You are not allowed to go there...")
  1062.             say(getname(player) .. " found a blocked spot...", false)
  1063.             kill(player)
  1064.         end
  1065.  
  1066.     elseif cur_map == "infinity" and team ~= zombie_team then
  1067.         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
  1068.             sendconsoletext(player, "You are not allowed to go there...")
  1069.             say(getname(player) .. " found a blocked spot...", false)
  1070.             kill(player)
  1071.         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
  1072.             sendconsoletext(player, "You are not allowed to go there...")
  1073.             say(getname(player) .. " found a blocked spot...", false)
  1074.             kill(player)
  1075.         elseif object_in_sphere(m_objectId, -52.73, -19.67, 17.4, 2) then
  1076.             sendconsoletext(player, "You are not allowed to go there...")
  1077.             say(getname(player) .. " found a blocked spot...", false)
  1078.             kill(player)
  1079.         elseif object_in_sphere(m_objectId, -53.29, -8.32, 21.01, 6) then
  1080.             sendconsoletext(player, "You are not allowed to go there...")
  1081.             say(getname(player) .. " found a blocked spot...", false)
  1082.             kill(player)
  1083.         end
  1084.  
  1085.     elseif cur_map == "bloodgulch" and team ~= zombie_team then
  1086.         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
  1087.             sendconsoletext(player, "You are not allowed to go there...")
  1088.             say(getname(player) .. " found a blocked spot...", false)
  1089.             kill(player)
  1090.         elseif object_in_sphere(m_objectId, 92.38, -93.65, 9.33, 6) then -- Rock Tower (by os cave)
  1091.             sendconsoletext(player, "You are not allowed to go there...")
  1092.             say(getname(player) .. " found a blocked spot...", false)
  1093.             kill(player)
  1094.         end
  1095.  
  1096.     elseif cur_map == "icefields" and team ~= zombie_team then
  1097.         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
  1098.             sendconsoletext(player, "You are not allowed to go there...")
  1099.             say(getname(player) .. " found a blocked spot...", false)
  1100.             kill(player)
  1101.         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
  1102.             sendconsoletext(player, "You are not allowed to go there...")
  1103.             say(getname(player) .. " found a blocked spot...", false)
  1104.             kill(player)
  1105.         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)
  1106.             sendconsoletext(player, "You are not allowed to go there...")
  1107.             say(getname(player) .. " found a blocked spot...", false)
  1108.             kill(player)
  1109.         elseif object_in_sphere(m_objectId, -17.66, 19.91, 11.58, 4) then -- Clif at bridge (unreachable one)
  1110.             sendconsoletext(player, "You are not allowed to go there...")
  1111.             say(getname(player) .. " found a blocked spot...", false)
  1112.             kill(player)
  1113.         end
  1114.  
  1115.     elseif cur_map == "hangemhigh" and team ~= zombie_team then
  1116.         if object_in_sphere(m_objectId, 7.38, 2.02, -3.16, 3) then  -- Back room and shotgun room
  1117.             sendconsoletext(player, "You are not allowed to go there...")
  1118.             say(getname(player) .. " found a blocked spot...", false)
  1119.             kill(player)
  1120.         end
  1121.  
  1122.     elseif cur_map == "putput" and team ~= zombie_team then
  1123.         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
  1124.             sendconsoletext(player, "You are not allowed to go there...")
  1125.             say(getname(player) .. " found a blocked spot...", false)
  1126.             kill(player)
  1127.         end
  1128.  
  1129.     elseif cur_map == "chillout" and team ~= zombie_team then
  1130.         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
  1131.             sendconsoletext(player, "You are not allowed to go there...")
  1132.             say(getname(player) .. " found a blocked spot...", false)
  1133.             kill(player)
  1134.         end
  1135.     end
  1136. end
  1137.  
  1138. function all_players_zombies(player)
  1139.     if player ~= nil and player ~= -1 and getplayer(player) then
  1140.         last_man_name = getname(player)
  1141.         local file = io.open("lastname_" .. processid .. ".tmp", "w")
  1142.         if (file ~= nil) then
  1143.             file:write(tostring(last_man_name))
  1144.             file:close()
  1145.         end
  1146.     end
  1147.     svcmd("sv_map_next")
  1148. end
  1149.  
  1150. function AssignZombieWeapons(id, count, table)
  1151.     local player = table[1]
  1152.     local clipcount = table[2]
  1153.     local ammocount = table[3]
  1154.     local batterycount = table[4]
  1155.     if getplayer(player) == nil then
  1156.         return
  1157.     end
  1158.     local m_objectId = getplayerobjectid(player)
  1159.     if m_objectId then
  1160.         local m_object = getobject(m_objectId)
  1161.         --count is increased everytime the timer is called
  1162.         if count == 1 then
  1163.             -- gets rid of any weapons a zombie is holding
  1164.             destroyweapons(player)
  1165.         end
  1166.         local i = count
  1167.         if zombie_weapon and zombie_weapon[i] and zombie_weapon[i] ~= "" then
  1168.             local m_weaponId = createobject(gettagid("weap", zombie_weapon[i]), 0, 0, false, 1, 1, 1)
  1169.             if m_weaponId and m_weaponId ~= 0xFFFFFFFF then
  1170.                 assignweapon(player, m_weaponId)
  1171.                 if oddball_or_flag == readdword(getobject(m_weaponId)) then
  1172.                     flagball_weap[player] = m_weaponId
  1173.                 else
  1174.                     local m_weapon = getobject(m_weaponId)
  1175.                     if m_weapon then
  1176.                         -- set the ammo
  1177.                         writeword(m_weapon, 0x2B6, ammocount)
  1178.                         writeword(m_weapon, 0x2B8, clipcount)
  1179.                         writefloat(m_weapon, 0x240, 1)
  1180.                         -- force it to sync
  1181.                         updateammo(m_weaponId)
  1182.                     end
  1183.                 end
  1184.             end
  1185.         end
  1186.         if count < 4 then return true else return false end
  1187.     end
  1188.     return false
  1189. end
  1190.  
  1191. function AssignHumanWeapons(id, count, player)
  1192.  
  1193.     if getplayer(player) == nil then
  1194.         return
  1195.     end
  1196.     local m_objectId = getplayerobjectid(player)
  1197.     if m_objectId then
  1198.         local m_object = getobject(m_objectId)
  1199.         --count is increased everytime the timer is called
  1200.         if count == 1 then
  1201.             -- gets rid of any weapons a zombie is holding
  1202.             destroyweapons(player)
  1203.         end
  1204.         local i = count
  1205.         if human_weapon and human_weapon[i] and human_weapon[i] ~= "" then
  1206.             local m_weaponId = createobject(gettagid("weap", human_weapon[i]), 0, 0, false, 1, 1, 1)
  1207.             if m_weaponId and m_weaponId ~= 0xFFFFFFFF then
  1208.                 assignweapon(player, m_weaponId)
  1209.             end
  1210.         end
  1211.         if count < 4 then return true else return false end
  1212.     end
  1213.     return false
  1214. end
  1215.  
  1216. function checkgamestate(id, count, player)
  1217.     -- check if the game has started yet
  1218.     if game_started == true then
  1219.         local human_count, zombie_count = getteamsizes()
  1220.         -- if no humans, but there are zombies, end the game
  1221.         if human_count == 0 and zombie_count > 0 then
  1222.             all_players_zombies(player)
  1223.         elseif human_count > 1 and zombie_count == 0 then
  1224.             noZombiesLeft()
  1225.         elseif human_count == 1 and zombie_count > 0 and not cur_last_man then
  1226.             onlastman()
  1227.         elseif cur_last_man and zombie_count == 0 then
  1228.             if getplayer(cur_last_man) then
  1229.                 makehuman(cur_last_man, false)
  1230.             end
  1231.             cur_last_man = nil
  1232.         elseif cur_last_man and human_count > 1 then
  1233.             if gametype == "Slayer" then takenavsaway(cur_last_man) end
  1234.             if getplayer(cur_last_man) then
  1235.                 makehuman(cur_last_man, false)
  1236.             end
  1237.             cur_last_man = nil
  1238.         end
  1239.     end
  1240.     return false
  1241. end
  1242.  
  1243. function ChooseRandomPlayer(excludeTeam)
  1244.     -- loop through all 16 possible spots and add to table
  1245.     local t = getplayertable(excludeTeam)
  1246.     if #t > 0 then
  1247.         -- generate a random number that we will use to select a player
  1248.         local r = getrandomnumber(1, #t+1)
  1249.         return tonumber(t[r])
  1250.     else
  1251.         return nil
  1252.     end
  1253. end
  1254.  
  1255. function destroyweapons(player)
  1256.     for i = 0,3 do -- loop through the player's weapons (primary to quartenary)
  1257.         local m_weaponId = getweaponobjectid(player, i)
  1258.         if m_weaponId ~= 0xFFFFFFFF then destroyobject(m_weaponId) end
  1259.     end
  1260. end
  1261.  
  1262. function DelayWriteCoords(id, count)
  1263.     writefloat(readdword(ctf_globals + 0x0), 0x8, readfloat(readdword(ctf_globals + 0x0), 0x8) - 100)
  1264.     writefloat(readdword(ctf_globals + 0x4), 0x8, readfloat(readdword(ctf_globals + 0x4), 0x8) - 100)
  1265.     return false
  1266. end
  1267.  
  1268. function getalphacount()
  1269.     -- recalculate how many "alpha" zombies there are
  1270.     if zombie_count < 1 then
  1271.         alpha_zombie_count = round((cur_players * zombie_count) + 0.5)
  1272.     else
  1273.         alpha_zombie_count = zombie_count
  1274.     end
  1275.     if alpha_zombie_count > max_zombie_count then
  1276.         alpha_zombie_count = max_zombie_count
  1277.     end
  1278.     return alpha_zombie_count
  1279. end
  1280.  
  1281. function GetGameAddresses(game)
  1282.     if game == "PC" then
  1283.         map_pointer = 0x63525c
  1284.         ctf_globals = 0x639B98
  1285.         flag_respawn_addr = 0x488A7E
  1286.         gametype_base = 0x671340
  1287.         slayer_globals = 0x63A0E8
  1288.         team_koth_score_array = 0x639BD0
  1289.  
  1290.         ctf_score_patch = 0x488602
  1291.         ctf_score_patch1 = 0x488606
  1292.  
  1293.         slayer_score_patch = 0x48F428
  1294.         slayer_score_patch2 = 0x48F23E
  1295.  
  1296.         koth_score_patch = 0x48A798
  1297.         koth_score_patch2 = 0x48A76D
  1298.     else
  1299.         map_pointer = 0x5B927C
  1300.         ctf_globals = 0x5BDBB8
  1301.         flag_respawn_addr = 0x4638EE
  1302.         gametype_base = 0x5F5498
  1303.         slayer_globals = 0x5BE108
  1304.         team_koth_score_array = 0x5BDBF0
  1305.  
  1306.         ctf_score_patch = 0x463472
  1307.         ctf_score_patch1 = 0x463476
  1308.  
  1309.         slayer_score_patch = 0x469CF8
  1310.         slayer_score_patch2 = 0x4691CE
  1311.  
  1312.         koth_score_patch = 0x465458
  1313.         koth_score_patch2 = 0x46542D
  1314.     end
  1315. end
  1316.  
  1317. function getplayertable(excludeTeam)
  1318.     local players = ""
  1319.     for i=0,15 do
  1320.         if getplayer(i) and getteam(i) ~= excludeTeam then
  1321.             if players == nil then
  1322.                 players = i .. ","
  1323.             else
  1324.                 players = players .. i .. ","
  1325.             end
  1326.         end
  1327.     end
  1328.     return tokenizestring(players, ",")
  1329. end
  1330.  
  1331. function getteamplay()
  1332.     local team_play = readbyte(gametype_base + 0x34)
  1333.     if team_play == 1 then
  1334.         return true
  1335.     else
  1336.         return false
  1337.     end
  1338. end
  1339.  
  1340. function getteamsizes()
  1341.     local human_size = 0
  1342.     local zombie_size = 0
  1343.     human_size = getteamsize(0)
  1344.     zombie_size = getteamsize(1)
  1345.     return human_size,zombie_size
  1346. end
  1347.  
  1348. function getweaponobjectid(player, slot)
  1349.     local m_objectId = getplayerobjectid(player)
  1350.     if m_objectId then return readdword(getobject(m_objectId) + 0x2F8 + slot*4) end
  1351. end
  1352.  
  1353. function HumanTimer(id, count)
  1354.     if map_reset_boolean == true then
  1355.         map_reset_boolean = false
  1356.     end
  1357.     if game_started == true then
  1358.         for i = 0,15 do
  1359.             if getplayer(i) then
  1360.                 local m_player = getplayer(i)
  1361.                 local name = getname(i)
  1362.                 local team = getteam(i)
  1363.                 local m_objectId = getplayerobjectid(i)
  1364.                 if m_objectId then
  1365.                     local m_object = getobject(m_objectId)
  1366.                     if m_object then
  1367.                         if tonumber(human_time[name]) then
  1368.                             human_time[name] = tonumber(human_time[name]) + 0.1
  1369.                         else
  1370.                             human_time[name] = 1
  1371.                         end
  1372.                     end
  1373.                 end
  1374.                 if gametype == "KOTH" then
  1375.                     local m_objectId = getplayerobjectid(i)
  1376.                     if m_objectId then
  1377.                         local m_object = getobject(m_objectId)
  1378.                         if PlayerInHill(i) == true and m_object then
  1379.                             if inhill_time[name] == nil then
  1380.                                 inhill_time[name] = 0
  1381.                                 writebit(m_object + 0x10, 0, 1)
  1382.                                 if team ~= zombie_team then
  1383.                                     say(getname(i) .. " must leave the hill in 10 seconds or they will be infected!")
  1384.                                 else
  1385.                                     say(getname(i) .. " must leave the hill in 10 seconds or they will be killed!")
  1386.                                 end
  1387.                             elseif inhill_time[name] >= 10 then
  1388.                                 if team ~= zombie_team then
  1389.                                     makezombie(i, true)
  1390.                                     say(getname(i) .. in_hill_too_long_msg)
  1391.                                 else
  1392.                                     kill(i)
  1393.                                     say(getname(i) .. " has been killed because they were in the hill too long!")
  1394.                                 end
  1395.                                 inhill_time[name] = nil
  1396.                             elseif team ~= zombie_team then
  1397.                                 privatesay(i, "You have " .. math.abs(inhill_time[name] - 10) .. " seconds to leave the hill!")
  1398.                                 inhill_time[name] = inhill_time[name] + 1
  1399.                             end
  1400.                         elseif m_object then
  1401.                             inhill_time[name] = nil
  1402.                             writebit(m_object + 0x10, 0, 0)
  1403.                         end
  1404.                     end
  1405.                 end
  1406.             end
  1407.         end
  1408.     end
  1409.     return true
  1410. end
  1411.  
  1412. function LoadTags()
  1413.     for i = 1,4 do
  1414.         if zombie_weapon[i] == "weapons\\ball\\ball" or zombie_weapon[i] == "weapons\\flag\\flag" then
  1415.             oddball_or_flag = gettagid("weap", zombie_weapon[i])
  1416.         end
  1417.     end
  1418.     camouflage_tag_id = gettagid("eqip", "powerups\\active camouflage")
  1419.     healthpack_tag_id = gettagid("eqip", "powerups\\health pack")
  1420.     overshield_tag_id = gettagid("eqip", "powerups\\over shield")
  1421.     fragnade_tag_id = gettagid("eqip", "weapons\\frag grenade\\frag grenade")
  1422.     plasmanade_tag_id = gettagid("eqip", "weapons\\plasma grenade\\plasma grenade")
  1423.     fragnade_tag_id = gettagid("eqip", "weapons\\frag grenade\\frag grenade")
  1424.     plasmanade_tag_id = gettagid("eqip", "weapons\\plasma grenade\\plasma grenade")
  1425.     oddball_tag_id = gettagid("weap", "weapons\\ball\\ball")
  1426.     flag_tag_id = gettagid("weap", "weapons\\flag\\flag")
  1427. end
  1428.  
  1429. function makehuman(player, forcekill, updatecounters)
  1430.     if getplayer(player) then
  1431.         if gametype == "Slayer" then
  1432.             writebyte(getplayer(player) + 0x20, human_team)
  1433.         end
  1434.         -- change the player's speed
  1435.         setspeed(player, human_speed)
  1436.         if getteam(player) == zombie_team then
  1437.             changeteam(player, forcekill)
  1438.             if not team_play then
  1439.                 OnFFATeamChange(player, getteam(player), updatecounters)
  1440.             end
  1441.         end
  1442.     end
  1443. end
  1444.  
  1445. function makezombie(player, forcekill, updatecounters)
  1446.     if getplayer(player) ~= nil then
  1447.         if gametype == "Slayer" then
  1448.             writebyte(getplayer(player) + 0x20, zombie_team)
  1449.         end
  1450.         -- change the player's speed
  1451.         setspeed(player, zombie_speed)
  1452.         if getteam(player) ~= zombie_team then
  1453.             changeteam(player, forcekill)
  1454.             if not team_play then
  1455.                 OnFFATeamChange(player, getteam(player), updatecounters)
  1456.             end
  1457.         end
  1458.     else
  1459.         say("Makezombie got nil")
  1460.     end
  1461. end
  1462.  
  1463. function makezombiedelay(id, count, arg)
  1464.     makezombie(arg[1], arg[2])
  1465. end
  1466.  
  1467. function makehumandelay(id, count, arg)
  1468.     makehuman(arg[1], arg[2])
  1469. end
  1470.  
  1471. function MsgTimer(id, count, player)
  1472.     if getplayer(player) then
  1473.         privatesay(player, welcome_message)
  1474.         if gametype == "KOTH" then
  1475.             privatesay(player, koth_additional_welcome_msg)
  1476.         elseif gametype == "Slayer" then
  1477.             --local msg = tokenizestring(slayer_additional_welcome_msg, "\n")
  1478.             --privatesay(player, msg[1])
  1479.             --privatesay(player, msg[2])
  1480.         end
  1481.     end
  1482.     return false
  1483. end
  1484.  
  1485. function NewGameTimer(id, count)
  1486.     if cur_players ~= 0 then
  1487.         local newgame_zombie_count = 0
  1488.         -- by default make all players human
  1489.         for x=0,15 do
  1490.             if getplayer(x) then
  1491.                 local thisTeam = getteam(x)
  1492.                 local name = getname(x)
  1493.                 if thisTeam then
  1494.                     if thisTeam == zombie_team then
  1495.                         changeteam(x, 0)
  1496.                     end
  1497.                     human_time[name] = 0
  1498.                 end
  1499.             end
  1500.         end
  1501.         local possible_count = cur_players
  1502.         -- make players zombie until the count has been met
  1503.         local finalZombies = 0
  1504.         if zombie_count >= 1 then
  1505.             finalZombies = zombie_count
  1506.         else
  1507.             finalZombies = round((possible_count * zombie_count) + 0.5)
  1508.         end
  1509.         -- make last man zombie
  1510.         local last_man_index = -1
  1511.         -- check if the last man is to be made a zombie
  1512.         -- if so find who was last man
  1513.         if last_man_next_zombie == true and cur_players > 1 then
  1514.             -- loop through all IP's and check if any match the last man
  1515.             readlastman()
  1516.             for i=0,15 do
  1517.                 if getplayer(i) then
  1518.                     local name = getname(i)
  1519.                     if last_man_name == name then
  1520.                         -- make them a zombie and save their info
  1521.                         makezombie(i, true)
  1522.                         newgame_zombie_count = 1
  1523.                         last_man_index = i
  1524.                         break
  1525.                     end
  1526.                 end
  1527.             end
  1528.         end
  1529.         -- reset last man
  1530.         last_man_name = 0
  1531.         if finalZombies == cur_players then -- if 0 players they will be human
  1532.             finalZombies = finalZombies - 1
  1533.         elseif finalZombies > possible_count then -- fix the count
  1534.             finalZombies = possible_count
  1535.         elseif max_zombie_count and finalZombies > max_zombie_count then -- cap the zombie count
  1536.             finalZombies = max_zombie_count
  1537.         elseif finalZombies < 0 then
  1538.             finalZombies = 0
  1539.         end
  1540.         -- set counters such that ChangeTeam wont end the game
  1541.         cur_zombie_count = 16
  1542.         cur_human_count = 16
  1543.         -- loop through the players, randomly selecting ones to become
  1544.         -- zombies
  1545.         while (newgame_zombie_count < finalZombies) do
  1546.             -- randomly choose a player
  1547.             local newzomb = ChooseRandomPlayer(zombie_team)
  1548.             if newzomb == nil then
  1549.                 break
  1550.             elseif newzomb ~= last_man_index then
  1551.                 makezombie(newzomb, true)
  1552.                 newgame_zombie_count = newgame_zombie_count + 1
  1553.             end
  1554.         end
  1555.         -- fix the team counters
  1556.         cur_zombie_count = newgame_zombie_count
  1557.         cur_human_count = cur_players - finalZombies
  1558.         -- reset the map
  1559.         killtimer = false
  1560.         svcmd("sv_map_reset")
  1561.         hprintf("Game started")
  1562.         say("The game has started")
  1563.         -- loop through and tell players which team they're on
  1564.         for i=0,15 do
  1565.             if getplayer(i) then
  1566.                 local pteam = getteam(i)
  1567.                 if pteam then
  1568.                     -- check if they're a zombie
  1569.                     if pteam == zombie_team then
  1570.                         privatesay(i, zombie_message)
  1571.                     else
  1572.                         if not team_play then makehuman(i) end
  1573.                         privatesay(i, human_message)
  1574.                     end
  1575.                 end
  1576.             end
  1577.         end
  1578.     end
  1579.     game_started = true
  1580.     killtimer = false
  1581.     new_game_timer = nil
  1582.     resptime = nil
  1583.     return false -- remove timer
  1584. end
  1585.  
  1586. function noZombiesLeft()
  1587.     if team_play then
  1588.         if player_change_timer == nil then
  1589.             allow_change = true
  1590.             say(nozombiesleftmessage)
  1591.             player_change_timer = registertimer(1000, "PlayerChangeTimer")
  1592.         end
  1593.     else
  1594.         -- pick a human and make them zombie.
  1595.         local newZomb = ChooseRandomPlayer(zombie_team)
  1596.         if newZomb then
  1597.             makezombie(newZomb, true)
  1598.             privatesay(newZomb, zombie_message)
  1599.         end
  1600.     end
  1601. end
  1602.  
  1603. function object_in_sphere(m_objectId, X, Y, Z, R)
  1604.     local Pass = false
  1605.     if getobject(m_objectId) then
  1606.         local x,y,z = getobjectcoords(m_objectId)
  1607.         if (X - x)^2 + (Y - y)^2 + (Z - z)^2 <= R then
  1608.             Pass = true
  1609.         end
  1610.     end
  1611.     return Pass
  1612. end
  1613.  
  1614. function OnFFATeamChange(player, dest_team, updatecounters)
  1615.     -- update team counts
  1616.     if not updatecounters then
  1617.         if dest_team == zombie_team then
  1618.             cur_human_count = cur_human_count - 1
  1619.             cur_zombie_count = cur_zombie_count + 1
  1620.         elseif dest_team ~= zombie_team then
  1621.             cur_human_count = cur_human_count + 1
  1622.             cur_zombie_count = cur_zombie_count - 1
  1623.         end
  1624.     end
  1625.     -- check if the game has started yet
  1626.     if game_started == true then
  1627.         registertimer(200,"checkgamestate",player)
  1628.     end
  1629.     -- update team with
  1630.     local thisNAME = getname(player)
  1631.     name_table[thisNAME] = team
  1632. end
  1633.  
  1634. function onlastman()
  1635.     -- lookup the last man
  1636.     for x=0,15 do
  1637.         if getplayer(x) then
  1638.             local team = getteam(x)
  1639.             if team ~= zombie_team and team then
  1640.                 cur_last_man = x
  1641.                 if gametype == "Slayer" then WriteNavsToZombies(x) end
  1642.                 -- give the last man speed and extra ammo
  1643.                 setspeed(x, lastman_speed)
  1644.                 -- find the last man's weapons
  1645.                 local m_player = getplayer(x)
  1646.                 if m_player then
  1647.                     local m_ObjId = readdword(m_player + 0x34)
  1648.                     if m_ObjId then
  1649.                         -- find the player's object
  1650.                         local m_object = getobject(m_ObjId)
  1651.                         if m_object then
  1652.                             if lastman_invulnerable and lastman_invulnerable > 0 then
  1653.                                 -- setup the invulnerable timer
  1654.                                 writebit(m_object + 0x10, 0, 1)
  1655.                                 registertimer(lastman_invulnerable * 1000, "RemoveLastmanProtection", m_object)
  1656.                             end
  1657.                             -- give all weapons 600 ammo
  1658.                             for i=0,3 do
  1659.                                 local m_weaponId = readdword(m_object + 0x2F8 + (i*4))
  1660.                                 if m_weaponId ~= 0xffffffff then
  1661.                                     -- get the weapons memory address
  1662.                                     local m_weapon = getobject(m_weaponId)
  1663.                                     if m_weapon then
  1664.                                         -- set the ammo
  1665.                                         writeword(m_weapon, 0x2B6, 132)
  1666.                                         writeword(m_weapon, 0x2B8, 100) --lastman clipcount
  1667.                                         updateammo(m_weaponId)
  1668.                                     end
  1669.                                 end
  1670.                             end
  1671.                         end
  1672.                     end
  1673.                 end
  1674.             end
  1675.         end
  1676.     end
  1677.     if cur_last_man then
  1678.         local lastman_name = getname(cur_last_man)
  1679.         local msg = string.format(lastman_message, tostring(lastman_name), lastman_invistime)
  1680.         say(msg)
  1681.         applycamo(cur_last_man, lastman_invistime)
  1682.     end
  1683. end
  1684.  
  1685. function PlayerChangeTimer(id, count)
  1686.     if count ~= 6 and team_play then
  1687.         local zombsize = cur_zombie_count
  1688.         if allow_change == false or zombsize > 0 then
  1689.             allow_change = false
  1690.             say("Thank you, the game can continue.")
  1691.             player_change_timer = nil
  1692.             return false
  1693.         end
  1694.         say("In " .. 6 - count .. " seconds a player will be forced to become a zombie.")
  1695.         return true
  1696.     else -- timer up, force team change
  1697.         allow_change = false
  1698.         -- pick a human and make them zombie.
  1699.         local newZomb = ChooseRandomPlayer(zombie_team)
  1700.         if newZomb ~= nil then
  1701.             makezombie(newZomb, true)
  1702.             kill(newZomb)
  1703.             say(getname(newZomb) .. " is now the new zombie!", false)
  1704.             privatesay(newZomb, zombie_message)
  1705.         else
  1706.             say("PlayerChangeTimer got nil")
  1707.         end
  1708.         player_change_timer = nil
  1709.         return false
  1710.     end
  1711. end
  1712.  
  1713. function PlayerInHill(player)
  1714.     player = tonumber(player)
  1715.     local bool = false
  1716.     local m_player = getplayer(player)
  1717.     if m_player then
  1718.         local InHill = readbyte(team_koth_score_array + player + 0x80)
  1719.         if InHill == 1 then
  1720.             bool = true
  1721.         end
  1722.     end
  1723.     return bool
  1724. end
  1725.  
  1726. function PutUnderMap(id, count, m_objectId)
  1727.     local m_object = getobject(m_objectId)
  1728.     if m_object then
  1729.         local x,y,z = getobjectcoords(m_objectId)
  1730.         movobjectcoords(m_objectId, x, y, z - 20)
  1731.     end
  1732.     return false
  1733. end
  1734.  
  1735. function privatesay(player, message, script_prefix)
  1736.     if GAME == "PC" then
  1737.         phasor_privatesay(player, (script_prefix or default_script_prefix) .. message, false)
  1738.     else
  1739.         phasor_privatesay(player, message, false)
  1740.     end
  1741. end
  1742.  
  1743. function say(message, script_prefix)
  1744.     if GAME == "PC" then
  1745.         phasor_say((script_prefix or default_script_prefix) .. message, false)
  1746.     else
  1747.         phasor_say(message, false)
  1748.     end
  1749. end
  1750.  
  1751. function sendresponse(message, player)
  1752.     if message == "" then
  1753.         return
  1754.     end
  1755.     player = tonumber(player)
  1756.     if tonumber(player) and player ~= nil and player ~= -1 and player >= 0 and player < 16 then
  1757.         sendconsoletext(player, message)
  1758.     else
  1759.         hprintf(message)
  1760.     end
  1761. end
  1762.  
  1763. function ScriptLoad()
  1764.     if Persistent then
  1765.         cur_zombie_count = 0
  1766.         cur_human_count = 0
  1767.         alpha_zombie_count = 0
  1768.         human_time = {}
  1769.         cur_players = 0
  1770.         cur_last_man = nil
  1771.         last_man_name = 0
  1772.         processid = 0
  1773.         game_started = false
  1774.         allow_change = false
  1775.         flagball_weap = {}
  1776.         last_hill_time = {}
  1777.         name_table = {}
  1778.         inhill_time = {}
  1779.     end
  1780.     gametype = readbyte(gametype_base + 0x30)
  1781.     gametype_indicator = readbyte(gametype_base + 0x3C)
  1782.     writedword(ctf_score_patch, 0x90909090)
  1783.     writebyte(ctf_score_patch1, 0x90)
  1784.     writebyte(slayer_score_patch, 0xEB)
  1785.     writebyte(slayer_score_patch2, 0xEB)
  1786.     writedword(koth_score_patch, 0xF3E9)
  1787.     writebyte(koth_score_patch2, 0xEB)
  1788.  
  1789.     -- recalculate team counters
  1790.     cur_human_count, cur_zombie_count = getteamsizes()
  1791.     cur_players = cur_zombie_count + cur_human_count
  1792.  
  1793.     -- recalculate how many "alpha" zombies there are
  1794.     alpha_zombie_count = getalphacount()
  1795.     team_play = getteamplay()
  1796.  
  1797.     if gametype == 1 then
  1798.         gametype = "CTF"
  1799.         writedword(flag_respawn_addr + 0x0, 0xFFFFFFFF)
  1800.         registertimer(0, "DelayWriteCoords")
  1801.         join_team = zombie_team
  1802.     elseif gametype == 2 then
  1803.         gametype = "Slayer"
  1804.         join_team = zombie_team
  1805.         if speedtimer == nil then
  1806.             speedtimer = registertimer(750, "SpeedTimer")
  1807.         end
  1808.         for player=0,15 do
  1809.             if getplayer(player) then
  1810.                 cur_players = cur_players + 1
  1811.                 local team = getteam(player)
  1812.                 -- onteamdecision isn't called for ffa gametypes
  1813.                 if not team_play then
  1814.                     -- initialize the destination team as the join team
  1815.                     local dest_team = join_team
  1816.                     -- if no zombies make them human
  1817.                     if cur_human_count == 0 then
  1818.                         dest_team = human_team
  1819.                     end
  1820.                     -- we need to overwrite the 'team' variable being passed to onplayerjoin
  1821.                     team = dest_team
  1822.                 end
  1823.                 if team == zombie_team then
  1824.                     cur_zombie_count = cur_zombie_count + 1
  1825.                     --we don't need to update the counters since they're already on the zombieteam
  1826.                     makezombie(player, false, true)
  1827.                     --send them the zombie message
  1828.                     privatesay(player, zombie_message)
  1829.                 else
  1830.                     cur_human_count = cur_human_count + 1
  1831.                     --make this person a human (they're currently a zombie)
  1832.                     makehuman(player, false, true)
  1833.                     --send them the human message
  1834.                     privatesay(player, human_message)
  1835.                 end
  1836.             end
  1837.         end
  1838.     elseif gametype == 4 then
  1839.         gametype = "KOTH"
  1840.         join_team = zombie_team
  1841.     else
  1842.         join_team = zombie_team
  1843.         hprintf("Incompatible gametype!")
  1844.     end
  1845.     -- assume a game is running
  1846.     game_started = true
  1847.  
  1848.     if humantimer == nil then
  1849.         humantimer = registertimer(1000, "HumanTimer")
  1850.     end
  1851.     LoadTags()
  1852.     registertimer(200,"checkgamestate",-1)
  1853. end
  1854.  
  1855. function readlastman()
  1856.     local file = io.open("lastname_" .. processid .. ".tmp", "r")
  1857.     if file then
  1858.         -- read the ip
  1859.         last_man_name = file:read("*line")
  1860.         file:close()
  1861.         -- delete the file
  1862.         os.remove("lastname_" .. processid .. ".tmp")
  1863.     end
  1864. end
  1865.  
  1866. function SpeedTimer(id, count)
  1867.     if gametype == "Slayer" then
  1868.         for i = 0,15 do
  1869.             local m_player = getplayer(i)
  1870.                 if m_player then
  1871.                 local speed = readfloat(m_player, 0x6C)
  1872.                 if getteam(i) == zombie_team and speed < zombie_speed then
  1873.                     setspeed(i, zombie_speed)
  1874.                 elseif getteam(i) ~= zombie_team and cur_last_man and speed < lastman_speed then
  1875.                     setspeed(i, lastman_speed)
  1876.                 elseif getteam(i) ~= zombie_team and not cur_last_man and speed < human_speed then
  1877.                     setspeed(i, human_speed)
  1878.                 end
  1879.             end
  1880.         end
  1881.         return true
  1882.     end
  1883.     return false
  1884. end
  1885.  
  1886. function RemoveLastmanProtection(id, count, m_object)
  1887.     writebit(m_object + 0x10, 0, 0)
  1888.     return false
  1889. end
  1890.  
  1891. function round(val, decimal)
  1892.     return math.floor((val * 10^(tonumber(decimal) or 0) + 0.5)) / (10^(tonumber(decimal) or 0))
  1893. end
  1894.  
  1895. function takenavsaway(lastman)
  1896.     for i = 0,15 do
  1897.         local m_player = getplayer(i)
  1898.         if m_player then
  1899.             writeword(m_player, 0x88, i)
  1900.         end
  1901.     end
  1902. end
  1903.  
  1904. function WriteNavsToZombies(cur_last_man)
  1905.     for i = 0,15 do
  1906.         if getplayer(i) ~= nil then
  1907.             local team = getteam(i)
  1908.             if team == zombie_team then
  1909.                 local m_player = getplayer(i)
  1910.                 if m_player then
  1911.                     local slayer_target = readword(m_player, 0x88)
  1912.                     if slayer_target < 16 and slayer_target > -1 then
  1913.                         writeword(m_player, 0x88, cur_last_man)
  1914.                     end
  1915.                 end
  1916.             end
  1917.         end
  1918.     end
  1919. end
  1920.  
  1921. function writewordsigned(address, offset, value)
  1922.     if tonumber(value) and value > 0x7FFF then
  1923.         local difference = 0xFFFF - value
  1924.         value = -1 - difference
  1925.     end
  1926.     writeword(address + offset, value)
  1927. end
  1928.  
  1929. function writedwordsigned(address, offset, value)
  1930.     if value and value > 0x7FFFFFFF then
  1931.         local difference = 0xFFFFFFFF - value
  1932.         value = -1 - difference
  1933.     end
  1934.     writedword(address + offset, value)
  1935. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement