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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
Code:
Catch_Type = 1	-- How to catch prisoners?
				--[[
					1	-	Default	(Set prisoner's position to CellX, CellY)
					2	-	make prisoner follow capturer + remove weapons
					3	-	"Paralyze" them	+ remove weapons
				--]]
function array (l, v)
	local a = {};l=l or 1; v = v or 0
	for i = 1, l do
		a[i] = v
	end
	return a
end
cap = array(32, 0)
if ( Catch_Type == 1 ) then
	if ( io.open("maps/"..map("name").."_cell.txt") ) then
		dofile("maps/"..map("name").."_cell.txt")
	else
		error("Can not find \"maps/"..map("name")..".txt\" script ended.")
	end
end
if ( type(CELLx) == "number" ) then
	CELLx = {CELLx}
end
if ( type(CELLy) == "number" ) then
	CELLy = {CELLy}
end
math.randomseed(os.time()/os.clock())
pris_trapWPN = {78} 	-- this is the table for weapons that allowed for captures seperate with a comma
pris_trapTeam = {1, 2} -- these are the teams allowed to capture people seperate with comma
addhook("walkover", "pris_wo")
addhook("hit", "pris_hit")
addhook("move", "pris_move")
function pris_wo (i, item)
	 for aw = 1, #pris_trapWPN do
		 if ( item == pris_trapWPN[aw] ) then
			 for at = 1, #pris_trapTeam do
					if ( player(i, "team") == pris_trapTeam[at] ) then
						 return 0
					else
						 return 1
					end
			 end
		 else
			 return 0
		 end
	 end
end
function pris_hit (id, s, wpn, hd, ad)
	 local wpt = false
	 for i = 1, #pris_trapWPN do
		if ( wpn == pris_trapWPN[i] ) then
			wpt = true
			hd = 0; ad = 0
		else
			wpt = false
		end
	end
	if ( cap[id] > 0 ) then
		hd = 0; ad = 0
	end
	 for i = 1, #pris_trapTeam do
		 if ( wpt and player(s, "team") == pris_trapTeam[i] ) then
			 if ( player(s, "team") ~= player(id, "team") ) then
					if ( Catch_Type == 1 ) then
						parse("setpos "..id.." "..(CELLx[math.random(1,#CELLx)]*32).." "..(CELLy[math.random(1,#CELLy)]*32))
						msg(player(id, "name").." has been captured by "..player(s, "name"))
						parse("sethealth "..id.." "..player(id, "maxhealth"))
					elseif ( Catch_Type == 2 ) then
						if ( cap[id] == 0 ) then
							cap[id] = s; parse("speedmod "..id.." -100")
							parse("strip "..id)
							parse("equip "..id.." 78")
							parse("strip "..id.." 51")
						else
							cap[id] = 0; parse("speedmod "..id.." 0")
						end
					elseif ( Catch_Type == 3 ) then
						if ( player(id, "speedmod") > -100 ) then
							parse("speedmod "..id.." -100")
							parse("strip "..id)
							parse("equip "..id.." 78")
							parse("strip "..id.." 51")
						else
							parse("speedmod "..id.." 0")
						end
					end	
			 else
					msg2(s, player(id, "name").." is on your team. Can not capture.")
			 end
		 end
	 end
	 parse("sethealth "..id.." "..(player(id, "health")-hd))
	 parse("setarmor "..id.." "..(player(id, "armor")-ad))
	 return 1
end
function pris_move (id,x,y,walk)
	for i = 1, 32 do
		if cap[i] > 0 then
			if walk then
				parse("setpos "..i.." "..player(cap[i], "x").." "..player(cap[i], "y"))
			else
				msg2(cap[i], "You must walk (use shift key) with prisoners or they will escape!")
				cap[i] = 0
			end
		end
	end
end