

--[[ ---------------------------------------------------------------------------------------------------
 File        : guid_teleport.script
 Description : teleport
 Copyright   : 2009 © mobile_changer
 Author      : singapur22 
--]]----------------------------------------------------------------------------------------------------


function start_level_changer(p_dest_pos, p_dest_lv, p_dest_gv, p_dest_level)
	local obj = alife():create("level_changer", db.actor:position(), db.actor:level_vertex_id(), db.actor:game_vertex_id())
	local packet = net_packet()
	obj:STATE_Write(packet)
-- свойства cse_alife_object
    local game_vertex_id     = packet:r_u16()
    local distance           = packet:r_float()
    local direct_control     = packet:r_u32()
    local level_vertex_id    = packet:r_u32()
    local object_flags       = packet:r_u32()
    local custom_data        = packet:r_stringZ()
    local story_id           = packet:r_u32()
    local spawn_story_id     = packet:r_u32()
-- свойства cse_shape
    local shape_count = packet:r_u8()
    for i=1,shape_count do
        local shape_type = packet:r_u8()
        if shape_type == 0 then
    -- sphere
            local center = packet:r_vec3()
            local radius = packet:r_float()
        else
    -- box
			local axis_x                = packet:r_vec3()
			local axis_y                = packet:r_vec3()
			local axis_z                = packet:r_vec3()
			local offset                = packet:r_vec3()
        end
    end
	-- свойства cse_alife_space_restrictor
	local restrictor_type 			= packet:r_u8()
	-- свойства cse_alife_level_changer
	local dest_game_vertex_id		= packet:r_u16()  
	local dest_level_vertex_id 		= packet:r_u32()  
	local dest_position 			= packet:r_vec3()
	local dest_direction 			= packet:r_vec3()
	local dest_level_name 			= packet:r_stringZ()
	local dest_graph_point 			= packet:r_stringZ()
	local silent_mode 			    = packet:r_u8()
 
 -----------------------------------------------------------
	packet:w_begin(game_vertex_id)
	packet:w_float(distance)
	packet:w_u32(direct_control) 
	packet:w_u32(level_vertex_id)
	packet:w_u32( bit_not(193) )
	packet:w_stringZ(custom_data)
    packet:w_u32(46489)
	packet:w_u32(46489)
    packet:w_u8(1)
    packet:w_u8(0)
    packet:w_vec3(vector():set(0, 0, 0))
    packet:w_float(2)
	packet:w_u8(3)
	packet:w_u16(p_dest_gv)
	packet:w_u32(p_dest_lv)	
	packet:w_vec3(p_dest_pos)
	packet:w_vec3(vector():set(0, 0, 0))
	packet:w_stringZ(p_dest_level)
	packet:w_stringZ("start_actor_99")
	packet:w_u8(1)
 
	packet:r_seek(0)
	obj:STATE_Read(packet, packet:w_tell())
end


function start_del()
    local obj =  alife():story_object( 46489 )
	if obj then
	    db.actor:set_fastcall(del_changer, db.actor)
	end
end

function del_changer()
  local obj =  alife():story_object( 46489 )
    if obj then
	  local lv_ch = game_graph():vertex(obj.m_game_vertex_id):level_id() 
	  local lv_ac = alife():level_id()                                   
		if lv_ch ~= lv_ac then                                             
	        alife():release(obj, true)                                     
				news_manager.send_tip(db.actor, "alife():release(obj, true)", 0, "trader", 19000)
		else		
			news_manager.send_tip(db.actor, "LV не удален", 0, "trader", 19000)
         end
    end
end

start_del()





















