-- Atlas (Spawn Menu) Mod 1.1
-- By: Helios (helios-50@hotmail.com)

class "atlas" (CUIScriptWnd)

function atlas:__init(owner,action) super()
	self.action = action
	self.owner = owner
	self:InitControls()
	self:InitCallBacks()
end

function atlas:__finalize() end

function atlas:InitControls()
	self:Init(50,50,550,450)
	local xml = CScriptXmlInit()
	xml:ParseFile("ui_atlas.xml")
	xml:InitStatic("back_video", self)
	xml:InitStatic("background", self)

	self:Register(xml:Init3tButton("title", self),"title")
	self:Register(xml:Init3tButton("caption", self),"caption")
	self:Register(xml:Init3tButton("caption2", self),"caption2")
	self:Register(xml:InitEditBox("edit_box", self), "edit_box")
	self:Register(xml:Init3tButton("btn_0", self),"btn_0")
	self:Register(xml:Init3tButton("btn_1", self),"btn_1")
	self:Register(xml:Init3tButton("btn_2", self),"btn_2")
	self:Register(xml:Init3tButton("btn_3", self),"btn_3")
	self:Register(xml:Init3tButton("btn_4", self),"btn_4")
	self:Register(xml:Init3tButton("btn_5", self),"btn_5")
	self:Register(xml:Init3tButton("btn_6", self),"btn_6")
	self:Register(xml:Init3tButton("btn_7", self),"btn_7")
	self:Register(xml:Init3tButton("btn_8", self),"btn_8")
	self:Register(xml:Init3tButton("btn_9", self),"btn_9")
	self:Register(xml:Init3tButton("btn_10", self),"btn_10")
	self:Register(xml:Init3tButton("btn_11", self),"btn_11")
	self:Register(xml:Init3tButton("btn_12", self),"btn_12")
	self:Register(xml:Init3tButton("btn_13", self),"btn_13")
	self:Register(xml:Init3tButton("btn_14", self),"btn_14")
	self:Register(xml:Init3tButton("btn_15", self),"btn_15")
	self:Register(xml:Init3tButton("btn_16", self),"btn_16")
	self:Register(xml:Init3tButton("btn_17", self),"btn_17")
	self:Register(xml:Init3tButton("btn_18", self),"btn_18")
	self:Register(xml:Init3tButton("btn_19", self),"btn_19")
	self:Register(xml:Init3tButton("btn_20", self),"btn_20")
	self:Register(xml:Init3tButton("btn_21", self),"btn_21")
	self:Register(xml:Init3tButton("btn_22", self),"btn_22")
	self:Register(xml:Init3tButton("btn_23", self),"btn_23")
	self:Register(xml:Init3tButton("btn_24", self),"btn_24")
	self:Register(xml:Init3tButton("btn_25", self),"btn_25")
	self:Register(xml:Init3tButton("btn_26", self),"btn_26")
	self:Register(xml:Init3tButton("btn_27", self),"btn_27")
	self:Register(xml:Init3tButton("btn_28", self),"btn_28")

	local caption = self:GetButton("caption")
	local caption2 = self:GetButton("caption2")
	local title = self:GetButton("title")
	local btn_0 = self:GetButton("btn_0")
	local btn_1 = self:GetButton("btn_1")
	local btn_2 = self:GetButton("btn_2")
	local btn_3 = self:GetButton("btn_3")
	local btn_4 = self:GetButton("btn_4")
	local btn_5 = self:GetButton("btn_5")
	local btn_6 = self:GetButton("btn_6")
	local btn_7 = self:GetButton("btn_7")
	local btn_8 = self:GetButton("btn_8")
	local btn_9 = self:GetButton("btn_9")
	local btn_10 = self:GetButton("btn_10")
	local btn_11 = self:GetButton("btn_11")
	local btn_12 = self:GetButton("btn_12")
	local btn_13 = self:GetButton("btn_13")
	local btn_14 = self:GetButton("btn_14")
	local btn_15 = self:GetButton("btn_15")
	local btn_16 = self:GetButton("btn_16")
	local btn_17 = self:GetButton("btn_17")
	local btn_18 = self:GetButton("btn_18")
	local btn_19 = self:GetButton("btn_19")
	local btn_20 = self:GetButton("btn_20")
	local btn_21 = self:GetButton("btn_21")
	local btn_22 = self:GetButton("btn_22")
	local btn_23 = self:GetButton("btn_23")
	local btn_24 = self:GetButton("btn_24")
	local btn_25 = self:GetButton("btn_25")
	local btn_26 = self:GetButton("btn_26")
	local btn_27 = self:GetButton("btn_27")
	local btn_28 = self:GetButton("btn_28")
 
	if self.action == "spawn" then
	caption:SetText("Консоль ввода направления и расстояния спавна:")
	caption2:SetText("Выберите направление по компасу (N, S, E, W) и расстояние (Пример: N, 10)")
	title:SetText("Atlas(Spawn Menu) для Солянки от 26.04.09.")
	btn_0:SetText("Выход")
	btn_1:SetText("Сталкер")
	btn_2:SetText("Бандит")
	btn_3:SetText("Зомби")
	btn_4:SetText("Слепая собака")
	btn_5:SetText("Псевдособака")
	btn_6:SetText("Пси-собака")
	btn_7:SetText("Кошка")
	btn_8:SetText("Долговец")
	btn_9:SetText("Свободовец")
	btn_10:SetText("Наёмник")
	btn_11:SetText("Кабан")
	btn_12:SetText("Плоть")
	btn_13:SetText("Тушкан")
	btn_14:SetText("Крыса")
	btn_15:SetText("Эколог")
	btn_16:SetText("Военный")
	btn_17:SetText("Монолитовец")
	btn_18:SetText("Кровосос")
	btn_19:SetText("Снорк")
	btn_20:SetText("Псевдогигант")
	btn_21:SetText("Химера")
	btn_22:SetText("Контролёр")
	btn_23:SetText("Бюрер")
	btn_24:SetText("Зомби")
	btn_25:SetText("Излом")
	btn_26:SetText("Полтергейст")
	btn_27:SetText("Огненный полтергейст")
	btn_28:SetText("Зомби-призрак")
