Thanks again smallg.....there was an unexpected error in what you sent me ( "end" to close to "if" at line 21) but I was able to fix that and now have me some shaweet sonar blip action....
function ai_tank2_init(e)
ai_soldier_state[e] = "patrol"
end
function ai_tank2_main(e)
SetAnimation(0);
SetAnimationSpeed(e,125)
SetCharacterSound(e,"enemysub")
if GetPlayerDistance(e) > 500 then
RotateToPlayerSlowly(e,1)
MoveForward(e,100)
LoopAnimation(e);
PlaySoundIfSilent(e,0)
elseif GetPlayerDistance(e) <= 500 then
StopAnimation(e)
end
end
if ai_soldier_state[e] == "patrol" then
if ai_soldier_pathindex[e] == -1 then
ai_soldier_pathindex[e] = -2
CharacterControlArmed(e)
PathIndex = -1
PathPointIndex = -1
pClosest = 99999
for pa = 1, AIGetTotalPaths(), 1 do
for po = 1 , AIGetPathCountPoints(pa), 1 do
pDX = g_Entity[e]['x'] - AIPathGetPointX(pa,po)
pDZ = g_Entity[e]['z'] - AIPathGetPointZ(pa,po)
pDist = math.sqrt(math.abs(pDX*pDX)+math.abs(pDZ*pDZ))
if pDist < pClosest and pDist < 200 then
pClosest = pDist
PathIndex = pa
PathPointIndex = po
end
end -- po
end -- pa
if PathIndex > -1 then
ai_soldier_pathindex[e] = PathIndex
ai_path_point_index[e] = PathPointIndex
ModulateSpeed(e,1.0)
SetCharacterToWalk(e)
ai_path_point_direction[e] = 1
ai_path_point_max[e] = AIGetPathCountPoints(ai_soldier_pathindex[e])
end
end
if ai_soldier_pathindex[e] > -1 then
ai_patrol_x[e] = AIPathGetPointX(ai_soldier_pathindex[e],ai_path_point_index[e])
ai_patrol_z[e] = AIPathGetPointZ(ai_soldier_pathindex[e],ai_path_point_index[e])
AIEntityGoToPosition(EntObjNo,ai_patrol_x[e],ai_patrol_z[e])
tDistX = g_Entity[e]['x'] - ai_patrol_x[e]
tDistZ = g_Entity[e]['z'] - ai_patrol_z[e]
DistFromPath = math.sqrt(math.abs(tDistX*tDistX)+math.abs(tDistZ*tDistZ))
if DistFromPath < 50 then
if ai_path_point_direction[e] == 1 then
ai_path_point_index[e] = ai_path_point_index[e] + 1
if ( ai_path_point_index[e] > ai_path_point_max[e] ) then
ai_path_point_index[e] = ai_path_point_max[e] - 1
ai_path_point_direction[e] = 0
end
else
ai_path_point_index[e] = ai_path_point_index[e] - 1
if ( ai_path_point_index[e] < 1 ) then
ai_path_point_index[e] = 2
ai_path_point_direction[e] = 1
end
end
end
end
end
time to hunt some enemy submarines and try to get them to shoot me...
@ Honkeyboy.....yes I found you speeder thread a while back and torpedo's would always come in handy ! TY for your input
Processor: Intel(R) i7-4700MQ CPU @ 2.40GHz 2.40 GHz Installed memory (RAM): 16.0 GB (15.8 GB usable) System type: 64-bit Operating System,x64-based processor
Start the day by righting your wrongs then end you day right so you don't have to do it again tomorrow ...
sHn33Ky