FAQ  •  Register  •  Login

Engineer Robot.

<<

sam686

User avatar

Posts: 468

Joined: Fri Oct 15, 2010 8:53 pm

Location: United States, South Dakota

Post Sat Feb 05, 2011 5:18 pm

Engineer Robot.

This is a robot I made that only use Engineer. Requires level with loadout zone, resource item, and engineer enabled.
  Code:
function getName()
    return("engineer_bot")
end


function hasOurLoadout()
    -- Test for triple weapon to see if we have changed loadout
    -- This is to avoid the memory leak with getCurrLoadout()
    return bot:hasWeapon(Weapon.Triple)
end


function gotoClosestLoadoutZone()
    local zone = findClosestLoadoutZone()

    -- Go to nearest loadout zone to change
    if zone ~= nil then
        -- If we're close enough, just sit instead of fighting other bots for
        -- the zone center point
        if point.distSquared(zone:getLoc(), bot:getLoc()) > 1225 then  -- (35^2)
            bot:setThrustToPt(zone:getLoc())
        end
    end
end


function onTick()
    local target = nil
   
    if hasOurLoadout() then
        if bot:getMountedItems(ObjType.ResourceItem)[1] == nil then
            table.clear(items)
            bot:findGlobalObjects(items, ObjType.ResourceItem)
           
            for index, item in ipairs(items) do
                if not item:isOnShip() then
                    target = item:getLoc()
                end
            end
        elseif bot:getEnergy() > 0.8 then
            bot:setThrust(1,angleTo)
            bot:setAngle(angleTo)
            angleTo = angleTo + bot:getTime() * 0.002
           
            if math.random(10) < 5 then
                bot:engineerDeployObject(EngineerBuildObject.ForceFieldProjector)
            else
                bot:engineerDeployObject(EngineerBuildObject.Turret)
            end
        end
    else
        bot:setReqLoadout(loadout);
       
        table.clear(items)
        bot:findGlobalObjects(items, ObjType.LoadoutZone)
       
        for index, item in ipairs(items) do
            if item:getTeamIndx() == 0 or item:getTeamIndx() == bot:getTeamIndx() then
                target = item:getLoc()
            end
        end
    end
   
    if target ~= nil then
        target = bot:getWaypoint(target)
    end
   
    if target ~= nil then
        angleTo = point.angleTo(bot:getLoc(),target)
        bot:setThrust(1,angleTo)
        bot:setAngle(angleTo)
    end
end


function main()
    angleTo = 0
    items = {}  -- Our search table
   
    -- Set up the loadout we want
    loadout = Loadout.new()
 
    loadout:setModule(1, Module.Engineer)  -- We only care about this
    loadout:setModule(2, Module.Shield)
    loadout:setWeapon(1, Weapon.Phaser)
    loadout:setWeapon(2, Weapon.Bounce)
    loadout:setWeapon(3, Weapon.Triple)    -- And this - to get around the memory leak
 
    -- Set the loadout, will become active when bot hits loadout zone
    -- or spawns, depending on game
    bot:setReqLoadout(loadout)
end


Update by raptor: updated for 018a
<<

Santiago ZAP

User avatar

Posts: 317

Joined: Sat May 14, 2011 8:05 am

Post Thu Feb 02, 2012 4:40 pm

Re: Engineer Robot.

i love it 5/5
:zapdance: :zapdance: :zapdance: :zapdance: :zapdance: :zapdance: :zapdance: :zapdance: :zapdance: :zapdance: :zapdance: :zapdance:
<<

CleverBot

User avatar

Posts: 560

Joined: Sun Dec 04, 2011 3:37 pm

Location: Orokin Void

Post Thu Feb 02, 2012 8:01 pm

Re: Engineer Robot.

Imagine a bot army filled with defensive bots and offensive bots (_k's bots) and engineering bots...that's annoying. Yeah I rather have bots build us stuff than me doing it.
<<

Santiago ZAP

User avatar

Posts: 317

Joined: Sat May 14, 2011 8:05 am

Post Sat Feb 04, 2012 4:17 pm

Re: Engineer Robot.

CleverBot wrote:I rather have bots build us stuff than me doing it.

Same here :P
:zapdance: :zapdance: :zapdance: :zapdance: :zapdance: :zapdance: :zapdance: :zapdance: :zapdance: :zapdance: :zapdance: :zapdance:
<<

CleverBot

User avatar

Posts: 560

Joined: Sun Dec 04, 2011 3:37 pm

Location: Orokin Void

Post Sat Feb 04, 2012 8:10 pm

Re: Engineer Robot.

We shall call them Servant Bots!....or just S_bots.... :?
Anyway I think the bitfighter community needs more engineers to fix the space ports and stuff.
<<

raptor

Posts: 1046

Joined: Mon Oct 11, 2010 9:03 pm

Post Mon Jul 01, 2013 2:47 pm

Re: Engineer Robot.

Updated for 018a

Return to Bots

Who is online

Users browsing this forum: No registered users and 4 guests