end
end

function atlas:InitCallBacks()
	self:AddCallback("btn_0", ui_events.BUTTON_CLICKED, self.on_quit, self)
	self:AddCallback("btn_1", ui_events.BUTTON_CLICKED, self.cheat1, self)
	self:AddCallback("btn_2", ui_events.BUTTON_CLICKED, self.cheat2, self)
	self:AddCallback("btn_3", ui_events.BUTTON_CLICKED, self.cheat3, self)
	self:AddCallback("btn_4", ui_events.BUTTON_CLICKED, self.cheat4, self)
	self:AddCallback("btn_5", ui_events.BUTTON_CLICKED, self.cheat5, self)
	self:AddCallback("btn_6", ui_events.BUTTON_CLICKED, self.cheat6, self)
	self:AddCallback("btn_7", ui_events.BUTTON_CLICKED, self.cheat7, self)
	self:AddCallback("btn_8", ui_events.BUTTON_CLICKED, self.cheat8, self)
	self:AddCallback("btn_9", ui_events.BUTTON_CLICKED, self.cheat9, self)
	self:AddCallback("btn_10", ui_events.BUTTON_CLICKED, self.cheat10, self)
	self:AddCallback("btn_11", ui_events.BUTTON_CLICKED, self.cheat11, self)
	self:AddCallback("btn_12", ui_events.BUTTON_CLICKED, self.cheat12, self)
	self:AddCallback("btn_13", ui_events.BUTTON_CLICKED, self.cheat13, self)
	self:AddCallback("btn_14", ui_events.BUTTON_CLICKED, self.cheat14, self)
	self:AddCallback("btn_15", ui_events.BUTTON_CLICKED, self.cheat15, self)
	self:AddCallback("btn_16", ui_events.BUTTON_CLICKED, self.cheat16, self)
	self:AddCallback("btn_17", ui_events.BUTTON_CLICKED, self.cheat17, self)
	self:AddCallback("btn_18", ui_events.BUTTON_CLICKED, self.cheat18, self)
	self:AddCallback("btn_19", ui_events.BUTTON_CLICKED, self.cheat19, self)
	self:AddCallback("btn_20", ui_events.BUTTON_CLICKED, self.cheat20, self)
	self:AddCallback("btn_21", ui_events.BUTTON_CLICKED, self.cheat21, self)
	self:AddCallback("btn_22", ui_events.BUTTON_CLICKED, self.cheat22, self)
	self:AddCallback("btn_23", ui_events.BUTTON_CLICKED, self.cheat23, self)
	self:AddCallback("btn_24", ui_events.BUTTON_CLICKED, self.cheat24, self)
	self:AddCallback("btn_25", ui_events.BUTTON_CLICKED, self.cheat25, self)
	self:AddCallback("btn_26", ui_events.BUTTON_CLICKED, self.cheat26, self)
	self:AddCallback("btn_27", ui_events.BUTTON_CLICKED, self.cheat27, self)
	self:AddCallback("btn_28", ui_events.BUTTON_CLICKED, self.cheat28, self)
