i dont think that is quite what he's aiming for, more like enemies attacking civilians... this is possible but you will need some basic functions that aren't available in the default code - i have some simple extra functions you can use though (such as rotate 1 object to face another) at the top of this post
https://forum.game-guru.com/thread/207801?page=1#msg2479478
if you can code then the basic idea should be pretty simple to get into action, if you can't code then obviously it will be a lot harder
i would likely set the civilians to a waypoint (waypoint code looks like this)
-- Try and find a close path to patrol, just check once for it
if ai_soldier_pathindex[e] == -1 then
ai_soldier_pathindex[e] = -2
CharacterControlArmed(e)
-- find initial waypoint path to follow
PathIndex = -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;
end
end -- po
end -- pa
-- follow found path
if PathIndex > -1 then
ai_soldier_pathindex[e] = PathIndex;
ai_path_point_index[e] = 2
SetCharacterToRun(e)
ai_path_point_direction[e] = 1
ai_path_point_max[e] = AIGetPathCountPoints(ai_soldier_pathindex[e])
end
-- If we have a path then lets patrol it
elseif 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(g_Entity[e]['obj'],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
else
CharacterControlFidget(e)
end
(you will also need to add a variable in the civilian script to store that it is infact a civilian)
then in the enemy script set the enemies to find a civilian - this can be done with a 'for' loop and a GetDistance(e,#) check (function found in link) to check which civilian is closest
something like
nearest_dist[e] = 9999
for a = 1,9999 do
if g_Entity[a] ~= nil then
if civilian[a] == 1 then
if GetDistance(e,a) < nearest_dist[e] then
nearest_dist[e] = GetDistance(e,a)
target[e] = a
end
end
end
end
then you can use the "target[e]" to head to the civilian like
CharacterControlArmed(e)
SetCharacterToRun(e)
AIEntityGoToPosition(g_Entity[e]['obj'],g_Entity[target[e]]['x'],g_Entity[target[e]]['z'])
obviously you will need more than just that but that is the basic script(s) flow.