Jump to content
Sign in to follow this  
Holter

[BETA] Ущелье песни войны

Recommended Posts

Здравствуйте. Как и обещал выкладываю разработку на ваш суд, сразу предупреждаю, код сырой, но на момент тестирования был рабочий, писал чисто ради хобби, но времени в какой-то момент стало не хватать и всё по красоте не получилось сделать. Так что тестируем, пишем ошибки, будем править, в этом помогу.

 

Гайд по локации

 

Первым делом качаем архив с картой и файлами для серверной стороны: Я.Диск

 

1. functions.lua

Функция cha_timer, добавляем в неё

	--------------------------
	--  Ущелье Песни Войны	--
	--------------------------
	
	-- Цикл проверки и отсева игроков не онлайн
	for COUNT_PLAYER = 0, table.getn(PLAYER_CHA_TEAM), 1 do
		if GetChaMapName(PLAYER_CHA_TEAM[COUNT_PLAYER]) == nil and PLAYER_CHA_TEAM[COUNT_PLAYER] ~= 1 and IsPlayer(role) == 1 then
			PLAYER_CHA_TEAM[COUNT_PLAYER] = 1
			COUNT_PLAYER_ONLINE = COUNT_PLAYER_ONLINE - 1
		end
	end	
	
	local times = os.time()
	if SONGWAR_RED_TOWER_ONE < times and SONGWAR_RED_TOWER_ONE ~= 0 then
		SONGWAR_RED_TOWER_ONE = 0
	elseif SONGWAR_RED_TOWER_TWO < times and SONGWAR_RED_TOWER_ONE ~= 0 then
		SONGWAR_RED_TOWER_TWO = 0
	elseif SONGWAR_GREEN_TOWER_ONE < times and SONGWAR_RED_TOWER_ONE ~= 0 then
		SONGWAR_GREEN_TOWER_ONE = 0
	elseif SONGWAR_GREEN_TOWER_TWO < times and SONGWAR_RED_TOWER_ONE ~= 0 then
		SONGWAR_GREEN_TOWER_TWO = 0		
	end
	
	if math.mod(now_tick, 120) == 0 and now_tick > 0 and GetChaMapName(role) == "songwar" then
		SystemNotice(role, "-----------------------------")
		SystemNotice(role, "----Ущелье Песни Войны-------")
		SystemNotice(role, "-----------Очки--------------")
		SystemNotice(role, "Красная команда: "..SONGWAR_RED_SCORE.."/"..SONGWAR_MAX_SCORE)
		SystemNotice(role, "Зеленая команда: "..SONGWAR_GREEN_SCORE.."/"..SONGWAR_MAX_SCORE)
	end
	
	-- Восстановление эффектов
	if math.mod(now_tick, 120) == 0 and now_tick > 0 and SONG_START == 1 then
		bonus_revive()
	end	
	
	-- Телепортация при закрытии
	if SONG_START == 0 and GetChaSideID(role) > 0 and GetChaMapName(role) == "songwar" then
		MoveCity(role, "Argent City")
	end

	-- Проверка на старт 
	if SONG_START == 1 and SONGWAR_START_TIME > 0 and GetChaSideID(role) > 0 then
		check_start_songwar(role)
	end
	
	-- Создание команды
	if SONG_START == 0 and COUNT_PLAYER_ONLINE >= SONGWAR_MIN_PLAYER then
		team_create()
	end
	
	-- Удаление ресурсов башни
	local is_resource = GetChaItem2 ( role , 2 , 7195 )
	if GetChaMapName(role) ~= "songwar" and is_resource ~= nil then
		TakeItem( role, 0, 7195, 1 )
	end

	flag_drop(role)
	bonus_songwar(role)
	capture_flag(role)	
	
	--------------------------
	--  Ущелье Песни Войны	--
	--	       Конец		--
	--------------------------	

 

Добавляем в конец файла functions.lua

 

------------------------------------------
--		Ущелье песни войны				--
--		Код сырой, но вроде рабочий		--
------------------------------------------

-- Функция возврата флага
function flag_restore(typeTeam)
	-- Флаг красных
	if typeTeam == 1 then
		-- Обнуляем носителя флага
		FLAG_RED_GIVE = nil	
		-- Возвращение флагов на базу
		AddState( CREATEFLAG_RED, CREATEFLAG_RED, 229, 1, 3600 )
		-- Оповещение о захвате
		FLAG_RED_CAPTURE = 0
		CHECK_DEATH_SONGWAR = 0
		Notice("Флаг [Красных] возвращен на базу!")
	-- Флаг зеленых
	elseif typeTeam == 2 then
		FLAG_GREEN_GIVE = nil		
		AddState( CREATEFLAG_GREEN, CREATEFLAG_GREEN, 229, 1, 3600 )
		FLAG_GREEN_CAPTURE = 0
		CHECK_DEATH_SONGWAR = 0
		Notice("Флаг [Зеленых] возвращен на базу!")
	end
end

-- Функция портации на карту
function move_songwar()
	-- Переносим две команды на поле боя
	
	-- Зеленые
	local i = 0
	-- Циклом проверяем чтобы игрок был зарегистрирован и не вышел с игры
	for i = 1, table.getn(PLAYER_TEAM_ROLE_GREEN), 1 do
		if PLAYER_TEAM_ROLE_GREEN[i] ~= nil then
			Notice(GetChaDefaultName(PLAYER_TEAM_ROLE_GREEN[i]))
			MoveCity(PLAYER_TEAM_ROLE_GREEN[i], "Song War Green")
		end
	end	
	
	-- Красные
	for i = 1, table.getn(PLAYER_TEAM_ROLE_RED), 1 do
		if PLAYER_TEAM_ROLE_RED[i] ~= nil then
			MoveCity(PLAYER_TEAM_ROLE_RED[i], "Song War Red")
		end
	end	