end

function atlas:OnKeyboard(dik, keyboard_action)
	CUIScriptWnd.OnKeyboard(self,dik,keyboard_action)
	if keyboard_action == ui_events.WINDOW_KEY_PRESSED then
	if dik == DIK_keys.DIK_ESCAPE then
	self:on_quit()
end	
end
	return true
end

function atlas:on_quit()
	self:GetHolder():start_stop_menu (self,true)
end

function atlas:spawn(spawn_item)
	local text = self:GetEditBox("edit_box"):GetText()
	local compass = text
	local actor_position = vector()
	local level_vertex
	local game_vertex
	local n = 1
	local sf = string.find(text,",")
	if sf then
n = string.sub(text,sf+1)+0
	if n==nil then
n = 0
end
	compass = string.sub(text,1,sf-1)
end
	actor_position = db.actor:position()
	level_vertex = db.actor:level_vertex_id()
	game_vertex = db.actor:game_vertex_id()
if compass ~= "N" then
	actor_position.z = actor_position.z - n
end
if compass ~= "n" then
	actor_position.z = actor_position.z - n
end
if compass ~= "S" then
	actor_position.z = actor_position.z + n
end
if compass ~= "s" then
	actor_position.z = actor_position.z + n
end
if compass ~= "E" then
	actor_position.x = actor_position.x - n
end
if compass ~= "e" then
	actor_position.x = actor_position.x - n
end
if compass ~= "W" then
	actor_position.x = actor_position.x + n
end
if compass ~= "w" then
	actor_position.x = actor_position.x + n
end
	return alife():create(spawn_item,vector():set(actor_position.x,actor_position.y,actor_position.z),level_vertex,game_vertex)
end

function atlas:cheat15()
	self:spawn("yan_ecolog_respawn_1")
end

function atlas:cheat1()
	local random18 = math.random(1, 18)
	if random18 == 1 then
self:spawn("agr_stalker_regular")
end
	if random18 == 2 then
self:spawn("agr_stalker_veteran")
end
	if random18 == 3 then
self:spawn("mil_neutral_barier_respawn_1")
end
	if random18 == 4 then
self:spawn("mil_stalker_respawn_1")
end
	if random18 == 5 then
self:spawn("mil_stalker_respawn_2")
end
	if random18 == 6 then
self:spawn("mil_stalker_respawn_3")
end
	if random18 == 7 then
self:spawn("gar_stalker_respawn_1")
end
	if random18 == 8 then
self:spawn("gar_stalker_respawn_2")
end
	if random18 == 9 then
self:spawn("esc_stalker_respawn_1")
end
	if random18 == 10 then
self:spawn("esc_stalker_respawn_2")
end
	if random18 == 11 then
