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
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
function array(v,e,m)
if not v then v = 0 end
if not e then e = 32 end
if not m then m = 1 end
local tbl = {}
for i = m,e,1 do
tbl[i] = v
end
return tbl
end
duck = array(false)
duck.x = array()
duck.y = array()
duck.rot = array()
rot = array()
rot.x = array()
rot.y = array()
function around(x,y,what)
if not what then what = "wall" end
if tile(x - 1,y,what) then
return true,x - 1,y,270
elseif tile(x + 1,y,what) then
return true,x + 1,y,90
elseif tile(x,y - 1,what) then
return true,x,y - 1,0
elseif tile(x,y + 1,what) then
return true,x,y + 1,180
elseif tile(x + 1,y + 1,what) then
return true,x + 1,y + 1,135
elseif tile(x + 1,y - 1,what) then
return true,x + 1,y - 1,45
elseif tile(x - 1,y + 1,what) then
return true,x - 1,y + 1,225
elseif tile(x - 1,y - 1,what) then
return true,x - 1,y - 1,315
else
return false
end
end
function table.find(tbl,val)
for i,v in pairs(tbl) do
if v == val then
return true
end
end
return false
end
addhook([[serveraction]],[[sac]])
function sac(id,a)
if a == 3 then
if player(id,"health") > 0 then
local x,y = player(id,"tilex"),player(id,"tiley")
local bla,bld,bls,bll = around(x,y,"obstacle")
duck.x[id] = bld
duck.y[id] = bls
duck.rot[id] = bll
if bla == true then
if duck[id] == true then
duck[id] = false
parse([[speedmod ]]..id..[[ 0]])
else
msg2(id,"©000255000Now you crouch behind an obstacle.")
parse([[speedmod ]]..id..[[ -100]])
duck[id] = true
end
else
duck[id] = false
parse([[speedmod ]]..id..[[ 0]])
end
end
end
end
addhook([[attack]],[[attacker]])
function attacker(id)
local x,y,rot = player(id,"x"),player(id,"y"),player(id,"rot")
if rot > 360 then
rot = rot - 360
elseif rot < 0 then
rot = rot + 360
end
rot.x[id] = x + math.sin(math.rad(rot[id])) * 32
rot.y[id] = y - math.cos(math.rad(rot[id])) * 32
rot.x[id] = math.ceil(rot.x[id]/32)
rot.y[id] = math.ceil(rot.y[id]/32)
if duck[id] == true then
return 1
end
end
addhook([[hit]],[[hitter]])
function hitter(id,src,wpn,hpdmg,apdmg)
if duck[id] == true then
if not table.find({49,48,51,72,73,75,76,77,86},wpn) then
if math.sqrt((rot.x[src] - player(id,"tilex"))^2 + (rot.y[src] - player(id,"tiley"))^2) < 350 then
if duck.rot[id] - rot[src] < 0 and duck.rot[id] - rot[src] > 360 then
return 1
else
return 0
end
else
return 1
end
end
end
end
edited 1×, last 01.01.11 07:39:51 pm