Sweet thanks JackalHead
didn't work so well for me with the soldier script but did work really well with the drone script I have
local attack_delay = {}
--local damage = {}
function drone_init(e)
attack_delay[e] = 10
--damage[e] = 20
descent = 0
totaldescent = 0
rotation = 0
flying = 1
attacking = 0
firing = 0
CharacterControlArmed(e)
end
GravityOff(e);
function drone_main(e)
CollisionOff(e)
--PlayerDist = GetPlayerDistance(e)
descent = math.random(-500,500)
rotation = math.random(-100,100)
if GetPlayerDistance(e) < 500 then
flying = 0
attacking = 0
firing = 1
end
if GetPlayerDistance(e) < 1000 and GetPlayerDistance(e) >250 then
flying = 0
attacking = 1
firing = 0
end
if GetPlayerDistance(e) > 1500 then
flying = 1
attacking = 0
firing = 0
end
if flying == 1 then
MoveForward(e,100)
if g_Entity[e]['y'] < 700 then
MoveUp(e,20)
end
RotateY(e,rotation)
totaldescent = totaldescent + descent
elseif attacking == 1 then
MoveForward(e,100)
if g_Entity[e]['y'] > g_PlayerPosY then
MoveUp(e,-20)
end
RotateToPlayer(e)
totaldescent = totaldescent + descent
elseif firing == 1 then
if GetPlayerDistance(e) > 250 then
MoveForward(e,100)
else
MoveForward(e,-100)
end
--MoveUp(e,20)
RotateToPlayer(e)
if g_Time > attack_delay[e] then
FireWeapon(e)
attack_delay[e] = g_Time + 250
end
totaldescent = totaldescent + descent
end
if totaldescent <-150 then
MoveUp(e,1)
totaldescent = totaldescent + 10
end
end
function drone_exit(e)
end