it's actually quite hard to do as the collision on the door stops them attempting to walk that direction so if you hide inside a building they wont automatically run up to the door and try to open it but kinda just stand and stare at the wall waiting for you to come out
(not without a custom ai script at least which is more hassle then im willing to spend on it right now - mainly because i can't think of a simple solution to check if you're indoors other than putting a zone inside every building but that is just too tedious)
but for standard waypoint following it works ok
*you just kinda need to be a bit more careful about where you place the waypoints as if it doesnt update the collision in time they will think they can't get to the next point - i put 1 point either side of the door, which as you can see causes a stutter or might make them use another route but does work*
also you can also open and close the door using the 'e' key of course
--enemies opening doors by smallg
local use_range = 100
local open = {}
pressed = 0
function char_open_door_init(e)
open[e] = 0
CollisionOff(e)
end
function char_open_door_main(e)
if GetPlayerDistance(e) < use_range * 1.2 then
if GetInKey() == "e" and pressed == 0 then
pressed = 1
if open[e] == 0 then
if g_Entity[e]['animating'] == 0 then
SetAnimation(0)
PlayAnimation(e)
g_Entity[e]['animating'] = 1
open[e] = 1
end
else
if g_Entity[e]['animating'] == 0 then
SetAnimation(1)
PlayAnimation(e)
g_Entity[e]['animating'] = 1
open[e] = 0
CollisionOn(e)
end
end
end
end
if open[e] == 1 then
if GetTimer(e) > 1000 then
CollisionOff(e)
end
end
for a = 1,9999 do
if g_Entity[a] ~= nil then
if ai_soldier_state[a] ~= nil then
if GetDistance(e,a) < use_range then
if open[e] == 0 then
if g_Entity[e]['animating'] == 0 then
SetAnimation(0)
PlayAnimation(e)
g_Entity[e]['animating'] = 1
CollisionOff(e)
open[e] = 1
end
break
end
elseif GetDistance(e,a) > use_range and GetDistance(e,a) < use_range * 1.5 and open[e] == 1 then
if g_Entity[e]['animating'] == 0 then
SetAnimation(1)
PlayAnimation(e)
g_Entity[e]['animating'] = 1
--CollisionOn(e)
open[e] = 0
end
break
end
end
end
end
if GetTimer(e) > 1500 then
CollisionOff(e)
StartTimer(e)
else
if GetTimer(e) > 200 or GetPlayerDistance(e) < use_range then
if open[e] == 0 then
CollisionOn(e)
end
end
end
if GetInKey() == "" then
pressed = 0
end
end --main
function char_open_door_exit(e)
end
p.s. i should say the script has a few bits that aren't really needed as i was testing switching the collision off for a short time to try get them to "see" it as a route to chase the player, it only slightly works in that regard - they will at least head in the general direction, which is why i left it in.
life\'s one big game
windows vista ultimate
i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11