optionsUtils.lua 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169
  1. local utils = {}
  2. local ProxyTable = global.ProxyTable
  3. local Facade = global.Facade
  4. local MMO = global.MMO
  5. -- GAME_DATA
  6. local MonsterPaperback = global.ConstantConfig.MonsterPaperback
  7. -- 称号
  8. local hudTitleSpriteID = {
  9. [0] = MMO.HUD_SPRITE_TITLE_1,
  10. [1] = MMO.HUD_SPRITE_TITLE_2,
  11. [2] = MMO.HUD_SPRITE_TITLE_3
  12. }
  13. local hudTitleLableID = {
  14. [0] = MMO.HUD_LABEL_TITLE_1,
  15. [1] = MMO.HUD_LABEL_TITLE_2,
  16. [2] = MMO.HUD_LABEL_TITLE_3
  17. }
  18. -- 顶戴
  19. local hudTipsID = {
  20. [0] = MMO.HUD_SPRITE_ICON_1,
  21. [1] = MMO.HUD_SPRITE_ICON_2,
  22. [2] = MMO.HUD_SPRITE_ICON_3,
  23. [3] = MMO.HUD_SPRITE_ICON_4,
  24. [4] = MMO.HUD_SPRITE_ICON_5,
  25. [5] = MMO.HUD_SPRITE_ICON_6,
  26. [6] = MMO.HUD_SPRITE_ICON_7,
  27. [7] = MMO.HUD_SPRITE_ICON_8,
  28. [8] = MMO.HUD_SPRITE_ICON_9,
  29. [9] = MMO.HUD_SPRITE_ICON_10,
  30. [10] = MMO.HUD_SPRITE_ICON_11
  31. }
  32. local animHudID = {
  33. [0] = MMO.HUD_NODE_TITLE_1,
  34. [1] = MMO.HUD_NODE_TITLE_2,
  35. [2] = MMO.HUD_NODE_TITLE_3,
  36. [3] = MMO.HUD_NODE_TITLE_4,
  37. [4] = MMO.HUD_NODE_TITLE_5,
  38. [5] = MMO.HUD_NODE_TITLE_6,
  39. [6] = MMO.HUD_NODE_TITLE_7,
  40. [7] = MMO.HUD_NODE_TITLE_8,
  41. [8] = MMO.HUD_NODE_TITLE_9,
  42. [9] = MMO.HUD_NODE_TITLE_10,
  43. [10] = MMO.HUD_NODE_TITLE_11
  44. }
  45. -- 不显示的类型
  46. local NoShowHpType = {
  47. [MMO.ACTOR_NPC] = 1,
  48. [MMO.ACTOR_SEFFECT] = 1,
  49. [MMO.ACTOR_DROPITEM] = 1,
  50. [MMO.ACTOR_COLLECTION] = 1
  51. }
  52. ------------------------------------------------------------------------------------------
  53. function utils:CheckSet_Npc_name()
  54. return CHECK_SERVER_OPTION(MMO.SERVER_OPTION_NPC_NAME) ~= 1
  55. end
  56. -- 人名显示
  57. function utils:CheckSet_Show_name()
  58. return CHECK_SETTING(MMO.SETTING_IDX_PLAYER_NAME) == 1
  59. end
  60. -- 只显人名
  61. function utils:CheckSet_OnlyShow_name()
  62. return CHECK_SETTING(MMO.SETTING_IDX_ONLY_NAME) == 1
  63. end
  64. ------------------------------------------------------------------------------------------
  65. -- 是否副驾
  66. function utils:IsHoreseCopilot(actor)
  67. return actor:IsPlayer() and actor:IsHoreseCopilot()
  68. end
  69. -- 屏蔽小怪
  70. function utils:IsHideMonster(actor)
  71. return actor:GetValueByKey(MMO.MONSTER_NORMAL) and CHECK_SETTING(MMO.SETTING_IDX_MONSTER_VISIBLE) == 1
  72. end
  73. -- 正常怪
  74. function utils:IsNormalMonster(actor)
  75. -- 检测是否普通怪 控制普通怪的怪物显名/屏蔽小怪判断
  76. if GUIFunction.CheckIsNormalMonster then
  77. local value = GUIFunction:CheckIsNormalMonster(actor:GetID())
  78. if type(value) == "boolean" then
  79. return value
  80. end
  81. end
  82. if actor:IsHaveMaster() then
  83. return true
  84. end
  85. if actor:IsDefender() then
  86. return false
  87. end
  88. if actor:IsEscort() then
  89. return false
  90. end
  91. if actor:IsCollection() then
  92. return false
  93. end
  94. return true
  95. end
  96. -- 只清理怪物和人形怪
  97. function utils:IsClearMonster(actor)
  98. if actor:IsMonster() or (actor:IsPlayer() and actor:IsHumanoid()) then
  99. return true
  100. end
  101. return false
  102. end
  103. -- 可清理
  104. function utils:IsCanClearMonster(actor)
  105. local IsCan = self:IsClearMonster(actor) and CHECK_SETTING(MMO.SETTING_IDX_HIDE_MONSTER_BODY) == 1 and self:ActorIsDie(actor)
  106. return IsCan
  107. end
  108. -- 是否视野内
  109. function utils:ActorInView(actor)
  110. return actor:GetValueByKey("InView")
  111. end
  112. -- 是否死亡
  113. function utils:ActorIsDie(actor)
  114. return actor:IsDie() or actor:IsDeath()
  115. end
  116. -- 是否是自己的英雄
  117. function utils:IsMyHero(actor)
  118. local HeroPropertyProxy = Facade:retrieveProxy(ProxyTable.HeroPropertyProxy)
  119. return actor:GetID() == HeroPropertyProxy:GetRoleUID()
  120. end
  121. -- 是否是城门怪
  122. function utils:IsGate(actor)
  123. return actor:GetValueByKey(MMO.Is_Gate)
  124. end
  125. -- 是否是城墙怪
  126. function utils:IsWall(actor)
  127. return actor:GetValueByKey(MMO.Is_Wall)
  128. end
  129. -- 是否钻地怪状态
  130. function utils:IsSleepInCave(actor)
  131. return actor:GetValueByKey(MMO.Is_Cave)
  132. end
  133. -- 拾取小精灵隐藏显血
  134. function utils:IsHideHpSprite(actor)
  135. if actor:IsPickUpSprite() and global.ConstantConfig.hideSpriteHp == 1 then
  136. return true
  137. end
  138. return false
  139. end
  140. ------------------------------------------------------------------------------------------
  141. -- 获得怪物简装形象
  142. function utils:get_MonsterSimpleDress(monster)
  143. if not self:checkMonsterFeatureEnable(monster:GetAnimationID(), monster) then
  144. return MonsterPaperback
  145. end
  146. -- Boss 不简装
  147. if monster:IsBoss() and CHECK_SETTING(MMO.SETTING_IDX_BOSS_NO_SIMPLE_DRESS) == 1 then
  148. return false
  149. end
  150. if CHECK_SETTING(MMO.SETTING_IDX_MONSTER_SIMPLE_DRESS) == 1 and (not monster:IsHaveMaster()) and monster:GetValueByKey(MMO.MONSTER_NORMAL) then
  151. return MonsterPaperback
  152. end
  153. return false
  154. end
  155. -- 判断玩家简装形象
  156. function utils:check_PlayerSimpleDress()
  157. if CHECK_SETTING(MMO.SETTING_IDX_PLAYER_SIMPLE_DRESS) == 1 then
  158. return true
  159. end
  160. return false
  161. end
  162. function utils:checkFeatureEnable(SFANIM_TYPE, ID, sex, actor)
  163. -- no thing
  164. if 0 == ID then
  165. return true
  166. end
  167. if 9999 == ID then
  168. return true
  169. end
  170. -- check param
  171. if not SFANIM_TYPE or not ID or not sex or SFANIM_TYPE < MMO.SFANIM_TYPE_PLAYER or SFANIM_TYPE > MMO.SFANIM_TYPE_NUM then
  172. return false
  173. end
  174. local mainPlayer = global.gamePlayerController:GetMainPlayer()
  175. if not mainPlayer then
  176. return true
  177. end
  178. if actor:IsMainPlayer() then
  179. return true
  180. end
  181. -- 屏蔽所有玩家
  182. if CHECK_SETTING(MMO.SETTING_IDX_PLAYER_SHOW) == 1 and self:CheckPlayer(actor) then
  183. return false
  184. end
  185. -- 屏蔽己方玩家
  186. if CHECK_SETTING(MMO.SETTING_IDX_PLAYER_SHOW_FRIEND) == 1 and self:CheckPlayerB(actor) then
  187. return false
  188. end
  189. return true
  190. end
  191. function utils:checkMonsterFeatureEnable(ID, actor)
  192. -- no thing
  193. if 0 == ID then
  194. return true
  195. end
  196. if 9999 == ID then
  197. return true
  198. end
  199. local mainPlayerID = global.gamePlayerController:GetMainPlayerID()
  200. if not mainPlayerID then
  201. return true
  202. end
  203. -- ignore main player pet
  204. if actor:GetMasterID() == mainPlayerID then
  205. return true
  206. end
  207. return true
  208. end
  209. ------------------------------------------------------------------------------------------
  210. -- 骑马状态的labelName更新
  211. function utils:refreshLabelName(actor)
  212. if not actor then
  213. return false
  214. end
  215. if not actor:IsPlayer() then
  216. return false
  217. end
  218. local nameHUD = global.HUDManager:GetHUD(actor:GetID(), MMO.HUD_TYPE_BATCH_LABEL, MMO.HUD_LABEL_NAME)
  219. if not nameHUD then
  220. return false
  221. end
  222. -- 有副驾
  223. local copilotid = actor:GetHorseCopilotID()
  224. local masterid = actor:GetHorseMasterID()
  225. if copilotid and masterid then
  226. local playerManager = global.playerManager
  227. local masterActor = playerManager:FindOnePlayerInCurrViewFieldById(masterid)
  228. local copilotActor = playerManager:FindOnePlayerInCurrViewFieldById(copilotid)
  229. if masterActor and copilotActor then
  230. local name = string.format("%s %s", masterActor:GetName(), copilotActor:GetName())
  231. if GUIFunction.OnRefreshActorHudName then
  232. name = GUIFunction:OnRefreshActorHudName(actor:GetID(), name)
  233. end
  234. nameHUD:setString(name)
  235. return false
  236. end
  237. end
  238. local name = actor:GetName()
  239. if GUIFunction.OnRefreshActorHudName then
  240. name = GUIFunction:OnRefreshActorHudName(actor:GetID(), name)
  241. end
  242. nameHUD:setString(name or "")
  243. end
  244. ------------------------------------------------------------------------------------------
  245. -- 检测血条
  246. function utils:CheckHUDHp(actor)
  247. if self:ActorIsDie(actor) then
  248. return false
  249. end
  250. -- 小精灵不显示血条
  251. if self:IsHideHpSprite(actor) then
  252. return false
  253. end
  254. if actor:IsMonster() and actor:IsNoShowHPBar() then
  255. return false
  256. end
  257. -- 空血不显示
  258. if actor:GetValueByKey(MMO.HUD_Hp_Null) then
  259. return false
  260. end
  261. if self:IsHoreseCopilot(actor) then
  262. return false
  263. end
  264. return true
  265. end
  266. -- 检测蓝条
  267. function utils:CheckHUDMp(actor)
  268. if self:ActorIsDie(actor) then
  269. return false
  270. end
  271. if actor:IsMonster() then
  272. return false
  273. end
  274. if actor:IsNPC() then
  275. return false
  276. end
  277. -- 服务器开关
  278. if CHECK_SERVER_OPTION(MMO.PLAYER_BLUE_BLOOD) ~= 0 then
  279. return false
  280. end
  281. -- 没有护身
  282. if actor.IsHuShen and not actor:IsHuShen() then
  283. return false
  284. end
  285. -- 没有受到伤害
  286. if actor.IsDamage and not actor:IsDamage() then
  287. return false
  288. end
  289. if actor:GetValueByKey(MMO.HUD_Hp_Null) then
  290. return false
  291. end
  292. -- 是否是副驾位
  293. if self:IsHoreseCopilot(actor) then
  294. return false
  295. end
  296. return true
  297. end
  298. -- 检测内功条
  299. function utils:CheckHUDNG(actor)
  300. if not actor then
  301. return false
  302. end
  303. if actor:IsMonster() then
  304. return false
  305. end
  306. if actor:IsNPC() then
  307. return false
  308. end
  309. -- 本地开关
  310. if tonumber(SL:GetMetaValue("GAME_DATA", "OpenNGUI")) ~= 1 then
  311. return false
  312. end
  313. -- 单控开关
  314. if tonumber(SL:GetMetaValue("GAME_DATA", "HideNGHUD")) == 1 then
  315. return false
  316. end
  317. -- 代码开关
  318. local MeridianProxy = global.Facade:retrieveProxy(global.ProxyTable.MeridianProxy)
  319. if not MeridianProxy:GetNGHudShow() then
  320. return false
  321. end
  322. -- 服务端开关
  323. local mainPlayerID = global.gamePlayerController:GetMainPlayerID()
  324. local HeroPropertyProxy = global.Facade:retrieveProxy( global.ProxyTable.HeroPropertyProxy )
  325. local HeroID = HeroPropertyProxy:GetRoleUID()
  326. if actor:IsHero() then
  327. if HeroID == actor:GetID() and not SL:GetMetaValue("H.IS_LEARNED_INTERNAL") then
  328. return false
  329. end
  330. elseif actor:IsPlayer() then
  331. if mainPlayerID == actor:GetID() and not SL:GetMetaValue("IS_LEARNED_INTERNAL") then
  332. return false
  333. end
  334. end
  335. if actor:GetMaxForce() == 0 then
  336. return false
  337. end
  338. return true
  339. end
  340. -- 检测血量文本
  341. function utils:CheckHUDHMPLabel(actor)
  342. if self:ActorIsDie(actor) then
  343. return false
  344. end
  345. if CHECK_SETTING(MMO.SETTING_IDX_HP_NUM) ~= 1 then
  346. return false
  347. end
  348. if actor:IsMonster() and actor:IsNoShowHPBar() then
  349. return false
  350. end
  351. -- 小精灵不显示血条
  352. if self:IsHideHpSprite(actor) then
  353. return false
  354. end
  355. if NoShowHpType[actor:GetType()] then
  356. return false
  357. end
  358. local actorID = actor:GetID()
  359. -- 自己的英雄空血 不显示 血量文本
  360. local HeroPropertyProxy = Facade:retrieveProxy(ProxyTable.HeroPropertyProxy)
  361. local isMyHero = HeroPropertyProxy:GetRoleUID() == actorID
  362. if isMyHero then
  363. if actor:GetValueByKey(MMO.HUD_Hp_Null) then
  364. return false
  365. end
  366. end
  367. -- 空血/满血 排除主玩家 和自己的英雄
  368. local mainPlayerID = global.gamePlayerController:GetMainPlayerID()
  369. if actorID ~= mainPlayerID and (not isMyHero) then
  370. if actor:GetValueByKey(MMO.HUD_Hp_Null) or actor:GetValueByKey(MMO.HUD_Hp_Full) then
  371. return false
  372. end
  373. if not actor:GetValueByKey(MMO.HUD_BAR_SHOW_FULL_HP) then
  374. return false
  375. end
  376. end
  377. if self:IsHoreseCopilot(actor) then
  378. return false
  379. end
  380. return true
  381. end
  382. function utils:checkPlayerName(actor)
  383. if not actor:IsPlayer() then
  384. return true
  385. end
  386. -- 活动统一名字
  387. local mapProxy = Facade:retrieveProxy(ProxyTable.Map)
  388. if mapProxy:IsUnitiveName() then
  389. return false
  390. end
  391. -- 神秘人
  392. if actor:IsShenMiRen() then
  393. return false
  394. end
  395. -- 人名显示
  396. if not self:CheckSet_Show_name() then
  397. return false
  398. end
  399. -- 只显人名
  400. if self:CheckSet_OnlyShow_name() then
  401. return false
  402. end
  403. if self:IsHoreseCopilot(actor) then
  404. return false
  405. end
  406. -- 潜行
  407. if actor:GetValueByKey(MMO.HUD_SNEAK) then
  408. return false
  409. end
  410. return true
  411. end
  412. -- 人名
  413. function utils:CheckHUDLabelName(actor)
  414. local funcName = {
  415. [MMO.ACTOR_PLAYER] = function (actor)
  416. if actor:IsHumanoid() then
  417. -- 死亡不显示
  418. if self:ActorIsDie(actor) then
  419. return false
  420. end
  421. -- 隐藏小怪
  422. if self:IsHideMonster(actor) then
  423. return false
  424. end
  425. -- 怪物显名
  426. if actor:GetValueByKey(MMO.MONSTER_NORMAL) and CHECK_SETTING(MMO.SETTING_IDX_MONSTER_NAME) ~= 1 then
  427. return false
  428. end
  429. return true
  430. end
  431. if CHECK_SETTING(MMO.SETTING_IDX_LEVEL_SHOW_NAME_HUD) == 1 then
  432. local mainPlayerID = global.gamePlayerController:GetMainPlayerID()
  433. local actorID = actor:GetID()
  434. local isMain = mainPlayerID and actorID == mainPlayerID
  435. local inputProxy = Facade:retrieveProxy(ProxyTable.PlayerInputProxy)
  436. if not isMain and inputProxy:GetTargetID() ~= actorID then
  437. local defaultValues = GET_SETTING(MMO.SETTING_IDX_LEVEL_SHOW_NAME_HUD,true)
  438. local needLevel = defaultValues and tonumber(defaultValues[2])
  439. local roleLevel = actor:GetLevel() or 0
  440. if needLevel and roleLevel < needLevel then
  441. return false
  442. end
  443. end
  444. end
  445. if self:IsHoreseCopilot(actor) then
  446. return false
  447. end
  448. -- 潜行
  449. if actor:GetValueByKey(MMO.HUD_SNEAK) then
  450. return false
  451. end
  452. return utils:CheckSet_Show_name()
  453. end,
  454. [MMO.ACTOR_MONSTER] = function (actor)
  455. if self:IsSleepInCave(actor) then
  456. return false
  457. end
  458. -- 死亡不显示
  459. if self:ActorIsDie(actor) then
  460. return false
  461. end
  462. if actor:IsNoShowName() then
  463. return false
  464. end
  465. -- 隐藏小怪
  466. if self:IsHideMonster(actor) and SL:GetMetaValue("GAME_DATA", "mon_hide_visible_name") ~= 1 then
  467. return false
  468. end
  469. -- 怪物显名
  470. if actor:GetValueByKey(MMO.MONSTER_NORMAL) and CHECK_SETTING(MMO.SETTING_IDX_MONSTER_NAME) ~= 1 then
  471. return false
  472. end
  473. return true
  474. end,
  475. [MMO.ACTOR_DROPITEM] = function (actor)
  476. local typeIndex = actor:GetTypeIndex()
  477. if typeIndex == 0 then
  478. typeIndex = 1
  479. end
  480. return CHECK_ITEM_DROP_SHOW(typeIndex)
  481. end,
  482. [MMO.ACTOR_NPC] = function ()
  483. return utils:CheckSet_Npc_name()
  484. end
  485. }
  486. if funcName[actor:GetType()] then
  487. return funcName[actor:GetType()] (actor)
  488. end
  489. return true
  490. end
  491. -- 行会名
  492. function utils:CheckHUDLabelGuild(actor)
  493. return self:checkPlayerName(actor)
  494. end
  495. -- 封号名
  496. function utils:CheckHUDLabelTitle(actor)
  497. local funcTitle = {
  498. [MMO.ACTOR_PLAYER] = function (actor)
  499. return utils:checkPlayerName(actor)
  500. end,
  501. [MMO.ACTOR_MONSTER] = function (actor)
  502. if actor:IsEscort() then
  503. return false
  504. end
  505. local curHP = actor:GetHP() or 0
  506. if curHP < 1 then
  507. return false
  508. end
  509. return true
  510. end,
  511. [MMO.ACTOR_DROPITEM] = function ()
  512. return false
  513. end,
  514. [MMO.ACTOR_NPC] = function ()
  515. return true
  516. end
  517. }
  518. if funcTitle[actor:GetType()] then
  519. return funcTitle[actor:GetType()] (actor)
  520. end
  521. return true
  522. end
  523. -- 检测 称号/顶戴
  524. function utils:CheckHUDTitle(actor)
  525. if not actor then
  526. return false
  527. end
  528. -- 镖车
  529. if actor:IsEscort() then
  530. return true
  531. end
  532. -- npc
  533. if actor:IsNPC() then
  534. return true
  535. end
  536. -- 掉落物
  537. if actor:IsDropItem() then
  538. local TypeIndex = actor:GetTypeIndex()
  539. if TypeIndex == 0 then
  540. TypeIndex = 1
  541. end
  542. return CHECK_ITEM_DROP_SHOW(TypeIndex)
  543. end
  544. -- 怪物
  545. if actor:IsMonster() or actor:IsHumanoid() then
  546. -- 死亡不显示
  547. if self:ActorIsDie(actor) then
  548. return false
  549. end
  550. -- 隐藏小怪
  551. if self:IsHideMonster(actor) then
  552. return false
  553. end
  554. if actor:IsElite() and CHECK_SETTING(MMO.SETTING_IDX_MONSTER_VISIBLE) == 1 then
  555. return false
  556. end
  557. -- 血量显示死亡不显示
  558. if actor:GetHP() < 1 then
  559. return false
  560. end
  561. return true
  562. end
  563. if not actor:IsPlayer() then
  564. return true
  565. end
  566. -- 摆摊
  567. if actor:IsStallStatus() then
  568. return false
  569. end
  570. -- -- 神秘人
  571. -- if actor:IsShenMiRen() then
  572. -- return false
  573. -- end
  574. -- 隐藏称号
  575. if CHECK_SETTING(MMO.SETTING_IDX_TITLE_VISIBLE) == 1 then
  576. return false
  577. end
  578. if self:IsHoreseCopilot(actor) then
  579. return false
  580. end
  581. -- 潜行
  582. if actor:GetValueByKey(MMO.HUD_SNEAK) then
  583. return false
  584. end
  585. return true
  586. end
  587. ------------------------------------------------------------------------------------------
  588. function utils:SetHUDHpBarVisible(actor, visible)
  589. local hpBar = actor.mHUDUI[MMO.HUDHPUI_BAR]
  590. if hpBar then
  591. hpBar:setVisible(visible)
  592. end
  593. local hpBorder = actor.mHUDUI[MMO.HUDHPUI_BORDER]
  594. if hpBorder then
  595. hpBorder:setVisible(visible)
  596. end
  597. end
  598. -- 血条
  599. function utils:CheckHUDHpBarVisible(actor)
  600. local visible = false
  601. if not self:IsSleepInCave(actor) then
  602. visible = self:ActorInView(actor) and CHECK_SETTING(MMO.SETTING_IDX_HP_HUD) == 1 and actor:GetValueByKey(MMO.HUD_HPBAR_VISIBLE)
  603. end
  604. -- 潜行
  605. if visible and actor:GetValueByKey(MMO.HUD_SNEAK) then
  606. visible = false
  607. end
  608. -- 副驾
  609. if visible and self:IsHoreseCopilot(actor) then
  610. visible = false
  611. end
  612. self:SetHUDHpBarVisible(actor, visible)
  613. end
  614. function utils:SetHUDMpBarVisible(actor, visible)
  615. local mpBar = actor.mHUDUI[MMO.HUDMPUI_BAR]
  616. if mpBar then
  617. mpBar:setVisible(visible)
  618. end
  619. local mpBorder = actor.mHUDUI[MMO.HUDMPUI_BORDER]
  620. if mpBorder then
  621. mpBorder:setVisible(visible)
  622. end
  623. end
  624. -- 蓝条
  625. function utils:CheckHUDMpBarVisible(actor)
  626. local visible = self:ActorInView(actor) and actor:GetValueByKey(MMO.HUD_MPBAR_VISIBLE)
  627. -- 潜行
  628. if visible and actor:GetValueByKey(MMO.HUD_SNEAK) then
  629. visible = false
  630. end
  631. -- 副驾
  632. if visible and self:IsHoreseCopilot(actor) then
  633. visible = false
  634. end
  635. self:SetHUDMpBarVisible(actor, visible)
  636. end
  637. function utils:refreshHUDHMpLabelVisible(actor)
  638. local visible = false
  639. if not self:IsSleepInCave(actor) then
  640. visible = actor:IsVisibleServerHpLabel() or (actor:GetValueByKey(MMO.HUD_PC_MOUSE_SHOW) and (not self:ActorIsDie(actor))) or (self:ActorInView(actor) and actor:GetValueByKey(MMO.HUD_HMPLabel_VISIBLE))
  641. end
  642. -- 潜行
  643. if visible and actor:GetValueByKey(MMO.HUD_SNEAK) then
  644. visible = false
  645. end
  646. -- 副驾
  647. if visible and self:IsHoreseCopilot(actor) then
  648. visible = false
  649. end
  650. self:SetHMPLabelVisible(actor, visible)
  651. end
  652. function utils:SetHUDNGBarVisible(actor, visible)
  653. local ngBar = actor.mHUDUI[MMO.HUDNGUI_BAR]
  654. if ngBar then
  655. ngBar:setVisible(visible)
  656. end
  657. local ngBorder = actor.mHUDUI[MMO.HUDNGUI_BORDER]
  658. if ngBorder then
  659. ngBorder:setVisible(visible)
  660. end
  661. end
  662. -- 内功条显示
  663. function utils:CheckHUDNGBarVisible(actor)
  664. local visible = self:ActorInView(actor) and actor:GetValueByKey(MMO.HUD_NGBAR_VISIBLE)
  665. -- 潜行
  666. if visible and actor:GetValueByKey(MMO.HUD_SNEAK) then
  667. visible = false
  668. end
  669. -- 副驾
  670. if visible and self:IsHoreseCopilot(actor) then
  671. visible = false
  672. end
  673. self:SetHUDNGBarVisible(actor, visible)
  674. end
  675. -- 血量文本
  676. function utils:SetHMPLabelVisible(actor, visible)
  677. local sprite = global.HUDManager:GetHUD(actor:GetID(), global.MMO.HUD_TYPE_BATCH_LABEL, global.MMO.HUD_LABEL_HP)
  678. if not sprite then
  679. return false
  680. end
  681. sprite:setVisible(visible)
  682. end
  683. -- HUD Name -------------------------------------------------------------------------------------------------
  684. function utils:SetHUDLabelNameVisible(actor, visible)
  685. global.HUDManager:setVisible(actor:GetID(), MMO.HUD_TYPE_BATCH_LABEL, MMO.HUD_LABEL_NAME, visible)
  686. end
  687. -- 检测名字
  688. function utils:refreshHUDLabelNameVisible(actor)
  689. local gmVisible = actor:GetValueByKey(MMO.HUD_GM_SHOW)
  690. local visible = gmVisible or actor:GetValueByKey(MMO.HUD_PC_MOUSE_SHOW) or (self:ActorInView(actor) and actor:GetValueByKey(MMO.HUD_NAMELabel_VISIBLE))
  691. -- 潜行
  692. if visible and actor:GetValueByKey(MMO.HUD_SNEAK) then
  693. visible = false
  694. end
  695. -- 副驾
  696. if self:IsHoreseCopilot(actor) then
  697. visible = false
  698. end
  699. self:SetHUDLabelNameVisible(actor, visible)
  700. end
  701. -- HUD Guild -------------------------------------------------------------------------------------------------
  702. function utils:SetHUDLabelGuildVisible(actor, visible)
  703. global.HUDManager:setVisible(actor:GetID(), MMO.HUD_TYPE_BATCH_LABEL, MMO.HUD_LABEL_GUILD, visible)
  704. end
  705. -- 检测行会
  706. function utils:refreshHUDLabelGuildVisible(actor)
  707. local visible = actor:GetValueByKey(MMO.HUD_PC_MOUSE_SHOW) or (self:ActorInView(actor) and actor:GetValueByKey(MMO.HUD_GUILDLabel_VISIBLE))
  708. -- 潜行
  709. if visible and actor:GetValueByKey(MMO.HUD_SNEAK) then
  710. visible = false
  711. end
  712. -- 副驾
  713. if visible and self:IsHoreseCopilot(actor) then
  714. visible = false
  715. end
  716. self:SetHUDLabelGuildVisible(actor, visible)
  717. end
  718. -- HUD Title -------------------------------------------------------------------------------------------------
  719. function utils:SetHUDTitleLabelVisible(actor, visible)
  720. local actorID = actor:GetID()
  721. local hudType = MMO.HUD_TYPE_BATCH_LABEL
  722. local hudMin = MMO.HUD_LABEL_PRE_NAME1
  723. for i = 0, 11 do
  724. global.HUDManager:setVisible(actorID, hudType, hudMin + i, visible)
  725. end
  726. end
  727. -- 检测Title
  728. function utils:refreshHUDLabelTitleVisible(actor)
  729. local visible = actor:GetValueByKey(MMO.HUD_PC_MOUSE_SHOW) or (self:ActorInView(actor) and actor:GetValueByKey(MMO.HUD_TITLELabel_VISIBLE))
  730. -- 潜行
  731. if visible and actor:GetValueByKey(MMO.HUD_SNEAK) then
  732. visible = false
  733. end
  734. -- 副驾
  735. if visible and self:IsHoreseCopilot(actor) then
  736. visible = false
  737. end
  738. self:SetHUDTitleLabelVisible(actor, visible)
  739. end
  740. -- 刷新 名字、行会名、顶戴
  741. function utils:refreshLabelVisible(actor)
  742. self:InitHUDVisibleValue(actor, global.MMO.HUD_NAMELabel_VISIBLE)
  743. self:InitHUDVisibleValue(actor, global.MMO.HUD_GUILDLabel_VISIBLE)
  744. self:InitHUDVisibleValue(actor, global.MMO.HUD_TITLELabel_VISIBLE)
  745. self:InitHUDVisibleValue(actor, global.MMO.HUD_TITLE_VISIBLE)
  746. self:refreshHUDLabelNameVisible(actor)
  747. self:refreshHUDLabelGuildVisible(actor)
  748. self:refreshHUDLabelTitleVisible(actor)
  749. self:refreshHUDTitleVisible(actor)
  750. end
  751. -- 顶戴、称号
  752. function utils:SetHUDTitleVisible(actor, visible, isHorseUpdate)
  753. local HUDManager = global.HUDManager
  754. local actorID = actor:GetID()
  755. if isHorseUpdate then
  756. local actorID = actor:GetID()
  757. for i = 0, 2 do
  758. if hudTitleSpriteID[i] then
  759. HUDManager:setVisible(actorID, MMO.HUD_TYPE_SPRITE, hudTitleSpriteID[i], visible)
  760. end
  761. if hudTitleLableID[i] then
  762. HUDManager:setVisible(actorID, MMO.HUD_TYPE_BATCH_LABEL, hudTitleLableID[i], visible)
  763. end
  764. end
  765. else
  766. local Box996Proxy = Facade:retrieveProxy(ProxyTable.Box996Proxy)
  767. for i = 0, 10 do
  768. local hudSprite = HUDManager:GetHUD(actorID, MMO.HUD_TYPE_SPRITE, hudTipsID[i])
  769. local hudAnim = HUDManager:GetHUD(actorID, MMO.HUD_TYPE_ANIM, animHudID[i])
  770. if hudSprite and hudSprite.isBox996 then --盒子称号 有自己的开关
  771. local hzVisible = Box996Proxy:isShowTitleByActor(actor)
  772. -- 潜行
  773. if hzVisible and actor:GetValueByKey(MMO.HUD_SNEAK) then
  774. hzVisible = false
  775. end
  776. HUDManager:setVisible(actorID, MMO.HUD_TYPE_SPRITE, hudTipsID[i], hzVisible)
  777. elseif hudAnim and hudAnim.isBox996 then --盒子称号 有自己的开关
  778. local hzVisible = Box996Proxy:isShowTitleByActor(actor)
  779. -- 潜行
  780. if hzVisible and actor:GetValueByKey(MMO.HUD_SNEAK) then
  781. hzVisible = false
  782. end
  783. HUDManager:setVisible(actorID, MMO.HUD_TYPE_ANIM, animHudID[i], hzVisible)
  784. else
  785. HUDManager:setVisible(actorID, MMO.HUD_TYPE_SPRITE, hudTipsID[i], visible)
  786. HUDManager:setVisible(actorID, MMO.HUD_TYPE_ANIM, animHudID[i], visible)
  787. end
  788. if hudTitleSpriteID[i] then
  789. HUDManager:setVisible(actorID, MMO.HUD_TYPE_SPRITE, hudTitleSpriteID[i], visible)
  790. end
  791. if hudTitleLableID[i] then
  792. HUDManager:setVisible(actorID, MMO.HUD_TYPE_BATCH_LABEL, hudTitleLableID[i], visible)
  793. end
  794. end
  795. end
  796. end
  797. -- 刷新 称号、顶戴
  798. function utils:refreshHUDTitleVisible(actor, isHorseUpdate)
  799. local visible = self:ActorInView(actor) and actor:GetValueByKey(MMO.HUD_TITLE_VISIBLE)
  800. -- 潜行
  801. if visible and actor:GetValueByKey(MMO.HUD_SNEAK) then
  802. visible = false
  803. end
  804. -- 副驾
  805. if visible and self:IsHoreseCopilot(actor) then
  806. visible = false
  807. end
  808. self:SetHUDTitleVisible(actor, visible, isHorseUpdate)
  809. end
  810. ---------------------------------------------------------------------------------------------------------------------
  811. -- 英雄(非主玩家)
  812. -- 检测英雄显示状态
  813. function utils:CheckHero(actor)
  814. return not self:IsMyHero(actor)
  815. end
  816. -- 设置状态
  817. function utils:SetHeroVisible(actor, visible)
  818. local node = actor:GetNode()--GetAvatarNode()
  819. if node then
  820. node:setVisible(visible)
  821. end
  822. end
  823. -- 刷新
  824. function utils:refreshHeroVisible(actor)
  825. local visible = self:IsMyHero(actor) or (self:ActorInView(actor) and CHECK_SETTING(MMO.SETTING_IDX_HERO_HIDE) ~= 1 and actor:GetValueByKey(MMO.HERO_VISIBLE))
  826. self:SetHeroVisible(actor, visible)
  827. end
  828. ------------------
  829. -- 玩家
  830. function utils:CheckPlayer(actor)
  831. local mainPlayerID = global.gamePlayerController:GetMainPlayerID()
  832. if not mainPlayerID then
  833. return false
  834. end
  835. if actor:IsMainPlayer() then
  836. return true
  837. end
  838. if self:IsHoreseCopilot(actor) then
  839. return false
  840. end
  841. -- 清理怪
  842. if self:IsCanClearMonster(actor) then
  843. return false
  844. end
  845. return true
  846. end
  847. function utils:SetPlayerVisible(actor, visible)
  848. local node = actor:GetNode()--GetAvatarNode()
  849. if node then
  850. node:setVisible(visible)
  851. end
  852. end
  853. -- 刷新
  854. function utils:refreshPlayerVisible(actor)
  855. local visible = actor:IsMainPlayer() or (self:ActorInView(actor) and CHECK_SETTING(MMO.SETTING_IDX_PLAYER_SHOW) ~= 1 and actor:GetValueByKey(MMO.PLAYER_VISIBLE))
  856. -- 潜行
  857. if visible and actor:GetValueByKey(MMO.HUD_SNEAK) then
  858. visible = false
  859. end
  860. -- 副驾
  861. if visible and self:IsHoreseCopilot(actor) then
  862. visible = false
  863. end
  864. self:SetPlayerVisible(actor, visible)
  865. end
  866. -- 检测乙方阵营
  867. function utils:CheckPlayerB(actor)
  868. return actor:IsSameCamp()
  869. end
  870. function utils:CheckSamePlayer(actor)
  871. if (not actor:IsMainPlayer()) and actor:GetValueByKey(MMO.PLAYER_B_VISIBLE) and CHECK_SETTING(MMO.SETTING_IDX_PLAYER_SHOW_FRIEND) == 1 then
  872. return false
  873. end
  874. return true
  875. end
  876. function utils:refreshPlayerBVisible(actor)
  877. local visible = actor:IsMainPlayer() or (self:ActorInView(actor) and self:CheckSamePlayer(actor) and CHECK_SETTING(MMO.SETTING_IDX_PLAYER_SHOW) ~= 1)
  878. -- 潜行
  879. if visible and actor:GetValueByKey(MMO.HUD_SNEAK) then
  880. visible = false
  881. end
  882. -- 副驾
  883. if visible and self:IsHoreseCopilot(actor) then
  884. visible = false
  885. end
  886. self:SetPlayerVisible(actor, visible)
  887. end
  888. function utils:CheckOwnSidePlayerVisible(actor)
  889. if not actor:IsPlayer() then
  890. return
  891. end
  892. if actor:IsMainPlayer() then
  893. return
  894. end
  895. self:InitHUDVisibleValue(actor, global.MMO.PLAYER_B_VISIBLE)
  896. if CHECK_SETTING(MMO.SETTING_IDX_PLAYER_SHOW_FRIEND) == 1 then
  897. self:refreshPlayerBVisible(actor)
  898. global.Facade:sendNotification(global.NoticeTable.UpdatePlayerFeatureVisible, actor)
  899. end
  900. end
  901. ---------------------------------------------------------------------------------------------------------------------
  902. function utils:CheckMonster(actor)
  903. if not actor then
  904. return false
  905. end
  906. -- 清理尸体
  907. if self:IsCanClearMonster(actor) then
  908. return false
  909. end
  910. -- 隐藏怪
  911. if not actor:IsHaveMaster() and self:IsHideMonster(actor) then
  912. return false
  913. end
  914. -- 召唤物
  915. local mainPlayerID = global.gamePlayerController:GetMainPlayerID()
  916. if CHECK_SETTING(MMO.SETTING_IDX_MONSTER_PET_VISIBLE) == 1 and actor:IsHaveMaster() and actor:GetMasterID() ~= mainPlayerID then
  917. return false
  918. end
  919. return true
  920. end
  921. function utils:SetMonsterVisible(actor, visible)
  922. local node = actor:GetNode()--GetAvatarNode()
  923. if node then
  924. node:setVisible(visible==true)
  925. end
  926. end
  927. function utils:refreshMonsterVisible(actor)
  928. local visible = false
  929. if not self:IsSleepInCave(actor) then
  930. visible = self:IsGate(actor) or self:IsWall(actor) or (self:ActorInView(actor) and actor:GetValueByKey(MMO.MONSTER_VISIBLE))
  931. end
  932. self:SetMonsterVisible(actor, visible)
  933. end
  934. -- Init HUD visible -------------------------------------------------------------------------------------------------
  935. local KeyFunc = {
  936. [MMO.HUD_HPBAR_VISIBLE] = function (actor) return utils:CheckHUDHp(actor) end,
  937. [MMO.HUD_MPBAR_VISIBLE] = function (actor) return utils:CheckHUDMp(actor) end,
  938. [MMO.HUD_NGBAR_VISIBLE] = function (actor) return utils:CheckHUDNG(actor) end,
  939. [MMO.HUD_HMPLabel_VISIBLE] = function (actor) return utils:CheckHUDHMPLabel(actor) end,
  940. [MMO.HUD_TITLE_VISIBLE] = function (actor) return utils:CheckHUDTitle(actor) end,
  941. [MMO.HUD_NAMELabel_VISIBLE] = function (actor) return utils:CheckHUDLabelName(actor) end,
  942. [MMO.HUD_GUILDLabel_VISIBLE] = function (actor) return utils:CheckHUDLabelGuild(actor) end,
  943. [MMO.HUD_TITLELabel_VISIBLE] = function (actor) return utils:CheckHUDLabelTitle(actor) end,
  944. [MMO.HERO_VISIBLE] = function (actor) return utils:CheckHero(actor) end,
  945. [MMO.MONSTER_VISIBLE] = function (actor) return utils:CheckMonster(actor) end,
  946. [MMO.PLAYER_VISIBLE] = function (actor) return utils:CheckPlayer(actor) end,
  947. [MMO.PLAYER_B_VISIBLE] = function (actor) return utils:CheckPlayerB(actor) end,
  948. [MMO.MONSTER_NORMAL] = function (actor) return utils:IsNormalMonster(actor) end,
  949. [MMO.MONSTER_CLEAR] = function (actor) return utils:IsClearMonster(actor) end,
  950. }
  951. -- 初始化 actor 显示数据
  952. function utils:InitHUDVisibleValue(actor, key)
  953. if KeyFunc[key] then
  954. actor:SetKeyValue(key, KeyFunc[key](actor))
  955. end
  956. end
  957. -----------------------------------------------------------------------------------------------------------------------
  958. return utils