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")
364 wgTargetSlotForce
.active
= true
365 wgTargetSlotForce
.texture
= "consider_bg.tga"
366 wgImpossible
.active
= true
367 wgTargetSlotForce
.h
= 16
370 if twGetTargetLevel() == -1 then
371 wgLock
.active
= false
372 wgTargetSlotForce
.active
= false
373 wgTargetLevel
.active
= false
374 wgImpossible
.active
= false
375 wgSlotRing
.active
= false
376 if (isTargetUser() and twIsPlayerInPVPMode()) then
377 wgToolTip
.tooltip
= ""
378 wgPvPTag
.active
= true
381 wgPvPTag
.active
= false
383 wgToolTip
.tooltip
= i18n
.get("uittConsiderTargetNoSelection")
388 local pvpMode
= false
389 wgPvPTag
.active
= false
393 -- /luaScript getUI("ui:interface:target:header_opened:lock").active=true
395 -- if the selection is a player, then both the local & targeted player must be in PVP mode for the level to be displayed
396 if (twIsTargetPlayer()) then
397 -- don't display anything ...
398 wgLock
.active
= false
399 wgTargetSlotForce
.active
= false
400 wgTargetLevel
.active
= false
401 wgImpossible
.active
= false
402 wgSlotRing
.active
= false
403 wgToolTip
.tooltip
= ""
404 if twIsTargetInPVPMode() then
405 wgPvPTag
.active
= true
410 wgLock
.active
= false
411 local level
= getDbProp(getDefine("target_player_level"))
413 if level
== 2 then -- Locked by team of player
415 wgLock
.color
= "50 250 250 255"
417 if level
== 1 then -- Locked by another team
419 wgLock
.color
= "250 50 50 255"
424 -- depending on the number of people in the group, set the max diff for visibility between player level
425 -- & creature level (x 10 per member)
426 local maxDiffLevel
= 10
428 -- exception there : when "pvping", don't relate the levelof the target to the level of the group, but to thelocal
431 if getDbProp("SERVER:GROUP:" .. tostring(gm
) .. ":PRESENT") ~= 0 then
432 maxDiffLevel
= maxDiffLevel
+ 10
437 --debugInfo("Max diff level= " .. tostring(maxDiffLevel))
439 local impossible
= (twGetTargetLevel() - twGetPlayerLevel() > maxDiffLevel
)
441 wgSlotRing
.active
= false
444 -- targeted object is too hard too beat, display a skull
445 wgTargetLevel
.active
= false
447 wgImpossible
.color
= "255 50 50 255"
449 -- player can see the level of the targeted creature
450 wgTargetLevel
.active
= true
452 wgTargetLevel
.hardtext
= tostring(twGetTargetLevel())
453 wgImpossible
.color
= "255 255 255 255"
454 wgTargetLevel
.color
= getDefine("region_force_" .. tostring(levelToForceRegion(twGetTargetLevel())))
457 -- based on the 'level force', set a colored ring around the level
458 local levelForce
= twGetTargetLevelForce()
459 wgTargetSlotForce
.color
= getDefine("region_force_" .. tostring(levelToForceRegion(twGetTargetLevel())))
461 wgImpossible
.texture
= getDefine("force_level_" .. tostring(levelForce
))
462 wgImpossible
.active
= true
463 if levelForce
< 6 then
464 wgToolTip
.tooltip
= i18n
.get("uittConsiderTargetLevel")
465 elseif levelForce
== 6 then
467 wgImpossible
.color
= "117 132 126 255"
468 wgSlotRing
.color
= "117 132 126 255"
469 wgTargetSlotForce
.color
= "117 132 126 255"
470 wgSlotRing
.texture
= "consider_ring.tga"
471 wgToolTip
.tooltip
= i18n
.get("uittConsiderNamedOrMiniBoss")
472 elseif levelForce
== 7 then
474 wgImpossible
.color
= "156 98 65 255"
475 wgSlotRing
.color
= "156 98 65 255"
476 wgTargetSlotForce
.color
= "156 98 65 255"
477 wgSlotRing
.texture
= "consider_ring.tga"
478 wgToolTip
.tooltip
= i18n
.get("uittConsiderNamedOrMiniBoss")
479 elseif levelForce
== 8 then
481 wgImpossible
.color
= "213 212 9 255"
482 wgSlotRing
.texture
= "consider_ring.tga"
483 wgSlotRing
.color
= "213 212 9 255"
484 if isTargetNPC() then
485 wgTargetSlotForce
.color
= "255 255 255 255"
486 wgToolTip
.tooltip
= i18n
.get("uittConsiderBossNpc")
488 wgTargetSlotForce
.color
= "213 212 9 255"
489 wgToolTip
.tooltip
= i18n
.get("uittConsiderBoss")
491 elseif levelForce
== 12 then
492 wgImpossible
.color
= "255 255 255 255"
493 wgTargetSlotForce
.texture
= "episode_step.tga"
494 wgTargetSlotForce
.color
= "255 255 255 255"
495 wgToolTip
.tooltip
= i18n
.get("uittConsiderUnknownLevel")
496 wgTargetLevel
.active
= false
498 elseif levelForce
> 12 then
499 wgImpossible
.color
= "255 255 255 255"
500 wgTargetSlotForce
.texture
= "episode_step_ok.tga"
501 wgTargetSlotForce
.color
= "255 255 255 255"
502 wgToolTip
.tooltip
= i18n
.get("uittConsiderSpecialLevel")
503 wgTargetLevel
.active
= false
508 wgToolTip
.tooltip
= concatUCString(wgToolTip
.tooltip
, ucstring("\n"), i18n
.get("uittConsiderUnknownLevel"))
512 ----------------------
513 -- MISC local tests function
517 twTargetPlayer
= false
518 game
:updateTargetConsiderUI()
520 -- selection, not impossible
522 twTargetPlayer
= false
525 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
526 twTargetLevelForce
= levelToLevelForce(twTargetLevel
)
527 game
:updateTargetConsiderUI()
529 -- selection, not impossible (limit)
531 twTargetPlayer
= false
534 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
535 twTargetLevelForce
= levelToLevelForce(twTargetLevel
)
536 game
:updateTargetConsiderUI()
538 -- selection, impossible
540 twTargetPlayer
= false
543 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
544 twTargetLevelForce
= levelToLevelForce(twTargetLevel
)
545 game
:updateTargetConsiderUI()
549 -- selection, not impossible, named
551 twTargetPlayer
= false
554 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
555 twTargetLevelForce
= 6
556 game
:updateTargetConsiderUI()
558 -- selection, not impossible (limit), named
560 twTargetPlayer
= false
563 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
564 twTargetLevelForce
= 6
565 game
:updateTargetConsiderUI()
567 -- selection, impossible, named
569 twTargetPlayer
= false
572 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
573 twTargetLevelForce
= 6
574 game
:updateTargetConsiderUI()
578 -- selection, not impossible, boss
580 twTargetPlayer
= false
583 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
584 twTargetLevelForce
= 7
585 game
:updateTargetConsiderUI()
587 -- selection, not impossible (limit), boss
589 twTargetPlayer
= false
592 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
593 twTargetLevelForce
= 7
594 game
:updateTargetConsiderUI()
596 -- selection, impossible, boss
598 twTargetPlayer
= false
601 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
602 twTargetLevelForce
= 7
603 game
:updateTargetConsiderUI()
607 -- selection, not impossible, boss
609 twTargetPlayer
= false
612 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
613 twTargetLevelForce
= 8
614 game
:updateTargetConsiderUI()
616 -- selection, not impossible (limit), boss
618 twTargetPlayer
= false
621 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
622 twTargetLevelForce
= 8
623 game
:updateTargetConsiderUI()
625 -- selection, impossible, boss
627 twTargetPlayer
= false
630 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
631 twTargetLevelForce
= 8
632 game
:updateTargetConsiderUI()
635 ------ PLAYER SELECTION
636 ------ 2 players, no pvp
638 twTargetPlayer
= true
639 twPlayerInPVPMode
= false
640 twTargetInPVPMode
= false
644 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
645 twTargetLevelForce
= levelToLevelForce(twTargetLevel
)
646 game
:updateTargetConsiderUI()
650 twTargetPlayer
= true
651 twPlayerInPVPMode
= true
652 twTargetInPVPMode
= true
656 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
657 twTargetLevelForce
= levelToLevelForce(twTargetLevel
)
658 game
:updateTargetConsiderUI()
662 ------ 2 players, pvp
665 function twGroup(groupSize
)
667 if gm
< groupSize
then
668 setDbProp("SERVER:GROUP:" .. tostring(gm
) .. ":PRESENT", 1)
670 setDbProp("SERVER:GROUP:" .. tostring(gm
) .. ":PRESENT", 0)
675 ------------------------------------------------------------------------------------------------------------
677 function game
:closeWebIGBrowserHeader()
678 local ui
= getUI('ui:interface:webig')
681 ui_webig_browser_h
= ui
.h
682 ui_webig_browser_w
= ui
.w
684 -- reduce window size
690 ------------------------------------------------------------------------------------------------------------
692 function game
:openWebIGBrowserHeader()
693 local ui
= getUI('ui:interface:webig');
696 -- set size from saved values
697 if (ui_webig_browser_h
~= nil) then
698 ui
.h
= ui_webig_browser_h
;
701 if (ui_webig_browser_w
~= nil) then
702 ui
.w
= ui_webig_browser_w
;
706 ------------------------------------------------------------------------------------------------------------
708 function game
:closeWindowHeader()
709 local ui
= getUICaller().parent
;
712 if game
.ui_props
[id
] == nil then
713 game
.ui_props
[id
] = {}
717 game
.ui_props
[id
].w
= ui
.w
718 game
.ui_props
[id
].h
= ui
.h
719 game
.ui_props
[id
].pop_min_h
= ui
.pop_min_h
721 -- reduce window size
727 ------------------------------------------------------------------------------------------------------------
729 function game
:openWindowHeader()
730 local ui
= getUICaller().parent
;
733 if ui
~= nil and game
.ui_props
[id
] ~= nil then
734 -- set size from saved values
735 if game
.ui_props
[id
].pop_min_h
~= nil then
736 ui
.pop_min_h
= game
.ui_props
[id
].pop_min_h
739 if game
.ui_props
[id
].h
~= nil then
740 ui
.h
= game
.ui_props
[id
].h
743 if ui_webig_browser_w
~= nil then
744 ui
.w
= game
.ui_props
[id
].w
;
750 ------------------------------------------------------------------------------------------------------------
751 function game
:openGuildIsland(url_island
)
752 local nbMember
= getNbGuildMembers();
754 for i
= 0,(nbMember
-1) do
755 local memberGrade
= getGuildMemberGrade(i
);
756 if (memberGrade
== "Leader") or (memberGrade
== "HighOfficer") then
757 params
= params
.. string.lower(getGuildMemberName(i
)) .. "=" .. memberGrade
.."&";
760 local x
,y
,z
= getPlayerPos()
761 params
= params
.. "&posx=" .. tostring(x
) .. "&posy=" .. tostring(y
) .. "&posz=" .. tostring(z
)
763 getUI("ui:interface:guild:content:tab_island:props:html"):browse(url_island
.."params="..params
);
764 runAH(nil, "browse_home", "name=ui:interface:guild:content:tab_island:inv:html")
767 function game
:openGuildSpecialBag()
768 runAH(nil, "browse_home", "name=ui:interface:guild:content:tab_special_bag:inv:html")
773 ------------------------------------------------------------------------------------------------------------
775 function game
:chatUrl(url
)
777 runAH(nil, "active_menu", "menu=ui:interface:chat_uri_action_menu")
779 function game
:chatUrlCopy()
780 runAH(nil, "copy_to_clipboard", SavedUrl
)
782 function game
:chatUrlBrowse()
783 runAH(nil, "browse", "name=ui:interface:webig:content:html|url=" .. SavedUrl
)
786 ------------------------------------------------------------------------------------------------------------
788 if game
.sDynChat
== nil then game
.sDynChat
= {} end
790 -- called from onInGameDbInitialized
791 function game
:openChannels()
792 if getDbProp("UI:SAVE:CHAT:AUTO_CHANNEL") > 0 then
793 local uc
= readUserChannels()
796 for _
in pairs(uc
) do
800 for i
= 0, index
-1 do
801 local node
= uc
[tostring(i
)]
802 channels
[tonumber(node
.id
)] = {
810 for k
in pairs(channels
) do table.insert(t
, k
) end
813 for _
, id
in ipairs(t
) do
815 for i
= 0, getMaxDynChan()-1 do
816 if getDbProp("UI:SAVE:ISENABLED:DYNAMIC_CHAT"..i
) == 1 then
817 local cname
= getDbProp("SERVER:DYN_CHAT:CHANNEL"..i
..":NAME")
818 if isDynStringAvailable(cname
) then
819 local chan
= getDynString(cname
):toUtf8()
821 if channels
[id
].name
== chan
then found
= true end
826 self
:connectUserChannel(channels
[id
].name
.." "..channels
[id
].passwd
)
827 -- now restore colors
828 if channels
[id
].rgba
~= '' then
831 local rgba
= {[0]="R", [1]="G", [2]="B", [3]="A"}
832 for color
in string.gmatch(channels
[id
].rgba
, "%d+") do
833 c
[rgba
[i]]
= tonumber(color
)
836 setDbRGBA("UI:SAVE:CHAT:COLORS:DYN:"..id
, CRGBA(c
.R
, c
.G
, c
.B
, c
.A
))
844 -- store channel detail before it open
845 function game
:connectUserChannel(args
)
847 for w
in string.gmatch(args
, "%S+") do
848 table.insert(argv
, w
)
851 local params
= argv
[1]
853 for _
, ch
in pairs(self
.sDynChat
) do
854 if ch
[argv
[1]]
then ch
[argv
[1]]
= nil end
856 if argv
[2] ~= '*' and argv
[2] ~= '***' then
857 table.insert(self
.sDynChat
, {[argv
[1]]
=argv
[2]})
859 params
= params
.." "..argv
[2]
861 runAH(nil, "talk", "mode=0|text=/a connectUserChannel "..params
)
865 -- save user created channels
866 function game
:saveChannel(verbose
)
867 if verbose
== nil then
871 for i
= 0, getMaxDynChan()-1 do
872 if getDbProp("UI:SAVE:ISENABLED:DYNAMIC_CHAT"..i
) == 1 then
873 local cname
= getDbProp("SERVER:DYN_CHAT:CHANNEL"..i
..":NAME")
874 if isDynStringAvailable(cname
) then
875 local chan
= getDynString(cname
):toUtf8()
877 -- avoid empty cvar case
878 if getClientCfgVar("ChannelIgnoreFilter") then
879 for _
, k
in pairs(getClientCfgVar("ChannelIgnoreFilter")) do
880 if k
== chan
then found
= true end
883 -- store current colors
884 local cRGBA
= getDbRGBA("UI:SAVE:CHAT:COLORS:DYN:"..i
)
886 -- include private channels
887 for _
, k
in pairs(game
.sDynChat
) do
888 if k
[chan
] then password
= k
[chan
] end
890 channels
[tostring(i
)] = {
900 saveUserChannels(channels
, verbose
)
903 ------------------------------------------------------------------------------------------------------------
905 function game
:chatWelcomeMsg(input
)
909 input
= getUICaller().params_r
911 input
= input
:match("ED:([^_]+)"):lower()
915 local temp
= "UI:TEMP:ONCHAT:"
916 if game
.InGameDbInitialized
then
917 -- is input chat a dynamic channel?
918 if type(input
) == "number" then
919 local id
= getDbProp("SERVER:DYN_CHAT:CHANNEL"..input
..":NAME")
920 if isDynStringAvailable(id
) then
921 name
= getDynString(id
):toUtf8()
922 -- variable for this session
923 if getDbProp(temp
..name
) == 0 then
924 -- faction, nation and organization
926 kami
= i18n
.get("uiFameAllegiance2"),
927 karavan
= i18n
.get("uiFameAllegiance3"),
928 fyros
= i18n
.get("uiFameAllegiance4"),
929 matis
= i18n
.get("uiFameAllegiance5"),
930 tryker
= i18n
.get("uiFameAllegiance6"),
931 zorai
= i18n
.get("uiFameAllegiance7"),
932 marauder
= i18n
.get("uiFameMarauders"),
933 ranger
= i18n
.get("uiOrganization_7")
935 if name
== v
:toUtf8() then
936 msg
= i18n
.get("uiWelcome_"..k
)
941 -- chat_group_filter sParam
942 chat
= "dyn_chat"..input
945 -- around, region and universe
946 if getDbProp(temp
..input
) == 0 then
947 msg
= i18n
.get("uiWelcome_"..input
)
952 displayChatMessage(tostring(msg
), input
)
953 -- save for this session
954 addDbProp(temp
..name
, 1)
957 runAH(getUICaller(), "chat_group_filter", chat
)
961 function game
:TalkWithNpc(bullying
)
962 setTargetAsInterlocutor()
964 if bullying
== 1 then
965 runCommand("a", "openTargetUrl", "1")
967 runCommand("a", "openTargetUrl")
972 -----------------------------------
975 function tablelength(T
)
980 for _
in pairs(T
) do count
= count
+ 1 end
984 function arkNpcShop
:showBuy()
985 getUI("ui:interface:ark_shop_buy_item"):find("ok").active
=true
988 function arkNpcShop
:openSection(url
)
989 framewin
= getUI("ui:interface:ark_npc_shop"):find("buy"):renderHtml(arkNpcShop
.PleaseWait
)
990 getUI("ui:interface:web_transactions"):find("html"):browse(url
)
993 function arkNpcShop
:updateWindow(px
, py
)
994 local x
, y
, z
= getPlayerPos()
996 if (px
-x
)*(px
-x
)+(py
-y
)*(py
-y
) > 25 then
997 local w
= getUI("ui:interface:ark_npc_shop")
1000 getUI("ui:interface:ark_shop_buy_item").active
= false
1001 arkNpcShop
.player_can_buy
= false
1002 broadcast(arkNpcShop
.TooFar
)
1005 local diff
= math
.floor((nltime
.getLocalTime() - arkNpcShop
.lastMultipleItemsUpdate
) / 10)
1007 arkNpcShop
.lastMultipleItemsUpdate
= nltime
.getLocalTime()
1008 if arkNpcShop
.player_money_per_items
~= nil then
1009 for item
, price
in pairs(arkNpcShop
.player_money_per_items
) do
1010 if arkNpcShop
.lastMultipleItemsIndex
[item
] == nil then
1011 arkNpcShop
.lastMultipleItemsIndex
[item
] = {}
1014 local w
= getUI("ui:interface:ark_npc_shop"):find("ark_npc_shop_item_"..item
.."_price"..tostring(i
))
1015 if w
~= nil and arkNpcShop
.all_items
[item
] ~= nil and arkNpcShop
.all_items
[item
][i
] ~= nil then
1016 if price
[i
] ~= nil and price
[i
] < 1 then
1017 if arkNpcShop
.lastMultipleItemsIndex
[item
][i
] == nil then
1018 arkNpcShop
.lastMultipleItemsIndex
[item
][i
] = 0
1021 arkNpcShop
.lastMultipleItemsIndex
[item
][i
] = arkNpcShop
.lastMultipleItemsIndex
[item
][i
] + 1
1022 if arkNpcShop
.lastMultipleItemsIndex
[item
][i
] > tablelength(arkNpcShop
.all_items
[item
][i
]) then
1023 arkNpcShop
.lastMultipleItemsIndex
[item
][i
] = 1
1026 local sheet
= arkNpcShop
.all_items
[item
][i
][arkNpcShop
.lastMultipleItemsIndex
[item
][i]]
1027 if sheet
~= ".sitem" then
1028 setDbProp("UI:TEMP:ARK:ITEM:"..item
.."_"..tostring(i
)..":SHEET", getSheetId(sheet
))
1038 function arkNpcShop
:checkitems(db
, items
, quality
, id
)
1040 for i
= 0, 499, 1 do
1041 local sheet
= getDbProp("SERVER:INVENTORY:BAG:"..tostring(i
)..":SHEET")
1043 local name
= string.lower(getSheetName(sheet
))
1044 for _
, item
in pairs(items
) do
1045 if name
== item
then
1046 local qual
= getDbProp("SERVER:INVENTORY:BAG:"..tostring(i
)..":QUALITY")
1047 local quant
= getDbProp("SERVER:INVENTORY:BAG:"..tostring(i
)..":QUANTITY")
1049 if qual
>= quality
then
1050 total
= total
+ quant
1051 setDbProp(db
..":SHEET", sheet
)
1052 setDbProp(db
..":QUALITY", qual
)
1061 function arkNpcShop
:getHtmlIcon(id
, item
)
1062 if string.sub(item
[2], 1, 1) == "#" then
1063 addDbProp("UI:TEMP:ARK:SELECTITEM:RESALE_FLAG", 0)
1065 if string.sub(item
[3], 1, 1) == "!" then
1066 webig
:addSheet("UI:TEMP:ARK:SELECTITEM", getSheetId(item
[7]), item
[4], tonumber(string.sub(item
[3], 2)))
1068 webig
:addSheet("UI:TEMP:ARK:SELECTITEM", getSheetId(item
[7]), item
[4], 1)
1070 addDbProp("UI:TEMP:ARK:SELECTITEM:USER_COLOR", item
[9])
1071 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>]]
1073 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>]]
1078 function arkNpcShop
:OpenSheetInfosWindow(id
)
1079 local w
= getUI("ui:interface:ark_npc_shop")
1080 local x
= w
:find("buy"):find("ark_npc_shop_item_"..tostring(id
))
1081 runAH(x
:find("sheet"), "open_help_auto", "")
1085 function arkNpcShop
:HideHelpWindow(id
)
1086 -- Check what help window are active
1087 local help_active
={}
1089 help_active
[i
] = getUI("ui:interface:sheet_help"..i
).active
1092 arkNpcShop
:OpenSheetInfosWindow(id
)
1094 -- Apply previous stats of help window
1096 getUI("ui:interface:sheet_help"..i
).active
= help_active
[i
]
1100 function arkNpcShop
:OpenItemWindow(id
, buy
)
1101 local item
= arkNpcShop
.items
[id
]
1102 if arkNpcShop
.all_items
[id
] ~= nil and arkNpcShop
.all_items
[id
].need_real_item
~= nil then
1103 arkNpcShop
.max_quantity
= 1
1105 if string.sub(item
[3], 1, 1) == "!" then
1106 arkNpcShop
.max_quantity
= 1
1108 arkNpcShop
.max_quantity
= item
[3]
1112 arkNpcShop
:HideHelpWindow(id
)
1114 local non_buy_window_w
= 400
1116 local ui_item_preview
= getUI("ui:interface:ark_shop_buy_item:content:header_opened:item_preview")
1117 if ui_item_preview
then
1118 ui_item_preview
.active
= false
1121 local ui_item_show_desc
= getUI("ui:interface:ark_shop_buy_item:content:header_opened:desc")
1122 if ui_item_show_desc
then
1123 ui_item_show_desc
.active
= item
[2] == "#sheet"
1126 if string.sub(item
[2], 1, 1) == "#" then
1127 local item_type
= getSheetFamily(item
[7])
1128 local display_preview
= item_type
== "SHIELD" or item_type
== "ARMOR" or item_type
== "MELEE_WEAPON" or item_type
== "RANGE_WEAPON"
1129 if ui_item_preview
then
1130 ui_item_preview
.active
= display_preview
1133 if display_preview
then
1134 non_buy_window_w
= 495
1136 -- Items who are not named items must display help window when no buy
1137 if buy
== nil and item
[2] == "#sheet" then
1138 arkNpcShop
:OpenSheetInfosWindow(id
)
1145 arkNpcShop
.price
= item
[1]
1146 setDbProp("UI:TEMP:ARK_MONEY_PRICE", arkNpcShop
.price
)
1147 setDbProp("UI:TEMP:ARK_MONEY_TOTAL", arkNpcShop
.price
)
1149 if arkNpcShop
.price
> arkNpcShop
.player_money
then
1150 arkNpcShop
.player_can_buy
= false
1152 arkNpcShop
.player_can_buy
= true
1156 local framewin
= getUI("ui:interface:ark_shop_buy_item")
1157 if framewin
== nil then
1158 createRootGroupInstance("webig_bot_chat_buy_item", "ark_shop_buy_item", {id
="content", infosclick
="arkNpcShop:OpenSheetInfosWindow("..id
..")", onclick
="arkNpcShop:Buy("..id
..")"})
1159 framewin
= getUI("ui:interface:ark_shop_buy_item")
1160 framewin
.x
= math
.ceil(((getUI("ui:interface").w
- framewin
.w
))/2)
1161 framewin
.y
= math
.ceil(((getUI("ui:interface").h
+ framewin
.h
))/2)
1164 runAH(nil, "proc", "ark_shop_animate_preview_body")
1167 local eb
= framewin
:find("edit"):find("eb")
1170 eb
:setSelectionAll()
1171 framewin
:find("item_total_price"):find("icone").texture
= arkNpcShop
.MoneyIcon
1172 framewin
:find("item_price"):find("icone").texture
= arkNpcShop
.MoneyIcon
1173 framewin
:find("item_total_price"):find("tt").tooltip
= arkNpcShop
.Money
1174 framewin
:find("item_price"):find("tt").tooltip
= arkNpcShop
.Money
1175 arkNpcShop
.window_params
= {-70, 305, 408}
1177 arkNpcShop
.window_params
= {-20, 380, non_buy_window_w
}
1180 framewin
:find("top").active
= buy
== true -- active onlye if buy
1181 framewin
:find("scroll_text").y
=arkNpcShop
.window_params
[1]
1182 framewin
:find("scroll_text").h
=arkNpcShop
.window_params
[2]
1183 framewin
.w
=arkNpcShop
.window_params
[3]
1184 framewin
.uc_title
= getUCtf8(item
[6])
1188 html
= arkNpcShop
:getHtmlIcon(id
, item
)
1189 framewin
:find("buy_sell_slot"):renderHtml(html
)
1190 if string.sub(item
[5], 1 , 8) == "https://" then
1191 framewin
:find("ok").active
=false
1192 framewin
:find("infos"):renderHtml(arkNpcShop
.PleaseWait
)
1193 framewin
:find("infos"):browse(item
[5])
1195 framewin
:find("ok").active
=true
1196 framewin
:find("infos"):renderHtml("<table width='380px'><tr><td>"..item
[5].."</td></tr></table>")
1198 arkNpcShop
:CheckMoney()
1199 -- framewin:setModalParentList("ui:interface:ark_npc_shop")
1201 html
= arkNpcShop
:getHtmlIcon(id
, item
)
1202 framewin
:find("infos"):renderHtml([[
1203 <table width="100%">
1205 <td width="40px" valign="top">]]..html
..[[</td>
1206 <td >]]..item
[5]..[[</td>
1212 framewin
:find("desc").params_l
= "arkNpcShop:OpenSheetInfosWindow("..id
..")"
1213 framewin
:find("ok").params_l
= "arkNpcShop:Buy("..id
..")"
1214 framewin
.opened
=true
1215 framewin
.active
=true
1219 function arkNpcShop
:CheckMoney()
1220 local win
= getUI("ui:interface:ark_shop_buy_item")
1221 local value
= tonumber(win
:find("edit"):find("eb").input_string
)
1222 if value
== nil or value
== 0 then
1225 if arkNpcShop
.max_quantity
~= 0 and value
> arkNpcShop
.max_quantity
then
1226 win
:find("edit"):find("eb").input_string
= arkNpcShop
.max_quantity
1227 value
= arkNpcShop
.max_quantity
1230 local total
= arkNpcShop
.price
*value
1232 if total
> arkNpcShop
.player_money
then
1233 win
:find("ok").hardtext
="uiNotEnoughMoney"
1234 arkNpcShop
.player_can_buy
= false
1236 win
:find("ok").hardtext
= arkNpcShop
.ActionName
1237 arkNpcShop
.player_can_buy
= true
1239 setDbProp("UI:TEMP:ARK_MONEY_TOTAL", total
)
1242 function arkNpcShop
:Close()
1243 local framewin
= getUI("ui:interface:ark_npc_shop")
1244 if framewin
~= nil then
1245 framewin
.active
=false
1248 framewin
= getUI("ui:interface:ark_shop_buy_item")
1249 if framewin
~= nil then
1250 framewin
.active
=false
1255 function arkNpcShop
:timer(id
, len
)
1256 local diff
= math
.floor((nltime
.getLocalTime() - savedTime
) / 50)
1257 getUI("ui:interface:current_action").active
=true
1258 setDbProp("UI:PHRASE:ACT_BAR_LEN", (100/len
)*diff
)
1260 getUI("ui:interface:current_action").active
=false
1261 setOnDraw(getUI("ui:interface:current_action"), "")
1262 local quantity
= getUI("ui:interface:ark_shop_buy_item"):find("edit"):find("eb").input_string
1263 getUI("ui:interface:web_transactions"):find("html"):browse(arkNpcShop
.ValidateUrl
..quantity
.."&item_id="..id
.."&item_selection="..arkNpcShop
.selectedItems
[id
])
1268 function arkNpcShop
:Buy(id
)
1269 local item
= arkNpcShop
.items
[id
]
1270 local win
= getUI("ui:interface:ark_shop_buy_item")
1271 local quantity
= win
:find("edit"):find("eb").input_string
1272 if arkNpcShop
.player_can_buy
then
1273 local message
= ucstring()
1274 message
:fromUtf8("@{F5FF}"..getUI("ui:interface:target").title
..": @{FF0F}I\'m checking to see if you\'re trying to rip him off... ")
1275 -- displaySystemInfo(message, "BC")
1277 if arkNpcShop
.AtysPoint
then
1278 if item
[8] == 0 then
1279 local message
= ucstring()
1280 message
:fromUtf8(arkNpcShop
.AtysPointsBuyMessage
)
1281 displaySystemInfo(message
, "BC")
1282 savedTime
= nltime
.getLocalTime()
1283 getUI("ui:interface:current_action").active
=true
1288 setOnDraw(getUI("ui:interface:current_action"), "arkNpcShop:timer("..id
..", "..tostring(len
)..")")
1290 getUI("ui:interface:web_transactions"):find("html"):browse(arkNpcShop
.ValidateUrl
..quantity
.."&item_id="..id
.."&item_selection="..arkNpcShop
.selectedItems
[id
])
1293 getUI("ui:interface:web_transactions"):find("html"):browse(arkNpcShop
.ValidateUrl
..quantity
.."&item_id="..id
.."&item_selection="..arkNpcShop
.selectedItems
[id
])
1300 RYZOM_INTERACTION_VERSION
= 324