Diff
checker
텍스트
텍스트
이미지
문서
Excel
폴더
Legal
Enterprise
데스크톱
요금제
로그인
데스크톱 앱 다운로드
텍스트 비교
두 텍스트 파일의 차이점을 찾아보세요
도구
기록
실시간 편집
변경 없는 행 숨기기
줄바꿈 비활성화
레이아웃
나란히 보기
합쳐 보기
비교 단위
스마트
단어
글자
구문 강조
언어 선택
제외
텍스트 변환
첫 변경으로
수정
Diffchecker Desktop
가장 안전하게 Diffchecker를 사용하는 방법. 데스크톱 앱을 사용하면 비교 데이터가 외부로 전송되지 않습니다!
데스크톱 앱 받기
Untitled diff
생성일
11년 전
비교 결과 만료 없음
초기화
내보내기
공유
설명
0 삭제
행
총
삭제
글자
총
삭제
이 기능을 계속 사용하려면 업그레이드해 주세요
Diff
checker
Pro
요금제 보기
664 행
복사
0 추가
행
총
추가
글자
총
추가
이 기능을 계속 사용하려면 업그레이드해 주세요
Diff
checker
Pro
요금제 보기
664 행
복사
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
-- Client Lua Script for WillYouBeMyNeighbor
-- Client Lua Script for WillYouBeMyNeighbor
-- Copyright (c) NCsoft. All rights reserved
-- Copyright (c) NCsoft. All rights reserved
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
require "Window"
require "Window"
require "HousingLib"
require "HousingLib"
local DEBUGDATA={}
local DEBUGDATA={}
local function DEBUG(s)
local function DEBUG(s)
table.insert(DEBUGDATA, 1, {st=debug.getinfo(2).name, msg=s})
table.insert(DEBUGDATA, 1, {st=debug.getinfo(2).name, msg=s})
DEBUGDATA[101] = nil
DEBUGDATA[101] = nil
end
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
-- WillYouBeMyNeighbor Module Definition
-- WillYouBeMyNeighbor Module Definition
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
WillYouBeMyNeighbor = {}
WillYouBeMyNeighbor = {}
WillYouBeMyNeighbor.tLocale = {}
WillYouBeMyNeighbor.tLocale = {}
NBR_NEIGHBORS = {
NBR_NEIGHBORS = {
crnt = 0,
crnt = 0,
next = 0,
next = 0,
nk = "",
nk = "",
list = {}
list = {}
}
}
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
-- Constants
-- Constants
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
local version = 1.047
local version = 1.047
local kcrOnline = ApolloColor.new("UI_TextHoloBodyHighlight")
local kcrOnline = ApolloColor.new("UI_TextHoloBodyHighlight")
local kcrOffline = ApolloColor.new("UI_BtnTextGrayNormal")
local kcrOffline = ApolloColor.new("UI_BtnTextGrayNormal")
local kcrIgnored = ApolloColor.new("UI_WindowAlert")
local kcrIgnored = ApolloColor.new("UI_WindowAlert")
local RegisteredUsers = {}
local RegisteredUsers = {}
local lastVisit = {}
local lastVisit = {}
local OnlineUsers = {}
local OnlineUsers = {}
local AutoDisplay = true
local AutoDisplay = true
local AutoAccept = false
local AutoAccept = false
local DeclineByFilter = false
local DeclineByFilter = false
local NodeFilter = "Mineral Deposit"
local NodeFilter = "Mineral Deposit"
local ShareFilter = 0
local ShareFilter = 0
local NodeLevelFilter = 1
local NodeLevelFilter = 1
local GuildFilter = ""
local GuildFilter = ""
local PlantPiratesAlert = true
local PlantPiratesAlert = true
local HarvestNotifications = true
local HarvestNotifications = true
local AcceptAllSocials = false
local AcceptAllSocials = false
local currentZone = ""
local currentZone = ""
local IgnoredPlots = {
local IgnoredPlots = {
ignore = false,
ignore = false,
ignoreList = {}
ignoreList = {}
}
}
local ResourceTypes = {
local ResourceTypes = {
filter = { mineral=false, relic=false, thicket=false },
filter = { mineral=false, relic=false, thicket=false },
mineral = {},
mineral = {},
relic = {},
relic = {},
thicket = {}
thicket = {}
}
}
local PlotRatings = {}
local PlotRatings = {}
local wybmnOptions = {
local wybmnOptions = {
takeMail = false,
takeMail = false,
autoZone = false
autoZone = false
}
}
local autoVisit = false
local autoVisit = false
local skipNeeded = false
local skipNeeded = false
local autoCount = 0
local autoCount = 0
local Plugs = {}
local Plugs = {}
local skipnodeTypes = {}
local skipnodeTypes = {}
--local nameIndex = {}
--local nameIndex = {}
nameIndex = {}
nameIndex = {}
local nodeTypes = {
local nodeTypes = {
-- EN
-- EN
["Elite Mineral Deposit"] = { k="mineral", t=5 },
["Elite Mineral Deposit"] = { k="mineral", t=5 },
["Elite Relic Excavation"] = { k="mineral", t=5 },
["Elite Relic Excavation"] = { k="mineral", t=5 },
["Elite Thicket"] = { k="thicket", t=5 },
["Elite Thicket"] = { k="thicket", t=5 },
["Mineral Deposit"] = { k="mineral", t=1 },
["Mineral Deposit"] = { k="mineral", t=1 },
["Mineral Deposit Tier 1"] = { k="mineral", t=1 },
["Mineral Deposit Tier 1"] = { k="mineral", t=1 },
["Mineral Deposit Tier 2"] = { k="mineral", t=2 },
["Mineral Deposit Tier 2"] = { k="mineral", t=2 },
["Mineral Deposit Tier 3"] = { k="mineral", t=3 },
["Mineral Deposit Tier 3"] = { k="mineral", t=3 },
["Mineral Deposit Tier 4"] = { k="mineral", t=4 },
["Mineral Deposit Tier 4"] = { k="mineral", t=4 },
["Relic Excavation"] = { k="relic", t=1 },
["Relic Excavation"] = { k="relic", t=1 },
["Relic Excavation Tier 1"] = { k="relic", t=1 },
["Relic Excavation Tier 1"] = { k="relic", t=1 },
["Relic Excavation Tier 2"] = { k="relic", t=2 },
["Relic Excavation Tier 2"] = { k="relic", t=2 },
["Relic Excavation Tier 3"] = { k="relic", t=3 },
["Relic Excavation Tier 3"] = { k="relic", t=3 },
["Relic Excavation Tier 4"] = { k="relic", t=4 },
["Relic Excavation Tier 4"] = { k="relic", t=4 },
["Thicket Tier 1"] = { k="thicket", t=1 },
["Thicket Tier 1"] = { k="thicket", t=1 },
["Thicket"] = { k="thicket", t=1 },
["Thicket"] = { k="thicket", t=1 },
["Thicket Tier 2"] = { k="thicket", t=2 },
["Thicket Tier 2"] = { k="thicket", t=2 },
["Thicket Tier 3"] = { k="thicket", t=3 },
["Thicket Tier 3"] = { k="thicket", t=3 },
["Thicket Tier 4"] = { k="thicket", t=4 },
["Thicket Tier 4"] = { k="thicket", t=4 },
-- DE
-- DE
["Mineralvorkommen"] = { k="mineral", t=1 },
["Mineralvorkommen"] = { k="mineral", t=1 },
["Mineralvorkommen (Rang 1)"] = { k="mineral", t=1 },
["Mineralvorkommen (Rang 1)"] = { k="mineral", t=1 },
["Mineralvorkommen (Rang 2)"] = { k="mineral", t=2 },
["Mineralvorkommen (Rang 2)"] = { k="mineral", t=2 },
["Mineralvorkommen (Rang 3)"] = { k="mineral", t=3 },
["Mineralvorkommen (Rang 3)"] = { k="mineral", t=3 },
["Mineralvorkommen (Rang 4)"] = { k="mineral", t=4 },
["Mineralvorkommen (Rang 4)"] = { k="mineral", t=4 },
["Dickicht"] = { k="thicket", t=1 },
["Dickicht"] = { k="thicket", t=1 },
["Dickicht (Rang 1)"] = { k="thicket", t=1 },
["Dickicht (Rang 1)"] = { k="thicket", t=1 },
["Dickicht (Rang 2)"] = { k="thicket", t=2 },
["Dickicht (Rang 2)"] = { k="thicket", t=2 },
["Dickicht (Rang 3)"] = { k="thicket", t=3 },
["Dickicht (Rang 3)"] = { k="thicket", t=3 },
["Dickicht (Rang 4)"] = { k="thicket", t=4 },
["Dickicht (Rang 4)"] = { k="thicket", t=4 },
["Reliktausgrabung"] = { k="relic", t=1 },
["Reliktausgrabung"] = { k="relic", t=1 },
["Reliktausgrabung (Rang 1)"] = { k="relic", t=1 },
["Reliktausgrabung (Rang 1)"] = { k="relic", t=1 },
["Reliktausgrabung (Rang 2)"] = { k="relic", t=1 },
["Reliktausgrabung (Rang 2)"] = { k="relic", t=1 },
["Reliktausgrabung (Rang 3)"] = { k="relic", t=1 },
["Reliktausgrabung (Rang 3)"] = { k="relic", t=1 },
["Reliktausgrabung (Rang 4)"] = { k="relic", t=1 },
["Reliktausgrabung (Rang 4)"] = { k="relic", t=1 },
["Elite-Mineralvorkommen"] = { k="mineral", t=5 },
["Elite-Mineralvorkommen"] = { k="mineral", t=5 },
["Elite-Dickicht"] = { k="thicket", t=5 },
["Elite-Dickicht"] = { k="thicket", t=5 },
["Elite-Reliktausgrabung"] = { k="relic", t=5 },
["Elite-Reliktausgrabung"] = { k="relic", t=5 },
}
}
local unitTypes = {
local unitTypes = {
-- EN
-- EN
["Deradune Tree"] = { k="thicket", t=1 },
["Deradune Tree"] = { k="thicket", t=1 },
["Algoroc Tree"] = { k="thicket", t=1 },
["Algoroc Tree"] = { k="thicket", t=1 },
["Ellevar Tree"] = { k="thicket", t=1 },
["Ellevar Tree"] = { k="thicket", t=1 },
["Celestion Tree"] = { k="thicket", t=1 },
["Celestion Tree"] = { k="thicket", t=1 },
["Galeras Tree"] = { k="thicket", t=2 },
["Galeras Tree"] = { k="thicket", t=2 },
["Whitevale Tree"] = { k="thicket", t=2 },
["Whitevale Tree"] = { k="thicket", t=2 },
["Auroria Tree"] = { k="thicket", t=2 },
["Auroria Tree"] = { k="thicket", t=2 },
["Wilderrun Tree"] = { k="thicket", t=3 },
["Wilderrun Tree"] = { k="thicket", t=3 },
["Farside Tree"] = { k="thicket", t=3 },
["Farside Tree"] = { k="thicket", t=3 },
["Grimvault Tree"] = { k="thicket", t=4 },
["Grimvault Tree"] = { k="thicket", t=4 },
["Malgrave Tree"] = { k="thicket", t=4 },
["Malgrave Tree"] = { k="thicket", t=4 },
["Standard Relic Node"] = { k="relic", t=1 },
["Standard Relic Node"] = { k="relic", t=1 },
["Accelerated Relic Node"] = { k="relic", t=1 },
["Accelerated Relic Node"] = { k="relic", t=1 },
["Advanced Relic Node"] = { k="relic", t=2 },
["Advanced Relic Node"] = { k="relic", t=2 },
["Dynamic Relic Node"] = { k="relic", t=3 },
["Dynamic Relic Node"] = { k="relic", t=3 },
["Kinetic Relic Node"] = { k="relic", t=4 },
["Kinetic Relic Node"] = { k="relic", t=4 },
["Iron Node"] = { k="mineral", t=1 },
["Iron Node"] = { k="mineral", t=1 },
["Titanium Node"] = { k="mineral", t=1 },
["Titanium Node"] = { k="mineral", t=1 },
["Zephyrite Node"] = { k="mineral", t=1 },
["Zephyrite Node"] = { k="mineral", t=1 },
["Platinum Node"] = { k="mineral", t=2 },
["Platinum Node"] = { k="mineral", t=2 },
["Hydrogem Node"] = { k="mineral", t=2 },
["Hydrogem Node"] = { k="mineral", t=2 },
["Xenocite Node"] = { k="mineral", t=3 },
["Xenocite Node"] = { k="mineral", t=3 },
["Shadeslate Node"] = { k="mineral", t=3 },
["Shadeslate Node"] = { k="mineral", t=3 },
["Galactium Node"] = { k="mineral", t=4 },
["Galactium Node"] = { k="mineral", t=4 },
["Novacite Node"] = { k="mineral", t=4 },
["Novacite Node"] = { k="mineral", t=4 },
}
}
local opacity = {
local opacity = {
[false] = 1,
[false] = 1,
[true] = 0.6
[true] = 0.6
}
}
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
-- Initialization
-- Initialization
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
function WillYouBeMyNeighbor:new(o)
function WillYouBeMyNeighbor:new(o)
o = o or {}
o = o or {}
setmetatable(o, self)
setmetatable(o, self)
self.__index = self
self.__index = self
-- initialize variables here
-- initialize variables here
return o
return o
end
end
function WillYouBeMyNeighbor:Init()
function WillYouBeMyNeighbor:Init()
local bHasConfigureFunction = false
local bHasConfigureFunction = false
local strConfigureButtonText = ""
local strConfigureButtonText = ""
local tDependencies = {
local tDependencies = {
"NeighborList"
"NeighborList"
}
}
Apollo.RegisterAddon(self, bHasConfigureFunction, strConfigureButtonText, tDependencies)
Apollo.RegisterAddon(self, bHasConfigureFunction, strConfigureButtonText, tDependencies)
end
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
-- Saved Information
-- Saved Information
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
function WillYouBeMyNeighbor:OnSave(eLevel)
function WillYouBeMyNeighbor:OnSave(eLevel)
if eLevel ~= GameLib.CodeEnumAddonSaveLevel.Character then
if eLevel ~= GameLib.CodeEnumAddonSaveLevel.Character then
return nil
return nil
end
end
local save = {}
local save = {}
save.AutoDisplay = AutoDisplay
save.AutoDisplay = AutoDisplay
save.AutoAccept = AutoAccept
save.AutoAccept = AutoAccept
save.DeclineByFilter = DeclineByFilter
save.DeclineByFilter = DeclineByFilter
save.NodeFilter = NodeFilter
save.NodeFilter = NodeFilter
save.ShareFilter = ShareFilter
save.ShareFilter = ShareFilter
save.NodeLevelFilter = NodeLevelFilter
save.NodeLevelFilter = NodeLevelFilter
save.GuildFilter = GuildFilter
save.GuildFilter = GuildFilter
save.PlantPiratesAlert = PlantPiratesAlert
save.PlantPiratesAlert = PlantPiratesAlert
save.HarvestNotifications = HarvestNotifications
save.HarvestNotifications = HarvestNotifications
save.AcceptAllSocials = AcceptAllSocials
save.AcceptAllSocials = AcceptAllSocials
save.RegisteredUsers = RegisteredUsers
save.RegisteredUsers = RegisteredUsers
save.lastVisit = lastVisit
save.lastVisit = lastVisit
save.IgnoredPlots = IgnoredPlots
save.IgnoredPlots = IgnoredPlots
save.ResourceTypes = ResourceTypes
save.ResourceTypes = ResourceTypes
save.PlotRatings = PlotRatings
save.PlotRatings = PlotRatings
save.wybmnOptions = wybmnOptions
save.wybmnOptions = wybmnOptions
return save
return save
end
end
function WillYouBeMyNeighbor:OnRestore(eLevel, tData)
function WillYouBeMyNeighbor:OnRestore(eLevel, tData)
if eLevel == GameLib.CodeEnumAddonSaveLevel.Character then
if eLevel == GameLib.CodeEnumAddonSaveLevel.Character then
if tData.AutoDisplay ~= nil then AutoDisplay = tData.AutoDisplay end
if tData.AutoDisplay ~= nil then AutoDisplay = tData.AutoDisplay end
if tData.AutoAccept ~= nil then AutoAccept = tData.AutoAccept end
if tData.AutoAccept ~= nil then AutoAccept = tData.AutoAccept end
if tData.DeclineByFilter ~= nil then DeclineByFilter = tData.DeclineByFilter end
if tData.DeclineByFilter ~= nil then DeclineByFilter = tData.DeclineByFilter end
if tData.NodeFilter ~= nil then NodeFilter = tData.NodeFilter end
if tData.NodeFilter ~= nil then NodeFilter = tData.NodeFilter end
if tData.ShareFilter ~= nil then ShareFilter = tData.ShareFilter end
if tData.ShareFilter ~= nil then ShareFilter = tData.ShareFilter end
if tData.NodeLevelFilter ~= nil then NodeLevelFilter = tData.NodeLevelFilter end
if tData.NodeLevelFilter ~= nil then NodeLevelFilter = tData.NodeLevelFilter end
if tData.GuildFilter ~= nil then GuildFilter = tData.GuildFilter end
if tData.GuildFilter ~= nil then GuildFilter = tData.GuildFilter end
if tData.PlantPiratesAlert ~= nil then PlantPiratesAlert = tData.PlantPiratesAlert end
if tData.PlantPiratesAlert ~= nil then PlantPiratesAlert = tData.PlantPiratesAlert end
if tData.HarvestNotifications ~= nil then HarvestNotifications = tData.HarvestNotifications end
if tData.HarvestNotifications ~= nil then HarvestNotifications = tData.HarvestNotifications end
if tData.AcceptAllSocials ~= nil then AcceptAllSocials = tData.AcceptAllSocials end
if tData.AcceptAllSocials ~= nil then AcceptAllSocials = tData.AcceptAllSocials end
if tData.RegisteredUsers ~= nil then RegisteredUsers = tData.RegisteredUsers end
if tData.RegisteredUsers ~= nil then RegisteredUsers = tData.RegisteredUsers end
if tData.lastVisit then lastVisit = tData.lastVisit end
if tData.lastVisit then lastVisit = tData.lastVisit end
if tData.IgnoredPlots then IgnoredPlots = tData.IgnoredPlots end
if tData.IgnoredPlots then IgnoredPlots = tData.IgnoredPlots end
if tData.ResourceTypes then ResourceTypes = tData.ResourceTypes end
if tData.ResourceTypes then ResourceTypes = tData.ResourceTypes end
if tData.PlotRatings then PlotRatings = tData.PlotRatings end
if tData.PlotRatings then PlotRatings = tData.PlotRatings end
if tData.wybmnOptions then wybmnOptions = tData.wybmnOptions end
if tData.wybmnOptions then wybmnOptions = tData.wybmnOptions end
for k,v in pairs(RegisteredUsers) do
for k,v in pairs(RegisteredUsers) do
if type(v) == "table" then
if type(v) == "table" then
local nt = nodeTypes[v.nodetype]
local nt = nodeTypes[v.nodetype]
if nt and ResourceTypes[nt.k] and ResourceTypes[nt.k][v.name] == nil then
if nt and ResourceTypes[nt.k] and ResourceTypes[nt.k][v.name] == nil then
ResourceTypes[nt.k][v.name] = nt.t
ResourceTypes[nt.k][v.name] = nt.t
end
end
if PlotRatings[v.name] == nil then
if PlotRatings[v.name] == nil then
PlotRatings[v.name] = 1
PlotRatings[v.name] = 1
end
end
end
end
end
end
end
end
end
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
-- OnLoad
-- OnLoad
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
function WillYouBeMyNeighbor:OnLoad()
function WillYouBeMyNeighbor:OnLoad()
-- load our form file
-- load our form file
self.xmlDoc = XmlDoc.CreateFromFile("WillYouBeMyNeighbor.xml")
self.xmlDoc = XmlDoc.CreateFromFile("WillYouBeMyNeighbor.xml")
self.xmlDoc:RegisterCallback("OnDocLoaded", self)
self.xmlDoc:RegisterCallback("OnDocLoaded", self)
if Apollo.GetAddon("VikingContextMenuPlayer") ~= nil then
if Apollo.GetAddon("VikingContextMenuPlayer") ~= nil then
self.contextMenuPlayer = Apollo.GetAddon("VikingContextMenuPlayer")
self.contextMenuPlayer = Apollo.GetAddon("VikingContextMenuPlayer")
else
else
self.contextMenuPlayer = Apollo.GetAddon("ContextMenuPlayer")
self.contextMenuPlayer = Apollo.GetAddon("ContextMenuPlayer")
end
end
local oldRedrawAll = self.contextMenuPlayer.RedrawAll
local oldRedrawAll = self.contextMenuPlayer.RedrawAll
self.contextMenuPlayer.RedrawAll = function(context)
self.contextMenuPlayer.RedrawAll = function(context)
if self.contextMenuPlayer.wndMain ~= nil then
if self.contextMenuPlayer.wndMain ~= nil then
local wndButtonList = self.contextMenuPlayer.wndMain:FindChild("ButtonList")
local wndButtonList = self.contextMenuPlayer.wndMain:FindChild("ButtonList")
if wndButtonList ~= nil then
if wndButtonList ~= nil then
local wndNew = wndButtonList:FindChildByUserData(tObject)
local wndNew = wndButtonList:FindChildByUserData(tObject)
if not wndNew then
if not wndNew then
wndNew = Apollo.LoadForm(self.contextMenuPlayer.xmlDoc, "BtnRegular", wndButtonList, self.contextMenuPlayer)
wndNew = Apollo.LoadForm(self.contextMenuPlayer.xmlDoc, "BtnRegular", wndButtonList, self.contextMenuPlayer)
wndNew:SetData("VisitNeighbor")
wndNew:SetData("VisitNeighbor")
end
end
wndNew:FindChild("BtnText"):SetText("Visit Neighbor")
wndNew:FindChild("BtnText"):SetText("Visit Neighbor")
end
end
end
end
oldRedrawAll(context)
oldRedrawAll(context)
end
end
-- catch the event fired when the player clicks the context menu
-- catch the event fired when the player clicks the context menu
local oldProcessContextClick = self.contextMenuPlayer.ProcessContextClick
local oldProcessContextClick = self.contextMenuPlayer.ProcessContextClick
self.contextMenuPlayer.ProcessContextClick = function(context, eButtonType)
self.contextMenuPlayer.ProcessContextClick = function(context, eButtonType)
if eButtonType == "VisitNeighbor" then
if eButtonType == "VisitNeighbor" then
self:VisitNeighbor(self.contextMenuPlayer.strTarget)
self:VisitNeighbor(self.contextMenuPlayer.strTarget)
else
else
oldProcessContextClick (context, eButtonType)
oldProcessContextClick (context, eButtonType)
end
end
end
end
self.tQueuedUnits = {}
self.tQueuedUnits = {}
self.rosters = {}
self.rosters = {}
Apollo.RegisterEventHandler("UnitCreated", "OnUnitCreated", self)
Apollo.RegisterEventHandler("UnitCreated", "OnUnitCreated", self)
--Apollo.RegisterEventHandler("UnitDestroyed", "OnUnitDestroyed", self)
--Apollo.RegisterEventHandler("UnitDestroyed", "OnUnitDestroyed", self)
Apollo.RegisterEventHandler("InterfaceMenuListHasLoaded", "OnInterfaceMenuListHasLoaded", self)
Apollo.RegisterEventHandler("InterfaceMenuListHasLoaded", "OnInterfaceMenuListHasLoaded", self)
Apollo.RegisterEventHandler("HarvestItemsSentToOwner", "OnHarvest", self)
Apollo.RegisterEventHandler("HarvestItemsSentToOwner", "OnHarvest", self)
self.chanICC = ICCommLib.JoinChannel("WillYouBeMyNeighborChannel", "OnDotMessageWillYouBeMyNeighborChannelMessage", self)
self.chanICC = ICCommLib.JoinChannel("WillYouBeMyNeighborChannel", "OnDotMessageWillYouBeMyNeighborChannelMessage", self)
self.chanICCOL = ICCommLib.JoinChannel("WillYouBeMyNeighborOnlineChannel", "OnDotMessageWillYouBeMyNeighborOnlineChannelMessage", self)
self.chanICCOL = ICCommLib.JoinChannel("WillYouBeMyNeighborOnlineChannel", "OnDotMessageWillYouBeMyNeighborOnlineChannelMessage", self)
self.chanICCPP = ICCommLib.JoinChannel("WillYouBeMyNeighborPPChannel", "OnDotMessageWillYouBeMyNeighborPPChannelMessage", self)
self.chanICCPP = ICCommLib.JoinChannel("WillYouBeMyNeighborPPChannel", "OnDotMessageWillYouBeMyNeighborPPChannelMessage", self)
self.chanICCHN = ICCommLib.JoinChannel("WillYouBeMyNeighborHarvestNotificationChannel", "OnDotMessageWillYouBeMyNeighborHarvestNotificationChannelMessage", self)
self.chanICCHN = ICCommLib.JoinChannel("WillYouBeMyNeighborHarvestNotificationChannel", "OnDotMessageWillYouBeMyNeighborHarvestNotificationChannelMessage", self)
self:SetLocaleData()
self:SetLocaleData()
end
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
-- OnDocLoaded
-- OnDocLoaded
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
function WillYouBeMyNeighbor:OnDocLoaded()
function WillYouBeMyNeighbor:OnDocLoaded()
if self.xmlDoc ~= nil and self.xmlDoc:IsLoaded() then
if self.xmlDoc ~= nil and self.xmlDoc:IsLoaded() then
self.wndMain = Apollo.LoadForm(self.xmlDoc, "WillYouBeMyNeighborForm", nil, self)
self.wndMain = Apollo.LoadForm(self.xmlDoc, "WillYouBeMyNeighborForm", nil, self)
if self.wndMain == nil then
if self.wndMain == nil then
Apollo.AddAddonErrorText(self, "Could not load the main window for some reason.")
Apollo.AddAddonErrorText(self, "Could not load the main window for some reason.")
return
return
end
end
self.wndMain:Show(false, true)
self.wndMain:Show(false, true)
-- if the xmlDoc is no longer needed, you should set it to nil
-- if the xmlDoc is no longer needed, you should set it to nil
-- self.xmlDoc = nil
-- self.xmlDoc = nil
-- Register handlers for events, slash commands and timer, etc.
-- Register handlers for events, slash commands and timer, etc.
-- e.g. Apollo.RegisterEventHandler("KeyDown", "OnKeyDown", self)
-- e.g. Apollo.RegisterEventHandler("KeyDown", "OnKeyDown", self)
Apollo.RegisterSlashCommand("rogers", "OnWillYouBeMyNeighborOn", self)
Apollo.RegisterSlashCommand("rogers", "OnWillYouBeMyNeighborOn", self)
Apollo.RegisterEventHandler("WillYouBeMyNeighborOn", "OnWillYouBeMyNeighborOn", self)
Apollo.RegisterEventHandler("WillYouBeMyNeighborOn", "OnWillYouBeMyNeighborOn", self)
Apollo.RegisterEventHandler("GuildRoster", "OnGuildRoster", self)
Apollo.RegisterEventHandler("GuildRoster", "OnGuildRoster", self)
Apollo.RegisterEventHandler("ZoneCompletionUpdated", "OnZoneCompletionUpdated", self)
Apollo.RegisterEventHandler("ZoneCompletionUpdated", "OnZoneCompletionUpdated", self)
Apollo.RegisterEventHandler("HousingNeighborInviteRecieved", "OnNeighborInviteRecieved", self)
Apollo.RegisterEventHandler("HousingNeighborInviteRecieved", "OnNeighborInviteRecieved", self)
Apollo.RegisterEventHandler("WindowManagementReady", "OnWindowManagementReady", self)
Apollo.RegisterEventHandler("WindowManagementReady", "OnWindowManagementReady", self)
-- Do additional Addon initialization here
-- Do additional Addon initialization here
self.currentNeighbor = 1
self.currentNeighbor = 1
self.currentNeighborName = ""
self.currentNeighborName = ""
self.expanded = false
self.expanded = false
self.performInvites = ""
self.performInvites = ""
self.faction = 0
self.faction = 0
self.timer = ApolloTimer.Create(5.0, true, "UpdateMyself", self)
self.timer = ApolloTimer.Create(5.0, true, "UpdateMyself", self)
self.timer1 = ApolloTimer.Create(1.0, true, "UpdateCurrent", self)
self.timer1 = ApolloTimer.Create(1.0, true, "UpdateCurrent", self)
Apollo.CreateTimer("skiptimer", 0.5, false)
Apollo.CreateTimer("skiptimer", 0.5, false)
Apollo.RegisterTimerHandler("skiptimer","AutoSkipCheck",self)
Apollo.RegisterTimerHandler("skiptimer","AutoSkipCheck",self)
self.wndMain:FindChild("ComboShareRatioList"):AddItem("100% to me", "", "100% to me")
self.wndMain:FindChild("ComboShareRatioList"):AddItem("100% to me", "", "100% to me")
self.wndMain:FindChild("ComboShareRatioList"):AddItem("75% to me", "", "75% to me")
self.wndMain:FindChild("ComboShareRatioList"):AddItem("75% to me", "", "75% to me")
self.wndMain:FindChild("ComboShareRatioList"):AddItem("50% to me", "", "50% to me")
self.wndMain:FindChild("ComboShareRatioList"):AddItem("50% to me", "", "50% to me")
self.wndMain:FindChild("ComboShareRatioList"):AddItem("25% to me", "", "25% to me")
self.wndMain:FindChild("ComboShareRatioList"):AddItem("25% to me", "", "25% to me")
self.wndMain:FindChild("ComboShareRatioList"):AddItem("0% to me", "", "0% to me")
self.wndMain:FindChild("ComboShareRatioList"):AddItem("0% to me", "", "0% to me")
self:PopulateCircles()
self:PopulateCircles()
self.mail = Apollo.GetAddon("Mail")
self.mail = Apollo.GetAddon("Mail")
if self.mail then
if self.mail then
local mailtoggle = self.mail.ToggleWindow
local mailtoggle = self.mail.ToggleWindow
function self.mail.ToggleWindow(s)
function self.mail.ToggleWindow(s)
mailtoggle(s)
mailtoggle(s)
if wybmnOptions.takeMail and MailSystemLib.AtMailbox() then
if wybmnOptions.takeMail and MailSystemLib.AtMailbox() then
if s.wndMain:IsVisible() then
if s.wndMain:IsVisible() then
local blooted = false
local blooted = false
local lootedItems = {}
local lootedItems = {}
for k,v in pairs(MailSystemLib.GetInbox()) do
for k,v in pairs(MailSystemLib.GetInbox()) do
local tMI = v:GetMessageInfo()
local tMI = v:GetMessageInfo()
if tMI and tMI.strSubject == "Harvest Loot" and tMI.strSenderName == "Phineas T. Rotostar" then
if tMI and tMI.strSubject == "Harvest Loot" and tMI.strSenderName == "Phineas T. Rotostar" then
--if tMI and tMI.strSenderName == "Phineas T. Rotostar" then
--if tMI and tMI.strSenderName == "Phineas T. Rotostar" then
--
--
-- /dump Apollo.GetAddon("Mail").tMailItemWnds
-- /dump Apollo.GetAddon("Mail").tMailItemWnds
--
--
if tMI.arAttachments then
if tMI.arAttachments then
local tAttach
local tAttach
for x=1, 10 do
for x=1, 10 do
tAttach = tMI.arAttachments[x]
tAttach = tMI.arAttachments[x]
if tAttach then
if tAttach then
local sN = tAttach.itemAttached:GetName()
local sN = tAttach.itemAttached:GetName()
local nS = tAttach.nStackCount
local nS = tAttach.nStackCount
if lootedItems[sN] then
if lootedItems[sN] then
lootedItems[sN] = lootedItems[sN] + nS
lootedItems[sN] = lootedItems[sN] + nS
else
else
lootedItems[sN] = nS
lootedItems[sN] = nS
blooted = true
blooted = true
end
end
end
end
end
end
end
end
v:TakeAllAttachments()
v:TakeAllAttachments()
local wnd = self.mail.tMailItemWnds[v:GetIdStr()]
local wnd = self.mail.tMailItemWnds[v:GetIdStr()]
if wnd then
if wnd then
wnd:FindChild("SelectMarker"):SetCheck(true)
wnd:FindChild("SelectMarker"):SetCheck(true)
end
end
end
end
end
end
if blooted then
if blooted then
local srtLoot = {}
local srtLoot = {}
for k,v in pairs(lootedItems) do
for k,v in pairs(lootedItems) do
table.insert(srtLoot, {n=k, s=v})
table.insert(srtLoot, {n=k, s=v})
end
end
table.sort(srtLoot, function(a,b) return a.n < b.n end)
table.sort(srtLoot, function(a,b) return a.n < b.n end)
for k,v in ipairs(srtLoot) do
for k,v in ipairs(srtLoot) do
Print(v.n.." x"..tostring(v.s))
Print(v.n.." x"..tostring(v.s))
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
-- WillYouBeMyNeighbor Functions
-- WillYouBeMyNeighbor Functions
-----------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
function WillYouBeMyNeighbor:GetCurrentZoneName()
function WillYouBeMyNeighbor:GetCurrentZoneName()
if HousingLib:IsOnMyResidence() == true then
if HousingLib:IsOnMyResidence() == true then
if self.NBR_PLAYERNAME then
if self.NBR_PLAYERNAME then
return self.NBR_PLAYERNAME
return self.NBR_PLAYERNAME
else
else
local sZN = GetCurrentZoneName()
local sZN = GetCurrentZoneName()
if sZN then
if sZN then
self.NBR_PLAYERNAME = sZN
self.NBR_PLAYERNAME = sZN
return self.NBR_PLAYERNAME
return self.NBR_PLAYERNAME
else
else
return "YOURSELF"
return "YOURSELF"
end
end
end
end
else
else
local sZN = GetCurrentZoneName()
local sZN = GetCurrentZoneName()
if sZN then
if sZN then
sZN = string.match(GetCurrentZoneName(), "%b[]")
sZN = string.match(GetCurrentZoneName(), "%b[]")
if sZN then
if sZN then
sZN = sZN:sub(2,-2)
sZN = sZN:sub(2,-2)
return sZN
return sZN
end
end
end
end
end
end
return nil
return nil
end
end
function WillYouBeMyNeighbor:GetNextNeighbor()
function WillYouBeMyNeighbor:GetNextNeighbor()
local neighborList=self:GetSortedNeighbors()
local neighborList=self:GetSortedNeighbors()
if neighborList then
if neighborList then
self.currentNeighbor = 1
self.currentNeighbor = 1
if #neighborList > 1 then
if #neighborList > 1 then
local sZN = self:GetCurrentZoneName()
local sZN = self:GetCurrentZoneName()
if sZN then
if sZN then
local nRank = PlotRatings[sZN] or 0
local nRank = PlotRatings[sZN] or 0
nRank = 9-nRank
nRank = 9-nRank
local sortkey = string.format("%d-%s", nRank, sZN)
local sortkey = string.format("%d-%s", nRank, sZN)
NBR_NEIGHBORS.crnt = sortkey
NBR_NEIGHBORS.crnt = sortkey
for x=1, #neighborList do
for x=1, #neighborList do
if neighborList[x].sortKey > sortkey then
if neighborList[x].sortKey > sortkey then
NBR_NEIGHBORS.next = x
NBR_NEIGHBORS.next = x
NBR_NEIGHBORS.nk = neighborList[x].sortKey
NBR_NEIGHBORS.nk = neighborList[x].sortKey
self.currentNeighbor = x
self.currentNeighbor = x
break
break
end
end
end
end
end
end
end
end
end
end
return neighborList
return neighborList
end
end
function WillYouBeMyNeighbor:GetSortedNeighbors()
function WillYouBeMyNeighbor:GetSortedNeighbors()
--if HousingLib:IsHousingWorld() == true and HousingLib:IsWarplotResidence() == false then
--if HousingLib:IsHousingWorld() == true and HousingLib:IsWarplotResidence() == false then
local neighborList=HousingLib.GetNeighborList()
local neighborList=HousingLib.GetNeighborList()
local sZN = self:GetCurrentZoneName()
local sZN = self:GetCurrentZoneName()
self.CURRENTPLOTID = 0
self.CURRENTPLOTID = 0
self.IGNOREDPLOTS = {}
self.IGNOREDPLOTS = {}
nameIndex = {}
nameIndex = {}
if IgnoredPlots.ignore then
if IgnoredPlots.ignore then
for x=#neighborList, 1, -1 do
for x=#neighborList, 1, -1 do
if IgnoredPlots.ignore and IgnoredPlots.ignoreList[neighborList[x].strCharacterName] then
if IgnoredPlots.ignore and IgnoredPlots.ignoreList[neighborList[x].strCharacterName] then
table.remove(neighborList, x)
table.remove(neighborList, x)
end
end
end
end
end
end
local bMin = ResourceTypes.filter.mineral
local bMin = ResourceTypes.filter.mineral
local bRel = ResourceTypes.filter.relic
local bRel = ResourceTypes.filter.relic
local bThi = ResourceTypes.filter.thicket
local bThi = ResourceTypes.filter.thicket
for x=#neighborList, 1, -1 do
for x=#neighborList, 1, -1 do
local bRemove = true
local bRemove = true
if bMin == false and ResourceTypes.mineral[neighborList[x].strCharacterName] then
if bMin == false and ResourceTypes.mineral[neighborList[x].strCharacterName] then
bRemove = false
bRemove = false
end
end
if bRel == false and ResourceTypes.relic[neighborList[x].strCharacterName] then
if bRel == false and ResourceTypes.relic[neighborList[x].strCharacterName] then
bRemove = false
bRemove = false
end
end
if bThi == false and ResourceTypes.thicket[neighborList[x].strCharacterName] then
if bThi == false and ResourceTypes.thicket[neighborList[x].strCharacterName] then
bRemove = false
bRemove = false
end
end
--if sZN == neighborList[x].strCharacterName then
--if sZN == neighborList[x].strCharacterName then
-- bRemove = true
-- bRemove = true
--end
--end
if bRemove then
if bRemove then
self.IGNOREDPLOTS[neighborList[x].strCharacterName] = neighborList[x]
self.IGNOREDPLOTS[neighborList[x].strCharacterName] = neighborList[x]
table.remove(neighborList, x)
table.remove(neighborList, x)
else
else
local sName = neighborList[x].strCharacterName
local sName = neighborList[x].strCharacterName
local nRank = PlotRatings[sName] or 0
local nRank = PlotRatings[sName] or 0
nRank = 9-nRank
nRank = 9-nRank
neighborList[x].sortKey = string.format("%d-%s", nRank, sName)
neighborList[x].sortKey = string.format("%d-%s", nRank, sName)
end
end
end
end
if #neighborList > 1 then
if #neighborList > 1 then
table.sort(neighborList, function(a,b) return a.sortKey < b.sortKey end)
table.sort(neighborList, function(a,b) return a.sortKey < b.sortKey end)
NBR_NEIGHBORS.list = {}
NBR_NEIGHBORS.list = {}
for k,v in ipairs(neighborList) do
for k,v in ipairs(neighborList) do
nameIndex[v.strCharacterName] = k
nameIndex[v.strCharacterName] = k
if (v.strCharacterName == sZN) then
if (v.strCharacterName == sZN) then
self.CURRENTPLOTID = k
self.CURRENTPLOTID = k
end
end
table.insert(NBR_NEIGHBORS.list, {n=v.strCharacterName, k=v.sortKey})
table.insert(NBR_NEIGHBORS.list, {n=v.strCharacterName, k=v.sortKey})
end
end
elseif #neighborList == 1 then
elseif #neighborList == 1 then
nameIndex[neighborList[1].strCharacterName] = 1
nameIndex[neighborList[1].strCharacterName] = 1
end
end
if #neighborList == 0 then
if #neighborList == 0 then
self.wndMain:FindChild("WillYouBeMyNeighborName"):SetText("No Neighbors")
self.wndMain:FindChild("WillYouBeMyNeighborName"):SetText("No Neighbors")
self.wndMain:FindChild("WillYouBeMyNeighborName"):SetTextColor(kcrOffline)
self.wndMain:FindChild("WillYouBeMyNeighborName"):SetTextColor(kcrOffline)
self.wndMain:FindChild("WillYouBeMyNeighborShare"):SetText("No matching neighbors")
self.wndMain:FindChild("WillYouBeMyNeighborShare"):SetText("No matching neighbors")
self.wndMain:FindChild("WillYouBeMyNeighborNodeInfo"):SetText("Unknown")
self.wndMain:FindChild("WillYouBeMyNeighborNodeInfo"):SetText("Unknown")
self.wndMain:FindChild("WillYouBeMyNeighborHarvestInfo"):SetText("Unknown")
self.wndMain:FindChild("WillYouBeMyNeighborHarvestInfo"):SetText("Unknown")
self.wndMain:FindChild("WillYouBeMyNeighborRemaining"):SetText("Unknown")
self.wndMain:FindChild("WillYouBeMyNeighborRemaining"):SetText("Unknown")
self.wndMain:FindChild("WillYouBeMyNeighborActivity"):SetText("Unknown")
self.wndMain:FindChild("WillYouBeMyNeighborActivity"):SetText("Unknown")
self.wndMain:FindChild("WillYouBeMyNeighborLastVisit"):SetText("Unknown")
self.wndMain:FindChild("WillYouBeMyNeighborLastVisit"):SetText("Unknown")
self.wndMain:FindChild("WillYouBeMyNeighborVersionFlag"):Show(false)
self.wndMain:FindChild("WillYouBeMyNeighborVersionFlag"):Show(false)
end
end
return neighborList
return neighborList
--else
--else
-- DEBUG("Getting sorted list outside of housing...")
-- DEBUG("Getting sorted list outside of housing...")
-- return nil
-- return nil
--end
--end
end
end
function WillYouBeMyNeighbor:OnHarvest(data)
function WillYouBeMyNeighbor:OnHarvest(data)
local name = GameLib.GetPlayerUnit():GetName()
local name = GameLib.GetPlayerUnit():GetName()
local onplot = self.wndMain:FindChild("WillYouBeMyNeighborCurrentName"):GetText()
local onplot = self.wndMain:FindChild("WillYouBeMyNeighborCurrentName"):GetText()
if RegisteredUsers[name] == nil then return end
if RegisteredUsers[name] == nil then return end
if type(RegisteredUsers[name]) ~= "table" then return end
if type(RegisteredUsers[name]) ~= "table" then return end
if RegisteredUsers[name].activity == nil then
if RegisteredUsers[name].activity == nil then
RegisteredUsers[name].activity = 0
RegisteredUsers[name].activity = 0
end
end
if RegisteredUsers[name].month ~= GameLib:GetServerTime().nMonth then
if RegisteredUsers[name].month ~= GameLib:GetServerTime().nMonth then
RegisteredUsers[name].month = GameLib:GetServerTime().nMonth
RegisteredUsers[name].month = GameLib:GetServerTime().nMonth
RegisteredUsers[name].activity = 0
RegisteredUsers[name].activity = 0
end
end
for _, val in pairs(data) do
for _, val in pairs(data) do
RegisteredUsers[name].activity = RegisteredUsers[name].activity + val.nCount
RegisteredUsers[name].activity = RegisteredUsers[name].activity + val.nCount
if val.item:GetItemCategory() == 104 then
if val.item:GetItemCategory() == 104 then
local t = {}
local t = {}
t.name = onplot
t.name = onplot
t.message = "PLANT PIRATE ALERT: " .. name .. " harvested " .. val.item:GetName() .. " from your plot"
t.message = "PLANT PIRATE ALERT: " .. name .. " harvested " .. val.item:GetName() .. " from your plot"
self.chanICCPP:SendMessage(t)
self.chanICCPP:SendMessage(t)
else
else
local t = {}
local t = {}
t.name = onplot
t.name = onplot
t.message = name .. " harvested " .. val.nCount .. " " .. val.item:GetName() .. " for you!"
t.message = name .. " harvested " .. val.nCount .. " " .. val.item:GetName() .. " for you!"
self.chanICCHN:SendMessage(t)
self.chanICCHN:SendMessage(t)
end
end
end
end
end
end
function WillYouBeMyNeighbor:OnInterfaceMenuListHasLoaded()
function WillYouBeMyNeighbor:OnInterfaceMenuListHasLoaded()
Event_FireGenericEvent("InterfaceMenuList_NewAddOn", "WillYouBeMyNeighbor", {"WillYouBeMyNeighborOn", "", "BK3:sprHolo_Friends_Account"})
Event_FireGenericEvent("InterfaceMenuList_NewAddOn", "WillYouBeMyNeighbor", {"WillYouBeMyNeighborOn", "", "BK3:sprHolo_Friends_Account"})
end
end
local msgs = {}
local msgs = {}
function WillYouBeMyNeighbor:OnDotMessageWillYouBeMyNeighborChannelMessage(channel, tMsg)
function WillYouBeMyNeighbor:OnDotMessageWillYouBeMyNeighborChannelMessage(channel, tMsg)
if tMsg and tMsg.nodetype then
if tMsg and tMsg.nodetype then
if tMsg.nodetype == "No Node" then
if tMsg.nodetype == "No Node" then
-- No node
-- No node
elseif nodeTypes[tMsg.nodetype] then
elseif nodeTypes[tMsg.nodetype] then
local sName = tMsg.name
local sName = tMsg.name
local sType = nodeTypes[tMsg.nodetype].k
local sType = nodeTypes[tMsg.nodetype].k
local nRank = nodeTypes[tMsg.nodetype].t
local nRank = nodeTypes[tMsg.nodetype].t
if ResourceTypes[sType][sName] then
if ResourceTypes[sType][sName] then
if ResourceTypes[sType][sName] ~= nRank then
if ResourceTypes[sType][sName] ~= nRank then
ResourceTypes[sType][sName] = nRank
ResourceTypes[sType][sName] = nRank
end
end
else
else
ResourceTypes[sType][sName] = nRank
ResourceTypes[sType][sName] = nRank
end
end
end
end
end
end
self.unitPlayerDisposition = GameLib.GetPlayerUnit()
self.unitPlayerDisposition = GameLib.GetPlayerUnit()
if self.unitPlayerDisposition == nil or not self.unitPlayerDisposition:IsValid() or RegisteredUsers == nil then
if self.unitPlayerDisposition == nil or not self.unitPlayerDisposition:IsValid() or RegisteredUsers == nil then
DEBUG("self.tQueuedUnits[1]")
DEBUG("self.tQueuedUnits[1]")
self.tQueuedUnits = {}
self.tQueuedUnits = {}
return
return
end
end
if GameLib.GetPlayerUnit():GetName() == tMsg.name then return end
if GameLib.GetPlayerUnit():GetName() == tMsg.name then return end
if RegisteredUsers[tMsg.name] ~= nil and type(RegisteredUsers[tMsg.name]) == "table" then
if RegisteredUsers[tMsg.name] ~= nil and type(RegisteredUsers[tMsg.name]) == "table" then
if RegisteredUsers[tMsg.name].share ~= nil and tMsg.share == nil then return end
if RegisteredUsers[tMsg.name].share ~= nil and tMsg.share == nil then return end
if RegisteredUsers[tMsg.name].nodetype ~= nil and tMsg.nodetype == nil then return end
if RegisteredUsers[tMsg.name].nodetype ~= nil and tMsg.nodetype == nil then return end
if RegisteredUsers[tMsg.name].faction ~= nil and tMsg.faction == nil then return end
if RegisteredUsers[tMsg.name].faction ~= nil and tMsg.faction == nil then return end
if RegisteredUsers[tMsg.name].remaining ~= nil and tMsg.remaining == nil then return end
if RegisteredUsers[tMsg.name].remaining ~= nil and tMsg.remaining == nil then return end
if RegisteredUsers[tMsg.name].timestamp ~= nil and tMsg.timestamp == nil then return end
if RegisteredUsers[tMsg.name].timestamp ~= nil and tMsg.timestamp == nil then return end
if RegisteredUsers[tMsg.name].month ~= nil and tMsg.month == nil then return end
if RegisteredUsers[tMsg.name].month ~= nil and tMsg.month == nil then return end
if RegisteredUsers[tMsg.name].activity ~= nil and tMsg.activity == nil then return end
if RegisteredUsers[tMsg.name].activity ~= nil and tMsg.activity == nil then return end
if RegisteredUsers[tMsg.name].version ~= nil and tMsg.version == nil then return end
if RegisteredUsers[tMsg.name].version ~= nil and tMsg.version == nil then return end
if RegisteredUsers[tMsg.name].version ~= nil and tMsg.senderversion ~= nil and RegisteredUsers[tMsg.name].version > tMsg.senderversion then return end
if RegisteredUsers[tMsg.name].version ~= nil and tMsg.senderversion ~= nil and RegisteredUsers[tMsg.name].version > tMsg.senderversion then return end
if tMsg.timestamp == nil or (RegisteredUsers[tMsg.name].timestamp ~= nil and RegisteredUsers[tMsg.name].timestamp > tMsg.timestamp) then return end
if tMsg.timestamp == nil or (RegisteredUsers[tMsg.name].timestamp ~= nil and RegisteredUsers[tMsg.name].timestamp > tMsg.timestamp) then return end
if type(RegisteredUsers[tMsg.name].share) == "table" then
if type(RegisteredUsers[tMsg.name].share) == "table" then
RegisteredUsers[tMsg.name] = nil
RegisteredUsers[tMsg.name] = nil
end
end
end
end
if tMsg.nodetype == nil then
if tMsg.nodetype == nil then
if type(RegisteredUsers[tMsg.name]) == "table" then
if type(RegisteredUsers[tMsg.name]) == "table" then
return
return
end
end
if type(tMsg.share) == "table" then return end
if type(tMsg.share) == "table" then return end
RegisteredUsers[tMsg.name] = tMsg.share
RegisteredUsers[tMsg.name] = tMsg.share
else
else
if tMsg.version ~= nil and tMsg.version > version then
if tMsg.version ~= nil and tMsg.version > version then
self.wndMain:FindChild("VersionUpdate"):Show(true)
self.wndMain:FindChild("VersionUpdate"):Show(true)
end
end
RegisteredUsers[tMsg.name] = tMsg
RegisteredUsers[tMsg.name] = tMsg
end
end
end
end
function WillYouBeMyNeighbor:OnDotMessageWillYouBeMyNeighborPPChannelMessage(channel, tMsg)
function WillYouBeMyNeighbor:OnDotMessageWillYouBeMyNeighborPPChannelMessage(channel, tMsg)
self.unitPlayerDisposition = GameLib.GetPlayerUnit()
self.unitPlayerDisposition = GameLib.GetPlayerUnit()
if self.unitPlayerDisposition == nil or not self.unitPlayerDisposition:IsValid() or RegisteredUsers == nil then
if self.unitPlayerDisposition == nil or not self.unitPlayerDisposition:IsValid() or RegisteredUsers == nil then
DEBUG("self.tQueuedUnits[2]")
DEBUG("self.tQueuedUnits[2]")
self.tQueuedUnits = {}
self.tQueuedUnits = {}
return
return
end
end
local name = GameLib.GetPlayerUnit():GetName()
local name = GameLib.GetPlayerUnit():GetName()
if PlantPiratesAlert == true and tMsg.name == name then
if PlantPiratesAlert == true and tMsg.name == name then
ChatSystemLib.PostOnChannel(2, tMsg.message)
ChatSystemLib.PostOnChannel(2, tMsg.message)
end
end
end
end
function WillYouBeMyNeighbor:OnDotMessageWillYouBeMyNeighborHarvestNotificationChannelMessage(channel, tMsg)
function WillYouBeMyNeighbor:OnDotMessageWillYouBeMyNeighborHarvestNotificationChannelMessage(channel, tMsg)
self.unitPlayerDisposition = GameLib.GetPlayerUnit()
self.unitPlayerDisposition = GameLib.GetPlayerUnit()
if self.unitPlayerDisposition == nil or not self.unitPlayerDisposition:IsValid() or RegisteredUsers == nil then
if self.unitPlayerDisposition == nil or not self.unitPlayerDisposition:IsValid() or RegisteredUsers == nil then
DEBUG("self.tQueuedUnits[3]")
DEBUG("self.tQueuedUnits[3]")
self.tQueuedUnits = {}
self.tQueuedUnits = {}
return
return
end
end
local name = GameLib.GetPlayerUnit():GetName()
local name = GameLib.GetPlayerUnit():GetName()
if HarvestNotifications == true and tMsg.name == name then
if HarvestNotifications == true and tMsg.name == name then
ChatSystemLib.PostOnChannel(8, tMsg.message)
ChatSystemLib.PostOnChannel(8, tMsg.message)
end
end
end
end
function WillYouBeMyNeighbor:OnDotMessageWillYouBeMyNeighborOnlineChannelMessage(channel, tMsg)
function WillYouBeMyNeighbor:OnDotMessageWillYouBeMyNeighborOnlineChannelMessage(channel, tMsg)
self.unitPlayerDisposition = GameLib.GetPlayerUnit()
self.unitPlayerDisposition = GameLib.GetPlayerUnit()
if self.unitPlayerDisposition == nil or not self.unitPlayerDisposition:IsValid() or OnlineUsers == nil then
if self.unitPlayerDisposition == nil or not self.unitPlayerDisposition:IsValid() or OnlineUsers == nil then
DEBUG("self.tQueuedUnits[4]")
DEBUG("self.tQueuedUnits[4]")
self.tQueuedUnits = {}
self.tQueuedUnits = {}
return
return
end
end
OnlineUsers[tMsg.name] = self.ServerTime()
OnlineUsers[tMsg.name] = self.ServerTime()
end
end
function WillYouBeMyNeighbor:VisitNeighbor(Name)
function WillYouBeMyNeighbor:VisitNeighbor(Name)
if HousingLib.IsHousingWorld() == false then
if HousingLib.IsHousingWorld() == false then
Cha
Cha
저장된 비교 결과
원본
파일 열기
----------------------------------------------------------------------------------------------- -- Client Lua Script for WillYouBeMyNeighbor -- Copyright (c) NCsoft. All rights reserved ----------------------------------------------------------------------------------------------- require "Window" require "HousingLib" local DEBUGDATA={} local function DEBUG(s) table.insert(DEBUGDATA, 1, {st=debug.getinfo(2).name, msg=s}) DEBUGDATA[101] = nil end ----------------------------------------------------------------------------------------------- -- WillYouBeMyNeighbor Module Definition ----------------------------------------------------------------------------------------------- WillYouBeMyNeighbor = {} WillYouBeMyNeighbor.tLocale = {} NBR_NEIGHBORS = { crnt = 0, next = 0, nk = "", list = {} } ----------------------------------------------------------------------------------------------- -- Constants ----------------------------------------------------------------------------------------------- local version = 1.047 local kcrOnline = ApolloColor.new("UI_TextHoloBodyHighlight") local kcrOffline = ApolloColor.new("UI_BtnTextGrayNormal") local kcrIgnored = ApolloColor.new("UI_WindowAlert") local RegisteredUsers = {} local lastVisit = {} local OnlineUsers = {} local AutoDisplay = true local AutoAccept = false local DeclineByFilter = false local NodeFilter = "Mineral Deposit" local ShareFilter = 0 local NodeLevelFilter = 1 local GuildFilter = "" local PlantPiratesAlert = true local HarvestNotifications = true local AcceptAllSocials = false local currentZone = "" local IgnoredPlots = { ignore = false, ignoreList = {} } local ResourceTypes = { filter = { mineral=false, relic=false, thicket=false }, mineral = {}, relic = {}, thicket = {} } local PlotRatings = {} local wybmnOptions = { takeMail = false, autoZone = false } local autoVisit = false local skipNeeded = false local autoCount = 0 local Plugs = {} local skipnodeTypes = {} --local nameIndex = {} nameIndex = {} local nodeTypes = { -- EN ["Elite Mineral Deposit"] = { k="mineral", t=5 }, ["Elite Relic Excavation"] = { k="mineral", t=5 }, ["Elite Thicket"] = { k="thicket", t=5 }, ["Mineral Deposit"] = { k="mineral", t=1 }, ["Mineral Deposit Tier 1"] = { k="mineral", t=1 }, ["Mineral Deposit Tier 2"] = { k="mineral", t=2 }, ["Mineral Deposit Tier 3"] = { k="mineral", t=3 }, ["Mineral Deposit Tier 4"] = { k="mineral", t=4 }, ["Relic Excavation"] = { k="relic", t=1 }, ["Relic Excavation Tier 1"] = { k="relic", t=1 }, ["Relic Excavation Tier 2"] = { k="relic", t=2 }, ["Relic Excavation Tier 3"] = { k="relic", t=3 }, ["Relic Excavation Tier 4"] = { k="relic", t=4 }, ["Thicket Tier 1"] = { k="thicket", t=1 }, ["Thicket"] = { k="thicket", t=1 }, ["Thicket Tier 2"] = { k="thicket", t=2 }, ["Thicket Tier 3"] = { k="thicket", t=3 }, ["Thicket Tier 4"] = { k="thicket", t=4 }, -- DE ["Mineralvorkommen"] = { k="mineral", t=1 }, ["Mineralvorkommen (Rang 1)"] = { k="mineral", t=1 }, ["Mineralvorkommen (Rang 2)"] = { k="mineral", t=2 }, ["Mineralvorkommen (Rang 3)"] = { k="mineral", t=3 }, ["Mineralvorkommen (Rang 4)"] = { k="mineral", t=4 }, ["Dickicht"] = { k="thicket", t=1 }, ["Dickicht (Rang 1)"] = { k="thicket", t=1 }, ["Dickicht (Rang 2)"] = { k="thicket", t=2 }, ["Dickicht (Rang 3)"] = { k="thicket", t=3 }, ["Dickicht (Rang 4)"] = { k="thicket", t=4 }, ["Reliktausgrabung"] = { k="relic", t=1 }, ["Reliktausgrabung (Rang 1)"] = { k="relic", t=1 }, ["Reliktausgrabung (Rang 2)"] = { k="relic", t=1 }, ["Reliktausgrabung (Rang 3)"] = { k="relic", t=1 }, ["Reliktausgrabung (Rang 4)"] = { k="relic", t=1 }, ["Elite-Mineralvorkommen"] = { k="mineral", t=5 }, ["Elite-Dickicht"] = { k="thicket", t=5 }, ["Elite-Reliktausgrabung"] = { k="relic", t=5 }, } local unitTypes = { -- EN ["Deradune Tree"] = { k="thicket", t=1 }, ["Algoroc Tree"] = { k="thicket", t=1 }, ["Ellevar Tree"] = { k="thicket", t=1 }, ["Celestion Tree"] = { k="thicket", t=1 }, ["Galeras Tree"] = { k="thicket", t=2 }, ["Whitevale Tree"] = { k="thicket", t=2 }, ["Auroria Tree"] = { k="thicket", t=2 }, ["Wilderrun Tree"] = { k="thicket", t=3 }, ["Farside Tree"] = { k="thicket", t=3 }, ["Grimvault Tree"] = { k="thicket", t=4 }, ["Malgrave Tree"] = { k="thicket", t=4 }, ["Standard Relic Node"] = { k="relic", t=1 }, ["Accelerated Relic Node"] = { k="relic", t=1 }, ["Advanced Relic Node"] = { k="relic", t=2 }, ["Dynamic Relic Node"] = { k="relic", t=3 }, ["Kinetic Relic Node"] = { k="relic", t=4 }, ["Iron Node"] = { k="mineral", t=1 }, ["Titanium Node"] = { k="mineral", t=1 }, ["Zephyrite Node"] = { k="mineral", t=1 }, ["Platinum Node"] = { k="mineral", t=2 }, ["Hydrogem Node"] = { k="mineral", t=2 }, ["Xenocite Node"] = { k="mineral", t=3 }, ["Shadeslate Node"] = { k="mineral", t=3 }, ["Galactium Node"] = { k="mineral", t=4 }, ["Novacite Node"] = { k="mineral", t=4 }, } local opacity = { [false] = 1, [true] = 0.6 } ----------------------------------------------------------------------------------------------- -- Initialization ----------------------------------------------------------------------------------------------- function WillYouBeMyNeighbor:new(o) o = o or {} setmetatable(o, self) self.__index = self -- initialize variables here return o end function WillYouBeMyNeighbor:Init() local bHasConfigureFunction = false local strConfigureButtonText = "" local tDependencies = { "NeighborList" } Apollo.RegisterAddon(self, bHasConfigureFunction, strConfigureButtonText, tDependencies) end ----------------------------------------------------------------------------------------------- -- Saved Information ----------------------------------------------------------------------------------------------- function WillYouBeMyNeighbor:OnSave(eLevel) if eLevel ~= GameLib.CodeEnumAddonSaveLevel.Character then return nil end local save = {} save.AutoDisplay = AutoDisplay save.AutoAccept = AutoAccept save.DeclineByFilter = DeclineByFilter save.NodeFilter = NodeFilter save.ShareFilter = ShareFilter save.NodeLevelFilter = NodeLevelFilter save.GuildFilter = GuildFilter save.PlantPiratesAlert = PlantPiratesAlert save.HarvestNotifications = HarvestNotifications save.AcceptAllSocials = AcceptAllSocials save.RegisteredUsers = RegisteredUsers save.lastVisit = lastVisit save.IgnoredPlots = IgnoredPlots save.ResourceTypes = ResourceTypes save.PlotRatings = PlotRatings save.wybmnOptions = wybmnOptions return save end function WillYouBeMyNeighbor:OnRestore(eLevel, tData) if eLevel == GameLib.CodeEnumAddonSaveLevel.Character then if tData.AutoDisplay ~= nil then AutoDisplay = tData.AutoDisplay end if tData.AutoAccept ~= nil then AutoAccept = tData.AutoAccept end if tData.DeclineByFilter ~= nil then DeclineByFilter = tData.DeclineByFilter end if tData.NodeFilter ~= nil then NodeFilter = tData.NodeFilter end if tData.ShareFilter ~= nil then ShareFilter = tData.ShareFilter end if tData.NodeLevelFilter ~= nil then NodeLevelFilter = tData.NodeLevelFilter end if tData.GuildFilter ~= nil then GuildFilter = tData.GuildFilter end if tData.PlantPiratesAlert ~= nil then PlantPiratesAlert = tData.PlantPiratesAlert end if tData.HarvestNotifications ~= nil then HarvestNotifications = tData.HarvestNotifications end if tData.AcceptAllSocials ~= nil then AcceptAllSocials = tData.AcceptAllSocials end if tData.RegisteredUsers ~= nil then RegisteredUsers = tData.RegisteredUsers end if tData.lastVisit then lastVisit = tData.lastVisit end if tData.IgnoredPlots then IgnoredPlots = tData.IgnoredPlots end if tData.ResourceTypes then ResourceTypes = tData.ResourceTypes end if tData.PlotRatings then PlotRatings = tData.PlotRatings end if tData.wybmnOptions then wybmnOptions = tData.wybmnOptions end for k,v in pairs(RegisteredUsers) do if type(v) == "table" then local nt = nodeTypes[v.nodetype] if nt and ResourceTypes[nt.k] and ResourceTypes[nt.k][v.name] == nil then ResourceTypes[nt.k][v.name] = nt.t end if PlotRatings[v.name] == nil then PlotRatings[v.name] = 1 end end end end end ----------------------------------------------------------------------------------------------- -- OnLoad ----------------------------------------------------------------------------------------------- function WillYouBeMyNeighbor:OnLoad() -- load our form file self.xmlDoc = XmlDoc.CreateFromFile("WillYouBeMyNeighbor.xml") self.xmlDoc:RegisterCallback("OnDocLoaded", self) if Apollo.GetAddon("VikingContextMenuPlayer") ~= nil then self.contextMenuPlayer = Apollo.GetAddon("VikingContextMenuPlayer") else self.contextMenuPlayer = Apollo.GetAddon("ContextMenuPlayer") end local oldRedrawAll = self.contextMenuPlayer.RedrawAll self.contextMenuPlayer.RedrawAll = function(context) if self.contextMenuPlayer.wndMain ~= nil then local wndButtonList = self.contextMenuPlayer.wndMain:FindChild("ButtonList") if wndButtonList ~= nil then local wndNew = wndButtonList:FindChildByUserData(tObject) if not wndNew then wndNew = Apollo.LoadForm(self.contextMenuPlayer.xmlDoc, "BtnRegular", wndButtonList, self.contextMenuPlayer) wndNew:SetData("VisitNeighbor") end wndNew:FindChild("BtnText"):SetText("Visit Neighbor") end end oldRedrawAll(context) end -- catch the event fired when the player clicks the context menu local oldProcessContextClick = self.contextMenuPlayer.ProcessContextClick self.contextMenuPlayer.ProcessContextClick = function(context, eButtonType) if eButtonType == "VisitNeighbor" then self:VisitNeighbor(self.contextMenuPlayer.strTarget) else oldProcessContextClick (context, eButtonType) end end self.tQueuedUnits = {} self.rosters = {} Apollo.RegisterEventHandler("UnitCreated", "OnUnitCreated", self) --Apollo.RegisterEventHandler("UnitDestroyed", "OnUnitDestroyed", self) Apollo.RegisterEventHandler("InterfaceMenuListHasLoaded", "OnInterfaceMenuListHasLoaded", self) Apollo.RegisterEventHandler("HarvestItemsSentToOwner", "OnHarvest", self) self.chanICC = ICCommLib.JoinChannel("WillYouBeMyNeighborChannel", "OnDotMessageWillYouBeMyNeighborChannelMessage", self) self.chanICCOL = ICCommLib.JoinChannel("WillYouBeMyNeighborOnlineChannel", "OnDotMessageWillYouBeMyNeighborOnlineChannelMessage", self) self.chanICCPP = ICCommLib.JoinChannel("WillYouBeMyNeighborPPChannel", "OnDotMessageWillYouBeMyNeighborPPChannelMessage", self) self.chanICCHN = ICCommLib.JoinChannel("WillYouBeMyNeighborHarvestNotificationChannel", "OnDotMessageWillYouBeMyNeighborHarvestNotificationChannelMessage", self) self:SetLocaleData() end ----------------------------------------------------------------------------------------------- -- OnDocLoaded ----------------------------------------------------------------------------------------------- function WillYouBeMyNeighbor:OnDocLoaded() if self.xmlDoc ~= nil and self.xmlDoc:IsLoaded() then self.wndMain = Apollo.LoadForm(self.xmlDoc, "WillYouBeMyNeighborForm", nil, self) if self.wndMain == nil then Apollo.AddAddonErrorText(self, "Could not load the main window for some reason.") return end self.wndMain:Show(false, true) -- if the xmlDoc is no longer needed, you should set it to nil -- self.xmlDoc = nil -- Register handlers for events, slash commands and timer, etc. -- e.g. Apollo.RegisterEventHandler("KeyDown", "OnKeyDown", self) Apollo.RegisterSlashCommand("rogers", "OnWillYouBeMyNeighborOn", self) Apollo.RegisterEventHandler("WillYouBeMyNeighborOn", "OnWillYouBeMyNeighborOn", self) Apollo.RegisterEventHandler("GuildRoster", "OnGuildRoster", self) Apollo.RegisterEventHandler("ZoneCompletionUpdated", "OnZoneCompletionUpdated", self) Apollo.RegisterEventHandler("HousingNeighborInviteRecieved", "OnNeighborInviteRecieved", self) Apollo.RegisterEventHandler("WindowManagementReady", "OnWindowManagementReady", self) -- Do additional Addon initialization here self.currentNeighbor = 1 self.currentNeighborName = "" self.expanded = false self.performInvites = "" self.faction = 0 self.timer = ApolloTimer.Create(5.0, true, "UpdateMyself", self) self.timer1 = ApolloTimer.Create(1.0, true, "UpdateCurrent", self) Apollo.CreateTimer("skiptimer", 0.5, false) Apollo.RegisterTimerHandler("skiptimer","AutoSkipCheck",self) self.wndMain:FindChild("ComboShareRatioList"):AddItem("100% to me", "", "100% to me") self.wndMain:FindChild("ComboShareRatioList"):AddItem("75% to me", "", "75% to me") self.wndMain:FindChild("ComboShareRatioList"):AddItem("50% to me", "", "50% to me") self.wndMain:FindChild("ComboShareRatioList"):AddItem("25% to me", "", "25% to me") self.wndMain:FindChild("ComboShareRatioList"):AddItem("0% to me", "", "0% to me") self:PopulateCircles() self.mail = Apollo.GetAddon("Mail") if self.mail then local mailtoggle = self.mail.ToggleWindow function self.mail.ToggleWindow(s) mailtoggle(s) if wybmnOptions.takeMail and MailSystemLib.AtMailbox() then if s.wndMain:IsVisible() then local blooted = false local lootedItems = {} for k,v in pairs(MailSystemLib.GetInbox()) do local tMI = v:GetMessageInfo() if tMI and tMI.strSubject == "Harvest Loot" and tMI.strSenderName == "Phineas T. Rotostar" then --if tMI and tMI.strSenderName == "Phineas T. Rotostar" then -- -- /dump Apollo.GetAddon("Mail").tMailItemWnds -- if tMI.arAttachments then local tAttach for x=1, 10 do tAttach = tMI.arAttachments[x] if tAttach then local sN = tAttach.itemAttached:GetName() local nS = tAttach.nStackCount if lootedItems[sN] then lootedItems[sN] = lootedItems[sN] + nS else lootedItems[sN] = nS blooted = true end end end end v:TakeAllAttachments() local wnd = self.mail.tMailItemWnds[v:GetIdStr()] if wnd then wnd:FindChild("SelectMarker"):SetCheck(true) end end end if blooted then local srtLoot = {} for k,v in pairs(lootedItems) do table.insert(srtLoot, {n=k, s=v}) end table.sort(srtLoot, function(a,b) return a.n < b.n end) for k,v in ipairs(srtLoot) do Print(v.n.." x"..tostring(v.s)) end end end end end end end end ----------------------------------------------------------------------------------------------- -- WillYouBeMyNeighbor Functions ----------------------------------------------------------------------------------------------- function WillYouBeMyNeighbor:GetCurrentZoneName() if HousingLib:IsOnMyResidence() == true then if self.NBR_PLAYERNAME then return self.NBR_PLAYERNAME else local sZN = GetCurrentZoneName() if sZN then self.NBR_PLAYERNAME = sZN return self.NBR_PLAYERNAME else return "YOURSELF" end end else local sZN = GetCurrentZoneName() if sZN then sZN = string.match(GetCurrentZoneName(), "%b[]") if sZN then sZN = sZN:sub(2,-2) return sZN end end end return nil end function WillYouBeMyNeighbor:GetNextNeighbor() local neighborList=self:GetSortedNeighbors() if neighborList then self.currentNeighbor = 1 if #neighborList > 1 then local sZN = self:GetCurrentZoneName() if sZN then local nRank = PlotRatings[sZN] or 0 nRank = 9-nRank local sortkey = string.format("%d-%s", nRank, sZN) NBR_NEIGHBORS.crnt = sortkey for x=1, #neighborList do if neighborList[x].sortKey > sortkey then NBR_NEIGHBORS.next = x NBR_NEIGHBORS.nk = neighborList[x].sortKey self.currentNeighbor = x break end end end end end return neighborList end function WillYouBeMyNeighbor:GetSortedNeighbors() --if HousingLib:IsHousingWorld() == true and HousingLib:IsWarplotResidence() == false then local neighborList=HousingLib.GetNeighborList() local sZN = self:GetCurrentZoneName() self.CURRENTPLOTID = 0 self.IGNOREDPLOTS = {} nameIndex = {} if IgnoredPlots.ignore then for x=#neighborList, 1, -1 do if IgnoredPlots.ignore and IgnoredPlots.ignoreList[neighborList[x].strCharacterName] then table.remove(neighborList, x) end end end local bMin = ResourceTypes.filter.mineral local bRel = ResourceTypes.filter.relic local bThi = ResourceTypes.filter.thicket for x=#neighborList, 1, -1 do local bRemove = true if bMin == false and ResourceTypes.mineral[neighborList[x].strCharacterName] then bRemove = false end if bRel == false and ResourceTypes.relic[neighborList[x].strCharacterName] then bRemove = false end if bThi == false and ResourceTypes.thicket[neighborList[x].strCharacterName] then bRemove = false end --if sZN == neighborList[x].strCharacterName then -- bRemove = true --end if bRemove then self.IGNOREDPLOTS[neighborList[x].strCharacterName] = neighborList[x] table.remove(neighborList, x) else local sName = neighborList[x].strCharacterName local nRank = PlotRatings[sName] or 0 nRank = 9-nRank neighborList[x].sortKey = string.format("%d-%s", nRank, sName) end end if #neighborList > 1 then table.sort(neighborList, function(a,b) return a.sortKey < b.sortKey end) NBR_NEIGHBORS.list = {} for k,v in ipairs(neighborList) do nameIndex[v.strCharacterName] = k if (v.strCharacterName == sZN) then self.CURRENTPLOTID = k end table.insert(NBR_NEIGHBORS.list, {n=v.strCharacterName, k=v.sortKey}) end elseif #neighborList == 1 then nameIndex[neighborList[1].strCharacterName] = 1 end if #neighborList == 0 then self.wndMain:FindChild("WillYouBeMyNeighborName"):SetText("No Neighbors") self.wndMain:FindChild("WillYouBeMyNeighborName"):SetTextColor(kcrOffline) self.wndMain:FindChild("WillYouBeMyNeighborShare"):SetText("No matching neighbors") self.wndMain:FindChild("WillYouBeMyNeighborNodeInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborHarvestInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborRemaining"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborActivity"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborLastVisit"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborVersionFlag"):Show(false) end return neighborList --else -- DEBUG("Getting sorted list outside of housing...") -- return nil --end end function WillYouBeMyNeighbor:OnHarvest(data) local name = GameLib.GetPlayerUnit():GetName() local onplot = self.wndMain:FindChild("WillYouBeMyNeighborCurrentName"):GetText() if RegisteredUsers[name] == nil then return end if type(RegisteredUsers[name]) ~= "table" then return end if RegisteredUsers[name].activity == nil then RegisteredUsers[name].activity = 0 end if RegisteredUsers[name].month ~= GameLib:GetServerTime().nMonth then RegisteredUsers[name].month = GameLib:GetServerTime().nMonth RegisteredUsers[name].activity = 0 end for _, val in pairs(data) do RegisteredUsers[name].activity = RegisteredUsers[name].activity + val.nCount if val.item:GetItemCategory() == 104 then local t = {} t.name = onplot t.message = "PLANT PIRATE ALERT: " .. name .. " harvested " .. val.item:GetName() .. " from your plot" self.chanICCPP:SendMessage(t) else local t = {} t.name = onplot t.message = name .. " harvested " .. val.nCount .. " " .. val.item:GetName() .. " for you!" self.chanICCHN:SendMessage(t) end end end function WillYouBeMyNeighbor:OnInterfaceMenuListHasLoaded() Event_FireGenericEvent("InterfaceMenuList_NewAddOn", "WillYouBeMyNeighbor", {"WillYouBeMyNeighborOn", "", "BK3:sprHolo_Friends_Account"}) end local msgs = {} function WillYouBeMyNeighbor:OnDotMessageWillYouBeMyNeighborChannelMessage(channel, tMsg) if tMsg and tMsg.nodetype then if tMsg.nodetype == "No Node" then -- No node elseif nodeTypes[tMsg.nodetype] then local sName = tMsg.name local sType = nodeTypes[tMsg.nodetype].k local nRank = nodeTypes[tMsg.nodetype].t if ResourceTypes[sType][sName] then if ResourceTypes[sType][sName] ~= nRank then ResourceTypes[sType][sName] = nRank end else ResourceTypes[sType][sName] = nRank end end end self.unitPlayerDisposition = GameLib.GetPlayerUnit() if self.unitPlayerDisposition == nil or not self.unitPlayerDisposition:IsValid() or RegisteredUsers == nil then DEBUG("self.tQueuedUnits[1]") self.tQueuedUnits = {} return end if GameLib.GetPlayerUnit():GetName() == tMsg.name then return end if RegisteredUsers[tMsg.name] ~= nil and type(RegisteredUsers[tMsg.name]) == "table" then if RegisteredUsers[tMsg.name].share ~= nil and tMsg.share == nil then return end if RegisteredUsers[tMsg.name].nodetype ~= nil and tMsg.nodetype == nil then return end if RegisteredUsers[tMsg.name].faction ~= nil and tMsg.faction == nil then return end if RegisteredUsers[tMsg.name].remaining ~= nil and tMsg.remaining == nil then return end if RegisteredUsers[tMsg.name].timestamp ~= nil and tMsg.timestamp == nil then return end if RegisteredUsers[tMsg.name].month ~= nil and tMsg.month == nil then return end if RegisteredUsers[tMsg.name].activity ~= nil and tMsg.activity == nil then return end if RegisteredUsers[tMsg.name].version ~= nil and tMsg.version == nil then return end if RegisteredUsers[tMsg.name].version ~= nil and tMsg.senderversion ~= nil and RegisteredUsers[tMsg.name].version > tMsg.senderversion then return end if tMsg.timestamp == nil or (RegisteredUsers[tMsg.name].timestamp ~= nil and RegisteredUsers[tMsg.name].timestamp > tMsg.timestamp) then return end if type(RegisteredUsers[tMsg.name].share) == "table" then RegisteredUsers[tMsg.name] = nil end end if tMsg.nodetype == nil then if type(RegisteredUsers[tMsg.name]) == "table" then return end if type(tMsg.share) == "table" then return end RegisteredUsers[tMsg.name] = tMsg.share else if tMsg.version ~= nil and tMsg.version > version then self.wndMain:FindChild("VersionUpdate"):Show(true) end RegisteredUsers[tMsg.name] = tMsg end end function WillYouBeMyNeighbor:OnDotMessageWillYouBeMyNeighborPPChannelMessage(channel, tMsg) self.unitPlayerDisposition = GameLib.GetPlayerUnit() if self.unitPlayerDisposition == nil or not self.unitPlayerDisposition:IsValid() or RegisteredUsers == nil then DEBUG("self.tQueuedUnits[2]") self.tQueuedUnits = {} return end local name = GameLib.GetPlayerUnit():GetName() if PlantPiratesAlert == true and tMsg.name == name then ChatSystemLib.PostOnChannel(2, tMsg.message) end end function WillYouBeMyNeighbor:OnDotMessageWillYouBeMyNeighborHarvestNotificationChannelMessage(channel, tMsg) self.unitPlayerDisposition = GameLib.GetPlayerUnit() if self.unitPlayerDisposition == nil or not self.unitPlayerDisposition:IsValid() or RegisteredUsers == nil then DEBUG("self.tQueuedUnits[3]") self.tQueuedUnits = {} return end local name = GameLib.GetPlayerUnit():GetName() if HarvestNotifications == true and tMsg.name == name then ChatSystemLib.PostOnChannel(8, tMsg.message) end end function WillYouBeMyNeighbor:OnDotMessageWillYouBeMyNeighborOnlineChannelMessage(channel, tMsg) self.unitPlayerDisposition = GameLib.GetPlayerUnit() if self.unitPlayerDisposition == nil or not self.unitPlayerDisposition:IsValid() or OnlineUsers == nil then DEBUG("self.tQueuedUnits[4]") self.tQueuedUnits = {} return end OnlineUsers[tMsg.name] = self.ServerTime() end function WillYouBeMyNeighbor:VisitNeighbor(Name) if HousingLib.IsHousingWorld() == false then ChatSystemLib.PostOnChannel(2,"You can't visit people if you're not in the housing system!") return end local neighborList=self:GetSortedNeighbors() for i=1,#neighborList do if neighborList[i].strCharacterName == Name then HousingLib.VisitNeighborResidence(neighborList[i].nId) return end end ChatSystemLib.PostOnChannel(2,Name .. " is not a neighbor, sending neighbor invite!") HousingLib.NeighborInviteByName(Name) end local shares = { "100%", "75%", "50%", "25%", "0%" } local stars = { [0] = "0*", "1*", "2*", "3*", "4*", "5*" } function WillYouBeMyNeighbor:UpdateTargetPlot(name) if name then local nRank = PlotRatings[name] or 0 self.wndMain:FindChild("Window"):SetText(string.format("Target Plot [%s]", stars[nRank])) self.wndMain:FindChild("WillYouBeMyNeighborName"):SetText(name) local neighborList=self:GetSortedNeighbors() local neighborIndex = 0 for i=1, #neighborList do if neighborList[i].strCharacterName == name then neighborIndex = i break end end if IgnoredPlots.ignoreList[name] then self.wndMain:FindChild("WillYouBeMyNeighborName"):SetTextColor(kcrIgnored) else if neighborList[neighborIndex].fLastOnline == 0 then self.wndMain:FindChild("WillYouBeMyNeighborName"):SetTextColor(kcrOnline) else self.wndMain:FindChild("WillYouBeMyNeighborName"):SetTextColor(kcrOffline) end end if RegisteredUsers[name] ~= nil then local val = RegisteredUsers[name] if type(val) == "number" then self.wndMain:FindChild("WillYouBeMyNeighborShare"):SetText(string.format("%s to Owner", shares[val + 1])) self.wndMain:FindChild("WillYouBeMyNeighborNodeInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborHarvestInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborRemaining"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborActivity"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborLastVisit"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborVersionFlag"):Show(false) return end if type(val) == "table" then if type(val.share) == "table" then return end self.wndMain:FindChild("WillYouBeMyNeighborShare"):SetText(string.format("%s to Owner", shares[val.share + 1])) if val.nodetype == nil then self.wndMain:FindChild("WillYouBeMyNeighborNodeInfo"):SetText("Unknown") elseif val.nodelevel ~= nil then self.wndMain:FindChild("WillYouBeMyNeighborNodeInfo"):SetText(val.nodetype .. " " .. val.nodelevel) else self.wndMain:FindChild("WillYouBeMyNeighborNodeInfo"):SetText(val.nodetype) end local harvest if val.miner == true then harvest = "Miner" end if val.survivalist == true then if harvest == "Miner" then harvest = "Miner/Survivalist" else harvest = "Survivalist" end end if val.relichunter == true then if harvest == "Miner" or harvest == "Survivalist" then harvest = harvest .. "/Relic Hunter" else harvest = "Relic Hunter" end end self.wndMain:FindChild("WillYouBeMyNeighborHarvestInfo"):SetText(harvest) if neighborList[neighborIndex] == nil or neighborList[neighborIndex].fLastOnline == nil then self.wndMain:FindChild("WillYouBeMyNeighborCurrentRemaining"):SetText("Unknown") else self.wndMain:FindChild("WillYouBeMyNeighborRemaining"):SetText(self:HelperConvertToTime(neighborList[neighborIndex].fLastOnline)) end if val.activity ~= nil then if val.month ~= nil and val.month == GameLib:GetServerTime().nMonth then self.wndMain:FindChild("WillYouBeMyNeighborActivity"):SetText(val.activity .. " units") else self.wndMain:FindChild("WillYouBeMyNeighborActivity"):SetText("0 units") end else self.wndMain:FindChild("WillYouBeMyNeighborActivity"):SetText("Unknown") end if lastVisit[name] then local td = os.time() - lastVisit[name] local ns = td%60; td = td - ns td = td / 60 local nm = td%60; td = td - nm td = td / 60 self.wndMain:FindChild("WillYouBeMyNeighborLastVisit"):SetText(string.format("%02d:%02d:%02d",td,nm,ns)) else self.wndMain:FindChild("WillYouBeMyNeighborLastVisit"):SetText("Unknown") end if val.version == nil or val.version < version then self.wndMain:FindChild("WillYouBeMyNeighborVersionFlag"):Show(false) else self.wndMain:FindChild("WillYouBeMyNeighborVersionFlag"):Show(true) end return end end else local nl = self:GetSortedNeighbors() if #nl > 0 then self:UpdateTargetPlot(nl[1].strCharacterName) return end end self.wndMain:FindChild("Window"):SetText("Target Plot") self.wndMain:FindChild("WillYouBeMyNeighborShare"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborNodeInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborHarvestInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborRemaining"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborActivity"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborLastVisit"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborVersionFlag"):Show(false) end -- on SlashCommand "/rogers" function WillYouBeMyNeighbor:OnWillYouBeMyNeighborOn(cmd, args) local neighborList=self:GetNextNeighbor() if self.currentNeighbor > #neighborList then self.currentNeighbor = 1 end if args == "visit" then self:OnVisit() return elseif args == "mail" then wybmnOptions.takeMail = not wybmnOptions.takeMail Print("Setting autotake of mail attachments: "..tostring(wybmnOptions.takeMail)) return elseif args == "autozone" then wybmnOptions.autoZone = not wybmnOptions.autoZone Print("Setting autozone on empty plot: "..tostring(wybmnOptions.autoZone)) return elseif args == "debug" then for x=1, 25 do if DEBUGDATA[x] then Print(string.format("%02d: %s : %s", x, tostring(DEBUGDATA[x].st), tostring(DEBUGDATA[x].msg))) end end return end self.wndMain:Invoke() -- show the window if #neighborList == 0 then self.wndMain:FindChild("WillYouBeMyNeighborName"):SetText("No Neighbors") self.wndMain:FindChild("WillYouBeMyNeighborName"):SetTextColor(kcrOffline) self.wndMain:FindChild("WillYouBeMyNeighborShare"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborNodeInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborHarvestInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborRemaining"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborActivity"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborLastVisit"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborVersionFlag"):Show(false) else self.currentNeighborName = neighborList[self.currentNeighbor].strCharacterName self:UpdateTargetPlot(neighborList[self.currentNeighbor].strCharacterName) end self.wndMain:FindChild("ToggleMineral"):SetOpacity(opacity[ResourceTypes.filter.mineral]) self.wndMain:FindChild("ToggleRelic"):SetOpacity(opacity[ResourceTypes.filter.relic]) self.wndMain:FindChild("ToggleThicket"):SetOpacity(opacity[ResourceTypes.filter.thicket]) if IgnoredPlots.ignore then self.wndMain:FindChild("ToggleIgnore"):ChangeArt("CRB_QuestTrackerSprites:btnQT_QuestRedeem") else self.wndMain:FindChild("ToggleIgnore"):ChangeArt("CRB_QuestTrackerSprites:btnQT_QuestFailed") end self.wndMain:FindChild("AutoDisplay"):SetCheck(AutoDisplay) self.wndMain:FindChild("AutoAccept"):SetCheck(AutoAccept) if NodeFilter == "Mineral Deposit" then self.wndMain:FindChild("RadioMineral"):SetCheck(true) end if NodeFilter == "Thicket" then self.wndMain:FindChild("RadioThicket"):SetCheck(true) end if NodeFilter == "Relic Excavation" then self.wndMain:FindChild("RadioRelic"):SetCheck(true) end if NodeLevelFilter == 1 then self.wndMain:FindChild("RadioLevel1"):SetCheck(true) end if NodeLevelFilter == 2 then self.wndMain:FindChild("RadioLevel2"):SetCheck(true) end if NodeLevelFilter == 3 then self.wndMain:FindChild("RadioLevel3"):SetCheck(true) end if NodeLevelFilter == 4 then self.wndMain:FindChild("RadioLevel4"):SetCheck(true) end if ShareFilter == 0 then self.wndMain:FindChild("RadioShare100"):SetCheck(true) end if ShareFilter == 1 then self.wndMain:FindChild("RadioShare75"):SetCheck(true) end if ShareFilter == 2 then self.wndMain:FindChild("RadioShare50"):SetCheck(true) end if ShareFilter == 3 then self.wndMain:FindChild("RadioShare25"):SetCheck(true) end if ShareFilter == 4 then self.wndMain:FindChild("RadioShare0"):SetCheck(true) end self.wndMain:FindChild("ComboCircleList"):SetText(GuildFilter); self.wndMain:FindChild("AutoAcceptGridFilter"):SetCheck(DeclineByFilter) self.wndMain:FindChild("PlantPiratesAlert"):SetCheck(PlantPiratesAlert) self.wndMain:FindChild("HarvestNotifications"):SetCheck(HarvestNotifications) self.wndMain:FindChild("AcceptAllSocials"):SetCheck(AcceptAllSocials) end function WillYouBeMyNeighbor:PopulateCircles() self.wndMain:FindChild("ComboCircleList") local guilds = GuildLib.GetGuilds() self.wndMain:FindChild("ComboCircleList"):AddItem("", "", "") for i, guild in pairs(guilds) do self.wndMain:FindChild("ComboCircleList"):AddItem(guild:GetName(), "", guild:GetName()) end end function WillYouBeMyNeighbor:OnGuildRoster(uGuild, tRoster) self.rosters[uGuild:GetName()] = tRoster end function WillYouBeMyNeighbor:GetPlotNodeCounts() local tCounts = { thicket=0, mineral=0, relic=0, cnt=0 } for k,v in pairs(self.tQueuedUnits) do local sName = v:GetName() local tUT = unitTypes[sName] if tUT then DEBUG(">"..sName) tCounts[tUT.k] = tCounts[tUT.k]+1 tCounts.cnt = tCounts.cnt+1 autoVisit = false end end DEBUG("self.tQueuedUnits[5]:GetPlotNodeCounts") self.tQueuedUnits = {} return tCounts end function WillYouBeMyNeighbor:OnZoneCompletionUpdated() DEBUG("WillYouBeMyNeighbor:OnZoneCompletionUpdated()") DEBUG("#tQueuedUnits = "..tostring(#self.tQueuedUnits)) if self.unitPlayerDisposition == nil or not self.unitPlayerDisposition:IsValid() or RegisteredUsers == nil then DEBUG("self.tQueuedUnits[6]") self.tQueuedUnits = {} return end self:BuildSocialWorld() local idxCount = 0 local tCounts = self:GetPlotNodeCounts() if HousingLib:IsHousingWorld() == true then local sZN = self:GetCurrentZoneName() if tCounts.cnt > 0 then if ResourceTypes.filter.mineral then self.wndMain:FindChild("ToggleMineral"):SetText("") else self.wndMain:FindChild("ToggleMineral"):SetText(tostring(tCounts.mineral)) idxCount = idxCount + tCounts.mineral end if ResourceTypes.filter.relic then self.wndMain:FindChild("ToggleRelic"):SetText("") else self.wndMain:FindChild("ToggleRelic"):SetText(tostring(tCounts.relic)) idxCount = idxCount + tCounts.relic end if ResourceTypes.filter.thicket then self.wndMain:FindChild("ToggleThicket"):SetText("") else self.wndMain:FindChild("ToggleThicket"):SetText(tostring(tCounts.thicket)) idxCount = idxCount + tCounts.thicket end else self.wndMain:FindChild("ToggleMineral"):SetText("") self.wndMain:FindChild("ToggleRelic"):SetText("") self.wndMain:FindChild("ToggleThicket"):SetText("") end local neighborList=self:GetSortedNeighbors() if AutoDisplay == true then self.wndMain:Invoke() -- show the window if self.currentNeighbor > #neighborList then self.currentNeighbor = 1 end if #neighborList == 0 then self.wndMain:FindChild("WillYouBeMyNeighborName"):SetText("No Neighbors") self.wndMain:FindChild("WillYouBeMyNeighborName"):SetTextColor(kcrOffline) self.wndMain:FindChild("WillYouBeMyNeighborShare"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborNodeInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborHarvestInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborRemaining"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborActivity"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborVersionFlag"):Show(false) else self.currentNeighborName = neighborList[self.currentNeighbor].strCharacterName self:UpdateTargetPlot(neighborList[self.currentNeighbor].strCharacterName) end self.wndMain:FindChild("ToggleMineral"):SetOpacity(opacity[ResourceTypes.filter.mineral]) self.wndMain:FindChild("ToggleRelic"):SetOpacity(opacity[ResourceTypes.filter.relic]) self.wndMain:FindChild("ToggleThicket"):SetOpacity(opacity[ResourceTypes.filter.thicket]) if IgnoredPlots.ignore then self.wndMain:FindChild("ToggleIgnore"):ChangeArt("CRB_QuestTrackerSprites:btnQT_QuestRedeem") else self.wndMain:FindChild("ToggleIgnore"):ChangeArt("CRB_QuestTrackerSprites:btnQT_QuestFailed") end self.wndMain:FindChild("AutoDisplay"):SetCheck(AutoDisplay) self.wndMain:FindChild("AutoAccept"):SetCheck(AutoAccept) if NodeFilter == "Mineral Deposit" then self.wndMain:FindChild("RadioMineral"):SetCheck(true) end if NodeFilter == "Thicket" then self.wndMain:FindChild("RadioThicket"):SetCheck(true) end if NodeFilter == "Relic Excavation" then self.wndMain:FindChild("RadioRelic"):SetCheck(true) end if NodeLevelFilter == 1 then self.wndMain:FindChild("RadioLevel1"):SetCheck(true) end if NodeLevelFilter == 2 then self.wndMain:FindChild("RadioLevel2"):SetCheck(true) end if NodeLevelFilter == 3 then self.wndMain:FindChild("RadioLevel3"):SetCheck(true) end if NodeLevelFilter == 4 then self.wndMain:FindChild("RadioLevel4"):SetCheck(true) end if ShareFilter == 0 then self.wndMain:FindChild("RadioShare100"):SetCheck(true) end if ShareFilter == 1 then self.wndMain:FindChild("RadioShare75"):SetCheck(true) end if ShareFilter == 2 then self.wndMain:FindChild("RadioShare50"):SetCheck(true) end if ShareFilter == 3 then self.wndMain:FindChild("RadioShare25"):SetCheck(true) end if ShareFilter == 4 then self.wndMain:FindChild("RadioShare0"):SetCheck(true) end self.wndMain:FindChild("ComboCircleList"):SetText(GuildFilter); self.wndMain:FindChild("AutoAcceptGridFilter"):SetCheck(DeclineByFilter) self.wndMain:FindChild("PlantPiratesAlert"):SetCheck(PlantPiratesAlert) self.wndMain:FindChild("HarvestNotifications"):SetCheck(HarvestNotifications) self.wndMain:FindChild("AcceptAllSocials"):SetCheck(AcceptAllSocials) end local sAZ = tostring(wybmnOptions.autoZone) local sAV = tostring(autoVisit) local sMR = tostring(HousingLib:IsOnMyResidence() or false) if wybmnOptions.autoZone and autoVisit and HousingLib:IsOnMyResidence() ~= true then if idxCount == 0 then if autoCount < #neighborList then --if autoCount < 20 then autoCount = autoCount+1 DEBUG("Plot: "..self:GetCurrentZoneName().." has no nodes. Skipping in 0.5s.") Apollo.StartTimer("skiptimer") skipNeeded = true else autoCount = 0 autoVisit = false end else autoCount = 0 autoVisit = false end else autoCount = 0 autoVisit = false end else DEBUG("OZCU exit(2)") autoCount = 0 autoVisit = false if AutoDisplay == true then self.wndMain:Close() end end end function WillYouBeMyNeighbor:AutoSkipCheck() if skipNeeded then DEBUG("SKIP NEEDED: "..tostring(skipNeeded)..", #tQueuedUnits = "..tostring(#self.tQueuedUnits)) skipNeeded = false Apollo.StopTimer("skiptimer") if #self.tQueuedUnits > 0 then local tCounts = self:GetPlotNodeCounts() if ((ResourceTypes.filter.mineral == false and tCounts.mineral > 0) or (ResourceTypes.filter.relic == false and tCounts.relic > 0) or (ResourceTypes.filter.thicket == false and tCounts.thicket > 0)) then DEBUG("Aborting transfer!") return end end Print("Moving to next plot!") self:OnVisit() end end local currentBroadcast = "" function WillYouBeMyNeighbor:UpdateCurrent() self.unitPlayerDisposition = GameLib.GetPlayerUnit() if self.unitPlayerDisposition == nil or not self.unitPlayerDisposition:IsValid() or RegisteredUsers == nil or GetCurrentZoneName() == nil then DEBUG("self.tQueuedUnits[7]") self.tQueuedUnits = {} return end if HousingLib:IsHousingWorld() == true and HousingLib:IsWarplotResidence() == false then local name = n name = self:GetCurrentZoneName() local neighborList = self:GetSortedNeighbors() if name then self.wndMain:FindChild("WillYouBeMyNeighborCurrentName"):SetText(name) if name ~= currentZone then if HousingLib:IsOnMyResidence() then self.wndMain:FindChild("Window1"):SetText("Current Plot") else self.wndMain:FindChild("Window1"):SetText(string.format("[%s/%d] Current Plot",tostring(nameIndex[name] or "??"),#neighborList)) end currentZone = name if lastVisit then lastVisit[name] = os.time() end end if IgnoredPlots.ignoreList[name] then self.wndMain:FindChild("WillYouBeMyNeighborCurrentName"):SetTextColor(kcrIgnored) else if ( (self.CURRENTPLOTID>0 and neighborList[self.CURRENTPLOTID].fLastOnline and neighborList[self.CURRENTPLOTID].fLastOnline > 0) or (self.IGNOREDPLOTS[name] and self.IGNOREDPLOTS[name].fLastOnline and self.IGNOREDPLOTS[name].fLastOnline > 0) ) then self.wndMain:FindChild("WillYouBeMyNeighborCurrentName"):SetTextColor(kcrOffline) else self.wndMain:FindChild("WillYouBeMyNeighborCurrentName"):SetTextColor(kcrOnline) end end end if PlotRatings[name] then self:SetStarRating(PlotRatings[name]) else self:SetStarRating(0) end if name and RegisteredUsers[name] ~= nil then local val = RegisteredUsers[name] if type(val) == "number" then self.wndMain:FindChild("WillYouBeMyNeighborCurrentShare"):SetText(string.format("%s to Owner", shares[val + 1])) self.wndMain:FindChild("WillYouBeMyNeighborCurrentNodeInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborCurrentHarvestInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborCurrentRemaining"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborCurrentActivity"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborCurrentVersionFlag"):Show(false) return end if type(val) == "table" then if type(val.share) == "table" then return end self.wndMain:FindChild("WillYouBeMyNeighborCurrentShare"):SetText(string.format("%s to Owner", shares[val.share + 1])) if val.nodetype == nil then self.wndMain:FindChild("WillYouBeMyNeighborCurrentNodeInfo"):SetText("Unknown") elseif val.nodelevel ~= nil then self.wndMain:FindChild("WillYouBeMyNeighborCurrentNodeInfo"):SetText(val.nodetype .. " " .. val.nodelevel) else self.wndMain:FindChild("WillYouBeMyNeighborCurrentNodeInfo"):SetText(val.nodetype) end local harvest = "" if val.miner == true then harvest = "Miner" end if val.survivalist == true then if harvest == "Miner" then harvest = "Miner/Survivalist" else harvest = "Survivalist" end end if val.relichunter == true then if harvest == "Miner" or harvest == "Survivalist" then harvest = harvest .. "/Relic Hunter" else harvest = "Relic Hunter" end end self.wndMain:FindChild("WillYouBeMyNeighborCurrentHarvestInfo"):SetText(harvest) if GameLib:GetPlayerUnit():GetName() == name then self.wndMain:FindChild("WillYouBeMyNeighborCurrentRemaining"):SetText("Online") else if self.CURRENTPLOTID > 0 then if neighborList[self.CURRENTPLOTID] == nil or neighborList[self.CURRENTPLOTID].fLastOnline == nil then self.wndMain:FindChild("WillYouBeMyNeighborCurrentRemaining"):SetText("Unknown") else self.wndMain:FindChild("WillYouBeMyNeighborCurrentRemaining"):SetText(self:HelperConvertToTime(neighborList[self.CURRENTPLOTID].fLastOnline)) end else if self.IGNOREDPLOTS[name] then self.wndMain:FindChild("WillYouBeMyNeighborCurrentRemaining"):SetText(self:HelperConvertToTime(self.IGNOREDPLOTS[name].fLastOnline)) else self.wndMain:FindChild("WillYouBeMyNeighborCurrentRemaining"):SetText("Unknown*1") end end end if val.activity ~= nil then if val.month ~= nil and val.month == GameLib:GetServerTime().nMonth then self.wndMain:FindChild("WillYouBeMyNeighborCurrentActivity"):SetText(val.activity .. " units") else self.wndMain:FindChild("WillYouBeMyNeighborCurrentActivity"):SetText("0 units") end else self.wndMain:FindChild("WillYouBeMyNeighborCurrentActivity"):SetText("Unknown") end if val.version == nil or val.version < version then self.wndMain:FindChild("WillYouBeMyNeighborCurrentVersionFlag"):Show(false) else self.wndMain:FindChild("WillYouBeMyNeighborCurrentVersionFlag"):Show(true) end return end end self.wndMain:FindChild("WillYouBeMyNeighborCurrentShare"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborCurrentNodeInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborCurrentHarvestInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborCurrentRemaining"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborCurrentActivity"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborCurrentVersionFlag"):Show(false) else self.wndMain:FindChild("WillYouBeMyNeighborCurrentName"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborCurrentShare"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborCurrentNodeInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborCurrentHarvestInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborCurrentRemaining"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborCurrentActivity"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborCurrentVersionFlag"):Show(false) end end function WillYouBeMyNeighbor:UpdateMyself() self.unitPlayerDisposition = GameLib.GetPlayerUnit() if self.unitPlayerDisposition == nil or not self.unitPlayerDisposition:IsValid() or RegisteredUsers == nil then DEBUG("self.tQueuedUnits[8]") self.tQueuedUnits = {} return end if HousingLib:IsHousingWorld() == true and HousingLib:IsOnMyResidence() == true then local neighborList=self:GetSortedNeighbors() if #neighborList < 100 then local online = {} online.name = GameLib.GetPlayerUnit():GetName() self.chanICCOL:SendMessage(online) end self.faction = GameLib.GetPlayerUnit():GetFaction() local aNeighborList = Apollo.GetAddon("NeighborList") Apollo.RemoveEventHandler("HousingNeighborInviteRecieved", aNeighborList) local t = {} name = GameLib.GetPlayerUnit():GetName() if RegisteredUsers[name] == nil then RegisteredUsers[name] = {} end RegisteredUsers[name].name = name RegisteredUsers[name].share = HousingLib:GetNeighborHarvestSplit() RegisteredUsers[name].nodetype = "No Node" RegisteredUsers[name].remaining = 0 for i=1, 6 do local cPlot = HousingLib.GetPlot(i) for _, tNode in ipairs(Plugs) do if tNode == cPlot.strName then RegisteredUsers[name].nodetype = cPlot.strName RegisteredUsers[name].remaining = cPlot.fRemainingHours end end end RegisteredUsers[name].relichunter = false RegisteredUsers[name].survivalist = false RegisteredUsers[name].miner = false local tKnownSkills = CraftingLib.GetKnownTradeskills() if tKnownSkills then for nIndex, tSkill in ipairs(tKnownSkills) do local tInfo = CraftingLib.GetTradeskillInfo(tSkill.eId) if tInfo and tInfo.bIsActive then if tSkill.strName == "Relic Hunter" then RegisteredUsers[name].relichunter = true elseif tSkill.strName == "Survivalist" then RegisteredUsers[name].survivalist = true elseif tSkill.strName == "Mining" then RegisteredUsers[name].miner = true end end end end RegisteredUsers[name].timestamp = self.ServerTime() RegisteredUsers[name].faction = GameLib.GetPlayerUnit():GetFaction() RegisteredUsers[name].version = version RegisteredUsers[name].nodelevel = nil if RegisteredUsers[name].day ~= GameLib:GetServerTime().nDay then RegisteredUsers[name].day = GameLib:GetServerTime().nDay end self.chanICC:SendMessage(RegisteredUsers[name]) end if currentBroadcast == "" then currentBroadcast = next(RegisteredUsers) if RegisteredUsers[currentBroadcast] == nil then return end local val = RegisteredUsers[currentBroadcast] local t = {} if type(val) == "number" then t.name = currentBroadcast t.share = RegisteredUsers[currentBroadcast] self.chanICC:SendMessage(t) return end if type(val) == "table" then local subtable = RegisteredUsers[currentBroadcast].share if type(subtable) == "table" then return end if RegisteredUsers[currentBroadcast].name == nil then RegisteredUsers[currentBroadcast].name = currentBroadcast end self.chanICC:SendMessage(RegisteredUsers[currentBroadcast]) return end else if RegisteredUsers[currentBroadcast] == nil then return end currentBroadcast = next(RegisteredUsers, currentBroadcast) if currentBroadcast == nil then currentBroadcast = next(RegisteredUsers) end local val = RegisteredUsers[currentBroadcast] local t = {} if type(val) == "number" then t.name = currentBroadcast t.share = RegisteredUsers[currentBroadcast] self.chanICC:SendMessage(t) return end if type(val) == "table" then local subtable = RegisteredUsers[currentBroadcast].share if type(subtable) == "table" then return end if RegisteredUsers[currentBroadcast].name == nil then RegisteredUsers[currentBroadcast].name = currentBroadcast end self.chanICC:SendMessage(RegisteredUsers[currentBroadcast]) return end end end function WillYouBeMyNeighbor:OnUnitCreated(unit) if HousingLib:IsHousingWorld() == true and HousingLib:IsWarplotResidence() == false then if unit == nil or not unit:IsValid() or unit == GameLib.GetPlayerUnit() then return end table.insert(self.tQueuedUnits, unit) end end function WillYouBeMyNeighbor:OnNeighborInviteRecieved(strName) local aNeighborList = Apollo.GetAddon("NeighborList") if AutoAccept == true then if DeclineByFilter == false then aNeighborList.strInviterName = strName HousingLib.NeighborInviteAccept() ChatSystemLib.PostOnChannel(2,"Invite from " .. strName .. " accepted by WillYouBeMyNeighbor") elseif RegisteredUsers[strName] ~= nil then local key = strName local val = RegisteredUsers[key] if AcceptAllSocials == true and self.rosters ~= nil and self.rosters[GuildFilter] then for _, groupMember in pairs(self.rosters[GuildFilter]) do if groupMember.strName == key then HousingLib.NeighborInviteAccept() ChatSystemLib.PostOnChannel(2,"Invite from " .. strName .. " accepted by WillYouBeMyNeighbor") return end end end if GuildFilter ~= nil and GuildFilter ~= "" and self.rosters[GuildFilter] ~= nil then for _, groupMember in pairs(self.rosters[GuildFilter]) do if groupMember.strName == key then if type(val) == "table" and type(val.share) ~= "table" and key ~= GameLib:GetPlayerUnit():GetName() and val.share >= ShareFilter then if val.remaining ~= nil and val.faction == self.faction and string.find(val.nodetype, NodeFilter) then local nodelevel = 0 if string.find(val.nodetype, "Elite") or string.find(val.nodetype, "4") then nodelevel = 4 elseif string.find(val.nodetype, "3") then nodelevel = 3 elseif string.find(val.nodetype, "2") then nodelevel = 2 elseif string.find(val.nodetype, "1") then nodelevel = 1 end if nodelevel >= NodeLevelFilter then HousingLib.NeighborInviteAccept() ChatSystemLib.PostOnChannel(2,"Invite from " .. strName .. " accepted by WillYouBeMyNeighbor") return end elseif val.nodetype ~= nil and val.nodelevel ~= nil and val.nodelevel >= NodeLevelFilter and val.nodetype == NodeFilter then HousingLib.NeighborInviteAccept() ChatSystemLib.PostOnChannel(2,"Invite from " .. strName .. " accepted by WillYouBeMyNeighbor") return end end end end else if type(val) == "table" and type(val.share) ~= "table" and key ~= GameLib:GetPlayerUnit():GetName() and val.share >= ShareFilter then if val.remaining ~= nil and val.faction == self.faction and string.find(val.nodetype, NodeFilter) then local nodelevel = 0 if string.find(val.nodetype, "Elite") or string.find(val.nodetype, "4") then nodelevel = 4 elseif string.find(val.nodetype, "3") then nodelevel = 3 elseif string.find(val.nodetype, "2") then nodelevel = 2 elseif string.find(val.nodetype, "1") then nodelevel = 1 end if nodelevel >= NodeLevelFilter then HousingLib.NeighborInviteAccept() ChatSystemLib.PostOnChannel(2,"Invite from " .. strName .. " accepted by WillYouBeMyNeighbor") return else Print(string.format("Declining %d / %d", nodelevel, NodeLevelFilter)) end elseif val.nodetype ~= nil and val.nodelevel ~= nil and val.nodelevel >= NodeLevelFilter and val.nodetype == NodeFilter then HousingLib.NeighborInviteAccept() ChatSystemLib.PostOnChannel(2,"Invite from " .. strName .. " accepted by WillYouBeMyNeighbor") return end end end HousingLib.NeighborInviteDecline() ChatSystemLib.PostOnChannel(2,"Invite from " .. strName .. " declined by WillYouBeMyNeighbor based on filters") return else if AcceptAllSocials == true then for _, groupMember in pairs(self.rosters[GuildFilter]) do if groupMember.strName == key then HousingLib.NeighborInviteAccept() ChatSystemLib.PostOnChannel(2,"Invite from " .. strName .. " accepted by WillYouBeMyNeighbor") return end end end HousingLib.NeighborInviteDecline() ChatSystemLib.PostOnChannel(2,"Invite from " .. strName .. " declined by WillYouBeMyNeighbor based on filters") end else aNeighborList:OnNeighborInviteRecieved(strName) end end function WillYouBeMyNeighbor:BuildSocialWorld() local myUnit = GameLib.GetPlayerUnit() if (myUnit) then end for _, tCurrGuild in pairs(GuildLib.GetGuilds()) do tCurrGuild:RequestMembers() end end function WillYouBeMyNeighbor:OnWindowManagementReady() Event_FireGenericEvent("WindowManagementAdd", {wnd = self.wndMain, strName = "WillYouBeMyNeighbor"}) end function WillYouBeMyNeighbor:IsNeighbor(name) local neighborList=self:GetSortedNeighbors() for i=1,#neighborList do if neighborList[i].strCharacterName == name then return true end end return false end function WillYouBeMyNeighbor:HelperConvertToTime(nDays) if nDays == 0 then return Apollo.GetString("Neighbors_Online") end if nDays == nil then return "" end local tTimeInfo = {["name"] = "", ["count"] = nil} if nDays >= 365 then -- Years tTimeInfo["name"] = Apollo.GetString("CRB_Year") tTimeInfo["count"] = math.floor(nDays / 365) elseif nDays >= 30 then -- Months tTimeInfo["name"] = Apollo.GetString("CRB_Month") tTimeInfo["count"] = math.floor(nDays / 30) elseif nDays >= 7 then tTimeInfo["name"] = Apollo.GetString("CRB_Week") tTimeInfo["count"] = math.floor(nDays / 7) elseif nDays >= 1 then -- Days tTimeInfo["name"] = Apollo.GetString("CRB_Day") tTimeInfo["count"] = math.floor(nDays) else local fHours = nDays * 24 local nHoursRounded = math.floor(fHours) local nMin = math.floor(fHours*60) if nHoursRounded > 0 then tTimeInfo["name"] = Apollo.GetString("CRB_Hour") tTimeInfo["count"] = nHoursRounded elseif nMin > 0 then tTimeInfo["name"] = Apollo.GetString("CRB_Min") tTimeInfo["count"] = nMin else tTimeInfo["name"] = Apollo.GetString("CRB_Min") tTimeInfo["count"] = 1 end end return String_GetWeaselString(Apollo.GetString("CRB_TimeOffline"), tTimeInfo) end ---------------------------------------------- -- WillYouBeMyNeighbor Form Functions ----------------------------------------------------------------------------------------------- -- when the OK button is clicked function WillYouBeMyNeighbor:OnVisit() autoVisit = true local neighborList=self:GetSortedNeighbors() for i=1, #neighborList do if neighborList[i].strCharacterName == self.currentNeighborName then self.currentNeighbor = i break end end if #neighborList > 0 then if self.currentNeighbor > #neighborList then self.currentNeighbor = 1 self.currentNeighborName = neighborList[self.currentNeighbor].strCharacterName self:UpdateTargetPlot(neighborList[self.currentNeighbor].strCharacterName, self) else HousingLib.VisitNeighborResidence(neighborList[self.currentNeighbor].nId) self.currentNeighbor = self.currentNeighbor + 1 if self.currentNeighbor > #neighborList then self.currentNeighbor = 1 end self.currentNeighborName = neighborList[self.currentNeighbor].strCharacterName self:UpdateTargetPlot(neighborList[self.currentNeighbor].strCharacterName, self) end end end -- when the Cancel button is clicked function WillYouBeMyNeighbor:OnSkip() local neighborList=self:GetSortedNeighbors() self.currentNeighbor = self.currentNeighbor + 1 local sZN = self:GetCurrentZoneName() local nZN = nameIndex[sZN] or 0 if nZN == self.currentNeighbor then self:OnSkip() else if self.currentNeighbor > #neighborList then self.currentNeighbor = 1 end if #neighborList > 0 then self.currentNeighborName = neighborList[self.currentNeighbor].strCharacterName self:UpdateTargetPlot(neighborList[self.currentNeighbor].strCharacterName, self) else self.wndMain:FindChild("WillYouBeMyNeighborShare"):SetText("No matching neighbors") self.wndMain:FindChild("WillYouBeMyNeighborNodeInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborHarvestInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborRemaining"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborActivity"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborLastVisit"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborVersionFlag"):Show(false) end end end function WillYouBeMyNeighbor:ServerTime() local timetable = GameLib:GetServerTime() timetable.year = timetable.nYear timetable.month = timetable.nMonth timetable.day = timetable.nDay timetable.hour = timetable.nHour timetable.min = timetable.nMinute timetable.sec = timetable.nSecond timetable.isdst = false return os.time(timetable) end function WillYouBeMyNeighbor:SetLocaleData() -- Figure out the locale local strCancel = Apollo.GetString(1) if strCancel == "Abbrechen" then -- German Plugs = self.tLocale.de.Plugs else Plugs = self.tLocale.en.Plugs end end function WillYouBeMyNeighbor:Name_MouseButtonUp() local name = self.wndMain:FindChild("WillYouBeMyNeighborName"):GetText() if IgnoredPlots.ignoreList[name] then IgnoredPlots.ignoreList[name] = false else IgnoredPlots.ignoreList[name] = true end self:UpdateTargetPlot(name) end function WillYouBeMyNeighbor:OnToggleMineral() if ResourceTypes.filter.mineral then ResourceTypes.filter.mineral = false else ResourceTypes.filter.mineral = true end currentZone = "" self:UpdateTargetPlot() self:UpdateCurrent() self.wndMain:FindChild("ToggleMineral"):SetOpacity(opacity[ResourceTypes.filter.mineral]) end function WillYouBeMyNeighbor:OnToggleRelic() if ResourceTypes.filter.relic then ResourceTypes.filter.relic = false else ResourceTypes.filter.relic = true end currentZone = "" self:UpdateTargetPlot() self:UpdateCurrent() self.wndMain:FindChild("ToggleRelic"):SetOpacity(opacity[ResourceTypes.filter.relic]) end function WillYouBeMyNeighbor:OnToggleThicket() if ResourceTypes.filter.thicket then ResourceTypes.filter.thicket = false else ResourceTypes.filter.thicket = true end currentZone = "" self:UpdateTargetPlot() self:UpdateCurrent() self.wndMain:FindChild("ToggleThicket"):SetOpacity(opacity[ResourceTypes.filter.thicket]) end function WillYouBeMyNeighbor:OnToggleIgnore() if IgnoredPlots.ignore then IgnoredPlots.ignore = false self.wndMain:FindChild("ToggleIgnore"):ChangeArt("CRB_QuestTrackerSprites:btnQT_QuestFailed") else IgnoredPlots.ignore = true self.wndMain:FindChild("ToggleIgnore"):ChangeArt("CRB_QuestTrackerSprites:btnQT_QuestRedeem") end local name = self.wndMain:FindChild("WillYouBeMyNeighborName"):GetText() self:UpdateTargetPlot(name) end --------------------------------------------------------------------------------------------------- -- WillYouBeMyNeighborForm Functions --------------------------------------------------------------------------------------------------- function WillYouBeMyNeighbor:OnClose( wndHandler, wndControl, eMouseButton ) self.wndMain:Close() end function WillYouBeMyNeighbor:OnSlide( wndHandler, wndControl, eMouseButton ) local x1,y1,x2,y2 = self.wndMain:GetAnchorOffsets() if self.expanded == false then self.wndMain:SetAnchorOffsets(x1,y1,x1+750,y1+540) self.expanded = true self.wndMain:FindChild("SlideButton"):ChangeArt("BK3:btnHolo_ExpandCollapse_Inverted") self.wndMain:FindChild("Expanded"):Show(true) self.wndMain:FindChild("Data"):Show(true) self:BuildSocialWorld() self:GridRefresh() else self.wndMain:SetAnchorOffsets(x1,y1,x1+450,y1+170) self.expanded = false self.wndMain:FindChild("SlideButton"):ChangeArt("BK3:btnHolo_ExpandCollapse") self.wndMain:FindChild("Expanded"):Show(false) self.wndMain:FindChild("Data"):Show(false) end local OptInterface = Apollo.GetAddon("OptionsInterface") OptInterface:UpdateTrackedWindow(self.wndMain) end function WillYouBeMyNeighbor:OnAutoInvite( wndHandler, wndControl, eMouseButton ) local groupName = self.wndMain:FindChild("ComboCircleList"):GetText() if self.rosters == nil then self:BuildSocialWorld() ChatSystemLib.PostOnChannel(2,"Roster list was not ready, please try again in a few seconds") return end local neighborList=self:GetSortedNeighbors() for key, val in pairs(self.rosters[groupName]) do local neighbor = false for i=1, #neighborList do if neighborList[i].strCharacterName == val.strName then neighbor = true break end end if neighbor == false and val.fLastOnline == 0 and val.strName ~= GameLib.GetPlayerUnit():GetName() then HousingLib.NeighborInviteByName(val.strName) end end ChatSystemLib.PostOnChannel(2,"Neighbor invites sent to online members of " .. groupName) end function WillYouBeMyNeighbor:OnSetRatio( wndHandler, wndControl, eMouseButton ) if HousingLib:IsHousingWorld() == false or HousingLib:IsResidenceOwner() == false then ChatSystemLib.PostOnChannel(2,"You must be on your plot to set share ratio") return end local selectedRatio = self.wndMain:FindChild("ComboShareRatioList"):GetText() if selectedRatio == "100% to me" then HousingLib.SetNeighborHarvestSplit(0) end if selectedRatio == "75% to me" then HousingLib.SetNeighborHarvestSplit(1) end if selectedRatio == "50% to me" then HousingLib.SetNeighborHarvestSplit(2) end if selectedRatio == "25% to me" then HousingLib.SetNeighborHarvestSplit(3) end if selectedRatio == "0% to me" then HousingLib.SetNeighborHarvestSplit(4) end ChatSystemLib.PostOnChannel(2,"House share ratio set to " .. selectedRatio) end function WillYouBeMyNeighbor:AutoDisplayCheck( wndHandler, wndControl, eMouseButton ) AutoDisplay = self.wndMain:FindChild("AutoDisplay"):IsChecked() end function WillYouBeMyNeighbor:OnRemove( wndHandler, wndControl, eMouseButton ) local neighborList=self:GetSortedNeighbors() local name = self.wndMain:FindChild("WillYouBeMyNeighborName"):GetText() for i=1, #neighborList do if neighborList[i].strCharacterName == name then HousingLib.NeighborEvict(neighborList[i].nId) break end end self.currentNeighbor = self.currentNeighbor + 1 if self.currentNeighbor > #neighborList then self.currentNeighbor = 1 end self.currentNeighborName = neighborList[self.currentNeighbor].strCharacterName self:UpdateTargetPlot(neighborList[self.currentNeighbor].strCharacterName, self) end function WillYouBeMyNeighbor:AutoAcceptCheck( wndHandler, wndControl, eMouseButton ) AutoAccept = self.wndMain:FindChild("AutoAccept"):IsChecked() end function WillYouBeMyNeighbor:OnPrevious( wndHandler, wndControl, eMouseButton ) local neighborList=self:GetSortedNeighbors() self.currentNeighbor = self.currentNeighbor - 1 local sZN = self:GetCurrentZoneName() local nZN = nameIndex[sZN] or 0 if nZN == self.currentNeighbor then self:OnPrevious() else if self.currentNeighbor < 1 then self.currentNeighbor = #neighborList if nZN == self.currentNeighbor then self.currentNeighbor = self.currentNeighbor-1 if self.currentNeighbor < 1 then self.currentNeighbor = 1 end end end if #neighborList > 0 then self.currentNeighborName = neighborList[self.currentNeighbor].strCharacterName self:UpdateTargetPlot(neighborList[self.currentNeighbor].strCharacterName, self) else self.wndMain:FindChild("WillYouBeMyNeighborShare"):SetText("No matching neighbors") self.wndMain:FindChild("WillYouBeMyNeighborNodeInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborHarvestInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborRemaining"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborActivity"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborLastVisit"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborVersionFlag"):Show(false) end end end function WillYouBeMyNeighbor:OnHome( wndHandler, wndControl, eMouseButton ) HousingLib.RequestTakeMeHome() end function WillYouBeMyNeighbor:Test( wndHandler, wndControl, eMouseButton ) end function WillYouBeMyNeighbor:OnRadioRelic( wndHandler, wndControl, eMouseButton ) NodeFilter = "Relic Excavation" self:GridRefresh() end function WillYouBeMyNeighbor:OnRadioThicket( wndHandler, wndControl, eMouseButton ) NodeFilter = "Thicket" self:GridRefresh() end function WillYouBeMyNeighbor:OnRadioMineral( wndHandler, wndControl, eMouseButton ) NodeFilter = "Mineral Deposit" self:GridRefresh() end function WillYouBeMyNeighbor:GridRefresh() local grid = self.wndMain:FindChild("Grid") grid:DeleteAll() for key, val in pairs(RegisteredUsers) do if self:IsNeighbor(key) == false then if GuildFilter ~= nil and GuildFilter ~= "" and self.rosters[GuildFilter] ~= nil and OnlineUsers[key] ~= nil and OnlineUsers[key] > (self.ServerTime() - 11) then for _, groupMember in pairs(self.rosters[GuildFilter]) do if groupMember.strName == key then if type(val) == "table" and type(val.share) ~= "table" and key ~= GameLib:GetPlayerUnit():GetName() and val.share >= ShareFilter then if val.remaining ~= nil and val.faction == self.faction and string.find(val.nodetype, NodeFilter) then local nodelevel = 0 if string.find(val.nodetype, "Elite") or string.find(val.nodetype, "4") then nodelevel = 4 elseif string.find(val.nodetype, "3") then nodelevel = 3 elseif string.find(val.nodetype, "2") then nodelevel = 2 elseif string.find(val.nodetype, "1") then nodelevel = 1 end if nodelevel >= NodeLevelFilter then local iNewRow = grid:AddRow("") grid:SetCellText(iNewRow, 1, key) grid:SetCellText(iNewRow, 2, string.format("%s to Owner", shares[val.share + 1])) grid:SetCellText(iNewRow, 3, "Level " .. nodelevel) end elseif val.nodetype ~= nil and val.nodelevel ~= nil and val.nodelevel >= NodeLevelFilter and val.nodetype == NodeFilter then local iNewRow = grid:AddRow("") grid:SetCellText(iNewRow, 1, key) grid:SetCellText(iNewRow, 2, string.format("%s to Owner", shares[val.share + 1])) grid:SetCellText(iNewRow, 3, "Level " .. val.nodelevel) end end end end else if type(val) == "table" and type(val.share) ~= "table" and key ~= GameLib:GetPlayerUnit():GetName() and val.share >= ShareFilter and OnlineUsers[key] ~= nil and OnlineUsers[key] > (self.ServerTime() - 11) then if val.remaining ~= nil and val.faction == self.faction and string.find(val.nodetype, NodeFilter) then local nodelevel = 0 if string.find(val.nodetype, "Elite") or string.find(val.nodetype, "4") then nodelevel = 4 elseif string.find(val.nodetype, "3") then nodelevel = 3 elseif string.find(val.nodetype, "2") then nodelevel = 2 elseif string.find(val.nodetype, "1") then nodelevel = 1 end if nodelevel >= NodeLevelFilter then local iNewRow = grid:AddRow("") grid:SetCellText(iNewRow, 1, key) grid:SetCellText(iNewRow, 2, string.format("%s to Owner", shares[val.share + 1])) grid:SetCellText(iNewRow, 3, "Level " .. nodelevel) end elseif val.nodetype ~= nil and val.nodelevel ~= nil and val.nodelevel >= NodeLevelFilter and val.nodetype == NodeFilter then local iNewRow = grid:AddRow("") grid:SetCellText(iNewRow, 1, key) grid:SetCellText(iNewRow, 2, string.format("%s to Owner", shares[val.share + 1])) grid:SetCellText(iNewRow, 3, "Level " .. val.nodelevel) end end end end end end function WillYouBeMyNeighbor:OnAddNeighbors( wndHandler, wndControl, eMouseButton ) for key, val in pairs(RegisteredUsers) do if self:IsNeighbor(key) == false then if GuildFilter ~= nil and GuildFilter ~= "" and self.rosters[GuildFilter] ~= nil and OnlineUsers[key] ~= nil and OnlineUsers[key] > (self.ServerTime() - 11) then for _, groupMember in pairs(self.rosters[GuildFilter]) do if groupMember.strName == key then if type(val) == "table" and type(val.share) ~= "table" and key ~= GameLib:GetPlayerUnit():GetName() and val.share >= ShareFilter then if val.remaining ~= nil and val.faction == self.faction and string.find(val.nodetype, NodeFilter) then local nodelevel = 0 if string.find(val.nodetype, "Elite") or string.find(val.nodetype, "4") then nodelevel = 4 elseif string.find(val.nodetype, "3") then nodelevel = 3 elseif string.find(val.nodetype, "2") then nodelevel = 2 elseif string.find(val.nodetype, "1") then nodelevel = 1 end if nodelevel >= NodeLevelFilter then HousingLib.NeighborInviteByName(key) end elseif val.nodetype ~= nil and val.nodelevel ~= nil and val.nodelevel >= NodeLevelFilter and val.nodetype == NodeFilter then HousingLib.NeighborInviteByName(key) end end end end else if type(val) == "table" and type(val.share) ~= "table" and key ~= GameLib:GetPlayerUnit():GetName() and val.share >= ShareFilter and OnlineUsers[key] ~= nil and OnlineUsers[key] > (self.ServerTime() - 11) then if val.remaining ~= nil and val.faction == self.faction and string.find(val.nodetype, NodeFilter) then local nodelevel = 0 if string.find(val.nodetype, "Elite") or string.find(val.nodetype, "4") then nodelevel = 4 elseif string.find(val.nodetype, "3") then nodelevel = 3 elseif string.find(val.nodetype, "2") then nodelevel = 2 elseif string.find(val.nodetype, "1") then nodelevel = 1 end if nodelevel >= NodeLevelFilter then HousingLib.NeighborInviteByName(key) end elseif val.nodetype ~= nil and val.nodelevel ~= nil and val.nodelevel >= NodeLevelFilter and val.nodetype == NodeFilter then HousingLib.NeighborInviteByName(key) end end end end end ChatSystemLib.PostOnChannel(2,"Neighbor invites sent") end function WillYouBeMyNeighbor:OnRadio100( wndHandler, wndControl, eMouseButton ) ShareFilter = 0 self:GridRefresh() end function WillYouBeMyNeighbor:OnRadio75( wndHandler, wndControl, eMouseButton ) ShareFilter = 1 self:GridRefresh() end function WillYouBeMyNeighbor:OnRadio50( wndHandler, wndControl, eMouseButton ) ShareFilter = 2 self:GridRefresh() end function WillYouBeMyNeighbor:OnRadio25( wndHandler, wndControl, eMouseButton ) ShareFilter = 3 self:GridRefresh() end function WillYouBeMyNeighbor:OnRadio0( wndHandler, wndControl, eMouseButton ) ShareFilter = 4 self:GridRefresh() end function WillYouBeMyNeighbor:OnLevel1( wndHandler, wndControl, eMouseButton ) NodeLevelFilter = 1 self:GridRefresh() end function WillYouBeMyNeighbor:OnLevel2( wndHandler, wndControl, eMouseButton ) NodeLevelFilter = 2 self:GridRefresh() end function WillYouBeMyNeighbor:OnLevel3( wndHandler, wndControl, eMouseButton ) NodeLevelFilter = 3 self:GridRefresh() end function WillYouBeMyNeighbor:OnLevel4( wndHandler, wndControl, eMouseButton ) NodeLevelFilter = 4 self:GridRefresh() end function WillYouBeMyNeighbor:OnGuildFilterChange( wndHandler, wndControl ) GuildFilter = wndControl:GetSelectedText() self:GridRefresh() end function WillYouBeMyNeighbor:DeclineByFilter( wndHandler, wndControl, eMouseButton ) DeclineByFilter = wndControl:IsChecked() end function WillYouBeMyNeighbor:OnFilterPlantPirates( wndHandler, wndControl, eMouseButton ) PlantPiratesAlert = wndControl:IsChecked() end function WillYouBeMyNeighbor:OnHarvestNotifications( wndHandler, wndControl, eMouseButton ) HarvestNotifications = wndControl:IsChecked() end function WillYouBeMyNeighbor:OnAcceptAllSocials( wndHandler, wndControl, eMouseButton ) AcceptAllSocials = wndControl:IsChecked() end function WillYouBeMyNeighbor:SetStarRating(r) for x=1, 5 do if x<=r then self.wndMain:FindChild(string.format("Rating%d",x)):SetOpacity(1) else self.wndMain:FindChild(string.format("Rating%d",x)):SetOpacity(0.6) end end local cp = self.wndMain:FindChild("WillYouBeMyNeighborCurrentName"):GetText() if cp and PlotRatings[cp] ~= r then PlotRatings[cp] = r end end function WillYouBeMyNeighbor:OnStarRating1() self:SetStarRating(1) end function WillYouBeMyNeighbor:OnStarRating2() self:SetStarRating(2) end function WillYouBeMyNeighbor:OnStarRating3() self:SetStarRating(3) end function WillYouBeMyNeighbor:OnStarRating4() self:SetStarRating(4) end function WillYouBeMyNeighbor:OnStarRating5() self:SetStarRating(5) end ----------------------------------------------------------------------------------------------- -- WillYouBeMyNeighbor Instance ----------------------------------------------------------------------------------------------- local WillYouBeMyNeighborInst = WillYouBeMyNeighbor:new() WillYouBeMyNeighborInst:Init()
수정본
파일 열기
----------------------------------------------------------------------------------------------- -- Client Lua Script for WillYouBeMyNeighbor -- Copyright (c) NCsoft. All rights reserved ----------------------------------------------------------------------------------------------- require "Window" require "HousingLib" local DEBUGDATA={} local function DEBUG(s) table.insert(DEBUGDATA, 1, {st=debug.getinfo(2).name, msg=s}) DEBUGDATA[101] = nil end ----------------------------------------------------------------------------------------------- -- WillYouBeMyNeighbor Module Definition ----------------------------------------------------------------------------------------------- WillYouBeMyNeighbor = {} WillYouBeMyNeighbor.tLocale = {} NBR_NEIGHBORS = { crnt = 0, next = 0, nk = "", list = {} } ----------------------------------------------------------------------------------------------- -- Constants ----------------------------------------------------------------------------------------------- local version = 1.047 local kcrOnline = ApolloColor.new("UI_TextHoloBodyHighlight") local kcrOffline = ApolloColor.new("UI_BtnTextGrayNormal") local kcrIgnored = ApolloColor.new("UI_WindowAlert") local RegisteredUsers = {} local lastVisit = {} local OnlineUsers = {} local AutoDisplay = true local AutoAccept = false local DeclineByFilter = false local NodeFilter = "Mineral Deposit" local ShareFilter = 0 local NodeLevelFilter = 1 local GuildFilter = "" local PlantPiratesAlert = true local HarvestNotifications = true local AcceptAllSocials = false local currentZone = "" local IgnoredPlots = { ignore = false, ignoreList = {} } local ResourceTypes = { filter = { mineral=false, relic=false, thicket=false }, mineral = {}, relic = {}, thicket = {} } local PlotRatings = {} local wybmnOptions = { takeMail = false, autoZone = false } local autoVisit = false local skipNeeded = false local autoCount = 0 local Plugs = {} local skipnodeTypes = {} --local nameIndex = {} nameIndex = {} local nodeTypes = { -- EN ["Elite Mineral Deposit"] = { k="mineral", t=5 }, ["Elite Relic Excavation"] = { k="mineral", t=5 }, ["Elite Thicket"] = { k="thicket", t=5 }, ["Mineral Deposit"] = { k="mineral", t=1 }, ["Mineral Deposit Tier 1"] = { k="mineral", t=1 }, ["Mineral Deposit Tier 2"] = { k="mineral", t=2 }, ["Mineral Deposit Tier 3"] = { k="mineral", t=3 }, ["Mineral Deposit Tier 4"] = { k="mineral", t=4 }, ["Relic Excavation"] = { k="relic", t=1 }, ["Relic Excavation Tier 1"] = { k="relic", t=1 }, ["Relic Excavation Tier 2"] = { k="relic", t=2 }, ["Relic Excavation Tier 3"] = { k="relic", t=3 }, ["Relic Excavation Tier 4"] = { k="relic", t=4 }, ["Thicket Tier 1"] = { k="thicket", t=1 }, ["Thicket"] = { k="thicket", t=1 }, ["Thicket Tier 2"] = { k="thicket", t=2 }, ["Thicket Tier 3"] = { k="thicket", t=3 }, ["Thicket Tier 4"] = { k="thicket", t=4 }, -- DE ["Mineralvorkommen"] = { k="mineral", t=1 }, ["Mineralvorkommen (Rang 1)"] = { k="mineral", t=1 }, ["Mineralvorkommen (Rang 2)"] = { k="mineral", t=2 }, ["Mineralvorkommen (Rang 3)"] = { k="mineral", t=3 }, ["Mineralvorkommen (Rang 4)"] = { k="mineral", t=4 }, ["Dickicht"] = { k="thicket", t=1 }, ["Dickicht (Rang 1)"] = { k="thicket", t=1 }, ["Dickicht (Rang 2)"] = { k="thicket", t=2 }, ["Dickicht (Rang 3)"] = { k="thicket", t=3 }, ["Dickicht (Rang 4)"] = { k="thicket", t=4 }, ["Reliktausgrabung"] = { k="relic", t=1 }, ["Reliktausgrabung (Rang 1)"] = { k="relic", t=1 }, ["Reliktausgrabung (Rang 2)"] = { k="relic", t=1 }, ["Reliktausgrabung (Rang 3)"] = { k="relic", t=1 }, ["Reliktausgrabung (Rang 4)"] = { k="relic", t=1 }, ["Elite-Mineralvorkommen"] = { k="mineral", t=5 }, ["Elite-Dickicht"] = { k="thicket", t=5 }, ["Elite-Reliktausgrabung"] = { k="relic", t=5 }, } local unitTypes = { -- EN ["Deradune Tree"] = { k="thicket", t=1 }, ["Algoroc Tree"] = { k="thicket", t=1 }, ["Ellevar Tree"] = { k="thicket", t=1 }, ["Celestion Tree"] = { k="thicket", t=1 }, ["Galeras Tree"] = { k="thicket", t=2 }, ["Whitevale Tree"] = { k="thicket", t=2 }, ["Auroria Tree"] = { k="thicket", t=2 }, ["Wilderrun Tree"] = { k="thicket", t=3 }, ["Farside Tree"] = { k="thicket", t=3 }, ["Grimvault Tree"] = { k="thicket", t=4 }, ["Malgrave Tree"] = { k="thicket", t=4 }, ["Standard Relic Node"] = { k="relic", t=1 }, ["Accelerated Relic Node"] = { k="relic", t=1 }, ["Advanced Relic Node"] = { k="relic", t=2 }, ["Dynamic Relic Node"] = { k="relic", t=3 }, ["Kinetic Relic Node"] = { k="relic", t=4 }, ["Iron Node"] = { k="mineral", t=1 }, ["Titanium Node"] = { k="mineral", t=1 }, ["Zephyrite Node"] = { k="mineral", t=1 }, ["Platinum Node"] = { k="mineral", t=2 }, ["Hydrogem Node"] = { k="mineral", t=2 }, ["Xenocite Node"] = { k="mineral", t=3 }, ["Shadeslate Node"] = { k="mineral", t=3 }, ["Galactium Node"] = { k="mineral", t=4 }, ["Novacite Node"] = { k="mineral", t=4 }, } local opacity = { [false] = 1, [true] = 0.6 } ----------------------------------------------------------------------------------------------- -- Initialization ----------------------------------------------------------------------------------------------- function WillYouBeMyNeighbor:new(o) o = o or {} setmetatable(o, self) self.__index = self -- initialize variables here return o end function WillYouBeMyNeighbor:Init() local bHasConfigureFunction = false local strConfigureButtonText = "" local tDependencies = { "NeighborList" } Apollo.RegisterAddon(self, bHasConfigureFunction, strConfigureButtonText, tDependencies) end ----------------------------------------------------------------------------------------------- -- Saved Information ----------------------------------------------------------------------------------------------- function WillYouBeMyNeighbor:OnSave(eLevel) if eLevel ~= GameLib.CodeEnumAddonSaveLevel.Character then return nil end local save = {} save.AutoDisplay = AutoDisplay save.AutoAccept = AutoAccept save.DeclineByFilter = DeclineByFilter save.NodeFilter = NodeFilter save.ShareFilter = ShareFilter save.NodeLevelFilter = NodeLevelFilter save.GuildFilter = GuildFilter save.PlantPiratesAlert = PlantPiratesAlert save.HarvestNotifications = HarvestNotifications save.AcceptAllSocials = AcceptAllSocials save.RegisteredUsers = RegisteredUsers save.lastVisit = lastVisit save.IgnoredPlots = IgnoredPlots save.ResourceTypes = ResourceTypes save.PlotRatings = PlotRatings save.wybmnOptions = wybmnOptions return save end function WillYouBeMyNeighbor:OnRestore(eLevel, tData) if eLevel == GameLib.CodeEnumAddonSaveLevel.Character then if tData.AutoDisplay ~= nil then AutoDisplay = tData.AutoDisplay end if tData.AutoAccept ~= nil then AutoAccept = tData.AutoAccept end if tData.DeclineByFilter ~= nil then DeclineByFilter = tData.DeclineByFilter end if tData.NodeFilter ~= nil then NodeFilter = tData.NodeFilter end if tData.ShareFilter ~= nil then ShareFilter = tData.ShareFilter end if tData.NodeLevelFilter ~= nil then NodeLevelFilter = tData.NodeLevelFilter end if tData.GuildFilter ~= nil then GuildFilter = tData.GuildFilter end if tData.PlantPiratesAlert ~= nil then PlantPiratesAlert = tData.PlantPiratesAlert end if tData.HarvestNotifications ~= nil then HarvestNotifications = tData.HarvestNotifications end if tData.AcceptAllSocials ~= nil then AcceptAllSocials = tData.AcceptAllSocials end if tData.RegisteredUsers ~= nil then RegisteredUsers = tData.RegisteredUsers end if tData.lastVisit then lastVisit = tData.lastVisit end if tData.IgnoredPlots then IgnoredPlots = tData.IgnoredPlots end if tData.ResourceTypes then ResourceTypes = tData.ResourceTypes end if tData.PlotRatings then PlotRatings = tData.PlotRatings end if tData.wybmnOptions then wybmnOptions = tData.wybmnOptions end for k,v in pairs(RegisteredUsers) do if type(v) == "table" then local nt = nodeTypes[v.nodetype] if nt and ResourceTypes[nt.k] and ResourceTypes[nt.k][v.name] == nil then ResourceTypes[nt.k][v.name] = nt.t end if PlotRatings[v.name] == nil then PlotRatings[v.name] = 1 end end end end end ----------------------------------------------------------------------------------------------- -- OnLoad ----------------------------------------------------------------------------------------------- function WillYouBeMyNeighbor:OnLoad() -- load our form file self.xmlDoc = XmlDoc.CreateFromFile("WillYouBeMyNeighbor.xml") self.xmlDoc:RegisterCallback("OnDocLoaded", self) if Apollo.GetAddon("VikingContextMenuPlayer") ~= nil then self.contextMenuPlayer = Apollo.GetAddon("VikingContextMenuPlayer") else self.contextMenuPlayer = Apollo.GetAddon("ContextMenuPlayer") end local oldRedrawAll = self.contextMenuPlayer.RedrawAll self.contextMenuPlayer.RedrawAll = function(context) if self.contextMenuPlayer.wndMain ~= nil then local wndButtonList = self.contextMenuPlayer.wndMain:FindChild("ButtonList") if wndButtonList ~= nil then local wndNew = wndButtonList:FindChildByUserData(tObject) if not wndNew then wndNew = Apollo.LoadForm(self.contextMenuPlayer.xmlDoc, "BtnRegular", wndButtonList, self.contextMenuPlayer) wndNew:SetData("VisitNeighbor") end wndNew:FindChild("BtnText"):SetText("Visit Neighbor") end end oldRedrawAll(context) end -- catch the event fired when the player clicks the context menu local oldProcessContextClick = self.contextMenuPlayer.ProcessContextClick self.contextMenuPlayer.ProcessContextClick = function(context, eButtonType) if eButtonType == "VisitNeighbor" then self:VisitNeighbor(self.contextMenuPlayer.strTarget) else oldProcessContextClick (context, eButtonType) end end self.tQueuedUnits = {} self.rosters = {} Apollo.RegisterEventHandler("UnitCreated", "OnUnitCreated", self) --Apollo.RegisterEventHandler("UnitDestroyed", "OnUnitDestroyed", self) Apollo.RegisterEventHandler("InterfaceMenuListHasLoaded", "OnInterfaceMenuListHasLoaded", self) Apollo.RegisterEventHandler("HarvestItemsSentToOwner", "OnHarvest", self) self.chanICC = ICCommLib.JoinChannel("WillYouBeMyNeighborChannel", "OnDotMessageWillYouBeMyNeighborChannelMessage", self) self.chanICCOL = ICCommLib.JoinChannel("WillYouBeMyNeighborOnlineChannel", "OnDotMessageWillYouBeMyNeighborOnlineChannelMessage", self) self.chanICCPP = ICCommLib.JoinChannel("WillYouBeMyNeighborPPChannel", "OnDotMessageWillYouBeMyNeighborPPChannelMessage", self) self.chanICCHN = ICCommLib.JoinChannel("WillYouBeMyNeighborHarvestNotificationChannel", "OnDotMessageWillYouBeMyNeighborHarvestNotificationChannelMessage", self) self:SetLocaleData() end ----------------------------------------------------------------------------------------------- -- OnDocLoaded ----------------------------------------------------------------------------------------------- function WillYouBeMyNeighbor:OnDocLoaded() if self.xmlDoc ~= nil and self.xmlDoc:IsLoaded() then self.wndMain = Apollo.LoadForm(self.xmlDoc, "WillYouBeMyNeighborForm", nil, self) if self.wndMain == nil then Apollo.AddAddonErrorText(self, "Could not load the main window for some reason.") return end self.wndMain:Show(false, true) -- if the xmlDoc is no longer needed, you should set it to nil -- self.xmlDoc = nil -- Register handlers for events, slash commands and timer, etc. -- e.g. Apollo.RegisterEventHandler("KeyDown", "OnKeyDown", self) Apollo.RegisterSlashCommand("rogers", "OnWillYouBeMyNeighborOn", self) Apollo.RegisterEventHandler("WillYouBeMyNeighborOn", "OnWillYouBeMyNeighborOn", self) Apollo.RegisterEventHandler("GuildRoster", "OnGuildRoster", self) Apollo.RegisterEventHandler("ZoneCompletionUpdated", "OnZoneCompletionUpdated", self) Apollo.RegisterEventHandler("HousingNeighborInviteRecieved", "OnNeighborInviteRecieved", self) Apollo.RegisterEventHandler("WindowManagementReady", "OnWindowManagementReady", self) -- Do additional Addon initialization here self.currentNeighbor = 1 self.currentNeighborName = "" self.expanded = false self.performInvites = "" self.faction = 0 self.timer = ApolloTimer.Create(5.0, true, "UpdateMyself", self) self.timer1 = ApolloTimer.Create(1.0, true, "UpdateCurrent", self) Apollo.CreateTimer("skiptimer", 0.5, false) Apollo.RegisterTimerHandler("skiptimer","AutoSkipCheck",self) self.wndMain:FindChild("ComboShareRatioList"):AddItem("100% to me", "", "100% to me") self.wndMain:FindChild("ComboShareRatioList"):AddItem("75% to me", "", "75% to me") self.wndMain:FindChild("ComboShareRatioList"):AddItem("50% to me", "", "50% to me") self.wndMain:FindChild("ComboShareRatioList"):AddItem("25% to me", "", "25% to me") self.wndMain:FindChild("ComboShareRatioList"):AddItem("0% to me", "", "0% to me") self:PopulateCircles() self.mail = Apollo.GetAddon("Mail") if self.mail then local mailtoggle = self.mail.ToggleWindow function self.mail.ToggleWindow(s) mailtoggle(s) if wybmnOptions.takeMail and MailSystemLib.AtMailbox() then if s.wndMain:IsVisible() then local blooted = false local lootedItems = {} for k,v in pairs(MailSystemLib.GetInbox()) do local tMI = v:GetMessageInfo() if tMI and tMI.strSubject == "Harvest Loot" and tMI.strSenderName == "Phineas T. Rotostar" then --if tMI and tMI.strSenderName == "Phineas T. Rotostar" then -- -- /dump Apollo.GetAddon("Mail").tMailItemWnds -- if tMI.arAttachments then local tAttach for x=1, 10 do tAttach = tMI.arAttachments[x] if tAttach then local sN = tAttach.itemAttached:GetName() local nS = tAttach.nStackCount if lootedItems[sN] then lootedItems[sN] = lootedItems[sN] + nS else lootedItems[sN] = nS blooted = true end end end end v:TakeAllAttachments() local wnd = self.mail.tMailItemWnds[v:GetIdStr()] if wnd then wnd:FindChild("SelectMarker"):SetCheck(true) end end end if blooted then local srtLoot = {} for k,v in pairs(lootedItems) do table.insert(srtLoot, {n=k, s=v}) end table.sort(srtLoot, function(a,b) return a.n < b.n end) for k,v in ipairs(srtLoot) do Print(v.n.." x"..tostring(v.s)) end end end end end end end end ----------------------------------------------------------------------------------------------- -- WillYouBeMyNeighbor Functions ----------------------------------------------------------------------------------------------- function WillYouBeMyNeighbor:GetCurrentZoneName() if HousingLib:IsOnMyResidence() == true then if self.NBR_PLAYERNAME then return self.NBR_PLAYERNAME else local sZN = GetCurrentZoneName() if sZN then self.NBR_PLAYERNAME = sZN return self.NBR_PLAYERNAME else return "YOURSELF" end end else local sZN = GetCurrentZoneName() if sZN then sZN = string.match(GetCurrentZoneName(), "%b[]") if sZN then sZN = sZN:sub(2,-2) return sZN end end end return nil end function WillYouBeMyNeighbor:GetNextNeighbor() local neighborList=self:GetSortedNeighbors() if neighborList then self.currentNeighbor = 1 if #neighborList > 1 then local sZN = self:GetCurrentZoneName() if sZN then local nRank = PlotRatings[sZN] or 0 nRank = 9-nRank local sortkey = string.format("%d-%s", nRank, sZN) NBR_NEIGHBORS.crnt = sortkey for x=1, #neighborList do if neighborList[x].sortKey > sortkey then NBR_NEIGHBORS.next = x NBR_NEIGHBORS.nk = neighborList[x].sortKey self.currentNeighbor = x break end end end end end return neighborList end function WillYouBeMyNeighbor:GetSortedNeighbors() --if HousingLib:IsHousingWorld() == true and HousingLib:IsWarplotResidence() == false then local neighborList=HousingLib.GetNeighborList() local sZN = self:GetCurrentZoneName() self.CURRENTPLOTID = 0 self.IGNOREDPLOTS = {} nameIndex = {} if IgnoredPlots.ignore then for x=#neighborList, 1, -1 do if IgnoredPlots.ignore and IgnoredPlots.ignoreList[neighborList[x].strCharacterName] then table.remove(neighborList, x) end end end local bMin = ResourceTypes.filter.mineral local bRel = ResourceTypes.filter.relic local bThi = ResourceTypes.filter.thicket for x=#neighborList, 1, -1 do local bRemove = true if bMin == false and ResourceTypes.mineral[neighborList[x].strCharacterName] then bRemove = false end if bRel == false and ResourceTypes.relic[neighborList[x].strCharacterName] then bRemove = false end if bThi == false and ResourceTypes.thicket[neighborList[x].strCharacterName] then bRemove = false end --if sZN == neighborList[x].strCharacterName then -- bRemove = true --end if bRemove then self.IGNOREDPLOTS[neighborList[x].strCharacterName] = neighborList[x] table.remove(neighborList, x) else local sName = neighborList[x].strCharacterName local nRank = PlotRatings[sName] or 0 nRank = 9-nRank neighborList[x].sortKey = string.format("%d-%s", nRank, sName) end end if #neighborList > 1 then table.sort(neighborList, function(a,b) return a.sortKey < b.sortKey end) NBR_NEIGHBORS.list = {} for k,v in ipairs(neighborList) do nameIndex[v.strCharacterName] = k if (v.strCharacterName == sZN) then self.CURRENTPLOTID = k end table.insert(NBR_NEIGHBORS.list, {n=v.strCharacterName, k=v.sortKey}) end elseif #neighborList == 1 then nameIndex[neighborList[1].strCharacterName] = 1 end if #neighborList == 0 then self.wndMain:FindChild("WillYouBeMyNeighborName"):SetText("No Neighbors") self.wndMain:FindChild("WillYouBeMyNeighborName"):SetTextColor(kcrOffline) self.wndMain:FindChild("WillYouBeMyNeighborShare"):SetText("No matching neighbors") self.wndMain:FindChild("WillYouBeMyNeighborNodeInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborHarvestInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborRemaining"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborActivity"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborLastVisit"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborVersionFlag"):Show(false) end return neighborList --else -- DEBUG("Getting sorted list outside of housing...") -- return nil --end end function WillYouBeMyNeighbor:OnHarvest(data) local name = GameLib.GetPlayerUnit():GetName() local onplot = self.wndMain:FindChild("WillYouBeMyNeighborCurrentName"):GetText() if RegisteredUsers[name] == nil then return end if type(RegisteredUsers[name]) ~= "table" then return end if RegisteredUsers[name].activity == nil then RegisteredUsers[name].activity = 0 end if RegisteredUsers[name].month ~= GameLib:GetServerTime().nMonth then RegisteredUsers[name].month = GameLib:GetServerTime().nMonth RegisteredUsers[name].activity = 0 end for _, val in pairs(data) do RegisteredUsers[name].activity = RegisteredUsers[name].activity + val.nCount if val.item:GetItemCategory() == 104 then local t = {} t.name = onplot t.message = "PLANT PIRATE ALERT: " .. name .. " harvested " .. val.item:GetName() .. " from your plot" self.chanICCPP:SendMessage(t) else local t = {} t.name = onplot t.message = name .. " harvested " .. val.nCount .. " " .. val.item:GetName() .. " for you!" self.chanICCHN:SendMessage(t) end end end function WillYouBeMyNeighbor:OnInterfaceMenuListHasLoaded() Event_FireGenericEvent("InterfaceMenuList_NewAddOn", "WillYouBeMyNeighbor", {"WillYouBeMyNeighborOn", "", "BK3:sprHolo_Friends_Account"}) end local msgs = {} function WillYouBeMyNeighbor:OnDotMessageWillYouBeMyNeighborChannelMessage(channel, tMsg) if tMsg and tMsg.nodetype then if tMsg.nodetype == "No Node" then -- No node elseif nodeTypes[tMsg.nodetype] then local sName = tMsg.name local sType = nodeTypes[tMsg.nodetype].k local nRank = nodeTypes[tMsg.nodetype].t if ResourceTypes[sType][sName] then if ResourceTypes[sType][sName] ~= nRank then ResourceTypes[sType][sName] = nRank end else ResourceTypes[sType][sName] = nRank end end end self.unitPlayerDisposition = GameLib.GetPlayerUnit() if self.unitPlayerDisposition == nil or not self.unitPlayerDisposition:IsValid() or RegisteredUsers == nil then DEBUG("self.tQueuedUnits[1]") self.tQueuedUnits = {} return end if GameLib.GetPlayerUnit():GetName() == tMsg.name then return end if RegisteredUsers[tMsg.name] ~= nil and type(RegisteredUsers[tMsg.name]) == "table" then if RegisteredUsers[tMsg.name].share ~= nil and tMsg.share == nil then return end if RegisteredUsers[tMsg.name].nodetype ~= nil and tMsg.nodetype == nil then return end if RegisteredUsers[tMsg.name].faction ~= nil and tMsg.faction == nil then return end if RegisteredUsers[tMsg.name].remaining ~= nil and tMsg.remaining == nil then return end if RegisteredUsers[tMsg.name].timestamp ~= nil and tMsg.timestamp == nil then return end if RegisteredUsers[tMsg.name].month ~= nil and tMsg.month == nil then return end if RegisteredUsers[tMsg.name].activity ~= nil and tMsg.activity == nil then return end if RegisteredUsers[tMsg.name].version ~= nil and tMsg.version == nil then return end if RegisteredUsers[tMsg.name].version ~= nil and tMsg.senderversion ~= nil and RegisteredUsers[tMsg.name].version > tMsg.senderversion then return end if tMsg.timestamp == nil or (RegisteredUsers[tMsg.name].timestamp ~= nil and RegisteredUsers[tMsg.name].timestamp > tMsg.timestamp) then return end if type(RegisteredUsers[tMsg.name].share) == "table" then RegisteredUsers[tMsg.name] = nil end end if tMsg.nodetype == nil then if type(RegisteredUsers[tMsg.name]) == "table" then return end if type(tMsg.share) == "table" then return end RegisteredUsers[tMsg.name] = tMsg.share else if tMsg.version ~= nil and tMsg.version > version then self.wndMain:FindChild("VersionUpdate"):Show(true) end RegisteredUsers[tMsg.name] = tMsg end end function WillYouBeMyNeighbor:OnDotMessageWillYouBeMyNeighborPPChannelMessage(channel, tMsg) self.unitPlayerDisposition = GameLib.GetPlayerUnit() if self.unitPlayerDisposition == nil or not self.unitPlayerDisposition:IsValid() or RegisteredUsers == nil then DEBUG("self.tQueuedUnits[2]") self.tQueuedUnits = {} return end local name = GameLib.GetPlayerUnit():GetName() if PlantPiratesAlert == true and tMsg.name == name then ChatSystemLib.PostOnChannel(2, tMsg.message) end end function WillYouBeMyNeighbor:OnDotMessageWillYouBeMyNeighborHarvestNotificationChannelMessage(channel, tMsg) self.unitPlayerDisposition = GameLib.GetPlayerUnit() if self.unitPlayerDisposition == nil or not self.unitPlayerDisposition:IsValid() or RegisteredUsers == nil then DEBUG("self.tQueuedUnits[3]") self.tQueuedUnits = {} return end local name = GameLib.GetPlayerUnit():GetName() if HarvestNotifications == true and tMsg.name == name then ChatSystemLib.PostOnChannel(8, tMsg.message) end end function WillYouBeMyNeighbor:OnDotMessageWillYouBeMyNeighborOnlineChannelMessage(channel, tMsg) self.unitPlayerDisposition = GameLib.GetPlayerUnit() if self.unitPlayerDisposition == nil or not self.unitPlayerDisposition:IsValid() or OnlineUsers == nil then DEBUG("self.tQueuedUnits[4]") self.tQueuedUnits = {} return end OnlineUsers[tMsg.name] = self.ServerTime() end function WillYouBeMyNeighbor:VisitNeighbor(Name) if HousingLib.IsHousingWorld() == false then ChatSystemLib.PostOnChannel(2,"You can't visit people if you're not in the housing system!") return end local neighborList=self:GetSortedNeighbors() for i=1,#neighborList do if neighborList[i].strCharacterName == Name then HousingLib.VisitNeighborResidence(neighborList[i].nId) return end end ChatSystemLib.PostOnChannel(2,Name .. " is not a neighbor, sending neighbor invite!") HousingLib.NeighborInviteByName(Name) end local shares = { "100%", "75%", "50%", "25%", "0%" } local stars = { [0] = "0*", "1*", "2*", "3*", "4*", "5*" } function WillYouBeMyNeighbor:UpdateTargetPlot(name) if name then local nRank = PlotRatings[name] or 0 self.wndMain:FindChild("Window"):SetText(string.format("Target Plot [%s]", stars[nRank])) self.wndMain:FindChild("WillYouBeMyNeighborName"):SetText(name) local neighborList=self:GetSortedNeighbors() local neighborIndex = 0 for i=1, #neighborList do if neighborList[i].strCharacterName == name then neighborIndex = i break end end if IgnoredPlots.ignoreList[name] then self.wndMain:FindChild("WillYouBeMyNeighborName"):SetTextColor(kcrIgnored) else if neighborList[neighborIndex].fLastOnline == 0 then self.wndMain:FindChild("WillYouBeMyNeighborName"):SetTextColor(kcrOnline) else self.wndMain:FindChild("WillYouBeMyNeighborName"):SetTextColor(kcrOffline) end end if RegisteredUsers[name] ~= nil then local val = RegisteredUsers[name] if type(val) == "number" then self.wndMain:FindChild("WillYouBeMyNeighborShare"):SetText(string.format("%s to Owner", shares[val + 1])) self.wndMain:FindChild("WillYouBeMyNeighborNodeInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborHarvestInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborRemaining"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborActivity"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborLastVisit"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborVersionFlag"):Show(false) return end if type(val) == "table" then if type(val.share) == "table" then return end self.wndMain:FindChild("WillYouBeMyNeighborShare"):SetText(string.format("%s to Owner", shares[val.share + 1])) if val.nodetype == nil then self.wndMain:FindChild("WillYouBeMyNeighborNodeInfo"):SetText("Unknown") elseif val.nodelevel ~= nil then self.wndMain:FindChild("WillYouBeMyNeighborNodeInfo"):SetText(val.nodetype .. " " .. val.nodelevel) else self.wndMain:FindChild("WillYouBeMyNeighborNodeInfo"):SetText(val.nodetype) end local harvest if val.miner == true then harvest = "Miner" end if val.survivalist == true then if harvest == "Miner" then harvest = "Miner/Survivalist" else harvest = "Survivalist" end end if val.relichunter == true then if harvest == "Miner" or harvest == "Survivalist" then harvest = harvest .. "/Relic Hunter" else harvest = "Relic Hunter" end end self.wndMain:FindChild("WillYouBeMyNeighborHarvestInfo"):SetText(harvest) if neighborList[neighborIndex] == nil or neighborList[neighborIndex].fLastOnline == nil then self.wndMain:FindChild("WillYouBeMyNeighborCurrentRemaining"):SetText("Unknown") else self.wndMain:FindChild("WillYouBeMyNeighborRemaining"):SetText(self:HelperConvertToTime(neighborList[neighborIndex].fLastOnline)) end if val.activity ~= nil then if val.month ~= nil and val.month == GameLib:GetServerTime().nMonth then self.wndMain:FindChild("WillYouBeMyNeighborActivity"):SetText(val.activity .. " units") else self.wndMain:FindChild("WillYouBeMyNeighborActivity"):SetText("0 units") end else self.wndMain:FindChild("WillYouBeMyNeighborActivity"):SetText("Unknown") end if lastVisit[name] then local td = os.time() - lastVisit[name] local ns = td%60; td = td - ns td = td / 60 local nm = td%60; td = td - nm td = td / 60 self.wndMain:FindChild("WillYouBeMyNeighborLastVisit"):SetText(string.format("%02d:%02d:%02d",td,nm,ns)) else self.wndMain:FindChild("WillYouBeMyNeighborLastVisit"):SetText("Unknown") end if val.version == nil or val.version < version then self.wndMain:FindChild("WillYouBeMyNeighborVersionFlag"):Show(false) else self.wndMain:FindChild("WillYouBeMyNeighborVersionFlag"):Show(true) end return end end else local nl = self:GetSortedNeighbors() if #nl > 0 then self:UpdateTargetPlot(nl[1].strCharacterName) return end end self.wndMain:FindChild("Window"):SetText("Target Plot") self.wndMain:FindChild("WillYouBeMyNeighborShare"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborNodeInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborHarvestInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborRemaining"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborActivity"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborLastVisit"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborVersionFlag"):Show(false) end -- on SlashCommand "/rogers" function WillYouBeMyNeighbor:OnWillYouBeMyNeighborOn(cmd, args) local neighborList=self:GetNextNeighbor() if self.currentNeighbor > #neighborList then self.currentNeighbor = 1 end if args == "visit" then self:OnVisit() return elseif args == "mail" then wybmnOptions.takeMail = not wybmnOptions.takeMail Print("Setting autotake of mail attachments: "..tostring(wybmnOptions.takeMail)) return elseif args == "autozone" then wybmnOptions.autoZone = not wybmnOptions.autoZone Print("Setting autozone on empty plot: "..tostring(wybmnOptions.autoZone)) return elseif args == "debug" then for x=1, 25 do if DEBUGDATA[x] then Print(string.format("%02d: %s : %s", x, tostring(DEBUGDATA[x].st), tostring(DEBUGDATA[x].msg))) end end return end self.wndMain:Invoke() -- show the window if #neighborList == 0 then self.wndMain:FindChild("WillYouBeMyNeighborName"):SetText("No Neighbors") self.wndMain:FindChild("WillYouBeMyNeighborName"):SetTextColor(kcrOffline) self.wndMain:FindChild("WillYouBeMyNeighborShare"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborNodeInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborHarvestInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborRemaining"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborActivity"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborLastVisit"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborVersionFlag"):Show(false) else self.currentNeighborName = neighborList[self.currentNeighbor].strCharacterName self:UpdateTargetPlot(neighborList[self.currentNeighbor].strCharacterName) end self.wndMain:FindChild("ToggleMineral"):SetOpacity(opacity[ResourceTypes.filter.mineral]) self.wndMain:FindChild("ToggleRelic"):SetOpacity(opacity[ResourceTypes.filter.relic]) self.wndMain:FindChild("ToggleThicket"):SetOpacity(opacity[ResourceTypes.filter.thicket]) if IgnoredPlots.ignore then self.wndMain:FindChild("ToggleIgnore"):ChangeArt("CRB_QuestTrackerSprites:btnQT_QuestRedeem") else self.wndMain:FindChild("ToggleIgnore"):ChangeArt("CRB_QuestTrackerSprites:btnQT_QuestFailed") end self.wndMain:FindChild("AutoDisplay"):SetCheck(AutoDisplay) self.wndMain:FindChild("AutoAccept"):SetCheck(AutoAccept) if NodeFilter == "Mineral Deposit" then self.wndMain:FindChild("RadioMineral"):SetCheck(true) end if NodeFilter == "Thicket" then self.wndMain:FindChild("RadioThicket"):SetCheck(true) end if NodeFilter == "Relic Excavation" then self.wndMain:FindChild("RadioRelic"):SetCheck(true) end if NodeLevelFilter == 1 then self.wndMain:FindChild("RadioLevel1"):SetCheck(true) end if NodeLevelFilter == 2 then self.wndMain:FindChild("RadioLevel2"):SetCheck(true) end if NodeLevelFilter == 3 then self.wndMain:FindChild("RadioLevel3"):SetCheck(true) end if NodeLevelFilter == 4 then self.wndMain:FindChild("RadioLevel4"):SetCheck(true) end if ShareFilter == 0 then self.wndMain:FindChild("RadioShare100"):SetCheck(true) end if ShareFilter == 1 then self.wndMain:FindChild("RadioShare75"):SetCheck(true) end if ShareFilter == 2 then self.wndMain:FindChild("RadioShare50"):SetCheck(true) end if ShareFilter == 3 then self.wndMain:FindChild("RadioShare25"):SetCheck(true) end if ShareFilter == 4 then self.wndMain:FindChild("RadioShare0"):SetCheck(true) end self.wndMain:FindChild("ComboCircleList"):SetText(GuildFilter); self.wndMain:FindChild("AutoAcceptGridFilter"):SetCheck(DeclineByFilter) self.wndMain:FindChild("PlantPiratesAlert"):SetCheck(PlantPiratesAlert) self.wndMain:FindChild("HarvestNotifications"):SetCheck(HarvestNotifications) self.wndMain:FindChild("AcceptAllSocials"):SetCheck(AcceptAllSocials) end function WillYouBeMyNeighbor:PopulateCircles() self.wndMain:FindChild("ComboCircleList") local guilds = GuildLib.GetGuilds() self.wndMain:FindChild("ComboCircleList"):AddItem("", "", "") for i, guild in pairs(guilds) do self.wndMain:FindChild("ComboCircleList"):AddItem(guild:GetName(), "", guild:GetName()) end end function WillYouBeMyNeighbor:OnGuildRoster(uGuild, tRoster) self.rosters[uGuild:GetName()] = tRoster end function WillYouBeMyNeighbor:GetPlotNodeCounts() local tCounts = { thicket=0, mineral=0, relic=0, cnt=0 } for k,v in pairs(self.tQueuedUnits) do local sName = v:GetName() local tUT = unitTypes[sName] if tUT then DEBUG(">"..sName) tCounts[tUT.k] = tCounts[tUT.k]+1 tCounts.cnt = tCounts.cnt+1 autoVisit = false end end DEBUG("self.tQueuedUnits[5]:GetPlotNodeCounts") self.tQueuedUnits = {} return tCounts end function WillYouBeMyNeighbor:OnZoneCompletionUpdated() DEBUG("WillYouBeMyNeighbor:OnZoneCompletionUpdated()") DEBUG("#tQueuedUnits = "..tostring(#self.tQueuedUnits)) if self.unitPlayerDisposition == nil or not self.unitPlayerDisposition:IsValid() or RegisteredUsers == nil then DEBUG("self.tQueuedUnits[6]") self.tQueuedUnits = {} return end self:BuildSocialWorld() local idxCount = 0 local tCounts = self:GetPlotNodeCounts() if HousingLib:IsHousingWorld() == true then local sZN = self:GetCurrentZoneName() if tCounts.cnt > 0 then if ResourceTypes.filter.mineral then self.wndMain:FindChild("ToggleMineral"):SetText("") else self.wndMain:FindChild("ToggleMineral"):SetText(tostring(tCounts.mineral)) idxCount = idxCount + tCounts.mineral end if ResourceTypes.filter.relic then self.wndMain:FindChild("ToggleRelic"):SetText("") else self.wndMain:FindChild("ToggleRelic"):SetText(tostring(tCounts.relic)) idxCount = idxCount + tCounts.relic end if ResourceTypes.filter.thicket then self.wndMain:FindChild("ToggleThicket"):SetText("") else self.wndMain:FindChild("ToggleThicket"):SetText(tostring(tCounts.thicket)) idxCount = idxCount + tCounts.thicket end else self.wndMain:FindChild("ToggleMineral"):SetText("") self.wndMain:FindChild("ToggleRelic"):SetText("") self.wndMain:FindChild("ToggleThicket"):SetText("") end local neighborList=self:GetSortedNeighbors() if AutoDisplay == true then self.wndMain:Invoke() -- show the window if self.currentNeighbor > #neighborList then self.currentNeighbor = 1 end if #neighborList == 0 then self.wndMain:FindChild("WillYouBeMyNeighborName"):SetText("No Neighbors") self.wndMain:FindChild("WillYouBeMyNeighborName"):SetTextColor(kcrOffline) self.wndMain:FindChild("WillYouBeMyNeighborShare"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborNodeInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborHarvestInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborRemaining"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborActivity"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborVersionFlag"):Show(false) else self.currentNeighborName = neighborList[self.currentNeighbor].strCharacterName self:UpdateTargetPlot(neighborList[self.currentNeighbor].strCharacterName) end self.wndMain:FindChild("ToggleMineral"):SetOpacity(opacity[ResourceTypes.filter.mineral]) self.wndMain:FindChild("ToggleRelic"):SetOpacity(opacity[ResourceTypes.filter.relic]) self.wndMain:FindChild("ToggleThicket"):SetOpacity(opacity[ResourceTypes.filter.thicket]) if IgnoredPlots.ignore then self.wndMain:FindChild("ToggleIgnore"):ChangeArt("CRB_QuestTrackerSprites:btnQT_QuestRedeem") else self.wndMain:FindChild("ToggleIgnore"):ChangeArt("CRB_QuestTrackerSprites:btnQT_QuestFailed") end self.wndMain:FindChild("AutoDisplay"):SetCheck(AutoDisplay) self.wndMain:FindChild("AutoAccept"):SetCheck(AutoAccept) if NodeFilter == "Mineral Deposit" then self.wndMain:FindChild("RadioMineral"):SetCheck(true) end if NodeFilter == "Thicket" then self.wndMain:FindChild("RadioThicket"):SetCheck(true) end if NodeFilter == "Relic Excavation" then self.wndMain:FindChild("RadioRelic"):SetCheck(true) end if NodeLevelFilter == 1 then self.wndMain:FindChild("RadioLevel1"):SetCheck(true) end if NodeLevelFilter == 2 then self.wndMain:FindChild("RadioLevel2"):SetCheck(true) end if NodeLevelFilter == 3 then self.wndMain:FindChild("RadioLevel3"):SetCheck(true) end if NodeLevelFilter == 4 then self.wndMain:FindChild("RadioLevel4"):SetCheck(true) end if ShareFilter == 0 then self.wndMain:FindChild("RadioShare100"):SetCheck(true) end if ShareFilter == 1 then self.wndMain:FindChild("RadioShare75"):SetCheck(true) end if ShareFilter == 2 then self.wndMain:FindChild("RadioShare50"):SetCheck(true) end if ShareFilter == 3 then self.wndMain:FindChild("RadioShare25"):SetCheck(true) end if ShareFilter == 4 then self.wndMain:FindChild("RadioShare0"):SetCheck(true) end self.wndMain:FindChild("ComboCircleList"):SetText(GuildFilter); self.wndMain:FindChild("AutoAcceptGridFilter"):SetCheck(DeclineByFilter) self.wndMain:FindChild("PlantPiratesAlert"):SetCheck(PlantPiratesAlert) self.wndMain:FindChild("HarvestNotifications"):SetCheck(HarvestNotifications) self.wndMain:FindChild("AcceptAllSocials"):SetCheck(AcceptAllSocials) end local sAZ = tostring(wybmnOptions.autoZone) local sAV = tostring(autoVisit) local sMR = tostring(HousingLib:IsOnMyResidence() or false) if wybmnOptions.autoZone and autoVisit and HousingLib:IsOnMyResidence() ~= true then if idxCount == 0 then if autoCount < #neighborList then --if autoCount < 20 then autoCount = autoCount+1 DEBUG("Plot: "..self:GetCurrentZoneName().." has no nodes. Skipping in 0.5s.") Apollo.StartTimer("skiptimer") skipNeeded = true else autoCount = 0 autoVisit = false end else autoCount = 0 autoVisit = false end else autoCount = 0 autoVisit = false end else DEBUG("OZCU exit(2)") autoCount = 0 autoVisit = false if AutoDisplay == true then self.wndMain:Close() end end end function WillYouBeMyNeighbor:AutoSkipCheck() if skipNeeded then DEBUG("SKIP NEEDED: "..tostring(skipNeeded)..", #tQueuedUnits = "..tostring(#self.tQueuedUnits)) skipNeeded = false Apollo.StopTimer("skiptimer") if #self.tQueuedUnits > 0 then local tCounts = self:GetPlotNodeCounts() if ((ResourceTypes.filter.mineral == false and tCounts.mineral > 0) or (ResourceTypes.filter.relic == false and tCounts.relic > 0) or (ResourceTypes.filter.thicket == false and tCounts.thicket > 0)) then DEBUG("Aborting transfer!") return end end Print("Moving to next plot!") self:OnVisit() end end local currentBroadcast = "" function WillYouBeMyNeighbor:UpdateCurrent() self.unitPlayerDisposition = GameLib.GetPlayerUnit() if self.unitPlayerDisposition == nil or not self.unitPlayerDisposition:IsValid() or RegisteredUsers == nil or GetCurrentZoneName() == nil then DEBUG("self.tQueuedUnits[7]") self.tQueuedUnits = {} return end if HousingLib:IsHousingWorld() == true and HousingLib:IsWarplotResidence() == false then local name = n name = self:GetCurrentZoneName() local neighborList = self:GetSortedNeighbors() if name then self.wndMain:FindChild("WillYouBeMyNeighborCurrentName"):SetText(name) if name ~= currentZone then if HousingLib:IsOnMyResidence() then self.wndMain:FindChild("Window1"):SetText("Current Plot") else self.wndMain:FindChild("Window1"):SetText(string.format("[%s/%d] Current Plot",tostring(nameIndex[name] or "??"),#neighborList)) end currentZone = name if lastVisit then lastVisit[name] = os.time() end end if IgnoredPlots.ignoreList[name] then self.wndMain:FindChild("WillYouBeMyNeighborCurrentName"):SetTextColor(kcrIgnored) else if ( (self.CURRENTPLOTID>0 and neighborList[self.CURRENTPLOTID].fLastOnline and neighborList[self.CURRENTPLOTID].fLastOnline > 0) or (self.IGNOREDPLOTS[name] and self.IGNOREDPLOTS[name].fLastOnline and self.IGNOREDPLOTS[name].fLastOnline > 0) ) then self.wndMain:FindChild("WillYouBeMyNeighborCurrentName"):SetTextColor(kcrOffline) else self.wndMain:FindChild("WillYouBeMyNeighborCurrentName"):SetTextColor(kcrOnline) end end end if PlotRatings[name] then self:SetStarRating(PlotRatings[name]) else self:SetStarRating(0) end if name and RegisteredUsers[name] ~= nil then local val = RegisteredUsers[name] if type(val) == "number" then self.wndMain:FindChild("WillYouBeMyNeighborCurrentShare"):SetText(string.format("%s to Owner", shares[val + 1])) self.wndMain:FindChild("WillYouBeMyNeighborCurrentNodeInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborCurrentHarvestInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborCurrentRemaining"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborCurrentActivity"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborCurrentVersionFlag"):Show(false) return end if type(val) == "table" then if type(val.share) == "table" then return end self.wndMain:FindChild("WillYouBeMyNeighborCurrentShare"):SetText(string.format("%s to Owner", shares[val.share + 1])) if val.nodetype == nil then self.wndMain:FindChild("WillYouBeMyNeighborCurrentNodeInfo"):SetText("Unknown") elseif val.nodelevel ~= nil then self.wndMain:FindChild("WillYouBeMyNeighborCurrentNodeInfo"):SetText(val.nodetype .. " " .. val.nodelevel) else self.wndMain:FindChild("WillYouBeMyNeighborCurrentNodeInfo"):SetText(val.nodetype) end local harvest = "" if val.miner == true then harvest = "Miner" end if val.survivalist == true then if harvest == "Miner" then harvest = "Miner/Survivalist" else harvest = "Survivalist" end end if val.relichunter == true then if harvest == "Miner" or harvest == "Survivalist" then harvest = harvest .. "/Relic Hunter" else harvest = "Relic Hunter" end end self.wndMain:FindChild("WillYouBeMyNeighborCurrentHarvestInfo"):SetText(harvest) if GameLib:GetPlayerUnit():GetName() == name then self.wndMain:FindChild("WillYouBeMyNeighborCurrentRemaining"):SetText("Online") else if self.CURRENTPLOTID > 0 then if neighborList[self.CURRENTPLOTID] == nil or neighborList[self.CURRENTPLOTID].fLastOnline == nil then self.wndMain:FindChild("WillYouBeMyNeighborCurrentRemaining"):SetText("Unknown") else self.wndMain:FindChild("WillYouBeMyNeighborCurrentRemaining"):SetText(self:HelperConvertToTime(neighborList[self.CURRENTPLOTID].fLastOnline)) end else if self.IGNOREDPLOTS[name] then self.wndMain:FindChild("WillYouBeMyNeighborCurrentRemaining"):SetText(self:HelperConvertToTime(self.IGNOREDPLOTS[name].fLastOnline)) else self.wndMain:FindChild("WillYouBeMyNeighborCurrentRemaining"):SetText("Unknown*1") end end end if val.activity ~= nil then if val.month ~= nil and val.month == GameLib:GetServerTime().nMonth then self.wndMain:FindChild("WillYouBeMyNeighborCurrentActivity"):SetText(val.activity .. " units") else self.wndMain:FindChild("WillYouBeMyNeighborCurrentActivity"):SetText("0 units") end else self.wndMain:FindChild("WillYouBeMyNeighborCurrentActivity"):SetText("Unknown") end if val.version == nil or val.version < version then self.wndMain:FindChild("WillYouBeMyNeighborCurrentVersionFlag"):Show(false) else self.wndMain:FindChild("WillYouBeMyNeighborCurrentVersionFlag"):Show(true) end return end end self.wndMain:FindChild("WillYouBeMyNeighborCurrentShare"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborCurrentNodeInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborCurrentHarvestInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborCurrentRemaining"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborCurrentActivity"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborCurrentVersionFlag"):Show(false) else self.wndMain:FindChild("WillYouBeMyNeighborCurrentName"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborCurrentShare"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborCurrentNodeInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborCurrentHarvestInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborCurrentRemaining"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborCurrentActivity"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborCurrentVersionFlag"):Show(false) end end function WillYouBeMyNeighbor:UpdateMyself() self.unitPlayerDisposition = GameLib.GetPlayerUnit() if self.unitPlayerDisposition == nil or not self.unitPlayerDisposition:IsValid() or RegisteredUsers == nil then DEBUG("self.tQueuedUnits[8]") self.tQueuedUnits = {} return end if HousingLib:IsHousingWorld() == true and HousingLib:IsOnMyResidence() == true then local neighborList=self:GetSortedNeighbors() if #neighborList < 100 then local online = {} online.name = GameLib.GetPlayerUnit():GetName() self.chanICCOL:SendMessage(online) end self.faction = GameLib.GetPlayerUnit():GetFaction() local aNeighborList = Apollo.GetAddon("NeighborList") Apollo.RemoveEventHandler("HousingNeighborInviteRecieved", aNeighborList) local t = {} name = GameLib.GetPlayerUnit():GetName() if RegisteredUsers[name] == nil then RegisteredUsers[name] = {} end RegisteredUsers[name].name = name RegisteredUsers[name].share = HousingLib:GetNeighborHarvestSplit() RegisteredUsers[name].nodetype = "No Node" RegisteredUsers[name].remaining = 0 for i=1, 6 do local cPlot = HousingLib.GetPlot(i) for _, tNode in ipairs(Plugs) do if tNode == cPlot.strName then RegisteredUsers[name].nodetype = cPlot.strName RegisteredUsers[name].remaining = cPlot.fRemainingHours end end end RegisteredUsers[name].relichunter = false RegisteredUsers[name].survivalist = false RegisteredUsers[name].miner = false local tKnownSkills = CraftingLib.GetKnownTradeskills() if tKnownSkills then for nIndex, tSkill in ipairs(tKnownSkills) do local tInfo = CraftingLib.GetTradeskillInfo(tSkill.eId) if tInfo and tInfo.bIsActive then if tSkill.strName == "Relic Hunter" then RegisteredUsers[name].relichunter = true elseif tSkill.strName == "Survivalist" then RegisteredUsers[name].survivalist = true elseif tSkill.strName == "Mining" then RegisteredUsers[name].miner = true end end end end RegisteredUsers[name].timestamp = self.ServerTime() RegisteredUsers[name].faction = GameLib.GetPlayerUnit():GetFaction() RegisteredUsers[name].version = version RegisteredUsers[name].nodelevel = nil if RegisteredUsers[name].day ~= GameLib:GetServerTime().nDay then RegisteredUsers[name].day = GameLib:GetServerTime().nDay end self.chanICC:SendMessage(RegisteredUsers[name]) end if currentBroadcast == "" then currentBroadcast = next(RegisteredUsers) if RegisteredUsers[currentBroadcast] == nil then return end local val = RegisteredUsers[currentBroadcast] local t = {} if type(val) == "number" then t.name = currentBroadcast t.share = RegisteredUsers[currentBroadcast] self.chanICC:SendMessage(t) return end if type(val) == "table" then local subtable = RegisteredUsers[currentBroadcast].share if type(subtable) == "table" then return end if RegisteredUsers[currentBroadcast].name == nil then RegisteredUsers[currentBroadcast].name = currentBroadcast end self.chanICC:SendMessage(RegisteredUsers[currentBroadcast]) return end else if RegisteredUsers[currentBroadcast] == nil then return end currentBroadcast = next(RegisteredUsers, currentBroadcast) if currentBroadcast == nil then currentBroadcast = next(RegisteredUsers) end local val = RegisteredUsers[currentBroadcast] local t = {} if type(val) == "number" then t.name = currentBroadcast t.share = RegisteredUsers[currentBroadcast] self.chanICC:SendMessage(t) return end if type(val) == "table" then local subtable = RegisteredUsers[currentBroadcast].share if type(subtable) == "table" then return end if RegisteredUsers[currentBroadcast].name == nil then RegisteredUsers[currentBroadcast].name = currentBroadcast end self.chanICC:SendMessage(RegisteredUsers[currentBroadcast]) return end end end function WillYouBeMyNeighbor:OnUnitCreated(unit) if HousingLib:IsHousingWorld() == true and HousingLib:IsWarplotResidence() == false then if unit == nil or not unit:IsValid() or unit == GameLib.GetPlayerUnit() then return end table.insert(self.tQueuedUnits, unit) end end function WillYouBeMyNeighbor:OnNeighborInviteRecieved(strName) local aNeighborList = Apollo.GetAddon("NeighborList") if AutoAccept == true then if DeclineByFilter == false then aNeighborList.strInviterName = strName HousingLib.NeighborInviteAccept() ChatSystemLib.PostOnChannel(2,"Invite from " .. strName .. " accepted by WillYouBeMyNeighbor") elseif RegisteredUsers[strName] ~= nil then local key = strName local val = RegisteredUsers[key] if AcceptAllSocials == true and self.rosters ~= nil and self.rosters[GuildFilter] then for _, groupMember in pairs(self.rosters[GuildFilter]) do if groupMember.strName == key then HousingLib.NeighborInviteAccept() ChatSystemLib.PostOnChannel(2,"Invite from " .. strName .. " accepted by WillYouBeMyNeighbor") return end end end if GuildFilter ~= nil and GuildFilter ~= "" and self.rosters[GuildFilter] ~= nil then for _, groupMember in pairs(self.rosters[GuildFilter]) do if groupMember.strName == key then if type(val) == "table" and type(val.share) ~= "table" and key ~= GameLib:GetPlayerUnit():GetName() and val.share >= ShareFilter then if val.remaining ~= nil and val.faction == self.faction and string.find(val.nodetype, NodeFilter) then local nodelevel = 0 if string.find(val.nodetype, "Elite") or string.find(val.nodetype, "4") then nodelevel = 4 elseif string.find(val.nodetype, "3") then nodelevel = 3 elseif string.find(val.nodetype, "2") then nodelevel = 2 elseif string.find(val.nodetype, "1") then nodelevel = 1 end if nodelevel >= NodeLevelFilter then HousingLib.NeighborInviteAccept() ChatSystemLib.PostOnChannel(2,"Invite from " .. strName .. " accepted by WillYouBeMyNeighbor") return end elseif val.nodetype ~= nil and val.nodelevel ~= nil and val.nodelevel >= NodeLevelFilter and val.nodetype == NodeFilter then HousingLib.NeighborInviteAccept() ChatSystemLib.PostOnChannel(2,"Invite from " .. strName .. " accepted by WillYouBeMyNeighbor") return end end end end else if type(val) == "table" and type(val.share) ~= "table" and key ~= GameLib:GetPlayerUnit():GetName() and val.share >= ShareFilter then if val.remaining ~= nil and val.faction == self.faction and string.find(val.nodetype, NodeFilter) then local nodelevel = 0 if string.find(val.nodetype, "Elite") or string.find(val.nodetype, "4") then nodelevel = 4 elseif string.find(val.nodetype, "3") then nodelevel = 3 elseif string.find(val.nodetype, "2") then nodelevel = 2 elseif string.find(val.nodetype, "1") then nodelevel = 1 end if nodelevel >= NodeLevelFilter then HousingLib.NeighborInviteAccept() ChatSystemLib.PostOnChannel(2,"Invite from " .. strName .. " accepted by WillYouBeMyNeighbor") return else Print(string.format("Declining %d / %d", nodelevel, NodeLevelFilter)) end elseif val.nodetype ~= nil and val.nodelevel ~= nil and val.nodelevel >= NodeLevelFilter and val.nodetype == NodeFilter then HousingLib.NeighborInviteAccept() ChatSystemLib.PostOnChannel(2,"Invite from " .. strName .. " accepted by WillYouBeMyNeighbor") return end end end HousingLib.NeighborInviteDecline() ChatSystemLib.PostOnChannel(2,"Invite from " .. strName .. " declined by WillYouBeMyNeighbor based on filters") return else if AcceptAllSocials == true then for _, groupMember in pairs(self.rosters[GuildFilter]) do if groupMember.strName == key then HousingLib.NeighborInviteAccept() ChatSystemLib.PostOnChannel(2,"Invite from " .. strName .. " accepted by WillYouBeMyNeighbor") return end end end HousingLib.NeighborInviteDecline() ChatSystemLib.PostOnChannel(2,"Invite from " .. strName .. " declined by WillYouBeMyNeighbor based on filters") end else aNeighborList:OnNeighborInviteRecieved(strName) end end function WillYouBeMyNeighbor:BuildSocialWorld() local myUnit = GameLib.GetPlayerUnit() if (myUnit) then end for _, tCurrGuild in pairs(GuildLib.GetGuilds()) do tCurrGuild:RequestMembers() end end function WillYouBeMyNeighbor:OnWindowManagementReady() Event_FireGenericEvent("WindowManagementAdd", {wnd = self.wndMain, strName = "WillYouBeMyNeighbor"}) end function WillYouBeMyNeighbor:IsNeighbor(name, neighborList) for i=1,#neighborList do if neighborList[i].strCharacterName == name then return true end end return false end function WillYouBeMyNeighbor:HelperConvertToTime(nDays) if nDays == 0 then return Apollo.GetString("Neighbors_Online") end if nDays == nil then return "" end local tTimeInfo = {["name"] = "", ["count"] = nil} if nDays >= 365 then -- Years tTimeInfo["name"] = Apollo.GetString("CRB_Year") tTimeInfo["count"] = math.floor(nDays / 365) elseif nDays >= 30 then -- Months tTimeInfo["name"] = Apollo.GetString("CRB_Month") tTimeInfo["count"] = math.floor(nDays / 30) elseif nDays >= 7 then tTimeInfo["name"] = Apollo.GetString("CRB_Week") tTimeInfo["count"] = math.floor(nDays / 7) elseif nDays >= 1 then -- Days tTimeInfo["name"] = Apollo.GetString("CRB_Day") tTimeInfo["count"] = math.floor(nDays) else local fHours = nDays * 24 local nHoursRounded = math.floor(fHours) local nMin = math.floor(fHours*60) if nHoursRounded > 0 then tTimeInfo["name"] = Apollo.GetString("CRB_Hour") tTimeInfo["count"] = nHoursRounded elseif nMin > 0 then tTimeInfo["name"] = Apollo.GetString("CRB_Min") tTimeInfo["count"] = nMin else tTimeInfo["name"] = Apollo.GetString("CRB_Min") tTimeInfo["count"] = 1 end end return String_GetWeaselString(Apollo.GetString("CRB_TimeOffline"), tTimeInfo) end ---------------------------------------------- -- WillYouBeMyNeighbor Form Functions ----------------------------------------------------------------------------------------------- -- when the OK button is clicked function WillYouBeMyNeighbor:OnVisit() autoVisit = true local neighborList=self:GetSortedNeighbors() for i=1, #neighborList do if neighborList[i].strCharacterName == self.currentNeighborName then self.currentNeighbor = i break end end if #neighborList > 0 then if self.currentNeighbor > #neighborList then self.currentNeighbor = 1 self.currentNeighborName = neighborList[self.currentNeighbor].strCharacterName self:UpdateTargetPlot(neighborList[self.currentNeighbor].strCharacterName, self) else HousingLib.VisitNeighborResidence(neighborList[self.currentNeighbor].nId) self.currentNeighbor = self.currentNeighbor + 1 if self.currentNeighbor > #neighborList then self.currentNeighbor = 1 end self.currentNeighborName = neighborList[self.currentNeighbor].strCharacterName self:UpdateTargetPlot(neighborList[self.currentNeighbor].strCharacterName, self) end end end -- when the Cancel button is clicked function WillYouBeMyNeighbor:OnSkip() local neighborList=self:GetSortedNeighbors() self.currentNeighbor = self.currentNeighbor + 1 local sZN = self:GetCurrentZoneName() local nZN = nameIndex[sZN] or 0 if nZN == self.currentNeighbor then self:OnSkip() else if self.currentNeighbor > #neighborList then self.currentNeighbor = 1 end if #neighborList > 0 then self.currentNeighborName = neighborList[self.currentNeighbor].strCharacterName self:UpdateTargetPlot(neighborList[self.currentNeighbor].strCharacterName, self) else self.wndMain:FindChild("WillYouBeMyNeighborShare"):SetText("No matching neighbors") self.wndMain:FindChild("WillYouBeMyNeighborNodeInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborHarvestInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborRemaining"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborActivity"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborLastVisit"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborVersionFlag"):Show(false) end end end function WillYouBeMyNeighbor:ServerTime() local timetable = GameLib:GetServerTime() timetable.year = timetable.nYear timetable.month = timetable.nMonth timetable.day = timetable.nDay timetable.hour = timetable.nHour timetable.min = timetable.nMinute timetable.sec = timetable.nSecond timetable.isdst = false return os.time(timetable) end function WillYouBeMyNeighbor:SetLocaleData() -- Figure out the locale local strCancel = Apollo.GetString(1) if strCancel == "Abbrechen" then -- German Plugs = self.tLocale.de.Plugs else Plugs = self.tLocale.en.Plugs end end function WillYouBeMyNeighbor:Name_MouseButtonUp() local name = self.wndMain:FindChild("WillYouBeMyNeighborName"):GetText() if IgnoredPlots.ignoreList[name] then IgnoredPlots.ignoreList[name] = false else IgnoredPlots.ignoreList[name] = true end self:UpdateTargetPlot(name) end function WillYouBeMyNeighbor:OnToggleMineral() if ResourceTypes.filter.mineral then ResourceTypes.filter.mineral = false else ResourceTypes.filter.mineral = true end currentZone = "" self:UpdateTargetPlot() self:UpdateCurrent() self.wndMain:FindChild("ToggleMineral"):SetOpacity(opacity[ResourceTypes.filter.mineral]) end function WillYouBeMyNeighbor:OnToggleRelic() if ResourceTypes.filter.relic then ResourceTypes.filter.relic = false else ResourceTypes.filter.relic = true end currentZone = "" self:UpdateTargetPlot() self:UpdateCurrent() self.wndMain:FindChild("ToggleRelic"):SetOpacity(opacity[ResourceTypes.filter.relic]) end function WillYouBeMyNeighbor:OnToggleThicket() if ResourceTypes.filter.thicket then ResourceTypes.filter.thicket = false else ResourceTypes.filter.thicket = true end currentZone = "" self:UpdateTargetPlot() self:UpdateCurrent() self.wndMain:FindChild("ToggleThicket"):SetOpacity(opacity[ResourceTypes.filter.thicket]) end function WillYouBeMyNeighbor:OnToggleIgnore() if IgnoredPlots.ignore then IgnoredPlots.ignore = false self.wndMain:FindChild("ToggleIgnore"):ChangeArt("CRB_QuestTrackerSprites:btnQT_QuestFailed") else IgnoredPlots.ignore = true self.wndMain:FindChild("ToggleIgnore"):ChangeArt("CRB_QuestTrackerSprites:btnQT_QuestRedeem") end local name = self.wndMain:FindChild("WillYouBeMyNeighborName"):GetText() self:UpdateTargetPlot(name) end --------------------------------------------------------------------------------------------------- -- WillYouBeMyNeighborForm Functions --------------------------------------------------------------------------------------------------- function WillYouBeMyNeighbor:OnClose( wndHandler, wndControl, eMouseButton ) self.wndMain:Close() end function WillYouBeMyNeighbor:OnSlide( wndHandler, wndControl, eMouseButton ) local x1,y1,x2,y2 = self.wndMain:GetAnchorOffsets() if self.expanded == false then self.wndMain:SetAnchorOffsets(x1,y1,x1+750,y1+540) self.expanded = true self.wndMain:FindChild("SlideButton"):ChangeArt("BK3:btnHolo_ExpandCollapse_Inverted") self.wndMain:FindChild("Expanded"):Show(true) self.wndMain:FindChild("Data"):Show(true) self:BuildSocialWorld() self:GridRefresh() else self.wndMain:SetAnchorOffsets(x1,y1,x1+450,y1+170) self.expanded = false self.wndMain:FindChild("SlideButton"):ChangeArt("BK3:btnHolo_ExpandCollapse") self.wndMain:FindChild("Expanded"):Show(false) self.wndMain:FindChild("Data"):Show(false) end local OptInterface = Apollo.GetAddon("OptionsInterface") OptInterface:UpdateTrackedWindow(self.wndMain) end function WillYouBeMyNeighbor:OnAutoInvite( wndHandler, wndControl, eMouseButton ) local groupName = self.wndMain:FindChild("ComboCircleList"):GetText() if self.rosters == nil then self:BuildSocialWorld() ChatSystemLib.PostOnChannel(2,"Roster list was not ready, please try again in a few seconds") return end local neighborList=self:GetSortedNeighbors() for key, val in pairs(self.rosters[groupName]) do local neighbor = false for i=1, #neighborList do if neighborList[i].strCharacterName == val.strName then neighbor = true break end end if neighbor == false and val.fLastOnline == 0 and val.strName ~= GameLib.GetPlayerUnit():GetName() then HousingLib.NeighborInviteByName(val.strName) end end ChatSystemLib.PostOnChannel(2,"Neighbor invites sent to online members of " .. groupName) end function WillYouBeMyNeighbor:OnSetRatio( wndHandler, wndControl, eMouseButton ) if HousingLib:IsHousingWorld() == false or HousingLib:IsResidenceOwner() == false then ChatSystemLib.PostOnChannel(2,"You must be on your plot to set share ratio") return end local selectedRatio = self.wndMain:FindChild("ComboShareRatioList"):GetText() if selectedRatio == "100% to me" then HousingLib.SetNeighborHarvestSplit(0) end if selectedRatio == "75% to me" then HousingLib.SetNeighborHarvestSplit(1) end if selectedRatio == "50% to me" then HousingLib.SetNeighborHarvestSplit(2) end if selectedRatio == "25% to me" then HousingLib.SetNeighborHarvestSplit(3) end if selectedRatio == "0% to me" then HousingLib.SetNeighborHarvestSplit(4) end ChatSystemLib.PostOnChannel(2,"House share ratio set to " .. selectedRatio) end function WillYouBeMyNeighbor:AutoDisplayCheck( wndHandler, wndControl, eMouseButton ) AutoDisplay = self.wndMain:FindChild("AutoDisplay"):IsChecked() end function WillYouBeMyNeighbor:OnRemove( wndHandler, wndControl, eMouseButton ) local neighborList=self:GetSortedNeighbors() local name = self.wndMain:FindChild("WillYouBeMyNeighborName"):GetText() for i=1, #neighborList do if neighborList[i].strCharacterName == name then HousingLib.NeighborEvict(neighborList[i].nId) break end end self.currentNeighbor = self.currentNeighbor + 1 if self.currentNeighbor > #neighborList then self.currentNeighbor = 1 end self.currentNeighborName = neighborList[self.currentNeighbor].strCharacterName self:UpdateTargetPlot(neighborList[self.currentNeighbor].strCharacterName, self) end function WillYouBeMyNeighbor:AutoAcceptCheck( wndHandler, wndControl, eMouseButton ) AutoAccept = self.wndMain:FindChild("AutoAccept"):IsChecked() end function WillYouBeMyNeighbor:OnPrevious( wndHandler, wndControl, eMouseButton ) local neighborList=self:GetSortedNeighbors() self.currentNeighbor = self.currentNeighbor - 1 local sZN = self:GetCurrentZoneName() local nZN = nameIndex[sZN] or 0 if nZN == self.currentNeighbor then self:OnPrevious() else if self.currentNeighbor < 1 then self.currentNeighbor = #neighborList if nZN == self.currentNeighbor then self.currentNeighbor = self.currentNeighbor-1 if self.currentNeighbor < 1 then self.currentNeighbor = 1 end end end if #neighborList > 0 then self.currentNeighborName = neighborList[self.currentNeighbor].strCharacterName self:UpdateTargetPlot(neighborList[self.currentNeighbor].strCharacterName, self) else self.wndMain:FindChild("WillYouBeMyNeighborShare"):SetText("No matching neighbors") self.wndMain:FindChild("WillYouBeMyNeighborNodeInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborHarvestInfo"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborRemaining"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborActivity"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborLastVisit"):SetText("Unknown") self.wndMain:FindChild("WillYouBeMyNeighborVersionFlag"):Show(false) end end end function WillYouBeMyNeighbor:OnHome( wndHandler, wndControl, eMouseButton ) HousingLib.RequestTakeMeHome() end function WillYouBeMyNeighbor:Test( wndHandler, wndControl, eMouseButton ) end function WillYouBeMyNeighbor:OnRadioRelic( wndHandler, wndControl, eMouseButton ) NodeFilter = "Relic Excavation" self:GridRefresh() end function WillYouBeMyNeighbor:OnRadioThicket( wndHandler, wndControl, eMouseButton ) NodeFilter = "Thicket" self:GridRefresh() end function WillYouBeMyNeighbor:OnRadioMineral( wndHandler, wndControl, eMouseButton ) NodeFilter = "Mineral Deposit" self:GridRefresh() end function WillYouBeMyNeighbor:GridRefresh() local grid = self.wndMain:FindChild("Grid") grid:DeleteAll() -- Get the neighbors just once per refresh, rather than ONCE FOR EVERY REGISTERED USER. -- AKA: Other addons developers don't know how to program. local currNeighbors = self:GetSortedNeighbors() for key, val in pairs(RegisteredUsers) do if self:IsNeighbor(key, currNeighbors) == false then if GuildFilter ~= nil and GuildFilter ~= "" and self.rosters[GuildFilter] ~= nil and OnlineUsers[key] ~= nil and OnlineUsers[key] > (self.ServerTime() - 11) then for _, groupMember in pairs(self.rosters[GuildFilter]) do if groupMember.strName == key then if type(val) == "table" and type(val.share) ~= "table" and key ~= GameLib:GetPlayerUnit():GetName() and val.share >= ShareFilter then if val.remaining ~= nil and val.faction == self.faction and string.find(val.nodetype, NodeFilter) then local nodelevel = 0 if string.find(val.nodetype, "Elite") or string.find(val.nodetype, "4") then nodelevel = 4 elseif string.find(val.nodetype, "3") then nodelevel = 3 elseif string.find(val.nodetype, "2") then nodelevel = 2 elseif string.find(val.nodetype, "1") then nodelevel = 1 end if nodelevel >= NodeLevelFilter then local iNewRow = grid:AddRow("") grid:SetCellText(iNewRow, 1, key) grid:SetCellText(iNewRow, 2, string.format("%s to Owner", shares[val.share + 1])) grid:SetCellText(iNewRow, 3, "Level " .. nodelevel) end elseif val.nodetype ~= nil and val.nodelevel ~= nil and val.nodelevel >= NodeLevelFilter and val.nodetype == NodeFilter then local iNewRow = grid:AddRow("") grid:SetCellText(iNewRow, 1, key) grid:SetCellText(iNewRow, 2, string.format("%s to Owner", shares[val.share + 1])) grid:SetCellText(iNewRow, 3, "Level " .. val.nodelevel) end end end end else if type(val) == "table" and type(val.share) ~= "table" and key ~= GameLib:GetPlayerUnit():GetName() and val.share >= ShareFilter and OnlineUsers[key] ~= nil and OnlineUsers[key] > (self.ServerTime() - 11) then if val.remaining ~= nil and val.faction == self.faction and string.find(val.nodetype, NodeFilter) then local nodelevel = 0 if string.find(val.nodetype, "Elite") or string.find(val.nodetype, "4") then nodelevel = 4 elseif string.find(val.nodetype, "3") then nodelevel = 3 elseif string.find(val.nodetype, "2") then nodelevel = 2 elseif string.find(val.nodetype, "1") then nodelevel = 1 end if nodelevel >= NodeLevelFilter then local iNewRow = grid:AddRow("") grid:SetCellText(iNewRow, 1, key) grid:SetCellText(iNewRow, 2, string.format("%s to Owner", shares[val.share + 1])) grid:SetCellText(iNewRow, 3, "Level " .. nodelevel) end elseif val.nodetype ~= nil and val.nodelevel ~= nil and val.nodelevel >= NodeLevelFilter and val.nodetype == NodeFilter then local iNewRow = grid:AddRow("") grid:SetCellText(iNewRow, 1, key) grid:SetCellText(iNewRow, 2, string.format("%s to Owner", shares[val.share + 1])) grid:SetCellText(iNewRow, 3, "Level " .. val.nodelevel) end end end end end end function WillYouBeMyNeighbor:OnAddNeighbors( wndHandler, wndControl, eMouseButton ) -- Get the neighbors just once per add, rather than ONCE FOR EVERY REGISTERED USER. -- AKA: Other addons developers don't know how to program. local currNeighbors = self:GetSortedNeighbors() for key, val in pairs(RegisteredUsers) do if self:IsNeighbor(key, currNeighbors) == false then if GuildFilter ~= nil and GuildFilter ~= "" and self.rosters[GuildFilter] ~= nil and OnlineUsers[key] ~= nil and OnlineUsers[key] > (self.ServerTime() - 11) then for _, groupMember in pairs(self.rosters[GuildFilter]) do if groupMember.strName == key then if type(val) == "table" and type(val.share) ~= "table" and key ~= GameLib:GetPlayerUnit():GetName() and val.share >= ShareFilter then if val.remaining ~= nil and val.faction == self.faction and string.find(val.nodetype, NodeFilter) then local nodelevel = 0 if string.find(val.nodetype, "Elite") or string.find(val.nodetype, "4") then nodelevel = 4 elseif string.find(val.nodetype, "3") then nodelevel = 3 elseif string.find(val.nodetype, "2") then nodelevel = 2 elseif string.find(val.nodetype, "1") then nodelevel = 1 end if nodelevel >= NodeLevelFilter then HousingLib.NeighborInviteByName(key) end elseif val.nodetype ~= nil and val.nodelevel ~= nil and val.nodelevel >= NodeLevelFilter and val.nodetype == NodeFilter then HousingLib.NeighborInviteByName(key) end end end end else if type(val) == "table" and type(val.share) ~= "table" and key ~= GameLib:GetPlayerUnit():GetName() and val.share >= ShareFilter and OnlineUsers[key] ~= nil and OnlineUsers[key] > (self.ServerTime() - 11) then if val.remaining ~= nil and val.faction == self.faction and string.find(val.nodetype, NodeFilter) then local nodelevel = 0 if string.find(val.nodetype, "Elite") or string.find(val.nodetype, "4") then nodelevel = 4 elseif string.find(val.nodetype, "3") then nodelevel = 3 elseif string.find(val.nodetype, "2") then nodelevel = 2 elseif string.find(val.nodetype, "1") then nodelevel = 1 end if nodelevel >= NodeLevelFilter then HousingLib.NeighborInviteByName(key) end elseif val.nodetype ~= nil and val.nodelevel ~= nil and val.nodelevel >= NodeLevelFilter and val.nodetype == NodeFilter then HousingLib.NeighborInviteByName(key) end end end end end ChatSystemLib.PostOnChannel(2,"Neighbor invites sent") end function WillYouBeMyNeighbor:OnRadio100( wndHandler, wndControl, eMouseButton ) ShareFilter = 0 self:GridRefresh() end function WillYouBeMyNeighbor:OnRadio75( wndHandler, wndControl, eMouseButton ) ShareFilter = 1 self:GridRefresh() end function WillYouBeMyNeighbor:OnRadio50( wndHandler, wndControl, eMouseButton ) ShareFilter = 2 self:GridRefresh() end function WillYouBeMyNeighbor:OnRadio25( wndHandler, wndControl, eMouseButton ) ShareFilter = 3 self:GridRefresh() end function WillYouBeMyNeighbor:OnRadio0( wndHandler, wndControl, eMouseButton ) ShareFilter = 4 self:GridRefresh() end function WillYouBeMyNeighbor:OnLevel1( wndHandler, wndControl, eMouseButton ) NodeLevelFilter = 1 self:GridRefresh() end function WillYouBeMyNeighbor:OnLevel2( wndHandler, wndControl, eMouseButton ) NodeLevelFilter = 2 self:GridRefresh() end function WillYouBeMyNeighbor:OnLevel3( wndHandler, wndControl, eMouseButton ) NodeLevelFilter = 3 self:GridRefresh() end function WillYouBeMyNeighbor:OnLevel4( wndHandler, wndControl, eMouseButton ) NodeLevelFilter = 4 self:GridRefresh() end function WillYouBeMyNeighbor:OnGuildFilterChange( wndHandler, wndControl ) GuildFilter = wndControl:GetSelectedText() self:GridRefresh() end function WillYouBeMyNeighbor:DeclineByFilter( wndHandler, wndControl, eMouseButton ) DeclineByFilter = wndControl:IsChecked() end function WillYouBeMyNeighbor:OnFilterPlantPirates( wndHandler, wndControl, eMouseButton ) PlantPiratesAlert = wndControl:IsChecked() end function WillYouBeMyNeighbor:OnHarvestNotifications( wndHandler, wndControl, eMouseButton ) HarvestNotifications = wndControl:IsChecked() end function WillYouBeMyNeighbor:OnAcceptAllSocials( wndHandler, wndControl, eMouseButton ) AcceptAllSocials = wndControl:IsChecked() end function WillYouBeMyNeighbor:SetStarRating(r) for x=1, 5 do if x<=r then self.wndMain:FindChild(string.format("Rating%d",x)):SetOpacity(1) else self.wndMain:FindChild(string.format("Rating%d",x)):SetOpacity(0.6) end end local cp = self.wndMain:FindChild("WillYouBeMyNeighborCurrentName"):GetText() if cp and PlotRatings[cp] ~= r then PlotRatings[cp] = r end end function WillYouBeMyNeighbor:OnStarRating1() self:SetStarRating(1) end function WillYouBeMyNeighbor:OnStarRating2() self:SetStarRating(2) end function WillYouBeMyNeighbor:OnStarRating3() self:SetStarRating(3) end function WillYouBeMyNeighbor:OnStarRating4() self:SetStarRating(4) end function WillYouBeMyNeighbor:OnStarRating5() self:SetStarRating(5) end ----------------------------------------------------------------------------------------------- -- WillYouBeMyNeighbor Instance ----------------------------------------------------------------------------------------------- local WillYouBeMyNeighborInst = WillYouBeMyNeighbor:new() WillYouBeMyNeighborInst:Init()
비교하기