Advertisement
Guest User

AHA

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