Add inaccuracy to missile targeting

This commit is contained in:
Juhani Krekelä 2023-06-03 22:03:40 +03:00
parent d6952e9eaf
commit a935b498da
1 changed files with 3 additions and 1 deletions

View File

@ -25,6 +25,7 @@ local enemies = {}
local enemy_radius = 0.025
local enemy_min_shoot = 2
local enemy_max_shoot = 20
local enemy_inaccuracy = 0.05
local window_width = nil
local window_height = nil
@ -290,7 +291,8 @@ function updateEnemies(dt)
enemy.until_shoot = enemy_min_shoot + math.random() * (enemy_max_shoot - enemy_min_shoot)
if unreflected_missiles < unreflected_missiles_max then
local target = cities[math.random(1, #cities)]
spawnMissile(enemy.x, enemy.y, target.x, target.y, 0.2)
local inaccuracy = math.random() * 2 * enemy_inaccuracy - enemy_inaccuracy
spawnMissile(enemy.x, enemy.y, target.x + inaccuracy, target.y, 0.2)
end
end