What's new

Mods System nagr?d

buchaLL

bez spiny, luźno
Joined
Aug 2, 2011
Messages
1,013
Reaction score
68
Age
27
Autor: luanluciano93
Opis: Po zabiciu moba z tabeli REWARDCHEST - > bosses otrzymujemy nagrody z tabeli comum, kt?re znajdziemy w naszym dp zapakowane w paczk?.

rewardchest.lua (wrzucamy do g??wnego folderu)
[lua]-- Sistema de recompensa criado por luanluciano93

REWARDCHEST = {
rewardBagId = 2595,
formula = {hit = 3, block = 1, suport = 9},
storageExaust = 60000,
town_id = 1,
bosses = {
["ghazbaran"] =
{
comum = {
{2143, 10, 100}, -- white pearl
{2146, 10, 100}, -- small sapphire
{2145, 10, 100}, -- small diamond
{2144, 10, 100}, -- black pearl
{2149, 10, 100}, -- small emeralds
{5954, 3, 100}, -- demon horn
{7896, 1, 100}, -- glacier kilt
{7590, 1, 100}, -- great mana potion
{2179, 1, 100}, -- gold ring
{2151, 1, 100}, -- talon
},

semi_raro = {
{2152, 90, 100}, -- platinum coin
{7368, 50, 100}, -- assassin star
{2130, 1, 100}, -- golden amulet
{2436, 1, 100}, -- skull staff
{2447, 1, 100}, -- twin axe
{2171, 1, 100}, -- platinum amulet
{2158, 1, 100}, -- blue gem
{2393, 1, 100}, -- giant sword
{2164, 1, 100}, -- might ring
{7454, 1, 100}, -- glorious axe
{6553, 1, 100}, -- ruthless axe
{9971, 1, 100}, -- gold ingot
},

raro = {
{2160, 3, 100}, -- crystal coin
{8887, 1, 100}, -- frozen plate
{2470, 1, 100}, -- golden legs
{2472, 1, 100}, -- magic plate armor
{7431, 1, 100}, -- demonbone
{2520, 1, 100}, -- demon shield
{5943, 1, 100}, -- morgaroth hearth
{2466, 1, 100}, -- golden armor
{2514, 1, 100}, -- mastermind shield
{2142, 1, 100}, -- ancient amulet
{2123, 1, 100}, -- ring of the sky
{1984, 1, 100}, -- blue tome
},

muito_raro = {
{8866, 1, 100}, -- robe of the ice queen
{6553, 1, 100}, -- ruthless axe
{8884, 1, 100}, -- oceanborn leviathan armor
{2421, 1, 100}, -- thunder hammer
{2646, 1, 100}, -- golden boots
{7455, 1, 100}, -- mythril axe
},

sempre = {
{2148, 90, 100}, -- gold coin
{6500, 9, 100}, -- demonic essence
{2177, 1, 100}, -- life crystal
{2214, 1, 100}, -- ring of healing
},

storage = 65479,
},

["orshabaal"] =
{
comum = {
{2143, 10, 100}, -- white pearl
{2146, 10, 100}, -- small sapphire
{2145, 10, 100}, -- small diamond
{2144, 10, 100}, -- black pearl
{2149, 10, 100}, -- small emeralds
{5954, 3, 100}, -- demon horn
{7896, 1, 100}, -- glacier kilt
{2432, 1, 100}, -- fire axe
{2462, 1, 100}, -- devil helmet
{7590, 1, 100}, -- great mana potion
{2179, 1, 100}, -- gold ring
{2151, 1, 100}, -- talon
},

semi_raro = {
{2195, 1, 100}, -- boots of haste
{2436, 1, 100}, -- skull staff
{2393, 1, 100}, -- giant sword
{5954, 5, 100}, -- demon horn
},

raro = {
{2470, 1, 100}, -- golden legs
{2472, 1, 100}, -- magic plate armor
{2514, 1, 100}, -- mastermind shield
{2520, 1, 100}, -- demon shield
{1982, 1, 100}, -- purple tome
{2123, 1, 100}, -- ring of the sky
},

muito_raro = {
{8890, 1, 100}, -- Robe of the underworld
{2421, 1, 100}, -- thunder hammer
},

sempre = {
{5808, 1, 100}, -- orshabaals brain
{2171, 1, 100}, -- platinum amulet
{2148, 90, 100}, -- gold coin
{2146, 10, 100}, -- small sapphire
},

storage = 65480,
},

["ferumbras"] =
{
comum = {
{2143, 10, 100}, -- white pearl
{2146, 10, 100}, -- small sapphire
{2145, 10, 100}, -- small diamond
{2144, 10, 100}, -- black pearl
{2149, 10, 100}, -- small emeralds
{7416, 1, 100}, -- Bloody Edge
{7896, 1, 100}, -- glacier kilt
{2432, 1, 100}, -- fire axe
{2462, 1, 100}, -- devil helmet
{7590, 1, 100}, -- great mana potion
{2179, 1, 100}, -- gold ring
{2151, 1, 100}, -- talon
},

semi_raro = {
{2195, 1, 100}, -- boots of haste
{2472, 1, 100}, -- magic plate armor
{2393, 1, 100}, -- giant sword
{2470, 1, 100}, -- golden legs
{2514, 1, 100}, -- mastermind shield
},

raro = {
{8885, 1, 100}, -- divine plate
{2520, 1, 100}, -- demon shield
{8930, 1, 100}, -- emerald sword
{2522, 1, 100}, -- great shield
{2421, 1, 100}, -- thunder hammer
},

muito_raro = {
{5903, 1, 100}, -- ferumbras hat
},

sempre = {
{2171, 1, 100}, -- platinum amulet
{2148, 90, 100}, -- gold coin
{2146, 10, 100}, -- small sapphire
},

storage = 65481,
},
["zulazza the corruptor"] =
{
comum = {
{2158, 1, 100}, -- blue gem
{2156, 1, 100}, -- red gem
{2155, 1, 100}, -- green gem
{2154, 1, 100}, -- yellow gem
{2153, 1, 100}, -- violet gem
},

semi_raro = {
{5944, 5, 100}, -- soul orb
},

raro = {
{2514, 1, 100}, -- mastermind shield
},

muito_raro = {
{11114, 1, 100}, -- dragon scale boots
{8882, 1, 100}, -- earthborn titan armor
},

sempre = {
{2152, 90, 100}, -- platinum coin
{9971, 5, 100}, -- gold ingot
},

storage = 65482,
},
["morgaroth"] =
{
comum = {
{2143, 10, 100}, -- white pearl
{2146, 10, 100}, -- small sapphire
{2145, 10, 100}, -- small diamond
{2144, 10, 100}, -- black pearl
{2149, 10, 100}, -- small emeralds
{5954, 3, 100}, -- demon horn
{7896, 1, 100}, -- glacier kilt
{2432, 1, 100}, -- fire axe
{2462, 1, 100}, -- devil helmet
{7590, 1, 100}, -- great mana potion
{2179, 1, 100}, -- gold ring
{2151, 1, 100}, -- talon
},

semi_raro = {
{2195, 1, 100}, -- boots of haste
{2393, 1, 100}, -- giant sword
{5954, 5, 100}, -- demon horn
{2123, 1, 100}, -- ring of the sky
},

raro = {
{8886, 1, 100}, -- molten plate
{2472, 1, 100}, -- magic plate armor
{8867, 1, 100}, -- dragon robe
{2514, 1, 100}, -- mastermind shield
{2520, 1, 100}, -- demon shield
{1982, 1, 100}, -- purple tome
{8851, 1, 100}, -- Royal Crossbow
},

muito_raro = {
{2421, 1, 100}, -- thunder hammer
{2522, 1, 100}, -- great shield
{8850, 1, 100}, -- chain bolter
},

sempre = {
{5943, 1, 100}, -- morgaroths brain
{2171, 1, 100}, -- platinum amulet
{2148, 90, 100}, -- gold coin
{2146, 10, 100}, -- small sapphire
},
storage = 65483,
},
}
}[/lua]

