--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