Skip to content

Instantly share code, notes, and snippets.

@domgetter
Created December 17, 2013 13:37
Show Gist options
  • Save domgetter/8005000 to your computer and use it in GitHub Desktop.
Save domgetter/8005000 to your computer and use it in GitHub Desktop.
basic incomplete code for the logic of a heat seeking rocket projectile.
function init(args)
end
function main()
if collision() then asplode() end
local found_monster = false
local sensor_range = 10
for radius = 1, sensor_range do
--checks for any nearest monster within sensor range
monsters = world.monsterQuery(object.position(), radius)
if monster[1] then
set_kill_course(monster[1].postion)
found_monster = true
end
if found_monster then break end
end
if not found_monster then
--if no monster was within sensor range, just go straight
continue_course()
end
end
function set_kill_course(destination)
--modifies the trajectory of the rocket to match its target
end
function continue_course()
--continue trajectory in straight path to its inevitable doom
end
function collision()
--check to see if rocket has collided with anything like a wall, monster, or npc
end
function asplode()
-- explode and die/delete object
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment