1 -- In this file we define functions that serves for interaction windows
4 ------------------------------------------------------------------------------------------------------------
5 -- create the game namespace without reseting if already created in an other file.
10 if (game
.ui_props
== nil) then
14 if arkNpcShop
== nil then
18 ------------------------------------------------------------------------------------------------------------
20 function string:split(Pattern
)
23 local SplitStart
, SplitEnd
= string.find(self
, Pattern
, Start
)
25 table.insert(Results
, string.sub(self
, Start
, SplitStart
-1))
27 SplitStart
, SplitEnd
= string.find(self
, Pattern
, Start
)
29 table.insert(Results
, string.sub(self
, Start
))
33 ------------------------------------------------------------------------------------------------------------
34 -- called when server send an invitaion we receive a text id containing the string to display (invitor name)
35 function game
:onTeamInvation(textID
)
37 local ui
= getUI('ui:interface:join_team_proposal')
38 ui
.content
.inside
.invitor_name
.textid
= textID
45 ------------------------------------------------------------------------------------------------------------
47 function game
:teamInvitationAccept()
49 local ui
= getUI('ui:interface:join_team_proposal')
51 sendMsgToServer('TEAM:JOIN')
54 ------------------------------------------------------------------------------------------------------------
56 function game
:teamInvitationRefuse()
58 local ui
= getUI('ui:interface:join_team_proposal')
60 sendMsgToServer('TEAM:JOIN_PROPOSAL_DECLINE')
63 ------------------------------------------------------------------------------------------------------------
64 -- send team invite from friendslist
65 function game
:teamInvite(uiID
)
66 runAH(nil, 'talk', 'mode=0|text=/invite '.. getUI('ui:interface:' .. uiID
).title
)
69 ------------------------------------------------------------------------------------------------------------
70 -- send team invite from guildwindow
71 function game
:teamInviteFromGuild(uiID
)
72 runAH(nil, 'talk', 'mode=0|text=/invite ' .. getGuildMemberName(tonumber(uiID
:split(":m")[2])))
75 ------------------------------------------------------------------------------------------------------------
76 --Send Guild invite from guildwindow
77 function game
:invToGuild()
78 player
= getUI('ui:interface:add_guild'):find('edit_text').hardtext
:split(">")[2]
80 runAH(nil, 'talk', 'mode=0|text=/guildinvite ' .. player
)
82 runAH(nil, 'leave_modal', '')
85 ------------------------------------------------------------------------------------------------------------
86 --Check and active invite to guild button
87 function game
:updateGLinvB()
88 if(getUI('ui:interface:guild').active
)then
89 for v
= 0, (getNbGuildMembers()-1) do
90 local invB
= getUI('ui:interface:guild:content:tab_guild_info:invite')
91 if(getPlayerName() == getGuildMemberName(v
))then
92 --debugInfo(getGuildMemberName(v))
93 if(getGuildMemberGrade(v
) ~= 'Member')then
94 if(invB
.active
== false)then
105 ------------------------------------------------------------------------------------------------------------
107 function game
:switchChatTab(dbEntry
)
108 local db
= 'UI:SAVE:ISENABLED:' .. dbEntry
109 local val
= getDbProp(db
)
118 ------------------------------------------------------------------------------------------------------------
120 if (ui_free_chat_h
== nil) then
124 if (ui_free_chat_w
== nil) then
128 ------------------------------------------------------------------------------------------------------------
130 function game
:closeTellHeader(uiID
)
131 local ui
= getUI('ui:interface:' .. uiID
);
134 ui_free_chat_h
[uiID
] = ui
.h
;
135 ui_free_chat_w
[uiID
] = ui
.w
;
137 -- reduce window size
143 ------------------------------------------------------------------------------------------------------------
145 function game
:openTellHeader(uiID
)
146 local ui
= getUI('ui:interface:' .. uiID
);
149 -- set size from saved values
150 if (ui_free_chat_h
[uiID
] ~= nil) then
151 ui
.h
= ui_free_chat_h
[uiID
];
154 if (ui_free_chat_w
[uiID
] ~= nil) then
155 ui
.w
= ui_free_chat_w
[uiID
];
158 -- set Header Color to normal values (when a tell is closed and the telled player say someone, header change to "UI:SAVE:WIN:COLORS:INFOS")
159 ui
:setHeaderColor('UI:SAVE:WIN:COLORS:COM');
163 --/////////////////////////
164 --// TARGET WINDOW SETUP //
165 --/////////////////////////
167 -- local functions for tests
168 local function levelToForceRegion(level
)
171 elseif level
>= 250 then
174 return math
.floor(level
/ 50) + 2
178 local function levelToLevelForce(level
)
179 return math
.floor(math
.fmod(level
, 50) * 5 / 50) + 1
184 -- tmp var for tests in local mode
185 local twPlayerLevel
= 10
186 local twTargetLevel
= 19
187 local twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
188 local twTargetLevelForce
= levelToLevelForce(twTargetLevel
)
189 local twTargetPlayer
= false
190 local twPlayerInPVPMode
= false
191 local twTargetInPVPMode
= false
194 -----------------------------------
195 local function twGetPlayerLevel()
196 if config
.Local
== 1 then
199 return getPlayerLevel()
203 -----------------------------------
204 local function twGetTargetLevel()
205 if config
.Local
== 1 then
208 return getTargetLevel()
212 -----------------------------------
213 local function twGetTargetForceRegion()
214 if config
.Local
== 1 then
215 return twTargetForceRegion
217 return getTargetForceRegion()
221 -----------------------------------
222 local function twGetTargetLevelForce()
223 if config
.Local
== 1 then
224 return twTargetLevelForce
226 return getTargetLevelForce()
230 -----------------------------------
231 local function twIsTargetPlayer()
232 if config
.Local
== 1 then
233 return twTargetPlayer
235 return isTargetPlayer()
239 -----------------------------------
240 local function twIsPlayerInPVPMode()
241 if config
.Local
== 1 then
242 return twPlayerInPVPMode
244 return isPlayerInPVPMode()
248 -----------------------------------
249 local function twIsTargetInPVPMode()
250 if config
.Local
== 1 then
251 return twTargetInPVPMode
253 return isTargetInPVPMode()
258 game
.updateRpItemsUrl
= nil
259 game
.wantedRpLeftItem
= ""
260 game
.wantedRpRightItem
= ""
261 game
.wantedRpTargets
= {}
262 game
.wantedRpPositions
= {}
264 function game
:addRequireRpItemsPosition(x
, y
, id
)
265 local sx
= tostring(math
.floor(x
/10))
266 local sy
= tostring(math
.floor(y
/10))
267 game
.wantedRpPositions
[sx
..":"..sy
] = id
270 function game
:addRequireRpItems(left
, target
, mode
, id
)
271 game
.wantedRpTargets
[left
..":"..target
..":"..mode
] = id
274 game
.usedRpLeftItem
= "_"
275 game
.usedRpRightItem
= "_"
277 function game
:updateRpItems()
278 local left
= getPlayerTag(6)
279 local right
= getPlayerTag(5)
281 if getDbProp("LOCAL:INVENTORY:HAND:1:INDEX_IN_BAG") ~= 0 then
285 if getDbProp("LOCAL:INVENTORY:HAND:0:INDEX_IN_BAG") ~= 0 then
289 if game
.updateRpItemsUrl
then
290 if game
.usedRpLeftItem
~= left
or game
.usedRpRightItem
~= right
then
291 game
.usedRpLeftItem
= left
292 game
.usedRpRightItem
= right
293 webig
:openUrl(game
.updateRpItemsUrl
.."&left_hand="..left
.."&right_hand="..right
)
296 local target
= tostring(getTargetSheet())
300 mode
= tostring(getTargetMode())
303 local html
= getUI("ui:interface:rpitems_actions"):find("html")
304 for k
, v
in pairs(game
.wantedRpTargets
) do
305 local a
= html
:find("action"..v
)
307 if string.find(left
..":"..target
..":"..mode
, k
) or string.find(left
..":"..target
..":*", k
) then
308 a
:find("but").frozen
= false
309 a
:find("text").alpha
= 255
311 a
:find("but").frozen
= true
312 a
:find("text").alpha
= 155
319 function game
:checkRpItemsPosition()
320 local x
,y
,z
= getPlayerPos()
321 local sx
= tostring(math
.floor(x
/10))
322 local sy
= tostring(math
.floor(y
/10))
323 local html
= getUI("ui:interface:rpitems_actions"):find("html")
324 for k
, v
in pairs(game
.wantedRpPositions
) do
325 local a
= html
:find("action"..v
)
327 if string.find(sx
..":"..sy
, k
) then
328 a
:find("but").frozen
= false
329 a
:find("text").alpha
= 255
331 a
:find("but").frozen
= true
332 a
:find("text").alpha
= 155
338 ------------------------------------------------------------------------------------------------------------
339 -- This function is called when a new target is selected, it should update the 'consider' widget
340 -- Level of the creature
341 -- Is its level known (not too high ...)
342 -- Boss/Mini-bosses/Names colored ring
344 function game
:updateTargetConsiderUI()
345 game
:updateRpItems(game
.usedRpLeftItem
, game
.usedRpRightItem
)
346 local targetWindow
= getUI("ui:interface:target")
348 local wgTargetSlotForce
= targetWindow
:find("slot_force")
349 local wgTargetLevel
= targetWindow
:find("target_level")
350 local wgImpossible
= targetWindow
:find("impossible")
351 local wgSlotRing
= targetWindow
:find("slot_ring")
352 local wgToolTip
= targetWindow
:find("target_tooltip")
353 local wgPvPTag
= targetWindow
:find("pvp_tags")
354 local wgHeader
= targetWindow
:find("header_opened")
355 local wgLock
= targetWindow
:find("lock")
357 wgTargetSlotForce
.active
= true
358 wgTargetSlotForce
.texture
= "consider_bg.tga"
359 wgImpossible
.active
= true
360 wgTargetSlotForce
.h
= 16
363 if twGetTargetLevel() == -1 then
364 wgLock
.active
= false
365 wgTargetSlotForce
.active
= false
366 wgTargetLevel
.active
= false
367 wgImpossible
.active
= false
368 wgSlotRing
.active
= false
369 if (isTargetUser() and twIsPlayerInPVPMode()) then
370 wgToolTip
.tooltip
= ""
371 wgPvPTag
.active
= true
374 wgPvPTag
.active
= false
376 wgToolTip
.tooltip
= i18n
.get("uittConsiderTargetNoSelection")
381 local pvpMode
= false
382 wgPvPTag
.active
= false
386 -- /luaScript getUI("ui:interface:target:header_opened:lock").active=true
388 -- if the selection is a player, then both the local & targeted player must be in PVP mode for the level to be displayed
389 if (twIsTargetPlayer()) then
390 -- don't display anything ...
391 wgLock
.active
= false
392 wgTargetSlotForce
.active
= false
393 wgTargetLevel
.active
= false
394 wgImpossible
.active
= false
395 wgSlotRing
.active
= false
396 wgToolTip
.tooltip
= ""
397 if twIsTargetInPVPMode() then
398 wgPvPTag
.active
= true
403 wgLock
.active
= false
404 local level
= getDbProp(getDefine("target_player_level"))
406 if level
== 2 then -- Locked by team of player
408 wgLock
.color
= "50 250 250 255"
410 if level
== 1 then -- Locked by another team
412 wgLock
.color
= "250 50 50 255"
417 -- depending on the number of people in the group, set the max diff for visibility between player level
418 -- & creature level (x 10 per member)
419 local maxDiffLevel
= 10
421 -- exception there : when "pvping", don't relate the levelof the target to the level of the group, but to thelocal
424 if getDbProp("SERVER:GROUP:" .. tostring(gm
) .. ":PRESENT") ~= 0 then
425 maxDiffLevel
= maxDiffLevel
+ 10
430 --debugInfo("Max diff level= " .. tostring(maxDiffLevel))
432 local impossible
= (twGetTargetLevel() - twGetPlayerLevel() > maxDiffLevel
)
434 wgSlotRing
.active
= false
437 -- targeted object is too hard too beat, display a skull
438 wgTargetLevel
.active
= false
440 wgImpossible
.color
= "255 50 50 255"
442 -- player can see the level of the targeted creature
443 wgTargetLevel
.active
= true
445 wgTargetLevel
.hardtext
= tostring(twGetTargetLevel())
446 wgImpossible
.color
= "255 255 255 255"
447 wgTargetLevel
.color
= getDefine("region_force_" .. tostring(levelToForceRegion(twGetTargetLevel())))
450 -- based on the 'level force', set a colored ring around the level
451 local levelForce
= twGetTargetLevelForce()
452 wgTargetSlotForce
.color
= getDefine("region_force_" .. tostring(levelToForceRegion(twGetTargetLevel())))
454 wgImpossible
.texture
= getDefine("force_level_" .. tostring(levelForce
))
455 wgImpossible
.active
= true
456 if levelForce
< 6 then
457 wgToolTip
.tooltip
= i18n
.get("uittConsiderTargetLevel")
458 elseif levelForce
== 6 then
460 wgImpossible
.color
= "117 132 126 255"
461 wgSlotRing
.color
= "117 132 126 255"
462 wgTargetSlotForce
.color
= "117 132 126 255"
463 wgSlotRing
.texture
= "consider_ring.tga"
464 wgToolTip
.tooltip
= i18n
.get("uittConsiderNamedOrMiniBoss")
465 elseif levelForce
== 7 then
467 wgImpossible
.color
= "156 98 65 255"
468 wgSlotRing
.color
= "156 98 65 255"
469 wgTargetSlotForce
.color
= "156 98 65 255"
470 wgSlotRing
.texture
= "consider_ring.tga"
471 wgToolTip
.tooltip
= i18n
.get("uittConsiderNamedOrMiniBoss")
472 elseif levelForce
== 8 then
474 wgImpossible
.color
= "213 212 9 255"
475 wgSlotRing
.texture
= "consider_ring.tga"
476 wgSlotRing
.color
= "213 212 9 255"
477 if isTargetNPC() then
478 wgTargetSlotForce
.color
= "255 255 255 255"
479 wgToolTip
.tooltip
= i18n
.get("uittConsiderBossNpc")
481 wgTargetSlotForce
.color
= "213 212 9 255"
482 wgToolTip
.tooltip
= i18n
.get("uittConsiderBoss")
484 elseif levelForce
== 12 then
485 wgImpossible
.color
= "255 255 255 255"
486 wgTargetSlotForce
.texture
= "episode_step.tga"
487 wgTargetSlotForce
.color
= "255 255 255 255"
488 wgToolTip
.tooltip
= i18n
.get("uittConsiderUnknownLevel")
489 wgTargetLevel
.active
= false
491 elseif levelForce
> 12 then
492 wgImpossible
.color
= "255 255 255 255"
493 wgTargetSlotForce
.texture
= "episode_step_ok.tga"
494 wgTargetSlotForce
.color
= "255 255 255 255"
495 wgToolTip
.tooltip
= i18n
.get("uittConsiderSpecialLevel")
496 wgTargetLevel
.active
= false
501 wgToolTip
.tooltip
= concatUCString(wgToolTip
.tooltip
, ucstring("\n"), i18n
.get("uittConsiderUnknownLevel"))
505 ----------------------
506 -- MISC local tests function
510 twTargetPlayer
= false
511 game
:updateTargetConsiderUI()
513 -- selection, not impossible
515 twTargetPlayer
= false
518 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
519 twTargetLevelForce
= levelToLevelForce(twTargetLevel
)
520 game
:updateTargetConsiderUI()
522 -- selection, not impossible (limit)
524 twTargetPlayer
= false
527 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
528 twTargetLevelForce
= levelToLevelForce(twTargetLevel
)
529 game
:updateTargetConsiderUI()
531 -- selection, impossible
533 twTargetPlayer
= false
536 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
537 twTargetLevelForce
= levelToLevelForce(twTargetLevel
)
538 game
:updateTargetConsiderUI()
542 -- selection, not impossible, named
544 twTargetPlayer
= false
547 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
548 twTargetLevelForce
= 6
549 game
:updateTargetConsiderUI()
551 -- selection, not impossible (limit), named
553 twTargetPlayer
= false
556 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
557 twTargetLevelForce
= 6
558 game
:updateTargetConsiderUI()
560 -- selection, impossible, named
562 twTargetPlayer
= false
565 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
566 twTargetLevelForce
= 6
567 game
:updateTargetConsiderUI()
571 -- selection, not impossible, boss
573 twTargetPlayer
= false
576 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
577 twTargetLevelForce
= 7
578 game
:updateTargetConsiderUI()
580 -- selection, not impossible (limit), boss
582 twTargetPlayer
= false
585 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
586 twTargetLevelForce
= 7
587 game
:updateTargetConsiderUI()
589 -- selection, impossible, boss
591 twTargetPlayer
= false
594 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
595 twTargetLevelForce
= 7
596 game
:updateTargetConsiderUI()
600 -- selection, not impossible, boss
602 twTargetPlayer
= false
605 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
606 twTargetLevelForce
= 8
607 game
:updateTargetConsiderUI()
609 -- selection, not impossible (limit), boss
611 twTargetPlayer
= false
614 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
615 twTargetLevelForce
= 8
616 game
:updateTargetConsiderUI()
618 -- selection, impossible, boss
620 twTargetPlayer
= false
623 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
624 twTargetLevelForce
= 8
625 game
:updateTargetConsiderUI()
628 ------ PLAYER SELECTION
629 ------ 2 players, no pvp
631 twTargetPlayer
= true
632 twPlayerInPVPMode
= false
633 twTargetInPVPMode
= false
637 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
638 twTargetLevelForce
= levelToLevelForce(twTargetLevel
)
639 game
:updateTargetConsiderUI()
643 twTargetPlayer
= true
644 twPlayerInPVPMode
= true
645 twTargetInPVPMode
= true
649 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
650 twTargetLevelForce
= levelToLevelForce(twTargetLevel
)
651 game
:updateTargetConsiderUI()
655 ------ 2 players, pvp
658 function twGroup(groupSize
)
660 if gm
< groupSize
then
661 setDbProp("SERVER:GROUP:" .. tostring(gm
) .. ":PRESENT", 1)
663 setDbProp("SERVER:GROUP:" .. tostring(gm
) .. ":PRESENT", 0)
668 ------------------------------------------------------------------------------------------------------------
670 function game
:closeWebIGBrowserHeader()
671 local ui
= getUI('ui:interface:webig')
674 ui_webig_browser_h
= ui
.h
675 ui_webig_browser_w
= ui
.w
677 -- reduce window size
683 ------------------------------------------------------------------------------------------------------------
685 function game
:openWebIGBrowserHeader()
686 local ui
= getUI('ui:interface:webig');
689 -- set size from saved values
690 if (ui_webig_browser_h
~= nil) then
691 ui
.h
= ui_webig_browser_h
;
694 if (ui_webig_browser_w
~= nil) then
695 ui
.w
= ui_webig_browser_w
;
699 ------------------------------------------------------------------------------------------------------------
701 function game
:closeWindowHeader()
702 local ui
= getUICaller().parent
;
705 if game
.ui_props
[id
] == nil then
706 game
.ui_props
[id
] = {}
710 game
.ui_props
[id
].w
= ui
.w
711 game
.ui_props
[id
].h
= ui
.h
712 game
.ui_props
[id
].pop_min_h
= ui
.pop_min_h
714 -- reduce window size
720 ------------------------------------------------------------------------------------------------------------
722 function game
:openWindowHeader()
723 local ui
= getUICaller().parent
;
726 if ui
~= nil and game
.ui_props
[id
] ~= nil then
727 -- set size from saved values
728 if game
.ui_props
[id
].pop_min_h
~= nil then
729 ui
.pop_min_h
= game
.ui_props
[id
].pop_min_h
732 if game
.ui_props
[id
].h
~= nil then
733 ui
.h
= game
.ui_props
[id
].h
736 if ui_webig_browser_w
~= nil then
737 ui
.w
= game
.ui_props
[id
].w
;
743 ------------------------------------------------------------------------------------------------------------
744 function game
:openGuildIsland(url_island
)
745 local nbMember
= getNbGuildMembers();
747 for i
= 0,(nbMember
-1) do
748 local memberGrade
= getGuildMemberGrade(i
);
749 if (memberGrade
== "Leader") or (memberGrade
== "HighOfficer") then
750 params
= params
.. string.lower(getGuildMemberName(i
)) .. "=" .. memberGrade
.."&";
753 local x
,y
,z
= getPlayerPos()
754 params
= params
.. "&posx=" .. tostring(x
) .. "&posy=" .. tostring(y
) .. "&posz=" .. tostring(z
)
756 getUI("ui:interface:guild:content:tab_island:props:html"):browse(url_island
.."params="..params
);
757 runAH(nil, "browse_home", "name=ui:interface:guild:content:tab_island:inv:html")
760 function game
:openGuildSpecialBag()
761 runAH(nil, "browse_home", "name=ui:interface:guild:content:tab_special_bag:inv:html")
766 ------------------------------------------------------------------------------------------------------------
768 function game
:chatUrl(url
)
770 runAH(nil, "active_menu", "menu=ui:interface:chat_uri_action_menu")
772 function game
:chatUrlCopy()
773 runAH(nil, "copy_to_clipboard", SavedUrl
)
775 function game
:chatUrlBrowse()
776 runAH(nil, "browse", "name=ui:interface:webig:content:html|url=" .. SavedUrl
)
779 ------------------------------------------------------------------------------------------------------------
781 if game
.sDynChat
== nil then game
.sDynChat
= {} end
783 -- called from onInGameDbInitialized
784 function game
:openChannels()
785 if getDbProp("UI:SAVE:CHAT:AUTO_CHANNEL") > 0 then
786 local uc
= readUserChannels()
789 for _
in pairs(uc
) do
793 for i
= 0, index
-1 do
794 local node
= uc
[tostring(i
)]
795 channels
[tonumber(node
.id
)] = {
803 for k
in pairs(channels
) do table.insert(t
, k
) end
806 for _
, id
in ipairs(t
) do
808 for i
= 0, getMaxDynChan()-1 do
809 if getDbProp("UI:SAVE:ISENABLED:DYNAMIC_CHAT"..i
) == 1 then
810 local cname
= getDbProp("SERVER:DYN_CHAT:CHANNEL"..i
..":NAME")
811 if isDynStringAvailable(cname
) then
812 local chan
= getDynString(cname
):toUtf8()
814 if channels
[id
].name
== chan
then found
= true end
819 self
:connectUserChannel(channels
[id
].name
.." "..channels
[id
].passwd
)
820 -- now restore colors
821 if channels
[id
].rgba
~= '' then
824 local rgba
= {[0]="R", [1]="G", [2]="B", [3]="A"}
825 for color
in string.gmatch(channels
[id
].rgba
, "%d+") do
826 c
[rgba
[i]]
= tonumber(color
)
829 setDbRGBA("UI:SAVE:CHAT:COLORS:DYN:"..id
, CRGBA(c
.R
, c
.G
, c
.B
, c
.A
))
837 -- store channel detail before it open
838 function game
:connectUserChannel(args
)
840 for w
in string.gmatch(args
, "%S+") do
841 table.insert(argv
, w
)
844 local params
= argv
[1]
846 for _
, ch
in pairs(self
.sDynChat
) do
847 if ch
[argv
[1]]
then ch
[argv
[1]]
= nil end
849 if argv
[2] ~= '*' and argv
[2] ~= '***' then
850 table.insert(self
.sDynChat
, {[argv
[1]]
=argv
[2]})
852 params
= params
.." "..argv
[2]
854 runAH(nil, "talk", "mode=0|text=/a connectUserChannel "..params
)
858 -- save user created channels
859 function game
:saveChannel(verbose
)
860 if verbose
== nil then
864 for i
= 0, getMaxDynChan()-1 do
865 if getDbProp("UI:SAVE:ISENABLED:DYNAMIC_CHAT"..i
) == 1 then
866 local cname
= getDbProp("SERVER:DYN_CHAT:CHANNEL"..i
..":NAME")
867 if isDynStringAvailable(cname
) then
868 local chan
= getDynString(cname
):toUtf8()
870 -- avoid empty cvar case
871 if getClientCfgVar("ChannelIgnoreFilter") then
872 for _
, k
in pairs(getClientCfgVar("ChannelIgnoreFilter")) do
873 if k
== chan
then found
= true end
876 -- store current colors
877 local cRGBA
= getDbRGBA("UI:SAVE:CHAT:COLORS:DYN:"..i
)
879 -- include private channels
880 for _
, k
in pairs(game
.sDynChat
) do
881 if k
[chan
] then password
= k
[chan
] end
883 channels
[tostring(i
)] = {
893 saveUserChannels(channels
, verbose
)
896 ------------------------------------------------------------------------------------------------------------
898 function game
:chatWelcomeMsg(input
)
902 input
= getUICaller().params_r
904 input
= input
:match("ED:([^_]+)"):lower()
908 local temp
= "UI:TEMP:ONCHAT:"
909 if game
.InGameDbInitialized
then
910 -- is input chat a dynamic channel?
911 if type(input
) == "number" then
912 local id
= getDbProp("SERVER:DYN_CHAT:CHANNEL"..input
..":NAME")
913 if isDynStringAvailable(id
) then
914 name
= getDynString(id
):toUtf8()
915 -- variable for this session
916 if getDbProp(temp
..name
) == 0 then
917 -- faction, nation and organization
919 kami
= i18n
.get("uiFameAllegiance2"),
920 karavan
= i18n
.get("uiFameAllegiance3"),
921 fyros
= i18n
.get("uiFameAllegiance4"),
922 matis
= i18n
.get("uiFameAllegiance5"),
923 tryker
= i18n
.get("uiFameAllegiance6"),
924 zorai
= i18n
.get("uiFameAllegiance7"),
925 marauder
= i18n
.get("uiFameMarauders"),
926 ranger
= i18n
.get("uiOrganization_7")
928 if name
== v
:toUtf8() then
929 msg
= i18n
.get("uiWelcome_"..k
)
934 -- chat_group_filter sParam
935 chat
= "dyn_chat"..input
938 -- around, region and universe
939 if getDbProp(temp
..input
) == 0 then
940 msg
= i18n
.get("uiWelcome_"..input
)
945 displayChatMessage(tostring(msg
), input
)
946 -- save for this session
947 addDbProp(temp
..name
, 1)
950 runAH(getUICaller(), "chat_group_filter", chat
)
954 function game
:TalkWithNpc(bullying
)
955 setTargetAsInterlocutor()
957 if bullying
== 1 then
958 runCommand("a", "openTargetUrl", "1")
960 runCommand("a", "openTargetUrl")
965 -----------------------------------
968 function tablelength(T
)
973 for _
in pairs(T
) do count
= count
+ 1 end
977 function arkNpcShop
:showBuy()
978 getUI("ui:interface:ark_shop_buy_item"):find("ok").active
=true
981 function arkNpcShop
:openSection(url
)
982 framewin
= getUI("ui:interface:ark_npc_shop"):find("buy"):renderHtml(arkNpcShop
.PleaseWait
)
983 getUI("ui:interface:web_transactions"):find("html"):browse(url
)
986 function arkNpcShop
:updateWindow(px
, py
)
987 local x
, y
, z
= getPlayerPos()
989 if (px
-x
)*(px
-x
)+(py
-y
)*(py
-y
) > 25 then
990 local w
= getUI("ui:interface:ark_npc_shop")
993 getUI("ui:interface:ark_shop_buy_item").active
= false
994 arkNpcShop
.player_can_buy
= false
995 broadcast(arkNpcShop
.TooFar
)
998 local diff
= math
.floor((nltime
.getLocalTime() - arkNpcShop
.lastMultipleItemsUpdate
) / 10)
1000 arkNpcShop
.lastMultipleItemsUpdate
= nltime
.getLocalTime()
1001 if arkNpcShop
.player_money_per_items
~= nil then
1002 for item
, price
in pairs(arkNpcShop
.player_money_per_items
) do
1003 if arkNpcShop
.lastMultipleItemsIndex
[item
] == nil then
1004 arkNpcShop
.lastMultipleItemsIndex
[item
] = {}
1007 local w
= getUI("ui:interface:ark_npc_shop"):find("ark_npc_shop_item_"..item
.."_price"..tostring(i
))
1008 if w
~= nil and arkNpcShop
.all_items
[item
] ~= nil and arkNpcShop
.all_items
[item
][i
] ~= nil then
1009 if price
[i
] ~= nil and price
[i
] < 1 then
1010 if arkNpcShop
.lastMultipleItemsIndex
[item
][i
] == nil then
1011 arkNpcShop
.lastMultipleItemsIndex
[item
][i
] = 0
1014 arkNpcShop
.lastMultipleItemsIndex
[item
][i
] = arkNpcShop
.lastMultipleItemsIndex
[item
][i
] + 1
1015 if arkNpcShop
.lastMultipleItemsIndex
[item
][i
] > tablelength(arkNpcShop
.all_items
[item
][i
]) then
1016 arkNpcShop
.lastMultipleItemsIndex
[item
][i
] = 1
1019 local sheet
= arkNpcShop
.all_items
[item
][i
][arkNpcShop
.lastMultipleItemsIndex
[item
][i]]
1020 if sheet
~= ".sitem" then
1021 setDbProp("UI:TEMP:ARK:ITEM:"..item
.."_"..tostring(i
)..":SHEET", getSheetId(sheet
))
1031 function arkNpcShop
:checkitems(db
, items
, quality
, id
)
1033 for i
= 0, 499, 1 do
1034 local sheet
= getDbProp("SERVER:INVENTORY:BAG:"..tostring(i
)..":SHEET")
1036 local name
= string.lower(getSheetName(sheet
))
1037 for _
, item
in pairs(items
) do
1038 if name
== item
then
1039 local qual
= getDbProp("SERVER:INVENTORY:BAG:"..tostring(i
)..":QUALITY")
1040 local quant
= getDbProp("SERVER:INVENTORY:BAG:"..tostring(i
)..":QUANTITY")
1042 if qual
>= quality
then
1043 total
= total
+ quant
1044 setDbProp(db
..":SHEET", sheet
)
1045 setDbProp(db
..":QUALITY", qual
)
1054 function arkNpcShop
:getHtmlIcon(id
, item
)
1055 if string.sub(item
[2], 1, 1) == "#" then
1056 addDbProp("UI:TEMP:ARK:SELECTITEM:RESALE_FLAG", 0)
1058 if string.sub(item
[3], 1, 1) == "!" then
1059 webig
:addSheet("UI:TEMP:ARK:SELECTITEM", getSheetId(item
[7]), item
[4], tonumber(string.sub(item
[3], 2)))
1061 webig
:addSheet("UI:TEMP:ARK:SELECTITEM", getSheetId(item
[7]), item
[4], 1)
1063 addDbProp("UI:TEMP:ARK:SELECTITEM:USER_COLOR", item
[9])
1064 return [[<div class="ryzom-ui-grouptemplate" style="template:arkshop_inv_item;id:inv_special_bag_item;usesheet:true;isvirtual:false;sheetdb:UI:TEMP:ARK:SELECTITEM;w:40;params_r:arkNpcShop:OpenSheetInfosWindow(]]..id
..[[);"></div>]]
1066 return [[<div class="ryzom-ui-grouptemplate" style="template:arkshop_inv_item;id:inv_special_bag_item;usesheet:false;isvirtual:true;w:44;quantity: ;quality:]]..item
[4]..[[;tooltip:u:]]..item
[6]..[[;gc2:true;gc1:true;img1:]]..item
[2]..[[;col_over:0 0 0 0"></div>]]
1071 function arkNpcShop
:OpenSheetInfosWindow(id
)
1072 local w
= getUI("ui:interface:ark_npc_shop")
1073 local x
= w
:find("buy"):find("ark_npc_shop_item_"..tostring(id
))
1074 runAH(x
:find("sheet"), "open_help_auto", "")
1078 function arkNpcShop
:HideHelpWindow(id
)
1079 -- Check what help window are active
1080 local help_active
={}
1082 help_active
[i
] = getUI("ui:interface:sheet_help"..i
).active
1085 arkNpcShop
:OpenSheetInfosWindow(id
)
1087 -- Apply previous stats of help window
1089 getUI("ui:interface:sheet_help"..i
).active
= help_active
[i
]
1093 function arkNpcShop
:OpenItemWindow(id
, buy
)
1094 local item
= arkNpcShop
.items
[id
]
1095 if arkNpcShop
.all_items
[id
] ~= nil and arkNpcShop
.all_items
[id
].need_real_item
~= nil then
1096 arkNpcShop
.max_quantity
= 1
1098 if string.sub(item
[3], 1, 1) == "!" then
1099 arkNpcShop
.max_quantity
= 1
1101 arkNpcShop
.max_quantity
= item
[3]
1105 arkNpcShop
:HideHelpWindow(id
)
1107 local non_buy_window_w
= 400
1109 local ui_item_preview
= getUI("ui:interface:ark_shop_buy_item:content:header_opened:item_preview")
1110 if ui_item_preview
then
1111 ui_item_preview
.active
= false
1114 local ui_item_show_desc
= getUI("ui:interface:ark_shop_buy_item:content:header_opened:desc")
1115 if ui_item_show_desc
then
1116 ui_item_show_desc
.active
= item
[2] == "#sheet"
1119 if string.sub(item
[2], 1, 1) == "#" then
1120 local item_type
= getSheetFamily(item
[7])
1121 local display_preview
= item_type
== "SHIELD" or item_type
== "ARMOR" or item_type
== "MELEE_WEAPON" or item_type
== "RANGE_WEAPON"
1122 if ui_item_preview
then
1123 ui_item_preview
.active
= display_preview
1126 if display_preview
then
1127 non_buy_window_w
= 495
1129 -- Items who are not named items must display help window when no buy
1130 if buy
== nil and item
[2] == "#sheet" then
1131 arkNpcShop
:OpenSheetInfosWindow(id
)
1138 arkNpcShop
.price
= item
[1]
1139 setDbProp("UI:TEMP:ARK_MONEY_PRICE", arkNpcShop
.price
)
1140 setDbProp("UI:TEMP:ARK_MONEY_TOTAL", arkNpcShop
.price
)
1142 if arkNpcShop
.price
> arkNpcShop
.player_money
then
1143 arkNpcShop
.player_can_buy
= false
1145 arkNpcShop
.player_can_buy
= true
1149 local framewin
= getUI("ui:interface:ark_shop_buy_item")
1150 if framewin
== nil then
1151 createRootGroupInstance("webig_bot_chat_buy_item", "ark_shop_buy_item", {id
="content", infosclick
="arkNpcShop:OpenSheetInfosWindow("..id
..")", onclick
="arkNpcShop:Buy("..id
..")"})
1152 framewin
= getUI("ui:interface:ark_shop_buy_item")
1153 framewin
.x
= math
.ceil(((getUI("ui:interface").w
- framewin
.w
))/2)
1154 framewin
.y
= math
.ceil(((getUI("ui:interface").h
+ framewin
.h
))/2)
1157 runAH(nil, "proc", "ark_shop_animate_preview_body")
1160 local eb
= framewin
:find("edit"):find("eb")
1163 eb
:setSelectionAll()
1164 framewin
:find("item_total_price"):find("icone").texture
= arkNpcShop
.MoneyIcon
1165 framewin
:find("item_price"):find("icone").texture
= arkNpcShop
.MoneyIcon
1166 framewin
:find("item_total_price"):find("tt").tooltip
= arkNpcShop
.Money
1167 framewin
:find("item_price"):find("tt").tooltip
= arkNpcShop
.Money
1168 arkNpcShop
.window_params
= {-70, 305, 408}
1170 arkNpcShop
.window_params
= {-20, 380, non_buy_window_w
}
1173 framewin
:find("top").active
= buy
== true -- active onlye if buy
1174 framewin
:find("scroll_text").y
=arkNpcShop
.window_params
[1]
1175 framewin
:find("scroll_text").h
=arkNpcShop
.window_params
[2]
1176 framewin
.w
=arkNpcShop
.window_params
[3]
1177 framewin
.uc_title
= getUCtf8(item
[6])
1181 html
= arkNpcShop
:getHtmlIcon(id
, item
)
1182 framewin
:find("buy_sell_slot"):renderHtml(html
)
1183 if string.sub(item
[5], 1 , 8) == "https://" then
1184 framewin
:find("ok").active
=false
1185 framewin
:find("infos"):renderHtml(arkNpcShop
.PleaseWait
)
1186 framewin
:find("infos"):browse(item
[5])
1188 framewin
:find("ok").active
=true
1189 framewin
:find("infos"):renderHtml("<table width='380px'><tr><td>"..item
[5].."</td></tr></table>")
1191 arkNpcShop
:CheckMoney()
1192 -- framewin:setModalParentList("ui:interface:ark_npc_shop")
1194 html
= arkNpcShop
:getHtmlIcon(id
, item
)
1195 framewin
:find("infos"):renderHtml([[
1196 <table width="100%">
1198 <td width="40px" valign="top">]]..html
..[[</td>
1199 <td >]]..item
[5]..[[</td>
1205 framewin
:find("desc").params_l
= "arkNpcShop:OpenSheetInfosWindow("..id
..")"
1206 framewin
:find("ok").params_l
= "arkNpcShop:Buy("..id
..")"
1207 framewin
.opened
=true
1208 framewin
.active
=true
1212 function arkNpcShop
:CheckMoney()
1213 local win
= getUI("ui:interface:ark_shop_buy_item")
1214 local value
= tonumber(win
:find("edit"):find("eb").input_string
)
1215 if value
== nil or value
== 0 then
1218 if arkNpcShop
.max_quantity
~= 0 and value
> arkNpcShop
.max_quantity
then
1219 win
:find("edit"):find("eb").input_string
= arkNpcShop
.max_quantity
1220 value
= arkNpcShop
.max_quantity
1223 local total
= arkNpcShop
.price
*value
1225 if total
> arkNpcShop
.player_money
then
1226 win
:find("ok").hardtext
="uiNotEnoughMoney"
1227 arkNpcShop
.player_can_buy
= false
1229 win
:find("ok").hardtext
= arkNpcShop
.ActionName
1230 arkNpcShop
.player_can_buy
= true
1232 setDbProp("UI:TEMP:ARK_MONEY_TOTAL", total
)
1235 function arkNpcShop
:Close()
1236 local framewin
= getUI("ui:interface:ark_npc_shop")
1237 if framewin
~= nil then
1238 framewin
.active
=false
1241 framewin
= getUI("ui:interface:ark_shop_buy_item")
1242 if framewin
~= nil then
1243 framewin
.active
=false
1248 function arkNpcShop
:timer(id
, len
)
1249 local diff
= math
.floor((nltime
.getLocalTime() - savedTime
) / 50)
1250 getUI("ui:interface:current_action").active
=true
1251 setDbProp("UI:PHRASE:ACT_BAR_LEN", (100/len
)*diff
)
1253 getUI("ui:interface:current_action").active
=false
1254 setOnDraw(getUI("ui:interface:current_action"), "")
1255 local quantity
= getUI("ui:interface:ark_shop_buy_item"):find("edit"):find("eb").input_string
1256 getUI("ui:interface:web_transactions"):find("html"):browse(arkNpcShop
.ValidateUrl
..quantity
.."&item_id="..id
.."&item_selection="..arkNpcShop
.selectedItems
[id
])
1261 function arkNpcShop
:Buy(id
)
1262 local item
= arkNpcShop
.items
[id
]
1263 local win
= getUI("ui:interface:ark_shop_buy_item")
1264 local quantity
= win
:find("edit"):find("eb").input_string
1265 if arkNpcShop
.player_can_buy
then
1266 local message
= ucstring()
1267 message
:fromUtf8("@{F5FF}"..getUI("ui:interface:target").title
..": @{FF0F}I\'m checking to see if you\'re trying to rip him off... ")
1268 -- displaySystemInfo(message, "BC")
1270 if arkNpcShop
.AtysPoint
then
1271 if item
[8] == 0 then
1272 local message
= ucstring()
1273 message
:fromUtf8(arkNpcShop
.AtysPointsBuyMessage
)
1274 displaySystemInfo(message
, "BC")
1275 savedTime
= nltime
.getLocalTime()
1276 getUI("ui:interface:current_action").active
=true
1281 setOnDraw(getUI("ui:interface:current_action"), "arkNpcShop:timer("..id
..", "..tostring(len
)..")")
1283 getUI("ui:interface:web_transactions"):find("html"):browse(arkNpcShop
.ValidateUrl
..quantity
.."&item_id="..id
.."&item_selection="..arkNpcShop
.selectedItems
[id
])
1286 getUI("ui:interface:web_transactions"):find("html"):browse(arkNpcShop
.ValidateUrl
..quantity
.."&item_id="..id
.."&item_selection="..arkNpcShop
.selectedItems
[id
])