end

-- Функция захвата флага
function capture_flag(role)
	-- Ущелье песни войны
	local death_song = IsChaLiving(role)
	local map_cha2 = GetChaMapName(role)
	
	if map_cha2 == "songwar" and IsPlayer(role) == 1 and death_song == 1 then	
		local pos_x9, pos_y9 = GetChaPos(role)
		
		-- Захват флага 1ой командой у 2ой команды
		-- Позиция флага Красной команды команды
		if (pos_x9 >= 18175 and pos_x9 <= 18325 and pos_y9 >= 5625 and pos_y9 <= 5825) then
			-- Проверка на команду
			if GetChaSideID(role)  == 1 then
				-- Если флаг не взят
				if FLAG_RED_GIVE == nil then
					Notice("Флаг [Красной] команды захвачен!" )
					-- Наложение флага на персонажа
					AddState(role, role, 229, 1, 3600)
					--AddState(role, role, 155, 1, 3600)
					FLAG_RED_GIVE = role					
					-- Снятие эффекта флага с точки
					RemoveState(CREATEFLAG_RED, 229)
					RemoveState(CREATEFLAG_RED, 155)
				end
			-- Принос флага 1ой команды 2ой командой
			elseif GetChaSideID(role) == 2 and GetChaStateLv(role, 229) > 0 and FLAG_RED_GIVE == nil then
				-- Снятие флага
				RemoveState(role, 229)
				--RemoveState(role, 155)
				-- Возврат на базу
				flag_restore(2)
				SONGWAR_RED_SCORE = SONGWAR_RED_SCORE + 300
				Notice("Ущелье Песни Войны: Команда [Красных] принесла флаг [Зеленых] на свою базу!")
			elseif GetChaSideID(role) == 2 and GetChaStateLv(role, 229) > 0 and FLAG_RED_GIVE ~= nil then	
				SystemNotice(role, "Вы не можете поставить флаг пока ваш захвачен!")
			end
		end
		-- Захват флага 2ой командой у 1ой команды
		-- Позиция флага Зеленой команды
		if (pos_x9 >= 2425 and pos_x9 <= 2575 and pos_y9 >= 5475 and pos_y9 <= 5625) then
			if GetChaSideID(role) == 2 then
				if FLAG_GREEN_GIVE == nil then
					Notice("Флаг [Зеленой] команды захвачен!" )
					AddState(role, role, 229, 1, 3600)
					--AddState(role, role, 155, 1, 3600)
					FLAG_GREEN_GIVE = role					
					RemoveState(CREATEFLAG_GREEN, 229)
					RemoveState(CREATEFLAG_GREEN, 155)
				end
			-- Принос флага 2ой команды 1ой командой
			elseif GetChaSideID(role) == 1 and GetChaStateLv(role, 229) > 0 and FLAG_GREEN_GIVE == nil then
				RemoveState(role, 229)
				--RemoveState(role, 155)
				flag_restore(1)
				SONGWAR_GREEN_SCORE = SONGWAR_GREEN_SCORE + 300
				Notice("Ущелье Песни Войны: Команда [Зеленых] принесла флаг [Красных] на свою базу!")
			elseif GetChaSideID(role) == 1 and GetChaStateLv(role, 229) > 0 and FLAG_GREEN_GIVE ~= nil then
				SystemNotice(role, "Вы не можете поставить флаг пока ваш захвачен!")
			end			
		end
		
		----------------------------------------
		-- 		Оповещение о захвате флага	  --
		----------------------------------------
		
		if GetChaSideID(role) == 1 and FLAG_GREEN_GIVE ~= nil and FLAG_GREEN_CAPTURE ~= 1 then
			BickerNotice(role, "[Красные] украли ваш флаг, скорее верните его!")
			FLAG_GREEN_CAPTURE = 1
		elseif GetChaSideID(role) == 2 and FLAG_RED_GIVE ~= nil and FLAG_RED_CAPTURE ~= 1 then
			BickerNotice(role, "[Зелёные] украли ваш флаг, скорее верните его!")
			FLAG_RED_CAPTURE = 1
		end
	end
end

-- Функция выдачи бонусов
function bonus_songwar(role)
	local map_cha3 = GetChaMapName(role)
	
	if map_cha3 == "songwar" and IsPlayer(role) == 1 then	
		local pos_x2, pos_y2 = GetChaPos(role)
		
		if (pos_x2 >= 14000 and pos_x2 <= 14300 and pos_y2 >= 5900 and pos_y2 <= 6300) and GetChaStateLv(EFFECT_BONUS_ONE, 239) > 0 then
			AddState(role, role, 239, 1, 10)
			RemoveState(EFFECT_BONUS_ONE, 239)
		elseif (pos_x2 >= 14000 and pos_x2 <= 14300 and pos_y2 >= 4700 and pos_y2 <= 5100) and GetChaStateLv(EFFECT_BONUS_TWO, 238) > 0 then
			AddState(role, role, 2, 1, 10)
			RemoveState(EFFECT_BONUS_TWO, 238)
		elseif (pos_x2 >= 6400 and pos_x2 <= 6700 and pos_y2 >= 5900 and pos_y2 <= 6300) and GetChaStateLv(EFFECT_BONUS_THREE, 239) > 0 then
			AddState(role, role, 239, 1, 10)	
			RemoveState(EFFECT_BONUS_THREE, 239)
		elseif (pos_x2 >= 6400 and pos_x2 <= 6700 and pos_y2 >= 4700 and pos_y2 <= 5000) and GetChaStateLv(EFFECT_BONUS_FOUR, 238) > 0 then
			AddState(role, role, 2, 1, 10)	
			RemoveState(EFFECT_BONUS_FOUR, 238)
		end
	end
