Page 1 of 1

two problems

PostPosted: Fri Mar 21, 2014 1:59 am
by tazinator
main problem: I want this to shoot bullets only when the targetship shoots. it just leaves instead
  Code:
function onTick()
    table.clear(items)
    targetShip = findClosest(findAllObjects(items, ObjType.Ship))
    if(targetShip ~= nil) then
    local targetShiploc = targetShip:getPos()
    local angle = targetShip:getAngle()
    local shield = targetShip:isModActive(Module.Shield)
    local turbo = targetShip:isModActive(Module.Turbo)
    local weapon = targetShip:getActiveWeapon()
    bot:findVisibleObjects(items, ObjType.Bullet)
    local bulletOwner = bullet:getOwner()
        if(bot:canSeePoint(targetShiploc))  then
        if(shield == true) then
            bot:fireModule(Module.Shield)
        end
        if(turbo == true) then
            bot:fireModule(Module.Turbo)
        end
        if(weapon == Weapon.Phaser) or (weapon == Weapon.Triple) or (weapon == Weapon.Bouncer) and (bulletOwner == targetShip) then
            bot:fireWeapon(Weapon.Phaser)
        end
        if(weapon == Weapon.Burst) and (bulletOwner == targetShip) then
            bot:fireWeapon(Weapon.Burst)
        end
    end
    local playerVel = targetShip:getVel()
        if(bot:canSeePoint(targetShiploc))  then
            bot:setVel(1.1*playerVel) --1.1 is speed multiplier
            bot:setAngle(angle)
        else
            bot:setAngle(angle)
        end
    end
end
 

Re: two problems

PostPosted: Fri Mar 21, 2014 4:17 pm
by Fordcars
Can you post what the log says?