self:spawn("ds_stalker_respawn_1")
end
	if random18 == 12 then
self:spawn("ds_stalker_respawn_2")
end
	if random18 == 13 then
self:spawn("bar_stalker_respawn_1")
end
	if random18 == 14 then
self:spawn("bar_stalker_respawn_2")
end
	if random18 == 15 then
self:spawn("bar_stalker_respawn_3")
end
	if random18 == 16 then
self:spawn("bar_stalker_respawn_4")
end
	if random18 == 17 then
self:spawn("rad_freedom_respawn_1")
end
	if random18 == 18 then
self:spawn("pri_respawn_neutral2")
end
end

function atlas:spawn_8()
	local random7 = math.random(1, 7)
	if random7 == 1 then
self:spawn("gar_dolg_respawn_1")
end
	if random7 == 2 then
self:spawn("gar_dolg_respawn_2")
end
	if random7 == 3 then
self:spawn("bar_dolg_respawn_1")
end
	if random7 == 4 then
self:spawn("bar_dolg_respawn_2")
end
	if random7 == 5 then
self:spawn("bar_dolg_respawn_3")
end
	if random7 == 6 then
self:spawn("dolg_regular")
end
	if random7 == 7 then
self:spawn("pri_respawn_dolg2")
end
end

function atlas:spawn_9()
	local random9 = math.random(1, 9)
	if random9 == 1 then
self:spawn("mil_freedom_respawn_1")
end
	if random9 == 2 then
self:spawn("mil_freedom_respawn_2")
end
	if random9 == 3 then
self:spawn("mil_freedom_respawn_3")
end
	if random9 == 4 then
self:spawn("mil_freedom_respawn_sniper")
end
	if random9 == 5 then
self:spawn("mil_freedom_barier_respawn_1")
end
	if random9 == 6 then
self:spawn("rad_freedom_respawn_2")
end
	if random9 == 7 then
self:spawn("rad_freedom_respawn_3")
end
	if random9 == 8 then
self:spawn("sim_freedom_master_quest")
end
	if random9 == 9 then
self:spawn("pri_respawn_92")
end
end

function atlas:cheat10()
	local random11 = math.random(1, 11)
	if random11 == 1 then
self:spawn("mil_killer_respawn_1")
end
	if random11 == 2 then
self:spawn("mil_killer_respawn_2")
end
	if random11 == 3 then
self:spawn("mil_killer_respawn_3")
end
	if random11 == 4 then
self:spawn("mil_killer_respawn_4")
end
	if random11 == 5 then
self:spawn("cit_killer_respawn_1")
end
	if random11 == 6 then
self:spawn("cit_killer_respawn_2")
end
	if random11 == 7 then
self:spawn("cit_killer_respawn_3")
end
	if random11 == 8 then
self:spawn("ros_killer_respawn_1")
end
	if random11 == 9 then
self:spawn("ros_killer_respawn_2")
end
	if random11 == 10 then
self:spawn("ros_killer_respawn_3")
end
	if random11 == 11 then
self:spawn("ros_killer_respawn_4")
end
end

function atlas:spawn_3()
	local random6 = math.random(1, 6)
	if random6 == 1 then
self:spawn("rad_zombied_respawn_1")
end
	if random6 == 2 then
self:spawn("rad_zombied_respawn_2")
end
	if random6 == 3 then
self:spawn("rad_zombied_respawn_3")
end
	if random6 == 4 then
self:spawn("yan_zombied_respawn_1")
end
	if random6 == 5 then
self:spawn("yan_zombied_respawn_2")
end
	if random6 == 6 then
self:spawn("yan_zombied_respawn_3")
end
end

function atlas:cheat2()
	local random17 = math.random(1, 17)
	if random17 == 1 then
self:spawn("ds_bandit_respawn_1")
end
	if random17 == 2 then
self:spawn("ds_bandit_respawn_2")
end
	if random17 == 3 then