end

-- Функция возврата бонусов на точки
function bonus_revive()
	if GetChaStateLv(EFFECT_BONUS_ONE, 239) == 0 then
		AddState(EFFECT_BONUS_ONE, EFFECT_BONUS_ONE, 239, 1, 99999999)	
	end
	
	if GetChaStateLv(EFFECT_BONUS_TWO, 238) == 0 then
		AddState(EFFECT_BONUS_TWO, EFFECT_BONUS_TWO, 238, 1, 99999999)
	end		
	
	if GetChaStateLv(EFFECT_BONUS_THREE, 239) == 0 then	
		AddState(EFFECT_BONUS_THREE, EFFECT_BONUS_THREE, 239, 1, 99999999)	
	end	
	
	if GetChaStateLv(EFFECT_BONUS_FOUR, 238) == 0 then
		AddState(EFFECT_BONUS_FOUR, EFFECT_BONUS_FOUR, 238, 1, 99999999)	
	end	
end

-- Создание команды
function team_create()
	for COUNT_PLAYER = 1, table.getn(PLAYER_CHA_TEAM), 1 do
		if PLAYER_TEAM_COUNT_RED > PLAYER_TEAM_COUNT_GREEN and PLAYER_CHA_TEAM[COUNT_PLAYER] ~= 1 then
			table.insert(PLAYER_TEAM_ROLE_GREEN, PLAYER_CHA_TEAM[COUNT_PLAYER])
			PLAYER_TEAM_COUNT_GREEN = PLAYER_TEAM_COUNT_GREEN + 1
		elseif PLAYER_TEAM_COUNT_RED <= PLAYER_TEAM_COUNT_GREEN and PLAYER_CHA_TEAM[COUNT_PLAYER] ~= 1 then
			table.insert(PLAYER_TEAM_ROLE_RED, PLAYER_CHA_TEAM[COUNT_PLAYER])
			PLAYER_TEAM_COUNT_RED = PLAYER_TEAM_COUNT_RED + 1
		end
	end
	move_songwar()
	SONG_START = 1
end

-- Функция сброса флага
function flag_drop(role)
	local pos_x4, pos_y4 = GetChaPos(role)
	
	-- Флаг зеленых захваченный красными
	if FLAG_RED_X ~= 0 then
		if GetChaSideID(role) > 0 then
			if (pos_x4 >= FLAG_RED_X-100 and pos_x4 <= FLAG_RED_X+100 and pos_y4 >= FLAG_RED_Y-100 and pos_y4 <= FLAG_RED_Y+100) then
				if GetChaSideID(role) == 2 and GetChaStateLv(role, 54) < 1 then
					DelCha(FLAG_DROP_RED)
					AddState(role, role, 229, 1, 3600)
					FLAG_GREEN_GIVE = role
					FLAG_RED_X = 0	
					FLAG_RED_Y = 0						
				elseif GetChaSideID(role) == 1 then
					flag_restore(2)
					DelCha(FLAG_DROP_RED)
					FLAG_RED_X = 0
					FLAG_RED_Y = 0
				end
			end
		end
	end
	
	if FLAG_GREEN_X ~= 0 then
		if GetChaSideID(role) > 0 then
			if (pos_x4 >= FLAG_GREEN_X-100 and pos_x4 <= FLAG_GREEN_X+100 and pos_y4 >= FLAG_GREEN_Y-100 and pos_y4 <= FLAG_GREEN_Y+100) then
				if GetChaSideID(role) == 1 and GetChaStateLv(role, 54) < 1 then
					DelCha(FLAG_DROP_GREEN)	
					AddState(role, role, 229, 1, 3600)
					FLAG_RED_GIVE = role
					FLAG_GREEN_X = 0
					FLAG_GREEN_Y = 0
				elseif GetChaSideID(role) == 2 then
					flag_restore(1)
					DelCha(FLAG_DROP_GREEN)
					FLAG_GREEN_X = 0
					FLAG_GREEN_Y = 0
				end
			end
		end
	end	
end

-- Старт боя
function check_start_songwar(role)
		local pos_x2, pos_y2 = GetChaPos(role)
		SystemNotice(role, "До начала боя осталось "..SONGWAR_START_TIME.." секунд, приготовьтесь!")
		
		if pos_x2 >= 13200 and pos_x2 <= 14100 and pos_y2 >= 4300 and pos_y2 <= 6700 and GetChaMapName(role) == "songwar" and GetChaSideID(role) == 2 then
			MoveCity(role, "Song War Green")
			SystemNotice(role, "Бой ещё не начался, запрещено покидать зону своей базы!")
		elseif pos_x2 >= 6400 and pos_x2 <= 7300 and pos_y2 >= 4400 and pos_y2 <= 6600 and GetChaMapName(role) == "songwar" and GetChaSideID(role) == 1 then
			MoveCity(role, "Song War Red")
			SystemNotice(role, "Бой ещё не начался, запрещено покидать зону своей базы!")	
		end	
