-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRandom.lua
34 lines (31 loc) · 830 Bytes
/
Random.lua
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
return function()
return {
speed = math.random(1,5),
health = 15 + 3*math.random(1, 5),
firing_rate = math.random(1, 5),
effect_name = 'damage',
effect_power = math.random(1, 5),
update = function (bots, my_index, dt)
local my_team_name = bots[my_index].data.category
local enemies = {}
for _, bot in ipairs(bots) do
if bot.data.category ~= my_team_name and bot.data.is_alive() then
table.insert(enemies, bot)
end
end
local target
if enemies[1] then
target = enemies[math.random(1, #enemies)].data.get_position()
else
target = { x = 400, y = 400 }
end
return {
force = {
x = math.random(-1, 1),
y = math.random(-1, 1)
},
target = target
}
end
}
end