self:spawn("ds_bandit_respawn_3")
end
	if random17 == 4 then
self:spawn("gar_bandit_respawn_1")
end
	if random17 == 5 then
self:spawn("gar_bandit_respawn_2")
end
	if random17 == 6 then
self:spawn("agr_bandit_respawn_1")
end
	if random17 == 7 then
self:spawn("agr_bandit_respawn_2")
end
	if random17 == 8 then
self:spawn("esc_bandit_respawn_1")
end
	if random17 == 9 then
self:spawn("esc_bandit_respawn_2")
end
	if random17 == 10 then
self:spawn("cit_bandit_respawn_1")
end
	if random17 == 11 then
self:spawn("cit_bandit_respawn_2")
end
	if random17 == 12 then
self:spawn("val_bandit_respawn_1")
end
	if random17 == 13 then
self:spawn("val_bandit_respawn_2")
end
	if random17 == 14 then
self:spawn("val_bandit_respawn_3")
end
	if random17 == 15 then
self:spawn("val_bandit_respawn_4")
end
	if random17 == 16 then
self:spawn("ros_bandit_respawn_3")
end
	if random17 == 17 then
self:spawn("ros_bandit_respawn_4")
end
end

function atlas:cheat16()
	local random8 = math.random(1, 8)
	if random8 == 1 then
self:spawn("rad_soldier_master")
end
	if random8 == 2 then
self:spawn("rad_specnaz_respawn_specnaz")
end
	if random8 == 3 then
self:spawn("agr_soldier_regular")
end
	if random8 == 4 then
self:spawn("agr_soldier_veteran")
end
	if random8 == 5 then
self:spawn("esc_soldier_respawn_1")
end
	if random8 == 6 then
self:spawn("esc_soldier_respawn_specnaz")
end
	if random8 == 7 then
self:spawn("val_soldier_respawn_1")
end
	if random8 == 8 then
self:spawn("pri_respawn_162")
end
end

function atlas:cheat17()
	local random8 = math.random(1, 8)
	if random8 == 1 then
self:spawn("mil_monolit_rush_respawn_1")
end
	if random8 == 2 then
self:spawn("pri_monolith_respawn_1")
end
	if random8 == 3 then
self:spawn("pri_monolith_respawn_2")
end
	if random8 == 4 then
self:spawn("pri_monolith_respawn_3")
end
	if random8 == 5 then
self:spawn("rad_monolith_respawn_1")
end
	if random8 == 6 then
self:spawn("rad_monolith_respawn_2")
end
	if random8 == 7 then
self:spawn("rad_monolith_respawn_3")
end
	if random8 == 8 then
self:spawn("sar_monolith_respawn2")
end
end

function atlas:spawn_4()
	local random4 = math.random(1, 4)
	if random4 == 1 then
self:spawn("dog_weak")
end
	if random4 == 2 then
self:spawn("dog_normal")
end
	if random4 == 3 then
self:spawn("dog_strong")
end
	if random4 == 4 then
self:spawn("dog_old")
end
end

function atlas:spawn_5()
	local random3 = math.random(1, 3)
	if random3 == 1 then
self:spawn("pseudodog_weak")
end
	if random3 == 2 then
self:spawn("pseudodog_normal")
end
	if random3 == 3 then
self:spawn("pseudodog_strong")
end
end

function atlas:spawn_6()
	local random2 = math.random(1, 2)
	if random2 == 1 then
self:spawn("psy_dog")
end
	if random2 == 2 then
self:spawn("psy_dog_radar")
end
end

function atlas:cheat12()
	local random3 = math.random(1, 3)
	if random3 == 1 then
self:spawn("flesh_weak")
end
	if random3 == 2 then
self:spawn("flesh_normal")
end
	if random3 == 3 then
self:spawn("flesh_strong")
end
end

function atlas:cheat11()
	local random4 = math.random(1, 4)
	if random4 == 1 then
self:spawn("boar_weak")
end
	if random4 == 2 then
self:spawn("boar_normal")
end
	if random4 == 3 then
