-- direction defines FORWARD = 0 BACKWARD = 1 -- size defines SMALL = 0 MEDIUM = 1 LARGE = 2 -- types of guns MACHINE_GUN = 0 LASER_GUN = 1 FLAME_GUN = 2 -- armor LIGHT = 0 -- MEDIUM already defined as 1 HEAVY = 2 -- mine types PROXIMITY = 0 TIMED = 1 -- nothing NONE = -1 -- true/false TRUE = 1 FALSE = 0 -- gun defines NUM_GUNS = 0 -- 1 and 2 are only other valid options GUN_STRENTH = 0 -- other valid options 1 or 2 GUN_TYPE = NONE -- has 1 proximity mine NUM_MINES = 0 MINE_STRENGTH = NONE MINE_TYPE = NONE -- will be mult be 32 to get the real sight SIGHT = 5 FLYER = FALSE BUILDER = FALSE -- not a builder MINER = TRUE -- but it is a miner MOVEDIR = FORWARD -- scrap x and y position SCRAP_X = 0 SCRAP_Y = 0 -- whether robot has a target TARGETS = FALSE TARGETX = 0 TARGETY = 0 NUMTARGETS = 0 function callProperties() getSkin("miner.png", "miner2.png") getName("Miner") getGuns(NUM_GUNS, GUN_STRENTH, GUN_TYPE) getMines(NUM_MINES, MINE_STRENGTH, MINE_TYPE) getSight(SIGHT) getType(SMALL, BUILDER, MINER, FLYER) end -- randomly numbers become more random math.randomseed( os.time() ) -- wander aimlessly along the map function wander() -- move forward most of the time if (math.random(1,1000) == 10) then MOVEDIR = BACKWARD -- rotate (math.random(360)) end if (math.random(1,100) == 10) then MOVEDIR = FORWARD end -- calls our hardcoded robot move function move(ROBOTNUM, MOVEDIR) -- every so often pick a new random direction if math.random(1,500) == 50 then -- if random event happens (1 out of 100 chance) rotate(ROBOTNUM, math.random(360)) -- pick a new random rotation end end -- culmination of all AI routines go here function ai() getNumTargets(ROBOTNUM) if (TARGETS == TRUE and math.random(1,3)==2) then -- select a 'random' target getClosestTarget(ROBOTNUM) gotoTarget(ROBOTNUM, TARGETX, TARGETY) --print("X: " .. TARGETX .. " Y: " .. TARGETY) else wander() end end