diff --git a/ETWsk.lua b/ETWsk.lua new file mode 100644 index 0000000..4e6034a --- /dev/null +++ b/ETWsk.lua @@ -0,0 +1,1118 @@ +-------------------------------------------------------------------------------- +-- ETWsk - ETW-FZ Enemy Territory Anti-Spawnkill Mod for etpro +-------------------------------------------------------------------------------- +-- This script can be freely used and modified as long as [ETW-FZ] and the +-- original author are mentioned. +-------------------------------------------------------------------------------- +module_name = "ETWsk" +module_version = "0.9.1" +Author = "[ETW-FZ] Mad@Mat" +-- 2010-11-24 benny [ quakenet @ #hirntot.org ] --> putspec for etpub +-- 2009-03-12 benny [ quakenet @ #hirntot.org ] --> temp ban persistent offenders +-- 2008-11-16 benny [ quakenet @ #hirntot.org ] --> no warmup punish +-- 2008-10-06 benny [ quakenet @ #hirntot.org ] --> sin bin added. + + +-------------------------------------------------------------------------------- +-- DESCRIPTION +-------------------------------------------------------------------------------- +-- ETWsk aims to reduce spawnkilling (SK) on public funservers. An SK here is if +-- someone kills an enemy near a fix spawn point. A fix spawn point means that +-- it can not be cleared by the enemy. E.g. on radar map, the allied Side Gate +-- spawn is not fix as the axis can destroy the command post. However, the Main +-- Bunker spawn is fix after the Allies have destroyed the Main Gate. ETWsk does +-- not prevent but it detects and counts SKs for every player. If a player has +-- caused a certain number of SKs, he gets punished (putspec, kick, ban, ...). +-- As the detection of fix spawns is difficult especially on custom maps, little +-- configuration work has to be done. +-- +-- Features: +-- - circular protection areas around spawn points +-- - two protection radius can be defined: heavy weapons and normal weapons +-- - the spawn protection expires when a player hurts an enemy +-- (can be disabled) +-- - fully configurable for individual maps: fixing radius, positions; +-- adding actions that change protected areas during the game; adding new +-- protection areas. +-- - client console commands for stats and help for configuration +-- - no RunFrame() -> low server load +-- - sin bin [benny] --> don't let clients join a team for XX milliseconds +-- if they have been set spec +-- - temp ban for persistent spawn killers [benny] +-------------------------------------------------------------------------------- +-- CONFIG +-------------------------------------------------------------------------------- +ETWsk_putspec = 1 -- number of sk's needed for setting a client + -- to spectators +ETWsk_kick = 2 -- number of sk's needed for kicking a client +ETWsk_kicklen = 5 -- duration of kick +first_sk = 0 +-- benny ----------------------------------------------------------------------- +ETWsk_persistentoffender = 1 -- enable punishment 4 persistent spawn killers +ETWsk_POThreshold = 2 -- if players has been kicked before, he will + -- be temp banned with his XX spawn kill +ETWsk_banval = 30 -- (ETWsk_banval * 4 ^ kicksb4) = ban + -- If ETWsk_banval = 30, he'll be kicked 4 + -- 120 minutes, next is 480, 1920, 7680, ... +ETWsk_pofile = "ETWsk_PO.txt" -- save to /etpro/ETWsk_PO.txt +-------------------------------------------------------------------------------- +ETWsk_defaultradius1 = 0 -- protection radius for ordinary weapons +ETWsk_defaultradius2 = 0 -- protection radius for heavy weapons. def 800 +ETWsk_savemode = 1 -- if enabled, protection is only active on + -- maps that are configured +ETWsk_expires = 0 -- if enabled, spawn protection expires when + -- the victim hurts an enemy +-- benny ----------------------------------------------------------------------- +sinbin = true -- [true|false] +sinbin_duration = 300000 -- in milliseconds: 30000 = 30 seconds +sinbin_pos = "chat" -- prints to client on sin bin, "b 8 " = chat area +-------------------------------------------------------------------------------- + +-------------------------------------------------------------------------------- +-- heavyweapons = {17,19,27,49,57,30} -- heavy weapon indexes + -- (http://wolfwiki.anime.net/index.php/Etdamage) + +-- benny 'ref remove' doesn't work w/ bots in etpub... +function putspec(id) + return(string.format(putspec_str, id)) +end +putspec_str = "ref remove %d\n" + +heavyweapons = {1, 2, 3, 15, 17, 23, 26, 44, 52, 62, 63, 64} -- heavy weapon indexes + +maxcheckpointdist = 800 -- used to detect capturable flag poles +-------------------------------------------------------------------------------- + +-------------------------------------------------------------------------------- +-- CONSTANTS +NO_PROTECT = 0 +PROTECT_AXIS = 1 +PROTECT_ALLIES = 2 +-------------------------------------------------------------------------------- + +-- benny: sin bin hash + persistent offender hash +sinbinhash = {} +pohash = {} +et.CS_PLAYERS = 689 + +-------------------------------------------------------------------------------- +function getConfig(map) +-------------------------------------------------------------------------------- +-- configures protection of spawn areas in specific maps +-------------------------------------------------------------------------------- +-- elseif map == "" then +-- +-- +-------------------------------------------------------------------------------- +-- spawn definitions: +-- c.spawn[] = {} +-- spawn-num: spawn index (see /etwsk_spawns command) +-- spawn-fields: - comma-separated list of "key = value" +-- - for existing spawns all fields are optional (they overwrite +-- default values). +-- - fields: +-- name = : name of spawn point +-- state = NO_PROTECT|PROTECT_ALLIES|PROTECT_AXIS +-- pos = {x,y,z} : map coordinates of spawn point +-- radius1 = : protection radius for normal weapons +-- radius2 = : protection radius for heavy weapons +-- action definitions: actions are definitions of transitions of one state of a +-- spawn point into another one triggered by a message. +-- c.action[] = {} +-- action-num: just an increment number +-- action-fields: - comma-separated list of "key = value" +-- - all fields are mandatory +-- - fields: +-- spawn = +-- newstate = NO_PROTECT|PROTECT_ALLIES|PROTECT_AXIS +-- trigger = : part of a message that is displayed +-- by the server on a specific event. +-- adding new protection areas to maps: +-- new protection areas can easily been added: +-- 1. enter the map and walk to the location where you want to add the area +-- 2. type /etwsk_spawns and remember the highest spawn index number +-- 3. type /etwsk_pos and write down the coordinates +-- 4. add spawn to config with at least the name,state and pos field +-- default values: +-- At mapstart, ETWsk scans for all spawnpoints and sets the state either to +-- PROTECT_ALLIES or PROTECT_AXIS. It also scans for capturable flag poles +-- and sets the state of a spawnpoint near a flag pole to NO_PROTECT. The +-- location of a spawnpoint is taken from the WOLF_objective entity, the +-- small spawn flag that can be selected in the command map. This entity is +-- usually placed in the center of the individual player-spawnpoints. +-- However, on some maps this is not the case. Check the positions of the +-- small spawn flags on the command map or type /etwsk_pos after you have +-- spawned to check the distance to protected areas. If needed, adjust the +-- radius, or the pos or add a new protection area to the map. +-- If you wish to set all protection areas manually in a map, add: +-- c.defaults = false +-- to the definitions for a map. +-------------------------------------------------------------------------------- + hasconfig = true + local c = {spawns = {}, actions = {}, defaults = true} +-- airassfp1 28.03.2010 + if map == "airassfp1" then + c.spawns[1] = {name = "Base Barracks", state = PROTECT_AXIS, pos = {-410, -4450, 346}, radius2 = 400} + c.spawns[2] = {name = "Airfield Base", state = PROTECT_AXIS, pos = {-1660, 750, 240}, radius2 = 600} + c.spawns[3] = {name = "Airfield Base2", state = PROTECT_AXIS, pos = {-1660, 40, 240}, radius2 = 400} + c.spawns[4] = {name = "Allied Train Entrance", state = PROTECT_ALLIES, pos = {2650, -7530, 410}, radius2 = 1000} + c.actions[1] = {spawn = 1, newstate = PROTECT_ALLIES, trigger = "Allies have blown up the Main Entrance!"} +-- Siwa Oasis 16.11.2008 Update 21.04.2013 + elseif map == "oasis" then +-- c.spawns[1] = {name = "Axis Garrison", state = PROTECT_AXIS, pos = {7400, 4810, -391}, radius2 = 460} + c.spawns[1] = {name = "Axis Garrison", state = PROTECT_AXIS, pos = {7420, 4710, -391}, radius2 = 500} + c.spawns[2] = {name = "Allied Camp Base", state = PROTECT_ALLIES, pos = {1250, 2760, -415}, radius2 = 1140} + c.spawns[3] = {name = "Old City", state = NO_PROTECT, pos = {4300, 7000, -450}, radius2 = 870} + c.actions[1] = {spawn = 3, newstate = PROTECT_ALLIES, trigger = "breached the Old City wall"} +-- __BRIDGES__ 28.03.2010 + elseif map == "__bridges__" then + c.spawns[1] = {name = "The Sawmill Spawns", state = PROTECT_ALLIES, pos = {-4850, -7620, 820}, radius2 = 500} + c.spawns[2] = {name = "The Mill Tunnel Spawns", state = PROTECT_ALLIES, pos = {-1470, -2230, 630}, radius2 = 460} + c.spawns[3] = {name = "The Reservoir Spawns", state = PROTECT_AXIS, pos = {9440, 3680, 680}, radius2 = 500} + c.spawns[4] = {name = "North Tunnel2", state = PROTECT_AXIS, pos = {4020, 1200, 820}, radius2 = 300} + c.spawns[5] = {name = "The Boathouse Spawns", state = NO_PROTECT, pos = {180, 2100, 310}, radius2 = 500} + c.spawns[6] = {name = "The Mill Service Tunnel Spawns", state = NO_PROTECT, pos = {-5094, -2452, 480}, radius2 = 300} + c.actions[1] = {spawn = 5, newstate = PROTECT_AXIS, trigger = "Axis gained spawn positions at The Boathouse!"} + c.actions[2] = {spawn = 4, newstate = PROTECT_ALLIES, trigger = "Allies gained positions in the North Tunnel!"} + c.actions[3] = {spawn = 2, newstate = NO_PROTECT, trigger = "Allies gained positions in the North Tunnel!"} + c.actions[4] = {spawn = 5, newstate = NO_PROTECT, trigger = "Axis are regrouping at the reservoir!"} + c.actions[5] = {spawn = 2, newstate = PROTECT_ALLIES, trigger = "allies have gained spawn positions in the Mill Tunnel"} + c.actions[6] = {spawn = 4, newstate = PROTECT_AXIS, trigger = "allies have gained spawn positions in the Mill Tunnel"} + c.actions[7] = {spawn = 2, newstate = PROTECT_AXIS, trigger = "Axis gained spawn positions at The Mill Tunnel"} + c.actions[8] = {spawn = 4, newstate = NO_PROTECT, trigger = "Axis gained spawn positions at The Mill Tunnel"} + c.actions[9] = {spawn = 6, newstate = PROTECT_AXIS, trigger = "Axis gained spawn positions at The Mill Tunnel"} + +-- Axislab 28.03.2010 + elseif map == "axislab_final" then + c.spawns[1] = {name = "Hill Top", state = NO_PROTECT, pos = {-162, 2540, 1130}, radius2 = 600} + c.spawns[2] = {name = "Allied Side", state = PROTECT_ALLIES, pos = {2250, -4140, 170}, radius2 = 1000} + c.spawns[3] = {name = "Allied Cabin", state = NO_PROTECT, pos = {-2900, 225, 330}, radius2 = 100} + c.spawns[4] = {name = "Axis Bunker", state = PROTECT_AXIS, pos = {-1450, 2400, 470}, radius2 = 300} + c.spawns[5] = {name = "Axis Bunker2", state = PROTECT_AXIS, pos = {-1420, 2100, 470}, radius2 = 300} + c.spawns[6] = {name = "Axis Bunker3", state = PROTECT_AXIS, pos = {-990, 2038, 470}, radius2 = 300} + c.spawns[7] = {name = "Boardroom", state = PROTECT_AXIS, pos = {240, 1190, 310}, radius2 = 300} + c.actions[1] = {spawn = 1, newstate = PROTECT_ALLIES, trigger = "Allies have secured the Hill Top!"} +-- et_mor2 28.03.2010 + elseif map == "et_mor2" then + c.spawns[1] = {name = "Desert Camp", state = PROTECT_ALLIES, pos = {9590, 1600, -300}, radius2 = 1300} + c.spawns[2] = {name = "Gate House", state = PROTECT_AXIS, pos = {1720, 700, 30}, radius2 = 470} + c.spawns[3] = {name = "Gate House2", state = PROTECT_AXIS, pos = {2360, 645, 30}, radius2 = 300} + c.spawns[4] = {name = "NorthMarket", state = PROTECT_AXIS, pos = {-1290, 1620, 30}, radius2 = 600} + c.actions[1] = {spawn = 2, newstate = PROTECT_ALLIES, trigger = "Allies have destroyed the Main town gate!"} + c.actions[2] = {spawn = 3, newstate = PROTECT_ALLIES, trigger = "Allies have destroyed the Main town gate!"} +-- bulge_beta1 aka Wacht am Rhein 07.04.2010 + elseif map == "bulge_beta1" then + c.spawns[1] = {name = "Hotel", state = PROTECT_ALLIES, pos = {4060, -620, 330}, radius2 = 600} + c.spawns[2] = {name = "Allied Town Spawn", state = PROTECT_ALLIES, pos = {-4210, -800, 105}, radius2 = 600} + c.spawns[3] = {name = "Axis Headquarters", state = PROTECT_AXIS, pos = {4120, -4360, 400}, radius2 = 900} + c.actions[1] = {spawn = 1, newstate = PROTECT_AXIS, trigger = "The Tank is at the Hotel"} + c.actions[2] = {spawn = 1, newstate = NO_PROTECT, trigger = "The tank is near the 1st tank barrier"} +-- mp_rocket_et_a1 09.04.2010 + elseif map == "mp_rocket_et_a1" then + c.spawns[1] = {name = "Security Checkpoint", state = NO_PROTECT} + c.spawns[2] = {name = "The Train Cars", state = PROTECT_ALLIES, pos = {2570, -470, 25}, radius2 = 500} + c.spawns[3] = {name = "Security Checkpoint Axis", state = PROTECT_AXIS, pos = {370, 1250, 150}, radius2 = 500} + c.spawns[4] = {name = "Security Checkpoint Axis", state = PROTECT_AXIS, pos = {-10, 1360, 336}, radius2 = 300} +-- caen2 29.04.2010 +-- x0rnn 2018/03/22 decreased allied spawn radius + elseif map == "caen2" then + c.spawns[1] = {name = "TOWN", state = NO_PROTECT} + c.spawns[2] = {name = "Axis Spawn", state = PROTECT_AXIS, pos = {-1690, -2200, 310}, radius2 = 600} + c.spawns[3] = {name = "Allies Spawn", state = PROTECT_ALLIES, pos = {-2120, 6130, 570}, radius2 = 523} + c.actions[1] = {spawn = 1, newstate = PROTECT_AXIS, trigger = "The Axis are moving the Tank!"} +-- snatch3 29.04.2010 + elseif map == "snatch3" then + c.spawns[1] = {name = "Forest House", state = NO_PROTECT, pos = {-860, -1950, 190}, radius2 = 600} + c.spawns[2] = {name = "Base Spawn", state = PROTECT_AXIS, pos = {40, 2200, 600}, radius2 = 400} + c.spawns[3] = {name = "Allied House", state = PROTECT_ALLIES, pos = {2400, 2220, 215}, radius2 = 600} +-- Railgun + elseif map == "railgun" then + c.spawns[1] = {name = "Axis Tower Spawn", state = NO_PROTECT} + c.spawns[2] = {name = "Axis Construction Site", pos = {-1300, 5183, 420}, state = PROTECT_AXIS, radius2 = 1820} + c.spawns[4] = {name = "Allied Camp", state = PROTECT_ALLIES, radius2 = 700} + c.spawns[5] = {name = "Allied Camp", state = PROTECT_ALLIES, pos = {6000, 3370, 280}, radius2 = 790} +-- Seawall Battery + elseif map == "battery" then + c.spawns[1] = {name = "Axis Main Bunker", state = PROTECT_AXIS, pos = {3000, -5300, 1016}, radius2 = 400} + c.spawns[2] = {name = "Allied East Beach", state = PROTECT_ALLIES, pos = {4565, -620, 113}, radius2 = 450} + c.spawns[3] = {name = "Allied East Beach 2", state = PROTECT_ALLIES, pos = {5136, -1184, 488}, radius2 = 450} + c.spawns[4] = {name = "Allied West Beach", state = PROTECT_ALLIES, pos = {544, -760, 113}, radius2 = 400} + c.spawns[5] = {name = "Command Post spawnt", state = NO_PROTECT} + c.spawns[6] = {name = "West Bunker Allies", state = NO_PROTECT} + c.spawns[7] = {name = "Axis spawn / Command Post", state = NO_PROTECT} +-- SW Seawall Battery + elseif map == "sw_battery" then + c.spawns[1] = {name = "Axis Main Bunker", state = PROTECT_AXIS, pos = {3000, -5300, 1016}, radius2 = 400} + c.spawns[2] = {name = "Allied East Beach", state = PROTECT_ALLIES, pos = {4565, -620, 113}, radius2 = 550} + c.spawns[3] = {name = "Allied West Beach", state = PROTECT_ALLIES, pos = {544, -760, 113}, radius2 = 400} + c.spawns[4] = {name = "Command Post spawnt", state = NO_PROTECT} + c.spawns[5] = {name = "West Bunker Allies", state = NO_PROTECT} + c.spawns[6] = {name = "Axis spawn / Command Post", state = NO_PROTECT} +-- W�rzburg Radar +-- Radar 05.10.2018 - added axis house exit protection + elseif map == "radar" then + c.spawns[1] = {state = NO_PROTECT} -- Side Gate Command Post Spawn + c.spawns[2] = {name = "Abandoned Villa", state = PROTECT_ALLIES, pos = {2504, 3422, 1333}, radius2 = 999} + c.spawns[6] = {name = "Abandoned Villa", state = PROTECT_ALLIES, pos = {1504, 4495, 1333}, radius2 = 660} + c.spawns[3] = {name = "Forward Bunker", state = NO_PROTECT, pos = {-581, 1661, 1364}, radius2 = 785} + c.spawns[4] = {name = "Forward Hut", state = NO_PROTECT} + c.spawns[5] = {name = "Lower Warehouse", state = PROTECT_AXIS, pos = {-1494, -4032, 1248}, radius2 = 330} + c.spawns[7] = {name = "Lower Warehouse II", state = PROTECT_AXIS, pos = {-1270, -3772, 1248}, radius2 = 230} + c.spawns[8] = {name = "Lower Warehouse III", state = PROTECT_AXIS, pos = {-1369, -3662, 1248}, radius2 = 151} + c.actions[1] = {spawn = 3, newstate = PROTECT_ALLIES, trigger = "secured the Forward Bunker"} + elseif map == "radar_phx_b_3" or map == "radar_truck" then + c.spawns[1] = {state = NO_PROTECT} -- Side Gate Command Post Spawn + c.spawns[2] = {name = "Abandoned Villa", state = PROTECT_ALLIES, pos = {2504, 3422, 1333}, radius2 = 999} + c.spawns[6] = {name = "Abandoned Villa", state = PROTECT_ALLIES, pos = {1504, 4495, 1333}, radius2 = 660} + c.spawns[3] = {name = "Forward Bunker", state = NO_PROTECT, pos = {-581, 1661, 1364}, radius2 = 785} + c.spawns[4] = {name = "Forward Hut", state = NO_PROTECT} + c.spawns[5] = {name = "Lower Warehouse", state = PROTECT_AXIS, pos = {-1494, -4032, 1248}, radius2 = 330} + c.spawns[7] = {name = "Lower Warehouse II", state = PROTECT_AXIS, pos = {-1270, -3772, 1248}, radius2 = 230} + c.spawns[8] = {name = "Lower Warehouse III", state = PROTECT_AXIS, pos = {-1369, -3662, 1248}, radius2 = 151} + c.actions[1] = {spawn = 3, newstate = PROTECT_ALLIES, trigger = "secured the Forward Bunker"} + c.actions[2] = {spawn = 2, newstate = PROTECT_AXIS, trigger = "Axis Abandoned Villa spawn enabled"} + c.actions[3] = {spawn = 6, newstate = PROTECT_AXIS, trigger = "Axis Abandoned Villa spawn enabled"} +-- Fueldump +-- Fueldump 05.10.2018 - added lower axis fuel dump spawn exit protection, added allied tunnel spawn protection + elseif map == "fueldump" then + c.spawns[1] = {name = "Tunnel Store Room I", state = PROTECT_AXIS, pos = {-5142, -1724, 500}, radius2 = 290} + c.spawns[6] = {name = "Tunnel Store Room II", state = PROTECT_AXIS, pos = {-5652, -2275, 600}, radius2 = 300} + c.spawns[7] = {name = "Tunnel Store Room Lower Entrance", state = PROTECT_AXIS, pos = {-5655, -1471, 376}, radius2 = 80} + c.spawns[8] = {name = "Tunnel Store Room Stair Way", state = PROTECT_AXIS, pos = {-5661, -1699, 520}, radius2 = 320} + c.spawns[2] = {state = NO_PROTECT} -- Truck + c.spawns[3] = {state = NO_PROTECT} -- Garage HQ + c.spawns[4] = {name = "Axis Fuel Dump", state = PROTECT_AXIS, pos = {-8400, -5663, 417}, radius2 = 665} + c.spawns[9] = {name = "Axis Fuel Dump", state = PROTECT_AXIS, pos = {-8393, -6723, 232}, radius2 = 700} + c.spawns[5] = {name = "Allied Entrance", state = PROTECT_ALLIES, pos = {-857, -8050, 328}, radius2 = 870} + c.spawns[10] = {name = "Tunnel Spawn", state = NO_PROTECT, pos = {-6165, -1288, 344}, radius2 = 300} + c.spawns[11] = {name = "Axis Fuel Dump Lower Exit", state = PROTECT_AXIS, pos = {-8977, -7310, 232}, radius2 = 200} + c.spawns[12] = {name = "Axis Garage", state = PROTECT_AXIS, pos = {-10614, -6452, 232}, radius2 = 250} + c.spawns[13] = {name = "Axis Garage2", state = PROTECT_AXIS, pos = {-10792, -6416, 232}, radius2 = 120} + c.spawns[14] = {name = "Axis Garage3", state = PROTECT_AXIS, pos = {-10622, -6575, 408}, radius2 = 80} + c.spawns[15] = {name = "Axis Garage2", state = PROTECT_AXIS, pos = {-10819, -6576, 408}, radius2 = 150} + c.actions[1] = {spawn = 1, newstate = PROTECT_ALLIES, trigger = "breached the Tunnel Doors"} + c.actions[2] = {spawn = 6, newstate = PROTECT_ALLIES, trigger = "breached the Tunnel Doors"} + c.actions[3] = {spawn = 7, newstate = PROTECT_ALLIES, trigger = "breached the Tunnel Doors"} + c.actions[4] = {spawn = 8, newstate = PROTECT_ALLIES, trigger = "breached the Tunnel Doors"} + c.actions[5] = {spawn = 10, newstate = PROTECT_ALLIES, trigger = "Tunnel Spawn enabled"} + c.actions[6] = {spawn = 10, newstate = NO_PROTECT, trigger = "Tunnel Spawn disabled"} +-- Adlernest B4 16.11.2008 + elseif map == "adlernest" or map == "etl_adlernest" then + c.spawns[1] = {state = PROTECT_ALLIES, radius2 = 570} + c.spawns[4] = {name = "Tank", state = PROTECT_ALLIES, pos = {2513, -321,-95}, radius2 = 540} + c.spawns[2] = {state = NO_PROTECT} + c.spawns[3] = {name = "Axis1", state = PROTECT_AXIS, pos = {-1949, -725, 72}, radius2 = 334} + c.spawns[5] = {name = "Axis2", state = PROTECT_AXIS, pos = {-1925, -50, 72}, radius2 = 334} + c.spawns[6] = {name = "Axis3", state = PROTECT_AXIS, pos = {-978, -445, 72}, radius2 = 334} + c.spawns[7] = {name = "Axis4", state = PROTECT_AXIS, pos = {-1464, -596, 72}, radius2 = 334} + c.spawns[8] = {name = "Axis5", state = PROTECT_AXIS, pos = {-1241, -212, 72}, radius2 = 434} + c.spawns[9] = {name = "Axis6", state = PROTECT_AXIS, pos = {-1597, -184, 100}, radius2 = 447} + +-- Adlernest_roof_b4 + elseif map == "adlernest_roof_b4" then + c.spawns[1] = {name = "Tank", state = PROTECT_ALLIES, pos = {3476, -1037, -95}, radius2 = 800} + c.spawns[2] = {name = "CP Spawn", state = NO_PROTECT} + c.spawns[3] = {name = "Axis1", state = PROTECT_AXIS, pos = {-1949, -725, 72}, radius2 = 334} + c.spawns[4] = {name = "Axis2", state = PROTECT_AXIS, pos = {-1925, -50, 72}, radius2 = 334} + c.spawns[5] = {name = "Axis3", state = PROTECT_AXIS, pos = {-978, -445, 72}, radius2 = 334} + c.spawns[6] = {name = "Axis4", state = PROTECT_AXIS, pos = {-1464, -596, 72}, radius2 = 334} + c.spawns[7] = {name = "Axis5", state = PROTECT_AXIS, pos = {-1241, -212, 72}, radius2 = 334} + c.spawns[8] = {name = "Axis6", state = PROTECT_AXIS, pos = {-1597, -184, 100}, radius2 = 447} + c.spawns[9] = {name = "Allies Roof1", state = PROTECT_ALLIES, pos = {520, -2522, 546}, radius2 = 650} + c.spawns[10] = {name = "Allies Roof2", state = PROTECT_ALLIES, pos = {-29, -2296, 296}, radius2 = 200} + c.spawns[11] = {name = "Axis Roof1", state = PROTECT_AXIS, pos = {-1543, 264, 72}, radius2 = 293} + c.spawns[12] = {name = "Axis Roof2", state = PROTECT_AXIS, pos = {-1543, 567, 72}, radius2 = 365} + c.spawns[13] = {name = "Axis Roof3", state = PROTECT_AXIS, pos = {-1277, -386, 296}, radius2 = 400} + c.spawns[14] = {name = "Axis Roof4", state = PROTECT_AXIS, pos = {-1701, -149, 296}, radius2 = 200} + + elseif map =="et_operation_b3" then + c.spawns[1] = {name = "Axis Main Spawn", state = PROTECT_AXIS, pos = {2307, -3920, 80}, radius2 = 400} + c.spawns[2] = {name = "Axis Garage Spawns", state = PROTECT_AXIS, pos = {3075, -3874, -195}, radius2 = 400} + c.spawns[3] = {name = "Allied North Hut", state = PROTECT_ALLIES, pos = {6787, -2102, 80}, radius2 = 260} + c.spawns[4] = {name = "Allied South Hut", state = PROTECT_ALLIES, pos = {6621, -2710, 80}, radius2 = 230} + c.spawns[5] = {name = "Allied South Hut2", state = PROTECT_ALLIES, pos = {6600, -2778, 80}, radius2 = 200} + + +-- Braundorf B4 16.11.2008 + elseif map == "braundorf_b4" or map == "braundorf_final" then + c.spawns[1] = {name = "Factory District", state = NO_PROTECT, pos = {3505, -2355, 320}, radius2 = 375} + c.spawns[9] = {name = "Factory District", state = NO_PROTECT, pos = {3405, -2355, 320}, radius2 = 375} + c.spawns[2] = {name = "Bunker Back", state = PROTECT_AXIS, pos = {2849, 1919, 74}, radius2 = 250} + c.spawns[5] = {name = "Bunker Middle Back", state = PROTECT_AXIS, pos = {2687, 1562, 24}, radius2 = 190} + c.spawns[6] = {name = "Bunker Front", state = PROTECT_AXIS, pos = {2687, 383, 24}, radius2 = 170} + c.spawns[7] = {name = "Bunker Middle Front", state = PROTECT_AXIS, pos = {2687, 741, 24}, radius2 = 180} + c.spawns[8] = {name = "Bunker Middle", state = PROTECT_AXIS, pos = {2693, 1140, 24}, radius2 = 202} + c.spawns[3] = {state = PROTECT_ALLIES, radius2 = 540}--Allied Spawn + c.spawns[4] = {state = NO_PROTECT} --Command Post Spawn + c.actions[1] = {spawn = 1, newstate = PROTECT_ALLIES, trigger = "Allies permanently capture the factory district!"} + c.actions[2] = {spawn = 9, newstate = PROTECT_ALLIES, trigger = "Allies permanently capture the factory district!"} +-- Karsiah TE2 + elseif map == "karsiah_te2" then + c.spawns[1] = {name = "Backyard", state = PROTECT_AXIS, pos = {-1152, -263, 73}, radius2 = 395} + c.spawns[4] = {name = "Backyard", state = PROTECT_AXIS, pos = {-1050, -263, 73}, radius2 = 395} + c.spawns[5] = {name = "Backyard", state = PROTECT_AXIS, pos = {-1240, -263, 73}, radius2 = 470} + c.spawns[2] = {name = "Allied Hideout", state = PROTECT_ALLIES, pos = {4165, 430, 152}, radius2 = 335} + c.spawns[3] = {name = "Old City", state = NO_PROTECT, pos = {1304, -1430, 290}, radius2 = 400} + c.actions[1] = {spawn = 3, newstate = PROTECT_ALLIES, trigger = "captured the Old City"} +-- SW Siwa Oasias B3 16.11.2008 + elseif map == "sw_oasis_b3" then + c.spawns[1] = {name = "Axis Garrison", state = PROTECT_AXIS, pos = {7420, 4610, -391}, radius2 = 550} + c.spawns[2] = {name = "Old City", state = NO_PROTECT, pos = {4300, 7000, -450}, radius2 = 870} + c.spawns[3] = {name = "Axis Upper Garrison", state = NO_PROTECT} + c.spawns[4] = {name = "Allied Camp Base", state = PROTECT_ALLIES, pos = {1250, 2760, -400}, radius2 = 1140} + c.spawns[5] = {name = "Allied Camp Water Pump", state = NO_PROTECT, pos = {2584, 2144, -592}, radius2 = 1000} + c.spawns[6] = {name = "Axis Garrison Above", state = PROTECT_AXIS, pos = {7378, 4090, -199}, radius2 = 190} + c.spawns[7] = {name = "Axis Garrison Above2", state = PROTECT_AXIS, pos = {7151, 4289, -143}, radius2 = 230} + c.spawns[8] = {name = "Axis Garrison Above3", state = PROTECT_AXIS, pos = {7050, 4815, -143}, radius2 = 200} + c.actions[1] = {spawn = 2, newstate = PROTECT_ALLIES, trigger = "breached the Old City wall"} + c.actions[2] = {spawn = 4, newstate = NO_PROTECT, trigger = "Allies have built the Oasis Water"} + c.actions[3] = {spawn = 5, newstate = PROTECT_ALLIES, trigger = "Allies have built the Oasis Water"} + c.actions[4] = {spawn = 4, newstate = PROTECT_ALLIES, trigger = "Axis have damaged the Oasis Water"} + c.actions[5] = {spawn = 5, newstate = NO_PROTECT, trigger = "Axis have damaged the Oasis Water"} +-- Goldrush 25.11.2008 +-- Goldrush 05.10.2018 - disabled Allied spawnroof protection when truck with gold is near truck barrier #2 + elseif map == "goldrush" or map == "sw_goldrush_te" or map == "uje_goldrush" or map == "goldrush-gals" then + c.spawns[1] = {name = "Tank Depot Main Exit", state = PROTECT_AXIS, pos = {-79, 3005, 320}, radius2 = 250} + c.spawns[4] = {name = "Tank Depot Alternate Exit", state = PROTECT_AXIS, pos = {-664, 3541, 386}, radius2 = 420} + c.spawns[5] = {name = "Tank Depot Room", state = PROTECT_AXIS, pos = {-48, 3649, 344}, radius2 = 550} + c.spawns[13] = {name = "Tank Depot Room Exit", state = PROTECT_AXIS, pos = {110, 3100, 320}, radius2 = 370} + c.spawns[6] = {name = "Tank Depot", state = NO_PROTECT, pos = {-354, 2552, 344}, radius2 = 525} + c.spawns[7] = {name = "Tank Depot", state = NO_PROTECT, pos = {-354, 2052, 344}, radius2 = 525} + c.spawns[8] = {name = "Tank Depot", state = NO_PROTECT, pos = {-354, 1552, 344}, radius2 = 250} + c.spawns[2] = {name = "Axis", state = PROTECT_AXIS, pos = {3000, -822, -435}, radius2 = 600} + c.spawns[9] = {name = "Axis", state = PROTECT_AXIS, pos = {3010, -1555, -435}, radius2 = 250} + c.spawns[10] = {name = "Axis Lower Spawn", state = PROTECT_AXIS, pos = {3000, -822, -435}, radius2 = 600} + c.spawns[11] = {name = "Axis Lower Spawn", state = PROTECT_AXIS, pos = {3010, -1555, -435}, radius2 = 250} + c.spawns[12] = {name = "Axis", state = PROTECT_AXIS, pos = {2327, -868, -199}, radius2 = 200} + c.spawns[3] = {name = "Allied Spawn", state = PROTECT_ALLIES, pos = {-3360, -218, -67}, radius2 = 720} + c.actions[1] = {spawn = 1, newstate = PROTECT_ALLIES, trigger = "Allied team has stolen the Tank"} + c.actions[2] = {spawn = 4, newstate = PROTECT_ALLIES, trigger = "Allied team has stolen the Tank"} + c.actions[3] = {spawn = 5, newstate = PROTECT_ALLIES, trigger = "Allied team has stolen the Tank"} + c.actions[4] = {spawn = 6, newstate = PROTECT_ALLIES, trigger = "Allied team has stolen the Tank"} + c.actions[5] = {spawn = 7, newstate = PROTECT_ALLIES, trigger = "Allied team has stolen the Tank"} + c.actions[6] = {spawn = 8, newstate = PROTECT_ALLIES, trigger = "Allied team has stolen the Tank"} + c.actions[7] = {spawn = 3, newstate = NO_PROTECT, trigger = "spawnroof protection disabled"} + c.actions[8] = {spawn = 13, newstate = PROTECT_ALLIES, trigger = "Allied team has stolen the Tank"} + +-- Dubrovnik + elseif map == "dubrovnik_final" then + c.spawns[1] = {name = "Convent Up", state = PROTECT_AXIS, pos = {60, 727, 252}, radius2 = 221} + c.spawns[3] = {name = "Convent Up", state = PROTECT_AXIS, pos = {-611, 727, 228}, radius2 = 221} + c.spawns[4] = {name = "Convent Down", state = PROTECT_AXIS, pos = {60, 727, 40}, radius2 = 221} + c.spawns[5] = {name = "Convent Down", state = PROTECT_AXIS, pos = {-611, 727, 40}, radius2 = 221} + c.spawns[6] = {name = "Convent Yard", state = PROTECT_AXIS, pos = {-12, 1655, 40}, radius2 = 601} + c.spawns[2] = {name = "East Courtyard", state = PROTECT_ALLIES, pos = {1015, -2146, 40}, radius2 = 300} + c.spawns[7] = {name = "East Courtyard", state = PROTECT_ALLIES, pos = {1338, -2334, 40}, radius2 = 450} + c.spawns[8] = {name = "East Courtyard", state = PROTECT_ALLIES, pos = {1933, -2477, 40}, radius2 = 590} +-- Frostbite + elseif map == "frostbite" then + c.spawns[1] = {name = "Allied Barracks", state = PROTECT_ALLIES, pos = {-4698, -233, -201}, radius2 = 550} + c.spawns[2] = {name = "Axis Barracks", state = PROTECT_AXIS, pos = {-134, 1331, 280}, radius2 = 450} + c.spawns[3] = {name = "Axis Garage", state = PROTECT_AXIS, pos = {-847, 1440, 24}, radius2 = 440} + c.spawns[4] = {state = NO_PROTECT} -- Upper Complex (Command Post) + c.spawns[5] = {state = NO_PROTECT} --Axis Spawn (Documents) + c.actions[1] = {spawn = 3, newstate = NO_PROTECT, trigger = "Allies have transmitted the Supply Documents"} + +-- ETL Frostbite + elseif map == "etl_frostbite" then + c.spawns[1] = {name = "Allied Barracks", state = PROTECT_ALLIES, pos = {-4698, -233, -201}, radius2 = 550} + c.spawns[2] = {name = "Axis Barracks", state = PROTECT_AXIS, pos = {-140, 1286, 280}, radius2 = 400} + c.spawns[3] = {name = "Axis Garage", state = PROTECT_AXIS, pos = {-847, 1440, 24}, radius2 = 440} + c.spawns[4] = {state = NO_PROTECT} -- Upper Complex (Command Post) + c.spawns[5] = {state = NO_PROTECT} --Axis Spawn (Documents) + c.actions[1] = {spawn = 3, newstate = NO_PROTECT, trigger = "Allies have transmitted the Supply Documents"} + +-- ETL Bergen V3 23.10.2018 + elseif map == "etl_bergen_v3" then + c.spawns[1] = {state = NO_PROTECT} -- Forward Bunker (Flag) + c.spawns[2] = {name = "Axis Spawn", state = PROTECT_AXIS, pos = {6687, -1149, 216}, radius2 = 270} + c.spawns[3] = {name = "Allied Spawn", state = PROTECT_ALLIES, pos = {-1231, -2358, 89}, radius2 = 220} + c.spawns[4] = {name = "Axis Spawn 2", state = PROTECT_AXIS, pos = {6783, -684, 216}, radius2 = 236} + +-- Northpole 2018-12-11 + elseif map == "northpole" then + c.spawns[1] = {name = "Axis Spawn", state = PROTECT_AXIS, pos = {-3216, -2753, 827}, radius2 = 900} + c.spawns[2] = {name = "Town Spawn", state = PROTECT_ALLIES, pos = {2172, -998, 824}, radius2 = 250} + c.spawns[3] = {name = "Town Spawn", state = PROTECT_ALLIES, pos = {2002, -515, 824}, radius2 = 150} + c.spawns[4] = {name = "Town Spawn", state = PROTECT_ALLIES, pos = {2357, -473, 824}, radius2 = 200} + c.spawns[5] = {name = "Town Spawn outside", state = PROTECT_ALLIES, pos = {2697, -431, 827}, radius2 = 150} + c.spawns[6] = {name = "Town Spawn 2nd floor", state = PROTECT_ALLIES, pos = {2296, -653, 1016}, radius2 = 225} + +-- Bremen B2 16.11.2008 + elseif map == "bremen_b2" or map == "bremen_b3" or map == "fa_bremen_b3" or map == "fa_bremen_final" then + c.spawns[1] = {name = "Allied first spawn", state = PROTECT_ALLIES, pos = {-1957, -2222, 88}, radius2 = 440} + c.spawns[6] = {name = "Allied first spawn*", state = PROTECT_ALLIES, pos = {-2264, -1512, 88}, radius2 = 406} + c.spawns[2] = {state = NO_PROTECT} -- Axis Flag Spawn + c.spawns[3] = {name = "Allied Flag", state = NO_PROTECT, pos = {-2517, 1315, 88}, radius2 = 286} + c.spawns[4] = {name = "Axis Rear I", state = PROTECT_AXIS, pos = {727, -608, 88}, radius2 = 660} + c.spawns[7] = {name = "Axis Rear II", state = PROTECT_AXIS, pos = {287, 233, 88}, radius2 = 250} + c.spawns[5] = {state = NO_PROTECT} -- Command Post + c.actions[1] = {spawn = 3, newstate = PROTECT_ALLIES, trigger = "main gate has been destroyed"} + c.actions[2] = {spawn = 3, newstate = NO_PROTECT, trigger = "Truck has been repaired"} +-- Venice + elseif map == "venice" then + c.spawns[1] = {name = "Allies", state = PROTECT_ALLIES, pos = {-4067, -1001, -103}, radius2 = 850} + c.spawns[2] = {name = "Outpost", state = PROTECT_AXIS, pos = {517, 1286, -135}, radius2 = 381} --Axis/Allies + c.spawns[3] = {name = "Axis", state = PROTECT_AXIS, pos = {4859, 1708, -199}, radius2 = 500} + c.actions[1] = {spawn = 2, newstate = PROTECT_ALLIES, trigger = "captured the Outpost"} +-- Venice TC RC2 + elseif map == "venice_tcrc2_v1" then + c.spawns[1] = {name = "Allied", state = PROTECT_ALLIES, pos = {-2464, -1202, -213}, radius2 = 483} + c.spawns[2] = {name = "Outpost", state = PROTECT_AXIS, pos = {517, 1286, -135}, radius2 = 381} --Axis/Allies + c.spawns[3] = {name = "Axis Spawn North", state = PROTECT_AXIS, pos = {4859, 1708, -199}, radius2 = 500} + c.spawns[4] = {name = "Axis Spawn South", state = PROTECT_AXIS, pos = {2544, -2784, -215}, radius2 = 800} + c.actions[1] = {spawn = 2, newstate = PROTECT_ALLIES, trigger = "captured the Outpost"} +-- Reactor + elseif map == "reactor_final" then + c.spawns[1] = {name = "Forward Bunker", state = NO_PROTECT, pos = {96, -551, 280}, radius2 = 430} + c.spawns[2] = {name = "Head Quarters", state = PROTECT_AXIS, pos = {-283, 1415, 216}, radius2 = 320} --Axis + c.spawns[6] = {name = "Head Quarters", state = PROTECT_AXIS, pos = {292, 1341, 280}, radius2 = 278} --Axis + c.spawns[3] = {name = "Caves", state = PROTECT_ALLIES, pos = {1668, -3100, 616}, radius2 = 240} + c.spawns[4] = {name = "Caves", state = PROTECT_ALLIES, pos = {1150, -3128, 456}, radius2 = 200} + c.actions[1] = {spawn = 1, newstate = PROTECT_ALLIES, trigger = "secured the forward bunker"} +-- Supply 16.11.2008 + elseif map == "supply" then + c.spawns[1] = {name = "Allied start", state = PROTECT_ALLIES, pos = {-2050, 131, 0}, radius2 = 540} + c.spawns[3] = {name = "Forward", state = NO_PROTECT, pos = {-283, 2391, 264}, radius2 = 220} + c.spawns[4] = {state = NO_PROTECT} --Command Post Spawn + c.spawns[2] = {name = "Axis Depot", state = PROTECT_AXIS, pos = {650, -1810, -135}, radius2 = 330} + c.spawns[7] = {name = "Axis Depot Stairs", state = PROTECT_AXIS, pos = {719, -1487, -31}, radius2 = 150} + c.spawns[5] = {name = "Axis Depot Back Exit", state = PROTECT_AXIS, pos = {771, -2629, -47}, radius2 = 260} + c.spawns[6] = {name = "Axis Depot Tunnel", state = PROTECT_AXIS, pos = {890, -2270, -147}, radius2 = 260} + c.actions[1] = {spawn = 3, newstate = PROTECT_ALLIES, trigger = "breached the Forward Bunker"} + elseif map == "etl_supply" then + c.spawns[1] = {name = "Allied start", state = PROTECT_ALLIES, pos = {-2050, 131, 0}, radius2 = 540} + c.spawns[3] = {name = "Forward", state = NO_PROTECT, pos = {-283, 2391, 264}, radius2 = 220} + c.spawns[4] = {state = NO_PROTECT} --Command Post Spawn + c.spawns[2] = {name = "Axis Depot", state = PROTECT_AXIS, pos = {650, -1810, -135}, radius2 = 330} + c.spawns[7] = {name = "Axis Depot Stairs", state = PROTECT_AXIS, pos = {719, -1487, -31}, radius2 = 150} + c.spawns[5] = {name = "Axis Depot Back Exit", state = PROTECT_AXIS, pos = {771, -2629, -47}, radius2 = 260} + c.spawns[6] = {name = "Axis Depot Tunnel", state = PROTECT_AXIS, pos = {890, -2270, -147}, radius2 = 260} + c.actions[1] = {spawn = 3, newstate = PROTECT_ALLIES, trigger = "breached the Forward Bunker"} +-- Supply Pro 23.10.2018 + elseif map == "supply_pro" then + c.spawns[1] = {name = "Farmhouse", state = PROTECT_ALLIES, pos = {-2175, -210, 24}, radius2 = 221} + c.spawns[5] = {name = "Farmhouse Exit", state = PROTECT_ALLIES, pos = {-2175, 140, 24}, radius2 = 221} + c.spawns[3] = {name = "Forward Bunker Spawn", state = NO_PROTECT, pos = {-271, 2367, 264}, radius2 = 170} + c.spawns[4] = {state = NO_PROTECT} --Command Post Spawn + c.spawns[2] = {name = "Axis Depot Spawn", state = PROTECT_AXIS, pos = {650, -1789, -165}, radius2 = 210} + c.spawns[8] = {name = "Axis Depot Stairs", state = PROTECT_AXIS, pos = {719, -1487, -31}, radius2 = 150} + c.spawns[6] = {name = "Axis Depot Spawn Back Exit", state = PROTECT_AXIS, pos = {771, -2629, -47}, radius2 = 220} + c.spawns[7] = {name = "Axis Depot Spawn Tunnel", state = PROTECT_AXIS, pos = {890, -2270, -147}, radius2 = 260} + c.actions[1] = {spawn = 3, newstate = PROTECT_ALLIES, trigger = "breached the Forward Bunker"} + + +-- missile_b3 + elseif map == "missile_b3" then + c.spawns[1] = {name = "Gate Control Spawn", state = PROTECT_AXIS, pos = {3750, -4823, 80}, radius2 = 400} + c.spawns[3] = {name = "Bunker Spawn", state = PROTECT_ALLIES, radius2 = 700} + c.spawns[5] = {name = "Rocket Hall Spawn", state = PROTECT_AXIS, radius2 = 600} + c.spawns[6] = {name = "Rocket Gate Spawn", state = NO_PROTECT, radius2 = 450} + c.actions[1] = {spawn = 1, newstate = NO_PROTECT, trigger = "Magnetic seal deactivated"} + --c.actions[2] = {spawn = 6, newstate = PROTECT_ALLIES, trigger = "Allies have activated the Gate Controls"} + elseif map == "missile_b4" then + c.spawns[1] = {name = "Gate Control Spawn", state = PROTECT_AXIS, pos = {4119, -4408, 353}, radius2 = 500} + c.spawns[3] = {name = "Bunker Spawn", state = PROTECT_ALLIES, radius2 = 700} + c.spawns[5] = {name = "Rocket Hall Spawn", state = PROTECT_AXIS, radius2 = 560} + c.spawns[6] = {name = "Rocket Gate Spawn", state = NO_PROTECT, radius2 = 450} + c.actions[1] = {spawn = 1, newstate = NO_PROTECT, trigger = "Magnetic seal deactivated"} + --c.actions[2] = {spawn = 6, newstate = PROTECT_ALLIES, trigger = "Allies have activated the Gate Controls"} + + + elseif map == "transmitter" then + c.spawns[3] = {name = "Allied Base", state = PROTECT_ALLIES, radius2 = 1000} + c.spawns[2] = {name = "Castle", state = PROTECT_AXIS, radius2 = 400} +-- 1944_beach + elseif map == "1944_beach" then + c.spawns[1] = {name = "Axis Spawn", state = PROTECT_AXIS, pos = {3254, -4882, 5384}, radius2 = 500} + c.spawns[2] = {name = "Forward Spawn", state = NO_PROTECT} + c.spawns[3] = {name = "Allies Spawn", state = PROTECT_ALLIES, pos = {310, 1984, 4512}, radius2 = 180} + c.spawns[4] = {name = "Allies Spawn", state = PROTECT_ALLIES, pos = {310, 1884, 4512}, radius2 = 200} + c.spawns[5] = {name = "Allies Spawn", state = PROTECT_ALLIES, pos = {310, 1684, 4512}, radius2 = 200} + c.spawns[6] = {name = "Allies Spawn", state = PROTECT_ALLIES, pos = {310, 1584, 4512}, radius2 = 200} + c.spawns[7] = {name = "Allies Spawn", state = PROTECT_ALLIES, pos = {333, 1457, 4512}, radius2 = 200} + c.spawns[8] = {name = "Allies Spawn", state = PROTECT_ALLIES, pos = {328, 1211, 4512}, radius2 = 300} + c.spawns[9] = {name = "Transmitter Spawn", state = NO_PROTECT} + c.spawns[10] = {name = "Allies Spawn 2", state = PROTECT_ALLIES, pos = {-2193, 1014, 4472}, radius2 = 100} + c.spawns[11] = {name = "Allies Spawn 2", state = PROTECT_ALLIES, pos = {-2202, 689, 4512}, radius2 = 200} + c.spawns[12] = {name = "Allies Spawn 2", state = PROTECT_ALLIES, pos = {-2197, 513, 4512}, radius2 = 200} + c.spawns[13] = {name = "Allies Spawn 2", state = PROTECT_ALLIES, pos = {-2209, 193, 4516}, radius2 = 300} + +-- decay_b7 + elseif map == "decay_b7" then + c.spawns[1] = {name = "Forward Flag", state = NO_PROTECT, pos = {-415, 800, 348}, radius2 = 290} + c.spawns[2] = {name = "Axis Garrison", state = PROTECT_AXIS, pos = {2956, 3997, 319}, radius2 = 500} + c.spawns[3] = {name = "Side Entrance", state = NO_PROTECT} + c.spawns[4] = {name = "Allied Camp", state = PROTECT_ALLIES, pos = {3590, -19, 64}, radius2 = 700} + c.spawns[5] = {name = "Allied Camp", state = PROTECT_ALLIES, pos = {3722, -709, 64}, radius2 = 700} + c.spawns[6] = {name = "Allied Camp", state = PROTECT_ALLIES, pos = {3613, 562, 64}, radius2 = 800} + c.spawns[7] = {name = "Locker Room", state = NO_PROTECT, pos = {-383, 2282, 327}, radius2 = 240} + c.actions[1] = {spawn = 1, newstate = PROTECT_ALLIES, trigger = "Allies have permanently secured the"} + c.actions[2] = {spawn = 7, newstate = PROTECT_ALLIES, trigger = "The Allies have destroyed the generator, the vault"} +-- library_b3 + elseif map == "library_b3" then + c.spawns[1] = {name = "Allied First Spawn", state = PROTECT_ALLIES, pos = {-2202, -3267, -15}, radius2 = 500} + c.spawns[2] = {name = "Axis Spawn", state = PROTECT_AXIS, pos = {-582, 3303, -115}, radius2 = 400} + c.spawns[3] = {name = "Library Office Spawn", state = PROTECT_AXIS, pos = {-96, 3971, -75}, radius2 = 260} + +-- ET Ice + elseif map == "et_ice" then + c.spawns[1] = {name = "Axis North Barracks", state = PROTECT_AXIS, radius2 = 360} + c.spawns[2] = {name = "Axis South Barracks", state = PROTECT_AXIS, radius2 = 360} + c.spawns[3] = {name = "Allies North Barracks", state = PROTECT_ALLIES} + c.spawns[4] = {name = "Allies South Barracks", state = PROTECT_ALLIES} --Transmitter +-- Heart of Gold + elseif map == "hog_b12_dt" then + c.spawns[2] = {state = NO_PROTECT} --Gate + c.spawns[3] = {name = "Village", state = PROTECT_AXIS, radius1 = 150, radius2 = 440} + c.spawns[5] = {name = "Village", state = PROTECT_AXIS, pos = {-4, 703, 300}, radius2 = 220} + c.spawns[6] = {name = "Village", state = PROTECT_AXIS, pos = {610, 112, 350}, radius2 = 235} + c.spawns[1] = {name = "Garage", state = PROTECT_ALLIES, pos = {-4943, -77, 0}, radius2 = 780} + c.spawns[4] = {state = NO_PROTECT} --Command Post Spawn +-- ET Beach + elseif map == "et_beach" then + c.spawns[1] = {name = "Axis Side", state = PROTECT_AXIS, pos = {2541, 3217, 1176}, radius2 = 301} +-- c.spawns[1] = {name = "Axis Side", state = PROTECT_AXIS, pos = {2548, 3116, 1176}, radius2 = 360} + c.spawns[2] = {state = NO_PROTECT} -- Axis Side (unten) + c.spawns[3] = {name = "Forward Bunker", state = NO_PROTECT, pos = {1333, 3455, 680}, radius2 = 140} -- Forward Bunker + c.spawns[4] = {name = "Allied Side", state = PROTECT_ALLIES, pos = {-1872, 3504, 97}, radius2 = 600} + c.spawns[5] = {name = "Supply Bunker", state = NO_PROTECT} -- Command Post Spawn Supply Bunker + c.spawns[6] = {name = "Supply Bunker", state = NO_PROTECT} -- Bed Room Spawn + c.spawns[7] = {state = NO_PROTECT} -- Seawall Breach + c.spawns[8] = {name = "Allied Side", state = PROTECT_ALLIES, pos = {-1799, -2651, 296}, radius2 = 300} + c.actions[1] = {spawn = 3, newstate = PROTECT_ALLIES, trigger = "Allies secured the Forward Bunker"} +-- TC Base + elseif map == "tc_base" then + c.spawns[1] = {name = "Allies", state = PROTECT_ALLIES, radius2 = 850, radius2 = 1000} + c.spawns[2] = {name = "Axis", state = PROTECT_AXIS, pos = {3229, 2111, 100}, radius2 = 900} +-- SP Delivery TE 16.11.2008 + elseif map == "sp_delivery_te" then + c.spawns[1] = {name = "Forward Bunker", state = NO_PROTECT, radius2 = 350} -- flag + c.spawns[2] = {name = "The Offices", state = PROTECT_AXIS, radius2 = 850} --axis + c.spawns[3] = {name = "The Train Cars", state = PROTECT_ALLIES, radius2 = 1550} + c.actions[1] = {spawn = 1, newstate = PROTECT_ALLIES, trigger = "secured the forward bunker"} +-- Warbell + elseif map == "warbell" then + c.spawns[1] = {name = "Monastery", state = PROTECT_ALLIES, pos = {2370, -2058, 24}, radius2 = 165} + c.spawns[5] = {name = "Monastery", state = PROTECT_ALLIES, pos = {2623, -2005, 24}, radius2 = 185} + c.spawns[2] = {name = "Axis Start", state = PROTECT_AXIS, radius2 = 1000} --axis + c.spawns[3] = {name = "Command Post", state = NO_PROTECT} + c.spawns[4] = {name = "Guard House", state = NO_PROTECT, radius2 = 350} + c.actions[1] = {spawn = 4, newstate = PROTECT_AXIS, trigger = "secured the Guardhouse Flag"} +-- etl_warbell + elseif map == "etl_warbell" then + c.spawns[1] = {name = "Monastery", state = PROTECT_ALLIES, pos = {2370, -2058, 24}, radius2 = 380} + c.spawns[5] = {name = "Monastery", state = PROTECT_ALLIES, pos = {2623, -2005, 24}, radius2 = 185} + c.spawns[2] = {name = "Axis Spawn", state = PROTECT_AXIS, pos = {960, 2064, 416}, radius2 = 900} + c.spawns[3] = {name = "Command Post", state = NO_PROTECT} + c.spawns[4] = {name = "Guard House", state = NO_PROTECT, pos = {-2742, -148, 512}, radius2 = 350} + c.actions[1] = {spawn = 4, newstate = PROTECT_AXIS, trigger = "have destroyed the Guardhouse Gate"} +-- TroopTrain + elseif map == "trooptrain" then + c.spawns[1] = {state = NO_PROTECT} + c.spawns[2] = {state = NO_PROTECT} + c.spawns[3] = {state = NO_PROTECT} +-- vengeance_te_final + elseif map == "vengeance_te_final" then + c.spawns[6] = {name = "East Spawn", state = PROTECT_AXIS, radius2 = 280} --axis + c.spawns[3] = {name = "West Spawn", state = PROTECT_AXIS, radius2 = 240} --axis + c.spawns[2] = {name = "Allied Spawn", state = PROTECT_ALLIES, radius2 = 300} + c.spawns[1] = {name = "Forward Spawn", state = NO_PROTECT, pos = {973, -704, 128}, radius2 = 185} --Flag Spawn + c.spawns[7] = {name = "Forward Spawn", state = NO_PROTECT, pos = {1245, -704, 128}, radius2 = 185} --Flag Spawn + c.spawns[4] = {name = "Allied CP", state = NO_PROTECT} + c.spawns[5] = {name = "Axis CP", state = NO_PROTECT} + c.actions[1] = {spawn = 1, newstate = PROTECT_AXIS, trigger = "breached the bunker door"} + c.actions[2] = {spawn = 7, newstate = PROTECT_AXIS, trigger = "breached the bunker door"} +-- apennines_b2 + elseif map == "apennines_b2" then + c.spawns[1] = {name = "Desert Cabin", state = NO_PROTECT} + c.spawns[2] = {name = "Research Complex", state = NO_PROTECT} + c.spawns[3] = {name = "Garage Spawn", state = NO_PROTECT} +-- italyfp2 + elseif map == "italyfp2" then + c.spawns[3] = {name = "Axis Spawn", pos = {1018, 3096, 98}, state = PROTECT_AXIS, radius2 = 350} --axis + c.spawns[6] = {name = "Allied CP Spawn", pos = {-1050, -2125, -290}, state = PROTECT_ALLIES, radius2 = 440} +-- italyfp2 + elseif map == "italyfp2" then + c.spawns[3] = {name = "Axis Spawn", pos = {1018, 3096, 98}, state = PROTECT_AXIS, radius2 = 350} --axis + c.spawns[6] = {name = "Allied CP Spawn", pos = {-1050, -2125, -290}, state = PROTECT_ALLIES, radius2 = 440} + +-- v2base_te 17.06.2019 + elseif map == "v2base_te" then + c.spawns[1] = {name = "Axis Spawn", pos = {-2467, 1427, -215}, state = PROTECT_AXIS, radius2 = 295} --axis + c.spawns[2] = {name = "Allies Spawn", pos = {-2047, -1995, 92}, state = PROTECT_ALLIES, radius2 = 200} --allies + c.spawns[3] = {state = NO_PROTECT} + c.spawns[4] = {name = "Allies Spawn", pos = {-2047, -1771, 92}, state = PROTECT_ALLIES, radius2 = 200} --allies + +-- sos_secret_weapon + elseif map == "sos_secret_weapon" then + c.spawns[1] = {state = "Allies Spawn", pos = {2270, -2214, 68}, state = PROTECT_ALLIES, radius2 = 600} + c.spawns[2] = {state = NO_PROTECT} + c.spawns[3] = {state = "Axis Spawn", pos = {-1847, 2307, 68}, state = PROTECT_AXIS, radius2 = 500} + +-- pirates + elseif map == "pirates" then + c.spawns[1] = {state = "Old City", state = NO_PROTECT} + c.spawns[2] = {state = "Seaport", state = PROTECT_AXIS, radius2 = 450} + c.spawns[3] = {name = "Beach Spawn", state = PROTECT_ALLIES, radius2 = 430} + c.spawns[4] = {name = "Courtyard", state = NO_PROTECT} + +-- eagles_2ways_b3 + elseif map == "eagles_2ways_b3" then + c.spawns[1] = {state = "Axis 2", pos = {-4363, -2043, 2208}, state = PROTECT_AXIS, radius2 = 500} + c.spawns[2] = {state = "Allied 3", state = NO_PROTECT, pos = {-3506, -2322, 1776}, radius2 = 450} + c.actions[1] = {spawn = 2, newstate = PROTECT_ALLIES, trigger = "Allied 3"} + +-- marketgarden_et_r2 + elseif map == "marketgarden_et_r2" then + c.spawns[1] = {state = "The Bridge", state = NO_PROTECT} + c.spawns[2] = {state = "Command Center", state = NO_PROTECT} + c.spawns[3] = {state = "Banner Room", pos = {-5068, 712, 1112}, state = PROTECT_ALLIES, radius2 = 400} + c.spawns[4] = {state = "South Arch", pos = {2137, -2488, 1104}, state = PROTECT_AXIS, radius2 = 400} + +-- falkenstein_b3 + elseif map == "falkenstein_b3" then + c.spawns[1] = {state = "Station Spawns", pos = {3217, -1241, 112}, state = PROTECT_AXIS, radius2 = 400} + c.spawns[2] = {state = "Base Spawns", pos = {7476, -3911, 352}, state = PROTECT_AXIS, radius2 = 400} + c.spawns[3] = {state = "Allied Spawn One", pos = {2263, -4409, 833}, state = PROTECT_ALLIES, radius2 = 600} + c.actions[1] = {spawn = 1, newstate = PROTECT_ALLIES, trigger = "Allies gained access to the base"} + +-- goldendunk_a2 + elseif map == "goldendunk_a2" then + c.spawns[1] = {name = "Axis Spawn1", pos = {-2370, 750, 60}, state = PROTECT_AXIS, radius2 = 250} + c.spawns[2] = {name = "Axis Spawn2", pos = {-2370, -750, 60}, state = PROTECT_AXIS, radius2 = 250} + c.spawns[3] = {name = "Allied Spawn1", pos = {2370, 750, 60}, state = PROTECT_ALLIES, radius2 = 250} + c.spawns[4] = {name = "Allied Spawn2", pos = {2370, -750, 60}, state = PROTECT_ALLIES, radius2 = 250} + + + else hasconfig = false + end + return c +end + + +-------------------------------------------------------------------------------- +-- called when client types a command like "/command" on console +function et_ClientCommand(cno, command) +-------------------------------------------------------------------------------- +-- commands: +-- etwsk : prints mod info and current spawnkill statistics +-- etwsk_spawns : prints list of spawnpoints with current state +-- etwsk_pos : prints current position and distances to protected spawns +-------------------------------------------------------------------------------- + local cmd = string.lower(command) + if cmd == "etwsk_spawns" then + printSpawns(cno) + return 1 + elseif cmd == "etwsk_pos" then + printPos(cno) + return 1 + elseif cmd == "etwsk" then + printStats(cno) + return 1 + elseif cmd == "team" and sinbin and sinbinhash[cno] then -- spam... + if sinbinhash[cno] > et.trap_Milliseconds() then + local team = et.Info_ValueForKey( et.trap_GetConfigstring(et.CS_PLAYERS + cno), "t" ) + local penalty_left = math.ceil( ( sinbinhash[cno] - et.trap_Milliseconds() ) / 1000 ) + et.trap_SendServerCommand( cno, + sinbin_pos .. " \"^3ATTENTION: ^7You may not join a team for another ^1"..penalty_left.." ^7seconds^1!\"\n") + return 1 + else + sinbinhash[cno] = nil --reset + return 0 + end + return 1 + end + return 0 +end + + +-------------------------------------------------------------------------------- +-- calculates the distance +-- note: not true distance as hight is doubled. So the body defined by constant +-- distance is not a sphere, but an ellipsoid +function calcDist(pos1, pos2) +-------------------------------------------------------------------------------- + local dist2 = (pos1[1]-pos2[1])^2 + (pos1[2]-pos2[2])^2 + + ((pos1[3]-pos2[3])*2)^2 + return math.sqrt(dist2) +end + +-------------------------------------------------------------------------------- +-- called at map start +function et_InitGame( levelTime, randomSeed, restart) +-------------------------------------------------------------------------------- + local modname = string.format("%s v%s", module_name, module_version) + et.G_Print(string.format("%s loaded\n", modname)) + et.RegisterModname(modname) + + mapname = et.trap_Cvar_Get("mapname") + c = getConfig(mapname) + + damagegiven = {} + spawnkills = {} + + local checkpoints = {} + -- find capturable flag poles + for i = 64, 1021 do + if et.gentity_get(i, "classname") == "team_WOLF_checkpoint" then + table.insert(checkpoints,i) + end + end + -- complete config with default extracted values + local spawn = 1 + for i = 64, 1021 do + if et.gentity_get(i, "classname") == "team_WOLF_objective" then + local pos = et.gentity_get(i, "origin"); + if c.spawns[spawn] == nil then + c.spawns[spawn] = {} end + if c.spawns[spawn].name == nil then + c.spawns[spawn].name = et.gentity_get(i, "message") end + if c.spawns[spawn].pos == nil then + c.spawns[spawn].pos = et.gentity_get(i, "origin") end + if c.spawns[spawn].state == nil then + local iscapturable = false + for k,v in pairs(checkpoints) do + local cp = et.gentity_get(v, "origin") + if(calcDist(c.spawns[spawn].pos, cp) <= + maxcheckpointdist) then + iscapturable = true + end + end + if iscapturable then + c.spawns[spawn].state = NO_PROTECT + else + c.spawns[spawn].state = et.G_GetSpawnVar(i, "spawnflags") + end + end + if c.spawns[spawn].radius1 == nil then + c.spawns[spawn].radius1 = ETWsk_defaultradius1 end + if c.spawns[spawn].radius2 == nil then + c.spawns[spawn].radius2 = ETWsk_defaultradius2 end + spawn = spawn + 1 + end + end + -- auto complete spawns + for i,spawn in pairs(c.spawns) do + if spawn.radius1 == nil then + spawn.radius1 = ETWsk_defaultradius1 end + if spawn.radius2 == nil then + spawn.radius2 = ETWsk_defaultradius2 end + end + + readPO(ETWsk_pofile) +end + +-------------------------------------------------------------------------------- +-- called when something is printed on server console +function et_Print(text) +-------------------------------------------------------------------------------- + if(c == nil) then return end + for i,action in pairs(c.actions) do + if(string.find(text, action.trigger)) then + local msg + if action.newstate == NO_PROTECT then + msg = "is no longer protected!" + else msg = "is now protected!" + end + c.spawns[action.spawn].state = action.newstate + et.trap_SendServerCommand(-1, "chat \"^3ATTENTION: ^1The ".. + c.spawns[action.spawn].name.." "..msg.."\n\"") +-- et.trap_SendServerCommand(-1, "chat \"^3ATTENTION: ^1The ^4".. +-- c.spawns[action.spawn].name.." Spawn ^2"..msg.."\n\"") + + end + end +end + +-------------------------------------------------------------------------------- +-- called when client enters the game +function et_ClientBegin(cno) +-------------------------------------------------------------------------------- + -- reset spawnkills + spawnkills[cno] = nil +end + +-------------------------------------------------------------------------------- +-- called when client spawns +function et_ClientSpawn(cno, revived ) +-------------------------------------------------------------------------------- + if (hasconfig and revived == 0) then + damagegiven[cno] = et.gentity_get(cno, "sess.damage_given") + if(damagegiven[cno] == nil) then damagegiven[cno] = 0 end + end +end + +-------------------------------------------------------------------------------- +function et_ClientDisconnect( cno ) +-------------------------------------------------------------------------------- + if sinbinhash[cno] then + sinbinhash[cno] = nil -- reset + end +end + +-------------------------------------------------------------------------------- +function printSpawns(cno) +-------------------------------------------------------------------------------- + if not hasconfig then + et.trap_SendServerCommand(cno, + "print \"^3ATTENTION:^7 no config for this map!\n\"") + if ETWsk_savemode == 1 then + et.trap_SendServerCommand(cno, + "print \"^3ATTENTION: ^7 protection deactivated (savemode)!\n\"") + end + end + local protect = {} + protect[0] = "NO_PROTECT" + protect[1] = "^1PROTECT_AXIS" + protect[2] = "^4PROTECT_ALLIES" + if cno >= 0 then + et.trap_SendServerCommand(cno,"chat \"^3ATTENTION:^7 Mapname: ^3"..mapname.."\n\"") + end + for i,spawn in pairs(c.spawns) do + if cno == -1 then et.G_Print(string.format("ETWsk> Spawn %d \"%s\" %s \n", i, spawn.name, protect[spawn.state])) + else et.trap_SendServerCommand(cno, "chat \"^3ATTENTION:^7 Spawn ^3"..i.."^7 "..spawn.name.." "..protect[spawn.state].."\n\"") + end + end +end + +-------------------------------------------------------------------------------- +function printPos(cno) +-------------------------------------------------------------------------------- + local pos = et.gentity_get(cno, "r.currentOrigin") + local spos = string.format('%.2f, %.2f, %.2f', + table.unpack(pos)) + et.trap_SendServerCommand(cno, + "print \"^3ATTENTION:^7 current pos: "..spos.."\n\"") + local team = et.gentity_get(cno, "sess.sessionTeam") + local protect_normal = "^2protected_normal" + local protect_heavy = "^2protected_heavy_only" + for i,spawn in pairs(c.spawns) do + local protect = "^1not protected" + if spawn.state == team then + local dist = calcDist(pos, spawn.pos) + if dist < spawn.radius1 then + protect = protect_normal + elseif dist < spawn.radius2 then + protect = protect_heavy + end + et.trap_SendServerCommand(cno, string.format( + "print \"^3ATTENTION:^7 spawn ^3%d (%s): %s ^7distance: %.2f \n\"", + i, spawn.name, protect, dist)) + end + end +end + +-------------------------------------------------------------------------------- +function printStats(cno) +-------------------------------------------------------------------------------- + et.trap_SendServerCommand(cno, "print \"^3ATTENTION: ^7v"..module_version .. + " spawnkill protection by ^2[^4ETW^2-^4FZ^2] ^4Mad^2@^4Mat^7.\n\"") + for killer,kills in pairs(spawnkills) do + local killername = + et.Info_ValueForKey(et.trap_GetUserinfo(killer), "name") + et.trap_SendServerCommand(cno, + "print \" "..kills.." SKs: "..killername.."\n\"") + end +end + +-------------------------------------------------------------------------------- +-- called when someone has been killed +function et_Obituary(victim, killer, meansOfDeath) +-------------------------------------------------------------------------------- + -- same team + -- et.trap_SendServerCommand(-1, "print \"SK: "..victim.." "..killer.."\n\"") + -- warmup fix, n00b! benny + if tonumber(et.trap_Cvar_Get("gamestate")) ~= 0 then return end + + local vteam = et.gentity_get(victim, "sess.sessionTeam") + + -- IlDuca - fix: check if the killer is a real player or if it's something else... + if ( et.gentity_get( killer, "s.number" ) < tonumber( et.trap_Cvar_Get( "sv_maxClients" )) ) then + if( vteam == et.gentity_get(killer, "sess.sessionTeam")) then + return + end + else + return + end + + -- protection expired ? + if ETWsk_expires == 1 then + local vdg = 0 + vdg = et.gentity_get(victim, "sess.damage_given") + -- et.G_Printf("vdg = %d, dg = %d\n", vdg, damagegiven[victim]) + if(vdg ~= nil and vdg > damagegiven[victim]) then return end + end + -- was heavyweapon? + local isheavy = false + for k,v in pairs(heavyweapons) do + if (meansOfDeath == v) then isheavy = true end + if mapname == "goldrush" or mapname == "goldrush-gals" then -- don't punish tank mg + if (meansOfDeath == 3) then isheavy = false end + end + end + -- protected spawn? + local vpos = et.gentity_get(victim, "r.currentOrigin") + local isprotected = false + local dist2 + local radius2 + for i,spawn in pairs(c.spawns) do + if spawn.state == vteam then + if(isheavy) then + radius2 = spawn.radius2 + else + radius2 = spawn.radius1 + end + dist = calcDist(vpos, spawn.pos) + if(dist < radius2) then + ClientSpawnkill(victim, killer, isheavy) + end + end + end +end + +-------------------------------------------------------------------------------- +-- called when ETWsk has detected a spawnkill +function ClientSpawnkill(victim, killer, isheavy) +-------------------------------------------------------------------------------- + if killer < 0 or (ETWsk_savemode == 1 and not hasconfig) then return end + + local killername = et.Info_ValueForKey(et.trap_GetUserinfo(killer), "name") + + if spawnkills[killer] == nil then spawnkills[killer] = 0 end + + spawnkills[killer] = spawnkills[killer] + 1 + local numsk = spawnkills[killer] + + -- he has been kicked before + if numsk >= ETWsk_POThreshold then + local kicksb4 = isPO(killer) + + if kicksb4 > 0 then + et.trap_SendServerCommand(-1, "chat \"^3ATTENTION: ^7"..killername.." ^3has been temp banned - repeated spawn killing!\"\n") + spawnkills[killer] = nil + addPO (killer) + savePO(ETWsk_pofile) + et.trap_DropClient(killer, "temp ban - "..kicksb4.." former kicks for spawn killing!", (ETWsk_banval * (2^kicksb4))) + et.G_LogPrint("LUA event: temp SK ban for " .. killername .. " - ".. kicksb4 .. " former kicks for spawn killing\n") + et.G_globalSound("sound/misc/duke_crapouttahere.wav") + return + end + end + + --et.trap_SendServerCommand(-1, "chat \"^3ATTENTION: ^1WARNING: ^2Spawn kill (#"..numsk..") by ^7"..killername.."\"\n" ) + --et.trap_SendServerCommand(killer, "cp \""..killername.." : ^1DO NOT SPAWN KILL!!! \"\n") + + if(numsk >= ETWsk_putspec and numsk < ETWsk_kick) then + et.trap_SendConsoleCommand( et.EXEC_APPEND, "ref remove " .. killer .. "\n" ) + sinbinhash[killer] = et.trap_Milliseconds() + sinbin_duration + et.trap_SendServerCommand(-1, "chat \"^3ATTENTION: ^7"..killername.." ^3was set to Spectators - too many Spawnkills!\"\n") + et.trap_SendServerCommand( killer, "cpm \"^3ATTENTION: ^1WARNING: ^3You were set to Spectator\"\n") + et.G_LogPrint("LUA event: " .. killername .. " sent to spectators for spawnkilling (" .. numsk .. " SK)\n") + et.G_globalSound("sound/misc/referee.wav") + first_sk = et.trap_Milliseconds() + elseif(numsk >= ETWsk_kick) then + if tonumber(et.gentity_get(killer, "pers.connected")) == 2 then + local kteam = et.gentity_get(killer, "sess.sessionTeam") + if kteam ~= 3 then + if et.trap_Milliseconds() - first_sk > 30000 then + et.trap_SendServerCommand(-1, "chat \"^3ATTENTION: ^7"..killername.." ^3has been kicked - too many spawnkills!\"\n") + addPO(killer) + savePO(ETWsk_pofile) + et.trap_DropClient(killer, "kicked for too many spawnkills!", ETWsk_kicklen) + et.G_LogPrint("LUA event: temp spawnkill ban for " .. killername .. " (" .. numsk .. " SK)\n") + et.G_globalSound("sound/misc/duke_crapouttahere.wav") + end + end + end + else + et.gentity_set(killer, "health", -511) + end + +end + +-------------------------------------------------------------------------------- + +-------------------------------------------------------------------------------- +-- persistent offenders stuff +function isPO (cno) + local guid = string.lower(et.Info_ValueForKey(et.trap_GetUserinfo(cno), "cl_guid")) + if pohash[guid] then + return pohash[guid] + end + return 0 +end + +function addPO (cno) -- unreliable shit + local guid = string.lower(et.Info_ValueForKey(et.trap_GetUserinfo(cno), "cl_guid")) + if string.find(guid, "[^%x]") or string.len(guid) ~= 32 then return end + if pohash[guid] then + pohash[guid] = pohash[guid] + 1 + else + pohash[guid] = 1 + end +end + +function readPO (file) + local fd,len = et.trap_FS_FOpenFile( file, et.FS_READ ) + local count = 0 + if len > -1 then + local filestr = et.trap_FS_Read(fd, len) + for guid, kicks in string.gmatch(filestr,"[^%#](%x+)%s(%d+)%;") do + if not string.find(guid, "[^%x]") and string.len(guid) == 32 then + pohash[string.lower(guid)] = tonumber(kicks) + count = count + 1 + end + end + filestr = nil + et.trap_FS_FCloseFile(fd) + else + et.G_LogPrint("ETWsk failed to open " .. file .. "\n") + return + end + et.G_LogPrint("ETWsk loaded "..count.." persistent spawn killers.\n") +end + +function savePO (file) + local count = 0 + local fd, len = et.trap_FS_FOpenFile(file, et.FS_WRITE) + if len == -1 then + et.G_LogPrint("ETWsk failed to open " .. file .. "\n") + return(0) + end + local head = string.format( + "# %s, written %s\n# to reload this file do a 'etwskread' via rcon/screen!\n", + file, os.date() + ) + et.trap_FS_Write(head, string.len(head), fd) + for guid, kicks in pairs(pohash) do + local line = guid.." "..kicks..";\n" + et.trap_FS_Write(line, string.len(line), fd) + count = count + 1 + end + et.trap_FS_FCloseFile(fd) + et.G_LogPrint("ETWsk saved "..count.." persistent spawn killers.\n") +end +-------------------------------------------------------------------------------- + + +-------------------------------------------------------------------------------- +-- et_ShutdownGame +function et_ShutdownGame( restart ) +-------------------------------------------------------------------------------- + savePO(ETWsk_pofile) +end + + + +-------------------------------------------------------------------------------- +-- et_ConsoleCommand +function et_ConsoleCommand() +-------------------------------------------------------------------------------- + if et.trap_Argv(0) == "etwskread" then + pohash = {} + readPO(ETWsk_pofile) + return 1 + end + return 0 +end diff --git a/endstats.lua b/endstats.lua new file mode 100644 index 0000000..edd1c34 --- /dev/null +++ b/endstats.lua @@ -0,0 +1,1274 @@ +-- endstats.lua by x0rnn, shows some interesting game statistics at the end of a round (most kill assists, most kill steals, most headshot kills, highest light weapon acc, highest hs acc, most dynamites planted, most pistol kills, kill/death stats vs. all opponents, etc.) + +killing_sprees = {} +death_sprees = {} +kmulti = {} +kendofmap = false +eomap_done = false +eomaptime = 0 +gamestate = -1 +topshots = {} +mkps = {} +weaponstats = {} +endplayers = {} +endplayerscnt = 0 +tblcount = 0 +vsstats = {} +vsstats_kills = {} +vsstats_deaths = {} +kills = {} +deaths = {} +worst_enemy = {} +easiest_prey = {} +vsstats = {} +vsstats_kills = {} +vsstats_deaths = {} +hitters = {} +light_weapons = {1,2,3,5,6,7,8,9,10,11,12,13,14,17,37,38,44,45,46,50,51,53,54,55,56,61,62,66} +explosives = {15,16,18,19,20,22,23,26,39,40,41,42,52,63,64} +HR_HEAD = 0 +HR_ARMS = 1 +HR_BODY = 2 +HR_LEGS = 3 +HR_NONE = -1 +HR_TYPES = {HR_HEAD, HR_ARMS, HR_BODY, HR_LEGS} +hitRegionsData = {} +death_time = {} +death_time_total = {} +players = {} +ltm2 = 0 +redspawn = 0 +bluespawn = 0 +redspawn2 = 0 +bluespawn2 = 0 +spawns = {} +redflag = false +blueflag = false +redlimbo1 = 0 +bluelimbo1 = 0 +redlimbo2 = 0 +bluelimbo2 = 0 +changedred = false +changedblue = false +paused = false + +topshot_names = { [1]="Most damage given", [2]="Most damage received", [3]="Most team damage given", [4]="Most team damage received", [5]="Most teamkills", [6]="Most selfkills", [7]="Most deaths", [8]="Most kills per minute", [9]="Quickest multikill w/ light weapons", [11]="Farthest riflenade kill", [12]="Most light weapon kills", [13]="Most pistol kills", [14]="Most rifle kills", [15]="Most riflenade kills", [16]="Most sniper kills", [17]="Most knife kills", [18]="Most air support kills", [19]="Most mine kills", [20]="Most grenade kills", [21]="Most panzer kills", [22]="Most mortar kills", [23]="Most panzer deaths", [24]="Mortarmagnet", [25]="Most multikills", [26]="Most MG42 kills", [27]="Most MG42 deaths", [28]="Most revives", [29]="Most revived", [30]="Best K/D ratio", [31]="Most dynamites planted", [32]="Most dynamites defused", [33]="Most doublekills", [34]="Longest killing spree", [35]="Longest death spree", [36]="Most objectives stolen", [37]="Most objectives returned", [38]="Most corpse gibs", [39]="Most kill assists", [40]="Most killsteals", [41]="Most headshot kills", [42]="Most damage per minute", [43]="Tank/Meatshield (Refuses to die)", [44]="Most useful kills (>Half respawn time left)", [45]="Full respawn king", [46]="Least time dead (What spawn?)"} + +function et_InitGame(levelTime, randomSeed, restart) + + et.RegisterModname("endstats.lua "..et.FindSelf()) + sv_maxclients = tonumber(et.trap_Cvar_Get("sv_maxclients")) + + local i = 0 + for i=0, sv_maxclients-1 do + killing_sprees[i] = 0 + death_sprees[i] = 0 + kmulti[i] = { [1]=0, [2]=0, } + topshots[i] = { [1]=0, [2]=0, [3]=0, [4]=0, [5]=0, [6]=0, [7]=0, [8]=0, [9]=0, [10]=0, [11]=0, [12]=0, [13]=0, [14]=0, [15]=0, [16]=0, [17]=0, [18]=0, [19]=0, [20]=0, [21]=0, [22]=0, [23]=0, [24]=0, [25]=0, [26]=0, [27]=0, [28]=0, [29]=0, [30]=0, [31]=0, [32]=0, [33]=0, [34]=0} + vsstats[i]={[0]=0,[1]=0,[2]=0,[3]=0,[4]=0,[5]=0,[6]=0,[7]=0,[8]=0,[9]=0,[10]=0,[11]=0,[12]=0,[13]=0,[14]=0,[15]=0,[16]=0,[17]=0,[18]=0,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,[50]=0,[51]=0,[52]=0,[53]=0,[54]=0,[55]=0,[56]=0,[57]=0,[58]=0,[59]=0,[60]=0,[61]=0,[62]=0,[63]=0} + vsstats_kills[i]={[0]=0,[1]=0,[2]=0,[3]=0,[4]=0,[5]=0,[6]=0,[7]=0,[8]=0,[9]=0,[10]=0,[11]=0,[12]=0,[13]=0,[14]=0,[15]=0,[16]=0,[17]=0,[18]=0,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,[50]=0,[51]=0,[52]=0,[53]=0,[54]=0,[55]=0,[56]=0,[57]=0,[58]=0,[59]=0,[60]=0,[61]=0,[62]=0,[63]=0} + vsstats_deaths[i]={[0]=0,[1]=0,[2]=0,[3]=0,[4]=0,[5]=0,[6]=0,[7]=0,[8]=0,[9]=0,[10]=0,[11]=0,[12]=0,[13]=0,[14]=0,[15]=0,[16]=0,[17]=0,[18]=0,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,[50]=0,[51]=0,[52]=0,[53]=0,[54]=0,[55]=0,[56]=0,[57]=0,[58]=0,[59]=0,[60]=0,[61]=0,[62]=0,[63]=0} + worst_enemy[i]={[0]=0,[1]=0,[2]=0,[3]=0,[4]=0,[5]=0,[6]=0,[7]=0,[8]=0,[9]=0,[10]=0,[11]=0,[12]=0,[13]=0,[14]=0,[15]=0,[16]=0,[17]=0,[18]=0,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,[50]=0,[51]=0,[52]=0,[53]=0,[54]=0,[55]=0,[56]=0,[57]=0,[58]=0,[59]=0,[60]=0,[61]=0,[62]=0,[63]=0} + easiest_prey[i]={[0]=0,[1]=0,[2]=0,[3]=0,[4]=0,[5]=0,[6]=0,[7]=0,[8]=0,[9]=0,[10]=0,[11]=0,[12]=0,[13]=0,[14]=0,[15]=0,[16]=0,[17]=0,[18]=0,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,[50]=0,[51]=0,[52]=0,[53]=0,[54]=0,[55]=0,[56]=0,[57]=0,[58]=0,[59]=0,[60]=0,[61]=0,[62]=0,[63]=0} + mkps[i] = { [1]=0, [2]=0, [3]=0 } + kills[i] = 0 + deaths[i] = 0 + hitters[i] = {nil, nil, nil, nil} + death_time[i] = 0 + death_time_total[i] = 0 + players[i] = nil + spawns[i] = nil + end +end + +local function roundNum(num, n) + local mult = 10^(n or 0) + return math.floor(num * mult + 0.5) / mult +end + +function getKeysSortedByValue(tbl, sortFunction) + local keys = {} + for key in pairs(tbl) do + table.insert(keys, key) + end + + table.sort(keys, function(a, b) + return sortFunction(tbl[a], tbl[b]) + end) + + return keys +end + +function has_value (tab, val) + for index, value in ipairs(tab) do + if value == val then + return true + end + end + return false +end + +function getAllHitRegions(clientNum) + local regions = {} + for index, hitType in ipairs(HR_TYPES) do + regions[hitType] = et.gentity_get(clientNum, "pers.playerStats.hitRegions", hitType) + end + return regions +end + +function hitType(clientNum) + local playerHitRegions = getAllHitRegions(clientNum) + if hitRegionsData[clientNum] == nil then + hitRegionsData[clientNum] = playerHitRegions + return 2 + end + for index, hitType in ipairs(HR_TYPES) do + if playerHitRegions[hitType] > hitRegionsData[clientNum][hitType] then + hitRegionsData[clientNum] = playerHitRegions + return hitType + end + end + hitRegionsData[clientNum] = playerHitRegions + return -1 +end + +function et_Damage(target, attacker, damage, damageFlags, meansOfDeath) + if gamestate == 0 then + if target ~= attacker and attacker ~= 1022 and attacker ~= 1023 and not (tonumber(target) < 0) and not (tonumber(target) > sv_maxclients-1) then + if has_value(light_weapons, meansOfDeath) or has_value(explosives, meansOfDeath) then + local v_team = et.gentity_get(target, "sess.sessionTeam") + local k_team = et.gentity_get(attacker, "sess.sessionTeam") + local v_health = et.gentity_get(target, "health") + local hitType = hitType(attacker) + if hitType == HR_HEAD then + if not has_value(explosives, meansOfDeath) then + hitters[target][et.trap_Milliseconds()] = {[1]=attacker, [2]=damage, [3]=meansOfDeath} + if v_team ~= k_team then + if damage >= v_health then + topshots[attacker][31] = topshots[attacker][31] + 1 + end + end + end + else + hitters[target][et.trap_Milliseconds()] = {[1]=attacker, [2]=damage, [3]=meansOfDeath} + end + end + end + end +end + +function topshots_f(id) + local max = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 0, 100} + local max_id = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} + local i = 0 + for i=0, sv_maxclients-1 do + local team = tonumber(et.gentity_get(i, "sess.sessionTeam")) + if team == 1 or team == 2 then + local dg = tonumber(et.gentity_get(i, "sess.damage_given")) + local dr = tonumber(et.gentity_get(i, "sess.damage_received")) + local tdg = tonumber(et.gentity_get(i, "sess.team_damage")) + local tdr = tonumber(et.gentity_get(i, "sess.team_received")) + local tk = tonumber(et.gentity_get(i, "sess.team_kills")) + local sk = tonumber(et.gentity_get(i, "sess.self_kills")) + local d = tonumber(et.gentity_get(i, "sess.deaths")) + local k = tonumber(et.gentity_get(i, "sess.kills")) + local gibs = tonumber(et.gentity_get(i, "sess.gibs")) + local kd = 0 + local kr = 0 + local timeplayed = tonumber(et.gentity_get(i, "sess.time_axis")) + tonumber(et.gentity_get(i, "sess.time_allies")) + if death_time[i] ~= 0 then + local diff = et.trap_Milliseconds() - death_time[i] + death_time_total[i] = death_time_total[i] + diff + end + + if d ~= 0 then + kd = k/d + else + kd = k + 1 + end + + -- damage given + if dg > max[1] then + max[1] = dg + max_id[1] = i + end + -- damage received + if dr > max[2] then + max[2] = dr + max_id[2] = i + end + -- team damage given + if tdg > max[3] then + max[3] = tdg + max_id[3] = i + end + -- team damage received + if tdr > max[4] then + max[4] = tdr + max_id[4] = i + end + -- teamkills + if tk > max[5] then + max[5] = tk + max_id[5] = i + end + -- selfkills + if sk > max[6] then + max[6] = sk + max_id[6] = i + end + -- deaths + if d > max[7] then + max[7] = d + max_id[7] = i + end + -- kills per minute + if k > 10 then + local kpm = 0 + kpm = k/((timeplayed/1000)/60) + if kpm > max[8] then + max[8] = kpm + max_id[8] = i + end + end + -- quickest lightweapon multikill + if topshots[i][14] >= max[9] then + if topshots[i][14] > max[9] then + max[9] = topshots[i][14] + max[10] = topshots[i][15] + max_id[9] = i + max_id[10] = i + elseif topshots[i][14] == max[9] then + if topshots[i][15] < max[10] then + max[9] = topshots[i][14] + max[10] = topshots[i][15] + max_id[9] = i + max_id[10] = i + end + end + end + -- farthest riflegrenade kill + if topshots[i][16] > max[11] then + max[11] = topshots[i][16] + max_id[11] = i + end + -- lightweapon kills + if topshots[i][1] > max[12] then + max[12] = topshots[i][1] + max_id[12] = i + end + -- pistol kills + if topshots[i][2] > max[13] then + max[13] = topshots[i][2] + max_id[13] = i + end + -- rifle kills + if topshots[i][3] > max[14] then + max[14] = topshots[i][3] + max_id[14] = i + end + -- riflegrenade kills + if topshots[i][4] > max[15] then + max[15] = topshots[i][4] + max_id[15] = i + end + -- sniper kills + if topshots[i][5] > max[16] then + max[16] = topshots[i][5] + max_id[16] = i + end + -- knife kills + if topshots[i][6] > max[17] then + max[17] = topshots[i][6] + max_id[17] = i + end + -- air support kills + if topshots[i][7] > max[18] then + max[18] = topshots[i][7] + max_id[18] = i + end + -- mine kills + if topshots[i][8] > max[19] then + max[19] = topshots[i][8] + max_id[19] = i + end + -- grenade kills + if topshots[i][9] > max[20] then + max[20] = topshots[i][9] + max_id[20] = i + end + -- panzerfaust kills + if topshots[i][10] > max[21] then + max[21] = topshots[i][10] + max_id[21] = i + end + -- mortar kills + if topshots[i][11] > max[22] then + max[22] = topshots[i][11] + max_id[22] = i + end + -- panzerfaust deaths + if topshots[i][12] > max[23] then + max[23] = topshots[i][12] + max_id[23] = i + end + -- mortar deaths + if topshots[i][13] > max[24] then + max[24] = topshots[i][13] + max_id[24] = i + end + -- multikills + if topshots[i][17] > max[25] then + max[25] = topshots[i][17] + max_id[25] = i + end + -- mg42 kills + if topshots[i][18] > max[26] then + max[26] = topshots[i][18] + max_id[26] = i + end + -- mg42 deaths + if topshots[i][19] > max[27] then + max[27] = topshots[i][19] + max_id[27] = i + end + -- most revives + if topshots[i][20] > max[28] then + max[28] = topshots[i][20] + max_id[28] = i + end + -- most revived + if topshots[i][21] > max[29] then + max[29] = topshots[i][21] + max_id[29] = i + end + -- k/d ratio + if k > 9 then + if kd > max[30] then + max[30] = kd + max_id[30] = i + end + end + -- most dynamites planted + if topshots[i][22] > max[31] then + max[31] = topshots[i][22] + max_id[31] = i + end + -- most dynamites defused + if topshots[i][23] > max[32] then + max[32] = topshots[i][23] + max_id[32] = i + end + -- most doublekills + local dk = topshots[i][24] - topshots[i][17] + if dk > max[33] then + max[33] = dk + max_id[33] = i + end + --longest kill spree + if topshots[i][25] > max[34] then + max[34] = topshots[i][25] + max_id[34] = i + end + --longest death spree + if topshots[i][26] > max[35] then + max[35] = topshots[i][26] + max_id[35] = i + end + --most objectives stolen + if topshots[i][27] > max[36] then + max[36] = topshots[i][27] + max_id[36] = i + end + --most objectives returned + if topshots[i][28] > max[37] then + max[37] = topshots[i][28] + max_id[37] = i + end + -- most gibs + if gibs > max[38] then + max[38] = gibs + max_id[38] = i + end + --most kill assists + if topshots[i][29] > max[39] then + max[39] = topshots[i][29] + max_id[39] = i + end + --most killsteals + if topshots[i][30] > max[40] then + max[40] = topshots[i][30] + max_id[40] = i + end + --most headshot kills + if topshots[i][31] > max[41] then + max[41] = topshots[i][31] + max_id[41] = i + end + --damage per minute + if dg > 1400 then + local dpm = 0 + dpm = dg/((timeplayed/1000)/60) + if dpm > max[42] then + max[42] = dpm + max_id[42] = i + end + end + --tank (damage received/deaths) + if dr > 2000 then + local drdr = 0 + if d ~= 0 then + drdr = (dr / d) / 130 + else + drdr = (dr + 1) / 130 + end + if drdr > 3 then + max[43] = drdr + max_id[43] = i + end + end + --most useful kills + if topshots[i][34] > max[44] then + max[44] = topshots[i][34] + max_id[44] = i + end + --most time dead + if timeplayed > 600000 or timeplayed == et.trap_Cvar_Get("timelimit") then + if (death_time_total[i] / timeplayed) * 100 > max[45] then + max[45] = (death_time_total[i] / timeplayed) * 100 + max_id[45] = i + max[47] = death_time_total[i] + end + end + -- least time dead + if timeplayed > 600000 or timeplayed == et.trap_Cvar_Get("timelimit") then + if (death_time_total[i] / timeplayed) * 100 < max[46] then + max[46] = (death_time_total[i] / timeplayed) * 100 + max_id[46] = i + max[48] = death_time_total[i] + end + end + end + end + if id == -2 then + local ws_max = { 0, 0, 0, 0 } + local ws_max_id = { 0, 0, 0, 0} + local cnt = 0 + for cnt=0, sv_maxclients-1 do + if endplayers[cnt] then + -- highest light weapons accuracy + if weaponstats[cnt][2] > 100 then + if (weaponstats[cnt][1]/weaponstats[cnt][2])*100 > ws_max[1] then + ws_max[1] = (weaponstats[cnt][1]/weaponstats[cnt][2])*100 + ws_max_id[1] = cnt + end + end + -- highest headshot accuracy + if weaponstats[cnt][1] > 10 and weaponstats[cnt][2] > 100 then + if (weaponstats[cnt][3]/weaponstats[cnt][1])*100 > ws_max[2] then + ws_max[2] = (weaponstats[cnt][3]/weaponstats[cnt][1])*100 + ws_max_id[2] = cnt + end + end + -- most headshots + if weaponstats[cnt][3] > ws_max[3] then + ws_max[3] = weaponstats[cnt][3] + ws_max_id[3] = cnt + end + -- most bullets fired + if weaponstats[cnt][2] > ws_max[4] then + ws_max[4] = weaponstats[cnt][2] + ws_max_id[4] = cnt + end + end + end + local j = 1 + local plyrs = {} + for j=1, 46 do + if max[j] > 1 and (j ~= 46 or (j == 46 and max[j] ~= 100)) then + if j ~= 10 and j ~= 25 and j ~= 33 and j~= 42 then + if j == 1 then + --topshot_sayClients("^z" .. topshot_names[j] .. ": " .. et.gentity_get(max_id[j], "pers.netname") .. " ^z- ^1" .. max[j] .. "\"\n") + table.insert(plyrs, { + topshot_names[j], + et.gentity_get(max_id[j], "pers.netname"), + max[j] + }) + if max[42] > 1 then + --topshot_sayClients("^z" .. topshot_names[42] .. ": " .. et.gentity_get(max_id[42], "pers.netname") .. " ^z- ^1" .. max[42] .. "\"\n") + table.insert(plyrs, { + topshot_names[42], + et.gentity_get(max_id[42], "pers.netname"), + max[42] + }) + end + elseif j == 8 then + --et.trap_SendServerCommand(-1, "chat \"^z" .. topshot_names[j] .. ": " .. et.gentity_get(max_id[j], "pers.netname") .. " ^z- ^1" .. roundNum(max[j], 2) .. "\"\n") + table.insert(plyrs, { + topshot_names[j], + et.gentity_get(max_id[j], "pers.netname"), + roundNum(max[j], 2) + }) + elseif j == 9 then + -- dirty "fix" instead of reordering all indexes lol + if max[33] > 1 then + --et.trap_SendServerCommand(-1, "chat \"^z" .. topshot_names[33] .. ": " .. et.gentity_get(max_id[33], "pers.netname") .. " ^z- ^1" .. max[33] .. "\"\n") + table.insert(plyrs, { + topshot_names[33], + et.gentity_get(max_id[33], "pers.netname"), + max[33] + }) + end + --et.trap_SendServerCommand(-1, "chat \"^z" .. topshot_names[25] .. ": " .. et.gentity_get(max_id[25], "pers.netname") .. " ^z- ^1" .. max[25] .. "\"\n") + --et.trap_SendServerCommand(-1, "chat \"^z" .. topshot_names[j] .. ": " .. et.gentity_get(max_id[j], "pers.netname") .. " ^z- ^1" .. max[j] .. " ^zkills in ^1" .. roundNum(max[10]/1000, 3) .. " ^zseconds\"\n") + table.insert(plyrs, { + topshot_names[25], + et.gentity_get(max_id[25], "pers.netname"), + max[25] + }) + table.insert(plyrs, { + topshot_names[j], + et.gentity_get(max_id[j], "pers.netname"), + max[j] .. " ^7kills in " .. roundNum(max[10]/1000, 2) .. "s" + }) + elseif j == 11 then + --et.trap_SendServerCommand(-1, "chat \"^z" .. topshot_names[j] .. ": " .. et.gentity_get(max_id[j], "pers.netname") .. " ^z- ^1" .. roundNum(max[j], 2) .. " ^zm\"\n") + table.insert(plyrs, { + topshot_names[j], + et.gentity_get(max_id[j], "pers.netname"), + roundNum(max[j], 2) .. " ^7m" + }) + elseif j == 43 then + --et.trap_SendServerCommand(-1, "chat \"^z" .. topshot_names[j] .. ": " .. et.gentity_get(max_id[j], "pers.netname") .. " ^z- ^1" .. roundNum(max[j], 2) .. " ^zpercent\"\n") + table.insert(plyrs, { + topshot_names[j], + et.gentity_get(max_id[j], "pers.netname"), + "^7Damage received vs death ratio: " .. roundNum(max[j], 2) .. "^7x" + }) + elseif j == 45 or j == 46 then + --et.trap_SendServerCommand(-1, "chat \"^z" .. topshot_names[j] .. ": " .. et.gentity_get(max_id[j], "pers.netname") .. " ^z- ^1" .. roundNum(max[j], 2) .. " ^zpercent, ^1" .. roundNum((max[j+2] / 60000), 2) .. " ^zmin\"\n") + table.insert(plyrs, { + topshot_names[j], + et.gentity_get(max_id[j], "pers.netname"), + roundNum(max[j], 2) .. " ^7percent, " .. roundNum((max[j+2] / 60000), 2) .. " ^7min" + }) + else + --et.trap_SendServerCommand(-1, "chat \"^z" .. topshot_names[j] .. ": " .. et.gentity_get(max_id[j], "pers.netname") .. " ^z- ^1" .. max[j] .. "\"\n") + table.insert(plyrs, { + topshot_names[j], + et.gentity_get(max_id[j], "pers.netname"), + max[j] + }) + end + end + end + end + local z = 1 + for z = 1, 4 do + if ws_max[z] > 1 then + if z == 1 then + --et.trap_SendServerCommand(-1, "chat \"^zHighest light weapons accuracy: " .. et.gentity_get(ws_max_id[z], "pers.netname") .. " ^z- ^1" .. roundNum(ws_max[z], 2) .. " ^zpercent\"\n") + table.insert(plyrs, { + "Highest light weapons accuracy", + et.gentity_get(ws_max_id[z], "pers.netname"), + roundNum(ws_max[z], 2) .. " percent" + }) + elseif z == 2 then + --et.trap_SendServerCommand(-1, "chat \"^zHighest headshot accuracy: " .. et.gentity_get(ws_max_id[z], "pers.netname") .. " ^z- ^1" .. roundNum(ws_max[z], 2) .. " ^zpercent\"\n") + table.insert(plyrs, { + "Highest headshot accuracy", + et.gentity_get(ws_max_id[z], "pers.netname"), + roundNum(ws_max[z], 2) .. " percent" + }) + elseif z == 3 then + --et.trap_SendServerCommand(-1, "chat \"^zMost headshots: " .. et.gentity_get(ws_max_id[z], "pers.netname") .. " ^z- ^1" .. ws_max[z] .. "\"\n") + table.insert(plyrs, { + "Most headshots", + et.gentity_get(ws_max_id[z], "pers.netname"), + ws_max[z] + }) + elseif z == 4 then + --et.trap_SendServerCommand(-1, "chat \"^zMost bullets fired: " .. et.gentity_get(ws_max_id[z], "pers.netname") .. " ^z- ^1" .. ws_max[z] .. "\"\n") + table.insert(plyrs, { + "Most bullets fired", + et.gentity_get(ws_max_id[z], "pers.netname"), + ws_max[z] + }) + end + end + end + send_table(-1, { + {name = "Award" }, + {name = "Player", align = "right"}, + {name = "Value", align = "right"}, + }, plyrs) + local p = 0 + for p=0, sv_maxclients-1 do + local t = tonumber(et.gentity_get(p, "sess.sessionTeam")) + if t == 1 or t == 2 then + et.trap_SendServerCommand(p, "cpm \"^zKills: ^1" .. kills[p] .. " ^z- Deaths: ^1" .. deaths[p] .. " ^z- Damage given: ^1" .. tonumber(et.gentity_get(p, "sess.damage_given")) .. "\"\n") + local top_we = {0, 0} + local top_ep = {0, 0} + local e = 0 + for e=0, sv_maxclients-1 do + if e ~= p then + local t2 = tonumber(et.gentity_get(e, "sess.sessionTeam")) + if t2 == 1 or t2 == 2 then + if t ~= t2 then + vsstats_f(p, e) + if worst_enemy[p][e] > top_we[1] then + top_we[1] = worst_enemy[p][e] + top_we[2] = e + end + if easiest_prey[p][e] > top_ep[1] then + top_ep[1] = easiest_prey[p][e] + top_ep[2] = e + end + end + end + end + end + local sortedKeys = getKeysSortedByValue(vsstats_kills[p], function(a, b) return a > b end) + local players2 = {} + for _, key in ipairs(sortedKeys) do + if not (vsstats_kills[p][key] == 0 and vsstats_deaths[p][key] == 0) then + local t3 = tonumber(et.gentity_get(key, "sess.sessionTeam")) + if t3 == 1 or t3 == 2 then + if t ~= t3 then + --et.trap_SendServerCommand(p, "chat \"" .. et.gentity_get(key, "pers.netname") .. "^7: ^3Kills: ^7" .. vsstats_kills[p][key] .. " ^3Deaths: ^7" .. vsstats_deaths[p][key] .. "\"") + table.insert(players2, { + et.gentity_get(key, "pers.netname"), + vsstats_kills[p][key], + vsstats_deaths[p][key] + }) + end + end + end + end + send_table(p, { + {name = "Player" }, + {name = "Kills", align = "right"}, + {name = "Deaths", align = "right"}, + }, players2) + + if top_ep[1] > 3 then + et.trap_SendServerCommand(p, "cpm \"^zEasiest prey: " .. et.gentity_get(top_ep[2], "pers.netname") .. "^z- Kills: ^1" .. top_ep[1] .. "\"\n") + end + if top_we[1] > 3 then + et.trap_SendServerCommand(p, "cpm \"^zWorst enemy: " .. et.gentity_get(top_we[2], "pers.netname") .. "^z- Deaths: ^1" .. top_we[1] .. "\"\n") + end + end + end + end +end + +function vsstats_f(id, id2) + local ratio = 0 + if vsstats[id2][id] == 0 then + ratio = vsstats[id][id2] + else + if vsstats[id][id2] == 0 then + ratio = -vsstats[id2][id] + else + ratio = roundNum(vsstats[id][id2]/vsstats[id2][id], 2) + end + end + if not (vsstats[id][id2] == 0 and vsstats[id2][id] == 0) then + vsstats_kills[id][id2] = vsstats[id][id2] + vsstats_deaths[id][id2] = vsstats[id2][id] + end +end + +function et_Print(text) + if gamestate == 0 then + if string.find(text, "Medic_Revive") then + local junk1,junk2,medic,zombie = string.find(text, "^Medic_Revive:%s+(%d+)%s+(%d+)") + topshots[tonumber(medic)][20] = topshots[tonumber(medic)][20] + 1 + topshots[tonumber(zombie)][21] = topshots[tonumber(zombie)][21] + 1 + end + if string.find(text, "Dynamite_Plant") then + local i, j = string.find(text, "%d+") + local id = tonumber(string.sub(text, i, j)) + topshots[id][22] = topshots[id][22] + 1 + end + if string.find(text, "Dynamite_Diffuse") then + local i, j = string.find(text, "%d+") + local id = tonumber(string.sub(text, i, j)) + topshots[id][23] = topshots[id][23] + 1 + end + if string.find(text, "team_CTF_redflag") or string.find(text, "team_CTF_blueflag") then + local i, j = string.find(text, "%d+") + local id = tonumber(string.sub(text, i, j)) + if string.find(text, "team_CTF_redflag") then + local team = tonumber(et.gentity_get(id, "sess.sessionTeam")) + if team == 2 then + topshots[id][27] = topshots[id][27] + 1 + elseif team == 1 then + topshots[id][28] = topshots[id][28] + 1 + end + elseif string.find(text, "team_CTF_blueflag") then + local team = tonumber(et.gentity_get(id, "sess.sessionTeam")) + if team == 1 then + topshots[id][27] = topshots[id][27] + 1 + elseif team == 2 then + topshots[id][28] = topshots[id][28] + 1 + end + end + end + end + + if kendofmap and string.find(text, "^WeaponStats: ") == 1 then + if endplayerscnt < tblcount then + for id in string.gmatch(text, "WeaponStats: ([%d]+)[^\n]+") do + if endplayers[tonumber(id)] then + if weaponstats[tonumber(id)] == nil then + endplayerscnt = endplayerscnt + 1 + local ws + local hits = 0 + local shots = 0 + local hs = 0 + for j = 2, 6 do + ws = et.gentity_get(tonumber(id), "sess.aWeaponStats", j) + hits = hits + ws[4] + shots = shots + ws[1] + hs = hs + ws[3] + if j == 6 then + ws = et.gentity_get(tonumber(id), "sess.aWeaponStats", 26) + hits = hits + ws[4] + shots = shots + ws[1] + hs = hs + ws[3] + end + end + weaponstats[tonumber(id)] = { [1]=hits, [2]=shots, [3]=hs } + end + end + end + if endplayerscnt == tblcount then + eomap_done = true + eomaptime = et.trap_Milliseconds() + 1000 + end + end + return(nil) + end + + if text == "Exit: Timelimit hit.\n" or text == "Exit: Wolf EndRound.\n" then + local x = 0 + for x=0,sv_maxclients-1 do + local team = tonumber(et.gentity_get(x, "sess.sessionTeam")) + if team == 1 or team == 2 then + endplayers[x] = true + end + end + for _ in pairs(endplayers) do + tblcount = tblcount + 1 + end + kendofmap = true + for i = 0, sv_maxclients-1 do + if killing_sprees[i] > 0 then + checkKSpreeEnd(i) + end + end + return(nil) + end +end + +function checkMultiKill (id, mod) + local lvltime = et.trap_Milliseconds() + if (lvltime - kmulti[id][1]) < 3000 then + kmulti[id][2] = kmulti[id][2] + 1 + if mod==6 or mod==7 or mod==8 or mod==9 or mod==10 or mod==12 or mod==45 or mod==53 or mod==54 or mod==55 or mod==56 or mod==66 then + mkps[id][1] = mkps[id][1] + 1 + if mkps[id][2] == 0 then + mkps[id][2] = lvltime + else + mkps[id][3] = et.trap_Milliseconds() + end + if mkps[id][1] >= 3 then + if mkps[id][1] >= topshots[id][14] then + if mkps[id][1] > topshots[id][14] then + topshots[id][14] = mkps[id][1] + topshots[id][15] = mkps[id][3] - mkps[id][2] + elseif mkps[id][1] == topshots[id][14] then + if (mkps[id][3] - mkps[id][2]) < topshots[id][15] then + topshots[id][15] = mkps[id][3] - mkps[id][2] + end + end + end + end + end + + if kmulti[id][2] == 2 then + topshots[id][24] = topshots[id][24] + 1 + elseif kmulti[id][2] == 3 then + topshots[id][17] = topshots[id][17] + 1 + elseif kmulti[id][2] == 6 then + topshots[id][17] = topshots[id][17] + 1 + end + else + kmulti[id][2] = 1 + mkps[id][1] = 1 + mkps[id][2] = 0 + mkps[id][3] = 0 + end + kmulti[id][1] = lvltime +end + +function dist(a, b) + ax, ay, az = a[1], a[2], a[3] + bx, by, bz = b[1], b[2], b[3] + dx = math.abs(bx - ax) + dy = math.abs(by - ay) + dz = math.abs(bz - az) + d = math.sqrt((dx ^ 2) + (dy ^ 2) + (dz ^ 2)) + return math.floor(d) / 39.37 +end + +function et_Obituary(victim, killer, mod) + if gamestate == 0 then + local v_teamid = et.gentity_get(victim, "sess.sessionTeam") + local k_teamid + if killer ~= 1022 and killer ~= 1023 then + k_teamid = et.gentity_get(killer, "sess.sessionTeam") + end + + if (victim == killer) then -- suicide + + if mod ~= 59 then + death_sprees[victim] = death_sprees[victim] + 1 + death_time[victim] = et.trap_Milliseconds() + end + checkKSpreeEnd(victim) + killing_sprees[victim] = 0 + + else + death_time[victim] = et.trap_Milliseconds() + if (v_teamid == k_teamid) then -- team kill + + checkKSpreeEnd(victim) + killing_sprees[victim] = 0 + --death_sprees[victim] = death_sprees[victim] + 1 + + else -- nomal kill + if killer ~= 1022 and killer ~= 1023 then -- no world / unknown kills + + killing_sprees[killer] = killing_sprees[killer] + 1 + vsstats[killer][victim] = vsstats[killer][victim] + 1 + kills[killer] = kills[killer] + 1 + deaths[victim] = deaths[victim] + 1 + worst_enemy[victim][killer] = worst_enemy[victim][killer] + 1 + easiest_prey[killer][victim] = easiest_prey[killer][victim] + 1 + local posk = et.gentity_get(killer, "ps.origin") + local posv = et.gentity_get(victim, "ps.origin") + local killdist = dist(posk, posv) + + if v_teamid == 1 then + if redspawn + redlimbo1 / 1000 - ltm2 >= (redlimbo1/1000)/2 and redspawn + redlimbo1 / 1000 - ltm2 > 0 then + topshots[killer][34] = topshots[killer][34] + 1 + end + elseif v_teamid == 2 then + if bluespawn + bluelimbo1 / 1000 - ltm2 >= (bluelimbo1/1000)/2 and bluespawn + bluelimbo1 / 1000 - ltm2 > 0 then + topshots[killer][34] = topshots[killer][34] + 1 + end + end + + checkMultiKill(killer, mod) + checkKSpreeEnd(victim) + checkDSpreeEnd(killer) + + -- most lightweapons kills + if mod==6 or mod==7 or mod==8 or mod==9 or mod==10 or mod==12 or mod==45 or mod==53 or mod==54 or mod==55 or mod==56 or mod==66 then + -- most pistol kills + if mod==6 or mod==7 or mod==12 or mod==45 or mod==53 or mod==54 or mod==55 or mod==56 then + topshots[killer][2] = topshots[killer][2] + 1 + end + topshots[killer][1] = topshots[killer][1] + 1 + end + -- most rifle kills + if mod == 11 or mod == 50 or mod == 37 or mod == 38 then + topshots[killer][3] = topshots[killer][3] + 1 + end + -- most riflegrenade kills + farthest riflegrenade kill + if mod == 39 or mod == 40 then + topshots[killer][4] = topshots[killer][4] + 1 + if killdist > topshots[killer][16] then + topshots[killer][16] = killdist + end + end + -- most sniper kills + if mod == 46 or mod == 51 then + topshots[killer][5] = topshots[killer][5] + 1 + end + -- most knife kills + if mod == 5 or mod == 61 or mod == 65 then + topshots[killer][6] = topshots[killer][6] + 1 + end + -- most air support kills + if mod == 23 or mod == 26 then + topshots[killer][7] = topshots[killer][7] + 1 + end + -- most mine kills + if mod == 41 then + topshots[killer][8] = topshots[killer][8] + 1 + end + -- most grenade kills + if mod == 16 or mod == 18 then + topshots[killer][9] = topshots[killer][9] + 1 + end + -- most panzer kills/deaths + if mod == 15 or mod == 64 then + topshots[killer][10] = topshots[killer][10] + 1 + topshots[victim][12] = topshots[victim][12] + 1 + end + -- most mortar kills/deaths + if mod == 52 or mod == 63 then + topshots[killer][11] = topshots[killer][11] + 1 + topshots[victim][13] = topshots[victim][13] + 1 + end + -- most mg42 kills/deaths + if mod == 1 or mod == 2 or mod == 3 or mod == 44 or mod == 62 then + topshots[killer][18] = topshots[killer][18] + 1 + topshots[victim][19] = topshots[victim][19] + 1 + end + else + deaths[victim] = deaths[victim] + 1 + checkKSpreeEnd(victim) + end + death_sprees[victim] = death_sprees[victim] + 1 + killing_sprees[victim] = 0 + death_sprees[killer] = 0 + end + + if has_value(light_weapons, mod) or has_value(explosives, mod) then + local killer_dmg = 0 + local assist_dmg = {} + local last_assist_wpn = {} + local ms = et.trap_Milliseconds() + for m=ms, ms-1500, -1 do + if hitters[victim][m] then + if hitters[victim][m][1] == killer then + killer_dmg = killer_dmg + hitters[victim][m][2] + else + if assist_dmg[hitters[victim][m][1]] == nil then + assist_dmg[hitters[victim][m][1]] = hitters[victim][m][2] + else + assist_dmg[hitters[victim][m][1]] = assist_dmg[hitters[victim][m][1]] + hitters[victim][m][2] + end + if not last_assist_wpn[hitters[victim][m][1]] then + last_assist_wpn[hitters[victim][m][1]] = hitters[victim][m][3] + end + end + end + end + local keyset={} + local n=0 + for k,v in pairs(assist_dmg) do + n=n+1 + keyset[n]=k + end + for j=1,#keyset do + if v_teamid ~= et.gentity_get(keyset[j], "sess.sessionTeam") then + topshots[keyset[j]][29] = topshots[keyset[j]][29] + 1 + end + if assist_dmg[keyset[j]] > killer_dmg then + if not has_value(explosives, mod) and not has_value(explosives, last_assist_wpn[keyset[j]]) then + if v_teamid ~= et.gentity_get(keyset[j], "sess.sessionTeam") and v_teamid ~= k_teamid then + topshots[killer][30] = topshots[killer][30] + 1 + end + end + end + end + end + end + + end -- gamestate +end + +function checkKSpreeEnd(id) + if killing_sprees[id] >= 3 then + if killing_sprees[id] > topshots[id][25] then + topshots[id][25] = killing_sprees[id] + end + end +end + +function checkDSpreeEnd(id) + if death_sprees[id] >= 3 then + if death_sprees[id] > topshots[id][26] then + topshots[id][26] = death_sprees[id] + end + end +end + +function et_RunFrame(levelTime) + if math.fmod(levelTime, 100) ~= 0 then return end + local cs = tonumber(et.trap_GetConfigstring(et.CS_SERVERTOGGLES)) + if paused == false then + if (1 << 4 & cs) == 1 then + paused = true + changedred = true + redflag = false + changedblue = true + blueflag = false + end + elseif paused == true then + if (1 << 4 & cs) == 0 then + paused = false + end + end + + if math.fmod(levelTime, 500) ~= 0 then return end + + local ltm = et.trap_Milliseconds() + if eomap_done then + if eomaptime < ltm then + eomap_done = false + topshots_f(-2) + end + end + gamestate = tonumber(et.trap_Cvar_Get("gamestate")) + + if math.fmod(levelTime, 1000) ~= 0 then return end + if gamestate == 0 then + redlimbo1 = tonumber(et.trap_Cvar_Get("g_redlimbotime")) + bluelimbo1 = tonumber(et.trap_Cvar_Get("g_bluelimbotime")) + if redlimbo2 == 0 then + redlimbo2 = redlimbo1 + bluelimbo2 = bluelimbo1 + end + if redlimbo1 ~= redlimbo2 or bluelimbo1 ~= bluelimbo2 then + if redlimbo1 ~= redlimbo2 then + changedred = true + redflag = false + redlimbo2 = redlimbo1 + elseif bluelimbo1 ~= bluelimbo2 then + changedblue = true + blueflag = false + bluelimbo2 = bluelimbo1 + end + end + ltm2 = os.time() + if redflag == true then + if ltm2 == redspawn + redlimbo1 / 1000 then + redspawn = ltm2 + end + end + if blueflag == true then + if ltm2 == bluespawn + bluelimbo1 / 1000 then + bluespawn = ltm2 + end + end + end +end + +function et_ClientBegin(id) + local team = tonumber(et.gentity_get(id, "sess.sessionTeam")) + if players[id] == nil then + players[id] = team + end +end + +function et_ClientUserinfoChanged(clientNum) + local team = tonumber(et.gentity_get(clientNum, "sess.sessionTeam")) + if players[clientNum] == nil then + players[clientNum] = team + end + if players[clientNum] ~= team then + spawns[clientNum] = nil + end + players[clientNum] = team +end + +function et_ClientSpawn(id, revived) + killing_sprees[id] = 0 + local team = tonumber(et.gentity_get(id, "sess.sessionTeam")) + if revived ~= 1 then + local health = tonumber(et.gentity_get(id, "health")) + local team = tonumber(et.gentity_get(id, "sess.sessionTeam")) + if team == 1 then + if health > 0 then + if redflag == false then + if spawns[id] == nil then + spawns[id] = 1 + else + spawns[id] = spawns[id] + 1 + end + if spawns[id] == 2 then + redflag = true + redspawn = os.time() + end + if changedred == true then + redflag = true + redspawn = os.time() + changedred = false + end + end + redspawn2 = os.time() + if redspawn ~= 0 and redspawn ~= redspawn2 then + redspawn = redspawn2 + end + end + elseif team == 2 then + if health > 0 then + if blueflag == false then + if spawns[id] == nil then + spawns[id] = 1 + else + spawns[id] = spawns[id] + 1 + end + if spawns[id] == 2 then + blueflag = true + bluespawn = os.time() + end + if changedblue == true then + blueflag = true + bluespawn = os.time() + changedblue = false + end + end + bluespawn2 = os.time() + if bluespawn ~= 0 and bluespawn ~= bluespawn2 then + bluespawn = bluespawn2 + end + end + end + end + hitters[id] = {nil, nil, nil, nil} + hitRegionsData[id] = getAllHitRegions(id) + if team == 1 or team == 2 then + if death_time[id] ~= 0 then + local diff = et.trap_Milliseconds() - death_time[id] + death_time_total[id] = death_time_total[id] + diff + end + end + death_time[id] = 0 +end + +function et_ClientDisconnect(id) + killing_sprees[id] = 0 + death_sprees[id] = 0 + topshots[id] = { [1]=0, [2]=0, [3]=0, [4]=0, [5]=0, [6]=0, [7]=0, [8]=0, [9]=0, [10]=0, [11]=0, [12]=0, [13]=0, [14]=0, [15]=0, [16]=0, [17]=0, [18]=0, [19]=0, [20]=0, [21]=0, [22]=0, [23]=0, [24]=0, [25]=0, [26]=0, [27]=0, [28]=0, [29]=0, [30]=0, [31]=0, [32]=0, [33]=0, [34]=0} + mkps[id] = { [1]=0, [2]=0, [3]=0 } + vsstats[id]={[0]=0,[1]=0,[2]=0,[3]=0,[4]=0,[5]=0,[6]=0,[7]=0,[8]=0,[9]=0,[10]=0,[11]=0,[12]=0,[13]=0,[14]=0,[15]=0,[16]=0,[17]=0,[18]=0,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,[50]=0,[51]=0,[52]=0,[53]=0,[54]=0,[55]=0,[56]=0,[57]=0,[58]=0,[59]=0,[60]=0,[61]=0,[62]=0,[63]=0} + vsstats_kills[id]={[0]=0,[1]=0,[2]=0,[3]=0,[4]=0,[5]=0,[6]=0,[7]=0,[8]=0,[9]=0,[10]=0,[11]=0,[12]=0,[13]=0,[14]=0,[15]=0,[16]=0,[17]=0,[18]=0,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,[50]=0,[51]=0,[52]=0,[53]=0,[54]=0,[55]=0,[56]=0,[57]=0,[58]=0,[59]=0,[60]=0,[61]=0,[62]=0,[63]=0} + vsstats_deaths[id]={[0]=0,[1]=0,[2]=0,[3]=0,[4]=0,[5]=0,[6]=0,[7]=0,[8]=0,[9]=0,[10]=0,[11]=0,[12]=0,[13]=0,[14]=0,[15]=0,[16]=0,[17]=0,[18]=0,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,[50]=0,[51]=0,[52]=0,[53]=0,[54]=0,[55]=0,[56]=0,[57]=0,[58]=0,[59]=0,[60]=0,[61]=0,[62]=0,[63]=0} + worst_enemy[id]={[0]=0,[1]=0,[2]=0,[3]=0,[4]=0,[5]=0,[6]=0,[7]=0,[8]=0,[9]=0,[10]=0,[11]=0,[12]=0,[13]=0,[14]=0,[15]=0,[16]=0,[17]=0,[18]=0,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,[50]=0,[51]=0,[52]=0,[53]=0,[54]=0,[55]=0,[56]=0,[57]=0,[58]=0,[59]=0,[60]=0,[61]=0,[62]=0,[63]=0} + easiest_prey[id]={[0]=0,[1]=0,[2]=0,[3]=0,[4]=0,[5]=0,[6]=0,[7]=0,[8]=0,[9]=0,[10]=0,[11]=0,[12]=0,[13]=0,[14]=0,[15]=0,[16]=0,[17]=0,[18]=0,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,[50]=0,[51]=0,[52]=0,[53]=0,[54]=0,[55]=0,[56]=0,[57]=0,[58]=0,[59]=0,[60]=0,[61]=0,[62]=0,[63]=0} + kills[id] = 0 + deaths[id] = 0 + local j = 0 + for j=0,sv_maxclients-1 do + vsstats[j][id] = 0 + worst_enemy[j][id] = 0 + easiest_prey[j][id] = 0 + vsstats_kills[j][id] = 0 + vsstats_deaths[j][id] = 0 + end + hitters[id] = {nil, nil, nil, nil} + death_time[id] = 0 + death_time_total[id] = 0 + players[id] = nil + spawns[id] = nil +end + +--- Sends a nice table to a client. +-- @param id client slot +-- @param columns {name = "column header title", align = "right/left/ommit"}, ... +-- @param rows { { x0, x1, ...} { ... } ... } +-- @param separator print separators between rows? +function send_table(id, columns, rows, separator) + + local lens = {} + + --table.foreach(columns, function(index, column) + --lens[index] = string.len(et.Q_CleanStr(column.name)) + --end) + + for index, column in pairs(columns) do + lens[index] = string.len(et.Q_CleanStr(column.name)) + end + + --table.foreach(rows, function(_, row) + for _, row in pairs(rows) do + + --table.foreach(row, function(index, value) + for index, value in pairs(row) do + + local len = string.len(et.Q_CleanStr(value)) + + if lens[index] < len then + lens[index] = len + end + + --end) + end + + --end) + end + + local width = 1 + + --table.foreach(lens, function(_, len) + --width = width + len + 3 -- 3 = padding around the value and cell separator + --end) + for _, len in pairs(lens) do + width = width + len + 3 -- 3 = padding around the value and cell separator + end + + -- Header separator + et.trap_SendServerCommand(id, "chat \"^7" .. string.rep('-', width) .. "\"") + et.G_LogPrint("Endstats: " .. string.rep('-', width) .. "\"\n") + + -- Column names + local row = "^7|" + + --table.foreach(columns, function(index, column) + --row = row .. " " .. column.name .. string.rep(' ', lens[index] - string.len(et.Q_CleanStr(column.name))) .. " |" + --end) + for index, column in pairs(columns) do + row = row .. " " .. column.name .. string.rep(' ', lens[index] - string.len(et.Q_CleanStr(column.name))) .. " |" + end + et.trap_SendServerCommand(id, "chat \"" .. row .. "\"") + et.G_LogPrint("Endstats: " .. row .. "\"\n") + + if #rows > 0 then + + -- Data separator + et.trap_SendServerCommand(id, "chat \"^7" .. string.rep('-', width) .. "\"") + et.G_LogPrint("Endstats: " .. string.rep('-', width) .. "\"\n") + + -- Rows + --table.foreach(rows, function(_, r) + for _, r in pairs(rows) do + + local row = "^7|" + + --table.foreach(r, function(index, value) + for index, value in pairs(r) do + if columns[index].align == "right" then + row = row .. " " .. string.rep(' ', lens[index] - string.len(et.Q_CleanStr(value))) .. value .. " ^7|" + else + row = row .. " " .. value .. string.rep(' ', lens[index] - string.len(et.Q_CleanStr(value))) .. " ^7|" + end + --end) + end + + et.trap_SendServerCommand(id, "chat \"" .. row .. "\"") -- values + et.G_LogPrint("Endstats: " .. row .. "\"\n") + + if separator then + et.trap_SendServerCommand(id, "chat \"^7" .. string.rep('-', width) .. "\"") -- separator + et.G_LogPrint("Endstats: " .. string.rep('-', width) .. "\"\n") + end + + --end) + end + + end + + -- Bottom line + if not separator then + et.trap_SendServerCommand(id, "chat \"^7" .. string.rep('-', width) .. "\"") + et.G_LogPrint("Endstats: " .. string.rep('-', width) .. "\"\n") + end + +end diff --git a/killassists.lua b/killassists.lua new file mode 100644 index 0000000..bbb592c --- /dev/null +++ b/killassists.lua @@ -0,0 +1,467 @@ +-- killassists.lua by x0rnn, shows kill assist information upon death (who all shot you, how much HP they took and how many HS they made) + +announce_hp = false -- announce HP and distance of killer upon dying +announce_killer = false -- announce kill assists to the killer also +announce_steal = true -- announce "kill stolen from/by" to the killer and to the player stolen from +hitters = {} +assists = {} +killsteals = {} +light_weapons = {1,2,3,5,6,7,8,9,10,11,12,13,14,17,37,38,44,45,46,50,51,53,54,55,56,61,62,66} +explosives = {15,16,18,19,20,22,23,26,39,40,41,42,52,63,64} +HR_HEAD = 0 +HR_ARMS = 1 +HR_BODY = 2 +HR_LEGS = 3 +HR_NONE = -1 +HR_TYPES = {HR_HEAD, HR_ARMS, HR_BODY, HR_LEGS} +hitRegionsData = {} +gamestate = -1 + +mod_weapons = { +[1]= "MG", +[2]= "Browning", +[3]= "MG42", +[5]= "Knife", +[6]= "Luger", +[7]= "Colt", +[8]= "MP40", +[9]= "Thompson", +[10]= "Sten", +[11]= "Garand", +[12]= "Luger", +[13]= "FG42", +[14]= "Scoped FG42", +[15]= "Panzerfaust", +[16]= "Grenade", +[17]= "Flamethrower", +[18]= "Grenade", +[19]= "Mortar", +[20]= "Mortar", +[22]= "Dynamite", +[23]= "Airstrike", +[26]= "Arty", +[37]= "Rifle", +[38]= "Rifle", +[39]= "Riflenade", +[40]= "Riflenade", +[41]= "Mine", +[42]= "Satchel", +[44]= "MG42", +[45]= "Colt", +[46]= "Scoped Garand", +[50]= "K43", +[51]= "Scoped K43", +[52]= "Mortar", +[53]= "Akimbo Colt", +[54]= "Akimbo Luger", +[55]= "Akimbo Colt", +[56]= "Akimbo Luger", +[61]= "Knife", +[62]= "Browning", +[63]= "Mortar", +[64]= "Bazooka", +[66]= "MP34", +} + +function has_value (tab, val) + for index, value in ipairs(tab) do + if value == val then + return true + end + end + return false +end + +function et_InitGame(levelTime, randomSeed, restart) + et.RegisterModname("killassists.lua "..et.FindSelf()) + sv_maxclients = tonumber(et.trap_Cvar_Get("sv_maxclients")) + local j = 0 + for j=0,sv_maxclients-1 do + hitters[j] = {nil, nil, nil, nil, nil} + assists[j] = 0 + killsteals[j] = 0 + end +end + +function getAllHitRegions(clientNum) + local regions = {} + for index, hitType in ipairs(HR_TYPES) do + regions[hitType] = et.gentity_get(clientNum, "pers.playerStats.hitRegions", hitType) + end + return regions +end + +function hitType(clientNum) + local playerHitRegions = getAllHitRegions(clientNum) + if hitRegionsData[clientNum] == nil then + hitRegionsData[clientNum] = playerHitRegions + return 2 + end + for index, hitType in ipairs(HR_TYPES) do + if playerHitRegions[hitType] > hitRegionsData[clientNum][hitType] then + hitRegionsData[clientNum] = playerHitRegions + return hitType + end + end + hitRegionsData[clientNum] = playerHitRegions + return -1 +end + +function et_Damage(target, attacker, damage, damageFlags, meansOfDeath) + if target ~= attacker and attacker ~= 1022 and attacker ~= 1023 and not (tonumber(target) < 0) and not (tonumber(target) > sv_maxclients-1) then + if has_value(light_weapons, meansOfDeath) or has_value(explosives, meansOfDeath) then + local hitType = hitType(attacker) + if hitType == HR_HEAD then + if not has_value(explosives, meansOfDeath) then + hitters[target][et.trap_Milliseconds()] = {[1]=attacker, [2]=damage, [3]=1, [4]=meansOfDeath} + end + else + hitters[target][et.trap_Milliseconds()] = {[1]=attacker, [2]=damage, [3]=0, [4]=meansOfDeath} + end + end + end +end + +function dist(a, b) + ax, ay, az = a[1], a[2], a[3] + bx, by, bz = b[1], b[2], b[3] + dx = math.abs(bx - ax) + dy = math.abs(by - ay) + dz = math.abs(bz - az) + d = math.sqrt((dx ^ 2) + (dy ^ 2) + (dz ^ 2)) + return math.floor(d) / 39.37 +end + +function roundNum(num, n) + local mult = 10^(n or 0) + return math.floor(num * mult + 0.5) / mult +end + +function et_RunFrame(levelTime) + if math.fmod(levelTime, 1000) ~= 0 then return end + + gamestate = tonumber(et.trap_Cvar_Get("gamestate")) +end + +function et_Obituary(victim, killer, mod) + if gamestate == 0 then + local v_teamid = et.gentity_get(victim, "sess.sessionTeam") + local k_teamid + if killer ~= 1022 and killer ~= 1023 then + k_teamid = et.gentity_get(killer, "sess.sessionTeam") + end + if victim ~= killer and killer ~= 1022 and killer ~= 1023 then + if has_value(light_weapons, mod) or has_value(explosives, mod) then + local names = "" + local names_cens = "" + local killer_dmg = 0 + local killer_hs = 0 + local killer_wpn = "" + local killer_wpns = {} + local assist_dmg = {} + local assist_hs = {} + local assist_wpn = {} + local assist_wpns = {} + local last_assist_wpn = {} + local ms = et.trap_Milliseconds() + for m=ms, ms-1500, -1 do + if hitters[victim][m] then + if hitters[victim][m][1] == killer then + killer_dmg = killer_dmg + hitters[victim][m][2] + killer_hs = killer_hs + hitters[victim][m][3] + killer_wpn = mod_weapons[hitters[victim][m][4]] + if #killer_wpns == 0 then + table.insert(killer_wpns, killer_wpn) + else + if not has_value(killer_wpns, killer_wpn) then + table.insert(killer_wpns, killer_wpn) + end + end + else + if assist_dmg[hitters[victim][m][1]] == nil then + assist_dmg[hitters[victim][m][1]] = hitters[victim][m][2] + else + assist_dmg[hitters[victim][m][1]] = assist_dmg[hitters[victim][m][1]] + hitters[victim][m][2] + end + if assist_hs[hitters[victim][m][1]] == nil then + assist_hs[hitters[victim][m][1]] = hitters[victim][m][3] + else + assist_hs[hitters[victim][m][1]] = assist_hs[hitters[victim][m][1]] + hitters[victim][m][3] + end + assist_wpn[hitters[victim][m][1]] = mod_weapons[hitters[victim][m][4]] + if not assist_wpns[hitters[victim][m][1]] then + assist_wpns[hitters[victim][m][1]] = {} + end + if not last_assist_wpn[hitters[victim][m][1]] then + last_assist_wpn[hitters[victim][m][1]] = hitters[victim][m][4] + end + if not has_value(assist_wpns[hitters[victim][m][1]], assist_wpn[hitters[victim][m][1]]) then + table.insert(assist_wpns[hitters[victim][m][1]], assist_wpn[hitters[victim][m][1]]) + end + end + end + end + local keyset={} + local n=0 + for k,v in pairs(assist_dmg) do + n=n+1 + keyset[n]=k + end + local max = 0 + local max_id = 0 + for j=1,#keyset do + if v_teamid ~= et.gentity_get(keyset[j], "sess.sessionTeam") then + assists[keyset[j]] = assists[keyset[j]] + 1 + end + if assist_dmg[keyset[j]] > killer_dmg then + if not has_value(explosives, mod) and not has_value(explosives, last_assist_wpn[keyset[j]]) then + if v_teamid ~= et.gentity_get(keyset[j], "sess.sessionTeam") and v_teamid ~= k_teamid then + killsteals[killer] = killsteals[killer] + 1 + end + if assist_dmg[keyset[j]] > max then + max = assist_dmg[keyset[j]] + max_id = keyset[j] + end + end + end + local C + if et.gentity_get(keyset[j], "sess.sessionTeam") == 1 then + C = 1 + else + C = 4 + end + if names == "" then + if assist_hs[keyset[j]] == 0 then + if #assist_wpns[keyset[j]] == 1 then + names = et.gentity_get(keyset[j], "pers.netname") .. " ^z(^" .. C .. assist_wpn[keyset[j]] .. "^z; ^" .. C .. assist_dmg[keyset[j]] .. "^z)" + if et.gentity_get(keyset[j], "sess.sessionTeam") ~= k_teamid then + names_cens = "^" .. C .. "TEAMMATE ^z(^" .. C .. assist_wpn[keyset[j]] .. "^z; ^" .. C .. assist_dmg[keyset[j]] .. "^z)" + else + names_cens = names + end + else + local wpns = table.concat(assist_wpns[keyset[j]], "^z, ^" .. C) + names = et.gentity_get(keyset[j], "pers.netname") .. " ^z(^" .. C .. wpns .. "^z; ^" .. C .. assist_dmg[keyset[j]] .. "^z)" + if et.gentity_get(keyset[j], "sess.sessionTeam") ~= k_teamid then + names_cens = "^" .. C .. "TEAMMATE ^z(^" .. C .. wpns .. "^z; ^" .. C .. assist_dmg[keyset[j]] .. "^z)" + else + names_cens = names + end + end + else + if #assist_wpns[keyset[j]] == 1 then + names = et.gentity_get(keyset[j], "pers.netname") .. " ^z(^" .. C .. assist_wpn[keyset[j]] .. "^z; ^" .. C .. assist_dmg[keyset[j]] .. "^z, ^" .. C .. assist_hs[keyset[j]] .. "^zHS)" + if et.gentity_get(keyset[j], "sess.sessionTeam") ~= k_teamid then + names_cens = "^" .. C .. "TEAMMATE ^z(^" .. C .. assist_wpn[keyset[j]] .. "^z; ^" .. C .. assist_dmg[keyset[j]] .. "^z, ^" .. C .. assist_hs[keyset[j]] .. "^zHS)" + else + names_cens = names + end + else + local wpns = table.concat(assist_wpns[keyset[j]], "^z, ^" .. C) + names = et.gentity_get(keyset[j], "pers.netname") .. " ^z(^" .. C .. wpns .. "^z; ^" .. C .. assist_dmg[keyset[j]] .. "^z, ^" .. C .. assist_hs[keyset[j]] .. "^zHS)" + if et.gentity_get(keyset[j], "sess.sessionTeam") ~= k_teamid then + names_cens = "^" .. C .. "TEAMMATE ^z(^" .. C .. wpns .. "^z; ^" .. C .. assist_dmg[keyset[j]] .. "^z, ^" .. C .. assist_hs[keyset[j]] .. "^zHS)" + else + names_cens = names + end + end + end + else + if assist_hs[keyset[j]] == 0 then + if #assist_wpns[keyset[j]] == 1 then + names = names .. ", " .. et.gentity_get(keyset[j], "pers.netname") .. " ^z(^" .. C .. assist_wpn[keyset[j]] .. "^z; ^" .. C .. assist_dmg[keyset[j]] .. "^z)" + if et.gentity_get(keyset[j], "sess.sessionTeam") ~= k_teamid then + names_cens = names_cens .. ", ^" .. C .. "TEAMMATE ^z(^" .. C .. assist_wpn[keyset[j]] .. "^z; ^" .. C .. assist_dmg[keyset[j]] .. "^z)" + else + names_cens = names_cens .. ", " .. et.gentity_get(keyset[j], "pers.netname") .. " ^z(^" .. C .. assist_wpn[keyset[j]] .. "^z; ^" .. C .. assist_dmg[keyset[j]] .. "^z)" + end + else + local wpns = table.concat(assist_wpns[keyset[j]], "^z, ^" .. C) + names = names .. ", " .. et.gentity_get(keyset[j], "pers.netname") .. " ^z(^" .. C .. wpns .. "^z; ^" .. C .. assist_dmg[keyset[j]] .. "^z)" + if et.gentity_get(keyset[j], "sess.sessionTeam") ~= k_teamid then + names_cens = names_cens .. ", ^" .. C .. "TEAMMATE ^z(^" .. C .. wpns .. "^z; ^" .. C .. assist_dmg[keyset[j]] .. "^z)" + else + names_cens = names_cens .. ", " .. et.gentity_get(keyset[j], "pers.netname") .. " ^z(^" .. C .. wpns .. "^z; ^" .. C .. assist_dmg[keyset[j]] .. "^z)" + end + end + else + if #assist_wpns[keyset[j]] == 1 then + names = names .. ", " .. et.gentity_get(keyset[j], "pers.netname") .. " ^z(^" .. C .. assist_wpn[keyset[j]] .. "^z; ^" .. C .. assist_dmg[keyset[j]] .. "^z, ^" .. C .. assist_hs[keyset[j]] .. "^zHS)" + if et.gentity_get(keyset[j], "sess.sessionTeam") ~= k_teamid then + names_cens = names_cens .. ", ^" .. C .. "TEAMMATE ^z(^" .. C .. assist_wpn[keyset[j]] .. "^z; ^" .. C .. assist_dmg[keyset[j]] .. "^z, ^" .. C .. assist_hs[keyset[j]] .. "^zHS)" + else + names_cens = names_cens .. ", " .. et.gentity_get(keyset[j], "pers.netname") .. " ^z(^" .. C .. assist_wpn[keyset[j]] .. "^z; ^" .. C .. assist_dmg[keyset[j]] .. "^z, ^" .. C .. assist_hs[keyset[j]] .. "^zHS)" + end + else + local wpns = table.concat(assist_wpns[keyset[j]], "^z, ^" .. C) + names = names .. ", " .. et.gentity_get(keyset[j], "pers.netname") .. " ^z(^" .. C .. wpns .. "^z; ^" .. C .. assist_dmg[keyset[j]] .. "^z, ^" .. C .. assist_hs[keyset[j]] .. "^zHS)" + if et.gentity_get(keyset[j], "sess.sessionTeam") ~= k_teamid then + names_cens = names_cens .. ", ^" .. C .. "TEAMMATE ^z(^" .. C .. wpns .. "^z; ^" .. C .. assist_dmg[keyset[j]] .. "^z, ^" .. C .. assist_hs[keyset[j]] .. "^zHS)" + else + names_cens = names_cens .. ", " .. et.gentity_get(keyset[j], "pers.netname") .. " ^z(^" .. C .. wpns .. "^z; ^" .. C .. assist_dmg[keyset[j]] .. "^z, ^" .. C .. assist_hs[keyset[j]] .. "^zHS)" + end + end + end + end + end + if max > 0 then + if v_teamid ~= et.gentity_get(max_id, "sess.sessionTeam") and v_teamid ~= k_teamid then + if announce_steal == true then + et.trap_SendServerCommand(killer, "bp \"^zKill stolen from: " .. et.gentity_get(max_id, "pers.netname") .. "\";") + et.trap_SendServerCommand(max_id, "bp \"^zKill stolen by: " .. et.gentity_get(killer, "pers.netname") .. "\";") + end + if announce_killer == true then + et.trap_SendServerCommand(killer, "chat \"^zKill Assists: " .. names_cens .. "\";") + end + et.G_AddSkillPoints(max_id, et.SK_BATTLE_SENSE, 1, "KillAssist") + end + else + if names ~= "" then + if v_teamid ~= k_teamid then + if announce_killer == true then + et.trap_SendServerCommand(killer, "chat \"^zKill Assists: " .. names_cens .. "\";") + end + end + end + end + local C + if k_teamid == 1 then + C = 1 + else + C = 4 + end + if v_teamid ~= k_teamid then + if announce_hp == true then + local posk = et.gentity_get(killer, "ps.origin") + local posv = et.gentity_get(victim, "ps.origin") + local killdist = dist(posk, posv) + local killerhp = et.gentity_get(killer, "health") + local C2 = 2 + if killerhp <= 50 then + C2 = 3 + end + if killerhp <= 20 then + C2 = 1 + end + if killerhp <= 0 then + if names == "" then + if #killer_wpns == 1 then + et.trap_SendServerCommand(victim, "cp \"" .. et.gentity_get(killer, "pers.netname") .. " ^zwas dead.\nDamage received last 1.5s: (^" .. C .. killer_wpn .. "^z; ^" .. C .. killer_dmg .. "^z)\";") + et.trap_SendServerCommand(victim, "chat \"" .. et.gentity_get(killer, "pers.netname") .. " ^zwas dead. Damage received last 1.5s: (^" .. C .. killer_wpn .. "^z; ^" .. C .. killer_dmg .. "^z)\";") + else + local wpns = table.concat(killer_wpns, "^z, ^" .. C) + et.trap_SendServerCommand(victim, "cp \"" .. et.gentity_get(killer, "pers.netname") .. " ^zwas dead.\nDamage received last 1.5s: (^" .. C .. wpns .. "^z; ^" .. C .. killer_dmg .. "^z)\";") + et.trap_SendServerCommand(victim, "chat \"" .. et.gentity_get(killer, "pers.netname") .. " ^zwas dead. Damage received last 1.5s: (^" .. C .. wpns .. "^z; ^" .. C .. killer_dmg .. "^z)\";") + end + else + if #killer_wpns == 1 then + et.trap_SendServerCommand(victim, "cp \"" .. et.gentity_get(killer, "pers.netname") .. " ^zwas dead.\nKill Assists: " .. et.gentity_get(killer, "pers.netname") .. "^z(^" .. C .. killer_wpn .. "^z; ^" .. C .. killer_dmg .. "^z)\n" .. names .. "\";") + et.trap_SendServerCommand(victim, "chat \"" .. et.gentity_get(killer, "pers.netname") .. " ^zwas dead. Kill Assists: " .. et.gentity_get(killer, "pers.netname") .. "^z(^" .. C .. killer_wpn .. "^z; ^" .. C .. killer_dmg .. "^z), " .. names .. "\";") + else + local wpns = table.concat(killer_wpns, "^z, ^" .. C) + et.trap_SendServerCommand(victim, "cp \"" .. et.gentity_get(killer, "pers.netname") .. " ^zwas dead.\nKill Assists: " .. et.gentity_get(killer, "pers.netname") .. "^z(^" .. C .. wpns .. "^z; ^" .. C .. killer_dmg .. "^z)\n" .. names .. "\";") + et.trap_SendServerCommand(victim, "chat \"" .. et.gentity_get(killer, "pers.netname") .. " ^zwas dead. Kill Assists: " .. et.gentity_get(killer, "pers.netname") .. "^z(^" .. C .. wpns .. "^z; ^" .. C .. killer_dmg .. "^z), " .. names .. "\";") + end + end + else + if names == "" then + if killer_hs == 0 then + if #killer_wpns == 1 then + et.trap_SendServerCommand(victim, "cp \"" .. et.gentity_get(killer, "pers.netname") .. " ^zhad ^" .. C2 .. killerhp .. " ^zHP left. Distance was ^3" .. math.floor(roundNum(killdist)) .. " ^zm\nDamage received last 1.5s: (^" .. C .. killer_wpn .. "^z; ^" .. C .. killer_dmg .. "^z)\";") + et.trap_SendServerCommand(victim, "chat \"" .. et.gentity_get(killer, "pers.netname") .. " ^zhad ^" .. C2 .. killerhp .. " ^zHP left. Distance was ^3" .. math.floor(roundNum(killdist)) .. " ^zm. Damage received last 1.5s: (^" .. C .. killer_wpn .. "^z; ^" .. C .. killer_dmg .. "^z)\";") + else + local wpns = table.concat(killer_wpns, "^z, ^" .. C) + et.trap_SendServerCommand(victim, "cp \"" .. et.gentity_get(killer, "pers.netname") .. " ^zhad ^" .. C2 .. killerhp .. " ^zHP left. Distance was ^3" .. math.floor(roundNum(killdist)) .. " ^zm\nDamage received last 1.5s: (^" .. C .. wpns .. "^z; ^" .. C .. killer_dmg .. "^z)\";") + et.trap_SendServerCommand(victim, "chat \"" .. et.gentity_get(killer, "pers.netname") .. " ^zhad ^" .. C2 .. killerhp .. " ^zHP left. Distance was ^3" .. math.floor(roundNum(killdist)) .. " ^zm. Damage received last 1.5s: (^" .. C .. wpns .. "^z; ^" .. C .. killer_dmg .. "^z)\";") + end + else + if #killer_wpns == 1 then + et.trap_SendServerCommand(victim, "cp \"" .. et.gentity_get(killer, "pers.netname") .. " ^zhad ^" .. C2 .. killerhp .. " ^zHP left. Distance was ^3" .. math.floor(roundNum(killdist)) .. " ^zm\nDamage received last 1.5s: (^" .. C .. killer_wpn .. "^z; ^" .. C .. killer_dmg .. "^z, ^" .. C .. killer_hs .. "^zHS)\";") + et.trap_SendServerCommand(victim, "chat \"" .. et.gentity_get(killer, "pers.netname") .. " ^zhad ^" .. C2 .. killerhp .. " ^zHP left. Distance was ^3" .. math.floor(roundNum(killdist)) .. " ^zm. Damage received last 1.5s: (^" .. C .. killer_wpn .. "^z; ^" .. C .. killer_dmg .. "^z, ^" .. C .. killer_hs .. "^zHS)\";") + else + local wpns = table.concat(killer_wpns, "^z, ^" .. C) + et.trap_SendServerCommand(victim, "cp \"" .. et.gentity_get(killer, "pers.netname") .. " ^zhad ^" .. C2 .. killerhp .. " ^zHP left. Distance was ^3" .. math.floor(roundNum(killdist)) .. " ^zm\nDamage received last 1.5s: (^" .. C .. wpns .. "^z; ^" .. C .. killer_dmg .. "^z, ^" .. C .. killer_hs .. "^zHS)\";") + et.trap_SendServerCommand(victim, "chat \"" .. et.gentity_get(killer, "pers.netname") .. " ^zhad ^" .. C2 .. killerhp .. " ^zHP left. Distance was ^3" .. math.floor(roundNum(killdist)) .. " ^zm. Damage received last 1.5s: (^" .. C .. wpns .. "^z; ^" .. C .. killer_dmg .. "^z, ^" .. C .. killer_hs .. "^zHS)\";") + end + end + else + if killer_hs == 0 then + if #killer_wpns == 1 then + et.trap_SendServerCommand(victim, "cp \"" .. et.gentity_get(killer, "pers.netname") .. " ^zhad ^" .. C2 .. killerhp .. " ^zHP left. Distance was ^3" .. math.floor(roundNum(killdist)) .. " ^zm\nKill Assists: " .. et.gentity_get(killer, "pers.netname") .. " ^z(^" .. C .. killer_wpn .. "^z; ^" .. C .. killer_dmg .. "^z)\n" .. names .. "\";") + et.trap_SendServerCommand(victim, "chat \"" .. et.gentity_get(killer, "pers.netname") .. " ^zhad ^" .. C2 .. killerhp .. " ^zHP left. Distance was ^3" .. math.floor(roundNum(killdist)) .. " ^zm. Kill Assists: " .. et.gentity_get(killer, "pers.netname") .. " ^z(^" .. C .. killer_wpn .. "^z; ^" .. C .. killer_dmg .. "^z), " .. names .. "\";") + else + local wpns = table.concat(killer_wpns, "^z, ^" .. C) + et.trap_SendServerCommand(victim, "cp \"" .. et.gentity_get(killer, "pers.netname") .. " ^zhad ^" .. C2 .. killerhp .. " ^zHP left. Distance was ^3" .. math.floor(roundNum(killdist)) .. " ^zm\nKill Assists: " .. et.gentity_get(killer, "pers.netname") .. " ^z(^" .. C .. wpns .. "^z; ^" .. C .. killer_dmg .. "^z)\n" .. names .. "\";") + et.trap_SendServerCommand(victim, "chat \"" .. et.gentity_get(killer, "pers.netname") .. " ^zhad ^" .. C2 .. killerhp .. " ^zHP left. Distance was ^3" .. math.floor(roundNum(killdist)) .. " ^zm. Kill Assists: " .. et.gentity_get(killer, "pers.netname") .. " ^z(^" .. C .. wpns .. "^z; ^" .. C .. killer_dmg .. "^z), " .. names .. "\";") + end + else + if #killer_wpns == 1 then + et.trap_SendServerCommand(victim, "cp \"" .. et.gentity_get(killer, "pers.netname") .. " ^zhad ^" .. C2 .. killerhp .. " ^zHP left. Distance was ^3" .. math.floor(roundNum(killdist)) .. " ^zm\nKill Assists: " .. et.gentity_get(killer, "pers.netname") .. " ^z(^" .. C .. killer_wpn .. "^z; ^" .. C .. killer_dmg .. "^z, ^" .. C .. killer_hs .. "^zHS)\n" .. names .. "\";") + et.trap_SendServerCommand(victim, "chat \"" .. et.gentity_get(killer, "pers.netname") .. " ^zhad ^" .. C2 .. killerhp .. " ^zHP left. Distance was ^3" .. math.floor(roundNum(killdist)) .. " ^zm. Kill Assists: " .. et.gentity_get(killer, "pers.netname") .. " ^z(^" .. C .. killer_wpn .. "^z; ^" .. C .. killer_dmg .. "^z, ^" .. C .. killer_hs .. "^zHS), " .. names .. "\";") + else + local wpns = table.concat(killer_wpns, "^z, ^" .. C) + et.trap_SendServerCommand(victim, "cp \"" .. et.gentity_get(killer, "pers.netname") .. " ^zhad ^" .. C2 .. killerhp .. " ^zHP left. Distance was ^3" .. math.floor(roundNum(killdist)) .. " ^zm\nKill Assists: " .. et.gentity_get(killer, "pers.netname") .. " ^z(^" .. C .. wpns .. "^z; ^" .. C .. killer_dmg .. "^z, ^" .. C .. killer_hs .. "^zHS)\n" .. names .. "\";") + et.trap_SendServerCommand(victim, "chat \"" .. et.gentity_get(killer, "pers.netname") .. " ^zhad ^" .. C2 .. killerhp .. " ^zHP left. Distance was ^3" .. math.floor(roundNum(killdist)) .. " ^zm. Kill Assists: " .. et.gentity_get(killer, "pers.netname") .. " ^z(^" .. C .. wpns .. "^z; ^" .. C .. killer_dmg .. "^z, ^" .. C .. killer_hs .. "^zHS), " .. names .. "\";") + end + end + end + end + else + if names == "" then + if killer_hs == 0 then + if #killer_wpns == 1 then + et.trap_SendServerCommand(victim, "cp \"^zDamage received last 1.5s: " .. et.gentity_get(killer, "pers.netname") .. " ^z(^" .. C .. killer_wpn .. "^z; ^" .. C .. killer_dmg .. "^z)\";") + et.trap_SendServerCommand(victim, "chat \"^zDamage received last 1.5s: " .. et.gentity_get(killer, "pers.netname") .. " ^z(^" .. C .. killer_wpn .. "^z; ^" .. C .. killer_dmg .. "^z)\";") + else + local wpns = table.concat(killer_wpns, "^z, ^" .. C) + et.trap_SendServerCommand(victim, "cp \"^zDamage received last 1.5s: " .. et.gentity_get(killer, "pers.netname") .. " ^z(^" .. C .. wpns .. "^z; ^" .. C .. killer_dmg .. "^z)\";") + et.trap_SendServerCommand(victim, "chat \"^zDamage received last 1.5s: " .. et.gentity_get(killer, "pers.netname") .. " ^z(^" .. C .. wpns .. "^z; ^" .. C .. killer_dmg .. "^z)\";") + end + else + if #killer_wpns == 1 then + et.trap_SendServerCommand(victim, "cp \"^zDamage received last 1.5s: " .. et.gentity_get(killer, "pers.netname") .. " ^z(^" .. C .. killer_wpn .. "^z; ^" .. C .. killer_dmg .. "^z, ^" .. C .. killer_hs .. "^zHS)\";") + et.trap_SendServerCommand(victim, "chat \"^zDamage received last 1.5s: " .. et.gentity_get(killer, "pers.netname") .. " ^z(^" .. C .. killer_wpn .. "^z; ^" .. C .. killer_dmg .. "^z, ^" .. C .. killer_hs .. "^zHS)\";") + else + local wpns = table.concat(killer_wpns, "^z, ^" .. C) + et.trap_SendServerCommand(victim, "cp \"^zDamage received last 1.5s: " .. et.gentity_get(killer, "pers.netname") .. " ^z(^" .. C .. wpns .. "^z; ^" .. C .. killer_dmg .. "^z, ^" .. C .. killer_hs .. "^zHS)\";") + et.trap_SendServerCommand(victim, "chat \"^zDamage received last 1.5s: " .. et.gentity_get(killer, "pers.netname") .. " ^z(^" .. C .. wpns .. "^z; ^" .. C .. killer_dmg .. "^z, ^" .. C .. killer_hs .. "^zHS)\";") + end + end + else + if killer_hs == 0 then + if #killer_wpns == 1 then + et.trap_SendServerCommand(victim, "cp \"^zKill Assists: " .. et.gentity_get(killer, "pers.netname") .. " ^z(^" .. C .. killer_wpn .. "^z; ^" .. C .. killer_dmg .. "^z)\n" .. names .. "\";") + et.trap_SendServerCommand(victim, "chat \"^zKill Assists: " .. et.gentity_get(killer, "pers.netname") .. " ^z(^" .. C .. killer_wpn .. "^z; ^" .. C .. killer_dmg .. "^z), " .. names .. "\";") + else + local wpns = table.concat(killer_wpns, "^z, ^" .. C) + et.trap_SendServerCommand(victim, "cp \"^zKill Assists: " .. et.gentity_get(killer, "pers.netname") .. " ^z(^" .. C .. wpns .. "^z; ^" .. C .. killer_dmg .. "^z)\n" .. names .. "\";") + et.trap_SendServerCommand(victim, "chat \"^zKill Assists: " .. et.gentity_get(killer, "pers.netname") .. " ^z(^" .. C .. wpns .. "^z; ^" .. C .. killer_dmg .. "^z), " .. names .. "\";") + end + else + if #killer_wpns == 1 then + et.trap_SendServerCommand(victim, "cp \"^zKill Assists: " .. et.gentity_get(killer, "pers.netname") .. " ^z(^" .. C .. killer_wpn .. "^z; ^" .. C .. killer_dmg .. "^z, ^" .. C .. killer_hs .. "^zHS)\n" .. names .. "\";") + et.trap_SendServerCommand(victim, "chat \"^zKill Assists: " .. et.gentity_get(killer, "pers.netname") .. " ^z(^" .. C .. killer_wpn .. "^z; ^" .. C .. killer_dmg .. "^z, ^" .. C .. killer_hs .. "^zHS), " .. names .. "\";") + else + local wpns = table.concat(killer_wpns, "^z, ^" .. C) + et.trap_SendServerCommand(victim, "cp \"^zKill Assists: " .. et.gentity_get(killer, "pers.netname") .. " ^z(^" .. C .. wpns .. "^z; ^" .. C .. killer_dmg .. "^z, ^" .. C .. killer_hs .. "^zHS)\n" .. names .. "\";") + et.trap_SendServerCommand(victim, "chat \"^zKill Assists: " .. et.gentity_get(killer, "pers.netname") .. " ^z(^" .. C .. wpns .. "^z; ^" .. C .. killer_dmg .. "^z, ^" .. C .. killer_hs .. "^zHS), " .. names .. "\";") + end + end + end + end + end + end + end + end +end + +function et_ClientSpawn(clientNum, revived, teamChange, restoreHealth) + hitters[clientNum] = {nil, nil, nil, nil, nil} + hitRegionsData[clientNum] = getAllHitRegions(clientNum) +end + +function et_ClientDisconnect(clientNum) + hitters[clientNum] = {nil, nil, nil, nil, nil} + assists[clientNum] = 0 + killsteals[clientNum] = 0 +end diff --git a/objtrack.lua b/objtrack.lua new file mode 100644 index 0000000..1b0a8f8 --- /dev/null +++ b/objtrack.lua @@ -0,0 +1,1368 @@ +-- objtrack.lua by x0rnn, tracks and announces who stole, returned or secured objectives +-- preconfigured maps only; support for additional maps needs to be added manually + +mapname = "" +goldcarriers = {} +goldcarriers_id = {} +doccarriers = {} +doccarriers_id = {} +objcarriers = {} +objcarriers_id = {} +second_obj = false +third_obj = false +fourth_obj = false +firstflag = false +secondflag = false + +function et_InitGame(levelTime, randomSeed, restart) + et.RegisterModname("objtrack.lua "..et.FindSelf()) + + mapname = string.lower(et.trap_Cvar_Get("mapname")) +end + +function et_Print(text) + if mapname == "radar" then + if(string.find(text, "team_CTF_redflag")) then + local i, j = string.find(text, "%d+") + local id = tonumber(string.sub(text, i, j)) + local team = tonumber(et.gentity_get(id, "sess.sessionTeam")) + local name = et.gentity_get(id, "pers.netname") + if team == 2 then + objcarriers[id] = true + table.insert(objcarriers_id, id) + if firstflag == true then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the West Radar Parts!\"\n") + elseif secondflag == true then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the East Radar Parts!\"\n") + else + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole a Radar Part!\"\n") + end + elseif team == 1 then + if firstflag == true then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the West Radar Parts!\"\n") + elseif secondflag == true then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the East Radar Parts!\"\n") + else + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned a Radar Part!\"\n") + end + end + end + if(string.find(text, "Allies have secured the East")) then + local x = 1 + for index in pairs(objcarriers_id) do + if objcarriers[objcarriers_id[x]] == true then + local redflag = et.gentity_get(objcarriers_id[x], "ps.powerups", 5) + if redflag == 0 then + local name = et.gentity_get(objcarriers_id[x], "pers.netname") + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured the East Radar Parts!\"\n") + objcarriers[objcarriers_id[x]] = nil + table.remove(objcarriers_id, x) + end + end + x = x + 1 + end + firstflag = true + end + if(string.find(text, "Allies have secured the West")) then + local x = 1 + for index in pairs(objcarriers_id) do + if objcarriers[objcarriers_id[x]] == true then + local redflag = et.gentity_get(objcarriers_id[x], "ps.powerups", 5) + if redflag == 0 then + local name = et.gentity_get(objcarriers_id[x], "pers.netname") + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured the West Radar Parts!\"\n") + objcarriers[objcarriers_id[x]] = nil + table.remove(objcarriers_id, x) + end + end + x = x + 1 + end + secondflag = true + end + end -- end radar + + if mapname == "goldrush" or mapname == "uje_goldrush" or mapname == "goldrush-ga" or mapname == "goldrush-gals" then + if(string.find(text, "team_CTF_redflag")) then + local i, j = string.find(text, "%d+") + local id = tonumber(string.sub(text, i, j)) + local team = tonumber(et.gentity_get(id, "sess.sessionTeam")) + local name = et.gentity_get(id, "pers.netname") + if team == 2 then + goldcarriers[id] = true + table.insert(goldcarriers_id, id) + if #goldcarriers_id == 1 then + if firstflag == false then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the first Gold Crate!\"\n") + else + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the second Gold Crate!\"\n") + end + elseif #goldcarriers_id == 2 then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the second Gold Crate!\"\n") + end + elseif team == 1 then + if firstflag == true then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the second Gold Crate!\"\n") + else + if #goldcarriers_id == 1 then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the second Gold Crate!\"\n") + else + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned a Gold Crate!\"\n") + end + end + end + end + if(string.find(text, "Allied team has secured the first Gold Crate")) then + local x = 1 + for index in pairs(goldcarriers_id) do + if goldcarriers[goldcarriers_id[x]] == true then + local redflag = et.gentity_get(goldcarriers_id[x], "ps.powerups", 5) + if redflag == 0 then + local name = et.gentity_get(goldcarriers_id[x], "pers.netname") + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured the first Gold Crate!\"\n") + goldcarriers[goldcarriers_id[x]] = nil + table.remove(goldcarriers_id, x) + end + end + x = x + 1 + end + firstflag = true + end + if(string.find(text, "Allied team has secured the second Gold Crate")) then + local name = et.gentity_get(goldcarriers_id[1], "pers.netname") + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured the second Gold Crate!\"\n") + goldcarriers[goldcarriers_id[1]] = nil + table.remove(goldcarriers_id, 1) + end + end -- end goldrush + + if (string.find(mapname, "frostbite")) then + if(string.find(text, "team_CTF_redflag")) then + local i, j = string.find(text, "%d+") + local id = tonumber(string.sub(text, i, j)) + local team = tonumber(et.gentity_get(id, "sess.sessionTeam")) + local name = et.gentity_get(id, "pers.netname") + if team == 2 then + doccarriers[id] = true + table.insert(doccarriers_id, id) + if second_obj == false then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the Supply Documents!\"\n") + else + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the Deciphered Supply Documents!\"\n") + end + elseif team == 1 then + if second_obj == true then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the Deciphered Supply Documents!\"\n") + else + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the Supply Documents!\"\n") + end + end + end + if(string.find(text, "The Allies have transmitted the Supply")) then + local name = et.gentity_get(doccarriers_id[1], "pers.netname") + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured the Supply Documents!\"\n") + doccarriers[doccarriers_id[1]] = nil + table.remove(doccarriers_id, 1) + second_obj = true + end + if(string.find(text, "The Allies have transmitted the Deciphered")) then + local name = et.gentity_get(doccarriers_id[1], "pers.netname") + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured the Deciphered Supply Documents!\"\n") + doccarriers[doccarriers_id[1]] = nil + table.remove(doccarriers_id, 1) + end + end -- end frostbite + + if (string.find(mapname, "missile")) then + if(string.find(text, "team_CTF_redflag")) then + local i, j = string.find(text, "%d+") + local id = tonumber(string.sub(text, i, j)) + local team = tonumber(et.gentity_get(id, "sess.sessionTeam")) + local name = et.gentity_get(id, "pers.netname") + if team == 2 then + objcarriers[id] = true + table.insert(objcarriers_id, id) + if second_obj == false then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the Gate Power Supply!\"\n") + else + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the Rocket Control!\"\n") + end + elseif team == 1 then + if second_obj == true then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the Rocket Control!\"\n") + else + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the Gate Power Supply!\"\n") + end + end + end + if(string.find(text, "Allies have transported the Power")) then + local name = et.gentity_get(objcarriers_id[1], "pers.netname") + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured the Gate Power Supply!\"\n") + objcarriers[objcarriers_id[1]] = nil + table.remove(objcarriers_id, 1) + second_obj = true + end + if(string.find(text, "Allies have transported the Rocket")) then + local name = et.gentity_get(objcarriers_id[1], "pers.netname") + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured the Rocket Control!\"\n") + objcarriers[objcarriers_id[1]] = nil + table.remove(objcarriers_id, 1) + end + end -- end missile_b3/b4 + + if (string.find(mapname, "sp_delivery")) then + if(string.find(text, "team_CTF_redflag")) then + local i, j = string.find(text, "%d+") + local id = tonumber(string.sub(text, i, j)) + local team = tonumber(et.gentity_get(id, "sess.sessionTeam")) + local name = et.gentity_get(id, "pers.netname") + if team == 2 then + goldcarriers[id] = true + table.insert(goldcarriers_id, id) + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole a Gold Crate!\"\n") + elseif team == 1 then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned a Gold Crate!\"\n") + end + end + if(string.find(text, "The Allies have secured a gold crate")) then + local x = 1 + for index in pairs(goldcarriers_id) do + if goldcarriers[goldcarriers_id[x]] == true then + local redflag = et.gentity_get(goldcarriers_id[x], "ps.powerups", 5) + if redflag == 0 then + local name = et.gentity_get(goldcarriers_id[x], "pers.netname") + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured a Gold Crate!\"\n") + goldcarriers[goldcarriers_id[x]] = nil + table.remove(goldcarriers_id, x) + end + end + x = x + 1 + end + end + end -- end sp_delivery_te/etl_sp_delivery + + if mapname == "sw_goldrush_te" then + if(string.find(text, "team_CTF_redflag")) then + local i, j = string.find(text, "%d+") + local id = tonumber(string.sub(text, i, j)) + local team = tonumber(et.gentity_get(id, "sess.sessionTeam")) + local name = et.gentity_get(id, "pers.netname") + if team == 2 then + goldcarriers[id] = true + table.insert(goldcarriers_id, id) + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the Gold Bars!\"\n") + elseif team == 1 then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the Gold Bars!\"\n") + end + end + if(string.find(text, "Allied team is escaping with the Gold")) then + local name = et.gentity_get(goldcarriers_id[1], "pers.netname") + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured the Gold Bars!\"\n") + goldcarriers[goldcarriers_id[1]] = nil + table.remove(goldcarriers_id, 1) + end + end -- end sw_goldrush_te + + if mapname == "bremen_b3" then + if(string.find(text, "team_CTF_redflag")) then + local i, j = string.find(text, "%d+") + local id = tonumber(string.sub(text, i, j)) + local team = tonumber(et.gentity_get(id, "sess.sessionTeam")) + local name = et.gentity_get(id, "pers.netname") + if team == 2 then + objcarriers[id] = true + table.insert(objcarriers_id, id) + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the Keycard!\"\n") + elseif team == 1 then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the Keycard!\"\n") + end + end + if(string.find(text, "The Allies have captured the keycard")) then + local name = et.gentity_get(objcarriers_id[1], "pers.netname") + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured the Keycard!\"\n") + objcarriers[objcarriers_id[1]] = nil + table.remove(objcarriers_id, 1) + end + end -- end bremen_b3 + + if (string.find(mapname, "adlernest")) then + if(string.find(text, "team_CTF_redflag")) then + local i, j = string.find(text, "%d+") + local id = tonumber(string.sub(text, i, j)) + local team = tonumber(et.gentity_get(id, "sess.sessionTeam")) + local name = et.gentity_get(id, "pers.netname") + if team == 2 then + doccarriers[id] = true + table.insert(doccarriers_id, id) + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the Documents!\"\n") + elseif team == 1 then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the Documents!\"\n") + end + end + if(string.find(text, "Allied team has transmitted the documents")) then + local name = et.gentity_get(doccarriers_id[1], "pers.netname") + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured the Documents!\"\n") + doccarriers[doccarriers_id[1]] = nil + table.remove(doccarriers_id, 1) + end + end -- end adlernest + + if mapname == "et_beach" then + if(string.find(text, "team_CTF_redflag")) then + local i, j = string.find(text, "%d+") + local id = tonumber(string.sub(text, i, j)) + local team = tonumber(et.gentity_get(id, "sess.sessionTeam")) + local name = et.gentity_get(id, "pers.netname") + if team == 2 then + doccarriers[id] = true + table.insert(doccarriers_id, id) + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the War Documents!\"\n") + elseif team == 1 then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the War Documents!\"\n") + end + end + if(string.find(text, "Allied team transmit the War Documents")) then + local name = et.gentity_get(doccarriers_id[1], "pers.netname") + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured the War Documents!\"\n") + doccarriers[doccarriers_id[1]] = nil + table.remove(doccarriers_id, 1) + end + end -- end et_beach + + if mapname == "venice" then + if(string.find(text, "team_CTF_redflag")) then + local i, j = string.find(text, "%d+") + local id = tonumber(string.sub(text, i, j)) + local team = tonumber(et.gentity_get(id, "sess.sessionTeam")) + local name = et.gentity_get(id, "pers.netname") + if team == 2 then + objcarriers[id] = true + table.insert(objcarriers_id, id) + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the Relic!\"\n") + elseif team == 1 then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the Relic!\"\n") + end + end + if(string.find(text, "Allied team has secured the Relic")) then + local name = et.gentity_get(objcarriers_id[1], "pers.netname") + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured the Relic!\"\n") + objcarriers[objcarriers_id[1]] = nil + table.remove(objcarriers_id, 1) + end + end -- end venice + + if mapname == "library_b3" then + if(string.find(text, "team_CTF_redflag")) then + local i, j = string.find(text, "%d+") + local id = tonumber(string.sub(text, i, j)) + local team = tonumber(et.gentity_get(id, "sess.sessionTeam")) + local name = et.gentity_get(id, "pers.netname") + if team == 2 then + doccarriers[id] = true + table.insert(doccarriers_id, id) + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the Secret Documents!\"\n") + elseif team == 1 then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the Secret Documents!\"\n") + end + end + if(string.find(text, "The Allies have sent the secret docs")) then + local name = et.gentity_get(doccarriers_id[1], "pers.netname") + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured the Secret Documents!\"\n") + doccarriers[doccarriers_id[1]] = nil + table.remove(doccarriers_id, 1) + end + end -- end library_b3 + + if mapname == "pirates" then + if(string.find(text, "team_CTF_redflag")) then + local i, j = string.find(text, "%d+") + local id = tonumber(string.sub(text, i, j)) + local team = tonumber(et.gentity_get(id, "sess.sessionTeam")) + local name = et.gentity_get(id, "pers.netname") + if team == 2 then + goldcarriers[id] = true + table.insert(goldcarriers_id, id) + if #goldcarriers_id == 1 then + if firstflag == false then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the first Gold Crate!\"\n") + else + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the second Gold Crate!\"\n") + end + elseif #goldcarriers_id == 2 then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the second Gold Crate!\"\n") + end + elseif team == 1 then + if firstflag == true then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the second Gold Crate!\"\n") + else + if #goldcarriers_id == 1 then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the second Gold Crate!\"\n") + else + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned a Gold Crate!\"\n") + end + end + end + end + if(string.find(text, "Allied team has secured the first Gold Crate")) then + local x = 1 + for index in pairs(goldcarriers_id) do + if goldcarriers[goldcarriers_id[x]] == true then + local redflag = et.gentity_get(goldcarriers_id[x], "ps.powerups", 5) + if redflag == 0 then + local name = et.gentity_get(goldcarriers_id[x], "pers.netname") + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured the first Gold Crate!\"\n") + goldcarriers[goldcarriers_id[x]] = nil + table.remove(goldcarriers_id, x) + end + end + x = x + 1 + end + firstflag = true + end + if(string.find(text, "Allied team has secured the second Gold Crate")) then + local name = et.gentity_get(goldcarriers_id[1], "pers.netname") + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured the second Gold Crate!\"\n") + goldcarriers[goldcarriers_id[1]] = nil + table.remove(goldcarriers_id, 1) + end + end -- end pirates + + --if mapname == "karsiah_te2" then + --if(string.find(text, "team_CTF_redflag")) then + --local i, j = string.find(text, "%d+") + --local id = tonumber(string.sub(text, i, j)) + --local team = tonumber(et.gentity_get(id, "sess.sessionTeam")) + --local name = et.gentity_get(id, "pers.netname") + --if team == 2 then + --objcarriers[id] = true + --table.insert(objcarriers_id, id) + --if firstflag == true then + --et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the South Documents!\"\n") + --elseif secondflag == true then + --et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the North Documents!\"\n") + --else + --et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole a stack of Documents!\"\n") + --end + --elseif team == 1 then + --if firstflag == true then + --et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the South Documents!\"\n") + --elseif secondflag == true then + --et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the North Documents!\"\n") + --else + --et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned a stack of Documents\"\n") + --end + --end + --end + --if(string.find(text, "Allies have transmitted the North Documents")) then + --local x = 1 + --for index in pairs(objcarriers_id) do + --if objcarriers[objcarriers_id[x]] == true then + --local redflag = et.gentity_get(objcarriers_id[x], "ps.powerups", 5) + --if redflag == 0 then + --local name = et.gentity_get(objcarriers_id[x], "pers.netname") + --et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured the North Documents!\"\n") + --objcarriers[objcarriers_id[x]] = nil + --table.remove(objcarriers_id, x) + --end + --end + --x = x + 1 + --end + --firstflag = true + --end + --if(string.find(text, "Allies have transmitted the South Documents")) then + --local x = 1 + --for index in pairs(objcarriers_id) do + --if objcarriers[objcarriers_id[x]] == true then + --local redflag = et.gentity_get(objcarriers_id[x], "ps.powerups", 5) + --if redflag == 0 then + --local name = et.gentity_get(objcarriers_id[x], "pers.netname") + --et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured the South Documents!\"\n") + --objcarriers[objcarriers_id[x]] = nil + --table.remove(objcarriers_id, x) + --end + --end + --x = x + 1 + --end + --secondflag = true + --end + --end -- end karsiah_te2 + + -- karsiah_te2 alternate script (karsiah_te3) + if (string.find(mapname, "karsiah_te2")) then + if(string.find(text, "team_CTF_redflag")) then + local i, j = string.find(text, "%d+") + local id = tonumber(string.sub(text, i, j)) + local team = tonumber(et.gentity_get(id, "sess.sessionTeam")) + local name = et.gentity_get(id, "pers.netname") + if team == 2 then + objcarriers[id] = true + table.insert(objcarriers_id, id) + if second_obj == false then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the North Documents!\"\n") + else + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the South Documents!\"\n") + end + elseif team == 1 then + if second_obj == true then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the South Documents!\"\n") + else + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the North Documents!\"\n") + end + end + end + if(string.find(text, "Allies have transmitted the North Documents")) then + local name = et.gentity_get(objcarriers_id[1], "pers.netname") + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured the North Documents!\"\n") + objcarriers[objcarriers_id[1]] = nil + table.remove(objcarriers_id, 1) + second_obj = true + end + if(string.find(text, "Allies have transmitted the South Documents")) then + local name = et.gentity_get(objcarriers_id[1], "pers.netname") + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured the South Documents!\"\n") + objcarriers[objcarriers_id[1]] = nil + table.remove(objcarriers_id, 1) + end + end -- end karsiah_te2 alternate script (karsiah_te3) + + if (string.find(mapname, "karsiah_te3")) then + if(string.find(text, "team_CTF_redflag")) then + local i, j = string.find(text, "%d+") + local id = tonumber(string.sub(text, i, j)) + local team = tonumber(et.gentity_get(id, "sess.sessionTeam")) + local name = et.gentity_get(id, "pers.netname") + if team == 2 then + objcarriers[id] = true + table.insert(objcarriers_id, id) + if second_obj == false then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the North Documents!\"\n") + else + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the South Documents!\"\n") + end + elseif team == 1 then + if second_obj == true then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the South Documents!\"\n") + else + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the North Documents!\"\n") + end + end + end + if(string.find(text, "Allies have transmitted the North Documents")) then + local name = et.gentity_get(objcarriers_id[1], "pers.netname") + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured the North Documents!\"\n") + objcarriers[objcarriers_id[1]] = nil + table.remove(objcarriers_id, 1) + second_obj = true + end + if(string.find(text, "Allies have transmitted the South Documents")) then + local name = et.gentity_get(objcarriers_id[1], "pers.netname") + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured the South Documents!\"\n") + objcarriers[objcarriers_id[1]] = nil + table.remove(objcarriers_id, 1) + end + end -- end karsiah_te3 + + if mapname == "et_ufo_final" then + if(string.find(text, "team_CTF_redflag")) then + local i, j = string.find(text, "%d+") + local id = tonumber(string.sub(text, i, j)) + local team = tonumber(et.gentity_get(id, "sess.sessionTeam")) + local name = et.gentity_get(id, "pers.netname") + if team == 2 then + doccarriers[id] = true + table.insert(doccarriers_id, id) + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the UFO Documents!\"\n") + elseif team == 1 then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the UFO Documents!\"\n") + end + end + if(string.find(text, "Allies Transmitted the UFO Documents")) then + local name = et.gentity_get(doccarriers_id[1], "pers.netname") + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured the UFO Documents!\"\n") + doccarriers[doccarriers_id[1]] = nil + table.remove(doccarriers_id, 1) + end + end -- end et_ufo_final + + if mapname == "sos_secret_weapon" then + if(string.find(text, "team_CTF_redflag")) then + local i, j = string.find(text, "%d+") + local id = tonumber(string.sub(text, i, j)) + local team = tonumber(et.gentity_get(id, "sess.sessionTeam")) + local name = et.gentity_get(id, "pers.netname") + if team == 2 then + objcarriers[id] = true + table.insert(objcarriers_id, id) + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the Secret Weapon!\"\n") + elseif team == 1 then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the Secret Weapon!\"\n") + end + end + if(string.find(text, "Allied team has secured the secret weapon")) then + local name = et.gentity_get(objcarriers_id[1], "pers.netname") + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured the Secret Weapon!\"\n") + objcarriers[objcarriers_id[1]] = nil + table.remove(objcarriers_id, 1) + end + end -- end sos_secret_weapon + + if mapname == "falkenstein_b3" then + if(string.find(text, "team_CTF_redflag")) then + local i, j = string.find(text, "%d+") + local id = tonumber(string.sub(text, i, j)) + local team = tonumber(et.gentity_get(id, "sess.sessionTeam")) + local name = et.gentity_get(id, "pers.netname") + if team == 2 then + objcarriers[id] = true + table.insert(objcarriers_id, id) + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the Prototype!\"\n") + elseif team == 1 then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the Prototype!\"\n") + end + end + if(string.find(text, "ALLIES ESCAPED WITH THE OBJECTIVE")) then + local name = et.gentity_get(objcarriers_id[1], "pers.netname") + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured the Prototype!\"\n") + objcarriers[objcarriers_id[1]] = nil + table.remove(objcarriers_id, 1) + end + end -- end falkenstein_b3 + + if (string.find(mapname, "decay")) then + if(string.find(text, "team_CTF_redflag")) then + local i, j = string.find(text, "%d+") + local id = tonumber(string.sub(text, i, j)) + local team = tonumber(et.gentity_get(id, "sess.sessionTeam")) + local name = et.gentity_get(id, "pers.netname") + if team == 2 then + objcarriers[id] = true + table.insert(objcarriers_id, id) + if second_obj == false then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the Access Codes!\"\n") + else + if firstflag == false then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the first Gold Crate!\"\n") + else + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the second Gold Crate!\"\n") + end + end + elseif team == 1 then + if second_obj == false then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the Access Codes!\"\n") + else + if firstflag == false then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the first Gold Crate!\"\n") + else + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the second Gold Crate!\"\n") + end + end + end + end + if(string.find(text, "The Allies have transmitted the Access codes")) then + local name = et.gentity_get(objcarriers_id[1], "pers.netname") + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured the Access Codes!\"\n") + objcarriers[objcarriers_id[1]] = nil + table.remove(objcarriers_id, 1) + second_obj = true + end + if(string.find(text, "The Allies have secured a gold crate!")) then + if firstflag == false then + local name = et.gentity_get(objcarriers_id[1], "pers.netname") + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured the first Gold Crate!\"\n") + objcarriers[objcarriers_id[1]] = nil + table.remove(objcarriers_id, 1) + firstflag = true + elseif firstflag == true then + local name = et.gentity_get(objcarriers_id[1], "pers.netname") + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured the second Gold Crate!\"\n") + objcarriers[objcarriers_id[1]] = nil + table.remove(objcarriers_id, 1) + end + end + end --end decay_b7/decay_sw + + -- decay_b7 alternate script + --if mapname == "decay_b7" then + --if(string.find(text, "team_CTF_redflag")) then + --local i, j = string.find(text, "%d+") + --local id = tonumber(string.sub(text, i, j)) + --local team = tonumber(et.gentity_get(id, "sess.sessionTeam")) + --local name = et.gentity_get(id, "pers.netname") + --if team == 2 then + --objcarriers[id] = true + --table.insert(objcarriers_id, id) + --if second_obj == false then + --et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the Access Codes!\"\n") + --else + --if #objcarriers_id == 1 then + --if firstflag == false then + --et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the first Gold Crate!\"\n") + --else + --et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the second Gold Crate!\"\n") + --end + --elseif #objcarriers_id == 2 then + --et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the second Gold Crate!\"\n") + --end + --end + --elseif team == 1 then + --if second_obj == false then + --et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the Access Codes!\"\n") + --else + --if firstflag == true then + --et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the second Gold Crate!\"\n") + --else + --if #objcarriers_id == 1 then + --et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the second Gold Crate!\"\n") + --else + --et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned a Gold Crate!\"\n") + --end + --end + --end + --end + --end + --if(string.find(text, "The Allies have transmitted the Access codes")) then + --local name = et.gentity_get(objcarriers_id[1], "pers.netname") + --et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured the Access Codes!\"\n") + --objcarriers[objcarriers_id[1]] = nil + --table.remove(objcarriers_id, 1) + --second_obj = true + --end + --if(string.find(text, "The Allies have secured a gold crate!")) then + --if firstflag == false then + --local x = 1 + --for index in pairs(objcarriers_id) do + --if objcarriers[objcarriers_id[x]] == true then + --local redflag = et.gentity_get(objcarriers_id[x], "ps.powerups", 5) + --if redflag == 0 then + --local name = et.gentity_get(objcarriers_id[x], "pers.netname") + --et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured the first Gold Crate!\"\n") + --objcarriers[objcarriers_id[x]] = nil + --table.remove(objcarriers_id, x) + --end + --end + --x = x + 1 + --end + --firstflag = true + --elseif firstflag == true then + --local name = et.gentity_get(objcarriers_id[1], "pers.netname") + --et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured the second Gold Crate!\"\n") + --objcarriers[objcarriers_id[1]] = nil + --table.remove(objcarriers_id, 1) + --end + --end + --end -- end decay_b7 alternate script + + if mapname == "te_escape2" then + if(string.find(text, "team_CTF_redflag")) then + local i, j = string.find(text, "%d+") + local id = tonumber(string.sub(text, i, j)) + local team = tonumber(et.gentity_get(id, "sess.sessionTeam")) + local name = et.gentity_get(id, "pers.netname") + if team == 2 then + objcarriers[id] = true + table.insert(objcarriers_id, id) + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the ^1Unholy Grail^7!\"\n") + elseif team == 1 then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the ^1Unholy Grail^7!\"\n") + end + end + if(string.find(text, "The Allied team escaped with the Unholy Grail")) then + local name = et.gentity_get(objcarriers_id[1], "pers.netname") + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured the ^1Unholy Grail^7!\"\n") + objcarriers[objcarriers_id[1]] = nil + table.remove(objcarriers_id, 1) + end + end -- end te_escape2 + + if mapname == "radar_phx_b_3" or (string.find(mapname, "radar_truck")) then + if(string.find(text, "team_CTF_redflag")) then + local i, j = string.find(text, "%d+") + local id = tonumber(string.sub(text, i, j)) + local team = tonumber(et.gentity_get(id, "sess.sessionTeam")) + local name = et.gentity_get(id, "pers.netname") + if team == 2 then + doccarriers[id] = true + table.insert(doccarriers_id, id) + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the Axis Documents!\"\n") + elseif team == 1 then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the Axis Documents!\"\n") + end + end + if(string.find(text, "Allies have secured the Documents")) then + local name = et.gentity_get(doccarriers_id[1], "pers.netname") + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured the Axis Documents!\"\n") + doccarriers[doccarriers_id[1]] = nil + table.remove(doccarriers_id, 1) + end + end -- end radar_phx_b_3 + + if mapname == "et_village" then + if(string.find(text, "team_CTF_redflag")) then + local i, j = string.find(text, "%d+") + local id = tonumber(string.sub(text, i, j)) + local team = tonumber(et.gentity_get(id, "sess.sessionTeam")) + local name = et.gentity_get(id, "pers.netname") + if team == 2 then + goldcarriers[id] = true + table.insert(goldcarriers_id, id) + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the Gold!\"\n") + elseif team == 1 then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the Gold!\"\n") + end + end + if(string.find(text, "Allied team has escaped with the gold!")) then + local name = et.gentity_get(goldcarriers_id[1], "pers.netname") + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured the Gold!\"\n") + goldcarriers[goldcarriers_id[1]] = nil + table.remove(goldcarriers_id, 1) + end + end -- end et_village + + if mapname == "1944_beach" then + if(string.find(text, "team_CTF_redflag")) then + local i, j = string.find(text, "%d+") + local id = tonumber(string.sub(text, i, j)) + local team = tonumber(et.gentity_get(id, "sess.sessionTeam")) + local name = et.gentity_get(id, "pers.netname") + if team == 2 then + doccarriers[id] = true + table.insert(doccarriers_id, id) + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the Axis Documents!\"\n") + elseif team == 1 then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the Axis Documents!\"\n") + end + end + if(string.find(text, "Allies have transmitted the documents")) then + local name = et.gentity_get(doccarriers_id[1], "pers.netname") + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured the Axis Documents!\"\n") + doccarriers[doccarriers_id[1]] = nil + table.remove(doccarriers_id, 1) + end + end -- end 1944_beach + + if mapname == "et_brewdog" then + if(string.find(text, "team_CTF_redflag")) then + local i, j = string.find(text, "%d+") + local id = tonumber(string.sub(text, i, j)) + local team = tonumber(et.gentity_get(id, "sess.sessionTeam")) + local name = et.gentity_get(id, "pers.netname") + if team == 2 then + doccarriers[id] = true + table.insert(doccarriers_id, id) + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the Quiz Answers!\"\n") + elseif team == 1 then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the Quiz Answers!\"\n") + end + end + if(string.find(text, "Allies have transmitted the Quiz Answers!")) then + local name = et.gentity_get(doccarriers_id[1], "pers.netname") + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured the Quiz Answers!\"\n") + doccarriers[doccarriers_id[1]] = nil + table.remove(doccarriers_id, 1) + end + end -- end et_brewdog + + if (string.find(mapname, "_ice")) then + if(string.find(text, "team_CTF_blueflag")) then + local i, j = string.find(text, "%d+") + local id = tonumber(string.sub(text, i, j)) + local team = tonumber(et.gentity_get(id, "sess.sessionTeam")) + local name = et.gentity_get(id, "pers.netname") + if team == 1 then + doccarriers[id] = true + table.insert(doccarriers_id, id) + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the Secret War Documents!\"\n") + elseif team == 2 then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the Secret War Documents!\"\n") + end + end + if(string.find(text, "The Axis team has transmited the Secret")) then + local name = et.gentity_get(doccarriers_id[1], "pers.netname") + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured the Secret War Documents!\"\n") + doccarriers[doccarriers_id[1]] = nil + table.remove(doccarriers_id, 1) + end + end -- end et_ice + + if mapname == "warbell" then + if(string.find(text, "team_CTF_blueflag")) then + local i, j = string.find(text, "%d+") + local id = tonumber(string.sub(text, i, j)) + local team = tonumber(et.gentity_get(id, "sess.sessionTeam")) + local name = et.gentity_get(id, "pers.netname") + if team == 1 then + objcarriers[id] = true + table.insert(objcarriers_id, id) + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the ^1Book of Death^7!\"\n") + elseif team == 2 then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the ^1Book of Death^7!\"\n") + end + end + if(string.find(text, "Axis have delivered the Book of Death")) then + local name = et.gentity_get(objcarriers_id[1], "pers.netname") + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured the ^1Book of Death^7!\"\n") + objcarriers[objcarriers_id[1]] = nil + table.remove(objcarriers_id, 1) + end + end -- end warbell + + if mapname == "etl_warbell" then + if(string.find(text, "team_CTF_blueflag")) then + local i, j = string.find(text, "%d+") + local id = tonumber(string.sub(text, i, j)) + local team = tonumber(et.gentity_get(id, "sess.sessionTeam")) + local name = et.gentity_get(id, "pers.netname") + if team == 1 then + objcarriers[id] = true + table.insert(objcarriers_id, id) + if second_obj == false then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the ^1Book of Death^7!\"\n") + else + if third_obj == false then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the First Sacrificial Armor piece (Shoe)!\"\n") + else + if fourth_obj == false then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the Second Sacrificial Armor piece (Chest)!\"\n") + else + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7stole the Third Sacrificial Armor piece (Sword)!\"\n") + end + end + end + elseif team == 2 then + if second_obj == false then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the ^1Book of Death^7!\"\n") + else + if third_obj == false then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the First Sacrificial Armor piece (Shoe)!\"\n") + else + if fourth_obj == false then + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the Second Sacrificial Armor piece (Chest)!\"\n") + else + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7returned the Third Sacrificial Armor piece (Sword)!\"\n") + end + end + end + end + end + if(string.find(text, "Axis have delivered the Book of Death")) then + local name = et.gentity_get(objcarriers_id[1], "pers.netname") + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7secured the ^1Book of Death^7!\"\n") + objcarriers[objcarriers_id[1]] = nil + table.remove(objcarriers_id, 1) + second_obj = true + end + if(string.find(text, "First Sacrifice performed!")) then + local name = et.gentity_get(objcarriers_id[1], "pers.netname") + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7performed the First Sacrifice!\"\n") + objcarriers[objcarriers_id[1]] = nil + table.remove(objcarriers_id, 1) + third_obj = true + end + if(string.find(text, "Second Sacrifice performed!")) then + local name = et.gentity_get(objcarriers_id[1], "pers.netname") + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7performed the Second Sacrifice!\"\n") + objcarriers[objcarriers_id[1]] = nil + table.remove(objcarriers_id, 1) + fourth_obj = true + end + if(string.find(text, "Third Sacrifice performed!")) then + local name = et.gentity_get(objcarriers_id[1], "pers.netname") + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7performed the Third Sacrifice!\"\n") + objcarriers[objcarriers_id[1]] = nil + table.remove(objcarriers_id, 1) + end + end -- end etl_warbell +end + +function et_Obituary(victim, killer, mod) + if mapname == "radar" then + objcarriers[victim] = nil + local x = 1 + for index in pairs(objcarriers_id) do + if objcarriers_id[x] == victim then + table.remove(objcarriers_id, x) + end + x = x + 1 + end + end + if mapname == "goldrush" or mapname == "uje_goldrush" or mapname == "goldrush-ga" or mapname == "goldrush-gals" then + goldcarriers[victim] = nil + local x = 1 + for index in pairs(goldcarriers_id) do + if goldcarriers_id[x] == victim then + table.remove(goldcarriers_id, x) + end + x = x + 1 + end + end + if (string.find(mapname, "frostbite")) then + doccarriers[victim] = nil + if doccarriers_id[1] == victim then + table.remove(doccarriers_id, 1) + end + end + if (string.find(mapname, "missile")) then + objcarriers[victim] = nil + if objcarriers_id[1] == victim then + table.remove(objcarriers_id, 1) + end + end + if (string.find(mapname, "sp_delivery")) then + goldcarriers[victim] = nil + local x = 1 + for index in pairs(goldcarriers_id) do + if goldcarriers_id[x] == victim then + table.remove(goldcarriers_id, x) + end + x = x + 1 + end + end + if mapname == "sw_goldrush_te" then + goldcarriers[victim] = nil + if goldcarriers_id[1] == victim then + table.remove(goldcarriers_id, 1) + end + end + if mapname == "bremen_b3" then + objcarriers[victim] = nil + if objcarriers_id[1] == victim then + table.remove(objcarriers_id, 1) + end + end + if (string.find(mapname, "adlernest")) then + doccarriers[victim] = nil + if doccarriers_id[1] == victim then + table.remove(doccarriers_id, 1) + end + end + if mapname == "et_beach" then + doccarriers[victim] = nil + if doccarriers_id[1] == victim then + table.remove(doccarriers_id, 1) + end + end + if mapname == "venice" then + objcarriers[victim] = nil + if objcarriers_id[1] == victim then + table.remove(objcarriers_id, 1) + end + end + if mapname == "library_b3" then + doccarriers[victim] = nil + if doccarriers_id[1] == victim then + table.remove(doccarriers_id, 1) + end + end + if mapname == "pirates" then + goldcarriers[victim] = nil + local x = 1 + for index in pairs(goldcarriers_id) do + if goldcarriers_id[x] == victim then + table.remove(goldcarriers_id, x) + end + x = x + 1 + end + end + + --if mapname == "karsiah_te2" then + --objcarriers[victim] = nil + --local x = 1 + --for index in pairs(objcarriers_id) do + --if objcarriers_id[x] == victim then + --table.remove(objcarriers_id, x) + --end + --x = x + 1 + --end + --end + + -- karsiah_te2 alternate script (karsiah_te3) + if mapname == "karsiah_te2" then + objcarriers[victim] = nil + if objcarriers_id[1] == victim then + table.remove(objcarriers_id, 1) + end + end + + if mapname == "karsiah_te3" then + objcarriers[victim] = nil + if objcarriers_id[1] == victim then + table.remove(objcarriers_id, 1) + end + end + + if mapname == "et_ufo_final" then + doccarriers[victim] = nil + if doccarriers_id[1] == victim then + table.remove(doccarriers_id, 1) + end + end + if mapname == "sos_secret_weapon" then + objcarriers[victim] = nil + if objcarriers_id[1] == victim then + table.remove(objcarriers_id, 1) + end + end + if mapname == "falkenstein_b3" then + objcarriers[victim] = nil + if objcarriers_id[1] == victim then + table.remove(objcarriers_id, 1) + end + end + if (string.find(mapname, "decay")) then + objcarriers[victim] = nil + if objcarriers_id[1] == victim then + table.remove(objcarriers_id, 1) + end + end + + --decay_b7 alternate script + --if mapname == "decay_b7" then + --objcarriers[victim] = nil + --local x = 1 + --for index in pairs(objcarriers_id) do + --if objcarriers_id[x] == victim then + --table.remove(objcarriers_id, x) + --end + --x = x + 1 + --end + --end + + if mapname == "te_escape2" then + objcarriers[victim] = nil + if objcarriers_id[1] == victim then + table.remove(objcarriers_id, 1) + end + end + if mapname == "radar_phx_b_3" or (string.find(mapname, "radar_truck")) then + doccarriers[victim] = nil + if doccarriers_id[1] == victim then + table.remove(doccarriers_id, 1) + end + end + if mapname == "et_village" then + goldcarriers[victim] = nil + if goldcarriers_id[1] == victim then + table.remove(goldcarriers_id, 1) + end + end + if (string.find(mapname, "_ice")) then + doccarriers[victim] = nil + if doccarriers_id[1] == victim then + table.remove(doccarriers_id, 1) + end + end + if mapname == "1944_beach" then + doccarriers[victim] = nil + if doccarriers_id[1] == victim then + table.remove(doccarriers_id, 1) + end + end + if mapname == "et_brewdog" then + doccarriers[victim] = nil + if doccarriers_id[1] == victim then + table.remove(doccarriers_id, 1) + end + end + if (string.find(mapname, "warbell")) then + objcarriers[victim] = nil + if objcarriers_id[1] == victim then + table.remove(objcarriers_id, 1) + end + end +end + +function et_ClientDisconnect(i) + if mapname == "radar" then + objcarriers[i] = nil + local x = 1 + for index in pairs(objcarriers_id) do + if objcarriers_id[x] == i then + table.remove(objcarriers_id, x) + end + x = x + 1 + end + end + if mapname == "goldrush" or mapname == "uje_goldrush" or mapname == "goldrush-ga" or mapname == "goldrush-gals" then + goldcarriers[i] = nil + local x = 1 + for index in pairs(goldcarriers_id) do + if goldcarriers_id[x] == i then + table.remove(goldcarriers_id, x) + end + x = x + 1 + end + end + if (string.find(mapname, "frostbite")) then + doccarriers[i] = nil + if doccarriers_id[1] == i then + table.remove(doccarriers_id, 1) + end + end + if (string.find(mapname, "missile")) then + objcarriers[i] = nil + if objcarriers_id[1] == i then + table.remove(objcarriers_id, 1) + end + end + if (string.find(mapname, "sp_delivery")) then + goldcarriers[i] = nil + local x = 1 + for index in pairs(goldcarriers_id) do + if goldcarriers_id[x] == i then + table.remove(goldcarriers_id, x) + end + x = x + 1 + end + end + if mapname == "sw_goldrush_te" then + goldcarriers[i] = nil + if goldcarriers_id[1] == i then + table.remove(goldcarriers_id, 1) + end + end + if mapname == "bremen_b3" then + objcarriers[i] = nil + if objcarriers_id[1] == i then + table.remove(objcarriers_id, 1) + end + end + if (string.find(mapname, "adlernest")) then + doccarriers[i] = nil + if doccarriers_id[1] == i then + table.remove(doccarriers_id, 1) + end + end + if mapname == "et_beach" then + doccarriers[i] = nil + if doccarriers_id[1] == i then + table.remove(doccarriers_id, 1) + end + end + if mapname == "venice" then + objcarriers[i] = nil + if objcarriers_id[1] == i then + table.remove(objcarriers_id, 1) + end + end + if mapname == "library_b3" then + doccarriers[i] = nil + if doccarriers_id[1] == i then + table.remove(doccarriers_id, 1) + end + end + if mapname == "pirates" then + goldcarriers[i] = nil + local x = 1 + for index in pairs(goldcarriers_id) do + if goldcarriers_id[x] == i then + table.remove(goldcarriers_id, x) + end + x = x + 1 + end + end + + --if mapname == "karsiah_te2" then + --objcarriers[i] = nil + --local x = 1 + --for index in pairs(objcarriers_id) do + --if objcarriers_id[x] == i then + --table.remove(objcarriers_id, x) + --end + --x = x + 1 + --end + --end + + -- karsiah_te2 alternate script (karsiah_te3) + if mapname == "karsiah_te2" then + objcarriers[i] = nil + if objcarriers_id[1] == i then + table.remove(objcarriers_id, 1) + end + end + + if mapname == "karsiah_te3" then + objcarriers[i] = nil + if objcarriers_id[1] == i then + table.remove(objcarriers_id, 1) + end + end + + if mapname == "et_ufo_final" then + doccarriers[i] = nil + if doccarriers_id[1] == i then + table.remove(doccarriers_id, 1) + end + end + if mapname == "sos_secret_weapon" then + objcarriers[i] = nil + if objcarriers_id[1] == i then + table.remove(objcarriers_id, 1) + end + end + if mapname == "falkenstein_b3" then + objcarriers[i] = nil + if objcarriers_id[1] == i then + table.remove(objcarriers_id, 1) + end + end + if (string.find(mapname, "decay")) then + objcarriers[i] = nil + if objcarriers_id[1] == i then + table.remove(objcarriers_id, 1) + end + end + + -- decay_b7 alternate script + --if mapname == "decay_b7" then + --objcarriers[i] = nil + --local x = 1 + --for index in pairs(objcarriers_id) do + --if objcarriers_id[x] == i then + --table.remove(objcarriers_id, x) + --end + --x = x + 1 + --end + --end + + if mapname == "te_escape2" then + objcarriers[i] = nil + if objcarriers_id[1] == i then + table.remove(objcarriers_id, 1) + end + end + if mapname == "radar_phx_b_3" or (string.find(mapname, "radar_truck")) then + doccarriers[i] = nil + if doccarriers_id[1] == i then + table.remove(doccarriers_id, 1) + end + end + if mapname == "et_village" then + goldcarriers[i] = nil + if goldcarriers_id[1] == i then + table.remove(goldcarriers_id, 1) + end + end + if (string.find(mapname, "_ice")) then + doccarriers[i] = nil + if doccarriers_id[1] == i then + table.remove(doccarriers_id, 1) + end + end + if mapname == "1944_beach" then + doccarriers[i] = nil + if doccarriers_id[1] == i then + table.remove(doccarriers_id, 1) + end + end + if mapname == "et_brewdog" then + doccarriers[i] = nil + if doccarriers_id[1] == i then + table.remove(doccarriers_id, 1) + end + end + if (string.find(mapname, "warbell")) then + objcarriers[i] = nil + if objcarriers_id[1] == i then + table.remove(objcarriers_id, 1) + end + end +end diff --git a/suddendeath.lua b/suddendeath.lua new file mode 100644 index 0000000..175a95c --- /dev/null +++ b/suddendeath.lua @@ -0,0 +1,693 @@ +-- x0rnn: added dynamite "sudden death" mode +-- modified Quake 3 sudden death sound: https://github.com/x0rnn/etpro/blob/master/lua/sudden_death.wav + +--------------------------------- +------- Dynamite counter -------- +------- By Necromancer -------- +------- 5/04/2009 -------- +------- www.usef-et.org -------- +--------------------------------- + +SHOW = 0 +-- 0 means disable timer +-- 1 means only the team that planted the dyno +-- 2 means everyone + +-- This script can be freely used and modified as long as the original author/s are mentioned (and their homepage: www.usef-et.org) + +mapname = "" +gametype = 0 +gamestate = -1 +maptime = 0 +mapstarted = false +paused = false +mapstart_time = 0 +paused_time = 0 +unpaused_time = 0 +stuck_time = 0 +gameFrameLevelTime = 0 +intervals = {[1]=0, [2]=0} +sudden_death = false +first_obj = false +first_obj_time = 0 +second_obj_time = 0 +first_obj_loc = "" +second_obj_loc = "" +dyna_counter = 0 +dyna_maps = {"battery", "sw_battery", "fueldump", "braundorf_b4", "etl_braundorf", "mp_sub_rc1", "sub2", "sw_oasis_b3", "oasis", "tc_base", "etl_base", "erdenberg_t2"} +plants = {} +defuses = {} +dyna_pos = {} + +-- Constans +COLOR = {} +COLOR.PLACE = '^8' +COLOR.TEXT = '^w' +COLOR.TIME = '^8' -- this constant is changing in the print_message() function + +CHAT = "bp" +POPUP = "legacy" + +timer = {} + +function isEmpty(str) + if str == nil or str == '' then + return 0 + end + return str +end + +function roundNum(num, n) -- timelimit rounds to 6 decimals + local mult = 10^(n or 0) + return math.floor(num * mult + 0.5) / mult +end + +function has_value (tab, val) + for index, value in ipairs(tab) do + if value == val then + return true + end + end + return false +end + +function calcDist(pos1, pos2) + local dist2 = (pos1[1]-pos2[1])^2 + (pos1[2]-pos2[2])^2 + ((pos1[3]-pos2[3])*2)^2 + return math.sqrt(dist2) +end + +function et_InitGame(levelTime, randomSeed, restart) + et.RegisterModname("suddendeath.lua" .. et.FindSelf()) + mapname = string.lower(et.trap_Cvar_Get("mapname")) + gametype = tonumber(et.trap_Cvar_Get("g_gametype")) + maptime = tonumber(et.trap_Cvar_Get("timelimit")) + mapstart_time = et.trap_GetConfigstring(et.CS_LEVEL_START_TIME) +end + +function et_RunFrame( levelTime ) + gamestate = tonumber(et.trap_Cvar_Get("gamestate")) + if gametype == 3 then + if gamestate == 0 then + if mapstarted == false then + mapstarted = true + local winnerteam = tonumber(et.trap_Cvar_Get("sd_winnerteam")) or 1 + if has_value(dyna_maps, mapname) then + if tonumber(et.trap_Cvar_Get("g_currentRound")) == 1 then -- round 2 + if winnerteam == 2 then -- 2 = allies, 1 = axis + et.trap_Cvar_Set("timelimit", maptime - 0.5) + maptime = tonumber(et.trap_Cvar_Get("timelimit")) + else + if et.trap_Cvar_Get("sd_bonustime") > et.trap_Cvar_Get("sd_defaulttime") then -- sudden death was activated, but dynamite defused in overtime + et.trap_Cvar_Set("timelimit", et.trap_Cvar_Get("sd_defaulttime")) + maptime = tonumber(et.trap_Cvar_Get("timelimit")) + end + end + else + et.trap_Cvar_Set("sd_defaulttime", maptime) + et.trap_Cvar_Set("sd_bonustime", 0) + et.trap_Cvar_Set("sd_winnerteam", 1) + end + end + end + end + end + gameFrameLevelTime = levelTime + current = os.time() + for dyno, temp in pairs(timer) do + if timer[dyno]["time"] - current >= 0 then + for key,temp in pairs(timer[dyno]) do + if type(key) == "number" then + if timer[dyno]["time"] - current == key then + send_print(timer,dyno,key) + timer[dyno][key] = nil + --et.G_LogPrint("dynamite key deleted: " .. dyno .." key: " .. key .. "\n") + end + end + end + + else + --et.G_LogPrint("dynamite out: " .. dyno .. "\n") + place_destroyed(timer[dyno]["place"]) + --timer[dyno] = nil + end + end + + if math.fmod(levelTime, 1000) == 0 then + if gamestate == 0 then + if paused == true then + local cs = et.trap_GetConfigstring(11) + if intervals[1] == 0 then + intervals[1] = cs + elseif intervals[1] ~= 0 then + if intervals[2] == 0 then + intervals[2] = cs + elseif intervals[2] ~= 0 then + intervals[1] = intervals[2] + intervals[2] = cs + if intervals[1] == intervals[2] then + paused = false + unpaused_time = et.trap_Milliseconds() - 1000 + stuck_time = unpaused_time - paused_time + stuck_time + intervals[1] = 0 + intervals[2] = 0 + end + end + end + end + + if sudden_death == true then + for i=0,tonumber(et.trap_Cvar_Get("sv_maxclients"))-1 do + local team = tonumber(et.gentity_get(i, "sess.sessionTeam")) + if team == 2 then + if et.gentity_get(i, "sess.PlayerType") == 2 then + local health = tonumber(et.gentity_get(i, "health")) + if health > 0 then + local pos = et.gentity_get(i, "r.currentOrigin") + local dist = calcDist(pos, dyna_pos) + if dist < 600 then + if et.gentity_get(i, "ps.ammoclip", 15) ~= 0 then + et.gentity_set(i, "ps.ammoclip", 15, 0) + et.RemoveWeaponFromPlayer(i, 15) + --et.RemoveWeaponFromPlayer(i, 21) + end + else + if et.gentity_get(i, "ps.ammoclip", 15) == 0 then + et.gentity_set(i, "ps.ammoclip", 15, 1) + et.AddWeaponToPlayer(i, 15, 1, 1, 0) + --et.AddWeaponToPlayer(i, 21, 1, 1, 0) + end + end + end + end + end + end + end + + elseif gamestate == et.GS_INTERMISSION then + if gametype == 3 then + local winnerteam = tonumber(isEmpty(et.Info_ValueForKey(et.trap_GetConfigstring(et.CS_MULTI_MAPWINNER), "w"))) + 1 -- change from scripting value for winner (0==AXIS, 1==ALLIES) to spawnflag value + et.trap_Cvar_Set("sd_winnerteam", winnerteam) + end + end + end +end + +function et_WeaponFire(clientNum, weapon) + if sudden_death == true then + local team = tonumber(et.gentity_get(clientNum, "sess.sessionTeam")) + if team == 2 then + if et.gentity_get(clientNum, "sess.PlayerType") == 2 then + local health = tonumber(et.gentity_get(clientNum, "health")) + if health > 0 then + local pos = et.gentity_get(clientNum, "r.currentOrigin") + local dist = calcDist(pos, dyna_pos) + if dist < 600 then + if weapon == 21 then + return 1 + end + end + end + end + end + end +end + +function et_ConsoleCommand() + local arg = et.trap_Argv(1) + if arg == "pause" then + paused = true + paused_time = et.trap_Milliseconds() + end + if arg == "unpause" then + paused = false + unpaused_time = et.trap_Milliseconds() + stuck_time = unpaused_time - paused_time + stuck_time + 10000 + end + return(0) +end + +function place_destroyed(place) -- removes any dynamite timers that were planted on this objective + for dynamite, temp in pairs(timer) do + if timer[dynamite]["place"] == place then + timer[dynamite] = nil + end + end +end + +function send_print(timer,dyno,ttime) + if SHOW == 0 then return end + if SHOW == 1 then + for player=0, tonumber(et.trap_Cvar_Get("sv_maxclients"))-1, 1 do + if et.gentity_get(player, "sess.sessionTeam") == timer[dyno]["team"] then + print_message(player, ttime, timer[dyno]["place"]) + end + end + else + print_message(-1, ttime, timer[dyno]["place"]) + end +end + +function print_message(slot, ttime, place) + if ttime > 3 then + COLOR.TIME = '^8' + else + COLOR.TIME = '^1' + end + + if ttime == -1 then + et.trap_SendServerCommand( slot , string.format('%s \"%s"\n',CHAT, COLOR.TEXT .. "Dynamite planted at " .. COLOR.PLACE .. place)) + elseif ttime == -2 then + et.trap_SendServerCommand( slot , string.format('%s \"%s"\n',CHAT, COLOR.TEXT .. "Dynamite defused at " .. COLOR.PLACE .. place)) + elseif ttime > 0 then + et.trap_SendServerCommand( slot , string.format('%s \"%s"\n',CHAT, COLOR.TEXT .. "Dynamite at " .. COLOR.PLACE .. place .. COLOR.TEXT .. " exploding in " .. COLOR.TIME ..ttime .. COLOR.TEXT .. " seconds!")) + end +end + +function et_Print(text) + if (string.find(text, "min Timebonus!") or string.find(text, "mins ^oTime Bonus!")) and not string.find(text, "say") then + if sudden_death == true then + sudden_death = false + et.trap_Cvar_Set("timelimit", tonumber(et.trap_Cvar_Get("timelimit")) - 0.5) + end + maptime = tonumber(et.trap_Cvar_Get("timelimit")) + end + + if string.find(text, "Dynamite_Plant") and not string.find(text, "say") then + local junk1,junk2,id,loc = string.find(text, "^Dynamite_Plant:%s+(%d+)%s+([^\n]+)") + table.insert(plants, {time=et.trap_Milliseconds(), name=et.gentity_get(id, "pers.netname"), location=loc, pos=et.gentity_get(id, "r.currentOrigin")}) + elseif string.find(text, "Dynamite_Diffuse") and not string.find(text, "say") then + local junk1,junk2,id,loc = string.find(text, "^Dynamite_Diffuse:%s+(%d+)%s+([^\n]+)") + table.insert(defuses, {time=et.trap_Milliseconds(), name=et.gentity_get(id, "pers.netname"), location=loc}) + end + + --legacy popup: axis planted "the Old City MG Nest" + start,stop = string.find(text, POPUP .. " popup:",1,true) -- check that its not any player print, trying to manipulate the dyno counter + if start and stop then + start,stop,team,plant = string.find(text, POPUP .. " popup: (%S+) planted \"([^%\"]*)\"") + if start and stop then -- dynamite planted + local timestamp = et.trap_Milliseconds() + if team == "axis" then team = 1 + else team = 2 end + index = #timer+1 + timer[index] = {} + timer[index]["team"] = team + timer[index]["place"] = plant + timer[index]["time"] = os.time() +30 + + timer[index][20] = true + timer[index][10] = true + timer[index][5] = true + timer[index][3] = true + timer[index][2] = true + timer[index][1] = true + timer[index][0] = true + + print_message(-1, -1, timer[index]["place"]) + --et.G_LogPrint("dynamite set: " .. index .. "\n") + + if mapname == "battery" or mapname == "sw_battery" or mapname == "fueldump" or mapname == "braundorf_b4" or mapname == "etl_braundorf" or mapname == "mp_sub_rc1" or mapname == "sub2" then + if plant == "the Gun Controls" or plant == "the Fuel Dump" or plant == "the Bunker Controls" or plant == "the Axis Submarine" or plant == "the axis submarine" then + local timelimit = tonumber(et.trap_Cvar_Get("timelimit")) * 1000 * 60 - 2000 --counts 2 seconds more for some reason... + local timeleft = roundNum(timelimit - ((gameFrameLevelTime - stuck_time) - mapstart_time), 6) + if timeleft < 30000 then + if sudden_death == false then + sudden_death = true + for i, dyna in ipairs(plants) do + if dyna.time >= timestamp - 5 and dyna.time <= timestamp then + if plant == dyna.location then + dyna_pos = dyna.pos + break + end + end + end + et.G_LogPrint("LUA event: " .. mapname .. " Dynamite sudden death activated!\n") + et.trap_SendServerCommand(-1, "chat \"^1Dynamite Sudden Death mode is activated!\"") + et.trap_Cvar_Set("timelimit", tonumber(et.trap_Cvar_Get("timelimit")) + 0.5) + et.G_globalSound("sound/misc/sudden_death.wav") + for j=0, tonumber(et.trap_Cvar_Get("sv_maxclients"))-1 do + local team = tonumber(et.gentity_get(j, "sess.sessionTeam")) + if team == 2 then + if et.gentity_get(j, "sess.PlayerType") == 2 then + local health = tonumber(et.gentity_get(j, "health")) + if health > 0 then + local pos = et.gentity_get(j, "r.currentOrigin") + local dist = calcDist(pos, dyna_pos) + if dist < 600 then + if et.gentity_get(j, "ps.ammoclip", 15) ~= 0 then + et.gentity_set(j, "ps.ammoclip", 15, 0) + et.RemoveWeaponFromPlayer(j, 15) + --et.RemoveWeaponFromPlayer(j, 21) + end + else + if et.gentity_get(j, "ps.ammoclip", 15) == 0 then + et.gentity_set(j, "ps.ammoclip", 15, 1) + et.AddWeaponToPlayer(j, 15, 1, 1, 0) + --et.AddWeaponToPlayer(j, 21, 1, 1, 0) + end + end + et.trap_SendServerCommand(j, "chat \"^1Sudden Death mode is activated! Can't plant additional dynamites!\"") + end + end + end + end + end + end + end + end + if mapname == "sw_oasis_b3" or mapname == "oasis" or mapname == "tc_base" or mapname == "etl_base" or mapname == "erdenberg_t2" then + if first_obj == true then + if plant == "the South PAK 75mm Gun" or plant == "the North PAK 75mm Gun" or plant == "the South Anti-Tank Gun" or plant == "the North Anti-Tank Gun" or plant == "the West Flak88" or plant == "the East Flak88" or plant == "the South Radar [02]" or plant == "the North Radar [01]" or plant == "the South Radar" or plant == "the North Radar" then + local timelimit = tonumber(et.trap_Cvar_Get("timelimit")) * 1000 * 60 - 2000 --counts 2 seconds more for some reason... + local timeleft = roundNum(timelimit - ((gameFrameLevelTime - stuck_time) - mapstart_time), 6) + if timeleft < 30000 then + if sudden_death == false then + sudden_death = true + for i, dyna in ipairs(plants) do + if dyna.time >= timestamp - 10 and dyna.time <= timestamp then + if plant == dyna.location then + dyna_pos = dyna.pos + break + end + end + end + et.G_LogPrint("LUA event: " .. mapname .. " Dynamite sudden death activated!\n") + et.trap_SendServerCommand(-1, "chat \"^1Dynamite Sudden Death mode is activated!\"") + et.trap_Cvar_Set("timelimit", tonumber(et.trap_Cvar_Get("timelimit")) + 0.5) + et.G_globalSound("sound/misc/sudden_death.wav") + for j=0, tonumber(et.trap_Cvar_Get("sv_maxclients"))-1 do + local team = tonumber(et.gentity_get(j, "sess.sessionTeam")) + if team == 2 then + if et.gentity_get(j, "sess.PlayerType") == 2 then + local health = tonumber(et.gentity_get(j, "health")) + if health > 0 then + local pos = et.gentity_get(j, "r.currentOrigin") + local dist = calcDist(pos, dyna_pos) + if dist < 600 then + if et.gentity_get(j, "ps.ammoclip", 15) ~= 0 then + et.gentity_set(j, "ps.ammoclip", 15, 0) + et.RemoveWeaponFromPlayer(j, 15) + --et.RemoveWeaponFromPlayer(j, 21) + end + else + if et.gentity_get(j, "ps.ammoclip", 15) == 0 then + et.gentity_set(j, "ps.ammoclip", 15, 1) + et.AddWeaponToPlayer(j, 15, 1, 1, 0) + --et.AddWeaponToPlayer(j, 21, 1, 1, 0) + end + end + et.trap_SendServerCommand(j, "chat \"^1Sudden Death mode is activated! Can't plant additional dynamites!\"") + end + end + end + end + end + end + end + else + if plant == "the South PAK 75mm Gun" or plant == "the North PAK 75mm Gun" or plant == "the South Anti-Tank Gun" or plant == "the North Anti-Tank Gun" or plant == "the West Flak88" or plant == "the East Flak88" or plant == "the South Radar [02]" or plant == "the North Radar [01]" or plant == "the South Radar" or plant == "the North Radar" then + local timelimit = tonumber(et.trap_Cvar_Get("timelimit")) * 1000 * 60 - 2000 --counts 2 seconds more for some reason... + local timeleft = roundNum(timelimit - ((gameFrameLevelTime - stuck_time) - mapstart_time), 6) + if timeleft < 60000 then + if first_obj_time == 0 then + first_obj_time = timestamp + first_obj_loc = plant + dyna_counter = dyna_counter + 1 + else + if plant == first_obj_loc then + dyna_counter = dyna_counter + 1 + first_obj_time = timestamp + else + second_obj_time = timestamp + second_obj_loc = plant + if timeleft < 30000 then + if sudden_death == false then + sudden_death = true + for i, dyna in ipairs(plants) do + if dyna.time >= timestamp - 10 and dyna.time <= timestamp then + if plant == dyna.location then + dyna_pos = dyna.pos + break + end + end + end + et.G_LogPrint("LUA event: " .. mapname .. " Dynamite sudden death activated!\n") + et.trap_SendServerCommand(-1, "chat \"^1Dynamite Sudden Death mode is activated!\"") + et.trap_Cvar_Set("timelimit", tonumber(et.trap_Cvar_Get("timelimit")) + 0.5) + et.G_globalSound("sound/misc/sudden_death.wav") + for j=0, tonumber(et.trap_Cvar_Get("sv_maxclients"))-1 do + local team = tonumber(et.gentity_get(j, "sess.sessionTeam")) + if team == 2 then + if et.gentity_get(j, "sess.PlayerType") == 2 then + local health = tonumber(et.gentity_get(j, "health")) + if health > 0 then + local pos = et.gentity_get(j, "r.currentOrigin") + local dist = calcDist(pos, dyna_pos) + if dist < 600 then + if et.gentity_get(j, "ps.ammoclip", 15) ~= 0 then + et.gentity_set(j, "ps.ammoclip", 15, 0) + et.RemoveWeaponFromPlayer(j, 15) + --et.RemoveWeaponFromPlayer(j, 21) + end + else + if et.gentity_get(j, "ps.ammoclip", 15) == 0 then + et.gentity_set(j, "ps.ammoclip", 15, 1) + et.AddWeaponToPlayer(j, 15, 1, 1, 0) + --et.AddWeaponToPlayer(j, 21, 1, 1, 0) + end + end + et.trap_SendServerCommand(j, "chat \"^1Dynamite Sudden Death mode is activated! Can't plant additional dynamites!\"") + end + end + end + end + end + end + end + end + end + end + end + end + end + + start,stop,team,plant = string.find(text, POPUP .. " popup: (%S+) defused \"([^%\"]*)\"") + if start and stop then -- dynamite defused + local timestamp = et.trap_Milliseconds() + if team == "axis" then team = 1 + else team = 2 end + + if mapname == "battery" or mapname == "sw_battery" or mapname == "fueldump" or mapname == "braundorf_b4" or mapname == "etl_braundorf" or mapname == "mp_sub_rc1" or mapname == "sub2" then + if plant == "the Gun Controls" or plant == "the Fuel Dump" or plant == "the Bunker Controls" or plant == "the Axis Submarine" or plant == "the axis submarine" then + if sudden_death == true then + local timelimit = tonumber(et.trap_Cvar_Get("timelimit")) * 1000 * 60 - 2000 --counts 2 seconds more for some reason... + local timeleft = roundNum(timelimit - ((gameFrameLevelTime - stuck_time) - mapstart_time), 6) + if gametype == 4 or gametype == 6 then + if (timelimit - 0.033333) - timeleft < (maptime * 1000 * 60) then + sudden_death = false + et.trap_Cvar_Set("timelimit", maptime) + for j=0, tonumber(et.trap_Cvar_Get("sv_maxclients"))-1 do + local team = tonumber(et.gentity_get(j, "sess.sessionTeam")) + if team == 2 then + if et.gentity_get(j, "sess.PlayerType") == 2 then + local health = tonumber(et.gentity_get(j, "health")) + if health > 0 then + if et.gentity_get(j, "ps.ammoclip", 15) == 0 then + et.gentity_set(j, "ps.ammoclip", 15, 1) + et.AddWeaponToPlayer(j, 15, 1, 1, 0) + --et.AddWeaponToPlayer(j, 21, 1, 1, 0) + end + end + end + end + end + elseif (timelimit - 0.033333) - timeleft >= (maptime * 1000 * 60) then + et.trap_Cvar_Set("timelimit", 0.0001) + et.G_LogPrint("LUA event: " .. mapname .. " Dynamite sudden death, Axis defused!\n") + for i, dyna in ipairs(defuses) do + if dyna.time == timestamp -1 then + if plant == dyna.location then + et.trap_SendServerCommand(-1, "chat \"" .. dyna.name .. " ^7defused ^1" .. plant .. "^7!\"") + break + end + end + end + end + elseif gametype == 3 then + if (timelimit - 0.033333) - timeleft < (maptime * 1000 * 60) then + sudden_death = false + et.trap_Cvar_Set("timelimit", maptime) + for j=0, tonumber(et.trap_Cvar_Get("sv_maxclients"))-1 do + local team = tonumber(et.gentity_get(j, "sess.sessionTeam")) + if team == 2 then + if et.gentity_get(j, "sess.PlayerType") == 2 then + local health = tonumber(et.gentity_get(j, "health")) + if health > 0 then + if et.gentity_get(j, "ps.ammoclip", 15) == 0 then + et.gentity_set(j, "ps.ammoclip", 15, 1) + et.AddWeaponToPlayer(j, 15, 1, 1, 0) + --et.AddWeaponToPlayer(j, 21, 1, 1, 0) + end + end + end + end + end + elseif (timelimit - 0.033333) - timeleft >= (maptime * 1000 * 60) then + et.trap_Cvar_Set("sd_bonustime", roundNum(timelimit/1000/60 - timeleft/1000/60, 6)) + et.trap_Cvar_Set("timelimit", 0.0001) + et.G_LogPrint("LUA event: " .. mapname .. " Dynamite sudden death, Axis defused!\n") + for i, dyna in ipairs(defuses) do + if dyna.time >= timestamp - 10 and dyna.time <= timestamp then + if plant == dyna.location then + et.trap_SendServerCommand(-1, "chat \"" .. dyna.name .. " ^7defused ^1" .. plant .. "^7!\"") + break + end + end + end + end + end + end + end + end + if mapname == "sw_oasis_b3" or mapname == "oasis" or mapname == "tc_base" or mapname == "etl_base" or mapname == "erdenberg_t2" then + if plant == "the South PAK 75mm Gun" or plant == "the North PAK 75mm Gun" or plant == "the South Anti-Tank Gun" or plant == "the North Anti-Tank Gun" or plant == "the West Flak88" or plant == "the East Flak88" or plant == "the South Radar [02]" or plant == "the North Radar [01]" or plant == "the South Radar" or plant == "the North Radar" then + if sudden_death == true then + local timelimit = tonumber(et.trap_Cvar_Get("timelimit")) * 1000 * 60 - 2000 --counts 2 seconds more for some reason... + local timeleft = roundNum(timelimit - ((gameFrameLevelTime - stuck_time) - mapstart_time), 6) + if gametype == 4 or gametype == 6 then + if (timelimit - 0.033333) - timeleft < (maptime * 1000 * 60) then + if first_obj_loc == plant then + dyna_counter = dyna_counter - 1 + end + if dyna_counter == 0 or second_obj_loc == plant then + if dyna_counter == 0 then + first_obj_time = second_obj_time + first_obj_loc = second_obj_loc + second_obj_time = 0 + second_obj_loc = "" + elseif second_obj_loc == plant then + second_obj_time = 0 + second_obj_loc = "" + end + sudden_death = false + et.trap_Cvar_Set("timelimit", maptime) + for j=0, tonumber(et.trap_Cvar_Get("sv_maxclients"))-1 do + local team = tonumber(et.gentity_get(j, "sess.sessionTeam")) + if team == 2 then + if et.gentity_get(j, "sess.PlayerType") == 2 then + local health = tonumber(et.gentity_get(j, "health")) + if health > 0 then + if et.gentity_get(j, "ps.ammoclip", 15) == 0 then + et.gentity_set(j, "ps.ammoclip", 15, 1) + et.AddWeaponToPlayer(j, 15, 1, 1, 0) + --et.AddWeaponToPlayer(j, 21, 1, 1, 0) + end + end + end + end + end + end + elseif (timelimit - 0.033333) - timeleft >= (maptime * 1000 * 60) then + et.trap_Cvar_Set("timelimit", 0.0001) + et.G_LogPrint("LUA event: " .. mapname .. " Dynamite sudden death, Axis defused!\n") + for i, dyna in ipairs(defuses) do + if dyna.time >= timestamp - 10 and dyna.time <= timestamp then + if plant == dyna.location then + et.trap_SendServerCommand(-1, "chat \"" .. dyna.name .. " ^7defused ^1" .. plant .. "^7!\"") + break + end + end + end + end + elseif gametype == 3 then + if (timelimit - 0.033333) - timeleft < (maptime * 1000 * 60) then + if first_obj_loc == plant then + dyna_counter = dyna_counter - 1 + end + if dyna_counter == 0 or second_obj_loc == plant then + if dyna_counter == 0 then + first_obj_time = second_obj_time + first_obj_loc = second_obj_loc + second_obj_time = 0 + second_obj_loc = "" + elseif second_obj_loc == plant then + second_obj_time = 0 + second_obj_loc = "" + end + sudden_death = false + et.trap_Cvar_Set("timelimit", maptime) + for j=0, tonumber(et.trap_Cvar_Get("sv_maxclients"))-1 do + local team = tonumber(et.gentity_get(j, "sess.sessionTeam")) + if team == 2 then + if et.gentity_get(j, "sess.PlayerType") == 2 then + local health = tonumber(et.gentity_get(j, "health")) + if health > 0 then + if et.gentity_get(j, "ps.ammoclip", 15) == 0 then + et.gentity_set(j, "ps.ammoclip", 15, 1) + et.AddWeaponToPlayer(j, 15, 1, 1, 0) + --et.AddWeaponToPlayer(j, 21, 1, 1, 0) + end + end + end + end + end + end + elseif (timelimit - 0.033333) - timeleft >= (maptime * 1000 * 60) then + et.trap_Cvar_Set("sd_bonustime", roundNum(timelimit/1000/60 - timeleft/1000/60, 6)) + et.trap_Cvar_Set("timelimit", 0.0001) + et.G_LogPrint("LUA event: " .. mapname .. " Dynamite sudden death, Axis defused!\n") + for i, dyna in ipairs(defuses) do + if dyna.time >= timestamp - 10 and dyna.time <= timestamp then + if plant == dyna.location then + et.trap_SendServerCommand(-1, "chat \"" .. dyna.name .. " ^7defused ^1" .. plant .. "^7!\"") + break + end + end + end + end + end + else + if first_obj_loc == plant then + dyna_counter = dyna_counter - 1 + if dyna_counter == 0 then + first_obj_time = 0 + first_obj_loc = "" + end + end + end + end + end + + for index,temp in pairs(timer) do + if timer[index]["place"] == plant then + print_message(-1, -2, timer[index]["place"]) + timer[index] = nil + --et.G_LogPrint("dynamite removed: " .. index .. "\n") + return + end + end + end + end + + if string.find(text, "Objective_Destroyed") and not string.find(text, "say") then + local junk1,junk2,id,plant = string.find(text, "^Objective_Destroyed:%s+(%d+)%s+([^\n]+)") + local name = et.gentity_get(id, "pers.netname") + + if plant == "the North Anti-Tank Gun" or plant == "the South Anti-Tank Gun" or plant == "the North PAK 75mm Gun" or plant == "the South PAK 75mm Gun" or plant == "the West Flak88" or plant == "the East Flak88" or plant == "the South Radar [02]" or plant == "the North Radar [01]" or plant == "the North Radar" or plant == "the South Radar" or plant == "the Gun Controls" or plant == "the Fuel Dump" or plant == "the Bunker Controls" or plant == "the Axis Submarine" or plant == "the axis submarine" then + if mapname == "oasis" or mapname == "sw_oasis_b3" or mapname == "erdenberg_t2" or mapname == "tc_base" or mapname == "etl_base" then + if first_obj == false then + first_obj = true + else + if sudden_death == true then + et.G_LogPrint("LUA event: " .. mapname .. " Dynamite sudden death, Allies win!\n") + end + end + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7destroyed ^1" .. plant .. "^7!\"") + else + et.trap_SendServerCommand(-1, "chat \"" .. name .. " ^7destroyed ^1" .. plant .. "^7!\"") + if sudden_death == true then + et.G_LogPrint("LUA event: " .. mapname .. " Dynamite sudden death, Allies win!\n") + end + end + end + end +end