1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
-- Settings
flagCaptureRadius = 2		-- 0 will make a 1x1 captureradius (normal cs2d), 1 will make 3x3, 2 will make 5x5 etc.
captureSpeed = 5000	-- Miliseconds it takes to cap a flag for 1 player.
maxCaptureBoost = 2			-- When 1 player is caping, it's normal speed. When 2 are caping it's double speed. When 3 are caping it's still double speed.
-- Public vars and server init
flagTileX = {}			-- Flags' X tile
flagTileY = {}			-- Flags' Y tile
flagCount = 0			-- Flags
inFlagZone = {}			-- Player ids
flagState = {}
function akd_dom_mapload()
	flagCount = 0
	--find flags, save them to flags[]
	if map("xsize") > map("ysize") then		--This statement checks if the map is horisontal.
		for x = 0, map("xsize") do
			for y = 0, map("ysize") do
				if entity(x,y,"typename") == "Info_Dom_Point" then
					flagCount = flagCount + 1
					flagTileX[#flagTileX+1] = x
					flagTileY[#flagTileY+1] = y
				end
			end
		end
	else	--If quadradic or vertical
		for y = 0, map("ysize") do
			for x = 0, map("xsize") do
				if entity(x,y,"typename") == "Info_Dom_Point" then
					flagCount = flagCount + 1
					flagTileX[#flagTileX+1] = x
					flagTileY[#flagTileY+1] = y
				end
			end
		end
	end
	print("Flags:")
	for i = 1, flagCount do
		flagState[i] = entity(flagTileX[i],flagTileY[i],"int0")
		print(i.." = "..flagTileX[i].." x "..flagTileY[i].." State: "..flagState[i]) -- DEBUG ONLY
	end
end
akd_dom_mapload()
addhook("movetile","akd_dom_movetile")
function akd_dom_movetile(id, x, y)
	foundFlagZone = 0
	for i = 1, flagCount do
		if player(id,"tilex") >= flagTileX[i] - flagCaptureRadius and player(id,"tilex") <= flagTileX[i] + flagCaptureRadius then
			if player(id,"tiley") >= flagTileY[i] - flagCaptureRadius and player(id,"tiley") <= flagTileY[i] + flagCaptureRadius then
				flagZone(id,i)
				foundFlagZone = 1
			end
		end
	end
	if not foundFlagZone == 1 then
		disFlagZone(id)
	end
end
addhook("move","akd_dom_move")
function akd_dom_move(id)
	--Images code
	if not inFlagZone[id] == nil then
		--
	end
end
function changeFlag(flag, id)
	--Entity = player(id,"team")
	flagState = player(id,"team")
end
function flagZone(id,flag)
	inFlagZone[id] = flag
	if not flagState[flag] == player(id,"team") then
		timer(captureSpeed,"changeFlag","flag","id")
	end
end
function disFlagZone(id)
	inFlagZone[id] = nil
end
addhook("dominate","akd_dom_dominate")
function akd_dom_dominate()
	return 1
end
print("AKD_DOM.lua \tSucessfully launched!")