diff options
| author | Alexander Gavrilov | 2012-09-11 19:17:24 +0400 |
|---|---|---|
| committer | Alexander Gavrilov | 2012-09-11 19:17:24 +0400 |
| commit | 3a075f4bc716550e0a621a2db40cfa578db1d0fa (patch) | |
| tree | f325fdaf7c01fc8dd94684cd1336b74944fa2e16 /plugins/lua | |
| parent | 8ab615f6d0dce167a1952c4684922a7e48263c23 (diff) | |
| download | dfhack-3a075f4bc716550e0a621a2db40cfa578db1d0fa.tar.gz dfhack-3a075f4bc716550e0a621a2db40cfa578db1d0fa.tar.bz2 dfhack-3a075f4bc716550e0a621a2db40cfa578db1d0fa.tar.xz | |
Trivial siege engine aiming at units, with logic in lua.
Diffstat (limited to 'plugins/lua')
| -rw-r--r-- | plugins/lua/siege-engine.lua | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/plugins/lua/siege-engine.lua b/plugins/lua/siege-engine.lua index 01b5d144..d078ce1d 100644 --- a/plugins/lua/siege-engine.lua +++ b/plugins/lua/siege-engine.lua @@ -10,4 +10,35 @@ local _ENV = mkmodule('plugins.siege-engine') --]] +Z_STEP_COUNT = 15 +Z_STEP = 1/31 + +function findShotHeight(engine, target) + local path = { target = target, delta = 0.0 } + + if projPathMetrics(engine, path).goal_step then + return path + end + + for i = 1,Z_STEP_COUNT do + path.delta = i*Z_STEP + if projPathMetrics(engine, path).goal_step then + return path + end + + path.delta = -i*Z_STEP + if projPathMetrics(engine, path).goal_step then + return path + end + end +end + +function doAimProjectile(engine, target_min, target_max) + local targets = proposeUnitHits(engine) + if #targets > 0 then + local rnd = math.random(#targets) + return findShotHeight(engine, targets[rnd].pos) + end +end + return _ENV
\ No newline at end of file |
