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
] = 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 game
:checkRpItemsPosition()
304 local html
= getUI("ui:interface:rpitems_actions"):find("html")
305 for k
, v
in pairs(game
.wantedRpTargets
) do
306 local a
= html
:find("action"..v
)
308 if a
:find("but").onclick_l
== "lua" and (string.find(k
, left
..":"..target
..":"..mode
) or string.find(k
, left
..":"..target
..":")) then
309 a
:find("img").texture
= "grey_0.tga"
310 a
:find("but").onclick_l
= "lua"
311 a
:find("but").alpha
= 255
312 a
:find("text").alpha
= 255
314 a
:find("img").texture
= "r2ed_toolbar_lock_small.tga"
315 a
:find("but").onclick_l
= ""
316 a
:find("but").alpha
= 150
317 a
:find("text").alpha
= 100
324 function game
:checkRpItemsPosition()
325 local x
,y
,z
= getPlayerPos()
326 local sx
= tostring(math
.floor(x
/10))
327 local sy
= tostring(math
.floor(y
/10))
328 local html
= getUI("ui:interface:rpitems_actions"):find("html")
329 for k
, v
in pairs(game
.wantedRpPositions
) do
330 local a
= html
:find("action"..v
)
332 if string.find(sx
..":"..sy
, k
) then
333 a
:find("but").onclick_l
= "lua"
334 a
:find("img").texture
= "grey_0.tga"
335 a
:find("text").alpha
= 255
337 a
:find("but").onclick_l
= "proc"
338 a
:find("img").texture
= "r2ed_toolbar_lock_small.tga"
339 a
:find("text").alpha
= 200
345 ------------------------------------------------------------------------------------------------------------
346 -- This function is called when a new target is selected, it should update the 'consider' widget
347 -- Level of the creature
348 -- Is its level known (not too high ...)
349 -- Boss/Mini-bosses/Names colored ring
351 function game
:updateTargetConsiderUI()
352 game
:updateRpItems(game
.usedRpLeftItem
, game
.usedRpRightItem
)
353 local targetWindow
= getUI("ui:interface:target")
355 local wgTargetSlotForce
= targetWindow
:find("slot_force")
356 local wgTargetLevel
= targetWindow
:find("target_level")
357 local wgImpossible
= targetWindow
:find("impossible")
358 local wgSlotRing
= targetWindow
:find("slot_ring")
359 local wgToolTip
= targetWindow
:find("target_tooltip")
360 local wgPvPTag
= targetWindow
:find("pvp_tags")
361 local wgHeader
= targetWindow
:find("header_opened")
362 local wgLock
= targetWindow
:find("lock")
363 local wginfos
= targetWindow
:find("target_tinfos")
365 wgTargetSlotForce
.active
= true
366 wgTargetSlotForce
.texture
= "consider_bg.tga"
367 wgImpossible
.active
= true
368 wgTargetSlotForce
.h
= 16
370 wginfos
.active
= false
373 if twGetTargetLevel() == -1 then
374 wgLock
.active
= false
375 wgTargetSlotForce
.active
= false
376 wgTargetLevel
.active
= false
377 wgImpossible
.active
= false
378 wgSlotRing
.active
= false
379 if (isTargetUser() and twIsPlayerInPVPMode()) then
380 wgToolTip
.tooltip
= ""
381 wgPvPTag
.active
= true
384 wgPvPTag
.active
= false
386 wgToolTip
.tooltip
= i18n
.get("uittConsiderTargetNoSelection")
391 local pvpMode
= false
392 wgPvPTag
.active
= false
396 -- /luaScript getUI("ui:interface:target:header_opened:lock").active=true
398 -- if the selection is a player, then both the local & targeted player must be in PVP mode for the level to be displayed
399 if (twIsTargetPlayer()) then
400 -- don't display anything except infos ...
401 wginfos
.active
= true
402 wgLock
.active
= false
403 wgTargetSlotForce
.active
= false
404 wgTargetLevel
.active
= false
405 wgImpossible
.active
= false
406 wgSlotRing
.active
= false
407 wgToolTip
.tooltip
= ""
408 if twIsTargetInPVPMode() then
409 wgPvPTag
.active
= true
414 wgLock
.active
= false
415 local level
= getDbProp(getDefine("target_player_level"))
417 if level
== 2 then -- Locked by team of player
419 wgLock
.color
= "50 250 250 255"
421 if level
== 1 then -- Locked by another team
423 wgLock
.color
= "250 50 50 255"
428 -- depending on the number of people in the group, set the max diff for visibility between player level
429 -- & creature level (x 10 per member)
430 local maxDiffLevel
= 10
432 -- exception there : when "pvping", don't relate the levelof the target to the level of the group, but to thelocal
435 if getDbProp("SERVER:GROUP:" .. tostring(gm
) .. ":PRESENT") ~= 0 then
436 maxDiffLevel
= maxDiffLevel
+ 10
441 --debugInfo("Max diff level= " .. tostring(maxDiffLevel))
443 local impossible
= (twGetTargetLevel() - twGetPlayerLevel() > maxDiffLevel
)
445 wgSlotRing
.active
= false
448 -- targeted object is too hard too beat, display a skull
449 wgTargetLevel
.active
= false
451 wgImpossible
.color
= "255 50 50 255"
453 -- player can see the level of the targeted creature
454 wgTargetLevel
.active
= true
456 wgTargetLevel
.hardtext
= tostring(twGetTargetLevel())
457 wgImpossible
.color
= "255 255 255 255"
458 wgTargetLevel
.color
= getDefine("region_force_" .. tostring(levelToForceRegion(twGetTargetLevel())))
461 -- based on the 'level force', set a colored ring around the level
462 local levelForce
= twGetTargetLevelForce()
463 wgTargetSlotForce
.color
= getDefine("region_force_" .. tostring(levelToForceRegion(twGetTargetLevel())))
465 wgImpossible
.texture
= getDefine("force_level_" .. tostring(levelForce
))
466 wgImpossible
.active
= true
467 if levelForce
< 6 then
468 wgToolTip
.tooltip
= i18n
.get("uittConsiderTargetLevel")
469 elseif levelForce
== 6 then
471 wgImpossible
.color
= "117 132 126 255"
472 wgSlotRing
.color
= "117 132 126 255"
473 wgTargetSlotForce
.color
= "117 132 126 255"
474 wgSlotRing
.texture
= "consider_ring.tga"
475 wgToolTip
.tooltip
= i18n
.get("uittConsiderNamedOrMiniBoss")
476 elseif levelForce
== 7 then
478 wgImpossible
.color
= "156 98 65 255"
479 wgSlotRing
.color
= "156 98 65 255"
480 wgTargetSlotForce
.color
= "156 98 65 255"
481 wgSlotRing
.texture
= "consider_ring.tga"
482 wgToolTip
.tooltip
= i18n
.get("uittConsiderNamedOrMiniBoss")
483 elseif levelForce
== 8 then
485 wgImpossible
.color
= "213 212 9 255"
486 wgSlotRing
.texture
= "consider_ring.tga"
487 wgSlotRing
.color
= "213 212 9 255"
488 if isTargetNPC() then
489 wgTargetSlotForce
.color
= "255 255 255 255"
490 wgToolTip
.tooltip
= i18n
.get("uittConsiderBossNpc")
492 wgTargetSlotForce
.color
= "213 212 9 255"
493 wgToolTip
.tooltip
= i18n
.get("uittConsiderBoss")
495 elseif levelForce
== 12 then
496 wgImpossible
.color
= "255 255 255 255"
497 wgTargetSlotForce
.texture
= "episode_step.tga"
498 wgTargetSlotForce
.color
= "255 255 255 255"
499 wgToolTip
.tooltip
= i18n
.get("uittConsiderUnknownLevel")
500 wgTargetLevel
.active
= false
502 elseif levelForce
> 12 then
503 wgImpossible
.color
= "255 255 255 255"
504 wgTargetSlotForce
.texture
= "episode_step_ok.tga"
505 wgTargetSlotForce
.color
= "255 255 255 255"
506 wgToolTip
.tooltip
= i18n
.get("uittConsiderSpecialLevel")
507 wgTargetLevel
.active
= false
512 wgToolTip
.tooltip
= concatUCString(wgToolTip
.tooltip
, ucstring("\n"), i18n
.get("uittConsiderUnknownLevel"))
516 ----------------------
517 -- MISC local tests function
521 twTargetPlayer
= false
522 game
:updateTargetConsiderUI()
524 -- selection, not impossible
526 twTargetPlayer
= false
529 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
530 twTargetLevelForce
= levelToLevelForce(twTargetLevel
)
531 game
:updateTargetConsiderUI()
533 -- selection, not impossible (limit)
535 twTargetPlayer
= false
538 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
539 twTargetLevelForce
= levelToLevelForce(twTargetLevel
)
540 game
:updateTargetConsiderUI()
542 -- selection, impossible
544 twTargetPlayer
= false
547 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
548 twTargetLevelForce
= levelToLevelForce(twTargetLevel
)
549 game
:updateTargetConsiderUI()
553 -- selection, not impossible, named
555 twTargetPlayer
= false
558 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
559 twTargetLevelForce
= 6
560 game
:updateTargetConsiderUI()
562 -- selection, not impossible (limit), named
564 twTargetPlayer
= false
567 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
568 twTargetLevelForce
= 6
569 game
:updateTargetConsiderUI()
571 -- selection, impossible, named
573 twTargetPlayer
= false
576 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
577 twTargetLevelForce
= 6
578 game
:updateTargetConsiderUI()
582 -- selection, not impossible, boss
584 twTargetPlayer
= false
587 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
588 twTargetLevelForce
= 7
589 game
:updateTargetConsiderUI()
591 -- selection, not impossible (limit), boss
593 twTargetPlayer
= false
596 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
597 twTargetLevelForce
= 7
598 game
:updateTargetConsiderUI()
600 -- selection, impossible, boss
602 twTargetPlayer
= false
605 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
606 twTargetLevelForce
= 7
607 game
:updateTargetConsiderUI()
611 -- selection, not impossible, boss
613 twTargetPlayer
= false
616 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
617 twTargetLevelForce
= 8
618 game
:updateTargetConsiderUI()
620 -- selection, not impossible (limit), boss
622 twTargetPlayer
= false
625 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
626 twTargetLevelForce
= 8
627 game
:updateTargetConsiderUI()
629 -- selection, impossible, boss
631 twTargetPlayer
= false
634 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
635 twTargetLevelForce
= 8
636 game
:updateTargetConsiderUI()
639 ------ PLAYER SELECTION
640 ------ 2 players, no pvp
642 twTargetPlayer
= true
643 twPlayerInPVPMode
= false
644 twTargetInPVPMode
= false
648 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
649 twTargetLevelForce
= levelToLevelForce(twTargetLevel
)
650 game
:updateTargetConsiderUI()
654 twTargetPlayer
= true
655 twPlayerInPVPMode
= true
656 twTargetInPVPMode
= true
660 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
661 twTargetLevelForce
= levelToLevelForce(twTargetLevel
)
662 game
:updateTargetConsiderUI()
666 ------ 2 players, pvp
669 function twGroup(groupSize
)
671 if gm
< groupSize
then
672 setDbProp("SERVER:GROUP:" .. tostring(gm
) .. ":PRESENT", 1)
674 setDbProp("SERVER:GROUP:" .. tostring(gm
) .. ":PRESENT", 0)
679 ------------------------------------------------------------------------------------------------------------
681 function game
:closeWebIGBrowserHeader()
682 local ui
= getUI('ui:interface:webig')
685 ui_webig_browser_h
= ui
.h
686 ui_webig_browser_w
= ui
.w
688 -- reduce window size
694 ------------------------------------------------------------------------------------------------------------
696 function game
:openWebIGBrowserHeader()
697 local ui
= getUI('ui:interface:webig');
700 -- set size from saved values
701 if (ui_webig_browser_h
~= nil) then
702 ui
.h
= ui_webig_browser_h
;
705 if (ui_webig_browser_w
~= nil) then
706 ui
.w
= ui_webig_browser_w
;
710 ------------------------------------------------------------------------------------------------------------
712 function game
:closeWindowHeader()
713 local ui
= getUICaller().parent
;
716 if game
.ui_props
[id
] == nil then
717 game
.ui_props
[id
] = {}
721 game
.ui_props
[id
].w
= ui
.w
722 game
.ui_props
[id
].h
= ui
.h
723 game
.ui_props
[id
].pop_min_h
= ui
.pop_min_h
725 -- reduce window size
731 ------------------------------------------------------------------------------------------------------------
733 function game
:openWindowHeader()
734 local ui
= getUICaller().parent
;
737 if ui
~= nil and game
.ui_props
[id
] ~= nil then
738 -- set size from saved values
739 if game
.ui_props
[id
].pop_min_h
~= nil then
740 ui
.pop_min_h
= game
.ui_props
[id
].pop_min_h
743 if game
.ui_props
[id
].h
~= nil then
744 ui
.h
= game
.ui_props
[id
].h
747 if ui_webig_browser_w
~= nil then
748 ui
.w
= game
.ui_props
[id
].w
;
754 ------------------------------------------------------------------------------------------------------------
755 function game
:openGuildIsland(url_island
)
756 local nbMember
= getNbGuildMembers();
758 for i
= 0,(nbMember
-1) do
759 local memberGrade
= getGuildMemberGrade(i
);
760 if (memberGrade
== "Leader") or (memberGrade
== "HighOfficer") then
761 params
= params
.. string.lower(getGuildMemberName(i
)) .. "=" .. memberGrade
.."&";
764 local x
,y
,z
= getPlayerPos()
765 params
= params
.. "&posx=" .. tostring(x
) .. "&posy=" .. tostring(y
) .. "&posz=" .. tostring(z
)
767 getUI("ui:interface:guild:content:tab_island:props:html"):browse(url_island
.."params="..params
);
768 runAH(nil, "browse_home", "name=ui:interface:guild:content:tab_island:inv:html")
771 function game
:openGuildSpecialBag()
772 runAH(nil, "browse_home", "name=ui:interface:guild:content:tab_special_bag:inv:html")
777 ------------------------------------------------------------------------------------------------------------
779 function game
:chatUrl(url
)
781 runAH(nil, "active_menu", "menu=ui:interface:chat_uri_action_menu")
783 function game
:chatUrlCopy()
784 runAH(nil, "copy_to_clipboard", SavedUrl
)
786 function game
:chatUrlBrowse()
787 runAH(nil, "browse", "name=ui:interface:webig:content:html|url=" .. SavedUrl
)
790 ------------------------------------------------------------------------------------------------------------
792 if game
.sDynChat
== nil then game
.sDynChat
= {} end
794 -- called from onInGameDbInitialized
795 function game
:openChannels()
796 if getDbProp("UI:SAVE:CHAT:AUTO_CHANNEL") > 0 then
797 local uc
= readUserChannels()
800 for _
in pairs(uc
) do
804 for i
= 0, index
-1 do
805 local node
= uc
[tostring(i
)]
806 channels
[tonumber(node
.id
)] = {
814 for k
in pairs(channels
) do table.insert(t
, k
) end
817 for _
, id
in ipairs(t
) do
819 for i
= 0, getMaxDynChan()-1 do
820 if getDbProp("UI:SAVE:ISENABLED:DYNAMIC_CHAT"..i
) == 1 then
821 local cname
= getDbProp("SERVER:DYN_CHAT:CHANNEL"..i
..":NAME")
822 if isDynStringAvailable(cname
) then
823 local chan
= getDynString(cname
):toUtf8()
825 if channels
[id
].name
== chan
then found
= true end
830 self
:connectUserChannel(channels
[id
].name
.." "..channels
[id
].passwd
)
831 -- now restore colors
832 if channels
[id
].rgba
~= '' then
835 local rgba
= {[0]="R", [1]="G", [2]="B", [3]="A"}
836 for color
in string.gmatch(channels
[id
].rgba
, "%d+") do
837 c
[rgba
[i]]
= tonumber(color
)
840 setDbRGBA("UI:SAVE:CHAT:COLORS:DYN:"..id
, CRGBA(c
.R
, c
.G
, c
.B
, c
.A
))
848 -- store channel detail before it open
849 function game
:connectUserChannel(args
)
851 for w
in string.gmatch(args
, "%S+") do
852 table.insert(argv
, w
)
855 local params
= argv
[1]
857 for _
, ch
in pairs(self
.sDynChat
) do
858 if ch
[argv
[1]]
then ch
[argv
[1]]
= nil end
860 if argv
[2] ~= '*' and argv
[2] ~= '***' then
861 table.insert(self
.sDynChat
, {[argv
[1]]
=argv
[2]})
863 params
= params
.." "..argv
[2]
865 runAH(nil, "talk", "mode=0|text=/a connectUserChannel "..params
)
869 -- save user created channels
870 function game
:saveChannel(verbose
)
871 if verbose
== nil then
875 for i
= 0, getMaxDynChan()-1 do
876 if getDbProp("UI:SAVE:ISENABLED:DYNAMIC_CHAT"..i
) == 1 then
877 local cname
= getDbProp("SERVER:DYN_CHAT:CHANNEL"..i
..":NAME")
878 if isDynStringAvailable(cname
) then
879 local chan
= getDynString(cname
):toUtf8()
881 -- avoid empty cvar case
882 if getClientCfgVar("ChannelIgnoreFilter") then
883 for _
, k
in pairs(getClientCfgVar("ChannelIgnoreFilter")) do
884 if k
== chan
then found
= true end
887 -- store current colors
888 local cRGBA
= getDbRGBA("UI:SAVE:CHAT:COLORS:DYN:"..i
)
890 -- include private channels
891 for _
, k
in pairs(game
.sDynChat
) do
892 if k
[chan
] then password
= k
[chan
] end
894 channels
[tostring(i
)] = {
904 saveUserChannels(channels
, verbose
)
907 ------------------------------------------------------------------------------------------------------------
909 function game
:chatWelcomeMsg(input
)
913 input
= getUICaller().params_r
915 input
= input
:match("ED:([^_]+)"):lower()
919 local temp
= "UI:TEMP:ONCHAT:"
920 if game
.InGameDbInitialized
then
921 -- is input chat a dynamic channel?
922 if type(input
) == "number" then
923 local id
= getDbProp("SERVER:DYN_CHAT:CHANNEL"..input
..":NAME")
924 if isDynStringAvailable(id
) then
925 name
= getDynString(id
):toUtf8()
926 -- variable for this session
927 if getDbProp(temp
..name
) == 0 then
928 -- faction, nation and organization
930 kami
= i18n
.get("uiFameAllegiance2"),
931 karavan
= i18n
.get("uiFameAllegiance3"),
932 fyros
= i18n
.get("uiFameAllegiance4"),
933 matis
= i18n
.get("uiFameAllegiance5"),
934 tryker
= i18n
.get("uiFameAllegiance6"),
935 zorai
= i18n
.get("uiFameAllegiance7"),
936 marauder
= i18n
.get("uiFameMarauders"),
937 ranger
= i18n
.get("uiOrganization_7")
939 if name
== v
:toUtf8() then
940 msg
= i18n
.get("uiWelcome_"..k
)
945 -- chat_group_filter sParam
946 chat
= "dyn_chat"..input
949 -- around, region and universe
950 if getDbProp(temp
..input
) == 0 then
951 msg
= i18n
.get("uiWelcome_"..input
)
956 displayChatMessage(tostring(msg
), input
)
957 -- save for this session
958 addDbProp(temp
..name
, 1)
961 runAH(getUICaller(), "chat_group_filter", chat
)
965 function game
:TalkWithNpc(bullying
)
966 setTargetAsInterlocutor()
968 if bullying
== 1 then
969 runCommand("a", "openTargetUrl", "1")
971 runCommand("a", "openTargetUrl")
976 -----------------------------------
979 function tablelength(T
)
984 for _
in pairs(T
) do count
= count
+ 1 end
988 function arkNpcShop
:showBuy()
989 getUI("ui:interface:ark_shop_buy_item"):find("ok").active
=true
992 function arkNpcShop
:openSection(url
)
993 framewin
= getUI("ui:interface:ark_npc_shop"):find("buy"):renderHtml(arkNpcShop
.PleaseWait
)
994 getUI("ui:interface:web_transactions"):find("html"):browse(url
)
997 function arkNpcShop
:updateWindow(px
, py
)
998 local x
, y
, z
= getPlayerPos()
1000 if (px
-x
)*(px
-x
)+(py
-y
)*(py
-y
) > 25 then
1001 local w
= getUI("ui:interface:ark_npc_shop")
1004 getUI("ui:interface:ark_shop_buy_item").active
= false
1005 arkNpcShop
.player_can_buy
= false
1006 broadcast(arkNpcShop
.TooFar
)
1009 local diff
= math
.floor((nltime
.getLocalTime() - arkNpcShop
.lastMultipleItemsUpdate
) / 10)
1011 arkNpcShop
.lastMultipleItemsUpdate
= nltime
.getLocalTime()
1012 if arkNpcShop
.player_money_per_items
~= nil then
1013 for item
, price
in pairs(arkNpcShop
.player_money_per_items
) do
1014 if arkNpcShop
.lastMultipleItemsIndex
[item
] == nil then
1015 arkNpcShop
.lastMultipleItemsIndex
[item
] = {}
1018 local w
= getUI("ui:interface:ark_npc_shop"):find("ark_npc_shop_item_"..item
.."_price"..tostring(i
))
1019 if w
~= nil and arkNpcShop
.all_items
[item
] ~= nil and arkNpcShop
.all_items
[item
][i
] ~= nil then
1020 if price
[i
] ~= nil and price
[i
] < 1 then
1021 if arkNpcShop
.lastMultipleItemsIndex
[item
][i
] == nil then
1022 arkNpcShop
.lastMultipleItemsIndex
[item
][i
] = 0
1025 arkNpcShop
.lastMultipleItemsIndex
[item
][i
] = arkNpcShop
.lastMultipleItemsIndex
[item
][i
] + 1
1026 if arkNpcShop
.lastMultipleItemsIndex
[item
][i
] > tablelength(arkNpcShop
.all_items
[item
][i
]) then
1027 arkNpcShop
.lastMultipleItemsIndex
[item
][i
] = 1
1030 local sheet
= arkNpcShop
.all_items
[item
][i
][arkNpcShop
.lastMultipleItemsIndex
[item
][i]]
1031 if sheet
~= ".sitem" then
1032 setDbProp("UI:TEMP:ARK:ITEM:"..item
.."_"..tostring(i
)..":SHEET", getSheetId(sheet
))
1042 function arkNpcShop
:checkitems(db
, items
, quality
, id
)
1044 for i
= 0, 499, 1 do
1045 local sheet
= getDbProp("SERVER:INVENTORY:BAG:"..tostring(i
)..":SHEET")
1047 local name
= string.lower(getSheetName(sheet
))
1048 for _
, item
in pairs(items
) do
1049 if name
== item
then
1050 local qual
= getDbProp("SERVER:INVENTORY:BAG:"..tostring(i
)..":QUALITY")
1051 local quant
= getDbProp("SERVER:INVENTORY:BAG:"..tostring(i
)..":QUANTITY")
1053 if qual
>= quality
then
1054 total
= total
+ quant
1055 setDbProp(db
..":SHEET", sheet
)
1056 setDbProp(db
..":QUALITY", qual
)
1065 function arkNpcShop
:getHtmlIcon(id
, item
)
1066 if string.sub(item
[2], 1, 1) == "#" then
1067 addDbProp("UI:TEMP:ARK:SELECTITEM:RESALE_FLAG", 0)
1069 if string.sub(item
[3], 1, 1) == "!" then
1070 webig
:addSheet("UI:TEMP:ARK:SELECTITEM", getSheetId(item
[7]), item
[4], tonumber(string.sub(item
[3], 2)))
1072 webig
:addSheet("UI:TEMP:ARK:SELECTITEM", getSheetId(item
[7]), item
[4], 1)
1074 addDbProp("UI:TEMP:ARK:SELECTITEM:USER_COLOR", item
[9])
1075 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>]]
1077 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>]]
1082 function arkNpcShop
:OpenSheetInfosWindow(id
)
1083 local w
= getUI("ui:interface:ark_npc_shop")
1084 local x
= w
:find("buy"):find("ark_npc_shop_item_"..tostring(id
))
1085 runAH(x
:find("sheet"), "open_help_auto", "")
1089 function arkNpcShop
:HideHelpWindow(id
)
1090 -- Check what help window are active
1091 local help_active
={}
1093 help_active
[i
] = getUI("ui:interface:sheet_help"..i
).active
1096 arkNpcShop
:OpenSheetInfosWindow(id
)
1098 -- Apply previous stats of help window
1100 getUI("ui:interface:sheet_help"..i
).active
= help_active
[i
]
1104 function arkNpcShop
:OpenItemWindow(id
, buy
)
1105 local item
= arkNpcShop
.items
[id
]
1106 if arkNpcShop
.all_items
[id
] ~= nil and arkNpcShop
.all_items
[id
].need_real_item
~= nil then
1107 arkNpcShop
.max_quantity
= 1
1109 if string.sub(item
[3], 1, 1) == "!" then
1110 arkNpcShop
.max_quantity
= 1
1112 arkNpcShop
.max_quantity
= item
[3]
1116 arkNpcShop
:HideHelpWindow(id
)
1118 local non_buy_window_w
= 400
1120 local ui_item_preview
= getUI("ui:interface:ark_shop_buy_item:content:header_opened:item_preview")
1121 if ui_item_preview
then
1122 ui_item_preview
.active
= false
1125 local ui_item_show_desc
= getUI("ui:interface:ark_shop_buy_item:content:header_opened:desc")
1126 if ui_item_show_desc
then
1127 ui_item_show_desc
.active
= item
[2] == "#sheet"
1130 if string.sub(item
[2], 1, 1) == "#" then
1131 local item_type
= getSheetFamily(item
[7])
1132 local display_preview
= item_type
== "SHIELD" or item_type
== "ARMOR" or item_type
== "MELEE_WEAPON" or item_type
== "RANGE_WEAPON"
1133 if ui_item_preview
then
1134 ui_item_preview
.active
= display_preview
1137 if display_preview
then
1138 non_buy_window_w
= 495
1140 -- Items who are not named items must display help window when no buy
1141 if buy
== nil and item
[2] == "#sheet" then
1142 arkNpcShop
:OpenSheetInfosWindow(id
)
1149 arkNpcShop
.price
= item
[1]
1150 setDbProp("UI:TEMP:ARK_MONEY_PRICE", arkNpcShop
.price
)
1151 setDbProp("UI:TEMP:ARK_MONEY_TOTAL", arkNpcShop
.price
)
1153 if arkNpcShop
.price
> arkNpcShop
.player_money
then
1154 arkNpcShop
.player_can_buy
= false
1156 arkNpcShop
.player_can_buy
= true
1160 local framewin
= getUI("ui:interface:ark_shop_buy_item")
1161 if framewin
== nil then
1162 createRootGroupInstance("webig_bot_chat_buy_item", "ark_shop_buy_item", {id
="content", infosclick
="arkNpcShop:OpenSheetInfosWindow("..id
..")", onclick
="arkNpcShop:Buy("..id
..")"})
1163 framewin
= getUI("ui:interface:ark_shop_buy_item")
1164 framewin
.x
= math
.ceil(((getUI("ui:interface").w
- framewin
.w
))/2)
1165 framewin
.y
= math
.ceil(((getUI("ui:interface").h
+ framewin
.h
))/2)
1168 runAH(nil, "proc", "ark_shop_animate_preview_body")
1171 local eb
= framewin
:find("edit"):find("eb")
1174 eb
:setSelectionAll()
1175 framewin
:find("item_total_price"):find("icone").texture
= arkNpcShop
.MoneyIcon
1176 framewin
:find("item_price"):find("icone").texture
= arkNpcShop
.MoneyIcon
1177 framewin
:find("item_total_price"):find("tt").tooltip
= arkNpcShop
.Money
1178 framewin
:find("item_price"):find("tt").tooltip
= arkNpcShop
.Money
1179 arkNpcShop
.window_params
= {-70, 305, 408}
1181 arkNpcShop
.window_params
= {-20, 380, non_buy_window_w
}
1184 framewin
:find("top").active
= buy
== true -- active onlye if buy
1185 framewin
:find("scroll_text").y
=arkNpcShop
.window_params
[1]
1186 framewin
:find("scroll_text").h
=arkNpcShop
.window_params
[2]
1187 framewin
.w
=arkNpcShop
.window_params
[3]
1188 framewin
.uc_title
= getUCtf8(item
[6])
1192 html
= arkNpcShop
:getHtmlIcon(id
, item
)
1193 framewin
:find("buy_sell_slot"):renderHtml(html
)
1194 if string.sub(item
[5], 1 , 8) == "https://" then
1195 framewin
:find("ok").active
=false
1196 framewin
:find("infos"):renderHtml(arkNpcShop
.PleaseWait
)
1197 framewin
:find("infos"):browse(item
[5])
1199 framewin
:find("ok").active
=true
1200 framewin
:find("infos"):renderHtml("<table width='380px'><tr><td>"..item
[5].."</td></tr></table>")
1202 arkNpcShop
:CheckMoney()
1203 -- framewin:setModalParentList("ui:interface:ark_npc_shop")
1205 html
= arkNpcShop
:getHtmlIcon(id
, item
)
1206 framewin
:find("infos"):renderHtml([[
1207 <table width="100%">
1209 <td width="40px" valign="top">]]..html
..[[</td>
1210 <td >]]..item
[5]..[[</td>
1216 framewin
:find("desc").params_l
= "arkNpcShop:OpenSheetInfosWindow("..id
..")"
1217 framewin
:find("ok").params_l
= "arkNpcShop:Buy("..id
..")"
1218 framewin
.opened
=true
1219 framewin
.active
=true
1223 function arkNpcShop
:CheckMoney()
1224 local win
= getUI("ui:interface:ark_shop_buy_item")
1225 local value
= tonumber(win
:find("edit"):find("eb").input_string
)
1226 if value
== nil or value
== 0 then
1229 if arkNpcShop
.max_quantity
~= 0 and value
> arkNpcShop
.max_quantity
then
1230 win
:find("edit"):find("eb").input_string
= arkNpcShop
.max_quantity
1231 value
= arkNpcShop
.max_quantity
1234 local total
= arkNpcShop
.price
*value
1236 if total
> arkNpcShop
.player_money
then
1237 win
:find("ok").hardtext
="uiNotEnoughMoney"
1238 arkNpcShop
.player_can_buy
= false
1240 win
:find("ok").hardtext
= arkNpcShop
.ActionName
1241 arkNpcShop
.player_can_buy
= true
1243 setDbProp("UI:TEMP:ARK_MONEY_TOTAL", total
)
1246 function arkNpcShop
:Close()
1247 local framewin
= getUI("ui:interface:ark_npc_shop")
1248 if framewin
~= nil then
1249 framewin
.active
=false
1252 framewin
= getUI("ui:interface:ark_shop_buy_item")
1253 if framewin
~= nil then
1254 framewin
.active
=false
1259 function arkNpcShop
:timer(id
, len
)
1260 local diff
= math
.floor((nltime
.getLocalTime() - savedTime
) / 50)
1261 getUI("ui:interface:current_action").active
=true
1262 setDbProp("UI:PHRASE:ACT_BAR_LEN", (100/len
)*diff
)
1264 getUI("ui:interface:current_action").active
=false
1265 setOnDraw(getUI("ui:interface:current_action"), "")
1266 local quantity
= getUI("ui:interface:ark_shop_buy_item"):find("edit"):find("eb").input_string
1267 getUI("ui:interface:web_transactions"):find("html"):browse(arkNpcShop
.ValidateUrl
..quantity
.."&item_id="..id
.."&item_selection="..arkNpcShop
.selectedItems
[id
])
1272 function arkNpcShop
:Buy(id
)
1273 local item
= arkNpcShop
.items
[id
]
1274 local win
= getUI("ui:interface:ark_shop_buy_item")
1275 local quantity
= win
:find("edit"):find("eb").input_string
1276 if arkNpcShop
.player_can_buy
then
1277 local message
= ucstring()
1278 message
:fromUtf8("@{F5FF}"..getUI("ui:interface:target").title
..": @{FF0F}I\'m checking to see if you\'re trying to rip him off... ")
1279 -- displaySystemInfo(message, "BC")
1281 if arkNpcShop
.AtysPoint
then
1282 if item
[8] == 0 then
1283 local message
= ucstring()
1284 message
:fromUtf8(arkNpcShop
.AtysPointsBuyMessage
)
1285 displaySystemInfo(message
, "BC")
1286 savedTime
= nltime
.getLocalTime()
1287 getUI("ui:interface:current_action").active
=true
1292 setOnDraw(getUI("ui:interface:current_action"), "arkNpcShop:timer("..id
..", "..tostring(len
)..")")
1294 getUI("ui:interface:web_transactions"):find("html"):browse(arkNpcShop
.ValidateUrl
..quantity
.."&item_id="..id
.."&item_selection="..arkNpcShop
.selectedItems
[id
])
1297 getUI("ui:interface:web_transactions"):find("html"):browse(arkNpcShop
.ValidateUrl
..quantity
.."&item_id="..id
.."&item_selection="..arkNpcShop
.selectedItems
[id
])
1304 RYZOM_INTERACTION_VERSION
= 324