end

function join_cha(role)
	if PLAYER_TEAM_COUNT_GREEN > PLAYER_TEAM_COUNT_RED then
		table.insert(PLAYER_TEAM_ROLE_RED, role)
		PLAYER_TEAM_COUNT_RED = PLAYER_TEAM_COUNT_RED + 1
		MoveCity(role, "Song War Green")
	elseif PLAYER_TEAM_COUNT_RED >= PLAYER_TEAM_COUNT_GREEN then
		table.insert(PLAYER_TEAM_ROLE_GREEN, role)
		PLAYER_TEAM_COUNT_GREEN = PLAYER_TEAM_COUNT_GREEN + 1
		MoveCity(role, "Song War Red")
	end
end


-- Вход на БГ
function enter_songwar( role )
	local i = 0
	if SONG_START == 0 and IsPlayer(role) == 1 then
		for count = 0, table.getn(PLAYER_CHA_TEAM), 1 do
			if GetChaDefaultName(PLAYER_CHA_TEAM[count]) == GetChaDefaultName(role) then
				PLAYER_CHA_TEAM[count] = role
				COUNT_PLAYER_ONLINE = COUNT_PLAYER_ONLINE + 1
				i = 1
				SystemNotice(role, "Вы встали в очередь на [Ущелье Песни Войны]. До начала осталось "..SONGWAR_MIN_PLAYER-COUNT_PLAYER_ONLINE.." человек(а)")
			end
		end
		if i < 1 and IsPlayer(role) == 1 then
			table.insert(PLAYER_CHA_TEAM, role)
			COUNT_PLAYER_ONLINE = COUNT_PLAYER_ONLINE + 1
			SystemNotice(role, "Вы встали в очередь на [Ущелье Песни Войны]. До начала осталось "..SONGWAR_MIN_PLAYER-COUNT_PLAYER_ONLINE.." человек(а)")
		end
	elseif SONG_START == 1 and IsPlayer(role) == 1 then
		join_cha(role)
	end
end

function attack_tower(role, team, birth)
	-- Красная команда
	if team == 1 then
		if birth == 1 and SONGWAR_RED_TOWER_ONE == 0 then
			local red_tower = CreateCha(1211, 17500, 4800, 145, 999999999)
			SetChaLifeTime(red_tower, 600000)
			SetChaSideID(red_tower, 2)
			SONGWAR_RED_TOWER_ONE = os.time() + 600
		elseif birth == 2 and SONGWAR_RED_TOWER_TWO == 0 then
			local red_tower = CreateCha(1211, 17500, 6400, 145, 999999999)
			SetChaLifeTime(red_tower, 600000)
			SetChaSideID(red_tower, 2)
			SONGWAR_RED_TOWER_TWO = os.time() + 600
		else
			SystemNotice(role, "Башня уже построенна!")
		end
	elseif team == 2 then
		if birth == 1 and SONGWAR_GREEN_TOWER_ONE == 0 then
			local green_tower = CreateCha(1210, 3300, 6400, 145, 999999999)
			SetChaLifeTime(green_tower, 600000)
			SetChaSideID(green_tower, 1)
			SONGWAR_GREEN_TOWER_ONE = os.time() + 600
		elseif birth == 2 and SONGWAR_GREEN_TOWER_TWO == 0 then
			local green_tower = CreateCha(1210, 3300, 4600, 145, 999999999)
			SetChaLifeTime(green_tower, 600000)
			SetChaSideID(green_tower, 1)
			SONGWAR_GREEN_TOWER_TWO = os.time() + 600
		else
			SystemNotice(role, "Башня уже построенна!")
		end		
	end
	return LUA_TRUE
end

function revive_songwar(role)
	local cha_gd = GetChaAttr ( role , ATTR_GD )
	local cha_del_gd = 300000
	if cha_gd >= cha_del_gd then
		TakeMoney(role, nil, cha_del_gd)
		RemoveState( role, 237 )
	else
		SystemNotice(role, "У вас не хватает золота!")
	end
end

 

Находим функцию Hp_Dmg и после local T = 0.25 вставляем

 

	-- Кладбище фракций
	local pos_x2, pos_y2 = GetChaPos(role)
	
	-- Кладбище зеленых
	if pos_x2 >= 18700 and pos_x2 <= 19300 and pos_y2 >= 1200 and pos_y2 <= 2400 and GetChaSideID(role) == 2 and FLAG_GREEN_GIVE ~= role then	
		dmg = 0
	end
	-- Кладбище красных
	if pos_x2 >= 1300 and pos_x2 <= 1800 and pos_y2 >= 8800 and pos_y2 <= 9700 and GetChaSideID(role) == 1 and FLAG_RED_GIVE ~= role then	
		dmg = 0
	end	

 

Так же это же добавляем в функцию Endure_Dmg

 

	-- Кладбище фракций
	local pos_x2, pos_y2 = GetChaPos(role)
	
	-- Кладбище зеленых
	if pos_x2 >= 18700 and pos_x2 <= 19300 and pos_y2 >= 1200 and pos_y2 <= 2400 and GetChaSideID(role) == 2 and FLAG_GREEN_GIVE ~= role then	
		hp = 0
	end
	-- Кладбище красных
	if pos_x2 >= 1300 and pos_x2 <= 1800 and pos_y2 >= 8800 and pos_y2 <= 9700 and GetChaSideID(role) == 1 and FLAG_RED_GIVE ~= role then	
		hp = 0
	end	

 

