  

      "zone_teleport",       create,         ,    -   .     ,   (       )   ,  all.spawn.           (                all.spawn).       " " ;)   .                        .       ,      - .       "" . 


  gamedata\scripts\   bind_mteleport.script     . 
-- ************************************************
-- **                    Imp                     **
-- **                 **
-- **     **
-- ************************************************

local teleport_binders ={}	--  

function abs_comp(a,b)
	--    
	if( a < b) then
		return (b - a)
	else
		return (a - b)
	end
end

function teleportate(x,y,z)
--  
	local a = vector()
	--  
	a.x = x
	a.y = y
	a.z = z

	--  
	db.actor:set_actor_position(a)

	--  
	local snd_obj = xr_sound.get_safe_sound_object([[affects\tinnitus3a]])
	snd_obj:play_no_feedback(db.actor, sound_object.s2d, 0, vector(), 1.0)

end


function actor_update(delta)
	local i,v,acter_poz,s

	--    (-    )
	acter_poz = db.actor:position()

	--   
	for i, v in pairs(teleport_binders) do
		s = v.parametrs

		local obj = level.object_by_id( i )
		if obj ~= nil then
		--      
			if s.teleporte ~= nil and s.teleporte ~= false then
				--  
				if ( time_global() <= s.time ) then
					--      
					-- ,  
					teleportate(s.poz_x,s.poz_y,s.poz_z)
					if s.rotate ~= nil then
						db.actor:set_actor_direction(s.rotate)
					end
					s.teleporte = false
				end
				return
			end

			--   -    
			if (abs_comp(s.x, acter_poz.x)< v.parametrs.radius  and
			    abs_comp(s.z, acter_poz.z)< v.parametrs.radius  and
			    abs_comp(s.y, acter_poz.y)< v.parametrs.z_radius) then
				--     ,  
				s["teleporte"] = true
				s["time"] = time_global() + 500

				--   
				level.add_pp_effector ("teleport.ppe", 2006, false)
			end
		end
	end
end

function bind( obj )
	obj:bind_object( restrictor_teleport( obj ) ) 
end

----------------------------------------------------------------------------------------------------
class "restrictor_teleport" ( object_binder )

function restrictor_teleport:__init(obj, char_ini) super(obj)
end

function restrictor_teleport:net_spawn(data)
	local char_ini = system_ini()

	--          
	if self.teleport == true then
		teleport_binders[self.object:id()] = self

		--   
		self["parametrs"] = {}
		if char_ini:line_exist(self.section, "radius") then
			self.parametrs["radius"] = tonumber(char_ini:r_string(self.section, "radius"))
		else
			self.parametrs["radius"] = 2 --    xy
		end
		if char_ini:line_exist(self.section, "z_radius") then
			self.parametrs["z_radius"] = tonumber(char_ini:r_string(self.section, "z_radius"))
		else
			self.parametrs["z_radius"] = self.parametrs["radius"] --          xy
		end

		--   -    
		local s_obj = alife():object(self.object:id())
		self.parametrs["x"] = tonumber(s_obj.position.x);
		self.parametrs["y"] = tonumber(s_obj.position.y);
		self.parametrs["z"] = tonumber(s_obj.position.z);

		--    
		self.parametrs["poz_x"] = tonumber(char_ini:r_string(self.section, "poz_x"))
		self.parametrs["poz_y"] = tonumber(char_ini:r_string(self.section, "poz_y"))
		self.parametrs["poz_z"] = tonumber(char_ini:r_string(self.section, "poz_z"))

		if char_ini:line_exist(self.section, "rotate") then
			self.parametrs["rotate"] = tonumber(char_ini:r_string(self.section, "rotate"))
		end
	end
	return true
end

function restrictor_teleport:net_destroy()
	--   
	teleport_binders[self.object:id()] = nil
	self.parametrs = nil
	object_binder.net_destroy(self)
end

function restrictor_teleport:reload(section)
	local char_ini = system_ini()

	self.section = section
	--     
	if char_ini ~= nil and char_ini:line_exist(self.section, "teleport") then
		self["teleport"] = true
	end
end


      actor_update()   ,     bind_stalker.script  : 

function actor_binder:update(delta) 

      bind_restrictor.actor_update(delta)         : bind_mteleport.actor_update(delta) 

    ,    . 

  gamedata\config\misc   zone_teleport.ltx          : 
[m_teleport_1]:zone_teleport
teleport			= standart
script_binding          	= bind_mteleport.bind
;  
radius				= 2
;  
z_radius			= 2

;  (     )
poz_x				= 22.78
poz_y				= 20.35
poz_z				= 659.24

;    .      .
rotate = 1.5

  : 
radius -     ,       (      ,  ,        ).      . 
z_radius -   . 
poz_x, poz_y, poz_z -   . 
rotate -       X (      ,  1.5   90 ).             . 
 

   create   : : 
	local obj
	local a = vector()
	a.x = -244.55
	a.y = -19.46
	a.z = -125.42
	obj = alife():create("m_teleport_1",a,12829,8,65535)

      .        (   ). 

!          
