-- LUA Script - precede every function and global member with lowercase name of script
-- init when level first runs
function civilian_waypoint_init(e)
ai_soldier_state[e] = "patrol";
ai_soldier_pathindex[e] = -1;
ModulateSpeed(e,1.0)
end
function civilian_waypoint_main(e)
EntObjNo = g_Entity[e]['obj']
--if PathIndex ~= nil then Prompt(PathIndex .." : - : " ..ai_soldier_pathindex[e]) end
if ai_soldier_state[e] == "patrol" then
if ai_soldier_pathindex[e] == -1 then
ai_soldier_pathindex[e] = -2
CharacterControlUnarmed(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)
--SetAnimationFrames(0,160)
--SetAnimationFrame(e,0)
LoopAnimation(e,0)
MoveWithAnimation(e,0)
--SetCharacterToWalk(e)
ai_path_point_direction[e] = 1
ai_path_point_max[e] = AIGetPathCountPoints(ai_soldier_pathindex[e])
end --PathIndex
end --ai_soldier_pathindex[e]
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 -- ai_path_point_direction[e]
end -- DistFromPath
end --ai_soldier_pathindex[e]
else
CharacterControlFidget(e)
end --ai_soldier_state[e]
end --main
Can remember who has posted this script in the forum, anyway ty for sharing it.
And thanks to Gtox for their awesome white shark.
About bubles, with AM's
sparks1_emitter.lua file.
hth
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz
OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4