Находим функцию after_player_kill_player и добавляем

	if map_name_ATKER == "songwar" or map_name_DEFER == "songwar" then
		local atk_name = GetChaDefaultName ( ATKER )
		local def_name = GetChaDefaultName ( DEFER )
		
		if GetChaSideID(ATKER) == 1 then
			SONGWAR_GREEN_SCORE = SONGWAR_GREEN_SCORE + SONGWAR_KILL_SCORE
		elseif GetChaSideID(ATKER) == 2 then
			SONGWAR_RED_SCORE = SONGWAR_RED_SCORE + SONGWAR_KILL_SCORE
		end
		
		local Notice_all = "["..def_name.."] терпит поражение от ["..atk_name.."] в Ущелье Песни Войны и приносит своей команде "..SONGWAR_KILL_SCORE.." очков "
		GiveItem ( ATKER , 0 , 7195  , 1 , 4 )
		Notice ( Notice_all )
	end		

 

 

2. exp_and_level.lua

 

Открываем файл и находим функцию Relive и заменяем на эту

 

function Relive( role )
	local mxhp = GetChaAttr ( role , ATTR_MXHP ) 
	local mxsp = GetChaAttr ( role , ATTR_MXSP ) 
	
	if GetChaMapName(role) == "songwar" then
		-- Кладбище зеленых
		local greenx = { "15", "14", "15"}
		local greeny = { "93", "92", "89"}
		
		-- Кладбище красных
		local redx = { "191", "192", "190"}
		local redy = { "16", "18", "20"}	
		
		local time_resp = { "10", "15", "20" }
		
		local rand =  math.random(1,3)	
	
		-- Красные
		if GetChaSideID(role) == 2 then
			GoTo( role,  redx[rand], redy[rand], "songwar")
			AddState( role , role , 237 , 1 , time_resp[rand] )
			SystemNotice(role, "До воскрешения осталось "..time_resp[rand].." секунд!")
			local cha_hp = GetChaAttr(role, ATTR_HP) 
			local cha_sp = GetChaAttr(role, ATTR_SP)	
			local total_hp = mxhp - cha_hp 
			local total_sp = mxsp - cha_sp 
			SetCharaAttr ( total_hp , role , ATTR_HP )
			SetCharaAttr ( total_sp , role , ATTR_SP )
			ALLExAttrSet( role )
		-- Зеленые
		elseif GetChaSideID(role) == 1 then
			GoTo( role,  greenx[rand], greeny[rand], "songwar")
			AddState( role , role , 237 , 1 , time_resp[rand] )
			SystemNotice(role, "До воскрешения осталось "..time_resp[rand].." секунд!")
			local cha_hp = GetChaAttr(role, ATTR_HP) 
			local cha_sp = GetChaAttr(role, ATTR_SP)	
			local total_hp = mxhp - cha_hp 
			local total_sp = mxsp - cha_sp 
			SetCharaAttr ( total_hp , role , ATTR_HP )
			SetCharaAttr ( total_sp , role , ATTR_SP )
			ALLExAttrSet( role )
		end	
	else
		local hp = math.max ( 1, math.floor( ( mxhp * 0.01 ) + 0.5 ) )
		local sp = math.max ( 1, math.floor( ( mxsp * 0.01 ) + 0.5 ) )
		SetCharaAttr ( hp , role , ATTR_HP ) 
		SetCharaAttr ( sp , role , ATTR_SP )
	end
	
end 

 

3. variable.lua

 

Добавим наши глобальные переменные, а их много :D

 

------------------------------------------------------
--		Массивы и переменные ущелья песни войны  	--
------------------------------------------------------
CREATEFLAG_GREEN			= 0		-- Флаг 1ой команды
CREATEFLAG_RED				= 0		-- Флаг 2ой команды
FLAG_GREEN_GIVE				= nil	-- Взят ли флаг 1ой команды(зеленый)
FLAG_RED_GIVE				= nil	-- Взят ли флаг 2ой команды(красный)
CHECK_DEATH_SONGWAR			= 0

PLAYER_CHA_TEAM 			= {} 	-- Массив с персонажами

PLAYER_TEAM_ROLE_RED		= {}	-- Массив с дескрипторами(role) персонажей, [n] - role, тело - дескриптор
PLAYER_TEAM_ROLE_GREEN		= {}	-- Массив с дескрипторами(role) персонажей, [n] - role, тело - дескриптор
PLAYER_TEAM_COUNT_RED       = 0		-- Количество человек в красной команде
PLAYER_TEAM_COUNT_GREEN     = 0		-- Количество человек в зеленой команде

COUNT_PLAYER_ONLINE 		= 1		-- Сколько из них онлайн

FLAG_GREEN_CAPTURE			= 0		-- Чек захвата флага зелёных
FLAG_RED_CAPTURE			= 0		-- Чек захвата флага красных

EFFECT_BONUS_ONE			= 0
EFFECT_BONUS_TWO			= 0
EFFECT_BONUS_THREE			= 0
EFFECT_BONUS_FOUR			= 0

FLAG_DROP_GREEN				= 0
FLAG_DROP_RED				= 0

FLAG_RED_X					= 0
FLAG_RED_Y					= 0
FLAG_GREEN_X				= 0
FLAG_GREEN_Y				= 0

SONG_START					= 0
SONGWAR_MIN_PLAYER			= 2
SONGWAR_START_TIME			= 30
SONGWAR_MAX_SCORE			= 1500
SONGWAR_KILL_SCORE			= 10

