Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Full Loot On Death Script by NotHawthorne of ModCraft/EmuDevs--
- local AIO = require("AIO")
- --DEFINE VARS
- local leveldiff = 5 --Amount of levels higher someone can be than the person they're killing and still recieve an HK
- local decaytime = 300 --Time in seconds it takes for belongings to decay
- local creaturedeath = true --Enable inventory dropping on creature death?
- local playerdeath = true --Enable inventory dropping on player death?
- local ContainerID = 818001
- local maxitems = 25 --Equal to amount of buttons that I have declared.
- local guid_linking_table = {}
- local item_table = {}
- --DEFINE LOOT FRAME
- local FullLootFrame = AIO:CreateFrame("Frame", "FullLootFrame", "UIParent", nil)
- FullLootFrame:SetSize(350, 500)
- FullLootFrame:SetMovable(true)
- FullLootFrame:SetEnabledMouse(true)
- FullLootFrame:RegisterForDrag("LeftButton")
- FullLootFrame:SetPoint("BOTTOMRIGHT", -270, 60)
- FullLootFrame:SetToplevel(true)
- FullLootFrame:SetClampedToScreen(true)
- FullLootFrame:SetBackdrop({
- bgFile = "Interface/DialogFrame/UI-DialogBox-Background-Dark",
- edgeFile = "Interface/DialogFrame/UI-DialogBox-Gold-Border",
- edgeSize = 20,
- --tile = true,
- --tilesize = 256,
- insets = { left = 5, right = 5, top = 5, bottom = 5 }
- })
- FullLootFrame:SetScript("OnDragStart", "StartMoving")
- FullLootFrame:SetScript("OnHide", "StopMovingOrSizing")
- FullLootFrame:SetScript("OnDragStop", "StopMovingOrSizing")
- FullLootFrame:Hide()
- local FullLootFrame_TitleBar = AIO:CreateFrame("Frame", "FullLootFrame_TitleBar", FullLootFrame, nil)
- FullLootFrame_TitleBar:SetSize(255, 25)
- FullLootFrame_TitleBar:SetPoint("TOP", 0, 9)
- FullLootFrame_TitleBar:SetBackdrop({
- bgFile = "Interface/CHARACTERFRAME/UI-Party-Background",
- edgeFile = "Interface/DialogFrame/UI-DialogBox-Border",
- tile = true,
- edgeSize = 16,
- tileSize = 16,
- insets = { left = 5, right = 5, top = 5, bottom = 5 }
- })
- local FullLootFrame_TitleText = FullLootFrame_TitleBar:CreateFontString("FullLootFrame_TitleText")
- FullLootFrame_TitleText:SetFont("Fonts\\FRIZQT__.TTF", 13)
- FullLootFrame_TitleText:SetSize(190, 5)
- FullLootFrame_TitleText:SetPoint("CENTER", 0, 0)
- local FullLootFrame_CloseButton = AIO:CreateFrame("Button", "FullLootFrame_CloseButton", FullLootFrame, "UIPanelCloseButton")
- FullLootFrame_CloseButton:SetPoint("TOPRIGHT", -5, -5)
- FullLootFrame_CloseButton:SetEnabledMouse(true)
- FullLootFrame_CloseButton:SetSize(27, 27)
- local FullLoot_ButtonTable = {}
- local FullLoot_TextTable = {}
- local function AddItem(player, Event, EventParamsTable, ClientFuncRet)
- local lootindex = ClientFuncRet[1]
- local lootguid = ClientFuncRet[2]
- if(type(lootindex) ~= "number") then
- return
- end
- if(type(lootguid) ~= "number") then
- return
- end
- if(not item_table[lootguid]) then
- return
- end
- local item = item_table[lootguid][lootindex]
- if(not item) then
- return
- end
- table.remove(item_table[lootguid], lootindex)
- player:AddItem(v[2], v[3])
- player:SendBroadcastMessage("You got a "..item[1])
- end
- for i = 1, maxitems do
- local OnHoverTooltip = [[
- local button = select(1, ...)
- if not button.itemlink then
- return
- end
- GameTooltip:SetOwner(button, "ANCHOR_RIGHT")
- GameTooltip:SetHyperlink(button.itemlink)
- GameTooltip:Show()
- ]]
- local button = AIO:CreateFrame("Button", "FullLoot_Button"..i, FullLootFrame, nil)
- button:SetSize(200, 13)
- button:SetPoint("TOPLEFT", 25, (-10-(i*15)))
- button:SetEnabledMouse(true)
- button:SetHighlightTexture("Interface/Buttons/UI-Listbox-Highlight")
- button:SetPushedTexture("Interface/Buttons/CheckButtonHilight")
- button:SetScript("OnLeave", AIO:ToFunction("GameTooltip:Hide()"))
- button:SetScript("OnEnter", AIO:ToFunction(OnHoverTooltip))
- button:SetScript("OnMouseUp", AddItem, AIO:ObjDo(button, ".lootindex", button, ".lootguid", "GameTooltip", ":Hide()", button, "SetText('|cff9d9d9dLooted Item|r')"))
- local text = button:CreateFontString("FullLoot_Text"..i)
- text:SetFont("Fonts\\FRIZQT__.TTF", 11)
- text:SetSize(200, 5)
- text:SetPoint("CENTER", 0, 0)
- text:SetJustifyH("LEFT")
- table.insert(FullLoot_ButtonTable, button)
- table.insert(FullLoot_TextTable, text)
- end
- --Function that removes bag from world.
- local function Remove_FullLootContainer(event, delay, call, object)
- guid_linking_table[object:GetGUIDLow()] = nil
- item_table[object:GetGUIDLow()] = nil
- FullLootFrame:Clear()
- FullLootFrame:Hide()
- local hidemsg = AIO:CreateMsg()
- hidemsg:Append(FullLootFrame)
- FullLootFrame:Clear()
- local nearbyplayers = object:GetPlayersInRange(100)
- for k, v in ipairs(nearbyplayers) do
- v:SendBroadcastMessage("|CFFFF8040The sack of items turns to dust, and blows away with the wind.|r")
- hidemsg:Send(v)
- end
- object:Despawn(1)
- object:RemoveFromWorld(false)
- end
- local function EntropyPvP(event, pKiller, pKilled)
- if (not playerdeath) then
- return
- end
- local pKilledGUID = pKilled:GetGUIDLow()
- local pKillerGUID = pKiller:GetGUIDLow()
- -- Dont trigger on self kill
- if(pKilledGUID == pKillerGUID) then
- return
- end
- --Fetch Guild Names
- local killerguild_name
- if (pKiller:GetGuildName()~=nil) then
- killerguild_name = " of "..pKiller:GetGuildName()
- else
- killerguild_name = ", a Lone Wolf"
- end
- local killedguild_name
- if (pKilled:GetGuildName()~=nil) then
- killedguild_name = " of"..killedguild:GetName()
- else
- killedguild_name = ", a Lone Wolf"
- end
- --Class color codes (Killed)
- local killed_color = 0
- if (pKilled:GetClass()==1) then killed_color = "C79C6E"
- elseif (pKilled:GetClass()==2) then killed_color = "F58CBA"
- elseif (pKilled:GetClass()==3) then killed_color = "ABD473"
- elseif (pKilled:GetClass()==4) then killed_color = "FFF569"
- elseif (pKilled:GetClass()==5) then killed_color = "FFFFFF"
- elseif (pKilled:GetClass()==6) then killed_color = "C41F3B"
- elseif (pKilled:GetClass()==7) then killed_color = "0070DE"
- elseif (pKilled:GetClass()==8) then killed_color = "69CCF0"
- elseif (pKilled:GetClass()==9) then killed_color = "9482C9"
- elseif (pKilled:GetClass()==11) then killed_color = "FF7D0A"
- elseif (pKilled:GetClass()==12) then killed_color = "EB2FDE"
- end
- --Class color codes (Killer)
- local killer_color = 0
- if (pKiller:GetClass()==1) then killer_color = "C79C6E"
- elseif (pKiller:GetClass()==2) then killer_color = "F58CBA"
- elseif (pKiller:GetClass()==3) then killer_color = "ABD473"
- elseif (pKiller:GetClass()==4) then killer_color = "FFF569"
- elseif (pKiller:GetClass()==5) then killer_color = "FFFFFF"
- elseif (pKiller:GetClass()==6) then killer_color = "C41F3B"
- elseif (pKiller:GetClass()==7) then killer_color = "0070DE"
- elseif (pKiller:GetClass()==8) then killer_color = "69CCF0"
- elseif (pKiller:GetClass()==9) then killer_color = "9482C9"
- elseif (pKiller:GetClass()==11) then killer_color = "FF7D0A"
- elseif (pKiller:GetClass()==12) then killer_color = "EB2FDE"
- end
- --Fetch PvP Stats
- local killerstats = CharDBQuery("SELECT honorable_kills,dishonorable_kills FROM shard_pvp_stats WHERE playerguid="..pKillerGUID)
- if (math.abs(pKiller:GetLevel() - pKilled:GetLevel()) <= leveldiff) then
- local x,y,z,o = pKilled:GetLocation()
- local FullLootContainer = pKiller:SummonGameObject(ContainerID, x, y, z, 2.5, 0) --Spawn a Sack of Belongings
- FullLootContainer:RegisterEvent(Remove_FullLootContainer, decaytime*1000, 1) --Register the Remove/Despawn event to the Sack of Belongings
- guid_linking_table[FullLootContainer:GetGUIDLow()] = pKilled:GetName()
- --Get Items
- item_table[FullLootContainer:GetGUIDLow()] = {}
- local items = item_table[FullLootContainer:GetGUIDLow()]
- for i = 0, 38 do
- local checkitem = pKilled:GetItemByPos(255, i)
- if (checkitem) then
- local entry = checkitem:GetEntry()
- if (not checkitem:IsBag() and entry ~= 6948) then
- table.insert(items, {GetItemLink(checkitem), entry, checkitem:GetCount(), pKilled:GetName()})
- --pKilled:RemoveItem(entry, checkitem:GetCount())
- if (#items >= maxitems) then
- break
- end
- end
- end
- end
- --Kill Announcer
- local kill_message = math.random(1,6)
- if (kill_message==1) then
- SendWorldMessage("[PvP]: |CFF"..killed_color..pKilled:GetName().."|r"..killedguild_name..", got rekt by |CFF"..killer_color..pKiller:GetName().."|r"..killerguild_name.."!")
- elseif (kill_message==2) then
- SendWorldMessage("[PvP]: |CFF"..killed_color..pKilled:GetName().."|r"..killedguild_name..", got knocked in da gabba by |CFF"..killer_color..pKiller:GetName().."|r"..killerguild_name.."!")
- elseif (kill_message==3) then
- SendWorldMessage("[PvP]: |CFF"..killed_color..pKilled:GetName().."|r"..killedguild_name..", had their behind superfluously carved by |CFF"..killer_color..pKiller:GetName().."|r"..killerguild_name.."!")
- elseif (kill_message==4) then
- SendWorldMessage("[PvP]: |CFF"..killed_color..pKilled:GetName().."|r"..killedguild_name..", had their lease on life terminated by |CFF"..killer_color..pKiller:GetName().."|r"..killerguild_name.."!")
- elseif (kill_message==5) then
- SendWorldMessage("[PvP]: |CFF"..killed_color..pKilled:GetName().."|r"..killedguild_name..", died of an iron overdose, courtesy of |CFF"..killer_color..pKiller:GetName().."|r"..killerguild_name..".")
- elseif (kill_message==6) then
- SendWorldMessage("[PvP]: |CFF"..killed_color..pKilled:GetName().."|r"..killedguild_name..", wanted a piece of |CFF"..killer_color..pKiller:GetName().."|r"..killerguild_name..", but bit off a little more than they could chew!")
- end
- CharDBExecute("UPDATE shard_pvp_stats SET honorable_kills="..(killerstats:GetUInt32(0)+1).." WHERE playerguid = "..pKiller:GetGUIDLow())
- else
- CharDBExecute("UPDATE shard_pvp_stats SET dishonorable_kills="..(killerstats:GetUInt32(1)+1).." WHERE playerguid = "..pKiller:GetGUIDLow())
- SendWorldMessage("[PvP]: |cffff0000Everyone give a big round of applause to|r |CFF"..killer_color..pKiller:GetName().."|r |cffff0000"..killerguild_name..", whom is level "..pKiller:GetLevel()..", killed|r |CFF"..killed_color..pKilled:GetName().."|r|cffff0000, a level "..pKilled:GetLevel()..".|r")
- end
- end
- local function CreatureDeath(event, pKiller, pKilled)
- if (not creaturedeath) then
- return
- end
- local pKilledGUID = pKilled:GetGUIDLow()
- local x,y,z,o = pKilled:GetLocation()
- local FullLootContainer = pKiller:SummonGameObject(ContainerID, x, y, z, 2.5, 0) --Spawn a Sack of Belongings
- FullLootContainer:RegisterEvent(Remove_FullLootContainer, decaytime*1000, 1) --Register the Remove/Despawn event to the Sack of Belongings
- guid_linking_table[FullLootContainer:GetGUIDLow()] = pKilled:GetName()
- --Get Items
- item_table[FullLootContainer:GetGUIDLow()] = {}
- local items = item_table[FullLootContainer:GetGUIDLow()]
- for i = 0, 38 do
- local checkitem = pKilled:GetItemByPos(255, i)
- if (checkitem) then
- local entry = checkitem:GetEntry()
- if (not checkitem:IsBag() and entry ~= 6948) then
- table.insert(items, {GetItemLink(checkitem), entry, checkitem:GetCount(), pKilled:GetName()})
- --pKilled:RemoveItem(entry, checkitem:GetCount())
- if (#items >= maxitems) then
- break
- end
- end
- end
- end
- end
- local function OnGossipHello(event, player, object)
- local objguid = object:GetGUIDLow()
- local items = item_table[objguid]
- if(not items) then
- return
- end
- FullLootFrame:Clear()
- for i = 1, maxitems do
- local button = FullLoot_ButtonTable[i]
- local text = FullLoot_TextTable[i]
- local item = items[i]
- if (item) then
- button:SetVar("lootguid", objguid)
- button:SetVar("lootindex", i)
- button:SetVar("itemlink", item[1])
- button:Show()
- text:SetText(item[1].." x"..item[3])
- text:Show()
- else
- button:Hide()
- text:Hide()
- end
- end
- local killedname = guid_linking_table[objguid]
- if (killedname) then
- FullLootFrame_TitleText:SetText("|cffFFC125"..killedname.."'s Belongings|r")
- else
- FullLootFrame_TitleText:SetText("|cffFFC125Unclaimed Belongings|r")
- end
- FullLootFrame:Send(player)
- end
- local function ShardPvPCommands(event, player, msg)
- if (not player:IsGM()) then
- player:SendBroadcastMessage("You do not have access to this function.")
- return false
- else
- if (msg=="#shard playerdeath on") then
- if (playerdeath) then
- player:SendBroadcastMessage("Shard PvP already active.")
- else
- player:SendBroadcastMessage("Shard PvP activated.")
- playerdeath = true
- end
- elseif (msg=="#shard playerdeath off") then
- if (playerdeath) then
- player:SendBroadcastMessage("Shard PvP already inactive.")
- else
- player:SendBroadcastMessage("Shard PvP deactivated.")
- playerdeath = false
- end
- elseif (msg=="#shard creaturedeath on") then
- if (creaturedeath) then
- player:SendBroadcastMessage("Shard PvE already active.")
- else
- player:SendBroadcastMessage("Shard PvE activated.")
- creaturedeath = true
- end
- elseif (msg=="#shard creaturedeath off") then
- if (creaturedeath) then
- player:SendBroadcastMessage("Shard PvE already inactive.")
- else
- player:SendBroadcastMessage("Shard PvE deactivated.")
- creaturedeath = false
- end
- else
- return true
- end
- return false
- end
- end
- AIO:AddInitMsg(FullLootFrame)
- RegisterPlayerEvent(6, EntropyPvP) --Triggered when player dies to player, including killing self
- RegisterPlayerEvent(8, CreatureDeath) --Triggered when player dies to creature
- RegisterGameObjectGossipEvent(818001, 1, OnGossipHello)
- RegisterPlayerEvent(18, ShardPvPCommands)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement