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
direction = {}
mode = {}
target = {}
i = 0
while (i <= 32) do
i = i + 1
direction [i]= 0
mode [i] = 1
target [i] = 0
end
addhook ("attack","player_attack")
addhook ("die","player_die")
addhook ("movetile","player_new_tile")
function ai_update_dead(id)
ai_respawn(id)
end
function ai_onspawn(id)
mode [id] = 1
parse ("setname "..id.." police bot")
parse ("equip "..id.." 1")
parse ("equip "..id.." 81")
direction [id] = math.random (0,360)
end
function ai_update_living(id)
if mode [id] == 1 then
direction [id] = direction [id] + math.random (-10,10)
ai_move(id,direction[id],0)
ai_rotate(id,direction[id])
function player_attack (id_shot)
i = 0
while (i <= 32) do
i = i + 1
if (player(i,"bot")) == true then
if (player(id_shot,"bot")) == false then
if (id_shot == i) == false then
if ai_freeline(id,player(id_shot,"x"),player(id_shot,"y")) then
if (math.sqrt((player(id,"x") - player(id_shot,"x"))^2 + (player(id,"y") - player(id_shot,"y"))^2)) < 250 then
mode [i] = 2
target [i] = id_shot
end
end
end
end
end
end
end
end
if mode [id] == 2 then
if (player(target[id],"health")) > 0 then
if ai_freeline(id,player(target [id],"x"),player(target [id],"y")) then
ai_aim(id,player(target [id],"x"),player(target [id],"y"))
ai_move(id,player(id,"rot"),1)
ai_iattack(id)
else
mode [id] = 1
target [id] = 0
end
end
end
function player_new_tile (id_move,x,y)
if id_move == id then
ai_use(id)
end
end
end
function ai_hear_radio(source,radio)
end
function ai_hear_chat(source,msg,teamonly)
end