SONGWAR_RED_TOWER_ONE 		= 0
SONGWAR_RED_TOWER_TWO 		= 0
SONGWAR_GREEN_TOWER_ONE 	= 0
SONGWAR_GREEN_TOWER_TWO 	= 0

SONGWAR_RED_SCORE			= 0
SONGWAR_GREEN_SCORE			= 0

 

4. skilleffect

 

-- +100 бега
function STATE_GO_Add ( role , statelv ) 

	
	--Характеристики персонажа
	local cha_bonus = GetChaAttr(role, ATTR_STATEV_MSPD)
	local add_bonus = 100
	local result_bonus = cha_bonus + add_bonus
	SetChaAttr(role, ATTR_STATEV_MSPD, result_bonus)
	ALLExAttrSet(role)  
end 

--Отнимание
function STATE_GO_Rem ( role , statelv )
	
	--Характеристики персонажа
	local cha_bonus = GetChaAttr(role, ATTR_STATEV_MSPD)
	local add_bonus = 100
	local result_bonus = cha_bonus - add_bonus
	SetChaAttr(role, ATTR_STATEV_MSPD, result_bonus)
	ALLExAttrSet(role)  
end

 

5. NpcSdk.lua

 

Добавляем в функцию MultiFunc

        elseif funclist[id].func == enter_songwar then
            return enter_songwar(character)			
        elseif funclist[id].func == revive_songwar then
            return revive_songwar(character)

 

В функцию MsgProc

		elseif item.func == enter_songwar then
            return enter_songwar(character)		
		elseif item.func == revive_songwar then
            return revive_songwar(character)

 

6. MissionSdk.lua

 

В функцию ActionsProc добавляем

		elseif actions[i].func == attack_tower then
			PRINT( "ActionProc:attack_tower, p1, p2", actions[i].p1, actions[i].p2 )
			local ret = attack_tower( character, actions[i].p1, actions[i].p2 )
			if ret ~= LUA_TRUE then
				PRINT( "ActionProc: attack_tower Не удалось!" )
				SystemNotice( character, "ActionProc: ошибка!" )
				return LUA_FALSE
			end		

 

7. NpcScriptX.lua

 

В любой вам понравившийся NpcScript добавляем

function r_tower()
	Talk( 1, "Диспетчер башень: У меня ты можешь построить башни для обороны своей базы, стоимость - 10 [Ресурс Базы] " )
	Text( 1, "Построить башню ", JumpPage, 3 )
	Text( 1, "Уйти ", CloseTalk )

	Talk( 3, "Диспетчер башень: Выбирай с какой стороны строить башню!")

	InitTrigger()
	TriggerCondition( 1, HasItem, 7195, 10 )
	TriggerAction( 1, TakeItem, 7195, 10 )
	TriggerAction( 1, attack_tower, 1, 1 )
	TriggerFailure( 1, JumpPage, 4 )
	Text( 3, "Слева ", MultiTrigger, GetMultiTrigger(), 1)

	InitTrigger()
	TriggerCondition( 1, HasItem, 7195, 10 )
	TriggerAction( 1, TakeItem, 7195, 10 )
	TriggerAction( 1, attack_tower, 1, 2 )
	TriggerFailure( 1, JumpPage, 4 )
	Text( 3, "Справа ", MultiTrigger, GetMultiTrigger(), 1)


	Talk( 4, "У тебя нету необходимых вещей для обмена, или твой инвентарь заблокирован " )
	Text( 4, "Назад ", JumpPage, 1) 
end

function r_songwar()
	Talk( 1, "Воин Песни Войны: Приветствую дорогой друг, нам требуется помощь в Ущельи Песни Войны чтобы отбить нашу базу от варваров, регистрируйся и помоги нам. [Во время BETA награды не начисляются!!!]" )
	Text( 1, "Встать в очередь ", enter_songwar )
	Text( 1, "Уйти ", CloseTalk )
end

function r_revive_song()
	Talk( 1, "Ангел Спаситель: Тебе требуется помощь? Мои услуги стоят очень скромно, всего 300.000 и я возвращу тебя с того света. " )
	Text( 1, "Воскреснуть ", revive_songwar )
	Text( 1, "Уйти ", CloseTalk )
end

 

 

8. birth_conf.lua

-- Ущелье песни войны
AddBirthPoint("Song War Green", "songwar", 178,52)
AddBirthPoint("Song War Green", "songwar", 178,60)
AddBirthPoint("Song War Green", "songwar", 173,57)
AddBirthPoint("Song War Green", "songwar", 174,63)

AddBirthPoint("Song War Red", "songwar", 30,51)
AddBirthPoint("Song War Red", "songwar", 32,54)
AddBirthPoint("Song War Red", "songwar", 27,59)
AddBirthPoint("Song War Red", "songwar", 35,59)

 

9. ScriptDefine.lua

AddMap( "songwar", "Song War" )

 

10. skilleff.txt

229	Флаг	-1	0	0	0	3	0	1	1	1	1	1	1	1	1	1	1	1	1	0	0	0	-1	0	0	0	583	-1	0	0	0	0	0	0	0
237	Остановка НПС	-1	0	State_Xy_Add	State_Xy_Rem	2	0	0	0	0	0	0	1	1	1	1	1	1	0	0	0	0	-1	0	0	1	0	1	0	0	0	0	0	0	0
238	Восстановление ЖЗ	-1	0	0	0	1	0	1	1	1	1	1	1	1	1	1	1	1	1	0	0	0	-1	173	0	0	174	-1	0	0	0	0	0	0	0
239	Бег	-1	0	STATE_GO_Add	STATE_GO_Rem	1	0	1	1	1	1	1	1	1	1	1	1	1	1	0	0	0	-1	0	0	0	214	-1	0	0	0	0	0	0	0

 