creaturescripts/scripts/rewardchest_boss.lua
[lua]-- Sistema de recompensa criado por luanluciano93

dofile('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
doAddContainerItem(chest, tabela_reward[x][1], math.random(tabela_reward[x][2]))
msg = msg .. " ".. (tabela_reward[x][2] > 1 and tabela_reward[x][2] 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, 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, 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 then
local boss = REWARDCHEST.bosses[getCreatureName(cid):lower()]
if boss then
setPlayerStorageValue(attacker, boss.storage, getPlayerStorageValue(attacker, boss.storage) + math.ceil((value / REWARDCHEST.formula.hit)))
end
end
return true
end[/lua]

creaturescripts/scripts/rewardchest_pontos.lua
[lua]-- Sistema de recompensa criado por luanluciano93

dofile('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, value in pairs(REWARDCHEST.bosses) do
if getPlayerStorageValue(cid, value.storage) > 0 then
if getCreatureHealth(cid) + value > getCreatureMaxHealth(cid) then
local add = getCreatureMaxHealth(cid) - getCreatureHealth(cid)
setPlayerStorageValue(attacker, value.storage, getPlayerStorageValue(attacker, value.storage) + math.ceil((add / REWARDCHEST.formula.suport)))
else
setPlayerStorageValue(attacker, value.storage, getPlayerStorageValue(attacker, value.storage) + math.ceil((value / REWARDCHEST.formula.suport)))
end
end
end
end
return true
end[/lua]

creaturescripts.xml
[xml]<event type="login" name="RewardChestLogin" event="script" value="rewardchest_pontos.lua"/>
<event type="statschange" name="RewardChestStats" event="script" value="rewardchest_pontos.lua"/>
<event type="death" name="RewardChestDeath" event="script" value="rewardchest_boss.lua"/>
<event type="statschange" name="RewardChestMonster" event="script" value="rewardchest_boss.lua"/>[/xml]

Oraz do ka?dego moba z rewardchest.lua w plikach .xml w folderze monster dodajemy:
[xml]<script>
<event name="RewardChestDeath"/>
<event name="RewardChestMonster"/>
</script>[/xml]
 
Top