self:spawn("boar_strong")
end
end

function atlas:cheat13()
	self:spawn("tushkano_normal")
end

function atlas:cheat14()
	local random3 = math.random(1, 3)
	if random3 == 1 then
self:spawn("rat_normal")
end
	if random3 == 2 then
self:spawn("rat_normal2")
end
	if random3 == 3 then
self:spawn("rat_normal3")
end
end

function atlas:spawn_7()
	local random3 = math.random(1, 3)
	if random3 == 1 then
self:spawn("cat_weak")
end
	if random3 == 2 then
self:spawn("cat_normal")
end
	if random3 == 3 then
self:spawn("cat_strong")
end
end

function atlas:cheat19()
	local random7 = math.random(1, 7)
	if random7 == 1 then
self:spawn("snork_weak")
end
	if random7 == 2 then
self:spawn("snork_normal")
end
	if random7 == 3 then
self:spawn("snork_strong")
end
	if random7 == 4 then
self:spawn("snork_jumper")
end
	if random7 == 5 then
self:spawn("snork_indoor")
end
	if random7 == 6 then
self:spawn("snork_outdoor")
end
	if random7 == 7 then
self:spawn("aes_snork")
end
end

function atlas:cheat18()
	local random4 = math.random(1, 4)
	if random4 == 1 then
self:spawn("bloodsucker_weak")
end
	if random4 == 2 then
self:spawn("bloodsucker_normal")
end
	if random4 == 3 then
self:spawn("bloodsucker_strong")
end
	if random4 == 4 then
self:spawn("bloodsucker_mil")
end
end

function atlas:cheat20()
	local random4 = math.random(1, 4)
	if random4 == 1 then
self:spawn("m_gigant_normal")
end
	if random4 == 2 then
self:spawn("gigant_normal")
end
	if random4 == 3 then
self:spawn("gigant_strong")
end
	if random4 == 4 then
self:spawn("gigant_undead")
end
end

function atlas:cheat21()
	local random3 = math.random(1, 3)
	if random3 == 1 then
self:spawn("chimera_weak")
end
	if random3 == 2 then
self:spawn("chimera_normal")
end
end

function atlas:cheat23()
	local random3 = math.random(1, 3)
	if random3 == 1 then
self:spawn("burer_weak")
end
	if random3 == 2 then
self:spawn("burer_normal")
end
	if random3 == 3 then
self:spawn("burer_strong")
end
end

function atlas:cheat22()
	local random5 = math.random(1, 5)
	if random5 == 1 then
self:spawn("controller_tubeman")
end
	if random5 == 2 then
self:spawn("m_controller_normal")
end
	if random5 == 3 then
self:spawn("m_controller_normal_fat")
end
	if random5 == 4 then
self:spawn("m_controller_old")
end
	if random5 == 5 then
self:spawn("m_controller_old_fat")
end
end

function atlas:cheat24()
	local random6 = math.random(1, 6)
	if random6 == 1 then
self:spawn("zombie_weak")
end
	if random6 == 2 then
self:spawn("zombie_normal")
end
	if random6 == 3 then
self:spawn("zombie_normal2")
end
	if random6 == 4 then
self:spawn("zombie_normal3")
end
	if random6 == 5 then
self:spawn("zombie_strong")
end
	if random6 == 6 then
self:spawn("zombie_immortal")
end
end

function atlas:cheat25()
	self:spawn("m_fracture_e")
end

function atlas:cheat28()
	self:spawn("zombie_ghost")
end

function atlas:cheat26()
	local random2 = math.random(1, 2)
	if random2 == 1 then
self:spawn("m_poltergeist_normal_tele")
end
	if random2 == 2 then
self:spawn("m_poltergeist_tele_outdoor")
end
end

function atlas:cheat27()
	local random2 = math.random(1, 2)
	if random2 == 1 then
self:spawn("m_poltergeist_normal_flame")
end
	if random2 == 2 then
self:spawn("m_poltergeist_strong_flame")
end
end