11. ItemInfo

7194	Сброс флага	n1645	10130015	0	0	0	0	0	00	31	0	0	0	0	0	1	1	1	1	99	0	1	-1	0	-1	0	0	-1	-1	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0	0	0,0	0	0	0	0	0	0	0	0	0	ItemUse_flag	0	0	0	0	0	0	Нажмите 2 раза чтобы сбросить флаг и отдать его другому игроку
7195	Ресурс Башни	n1702	10130015	0	0	0	0	0	00	31	0	0	0	0	0	1	0	1	1	99	0	1000	-1	0	-1	0	0	-1	-1	0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0,0	0	0,0	0,0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	Позволяет построить башню в Ущелье Песни Войны

 

12. ItemEffect.lua

-- Сброс флага
function ItemUse_flag ( role , Item )
 
	if GetChaStateLv(role, 229) > 0 and GetChaSideID(role) == 1 then
		local pos_x2, pos_y2 = GetChaPos(role)
		FLAG_DROP_GREEN = CreateCha(1209, pos_x2, pos_y2, 145, 30)
		SetChaLifeTime(FLAG_DROP_GREEN, 90000000)
		
		AddState( FLAG_DROP_GREEN, FLAG_DROP_GREEN, 229, 1, 360000 )
		AddState( FLAG_DROP_GREEN, FLAG_DROP_GREEN, 237, 1, 360000 )
		AddState( FLAG_DROP_GREEN, FLAG_DROP_GREEN, 155, 1, 360000 )
		AddState( role, role, 54, 1, 3 )
		FLAG_GREEN_GIVE = nil
		RemoveState(role, 229)
		RemoveState(role, 155)
		FLAG_GREEN_X = pos_x2
		FLAG_GREEN_Y = pos_y2
		UseItemFailed ( role )
	elseif GetChaStateLv(role, 229) > 0 and GetChaSideID(role) == 2 then
		local pos_x2, pos_y2 = GetChaPos(role)
		FLAG_DROP_RED = CreateCha(1209, pos_x2, pos_y2, 145, 30)
		SetChaLifeTime(FLAG_DROP_RED, 90000000)
		
		AddState( FLAG_DROP_RED, FLAG_DROP_RED, 229, 1, 360000 )
		AddState( FLAG_DROP_RED, FLAG_DROP_RED, 237, 1, 360000 )
		AddState( FLAG_DROP_RED, FLAG_DROP_RED, 155, 1, 360000 )
		AddState( role, role, 54, 1, 3 )
		FLAG_RED_GIVE = nil
		RemoveState(role, 229)
		RemoveState(role, 155)
		FLAG_RED_X = pos_x2
		FLAG_RED_Y = pos_y2	
		UseItemFailed ( role )
	else
		SystemNotice(role, "У вас нет флага!")
		UseItemFailed ( role )
	end
end

 

13. CharacterInfo

1209	Флаг	Флаг	1	5	0	0	100	9999	9999	9999	9999	9999	0	0	0	0	0	0,0,0	1	1	100	182	-1	-1	0	0	0	1,2,3,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1	1,051	1,369	2,599	40	1,5,0	0,0,0	399	398	0	0	0,0,0	1	1	1	0	28,325,-1,-1,-1,-1,-1,-1,-1,-1,-1	80,20,-1,-1,-1,-1,-1,-1,-1,-1,-1	268,866,2609,271,865,864,862,863,-1,-1	2000,100000,2000,100000,100000,100000,20000,20000,-1,-1	0	0	0	0,-1,-1,-1,-1,-1,-1,-1,-1,-1	0,-1,-1,-1,-1,-1,-1,-1,-1,-1	10	1	5000	0	0	1	0	75	80000000	0	10000	0	640	960	40	200	300	300	10	115	100	1000	500	300	2000	400	0	79	42	117	192	42	42	20	0	0	0	15500	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0
1210	Сторожевая башня зеленых	Сторожевая башня зеленых	4	17	704	0	1	1	0	0	0	0	0	0	0	0	0	0,0,0	1	191	100	-1	-1	-1	0	0	0	0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1	1,166	1,141	4,263	40	1,0,0	2,5,0	399	385	0	0	497,496,495	0	0	0	0	253,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1	100,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1	0,-1,-1,-1,-1,-1,-1,-1,-1,-1	0,-1,-1,-1,-1,-1,-1,-1,-1,-1	0	0	0	0,-1,-1,-1,-1,-1,-1,-1,-1,-1	0,-1,-1,-1,-1,-1,-1,-1,-1,-1	10	0	1500	0	0	1	0	65	350000	0	10000	0	1120	1680	39	205	248	247	10	126	29	12	1000	1500	1500	0	0	130	78	57	200	76	70	20	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0
1211	Сторожевая башня красных	Сторожевая башня красных	4	17	703	0	1	1	0	0	0	0	0	0	0	0	0	0,0,0	1	191	100	-1	-1	-1	0	0	0	0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1	1,166	1,141	4,263	40	1,0,0	2,5,0	399	384	0	0	497,496,495	0	0	0	0	253,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1	100,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1	0,-1,-1,-1,-1,-1,-1,-1,-1,-1	0,-1,-1,-1,-1,-1,-1,-1,-1,-1	0	0	0	0,-1,-1,-1,-1,-1,-1,-1,-1,-1	0,-1,-1,-1,-1,-1,-1,-1,-1,-1	10	0	1500	0	0	1	0	65	350000	0	10000	0	1120	1680	39	205	248	247	10	126	29	12	1000	1500	1500	0	0	130	78	57	200	76	70	20	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0

 

