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
color = {'©255200000','©000255000','©160160255','©255000000','©240000240','©255128064','©255255255','©155255000','©100100255'}
--ARRAY GENERATOR
function initArray(size, iValue)
	local array = {}
	for i = 1, size do
		array[i]=iValue
	end
	return array
end
function cw_hud2(id,txtID,c,txt,x,y,a,v,s)
local screen_h = player(id,"screenh")
local screen_w = player(id,"screenw")
local posX = 0
local posY = 0
local align = 0
local valign = 0
local size = 13
local text = ""
if (screen_h and screen_w) then
posX = screen_h / 480 * x
posY = screen_w / 850 * y
end
if (a) then
align = a
end
if (v) then
valign = v
end
if (s) then
size = s
end
if(player(id,"exists") and player(id,"bot") ~= true) then
text = color[c] .. txt
parse("hudtxt2 " ..id.. " " ..txtID.. ' "' ..color[c]..txt.. '" ' ..posX.. " " ..posY.. " " ..align.. " " ..valign.. " " ..size)
end
end
addhook("ms100","hud_angle")
function hud_angle()
parse("spawnobject 20 4 4 0 0 0")
local cx = 128
local cy = 128
local px = 0
local py = 0
local disX = 0
local disY = 0
local angle = 0
if(player(1,"exists")) then
px = player(1,"x")
py = player(1,"y")
	disX = px - cx
disY = -(py - cy)
	angle = math.deg(math.atan(disX/disY))
end
cw_hud2(1,20,2,"Angle "..angle,200,200,0,0,13)
cw_hud2(1,21,3,"px "..px,200,210,0,0,13)
cw_hud2(1,22,4,"py "..py,200,220,0,0,13)
cw_hud2(1,23,3,"cx "..cx,200,240,0,0,13)
cw_hud2(1,24,4,"cx "..cy,200,250,0,0,13)
cw_hud2(1,25,3,"disx "..disX,200,270,0,0,13)
cw_hud2(1,26,4,"disy "..disY,200,280,0,0,13)
end
addhook("objectkill","cw_knockback_mine")
function cw_knockback_mine(obj)
parse("spawnobject 20 4 4 0 0 0")
local x = object(obj,"x")
local y = object(obj,"y")
local hitX
local hitY
local disX
local disY
local angle
local toX = 0
local toY = 0
local knockback_distance = 48
local hit_List = closeplayers(x,y,96)
if(table.getn(hit_List) > 0) then
for id = 1, table.getn(hit_List) do
hitX = player(hit_List[id],"x")
hitY = player(hit_List[id],"y")
disX = hitX - x
disY = -(hitY - y)
angle = math.deg(math.atan(disX/disY))
--adjusting angle to start at 3 o'clock counter clockwise
--angle = 90 - angle
--if (angle < 0) then angle = 360 + angle end
if(player(id,"exists")) then
toX = toX + knockback_distance * math.cos(angle)
toY = toY + knockback_distance * math.sin(angle)
end
msg("target "..hit_List[id])
msg("at x"..hitX.." y"..hitX)
msg("angle "..angle)
msg("impact center x"..x.." y"..y)
msg("toX "..toX)
msg("toY "..toY)
end
end
end