two problems
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
Play my new level! Two different teams fight over a nexus: One mainly defends while the other attacks! is fun
viewtopic.php?f=33&p=21002#p21002
viewtopic.php?f=33&p=21002#p21002