Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- стыдно //look_at_you_
- local addon = {}
- addon.mainPanel = mainForm:GetChildChecked("MainPanel", false)
- local mode = "look_at_you_"
- local cooldown = {party = 60, raid = 180}
- local buff = {}
- local illuminate, illuminated, update_backlight_radius = common.GetAddonRelatedVisObject( "BacklightMobQuest" ), false, 70
- local isInit = false
- -----------------------------------------------------------------------------------
- local function place(widget,posX,posY,sizeX,sizeY,alignX,alignY,highPosX,highPosY)
- local tmp_place = widget:GetPlacementPlain()
- if posX then tmp_place.posX = posX end
- if posY then tmp_place.posY = posY end
- if sizeX then tmp_place.sizeX = sizeX end
- if sizeY then tmp_place.sizeY = sizeY end
- if alignX then tmp_place.alignX = alignX end
- if alignY then tmp_place.alignY = alignY end
- if highPosX then tmp_place.highPosX = highPosX end
- if highPosY then tmp_place.highPosY = highPosY end
- widget:SetPlacementPlain(tmp_place)
- end
- -----------------------------------------------------------------------------------
- local tmp_p = 0
- function update_distance(p)
- tmp_p = avatar.GetPos()
- buff[p].distance_number = math.floor( math.sqrt( math.pow( (buff[p].pos.posX - tmp_p.posX), 2 ) + math.pow( (buff[p].pos.posY - tmp_p.posY), 2 ) + math.pow( (buff[p].pos.posZ - tmp_p.posZ), 2 ) ) )
- buff[p].distance:SetVal( "value", common.FormatInt(buff[p].distance_number, "%d") )
- if buff[p].distance_number < update_backlight_radius then
- if not illuminated then
- mission.SetMarkerObject( illuminate, buff[p].pos )
- illuminated = true
- end
- else
- if illuminated then illuminated = false end
- end
- end
- function avatar_pos_changed(p)
- update_distance('l')
- if mode == 'raid' then update_distance('r') end
- end
- local function from_second_timer(p)
- if buff[p].cooldown > 0 then
- buff[p].time:SetVal( "value", common.FormatInt( buff[p].cooldown, "%d" ) )
- buff[p].pointer:Rotate( math.rad( (360/cooldown[mode]) * buff[p].cooldown ) )
- buff[p].cooldown = buff[p].cooldown - 1
- elseif buff[p].cooldown == 0 and buff[p].fix_timer == 0 then
- buff[p].time:SetVal( "value", userMods.ToWString( 'Баф' ) )
- buff[p].pointer:Rotate( math.rad( 0 ) )
- if not buff[p].id then
- buff[p].fix_timer = 10
- end
- elseif buff[p].fix_timer > 0 then
- buff[p].fix_timer = buff[p].fix_timer - 1
- if buff[p].fix_timer == 0 then
- buff[p].cooldown = cooldown[mode] - 10
- end
- end
- end
- function second_timer(p)
- from_second_timer('l')
- if mode == 'raid' then from_second_timer('r') end
- end
- local function from_track_added(p, id)
- buff[p].cooldown = 0
- buff[p].id = id
- buff[p].fix_timer = 0
- end
- function track_added(p)
- local trackInfo
- trackInfo = objects.GetTrackInfo(p.id)
- if not trackInfo then return end
- if not trackInfo.position then return end
- if userMods.FromWString( trackInfo.playerName ) ~= 'Возможности призыва' then return end
- if mode == 'party' then
- from_track_added('l', p.id)
- if math.ceil(buff.l.pos.posX) == 0 and math.ceil(buff.l.pos.posY) == 0 then
- buff.l.pos = trackInfo.position
- end
- end
- if mode == 'raid' then
- if math.ceil(trackInfo.position.posX) == math.ceil(buff.l.pos.posX) then
- from_track_added('l', p.id)
- else
- from_track_added('r', p.id)
- end
- end
- end
- function track_removed(p)
- if p.id == buff.l.id then
- buff.l.cooldown = cooldown[mode]
- buff.l.id = nil
- elseif p.id == buff.r.id then
- buff.r.cooldown = cooldown[mode]
- buff.r.id = nil
- end
- end
- function client_zone_changed(p)
- local tmp
- tmp = cartographer.GetCurrentZone().sysZoneName
- if string.sub( tmp, 1, 3 ) == 'MW_' then
- if tmp == 'MW_RaidIsle01' then
- if avatar.GetItemInfo then -- После обновления 5.0.01.19 AMW не появляется на рейдовом доминионе //look_at_you_
- mode = 'raid'
- initialization(true)
- else
- mode = 'look_at_you_'
- initialization(false)
- end
- else
- mode = 'party'
- initialization(true)
- end
- elseif addon.mainPanel:IsVisible() then
- mode = 'look_at_you_'
- initialization(false)
- end
- end
- function initialization(flag)
- -----
- buff.l.cooldown, buff.r.cooldown, buff.l.fix_timer, buff.r.fix_timer, buff.l.distance_number, buff.r.distance_number = -1, -1, 0, 0, 0, 0
- buff.l.pos, buff.r.pos = {posX = 0, posY = 0, posZ = 0}, {posX = 0, posY = 0, posZ = 0}
- buff.l.id, buff.r.id = nil, nil
- -----
- buff.l.time:SetVal( "value", userMods.ToWString( '*O*' ) )
- buff.l.distance:SetVal( "value", userMods.ToWString( 'P_rn' ) )
- -----
- buff.r.time:SetVal( "value", userMods.ToWString( '*O*' ) )
- buff.r.distance:SetVal( "value", userMods.ToWString( 'P_rn' ) )
- -----
- place(addon.mainPanel,nil,nil,60)
- -----
- if flag then
- -----
- if not isInit then
- -----
- if mode == 'raid' then
- buff.l.pos, buff.r.pos = {posX = 993.82, posY = 1282.44, posZ = 37.84}, {posX = 1574.70, posY = 1277.65, posZ = 38.62}
- place(addon.mainPanel,nil,nil,120)
- end
- -----
- addon.mainPanel:Show(true)
- -----
- common.RegisterEventHandler( track_added, "EVENT_TRACK_ADDED")
- common.RegisterEventHandler( track_removed, "EVENT_TRACK_REMOVED")
- common.RegisterEventHandler( avatar_pos_changed, "EVENT_AVATAR_POS_CHANGED")
- common.RegisterEventHandler( second_timer, "EVENT_SECOND_TIMER")
- -----
- collectgarbage()
- -----
- if debug and debug.state then
- update_backlight_radius = debug.update_backlight_radius
- else
- update_backlight_radius = 75
- end
- -----
- end
- -----
- else
- -----
- if isInit then
- -----
- addon.mainPanel:Show(false)
- -----
- common.UnRegisterEventHandler( track_added, "EVENT_TRACK_ADDED")
- common.UnRegisterEventHandler( track_removed, "EVENT_TRACK_REMOVED")
- common.UnRegisterEventHandler( avatar_pos_changed, "EVENT_AVATAR_POS_CHANGED")
- common.UnRegisterEventHandler( second_timer, "EVENT_SECOND_TIMER")
- -----
- mission.SetMarkerObject(nil, nil)
- -----
- end
- -----
- end
- end
- function avatar_created(p)
- -----
- common.RegisterEventHandler( client_zone_changed, "EVENT_AVATAR_CLIENT_ZONE_CHANGED")
- -----
- local panel = addon.mainPanel:GetChildChecked("panel", false)
- -----
- buff.l, buff.r = {}, {}
- -----
- buff.l.panel = mainForm:CreateWidgetByDesc(panel:GetWidgetDesc())
- addon.mainPanel:AddChild(buff.l.panel)
- buff.l.panel:SetName("panel.l")
- buff.l.panel:SetPriority(3)
- -----
- buff.l.time = buff.l.panel:GetChildChecked("time", false)
- buff.l.time:SetFormat( userMods.ToWString( '<header fontname="AllodsConsole" fontsize="18" shadow="1" alignx="right" color="0xFF000000"><r name="value"/></header>' ) )
- -----
- buff.l.timer = buff.l.panel:GetChildChecked("timer", false)
- -----
- buff.l.pointer = buff.l.timer:GetChildChecked("pointer", false)
- buff.l.pointer:Rotate( math.rad(0) )
- -----
- buff.l.distance = mainForm:CreateWidgetByDesc(buff.l.time:GetWidgetDesc())
- buff.l.panel:AddChild(buff.l.distance)
- buff.l.distance:SetName("distance")
- buff.l.distance:SetFormat( userMods.ToWString( '<header fontname="AllodsConsole" fontsize="15" shadow="1" alignx="right" color="0xFF000000"><r name="value"/></header>' ) )
- -----
- place(buff.l.panel,0,0,60,30,WIDGET_ALIGN_LOW,WIDGET_ALIGN_CENTER)
- place(buff.l.time,0,-3,34,22,WIDGET_ALIGN_HIGH,WIDGET_ALIGN_LOW,-2)
- place(buff.l.distance,0,0,60,18,WIDGET_ALIGN_HIGH,WIDGET_ALIGN_HIGH,-2,0)
- place(buff.l.timer,3,0,20,24,WIDGET_ALIGN_LOW,WIDGET_ALIGN_CENTER)
- place(buff.l.pointer,0,1,15,15,WIDGET_ALIGN_CENTER,WIDGET_ALIGN_CENTER)
- -----
- buff.r.panel = mainForm:CreateWidgetByDesc(panel:GetWidgetDesc())
- addon.mainPanel:AddChild(buff.r.panel)
- buff.r.panel:SetName("panel.r")
- -----
- buff.r.time = buff.r.panel:GetChildChecked("time", false)
- buff.r.time:SetFormat( userMods.ToWString( '<header fontname="AllodsConsole" fontsize="18" shadow="1" alignx="right" color="0xFF000000"><r name="value"/></header>' ) )
- -----
- buff.r.timer = buff.r.panel:GetChildChecked("timer", false)
- -----
- buff.r.pointer = buff.r.timer:GetChildChecked("pointer", false)
- buff.r.pointer:Rotate( math.rad(0) )
- -----
- buff.r.distance = mainForm:CreateWidgetByDesc(buff.r.time:GetWidgetDesc())
- buff.r.panel:AddChild(buff.r.distance)
- buff.r.distance:SetName("distance")
- buff.r.distance:SetFormat( userMods.ToWString( '<header fontname="AllodsConsole" fontsize="15" shadow="1" alignx="left" color="0xFF000000"><r name="value"/></header>' ) )
- -----
- place(buff.r.panel,0,0,60,30,WIDGET_ALIGN_HIGH,WIDGET_ALIGN_CENTER)
- place(buff.r.time,2,-3,34,22,WIDGET_ALIGN_LOW,WIDGET_ALIGN_LOW)
- place(buff.r.distance,2,0,58,18,WIDGET_ALIGN_LOW,WIDGET_ALIGN_HIGH)
- place(buff.r.timer,0,0,20,24,WIDGET_ALIGN_HIGH,WIDGET_ALIGN_CENTER,2)
- place(buff.r.pointer,0,1,15,15,WIDGET_ALIGN_CENTER,WIDGET_ALIGN_CENTER)
- -----
- panel:DestroyWidget()
- place(addon.mainPanel,0,0,120,30,WIDGET_ALIGN_LOW,WIDGET_ALIGN_LOW)
- DnD:Init(buff.l.panel, addon.mainPanel, true, true, {1,1,1,1})
- addon.mainPanel:Show(false)
- -----
- client_zone_changed()
- -----
- end
- function Init()
- common.RegisterEventHandler( avatar_created, "EVENT_AVATAR_CREATED")
- if avatar.IsExist() then avatar_created( {id = avatar.GetId()} ) end
- end
- Init()
Advertisement
Add Comment
Please, Sign In to add comment