Ir para conteúdo

Featured Replies

Postado
4 minutos atrás, luanluciano93 disse:

Deve alteração na fórmula: 



formula = {hit = 3, block = 1, suport = 9},

 

Coloquei todos como 3 @luanluciano93, mas ainda parece não dividir bem. Também não consegui entender o cálculo, saberia explicar? Uma coisa que percebi, se trocar o id do Reward Bag, o script não entrega a reward.

 

sistemas/

REWARDCHEST = {
	rewardBagId = 2595,
	formula = {hit = 3, block = 3, suport = 3},
	storageExaust = 60000,
	town_id = 1,

 

creaturescripts/rewardchestboss

dofile('data/sistemas/rewardchest.lua')

local function addRewardLoot(uid, bossName, tabela_reward)
	local money = math.random(10, 40)
	local msg = "The following items are available in your reward chest:"
	local chest = doCreateItemEx(REWARDCHEST.rewardBagId)

	doItemSetAttribute(chest, "description", "Reward System has kill the boss ".. bossName ..".")

	if table.maxn(tabela_reward) > 0 then
		for x = 1, table.maxn(tabela_reward) do
			local rand = math.random(100)
			if rand <= tabela_reward[x][3] then
				local count = math.random(1, tabela_reward[x][2])
				doAddContainerItem(chest, tabela_reward[x][1], count)
				msg = msg .. " ".. (count > 1 and count or "") .." "..getItemNameById(tabela_reward[x][1])..","
			end
		end
		doPlayerSendTextMessage(uid, MESSAGE_INFO_DESCR, msg .. " and ".. money .." platinum coins.")
	else
		doPlayerSendTextMessage(uid, MESSAGE_INFO_DESCR, msg .. " ".. money .." platinum coins.")
	end

	doAddContainerItem(chest, 2152, money)
	doPlayerSendMailByName(getPlayerName(uid), chest, REWARDCHEST.town_id)

	local boss = REWARDCHEST.bosses[bossName]
	setPlayerStorageValue(uid, boss.storage, 0)
	doSendMagicEffect(getPlayerPosition(uid), CONST_ME_MAGIC_BLUE)
end

local function addLoot(tabela_loot, tabela_reward, all_loot)
	if table.maxn(tabela_loot) > 0 then
		if all_loot then
			for x = 1, table.maxn(tabela_loot) do
				table.insert(tabela_reward, tabela_loot[x])
			end
		else
			table.insert(tabela_reward, tabela_loot[math.random(table.maxn(tabela_loot))])
		end
	end

	return tabela_reward
end

local function rewardChestSystem(bossName)
	local players = {}
	local boss = REWARDCHEST.bosses[bossName]

	for _, uid in ipairs(getPlayersOnline()) do
		if getPlayerStorageValue(uid, boss.storage) > 0 then
			table.insert(players, uid)
		end
	end

	table.sort(players, function(a, b) return getPlayerStorageValue(a, boss.storage) > getPlayerStorageValue(b, boss.storage) end)

	local porcentagem = math.ceil(getPlayerStorageValue(players[1], boss.storage))

	for i = 1, table.maxn(players) do

		local tabela_reward = {}
		local pontos = getPlayerStorageValue(players[i], boss.storage)

		if i == 1 then
			addLoot(boss.comum, tabela_reward, false)
			addLoot(boss.semi_raro, tabela_reward, false)
			addLoot(boss.raro, tabela_reward, false)
			addLoot(boss.sempre, tabela_reward, true)
		elseif i >= 2 and pontos >= math.ceil((porcentagem * 0.8)) then
			addLoot(boss.comum, tabela_reward, false)
			addLoot(boss.semi_raro, tabela_reward, false)
			addLoot(boss.raro, tabela_reward, false)
			addLoot(boss.muito_raro, tabela_reward, false)
		elseif pontos < math.ceil((porcentagem * 0.8)) and pontos >= math.ceil((porcentagem * 0.6)) then
			addLoot(boss.comum, tabela_reward, false)
			addLoot(boss.semi_raro, tabela_reward, false)
			addLoot(boss.raro, tabela_reward, false)
		elseif pontos < math.ceil((porcentagem * 0.6)) and pontos >= math.ceil((porcentagem * 0.4)) then
			addLoot(boss.comum, tabela_reward, false)
			addLoot(boss.semi_raro, tabela_reward, false)
		elseif pontos < math.ceil((porcentagem * 0.4)) and pontos >= math.ceil((porcentagem * 0.1)) then
			addLoot(boss.comum, tabela_reward, false)
		end

		addRewardLoot(players[i], bossName, tabela_reward)
	end
end

function onDeath(cid, corpse, killer)
	local boss = REWARDCHEST.bosses[getCreatureName(cid):lower()]
	if boss then
		addEvent(rewardChestSystem, 1000, getCreatureName(cid):lower())
	end
	return true
end

function onStatsChange(cid, attacker, type, combat, value)
	if isMonster(cid) and type == STATSCHANGE_HEALTHLOSS and isPlayer(attacker) then
		local boss = REWARDCHEST.bosses[getCreatureName(cid):lower()]
		if boss and attacker then
			setPlayerStorageValue(attacker, boss.storage, getPlayerStorageValue(attacker, boss.storage) + math.ceil((value / REWARDCHEST.formula.hit)))
		end
	end
	return true
end

rewardchestpontos

dofile('data/sistemas/rewardchest.lua')

function onLogin(cid)
	for key, value in pairs(REWARDCHEST.bosses) do
		if getPlayerStorageValue(cid, value.storage) > 0 then
			setPlayerStorageValue(cid, value.storage, 0)
		end
	end
	registerCreatureEvent(cid, "RewardChestStats")
	return true
end

function onStatsChange(cid, attacker, type, combat, value)
	if isMonster(attacker) and (type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS) then
		local boss = REWARDCHEST.bosses[getCreatureName(attacker):lower()]
		if boss then
			setPlayerStorageValue(cid, boss.storage, getPlayerStorageValue(cid, boss.storage) + math.ceil((value / REWARDCHEST.formula.block)))
			setPlayerStorageValue(cid, REWARDCHEST.storageExaust, os.time() + 5)
		end
	elseif (isPlayer(attacker) and (type == STATSCHANGE_HEALTHGAIN or type == STATSCHANGE_MANAGAIN) and (getCreatureHealth(cid) < getCreatureMaxHealth(cid)) and (getPlayerStorageValue(cid, REWARDCHEST.storageExaust) >= os.time())) then
		for key, valor in pairs(REWARDCHEST.bosses) do
			if getPlayerStorageValue(cid, valor.storage) > 0 then
				if getCreatureHealth(cid) + value > getCreatureMaxHealth(cid) then
					local add = getCreatureMaxHealth(cid) - getCreatureHealth(cid)
					setPlayerStorageValue(attacker, valor.storage, getPlayerStorageValue(attacker, valor.storage) + math.ceil((add / REWARDCHEST.formula.suport)))
				else
					setPlayerStorageValue(attacker, valor.storage, getPlayerStorageValue(attacker, valor.storage) + math.ceil((value / REWARDCHEST.formula.suport)))
				end
			end
		end
	end
	return true
end

 

Editado por Bruno Rezende
correção de informação (veja o histórico de edições)

  • Respostas 92
  • Visualizações 20k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • luanluciano93
    luanluciano93

    msg = msg .. " ".. (tabela_reward[x][2] > 1 and tabela_reward[x][2] or "") .." ".. getItemNameById(tabela_reward[x][1]) ..","  

  • luanluciano93
    luanluciano93

    pessoal, só final de semana para fixar

  • Coloquei em meu servidor 8.60 (TFS 0.4) e funcionou de primeira sem erros na distro ou algo parecido. Sistema perfeito. Rep + !! Uma dica para quem quer imitar o global com este sistema e ter uma

Posted Images

Postado
  • Autor
9 horas atrás, Bruno Rezende disse:

Também não consegui entender o cálculo, saberia explicar?

fórmula do hit = 'dano no boss' dividido pelo 'valor definido na fórmula'.

fórmula do block = 'dano recebido' dividido pelo 'valor definido na fórmula'.
fórmula do support = 'quantidade que você healar de alguém que está no boss' dividido pelo valor definido na fórmula.

 

9 horas atrás, Bruno Rezende disse:

Uma coisa que percebi, se trocar o id do Reward Bag, o script não entrega a reward.

estranho, você colocou de um 'container' funcional ? 

Postado
5 horas atrás, luanluciano93 disse:

fórmula do hit = 'dano no boss' dividido pelo 'valor definido na fórmula'.

fórmula do block = 'dano recebido' dividido pelo 'valor definido na fórmula'.
fórmula do support = 'quantidade que você healar de alguém que está no boss' dividido pelo valor definido na fórmula.

 

estranho, você colocou de um 'container' funcional ? 

Por incrível que pareça sim. O container é funcional , conforme imagem. Mas quando mato o boss, recebo uma letter. Poderia avaliar meu script pra ver se está correto @luanluciano93, por favor?

image.png

Postado
11 minutos atrás, luanluciano93 disse:

sem tempo amigo, usa o padrão do tópico que vai funcionar

Sim, é idêntico ao que você postou, só queria ver essa questão mesmo do container diferente pra reward a e divisão dos rewards.

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo