as far as im aware you can't find out the value of the 'ifused' field so it's not possible but you could check for an entity with a specific name or number if you stored it in the name field instead.
i dont think using AIEntityGoToPosition will work as the entity would need to be following the terrain, maybe if you had the origin point of the object way below it to simulate height? im not 100% sure.
anyway i have a RotateToEntity(e,t) function that would work fine.
so something like this (put the entity number of the target in the 'name' field of the entity with this script)
local target = {}
function helicopter2_init_name(e,name)
target[e] = tonumber(name)
CollisionOff(e)
end
function helicopter2_main(e)
if g_Entity[e]['animating'] == 0 then
LoopSound(e,1)
LoopAnimation(e)
g_Entity[e]['animating'] = 1
end
-- Point toward player and move
RotateToEntity(e,target[e])
if GetDistance(e,target[e]) > 250 then
MoveForward(e,100)
elseif GetDistance(e,target[e]) < 200 then
MoveForward(e,-100)
end
-- Nose down
if g_Entity[e]['anglez'] > -25 then
RotateZ(e,-1)
end
end
function helicopter2_exit(e)
end
function RotateToEntity(e,v)
if g_Entity[e] ~= nil and g_Entity[e] ~= 0 and g_Entity[v] ~= nil and g_Entity[v] ~= 0 then
local x = g_Entity[v]['x'] - g_Entity[e]['x']
local z = g_Entity[v]['z'] - g_Entity[e]['z']
local angle = math.atan2(x,z)
angle = angle * (180.0 / math.pi)
if angle < 0 then
angle = 360 + angle
elseif angle > 360 then
angle = angle - 360
end
SetRotation(e,0,angle,0)
return angle
end
end
function GetDistance(e,v)
if g_Entity[e] ~= nil and g_Entity[e] ~= 0 and g_Entity[v] ~= nil and g_Entity[v] ~= 0 then
local disx = g_Entity[e]['x'] - g_Entity[v]['x']
local disz = g_Entity[e]['z'] - g_Entity[v]['z']
local disy = g_Entity[e]['y'] - g_Entity[v]['y']
return math.sqrt(disx^2 + disz^2 + disy^2)
end
end