Dantez
Moim sekretem jest ciasto
- Joined
- May 22, 2008
- Messages
- 1,206
- Reaction score
- 202
Witam! Jak w temacie - skrypt dodaje do corpse przedmioty, je?li gracz posiada party. Itemy przyznawane s? w zale?no?ci od wielko?ci party (liczby graczy).
creaturescripts/scripts/login.lua
Pod:
Dodaj:
creaturescripts/creaturescripts.xml
creaturescripts/scripts/partyBoss.lua
Dodawanie nowych loot?w jest zupe?nie proste:
Changelog:
Version 1.1:
Version 1.2:
Wszelkie b??dy oraz pomys?y prosz? zg?asza? w komentarzach
Jak to wygl?da w praktyce?
Co je?li gracze s? daleko od nas i wcale nie bili potwora?
A co gdybym ubi? go sam?
v. 1.2 Losowanie
Co je?li gracze s? daleko od nas i wcale nie bili potwora?
A co gdybym ubi? go sam?
v. 1.2 Losowanie
creaturescripts/scripts/login.lua
Pod:
Code:
registerCreatureEvent(cid, "AdvanceSave")
Code:
registerCreatureEvent(cid, "PartyBoss")
creaturescripts/creaturescripts.xml
Code:
<event type="kill" name="PartyBoss" event="script" value="partyBoss.lua"/>
creaturescripts/scripts/partyBoss.lua
PHP:
local config = {
rollItems = 1,
}
local array = {
["Example Boss"] = {
[3] = {{2453, 1}},
[4] = {{2493, 2}}
},
["Ferumbras"] = {
[2] = {{2160, 5}, {2159, 10}, {2472, 2}},
[3] = {{2472, 2}, {2160, 40}},
[4] = {{2493, 2}}
},
}
function sendPartyMessage(members, msg)
for _, pid in pairs(members) do
doPlayerSendTextMessage(pid, MESSAGE_INFO_DESCR, msg)
end
return true
end
function dropBonusLoot(items, corpseid, position, members)
local container = doAddContainerItem(getTileItemById(position, corpseid).uid, 1988, 1)
for _, item in pairs(items) do
doAddContainerItem(container, item[1], item[2])
end
sendPartyMessage(members, createLootMessage(container))
return true
end
function roll(items, members)
for i=1, #items do
local numbers, index, num = {}, 0, 0
for _, person in pairs(members) do
table.insert(numbers, {person, math.random(1, 100)})
end
for z, val in ipairs(numbers) do
if (val[2] > num) then
num = val[2]
index = z
end
end
doPlayerAddItem(numbers[index][1], items[i][1], items[i][2])
sendPartyMessage(members, getCreatureName(numbers[index][1]) .. " rolled " .. numbers[index][2] .. " and gained " .. getItemNameById(items[i][1]) .. ".")
end
return true
end
function createLootMessage(container)
local text = "Party loot bonus: "
for i=0, getContainerSize(container)-1 do
local item = getContainerItem(container, i)
if item ~= nil then
local info = getItemInfo(item.itemid)
if (item.type > 1 and info.stackable) then
text = text .. item.type .. " " .. info.plural
else
if (info.article) then
text = text .. info.article .. " " .. info.name
else
text = text .. info.name
end
end
if (getContainerItem(container, i+1).itemid > 0 ) then
text = text .. ", "
else
text = text .. "."
end
else
return text
end
end
return text
end
function partyMembersCheck(cid, members)
for _, person in pairs(members) do
if(getDistanceBetween(getCreaturePosition(cid), getCreaturePosition(person)) > 30) then
return false
end
end
return true
end
function onKill(cid, target, lastHit)
local corpseid, loot = getMonsterInfo(getCreatureName(target)).lookCorpse, array[getCreatureName(target)]
if not (loot) or corpseid == nil or not isItemContainer(corpseid) then return true end
if (isInParty(cid)) then
local members, tab, items = getPartyMembers(getPartyLeader(cid)), 0, {}
if (partyMembersCheck(cid, members)) then
if (#members >= table.maxn(loot)) then tab = table.maxn(loot) else tab = #members end
for i=2, tab do
if (loot[i]) then
for _, it in pairs(loot[i]) do
if (it[2] > 1 and not getItemInfo(it[1]).stackable) then
for x=1, it[2] do
table.insert(items, {it[1], 1})
end
else
table.insert(items, it)
end
end
end
end
if #items > 0 then
if (config.rollItems > 0) then
roll(items, members)
else
addEvent(dropBonusLoot, 0, items, corpseid, getCreaturePosition(target), members)
end
end
else
doPlayerSendTextMessage(cid, 27, "Some party members are too far away. Bonus inactive.")
end
else
doPlayerSendTextMessage(cid, 27, "Next time take some people in party to get bonus loot.")
end
return true
end
Dodawanie nowych loot?w jest zupe?nie proste:
PHP:
["CREATURE NAME"] = {
-- [NUMBER OF PARTY MEMBERS] = {{ITEM_ID, ITEM_COUNT}, {ITEM2_ID, ITEM2_COUNT}}
[2] = {{2160, 5}, {2159, 10}, {2472, 2}},
[3] = {{2453, 1}, {2160, 50}},
[4] = {{2493, 2}}
}
Changelog:
Version 1.1:
- New array form
- Detect stackable and not stackable items (loot message)
- Bonus loot is now in backpack
Version 1.2:
- New Roll Items option!
- Fixed bug with empty arrays.
- Better messages - like normal loot (magic plate armor, magic plate armor).
- When 3 players are in the same party you earn loot for 2 players too!
- Some other bugs repaired.
Wszelkie b??dy oraz pomys?y prosz? zg?asza? w komentarzach