Jump to content
Sign in to follow this  
Graf

Комбо

Recommended Posts

Комбо

Взято с архива.
Этот скрипт позволяет нам добавить в игру такое явление, как "Комбо". Естественно вы можете прикрутить выдачу призов или еще что-нибудь интересное.
Заходим в Server/resource/script/exp_and_level.lua и в конец вставляем:

GetExp_New_original = GetExp_New
GetExp_New = function (dead , atk)
	GetExp_New_original(dead , atk  )
	custom_GetExp_New(dead,atk)
end

function custom_GetExp_New(ignore, dead, atk)
	local map_name = GetChaMapName (atk)
	
	if ValidCha(atk) == 0  then 
		return 
	end 
	local a = Check_Combat_Mod(dead , atk ) 
	-- Игрок убивает монстров
	if a == 1 then
		PK_combo (atk,dead)	
	end
	-- Игрок убивает игроков
	if a == 3 then
		PK_combo (atk,dead)
	end
end

function PK_combo (character,target)
	local name = GetChaDefaultName(character)
	-- Проверяем наличие комбо
	if PlayerCombo[name] ~= nil then
		-- Если последнее комбо было меньше 5 секунд назад
		local time_bonus = PlayerCombo[name].count
		if time_bonus > 10 then
			time_bonus = math.ceil(time_bonus / 3)
		end
		if time_bonus > 20 then
			time_bonus = math.ceil(time_bonus / 7)
		end
		if time_bonus > 30 then
			time_bonus = math.ceil(time_bonus / 10)
		end
		local combo_time = 3 + time_bonus
		if PlayerCombo[name].last < combo_time then
			-- Увеличиваем кол-во комбо
			PlayerCombo[name].count = PlayerCombo[name].count + 1
			PlayerCombo[name].last = 0
			if PlayerCombo[name].count == 10 then
				AddGold(character,1000)
				Notice("["..name.."] комбо х10! ")
			end
			if PlayerCombo[name].count == 30 then
				Notice("["..name.."] комбонатор! ")
			end
			if PlayerCombo[name].count == 40 then
				AddGold(character,10000)
				Notice("["..name.."] комбоголик! ")
			end
			if PlayerCombo[name].count == 100 then
				AddGold(character,50000)
				Notice("["..name.."] сделал супер комбо!")
			end
			if PlayerCombo[name].count == 200 then
				AddGold(character,500000)
				Notice("["..name.."] да ты читак, х200 комбо!")
			end
			BickerNotice(character,PlayerCombo[name].count.."x комбо!")
		else
			-- Убираем бонус
			RemoveComboBonus(character)
			local highest_combo = GetPlayerCustomData(character,"combo")
			if highest_combo < PlayerCombo[name].count then
				SetPlayerCustomData(character,"combo",PlayerCombo[name].count)
			end
			-- Удаляем комбо
			PlayerCombo[name] = nil
		end
	else
		-- Комбо отсутствует, поставим 1
		PlayerCombo[name] = { last = 1, count = 1}
	end
end

function PK_combo_timer (character)
	local name = GetChaDefaultName(character)
	-- Игрок совершает комбо
	if PlayerCombo[name] ~= nil then
		local time_bonus = PlayerCombo[name].count
		if time_bonus > 10 then
			time_bonus = math.ceil(time_bonus / 3)
		end
		if time_bonus > 20 then
			time_bonus = math.ceil(time_bonus / 7)
		end
		if time_bonus > 30 then
			time_bonus = math.ceil(time_bonus / 10)
		end
		local combo_time = 3 + time_bonus
		if PlayerCombo[name].last > combo_time then
			PlayerCombo[name] = nil
		else
			-- Увеличиваем таймер
			PlayerCombo[name].last = PlayerCombo[name].last + 1
			-- Добавляем бонус
			AddComboBonus(character,PlayerCombo[name].count)
		end
	else
		RemoveComboBonus(character)
	end
end

function AddComboBonus(character,amount)
	-- Добавляем бонус
	SetCharaAttr(amount ,character , ATTR_STATEV_MSPD)
	SetCharaAttr(amount ,character , ATTR_STATEV_ASPD)
	ALLExAttrSet(character)
end

function RemoveComboBonus(character)
	-- Убираем бонус
	SetCharaAttr(0 ,character , ATTR_STATEV_MSPD)
	SetCharaAttr(0 ,character , ATTR_STATEV_ASPD)
	ALLExAttrSet(character)
end

 

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