14. magicseanpc

110	[BETA] Песня Войны	1	802	11	91400,358100	91400,358100	0	Shaitan City	13	0	r_songwar	0

 

15. mapinfo

 

43	songwar	Песня Войны	1	50,50	3,50,50	255,255,255

 

Локация и НПС откуда происходит регистрация должны находится на одном GS ибо так же накладывается ограничение по глобальным переменным, они существуют в пределах GS, например если NPC в Шайтане то и songwar должна быть запущена на GS с Шайтаном

 

Чтобы использовать команду &updateall во время работы карты необходимо проделать следующее, скажем спасибо Виктору:

 

21 час назад, V3ct0r сказал:

Создай файл с названием songwar_variable.lua в папке GameServer\resource\script\calculate  и помести в него все переменные, необходимые для работы карты. Затем помести следующий код в начало variable.lua


if (SONGWAR_VARIABLE == nil) then
	SONGWAR_VARIABLE = 1
	dofile(".\\resource\\script\\calculate\\songwar_variable.lua")
end

Теперь эти переменные не будут обнуляться при использовании команды &updateall

 

За создание команд отвечают две функции, это team_create() и join_cha(role), так что если есть желание сделать сбалансированные команды нужно изменять их, одна отвечает за создание команды перед запуском битвы, вторая за вход игроков если уже идёт бой.

 

Вроде всё, обязательно отписывайтесь, может не всё скопировал.

Edited by Holter
  • Like 3

Share this post


Link to post
Share on other sites

magicseanpc

110	[BETA] Песня Войны	1	802	11	91400,358100	91400,358100	0	Shaitan City	13	0	r_songwar	0

А так же забыл упомянуть два момента. Во первых, не в коем случае не используем команду &updateall во время боя ибо всё завязано на глобальных переменных, а они обнулятся. Второе, локация и НПС откуда происходит регистрация должны находится на одном GS ибо так же накладывается ограничение по глобальным переменным, они существуют в пределах GS, например если NPC в Шайтане то и songwar должна быть запущена на GS с Шайтаном

Share this post


Link to post
Share on other sites
29 минут назад, Holter сказал:

Во первых, не в коем случае не используем команду &updateall во время боя ибо всё завязано на глобальных переменных, а они обнулятся.

Создай файл с названием songwar_variable.lua в папке GameServer\resource\script\calculate  и помести в него все переменные, необходимые для работы карты. Затем помести следующий код в начало variable.lua

if (SONGWAR_VARIABLE == nil) then
	SONGWAR_VARIABLE = 1
	dofile(".\\resource\\script\\calculate\\songwar_variable.lua")
end

Теперь эти переменные не будут обнуляться при использовании команды &updateall

  • Like 3

Share this post


Link to post
Share on other sites
4 часа назад, NMS3RR сказал:

@Holter mapinfo.txt забыл 

Ну я думал о таком то догадаются, но всё равно добавил, спасибо :smile:

Кто-нибудь проверит то?

Edited by Holter

Share this post


Link to post
Share on other sites
5 часов назад, Holter сказал:

Ну я думал о таком то догадаются, но всё равно добавил, спасибо :smile:

Кто-нибудь проверит то?

Я точно не смогу проверить) 
У меня CharacterInfo в другом формате и iteminfo


Делай добро и бросай его в воду

Share this post


Link to post
Share on other sites
8 часов назад, NMS3RR сказал:

Я точно не смогу проверить) 
У меня CharacterInfo в другом формате и iteminfo

В каком? Там различие может быть в одном нуле на конце, его или добавить или удалить. Моб "флаг" это скопированный ланс с ID 1 и одетый не в существующие вещи

9999	9999	9999	9999	9999

Башни из сада эдель, так что их можно просто скопировать и на мои ID поставить или в файлах везде ID поменять.

 

Так же и с ItemInfo, один предмет просто на использование с функцией, второй простая лутина которая выдаётся за убийства и меняется на постановку башни.

Share this post


Link to post
Share on other sites
Скрытый текст

:rofl: сейчас бы не понимать с какими файлами работаешь, почему такая разница и от чего это зависит.... сложна, просто ору.
p.s. у него такой же формат как у Hotler

 

Share this post


Link to post
Share on other sites

Привет Всем проверил все норм был только не большой бак когда персонаж с красной команды не мог брать флаг пока соперник не украл и не пренес на базу после этого все норм..... может конечно это я что не так может делал будем пробывать еще ...... есть такой вопрос можно ли сделать так чтобы было видно у кого флаг чтобы подсвечивался персонаж ?

Share this post


Link to post
Share on other sites
3 часа назад, destroger сказал:

Привет Всем проверил все норм был только не большой бак когда персонаж с красной команды не мог брать флаг пока соперник не украл и не пренес на базу после этого все норм..... может конечно это я что не так может делал будем пробывать еще ...... есть такой вопрос можно ли сделать так чтобы было видно у кого флаг чтобы подсвечивался персонаж ?

Так он и должен подсвечиваться, в ногах аура эффекта должна быть как на скриншоте в гайде

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...