源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3599 line
115 KiB

  1. TaskModel = TaskModel or BaseClass(BaseVo)
  2. local TaskModel = TaskModel
  3. --任务内容类型定义,任务后台有配置
  4. TaskTipType=
  5. {
  6. TYPE0=0, --开始对话
  7. TYPE1=1, --击败怪物
  8. TYPE2=11, --完成副本
  9. TYPE6=3, --收集物品(打怪)
  10. TYPE7=5, --与npc对话
  11. TYPE8= 6, --开始对话(不可选)
  12. TYPE9=7, --结束对话(不可选)
  13. TYPE16=12,-- 探索场景
  14. TYPE18=4,-- 采集
  15. -- TYPE41=18,--天命觉醒点亮星格
  16. TYPE80=80,--断级主线
  17. TYPE100 = 2, --击杀boss
  18. TYPE101 = 8, --强化装备
  19. TYPE102 = 9, --完成某类型副本
  20. TYPE103 = 10, --单次发条密室副本中获得x经验
  21. TYPE104 = 13, --添加好友
  22. TYPE105 = 14, --加入社团
  23. TYPE106 = 15, --社团装备回收
  24. TYPE107 = 16, --完成社团活动
  25. TYPE108 = 17, --捐献一件装备到社团仓库
  26. TYPE109 = 19, --从市场购买
  27. TYPE110 = 20, --在市场上架一个物品
  28. TYPE111 = 21, --符文之塔
  29. TYPE23 = 23, --物品合成
  30. TYPE24 = 24, --每日活跃度达到XXX点
  31. TYPE25 = 25, --五转天命星格觉醒
  32. TYPE26 = 26, --装备吞噬
  33. TYPE27 = 27, --击杀指定Boss
  34. TYPE28 = 28, --钓鱼之路
  35. TYPE29 = 29, --进入完成某个副本
  36. TYPE31 = 31, --竞技场次数
  37. TYPE34 = 34, --进入完成某类副本
  38. TYPE35 = 35, --可选对话任务
  39. TYPE36 = 36, --装备附能
  40. TYPE37 = 37, --副本波数进度
  41. TYPE38 = 38, --送信任务
  42. TYPE39 = 39, --装备升星
  43. TYPE40 = 40, --商城购买
  44. -------------------------9.16新增
  45. TYPE41 = 41, --好友送礼
  46. TYPE42 = 42, --好友亲密度
  47. TYPE43 = 43, --进阶系统升级
  48. TYPE44 = 44, --升品之路
  49. TYPE45 = 45, --唤神升级
  50. TYPE46 = 46, --星辰升级
  51. TYPE47 = 47, --宠物升级
  52. TYPE48 = 48, --晒娃
  53. TYPE49 = 49, --装备圣物
  54. TYPE50 = 50, --圣物寻宝
  55. TYPE51 = 51, --解锁地狱摩托
  56. TYPE52 = 52, --转职目标
  57. -------------------------
  58. TYPE53 = 53, --龙神抽奖
  59. TYPE54 = 54, --装备套装
  60. TYPE55 = 55, --战魂强化
  61. TYPE56 = 56, --进阶目标(进阶到一定阶数)
  62. TYPE57 = 57, --完成预期任务
  63. TYPE58 = 58, --宝宝同心值
  64. TYPE59 = 59, --战力
  65. TYPE60 = 60, --任意主动技能升级次数
  66. TYPE61 = 61, --指定商店购买技能书
  67. TYPE62 = 62, --任意商店技能书购买
  68. TYPE1002 = 1002, --成就任务
  69. TYPE1004 = 1004, --七日目标
  70. TYPE9998 = 9998, --客户端自定义日常类型
  71. }
  72. --任务类型
  73. TaskType =
  74. {
  75. MAIN_LINE=1, --主线任务
  76. EXTENSION_LINE=2, --支线任务
  77. TRUN_LINE=3, --转职任务
  78. LIMIT_LINE=4, --限时任务
  79. PSIONIC_LINE=5, --圣物任务
  80. GUILD_LINE=6, --社团任务
  81. BOUNTY_LINE=7, --赏金任务
  82. ACTIVITY_LINE=8, --活跃度任务
  83. ---------------------------------
  84. TREASURE = 1001, --藏宝图任务
  85. ACHIEVE = 1002, --成就任务
  86. DAILY_ACTIVITE = 1003, --日常活跃任务
  87. SEVEN_DAY_TARGET = 1004, -- 七日目标任务
  88. }
  89. --任务种类
  90. TaskKind =
  91. {
  92. TALK_KIND=0, --对话任务
  93. KILL_MONSTER_KIND=1, --杀怪任务
  94. COLLECT_KIND=2, --收集任务
  95. CAI_JI_KIND=3, --收集任务
  96. HU_SONG_KIND=4, --护送任务
  97. TAN_SUO_KIND=5, --探索任务
  98. DUN_KIND = 6, --副本任务
  99. ITEM_BACK = 7, --收集回收任务
  100. STREN = 8, --装备精炼任务
  101. RUNE_DUN = 9, --符文副本任务
  102. EXP_DUN = 10, --发条密室任务
  103. }
  104. TaskModel.TaskTypeStr =
  105. {
  106. [TaskType.MAIN_LINE]="主线",
  107. [TaskType.EXTENSION_LINE]="支线",
  108. [TaskType.TRUN_LINE]="转职",
  109. [TaskType.LIMIT_LINE]="限时",
  110. [TaskType.GUILD_LINE]="社团",
  111. [TaskType.BOUNTY_LINE]="日常",
  112. [TaskType.PSIONIC_LINE]="圣物",
  113. [TaskType.ACTIVITY_LINE]="活跃",
  114. }
  115. TaskModel.TaskTypeStr3 =
  116. {
  117. [TaskType.MAIN_LINE]="主线",
  118. [TaskType.EXTENSION_LINE]="支线",
  119. [TaskType.TRUN_LINE]="转职",
  120. [TaskType.LIMIT_LINE]="限时",
  121. [TaskType.GUILD_LINE]="社团",
  122. [TaskType.BOUNTY_LINE]="日常",
  123. [TaskType.PSIONIC_LINE]="圣物",
  124. [TaskType.ACTIVITY_LINE]="活跃",
  125. }
  126. TaskModel.TaskTypeStr2 =
  127. {
  128. [TaskType.MAIN_LINE]="主线",
  129. [TaskType.EXTENSION_LINE]="支线",
  130. [TaskType.TRUN_LINE]="转职",
  131. [TaskType.LIMIT_LINE]="限时",
  132. [TaskType.GUILD_LINE]="社团",
  133. [TaskType.BOUNTY_LINE]="日常",
  134. [TaskType.PSIONIC_LINE]="圣物",
  135. [TaskType.ACTIVITY_LINE]="活跃",
  136. [TaskType.TREASURE]="宝图",
  137. [TaskType.ACHIEVE]="成就",
  138. [TaskType.DAILY_ACTIVITE]="活跃",
  139. }
  140. TaskModel.Color =
  141. {
  142. WHITE= "#ffffff",
  143. GREEN = "#2CF66F",
  144. PINK = "#F257FC",
  145. YELLOW ="#FBB73F",
  146. ORANGE="#ffb346",
  147. BLUE = "#65A9FC"
  148. }
  149. TaskModel.ColorNoSymbols =
  150. {
  151. WHITE= Color(1, 1, 1, 1),
  152. GREEN = Color(44/255, 246/255, 44/255, 1),
  153. PINK = Color(242/255, 87/255, 252/255, 1),
  154. YELLOW = Color(251/255, 183/255, 63/255, 1),
  155. ORANGE= Color(255/255, 179/255, 70/255, 1),
  156. BLUE = Color(101/255, 169/255, 252/255, 1),
  157. }
  158. TaskModel.TaskPrefixIdStr =
  159. {
  160. [3070001]= {str = "推荐", color = TaskModel.Color.ORANGE},
  161. [3070002]= {str = "日常", color = TaskModel.Color.ORANGE},
  162. }
  163. TaskModel.QualityColor = {
  164. [0] = TaskModel.Color.WHITE,
  165. [1] = TaskModel.Color.GREEN,
  166. [2] = TaskModel.Color.BLUE,
  167. [3] = TaskModel.Color.PINK,
  168. [4] = TaskModel.Color.YELLOW,
  169. [5] = TaskModel.Color.ORANGE,
  170. }
  171. TaskModel.ColorToImg = {
  172. [TaskModel.Color.WHITE] = "task_item_color_green",
  173. [TaskModel.Color.GREEN] = "task_item_color_green",
  174. [TaskModel.Color.BLUE] = "task_item_color_blue",
  175. [TaskModel.Color.PINK] = "task_item_color_pink",
  176. [TaskModel.Color.YELLOW] = "task_item_color_orange",
  177. [TaskModel.Color.ORANGE] = "task_item_color_orange",
  178. }
  179. --转职任务,boss战 的任务id
  180. TaskModel.TaskTurnBossTaskId =
  181. {
  182. [5] = true,
  183. [10] = true,
  184. [15] = true,
  185. [20] = true,
  186. [25] = true,
  187. }
  188. --转职任务,boss战 推荐战力
  189. TaskModel.TaskTurnBossPower =
  190. {
  191. [5] = 250000,
  192. [10] = 1250000,
  193. [15] = 4500000,
  194. [20] = 12500000,
  195. [25] = 25000000,
  196. }
  197. --任务类型27,击杀类型(每个类型自己配置)
  198. TaskModel.TYPE27_KILL_TYPE =
  199. {
  200. [1] = 3, --赏金boss
  201. }
  202. TaskModel.FirstTaskId = 10010 --第一个任务id
  203. TaskModel.DragonTaskId = 10000100 --飞龙任务
  204. TaskModel.ADD_SPEED_DISTANCE = 7 --加速距离
  205. TaskModel.ShowArrowLv = 50 --显示任务提示箭头的等级
  206. TaskModel.AutoDoNewMainTaskLv = 96 --一定等级以下,收到30000协议会主动优先执行主线任务
  207. TaskModel.AutoOpViewStopTask = 100 --一定等级以下,打开特殊界面要停止任务
  208. function TaskModel:__init()
  209. TaskModel.Instance = self
  210. self:InitData()
  211. end
  212. function TaskModel:InitData( )
  213. self._receivedTaskList={}
  214. self._canTaskList={}
  215. self.all_task_list = {}
  216. self.circle_task_info = {} ----社团/赏金任务进度
  217. self.circle_cache_reward = nil --完成的奖励
  218. self.need_show_circle_tip = false --弹出跑环tip
  219. self.lask_bounty_process = nil --上一次完成的赏金任务进度
  220. self.lask_guild_process = nil --上一次完成的社团任务进度
  221. self.now_task_id = nil -- 同个npc下面可能同时会有主线和支线任务,12101协议任务数据可能会有2条,这样客户端就不知道应该选择哪个任务来触发相关操作, 所以在开始任务前,客户端先记下当前任务id
  222. self.game_start_request = true --游戏启动,要请求一次任务数据
  223. self.followNpcList = nil --跟随npc
  224. self.last_task_id_cache = nil --保存上一个完成的任务id
  225. self.last_task_type_cache = nil --保存上一个完成的任务类型
  226. self.is_auto_task = false --是否正在自动任务,点击任务后设为true,点取消挂机后设为false
  227. self.need_do_task_type = 0 --需要马上做的任务类型,用于赏金或社团任务,因为这两种类型的接任务过程不通用
  228. self.last_time = 0 --上次直接完成任务的时间
  229. self.is_stop = false --任务是否暂停
  230. self.default_task_arrow_list = {}--断级主线任务已显示箭头列表
  231. self.first_receive = false --第一次收到30000
  232. self.need_task = false --切场景后要寻路的数据
  233. self.need_accept = nil --需要升级接的任务, 一般是自动接的任务,要等升级了才能自动接
  234. self.last_finish_task_id = 0 --上一个完成的任务
  235. self.scmd12101Send = false --做完任务,有时服务端推12101过来,这种情况就忽略掉,不处理
  236. self.proto_count = 0 --必须等12005和12002返回才能继续寻路
  237. self.wait_30003 = false
  238. self.wait_30004 = false
  239. self.last_task_scene = nil
  240. self.need_open_rein = false --需要打开转职界面
  241. self.accept_power_task_id = false --接取到战力引导任务的id
  242. self.first_trigger_0 = false --触发标志,只有第一次触发才滚动任务栏
  243. self.first_trigger_1 = false
  244. self.first_trigger_2 = false
  245. self.first_trigger_3 = false
  246. self.first_trigger_4 = false
  247. self.wait_upgrade = false --等待升级后先做主线
  248. -- self.opening_circle_buy_tip = false--快速跑环任务界面展示中
  249. -- self.wait_circle_buy_tip_close = false--花钱跑环任务的话,停止当前任务,等界面关闭时再继续任务
  250. self.circle_auto_use_shoe = {}--非R玩家跑环执行的时候,需要记录是否自动小飞鞋
  251. self.circle_use_clock = false--第一次不用倒计时,点击确定按钮之后使用,中断跑环流程的时候重置不用倒计时
  252. self.need_check_monster = false
  253. self.is_dungeon_finish = false
  254. self.fly_shoe_end_need_task = false
  255. self.collect_task_id = false --收集任务的配置了多个点,使用飞鞋的时候需要使用上次选中的点
  256. self.finish_task_list = {} --已完成任务列表
  257. self.no_main_task_level = 0 --断级时当前主线任务对应的等级,用作标识是否弹可登录提示,同一个等级只触发弹一次可挑战提示(刚好触发断级的那一刻)
  258. self.temp_finish_task_info = {}--标记完成的表,每次有新的已完成任务的时候,就把任务栏滚动容器位置置顶
  259. self:InitTaskListenList()
  260. self.guild_kill_monster_num = 0--断击杀非主线怪物一定数量之后,拉玩家去做主线,每次调用进行任务的时候清零,20001返回的时候累计
  261. self.is_first_login_game_to_do_task = true --是否是第一次登陆游戏做任务
  262. self.is_auto_tip_new_main_line = nil --是否是自动滚动导致关掉提示引导
  263. self.cur_tips_daily_task_item = false --当前推荐的日常活跃任务
  264. self.recorded_finish_turn_task_lv = RoleManager.Instance.mainRoleInfo.level -- 上次完成转职任务的等级记录
  265. end
  266. --[[@
  267. :
  268. id存在的
  269. GlobalEventSystem:Bind(TaskEvent.ANS_FINISHED_TASK_LIST, on_task_finish)
  270. :
  271. :
  272. ]]
  273. function TaskModel:InitTaskListenList( )
  274. --所有需要侦听的任务列表
  275. self.task_listen_list = {}
  276. --功能开启配置
  277. for k,v in pairs(Config.Moduleid) do
  278. if v.task_id ~= 0 then
  279. self.task_listen_list[v.task_id] = true
  280. end
  281. end
  282. for k,v in pairs(Config.Modulesub) do
  283. if v.task_id ~= 0 then
  284. self.task_listen_list[v.task_id] = true
  285. end
  286. end
  287. --任务引导配置
  288. for k,v in pairs(Config.ConfigHelper.Task) do
  289. if k and k ~= 0 then
  290. self.task_listen_list[k] = true
  291. end
  292. end
  293. --羁绊任务
  294. for k,v in pairs(MateConst.SingleDogTask) do
  295. self.task_listen_list[v] = true
  296. end
  297. --剧情
  298. for k,v in pairs(Config.ConfigTaskEffect.TaskStoryID) do
  299. self.task_listen_list[k] = true
  300. end
  301. --摩托解锁任务
  302. for k,v in pairs(NewerTaskConst.PartTaskId) do
  303. self.task_listen_list[k] = true
  304. end
  305. --章节最后一个任务
  306. self.task_listen_list[Config.ConfigTaskEffect.LastChapterTaskId] = true
  307. --经验副本限制红点展示任务
  308. self.task_listen_list[ExpDunModel.Newly_Limit_Taskid] = true
  309. -- 宝宝开启任务
  310. self.task_listen_list[Config.Moduleid[165].task_id] = true
  311. -- 首充打开任务添加
  312. self.task_listen_list[CustomActivityModel.FIRST_RECHARGE_TASK_ID] = true
  313. --首充广告界面
  314. self.task_listen_list[CustomActivityModel.FIRST_RECHARGE_TIP_TASK_ID] = true
  315. --招财猫
  316. self.task_listen_list[CustomActivityModel.CAT_FOTANA_TASK_ID] = true
  317. --七日登陆
  318. self.task_listen_list[CustomActivityModel.SEVEN_LOGIN_TASK_ID] = true
  319. --VIP体验卡
  320. self.task_listen_list[CustomActivityModel.VIP_EX_CARD_TASK_ID] = true
  321. --V3强弹
  322. for i,v in ipairs(CustomActivityModel.VIP_THREE_TASK_ID_LIST) do
  323. self.task_listen_list[v] = true
  324. end
  325. end
  326. function TaskModel:GetDefalutTaskCurTaskAndDes()
  327. --主线断层增加任务提示:活跃度提示,经验副本,经验跑环,社团跑环
  328. local is_can_do_daily_task = false
  329. local is_guild = RoleManager.Instance.mainRoleInfo and RoleManager.Instance.mainRoleInfo.guild_id>0
  330. local is_can_do_guild_task = false
  331. local is_can_do_exp_dun = false
  332. local is_open_daily = false
  333. local daily_task_info = TaskModel:getInstance():GetTaskByType(TaskType.BOUNTY_LINE)
  334. local guild_task_info = TaskModel:getInstance():GetCircleTaskInfo(TaskType.GUILD_LINE)
  335. local live = DailyModel.Instance:GetLivenessInfoLive()
  336. -- if live < 10 then
  337. -- is_open_daily = true
  338. if daily_task_info then
  339. is_can_do_daily_task = true
  340. elseif live < 120 then
  341. is_open_daily = true
  342. elseif ExpDunModel:getInstance():GetNextWaveFitPowerRed() and ExpDunModel:getInstance():GetNextWaveFitLevel() then
  343. is_can_do_exp_dun = true
  344. -- elseif guild_task_info.cur_progress < 10 then
  345. -- is_can_do_guild_task = true
  346. -- elseif ExpDunModel:getInstance():GetNextWaveFitLevel() then
  347. -- is_can_do_exp_dun = true
  348. -- elseif guild_task_info.cur_progress < 20 then
  349. -- is_can_do_guild_task = true
  350. else
  351. is_open_daily = true
  352. end
  353. local content = "<color=#ff3232><u>查看升级途径</u></color>"
  354. -- if is_open_daily then
  355. -- content = "推荐完成<color=#2CF66F>日常活跃</color>"
  356. if is_can_do_daily_task then
  357. content = "完成<color=#2CF66F>经验跑环</color>"
  358. -- elseif is_can_do_guild_task then
  359. -- content = "推荐完成<color=#2CF66F>社团跑环</color>"
  360. elseif is_can_do_exp_dun then
  361. content = "闯关<color=#2CF66F>经验闯关</color>"
  362. else
  363. if self.cur_tips_daily_task_item then
  364. content = string.format("推荐<color=#2CF66F>%s</color>", self.cur_tips_daily_task_item.name)
  365. else
  366. content = "推荐进行日常任务"
  367. end
  368. end
  369. return is_open_daily, is_can_do_daily_task, is_can_do_guild_task, is_can_do_exp_dun, content
  370. end
  371. function TaskModel:__delete( )
  372. self:StopLoginTaskTimer()
  373. end
  374. function TaskModel:DefaultTask()
  375. local temp = nil
  376. local playerLv = RoleManager:getInstance():GetMainRoleVo().level
  377. --任务做了特殊处理
  378. if 53 < playerLv and playerLv < 56 then
  379. temp = ConfigItemMgr.Instance:GetTaskData(10540)
  380. else
  381. temp = ConfigItemMgr.Instance:GetTaskData(self.last_finish_task_id)
  382. end
  383. if temp then
  384. local data = ConfigItemMgr.Instance:GetTaskData(temp.next)
  385. if data then
  386. --主线断层增加任务提示:活跃度提示,经验副本,经验跑环,社团跑环
  387. local is_open_daily, is_can_do_daily_task, is_can_do_guild_task, is_can_do_exp_dun, content = self:GetDefalutTaskCurTaskAndDes()
  388. local lv = data.level
  389. local _nextMain=TaskVo.New()
  390. _nextMain.mainTip=true --假任务唯一的属性
  391. _nextMain.acceptType=1
  392. _nextMain.id = Config.ConfigTaskEffect.DefaultTaskId
  393. _nextMain.level = lv
  394. _nextMain.sortKey = Config.ConfigTaskEffect.TaskTypeSort[99]
  395. _nextMain.type = TaskType.MAIN_LINE
  396. _nextMain.order = 0
  397. local cfg = Config.ConfigTaskEffect.NextTaskName
  398. local task_name
  399. if cfg[lv] then
  400. task_name = cfg[lv]
  401. else
  402. task_name = string.format("升级到%s级", lv)
  403. end
  404. _nextMain.taskName = task_name or ""
  405. _nextMain.description = string.format("等级提升到<color=#2CF66F>%s</color>级,打开活动界面,里面有各种日常活动,奖励多多。", lv)
  406. _nextMain.tipContent = content
  407. local tasktipvo3 = TaskTipsVo.New()
  408. tasktipvo3.type = TaskTipType.TYPE80
  409. _nextMain.taskTips = {tasktipvo3}
  410. _nextMain.is_can_do_daily_task = is_can_do_daily_task
  411. _nextMain.is_can_do_guild_task = is_can_do_guild_task
  412. _nextMain.is_can_do_exp_dun = is_can_do_exp_dun
  413. _nextMain.is_open_daily = is_open_daily
  414. self._nextMain=_nextMain
  415. --断级时弹一次可挑战提示 记录当前断级的任务等级,同个任务等级断级只弹一次提示
  416. if data.level ~= self.no_main_task_level then --触发断级,上线的触发会直接无视
  417. -- BaseDungeonModel:getInstance():CheckDungeonTip()--断级的副本可挑战提示屏蔽
  418. end
  419. self.no_main_task_level = data.level
  420. else
  421. self._nextMain = nil
  422. end
  423. end
  424. end
  425. function TaskModel:getInstance()
  426. if TaskModel.Instance == nil then
  427. TaskModel.New()
  428. end
  429. return TaskModel.Instance
  430. end
  431. --返回登录,清除缓存数据,
  432. function TaskModel:ClearData()
  433. self:InitData()
  434. end
  435. --获取任务面板的选项卡设置
  436. function TaskModel:GetTabData(task_type)
  437. local data = {}
  438. for k,v in pairs(self.all_task_list) do
  439. --进度排序
  440. if self:IsNeedClickTask(v) then
  441. local tip = self:GetExtendSpecialTip(v)
  442. if tip and tip.isFinish==1 then
  443. v.progressState = 1
  444. else
  445. v.progressState = 0
  446. end
  447. else
  448. if v.target_num and v.target_num>0 then
  449. v.progressState = self:IsTaskProgressFinish(v) and 1 or 0
  450. else
  451. v.progressState = 0
  452. end
  453. end
  454. end
  455. self.all_task_list = self:SortFun(self.all_task_list)
  456. for i,v in ipairs(self.all_task_list) do
  457. if v.type == task_type then
  458. table.insert(data, v)
  459. end
  460. end
  461. return data
  462. end
  463. --根据id获取任务
  464. function TaskModel:GetTaskById( task_id )
  465. for k,v in pairs(self.all_task_list) do
  466. if v.id == task_id then
  467. return v
  468. end
  469. end
  470. end
  471. --获取已接的一个任务 根据任务类型
  472. function TaskModel:GetTaskByType( task_type , show)
  473. for k,v in pairs(self._receivedTaskList) do
  474. if v.type == task_type then
  475. return v, 1
  476. end
  477. end
  478. --转职还要判断可接
  479. if task_type == TaskType.TRUN_LINE then
  480. for k,v in pairs(self._canTaskList) do
  481. if v.type == task_type then
  482. return v, 2
  483. end
  484. end
  485. end
  486. end
  487. --获取当前正在做的任务
  488. function TaskModel:GetCurTask( )
  489. if self.now_task_id then
  490. for k,v in pairs(self.all_task_list) do
  491. if v.id == self.now_task_id then
  492. return v
  493. end
  494. end
  495. --判断是否赏金或者社团任务, 用于寻路
  496. if self.now_task_id == Config.ConfigTaskEffect.bountyTaskTipId then
  497. return self:GetBountyTipTask()
  498. elseif self.now_task_id == Config.ConfigTaskEffect.guildTaskTipId then
  499. return self:GetGuildTipTask()
  500. end
  501. end
  502. end
  503. --获取主界面上的任务推送数据 need_handle:是否需要把可接支线合并起来
  504. function TaskModel:GetMainUITaskData(need_handle)
  505. local is_guild = RoleManager.Instance.mainRoleInfo and RoleManager.Instance.mainRoleInfo.guild_id>0
  506. -------------------------
  507. local list = {}
  508. local main = false
  509. local extension = false
  510. local daily = false
  511. local other = false
  512. local extension_num = 0 --可接支线数量
  513. local turn = false -- 2020年2月19日新增:转职任务
  514. local tmp = {}
  515. for i,v in ipairs(self._receivedTaskList) do
  516. if v.type == TaskType.MAIN_LINE then
  517. if main == false then
  518. main = true
  519. table.insert(tmp, v)
  520. end
  521. elseif v.type == TaskType.EXTENSION_LINE then
  522. table.insert(list, v)
  523. elseif v.type == TaskType.BOUNTY_LINE then
  524. --日常任务显示id(完成这个任务才显示)
  525. local is_show_task_finish = TaskModel:getInstance():IsTaskFinished(Config.ConfigTaskEffect.DailyCircleShowTaskId)
  526. if is_show_task_finish then
  527. if not self:GetCircleExtraTask( TaskType.BOUNTY_LINE ) then
  528. table.insert(list, v)
  529. end
  530. end
  531. elseif v.type == TaskType.GUILD_LINE then
  532. if is_guild then
  533. if not self:GetCircleExtraTask( TaskType.GUILD_LINE ) then
  534. table.insert(list, v)
  535. end
  536. end
  537. elseif v.type == TaskType.LIMIT_LINE then
  538. table.insert(list, v)
  539. elseif v.type == TaskType.TRUN_LINE then
  540. if turn == false then
  541. table.insert(list, v)
  542. turn = true
  543. end
  544. elseif v.type == TaskType.PSIONIC_LINE then -- 圣物任务不显示
  545. -- table.insert(list, v)
  546. else
  547. if other == false then
  548. other = true
  549. table.insert(list, v)
  550. end
  551. end
  552. end
  553. for i,v in ipairs(self._canTaskList) do
  554. if v.type == TaskType.MAIN_LINE then
  555. if main == false then
  556. main = true
  557. table.insert(tmp, v)
  558. end
  559. elseif v.type == TaskType.EXTENSION_LINE then
  560. table.insert(list, v)
  561. -- if not need_handle then
  562. -- v.sortKey = Config.ConfigTaskEffect.TaskTypeSort[98] --可接支线的排序
  563. -- table.insert(list, v)
  564. -- end
  565. -- extension_num = extension_num + 1
  566. elseif v.type == TaskType.BOUNTY_LINE then
  567. table.insert(list, v)
  568. elseif v.type == TaskType.GUILD_LINE then
  569. if is_guild then
  570. table.insert(list, v)
  571. end
  572. elseif v.type == TaskType.LIMIT_LINE then
  573. table.insert(list, v)
  574. elseif v.type == TaskType.TRUN_LINE then
  575. if turn == false then
  576. v.order = 501
  577. table.insert(list, v)
  578. turn = true
  579. end
  580. elseif v.type == TaskType.PSIONIC_LINE then
  581. -- table.insert(list, v)
  582. else
  583. if other == false then
  584. other = true
  585. table.insert(list, v)
  586. end
  587. end
  588. end
  589. --[[--插入可接的赏金任务和社团任务(需求修改,不需要插入假任务)
  590. local taskVo = self:GetBountyTipTask()
  591. if taskVo then
  592. table.insert(list, taskVo)
  593. end
  594. taskVo = self:GetGuildTipTask()
  595. if taskVo then
  596. if is_guild then
  597. table.insert(list, taskVo)
  598. end
  599. end--]]
  600. --要插入跑环的十环领取任务
  601. local taskVo = self:GetCircleExtraTask( TaskType.BOUNTY_LINE )
  602. if taskVo then
  603. table.insert(list, taskVo)
  604. end
  605. local taskVo = self:GetCircleExtraTask( TaskType.GUILD_LINE )
  606. if taskVo then
  607. table.insert(list, taskVo)
  608. end
  609. local taskVo = false
  610. if turn == false then
  611. taskVo = self:GetTurnTipTask()
  612. if taskVo then
  613. table.insert(list, taskVo)
  614. end
  615. end
  616. if GetModuleIsOpen(424) then -- 藏宝图任务
  617. local normal_treasure_task = self:GetTreasureTask(TreasureMapConst.Normal) -- 普通藏宝任务
  618. if normal_treasure_task then
  619. table.insert(list, normal_treasure_task)
  620. end
  621. local advance_treasure_task = self:GetTreasureTask(TreasureMapConst.Advance) -- 高级藏宝任务
  622. if advance_treasure_task then
  623. table.insert(list, advance_treasure_task)
  624. end
  625. end
  626. -- --合并支线
  627. -- if extension_num > 0 then
  628. -- local taskVo = TaskVo.New()
  629. -- taskVo.level = 1
  630. -- local str = TaskModel.TaskTypeStr3[TaskType.EXTENSION_LINE]
  631. -- taskVo.description = string.format("<color=#2CF66F>有%d个可接取的支线任务</color>", extension_num)
  632. -- taskVo.taskName = string.format("%s任务", str)
  633. -- taskVo.type = TaskType.EXTENSION_LINE
  634. -- taskVo.isTipTask = true
  635. -- taskVo.need_find_way = 1
  636. -- taskVo.target_num = 0
  637. -- taskVo.order = 0
  638. -- taskVo.sortKey = Config.ConfigTaskEffect.TaskTypeSort[98]
  639. -- taskVo.id = Config.ConfigTaskEffect.extentTaskTipId
  640. -- taskVo.tipContent = string.format("有%d个可接取的支线任务", extension_num)
  641. -- table.insert(list, taskVo)
  642. -- end
  643. for k,v in pairs(list) do
  644. if self:IsNeedClickTask(v) then
  645. local tip = self:GetExtendSpecialTip(v)
  646. if tip and tip.isFinish==1 then
  647. v.progressState = 1
  648. else
  649. v.progressState = 0
  650. end
  651. else
  652. if v.target_num>0 then
  653. v.progressState = self:IsTaskProgressFinish(v) and 1 or 0
  654. else
  655. v.progressState = 0
  656. end
  657. end
  658. end
  659. for i,v in ipairs(tmp) do
  660. table.insert(list, 1, v)
  661. end
  662. --几个婚姻任务不显示
  663. for a,b in pairs(MateConst.SingleDogTask) do
  664. for i=#list,1,-1 do
  665. if b == list[i].id then
  666. table.remove(list, i)
  667. break
  668. end
  669. end
  670. end
  671. self:SetDailyActiviteTaskVo( list )
  672. -- 推荐成就以及可领奖成就(暂时不显示在任务面板)
  673. --self:SetAchiTaskVo( list )
  674. -- 七日目标
  675. -- self:SetSevenTargetTaskVo(list)
  676. list = self:SortFun(list)
  677. -------------------------
  678. --需要维护一个本地活动标记完成的表,每次有新的已完成任务的时候,就把任务栏滚动容器位置置顶
  679. local cur_temp_finish_task_info = {}
  680. local need = false
  681. for k,v in pairs(list) do
  682. if v.acceptType==0 and self:IsTaskProgressFinish(v) then
  683. if v.type ~= TaskType.MAIN_LINE then
  684. cur_temp_finish_task_info[v.id] = true
  685. end
  686. end
  687. -- 成就类要加个id
  688. if v.type == TaskType.ACHIEVE and
  689. v.progress_data and v.progress_data.status == 1 then
  690. if not cur_temp_finish_task_info[v.achieve_id] then
  691. cur_temp_finish_task_info[v.achieve_id] = true
  692. need = true
  693. end
  694. end
  695. end
  696. for k,v in pairs(cur_temp_finish_task_info) do
  697. if not self.temp_finish_task_info[k] then
  698. need = true
  699. end
  700. self.temp_finish_task_info[k] = true
  701. end
  702. if need then
  703. self:Fire(TaskEvent.SHOW_SCROLL_TO_TOP)
  704. end
  705. -------------------------
  706. return list
  707. end
  708. --任务的排序
  709. function TaskModel:SortFun(list)
  710. for k,v in pairs(list) do
  711. if v.tipType then
  712. v.tipTypeSort = Config.ConfigTaskEffect.TaskContentTypeSort[v.tipType] or 0
  713. else
  714. v.tipTypeSort = 0
  715. end
  716. v.sortKey = v.sortKey or 99
  717. end
  718. -------------------------
  719. local func_open_list = {} --功能开放性任务
  720. for i=#list, 1, -1 do
  721. if self:IsFuncOpenTask(list[i]) then
  722. table.insert( func_open_list, table.remove(list,i) )
  723. end
  724. end
  725. local high_order_list = {} --高排序型任务
  726. for i=#list, 1, -1 do
  727. if self:IsHighOrderTask(list[i]) then
  728. table.insert( high_order_list, table.remove(list,i) )
  729. end
  730. end
  731. local main_line_list = {}--主线或者升级指引
  732. for i=#list, 1, -1 do
  733. if list[i].type == TaskType.MAIN_LINE then
  734. table.insert( main_line_list, table.remove(list,i) )
  735. end
  736. end
  737. local over_list = {}--可领取的任务
  738. for i=#list, 1, -1 do
  739. if list[i].progressState == 1 then
  740. table.insert( over_list, table.remove(list,i) )
  741. end
  742. end
  743. local buy_gods_line_list = {}--购买型支线
  744. for i=#list, 1, -1 do
  745. if self:IsBuyGoodsTaskFinished(list[i]) then
  746. table.insert( buy_gods_line_list, table.remove(list,i) )
  747. end
  748. end
  749. --护送任务双倍的时候,提高优先级
  750. local escord_task_list = {}
  751. if EscortModel.getInstance():CurTimeIsDouble() then
  752. for i=#list, 1, -1 do
  753. if self:IsDailyActiviteEscortTask(list[i]) then
  754. table.insert( escord_task_list, table.remove(list,i) )
  755. break
  756. end
  757. end
  758. end
  759. local daily_line_list = {}--经验跑环任务
  760. for i=#list, 1, -1 do
  761. if list[i].type == TaskType.BOUNTY_LINE then
  762. table.insert( daily_line_list, table.remove(list,i) )
  763. end
  764. end
  765. for i=#list, 1, -1 do --社团跑环任务
  766. if list[i].type == TaskType.GUILD_LINE then
  767. table.insert( daily_line_list, table.remove(list,i) )
  768. end
  769. end
  770. local second_order_list = {} --第二排序序型任务
  771. for i=#list, 1, -1 do
  772. if self:IsSecondOrderTask(list[i]) then
  773. table.insert( second_order_list, table.remove(list,i) )
  774. end
  775. end
  776. local daily_activite_list = {} --日常活跃任务
  777. for i=#list, 1, -1 do
  778. if self:IsDailyActiviteTask(list[i]) then
  779. table.insert( daily_activite_list, table.remove(list,i) )
  780. end
  781. end
  782. local third_order_list = {} --第三排序序型任务
  783. for i=#list, 1, -1 do
  784. if self:IsThirdOrderTask(list[i]) then
  785. table.insert( third_order_list, table.remove(list,i) )
  786. end
  787. end
  788. -------------------------
  789. local arg = {"sortKey","progressState","order","acceptType","id"}
  790. local condition = {Array.LOWER,Array.UPPER,Array.UPPER, Array.LOWER,Array.LOWER,}
  791. SortTools.MoreKeysSorter(func_open_list, arg, condition)
  792. SortTools.MoreKeysSorter(high_order_list, arg, condition)
  793. SortTools.MoreKeysSorter(main_line_list, arg, condition)
  794. SortTools.MoreKeysSorter(buy_gods_line_list, arg, condition)
  795. SortTools.MoreKeysSorter(second_order_list, arg, condition)
  796. SortTools.MoreKeysSorter(daily_activite_list, arg, condition)
  797. SortTools.MoreKeysSorter(third_order_list, arg, condition)
  798. SortTools.MoreKeysSorter(over_list, arg, condition)
  799. SortTools.MoreKeysSorter(list, arg, condition)
  800. -------------------------
  801. local end_list = {}
  802. for i,v in ipairs(func_open_list) do table.insert( end_list, v ) end
  803. for i,v in ipairs(high_order_list) do table.insert( end_list, v ) end
  804. for i,v in ipairs(main_line_list) do table.insert( end_list, v ) end
  805. for i,v in ipairs(over_list) do table.insert( end_list, v ) end
  806. for i,v in ipairs(buy_gods_line_list) do table.insert( end_list, v ) end
  807. for i,v in ipairs(escord_task_list) do table.insert( end_list, v ) end
  808. for i,v in ipairs(daily_line_list) do table.insert( end_list, v ) end
  809. for i,v in ipairs(second_order_list) do table.insert( end_list, v ) end
  810. for i,v in ipairs(daily_activite_list) do table.insert( end_list, v ) end
  811. for i,v in ipairs(third_order_list) do table.insert( end_list, v ) end
  812. for i,v in ipairs(list) do table.insert( end_list, v ) end
  813. return end_list
  814. end
  815. -- 任务描述内容拼接
  816. function TaskModel:MakeTaskTip(taskVO)
  817. if taskVO == nil then return end
  818. if taskVO.mainTip == true then --假任务
  819. --下一个有任务的等级
  820. self:DefaultTask()
  821. taskVO.tipParam={}
  822. return
  823. end
  824. for key, taskTipVO in ipairs(taskVO.taskTips) do
  825. if (taskTipVO.isFinish==0 or key==#taskVO.taskTips) then
  826. if taskTipVO.type == TaskTipType.TYPE0 then
  827. --通用寻路
  828. self:makeFindType(taskVO, taskTipVO)
  829. --显示数量
  830. if taskVO.target_num > 0 then
  831. taskVO.tipContent=taskVO.tipContent.."<color="..TaskModel.Color.WHITE..">("..taskVO.cur_num.."/"..taskVO.target_num..")</color>"
  832. end
  833. elseif taskTipVO.type == TaskTipType.TYPE1 then--击败怪物
  834. self:makeType1(taskVO, taskTipVO)
  835. elseif taskTipVO.type == TaskTipType.TYPE2 or taskTipVO.type == TaskTipType.TYPE29 then--完成副本
  836. self:makeType2(taskVO, taskTipVO)
  837. elseif taskTipVO.type == TaskTipType.TYPE34 then
  838. self:makeType34(taskVO, taskTipVO)
  839. elseif taskTipVO.type == TaskTipType.TYPE6 then--收集物品(打怪)
  840. self:makeType6(taskVO, taskTipVO)
  841. elseif taskTipVO.type == TaskTipType.TYPE16 then--探索场景
  842. self:makeType16(taskVO, taskTipVO)
  843. elseif taskTipVO.type == TaskTipType.TYPE18 then--采集
  844. self:makeType18(taskVO, taskTipVO)
  845. elseif taskTipVO.type == TaskTipType.TYPE7 or taskTipVO.type == TaskTipType.TYPE8
  846. or taskTipVO.type == TaskTipType.TYPE9 or taskTipVO.type == TaskTipType.TYPE35
  847. or taskTipVO.type == TaskTipType.TYPE38 then --与npc对话
  848. self:makeType7(taskVO, taskTipVO)
  849. -- --显示数量
  850. -- if taskVO.target_num > 0 then
  851. -- taskVO.tipContent=taskVO.tipContent.."<color="..ColorUtil.WHITE..">("..taskVO.cur_num.."/"..taskVO.target_num..")</color>"
  852. -- end
  853. elseif taskTipVO.type == TaskTipType.TYPE100 then --击败boss
  854. self:makeType100(taskVO, taskTipVO)
  855. elseif taskTipVO.type == TaskTipType.TYPE109 or taskTipVO.type == TaskTipType.TYPE110 then --市场上架 市场购买
  856. self:makeType109(taskVO, taskTipVO)
  857. elseif taskTipVO.type == TaskTipType.TYPE102 then --完成某副本类型
  858. self:makeType102(taskVO, taskTipVO)
  859. elseif taskTipVO.type == TaskTipType.TYPE103 then --单次副本获得x经验
  860. self:makeType103(taskVO, taskTipVO)
  861. elseif taskTipVO.type == TaskTipType.TYPE106 then --提交装备
  862. self:makeType106(taskVO, taskTipVO)
  863. elseif taskTipVO.type == TaskTipType.TYPE107 then --完成社团活动
  864. self:makeType107(taskVO, taskTipVO)
  865. elseif taskTipVO.type == TaskTipType.TYPE23 then --合成物品
  866. self:makeType23(taskVO, taskTipVO)
  867. elseif taskTipVO.type == TaskTipType.TYPE24 then --活跃度
  868. self:makeType24(taskVO, taskTipVO)
  869. elseif taskTipVO.type == TaskTipType.TYPE104 then --添加好友
  870. self:makeType104(taskVO, taskTipVO)
  871. elseif taskTipVO.type == TaskTipType.TYPE26 then --装备吞噬
  872. self:makeType26(taskVO, taskTipVO)
  873. elseif taskTipVO.type == TaskTipType.TYPE27 then --击杀首领
  874. self:makeType27(taskVO, taskTipVO)
  875. elseif taskTipVO.type == TaskTipType.TYPE28 then --钓鱼活动
  876. self:makeType28(taskVO, taskTipVO)
  877. elseif taskTipVO.type == TaskTipType.TYPE29 then --烹饪活动
  878. self:makeType29(taskVO, taskTipVO)
  879. elseif taskTipVO.type == TaskTipType.TYPE111 then --符文爬塔
  880. self:makeType111(taskVO, taskTipVO)
  881. elseif taskTipVO.type == TaskTipType.TYPE36 then --装备附能
  882. self:makeType36(taskVO, taskTipVO)
  883. elseif taskTipVO.type == TaskTipType.TYPE37 then --副本波数进度
  884. self:makeType37(taskVO, taskTipVO)
  885. elseif taskTipVO.type == TaskTipType.TYPE101 then --强化装备
  886. self:makeType101(taskVO, taskTipVO)
  887. elseif taskTipVO.type == TaskTipType.TYPE31 then --竞技场次数
  888. self:makeType31(taskVO, taskTipVO)
  889. elseif taskTipVO.type == TaskTipType.TYPE39 then --装备升星
  890. self:makeType39(taskVO, taskTipVO)
  891. elseif taskTipVO.type == TaskTipType.TYPE40 then --交易券购买
  892. self:makeType40(taskVO, taskTipVO)
  893. elseif taskTipVO.type == TaskTipType.TYPE42 then --好感度
  894. self:makeNormalType2(taskVO, taskTipVO)
  895. elseif taskTipVO.type == TaskTipType.TYPE44 then --升品之路
  896. self:makeNormalType2(taskVO, taskTipVO)
  897. elseif taskTipVO.type == TaskTipType.TYPE49 then --圣物装备
  898. self:makeNormalType2(taskVO, taskTipVO)
  899. elseif taskTipVO.type == TaskTipType.TYPE51 then --解锁地狱摩托
  900. self:makeType51(taskVO, taskTipVO)
  901. elseif taskTipVO.type == TaskTipType.TYPE53 then --龙神抽奖
  902. self:makeType53(taskVO, taskTipVO)
  903. elseif taskTipVO.type == TaskTipType.TYPE54 then --装备套装
  904. self:makeType54(taskVO, taskTipVO)
  905. elseif taskTipVO.type == TaskTipType.TYPE55 then --战魂强化
  906. self:makeType55(taskVO, taskTipVO)
  907. elseif taskTipVO.type == TaskTipType.TYPE56 then --进阶目标(进阶到一定阶数)
  908. self:makeType56(taskVO, taskTipVO)
  909. elseif taskTipVO.type == TaskTipType.TYPE57 then --完成预期任务
  910. self:makeType57(taskVO, taskTipVO)
  911. elseif taskTipVO.type == TaskTipType.TYPE48 then --晒娃
  912. self:makeType48(taskVO, taskTipVO)
  913. elseif taskTipVO.type == TaskTipType.TYPE58 then --宝宝同心值
  914. self:makeType58(taskVO, taskTipVO)
  915. elseif taskTipVO.type == TaskTipType.TYPE59 then --战力
  916. self:makeType59(taskVO, taskTipVO)
  917. elseif taskTipVO.type == TaskTipType.TYPE60 then --任意商店技能书购买
  918. self:makeType60(taskVO, taskTipVO)
  919. elseif taskTipVO.type == TaskTipType.TYPE61 then --指定商店购买技能书
  920. self:makeType61(taskVO, taskTipVO)
  921. elseif taskTipVO.type == TaskTipType.TYPE62 then --任意商店技能书购买
  922. self:makeType62(taskVO, taskTipVO)
  923. else
  924. --无特殊参数要求
  925. self:makeNormalType(taskVO, taskTipVO)
  926. end
  927. taskVO.tipType = taskTipVO.type
  928. --显示数量
  929. if Config.ConfigTaskEffect.NeedShowNumTaskType[taskTipVO.type] or
  930. Config.ConfigTaskEffect.NeedShowNumTaskId[taskVO.id] then
  931. --通关专属幻魔要显示次数
  932. local numStr = ""
  933. numStr = "("..HtmlColorTxt(taskTipVO.nowCount, "#2CF66F").."/"..taskTipVO.count..")"
  934. taskVO.tipContent = taskVO.tipContent..numStr
  935. if taskTipVO.type == TaskTipType.TYPE100 then
  936. --赏金幻魔
  937. taskVO.tipContent = taskVO.tipContent .. "\n<color=#f558ff>可获大量装备和交易券</color>"
  938. end
  939. if taskTipVO.type == TaskTipType.TYPE102 then --完成某副本类型
  940. if taskTipVO.id == BaseDungeonModel.DUN_TYPE.PersonBoss then
  941. taskVO.tipContent = string.format( "击杀<color=#2CF66F>%s</color>%s\n<color=#f558ff>可获大量装备和交易券</color>",BaseDungeonModel.DUN_NAME[taskTipVO.id] or "",numStr )
  942. end
  943. end
  944. if taskTipVO.type == TaskTipType.TYPE58 then --完成宝宝同心值
  945. taskVO.tipContent = string.format( "同心值达到<color=#2CF66F></color>%s\n<color=#f558ff>完成日常任务积攒同心值</color>",numStr )
  946. end
  947. if taskTipVO.type == TaskTipType.TYPE59 then --战力
  948. taskVO.tipContent = string.format( "达到<color=#2CF66F></color>%s战力\n<color=#f558ff>点击查看可提战的系统</color>",numStr )
  949. end
  950. if taskTipVO.type == TaskTipType.TYPE62 then --任意商店技能书购买
  951. taskVO.tipContent = string.format( "购买%s本技能书",numStr )
  952. end
  953. -------------------------
  954. if taskTipVO.type == TaskTipType.TYPE24 then
  955. --活跃度要加文本
  956. taskVO.tipContent = taskVO.tipContent .. "\n<color=#f558ff>每天必做的成长任务</color>"
  957. end
  958. end
  959. break
  960. end
  961. end
  962. end
  963. function TaskModel:makeType1(taskVO, taskTipVO)
  964. local strs = ""
  965. local findtype = TaskTipType.TYPE1
  966. local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
  967. if cfg then
  968. local temp = ConfigItemMgr.Instance:GetMonsterDataItem(taskTipVO.id)
  969. if temp then
  970. strs = string.format(cfg, Trim(temp.name))
  971. end
  972. else
  973. strs = Trim(taskVO.tips)
  974. end
  975. local findstr={}
  976. if taskTipVO.scene_x ~= 0 and taskTipVO.scene_y ~= 0 then
  977. findstr={findtype, taskTipVO.sceneId, taskTipVO.id, taskVO.id,taskTipVO.scene_x, taskTipVO.scene_y, taskVO.type}
  978. else
  979. findstr={findtype, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
  980. end
  981. taskVO.tipContent=strs
  982. taskVO.tipParam=findstr
  983. taskVO.need_find_way = taskTipVO.need_find_way
  984. end
  985. --完成副本
  986. function TaskModel:makeType2(taskVO, taskTipVO)
  987. --特殊限制的主线副本,因为UI还是显示任务栏,需要把通关副本改为击败怪物
  988. local dun_id = taskTipVO.id
  989. local strs = ""
  990. local is_special_ui_dun = Config.ConfigChangeSceneEffect.DungeonLimit[dun_id] and Config.ConfigChangeSceneEffect.DungeonLimit[dun_id].keep_ui
  991. if is_special_ui_dun then
  992. local wave_cfg = Config.Dunwave[dun_id.."@1"]
  993. if wave_cfg then
  994. local mon_list = stringtotable(wave_cfg.mon_list) or {}
  995. local mon_id = mon_list[1] and mon_list[1][1]
  996. local mon_cfg = ConfigItemMgr.Instance:GetMonsterDataItem(mon_id)
  997. if mon_cfg then
  998. local cfg = "消灭 <color=#2CF66F>%s</color>"
  999. strs = string.format(cfg, Trim(mon_cfg.name))
  1000. if taskVO.type == TaskType.BOUNTY_LINE then
  1001. local numStr = ""
  1002. numStr = "("..HtmlColorTxt(taskTipVO.nowCount, "#2CF66F").."/"..taskTipVO.count..")"
  1003. strs = strs..numStr
  1004. end
  1005. else
  1006. strs = "消灭前方怪物"
  1007. end
  1008. else
  1009. strs = "消灭前方怪物"
  1010. end
  1011. else
  1012. local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
  1013. if cfg then
  1014. local temp = Config.Dungeoncfg[taskTipVO.id]
  1015. if temp then
  1016. if temp.type == BaseDungeonModel.DUN_TYPE.ONE_TOWER then
  1017. strs = string.format("通关简单模式第<color=#2CF66F>%s</color>层", taskTipVO.id-7000)
  1018. elseif dun_id == BossModel.FAKE_MONEY_BOSS_DUN_ID then
  1019. strs = string.format("击杀<color=#2CF66F>%s</color>", Trim(temp.name))
  1020. if not self:IsTaskProgressFinish(taskVO) then --未完成才显示进度
  1021. local numStr = ""
  1022. numStr = "("..HtmlColorTxt(taskTipVO.nowCount, "#2CF66F").."/"..taskTipVO.count..")"
  1023. strs = strs..numStr
  1024. end
  1025. else
  1026. strs = string.format(cfg, Trim(temp.name))
  1027. end
  1028. end
  1029. else
  1030. strs = Trim(taskVO.tips)
  1031. end
  1032. end
  1033. taskVO.tipContent=strs
  1034. taskVO.tipParam={TaskTipType.TYPE2, taskTipVO.sceneId, taskTipVO.id, taskVO.id, taskTipVO.scene_x, taskTipVO.scene_y}
  1035. taskVO.need_find_way = 1
  1036. local task_id = taskVO.id
  1037. if task_id == Config.ConfigTaskEffect.TOWER_DUN_ID then
  1038. local dun_id = taskVO.tipParam and taskVO.tipParam[3] or 0
  1039. if tonumber(taskVO.tipParam[1]) == TaskTipType.TYPE2 and dun_id > 7000 and dun_id < 8000 then
  1040. local dun_cfg = BaseDungeonModel:getInstance():GetDunCfg(dun_id)
  1041. local dun_power = 150000--dun_cfg and dun_cfg.recommend_power or 0
  1042. local my_power = RoleManager.Instance.mainRoleInfo.fighting
  1043. if my_power >= dun_power then
  1044. taskVO.sortKey = Config.ConfigTaskEffect.TaskTypeSort[taskVO.type]
  1045. else
  1046. taskVO.sortKey = 9999 --置底
  1047. end
  1048. end
  1049. end
  1050. end
  1051. --完成经验副本类型副本
  1052. function TaskModel:makeType34(taskVO, taskTipVO)
  1053. local strs = ""
  1054. local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
  1055. if cfg then
  1056. local dunStr = BaseDungeonModel.DUN_NAME[taskTipVO.id] or ""
  1057. strs = string.format(cfg, dunStr)
  1058. else
  1059. strs = Trim(taskVO.tips)
  1060. end
  1061. taskVO.tipContent=strs
  1062. taskVO.tipParam={TaskTipType.TYPE34, taskTipVO.sceneId, taskTipVO.id, taskVO.id, taskTipVO.scene_x, taskTipVO.scene_y}
  1063. taskVO.need_find_way = 1
  1064. end
  1065. --收集
  1066. function TaskModel:makeType6(taskVO, taskTipVO)
  1067. local strs = ""
  1068. local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
  1069. if cfg then
  1070. local temp = GoodsModel:getInstance():GetGoodsBasicByTypeId(taskTipVO.id)
  1071. strs = string.format(cfg, Trim(temp.goods_name))
  1072. else
  1073. strs = Trim(taskVO.tips)
  1074. end
  1075. local findstr={}
  1076. local findtype = TaskTipType.TYPE6
  1077. local monster_id = 0 --找坐标就行了
  1078. if taskTipVO.scene_x ~= 0 and taskTipVO.scene_y ~= 0 then
  1079. findstr={findtype, taskTipVO.sceneId, monster_id,taskVO.id,taskTipVO.scene_x, taskTipVO.scene_y, taskVO.type}
  1080. else
  1081. findstr={findtype, taskTipVO.sceneId, monster_id,taskVO.id,taskTipVO.scene_x, taskTipVO.scene_y, taskVO.type}
  1082. end
  1083. taskVO.tipContent=strs
  1084. taskVO.tipParam= findstr
  1085. taskVO.need_find_way = taskTipVO.need_find_way
  1086. end
  1087. --探索场景, 寻路到指定场景指定地点
  1088. function TaskModel:makeType16(taskVO, taskTipVO)
  1089. local strs = "探索场景"
  1090. local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
  1091. if cfg then
  1092. local temp = ConfigItemMgr.Instance:GetSceneItem(taskTipVO.sceneId)
  1093. if temp then
  1094. strs = string.format(cfg, Trim(temp.name))
  1095. end
  1096. end
  1097. taskVO.tipContent=strs
  1098. taskVO.tipParam={TaskTipType.TYPE16, taskTipVO.sceneId, taskTipVO.scene_x, taskTipVO.scene_y, taskTipVO.count}
  1099. taskVO.need_find_way = 1
  1100. end
  1101. --采集
  1102. function TaskModel:makeType18(taskVO, taskTipVO)
  1103. local strs = ""
  1104. local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
  1105. if cfg then
  1106. local temp = ConfigItemMgr.Instance:GetMonsterDataItem(taskTipVO.id)
  1107. if temp then
  1108. strs = string.format(cfg, Trim(temp.name))
  1109. end
  1110. else
  1111. strs = Trim(taskVO.tips)
  1112. end
  1113. local findstr={}
  1114. local findtype = TaskTipType.TYPE18
  1115. if taskTipVO.scene_x ~= 0 and taskTipVO.scene_y ~= 0 then
  1116. findstr={findtype, taskTipVO.sceneId, taskTipVO.id, taskVO.id,taskTipVO.scene_x, taskTipVO.scene_y, taskVO.type}
  1117. else
  1118. findstr={findtype, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
  1119. end
  1120. taskVO.tipContent=strs
  1121. taskVO.tipParam= findstr
  1122. taskVO.need_find_way = taskTipVO.need_find_way
  1123. end
  1124. --与npc对话
  1125. function TaskModel:makeType7(taskVO, taskTipVO)
  1126. local strs = ""
  1127. local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
  1128. if cfg and not SceneManager.Instance:IsClientHideNpc(taskTipVO.id) then
  1129. local temp = ConfigItemMgr.Instance:GetNpcItem(taskTipVO.id)
  1130. if temp and temp.name then
  1131. strs = string.format(cfg, Trim(temp.name))
  1132. end
  1133. else
  1134. strs = Trim(taskVO.tips)
  1135. end
  1136. taskVO.tipContent=strs
  1137. taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
  1138. taskVO.need_find_way = taskTipVO.need_find_way
  1139. end
  1140. --击杀boss
  1141. function TaskModel:makeType100( taskVO, taskTipVO )
  1142. local strs = ""
  1143. local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
  1144. strs = cfg or Trim(taskVO.tips)
  1145. taskVO.tipContent=strs
  1146. taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
  1147. taskVO.need_find_way = 1
  1148. end
  1149. --强化装备
  1150. function TaskModel:makeType101( taskVO, taskTipVO )
  1151. local strs = ""
  1152. local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
  1153. if cfg then
  1154. strs = string.format(cfg, taskTipVO.count, taskTipVO.id)
  1155. else
  1156. strs = Trim(taskVO.tips)
  1157. end
  1158. taskVO.tipContent=strs
  1159. taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
  1160. taskVO.need_find_way = 1
  1161. end
  1162. --市场上架 市场购买
  1163. function TaskModel:makeType109( taskVO, taskTipVO )
  1164. local strs = ""
  1165. local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
  1166. if cfg then
  1167. strs = string.format(cfg, taskTipVO.count)
  1168. else
  1169. strs = Trim(taskVO.tips)
  1170. end
  1171. taskVO.tipContent=strs
  1172. taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
  1173. taskVO.need_find_way = 1
  1174. end
  1175. --完成某副本类型
  1176. function TaskModel:makeType102( taskVO, taskTipVO )
  1177. local strs = ""
  1178. local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
  1179. if cfg then
  1180. local dunStr = BaseDungeonModel.DUN_NAME[taskTipVO.id] or ""
  1181. strs = string.format(cfg, dunStr)
  1182. else
  1183. strs = Trim(taskVO.tips)
  1184. end
  1185. taskVO.tipContent=strs
  1186. taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
  1187. taskVO.need_find_way = 1
  1188. end
  1189. --单次副本获得x经验
  1190. function TaskModel:makeType103( taskVO, taskTipVO )
  1191. local strs = ""
  1192. local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
  1193. if cfg then
  1194. local dunStr = Config.ConfigDungeonClient.dunTypeStr[taskTipVO.id] or ""
  1195. strs = string.format(cfg, CalUnitNum2(taskTipVO.count))
  1196. else
  1197. strs = Trim(taskVO.tips)
  1198. end
  1199. taskVO.tipContent=strs
  1200. taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
  1201. taskVO.need_find_way = 1
  1202. end
  1203. --添加好友类型
  1204. function TaskModel:makeType104( taskVO, taskTipVO )
  1205. local strs = ""
  1206. local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
  1207. if cfg then
  1208. strs = string.format(cfg,taskTipVO.count)
  1209. else
  1210. strs = Trim(taskVO.tips)
  1211. end
  1212. taskVO.tipContent=strs
  1213. taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
  1214. taskVO.need_find_way = 1
  1215. end
  1216. --装备吞噬
  1217. function TaskModel:makeType26( taskVO, taskTipVO )
  1218. local strs = ""
  1219. local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
  1220. if cfg then
  1221. strs = string.format(cfg,taskTipVO.id)
  1222. else
  1223. strs = Trim(taskVO.tips)
  1224. end
  1225. taskVO.tipContent=strs
  1226. taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
  1227. taskVO.need_find_way = 1
  1228. end
  1229. --击杀首领
  1230. function TaskModel:makeType27( taskVO, taskTipVO )
  1231. local strs = ""
  1232. local cfg = ConfigItemMgr.Instance:GetMonsterDataItem(taskTipVO.id)
  1233. if cfg then
  1234. strs = "击杀 " .. HtmlColorTxt(Trim(cfg.name), ColorUtil.GREEN_DARK)
  1235. else
  1236. strs = Trim(taskVO.tips)
  1237. end
  1238. taskVO.tipContent=strs
  1239. taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.count}
  1240. taskVO.need_find_way = 1
  1241. end
  1242. function TaskModel:makeType28( taskVO, taskTipVO )
  1243. local strs = ""
  1244. local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
  1245. if cfg then
  1246. strs = string.format(cfg, taskTipVO.count)
  1247. else
  1248. strs = Trim(taskVO.tips)
  1249. end
  1250. taskVO.tipContent=strs
  1251. taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
  1252. taskVO.need_find_way = 1
  1253. end
  1254. function TaskModel:makeType29( taskVO, taskTipVO )
  1255. local strs = ""
  1256. local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
  1257. if cfg then
  1258. strs = string.format(cfg, taskTipVO.count)
  1259. else
  1260. strs = Trim(taskVO.tips)
  1261. end
  1262. taskVO.tipContent=strs
  1263. taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
  1264. taskVO.need_find_way = 1
  1265. end
  1266. --符文爬塔
  1267. function TaskModel:makeType111( taskVO, taskTipVO )
  1268. -- local strs = ""
  1269. -- local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
  1270. -- if cfg then
  1271. -- local dun_id = taskTipVO.count
  1272. -- local layer_id = 1
  1273. -- local name = ""
  1274. -- local force_read_server = false
  1275. -- local config = Config.Dungeoncfg[dun_id]
  1276. -- if config then
  1277. -- if config.type == 20 then
  1278. -- name = "魂珠副本"
  1279. -- elseif config.type == 21 then
  1280. -- name = "神格副本"
  1281. -- elseif config.type == 5 then
  1282. -- force_read_server = true
  1283. -- end
  1284. -- end
  1285. -- if force_read_server then
  1286. -- strs = Trim(taskVO.tips)
  1287. -- else
  1288. -- config = BaseDungeonModel.GetDungeonrunelvdataCfg(dun_id)
  1289. -- if config then
  1290. -- layer_id = config.lv
  1291. -- end
  1292. -- strs = string.format(cfg,name,layer_id)
  1293. -- end
  1294. -- else
  1295. -- strs = Trim(taskVO.tips)
  1296. -- end
  1297. -- taskVO.tipContent=strs
  1298. -- taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.count, taskVO.id}
  1299. -- taskVO.need_find_way = 1
  1300. end
  1301. --装备附能
  1302. function TaskModel:makeType36( taskVO, taskTipVO )
  1303. local strs = ""
  1304. local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
  1305. if cfg then
  1306. strs = string.format(cfg, taskTipVO.count)
  1307. else
  1308. strs = Trim(taskVO.tips)
  1309. end
  1310. taskVO.tipContent=strs
  1311. taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
  1312. taskVO.need_find_way = 1
  1313. end
  1314. --副本波数进度
  1315. function TaskModel:makeType37( taskVO, taskTipVO )
  1316. local strs = ""
  1317. local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
  1318. if cfg then
  1319. local temp = Config.Dungeoncfg[taskTipVO.id]
  1320. if temp then
  1321. if temp.type == BaseDungeonModel.DUN_TYPE.EXP then
  1322. strs = string.format("成功挑战第<color=#2CF66F>%s</color>波", taskTipVO.count)
  1323. else
  1324. strs = string.format(cfg, Trim(temp.name), taskTipVO.count)
  1325. end
  1326. end
  1327. else
  1328. strs = Trim(taskVO.tips)
  1329. end
  1330. taskVO.tipContent=strs
  1331. taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
  1332. taskVO.need_find_way = 1
  1333. --战力
  1334. local task_id = taskVO.id
  1335. if task_id == Config.ConfigTaskEffect.EXP_DUN_ID then
  1336. local my_power = RoleManager.Instance.mainRoleInfo.fighting
  1337. local wave = taskTipVO.count
  1338. local wave_cfg = BaseDungeonModel:getInstance():GetDunWaveCfg(BaseDungeonModel.EXP_DUN_ID, wave)
  1339. local wave_power = wave_cfg.recommend_power or 999999999999
  1340. if my_power >= wave_power then
  1341. taskVO.sortKey = Config.ConfigTaskEffect.TaskTypeSort[taskVO.type]
  1342. else
  1343. taskVO.sortKey = 9999 --置底
  1344. end
  1345. end
  1346. end
  1347. --提交装备
  1348. function TaskModel:makeType106( taskVO, taskTipVO )
  1349. local strs = ""
  1350. local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
  1351. if cfg then
  1352. strs = string.format(cfg, taskTipVO.id, ColorUtil:getColorName(taskTipVO.count))
  1353. else
  1354. strs = Trim(taskVO.tips)
  1355. end
  1356. taskVO.tipContent=strs
  1357. taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
  1358. taskVO.need_find_way = 1
  1359. end
  1360. --竞技场次数
  1361. function TaskModel:makeType31( taskVO, taskTipVO )
  1362. local strs = ""
  1363. local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
  1364. if cfg then
  1365. strs = string.format(cfg, taskTipVO.count)
  1366. else
  1367. strs = Trim(taskVO.tips)
  1368. end
  1369. taskVO.tipContent=strs
  1370. taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
  1371. taskVO.need_find_way = 1
  1372. end
  1373. --装备升星
  1374. function TaskModel:makeType39( taskVO, taskTipVO )
  1375. local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
  1376. local strs = cfg or Trim(taskVO.tips)
  1377. taskVO.tipContent=strs
  1378. taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
  1379. taskVO.need_find_way = 1
  1380. end
  1381. --商城购买
  1382. function TaskModel:makeType40( taskVO, taskTipVO )
  1383. local need_money = taskTipVO.sceneId --需要的价格
  1384. local shop_key_id = taskTipVO.scene_x --商品id
  1385. local money_type = Config.Shop[shop_key_id] and Config.Shop[shop_key_id].ctype --商品消耗货币类型
  1386. local my_money = GoodsModel:getInstance():GetGoodsNumFromType(money_type) --我的商品消耗货币
  1387. local money_type_id = Config.ConfigNotNormalGoods[money_type] and Config.ConfigNotNormalGoods[money_type].goods_id
  1388. local money_name = GoodsModel:getInstance():getGoodsName(money_type_id)
  1389. local goods_type_id = taskTipVO.id
  1390. local goods_name = ""
  1391. local goods = ConfigItemMgr.Instance:GetGoodItem(goods_type_id)
  1392. if goods then
  1393. local colorStr = TaskModel.QualityColor[goods.color] or TaskModel.QualityColor[1]
  1394. goods_name = HtmlColorTxt(Trim(goods.goods_name), colorStr)
  1395. end
  1396. local strs = ""
  1397. if taskTipVO.isFinish == 1 or my_money >= need_money then --已完成
  1398. strs = string.format("%s足够了,去购买%s吧", money_name, goods_name)
  1399. else --未完成
  1400. strs = string.format("获得<color=#2CF66F>%s%s</color>,前往商城购买%s", need_money, money_name, goods_name)
  1401. strs = strs .. "\n" .. string.format("当前%s(<color=#2CF66F>%s</color>/%s)", money_name, my_money, need_money)
  1402. end
  1403. -------------------------
  1404. local equip_type = EquipModel:getInstance():GetEquipType( goods_type_id )
  1405. if equip_type then
  1406. local type_const = EquipModel.EquipType
  1407. if equip_type == type_const.Guard or equip_type == type_const.LeftRing
  1408. or equip_type == type_const.RightRing or equip_type == type_const.Necklace then
  1409. -- 守护戒指耳饰类--项链类
  1410. strs = string.format( "购买<color=#2CF66F>[%s]</color>",Trim(goods.goods_name) )
  1411. strs = strs .. "\n" .. string.format("拥有%s(<color=#2CF66F>%s</color>/%s)", money_name, my_money, need_money)
  1412. end
  1413. end
  1414. -------------------------
  1415. taskVO.is_money_enough = my_money >= need_money
  1416. taskVO.tipContent=strs
  1417. taskVO.tipParam={taskTipVO.type, shop_key_id, goods_type_id, taskVO.id, need_money}
  1418. taskVO.need_find_way = 1
  1419. -- taskVO.sortKey = Config.ConfigTaskEffect.TaskTypeSort[taskTipVO.type]
  1420. end
  1421. --解锁地狱摩托
  1422. function TaskModel:makeType51( taskVO, taskTipVO )
  1423. local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
  1424. taskVO.tipContent = cfg
  1425. taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
  1426. taskVO.need_find_way = 1
  1427. end
  1428. --龙神抽奖
  1429. function TaskModel:makeType53( taskVO, taskTipVO )
  1430. local strs = ""
  1431. local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
  1432. if cfg then
  1433. strs = string.format(cfg, taskTipVO.count)
  1434. else
  1435. strs = Trim(taskVO.tips)
  1436. end
  1437. taskVO.tipContent=strs
  1438. taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
  1439. taskVO.need_find_way = 1
  1440. end
  1441. --装备套装
  1442. function TaskModel:makeType54( taskVO, taskTipVO )
  1443. local strs = ""
  1444. local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
  1445. if cfg then
  1446. local color = ColorUtil:GetColor(taskTipVO.sceneId)
  1447. strs = string.format(cfg, taskTipVO.count, taskTipVO.id, color, ColorUtil:getColorName(taskTipVO.sceneId))
  1448. else
  1449. strs = Trim(taskVO.tips)
  1450. end
  1451. taskVO.tipContent=strs
  1452. taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
  1453. taskVO.need_find_way = 1
  1454. end
  1455. --战魂强化
  1456. function TaskModel:makeType55( taskVO, taskTipVO )
  1457. local strs = ""
  1458. local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
  1459. if cfg then
  1460. strs = string.format(cfg, taskTipVO.count)
  1461. else
  1462. strs = Trim(taskVO.tips)
  1463. end
  1464. taskVO.tipContent=strs
  1465. taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
  1466. taskVO.need_find_way = 1
  1467. end
  1468. --进阶目标(进阶到一定阶数)
  1469. function TaskModel:makeType56( taskVO, taskTipVO )
  1470. local strs = ""
  1471. local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
  1472. if cfg then
  1473. strs = string.format(cfg, FosterConst.ModelName[taskTipVO.id], taskTipVO.count)
  1474. else
  1475. strs = Trim(taskVO.tips)
  1476. end
  1477. taskVO.tipContent=strs
  1478. taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
  1479. taskVO.need_find_way = 1
  1480. end
  1481. --完成预期任务
  1482. function TaskModel:makeType57( taskVO, taskTipVO )
  1483. local strs = Trim(taskVO.tips)
  1484. if taskVO.id == 2040002 then
  1485. taskVO.tipContent = strs .. "\n" .. HtmlColorTxt( "AI娘可以协助出战" , '#f558ff')
  1486. elseif taskVO.id == 2040003 then
  1487. taskVO.tipContent = strs .. "\n" .. HtmlColorTxt( "恶魔骑士正在前方等你" , '#f558ff')
  1488. else
  1489. taskVO.tipContent = strs
  1490. end
  1491. taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
  1492. taskVO.need_find_way = 1
  1493. end
  1494. --晒娃
  1495. function TaskModel:makeType48( taskVO, taskTipVO )
  1496. local strs = Trim(taskVO.tips)
  1497. if taskVO.id == 3120003 then
  1498. taskVO.tipContent = strs .. "\n" .. HtmlColorTxt( "积攒同心值激活宝宝" , '#f558ff')
  1499. else
  1500. taskVO.tipContent = strs
  1501. end
  1502. taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
  1503. taskVO.need_find_way = 1
  1504. end
  1505. --宝宝同心值
  1506. function TaskModel:makeType58( taskVO, taskTipVO )
  1507. taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
  1508. taskVO.need_find_way = 1
  1509. end
  1510. --战力
  1511. function TaskModel:makeType59( taskVO, taskTipVO )
  1512. taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
  1513. taskVO.need_find_way = 1
  1514. end
  1515. --任意主动技能升级次数
  1516. function TaskModel:makeType60( taskVO, taskTipVO )
  1517. taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
  1518. taskVO.tipContent = HtmlColorTxt("升级技能", ColorUtil.GREEN_DARK)
  1519. taskVO.need_find_way = 1
  1520. end
  1521. --指定商店购买技能书
  1522. function TaskModel:makeType61( taskVO, taskTipVO )
  1523. taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
  1524. taskVO.tipContent = HtmlColorTxt("交易商店购买技能书", ColorUtil.GREEN_DARK)
  1525. taskVO.need_find_way = 1
  1526. end
  1527. --任意商店技能书购买
  1528. function TaskModel:makeType62( taskVO, taskTipVO )
  1529. taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
  1530. taskVO.need_find_way = 1
  1531. end
  1532. --无特殊参数要求2
  1533. function TaskModel:makeNormalType2( taskVO, taskTipVO )
  1534. local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
  1535. local strs = cfg or Trim(taskVO.tips)
  1536. taskVO.tipContent = string.format(strs, taskTipVO.count)
  1537. taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
  1538. taskVO.need_find_way = 1
  1539. end
  1540. --完成社团活动
  1541. function TaskModel:makeType107( taskVO, taskTipVO )
  1542. local strs = ""
  1543. local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
  1544. if cfg then
  1545. local tb = {"社团首领","社团晚宴","守卫社团","社团争霸"}
  1546. strs = string.format(cfg,tb[taskTipVO.id])
  1547. else
  1548. strs = Trim(taskVO.tips)
  1549. end
  1550. taskVO.tipContent=strs
  1551. taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
  1552. taskVO.need_find_way = 1
  1553. end
  1554. --合成装备
  1555. function TaskModel:makeType23( taskVO, taskTipVO )
  1556. local strs = ""
  1557. local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
  1558. if cfg then
  1559. local temp = GoodsModel:getInstance():GetGoodsBasicByTypeId(taskTipVO.id)
  1560. strs = string.format(cfg, taskTipVO.count, Trim(temp.goods_name))
  1561. else
  1562. strs = Trim(taskVO.tips)
  1563. end
  1564. taskVO.tipContent=strs
  1565. taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
  1566. taskVO.need_find_way = 1
  1567. end
  1568. --活跃度
  1569. function TaskModel:makeType24( taskVO, taskTipVO )
  1570. local strs = ""
  1571. local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
  1572. if cfg then
  1573. strs = string.format(cfg, taskTipVO.count)
  1574. else
  1575. strs = Trim(taskVO.tips)
  1576. end
  1577. taskVO.tipContent=strs
  1578. taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
  1579. taskVO.need_find_way = 1
  1580. end
  1581. --通用寻路数据
  1582. function TaskModel:makeFindType(taskVO, taskTipVO)
  1583. local strs = ""
  1584. strs = Trim(taskVO.tips)
  1585. taskVO.tipContent=strs
  1586. taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
  1587. taskVO.need_find_way = taskTipVO.need_find_way
  1588. end
  1589. --不需要数据
  1590. function TaskModel:makeNormalType(taskVO, taskTipVO)
  1591. local strs = ""
  1592. local cfg = Config.ConfigTaskEffect.ContentTip[taskTipVO.type]
  1593. if cfg then
  1594. strs = string.format(cfg, taskTipVO.id, taskTipVO.count)
  1595. else
  1596. strs = Trim(taskVO.tips)
  1597. end
  1598. taskVO.tipContent=strs
  1599. taskVO.tipParam={taskTipVO.type, taskTipVO.sceneId, taskTipVO.id, taskVO.id}
  1600. taskVO.need_find_way = 1
  1601. end
  1602. --* 使用","连接参数成字符串
  1603. function TaskModel:MakeParams( _table)
  1604. local result=""
  1605. local len=#_table
  1606. local index=1
  1607. for key, var in ipairs(_table) do
  1608. if index==len then
  1609. result=result..var
  1610. else
  1611. result=result..var..","
  1612. end
  1613. index=index+1
  1614. end
  1615. return result
  1616. end
  1617. --根据ID 获取可接任务对象,没有则放回null
  1618. function TaskModel:GetCanTaskById(taskId)
  1619. local taskVO=nil;
  1620. for key, taskVO in ipairs(self._canTaskList) do
  1621. if taskVO.id == taskId then
  1622. return taskVO
  1623. end
  1624. end
  1625. return nil
  1626. end
  1627. --根据ID 获取已接任务对象,没有则放回null
  1628. function TaskModel:GetReceivedTaskById(taskId)
  1629. local taskVO=nil;
  1630. for key, taskVO in ipairs(self._receivedTaskList) do
  1631. if taskVO.id == taskId then
  1632. return taskVO
  1633. end
  1634. end
  1635. return nil
  1636. end
  1637. -- 根据类型 返回是否有该类型的任务
  1638. function TaskModel:FindHaveTaskByType( taskType )
  1639. for i,taskVO in ipairs(self.all_task_list) do
  1640. if taskVO.type == taskType then
  1641. return true
  1642. end
  1643. end
  1644. return false
  1645. end
  1646. function TaskModel:GetReceivedTaskList()
  1647. return self._receivedTaskList
  1648. end
  1649. function TaskModel:GetCanTaskList()
  1650. return self._canTaskList
  1651. end
  1652. --获取主线任务
  1653. function TaskModel:GetMainTask()
  1654. for key, taskVO in ipairs(self._receivedTaskList) do
  1655. if taskVO.type == TaskType.MAIN_LINE then
  1656. return taskVO
  1657. end
  1658. end
  1659. for _, taskVO in ipairs(self._canTaskList) do
  1660. if taskVO.type == TaskType.MAIN_LINE and taskVO.level<=RoleManager.Instance.mainRoleInfo.level then
  1661. return taskVO
  1662. end
  1663. end
  1664. return self._nextMain
  1665. end
  1666. --npc是否是跟随npc
  1667. function TaskModel:IsFollowNpc(npc_id)
  1668. local bool = false
  1669. if self.followNpcList then
  1670. for i,v in ipairs(self.followNpcList) do
  1671. if tonumber(v[1]) == npc_id then
  1672. bool = true
  1673. break
  1674. end
  1675. end
  1676. end
  1677. return bool
  1678. end
  1679. --点击任务链接操作 @use_shoe 是否使用小飞鞋
  1680. --@force_use_shoe:点击任务栏飞鞋按钮时强制使用飞鞋
  1681. function TaskModel:TaskClickFun(task_data, use_shoe, force_use_shoe)
  1682. self.guild_kill_monster_num = 0--重置一下
  1683. if not task_data then
  1684. return
  1685. end
  1686. --未接任务的话就接一下
  1687. if task_data.acceptType and task_data.acceptType==1 and task_data.type and task_data.type == TaskType.MAIN_LINE and task_data.level and task_data.level<=RoleManager.Instance.mainRoleInfo.level and task_data.id then
  1688. TaskController.Instance.auto_accept_main_id = nil
  1689. GlobalEventSystem:Fire(TaskEventType.SEND_TASK_ACCEPT, task_data.id)
  1690. return
  1691. end
  1692. --PrintTable(task_data)
  1693. self:MakeTaskTip(task_data)
  1694. local params = self:MakeParams(task_data.tipParam)
  1695. print("Saber:TaskModel [969] params: ",params)
  1696. if not SceneManager.Instance:IsMainCityorYieldScene() and
  1697. not SceneManager.Instance:IsMirrorDungeonScene() and
  1698. not self:CanDoTaskInEveryScene(params) then
  1699. Message.show("正在副本或活动中")
  1700. return
  1701. end
  1702. self.is_stop = false --去掉停止任务状态 避免有些情况,停止了但不确定从哪个界面出来,没开始任务
  1703. local vip_free_shoe = VipModel:getInstance():CanFreeUseShoe()
  1704. -- if VipModel:getInstance():CanFreeUseShoe() then
  1705. -- use_shoe = true
  1706. -- end
  1707. if task_data.type == TaskType.BOUNTY_LINE or task_data.type == TaskType.GUILD_LINE then
  1708. --跑环类任务需要看看玩家有没有选择自动使用小飞鞋
  1709. if (not vip_free_shoe) and self.circle_auto_use_shoe[task_data.type] then
  1710. --有vip免费小飞鞋,就不要参与判断了
  1711. use_shoe = true
  1712. end
  1713. else
  1714. self.circle_auto_use_shoe = {}
  1715. end
  1716. -- if task_data.type == TaskType.MAIN_LINE then
  1717. -- GlobalEventSystem:Fire(TaskEventType.SHOW_TASK_GUILD_ARROW, false)
  1718. -- end
  1719. -- SceneManager.Instance:ClearPreChangeSceneHandle()
  1720. -- GlobalEventSystem:Fire(EventName.CANCEL_PRE_CHANGE)
  1721. if params and task_data.mainTip == false then
  1722. if self:IsAutoDoTask(task_data) then
  1723. self.now_task_id = task_data.id
  1724. -- 点击任务item的自动寻路,理论上应该也算是玩家自己选择任务,要避免进入多任务选择的逻辑
  1725. DialogueModel:getInstance():SetMultSelectTaskID(task_data.id)
  1726. end
  1727. --新手任务特殊处理,采集完直接弹出对话框
  1728. if task_data.id and task_data.id == 10020 then
  1729. local is_task_finished = true
  1730. for k,vo in pairs(task_data.taskTips) do
  1731. if vo.isFinish == 0 then
  1732. is_task_finished = false
  1733. end
  1734. end
  1735. task_data.need_find_way = is_task_finished and 0 or 1
  1736. end
  1737. local is_daily_task_finished = false
  1738. if task_data and task_data.type == TaskType.BOUNTY_LINE then
  1739. for k,vo in pairs(task_data.taskTips) do
  1740. if vo.isFinish == 1 then
  1741. is_daily_task_finished = true
  1742. end
  1743. end
  1744. end
  1745. if task_data and task_data.type == TaskType.GUILD_LINE then
  1746. is_daily_task_finished = task_data:IsLastTaskTipsFinished()
  1747. print('Ych:TaskModel.lua[1899] data', is_daily_task_finished)
  1748. PrintTable(task_data)
  1749. end
  1750. if is_daily_task_finished then
  1751. GlobalEventSystem:Fire(EventName.OPEN_TASK_CIRCLE_TIPS, task_data.type)
  1752. return
  1753. end
  1754. if task_data.need_find_way == 1 then
  1755. GlobalEventSystem:Fire(EventName.WAYFINDING, params, use_shoe, force_use_shoe)
  1756. else
  1757. --不需要寻路,直接打开npc对话框
  1758. if task_data.tipParam[3] then
  1759. local npc = Scene.Instance:GetNpc(task_data.tipParam[3])
  1760. if npc == nil or not npc:IsInState(PoseState.MOVE) then
  1761. GlobalEventSystem:Fire(SceneEventType.SHOW_TASK, task_data.tipParam[3])
  1762. end
  1763. end
  1764. -- 转职任务,如果是未达成需求等级的话弹出升级引导
  1765. if task_data.type == TaskType.TRUN_LINE and RoleManager.Instance.mainRoleInfo.level < task_data.level then
  1766. GlobalEventSystem:Fire(EventName.SHOW_MAIN_TASK_TIPS_VIEW, true)
  1767. return
  1768. end
  1769. end
  1770. if self:IsAutoDoTask(task_data) then
  1771. --如果当前点击的和上一个完成的任务类型不同,就重置
  1772. if task_data.type ~= self.last_task_type_cache then
  1773. self.last_task_type_cache = nil
  1774. self.last_task_id_cache = nil
  1775. end
  1776. -- GlobalEventSystem:Fire(EventName.STARTAUTOFIGHT,false,true)
  1777. if use_shoe then
  1778. Scene.Instance:CancelClickTarget()
  1779. Scene.Instance.user_manul_time = Status.NowTime
  1780. end
  1781. AutoFightManager:getInstance():CacheGoToPos()
  1782. --重置状态
  1783. self.is_auto_task = true --手动点击,设为true
  1784. self:ResetFlag()
  1785. end
  1786. end
  1787. end
  1788. --重置状态
  1789. function TaskModel:ResetFlag( )
  1790. self.need_accept = nil
  1791. self.is_stop = false
  1792. self.wait_30003 = false
  1793. self.wait_30004 = false
  1794. end
  1795. --获取任务打怪目标,用于自动战斗
  1796. function TaskModel:GetTaskTarget( now )
  1797. local task_data = self:GetCurTask()
  1798. if not task_data then return end
  1799. local params = self:MakeParams(task_data.tipParam)
  1800. if params and task_data.mainTip == false then
  1801. local array=Split(params,",")
  1802. local type=tonumber(array[1])
  1803. if type == TaskTipType.TYPE1 or type == TaskTipType.TYPE6
  1804. and task_data.cur_num<task_data.target_num then
  1805. local id = tonumber(array[3])
  1806. local sceneId = tonumber(array[2])
  1807. local monster = Scene.Instance:FindNearestMonster(id) --附近有怪的话直接自动打怪,没有则随机怪堆
  1808. if monster then
  1809. return monster
  1810. else
  1811. --打死怪物后,30001可能还没通知进度完成,这时可能去下一个打怪点,做下延迟判断
  1812. if now then
  1813. --如果做任务过程,有怪物追着你到npc,接完任务就马上打身边的怪物,
  1814. --打完九宫格内就没怪物了,所以如果附近没怪,要手动寻找怪物点
  1815. local random_pos = self:GetTaskMonsterRandomPos(id, sceneId)
  1816. if random_pos then --随机一堆怪物,解决玩家分流问题,避免玩家扎堆杀怪
  1817. local findVo = FindVo.New()
  1818. findVo.type = FindVo.MONSTER
  1819. findVo.id = id
  1820. findVo.x = random_pos.x
  1821. findVo.y = random_pos.y
  1822. findVo.sceneId = sceneId
  1823. GlobalEventSystem:Fire(EventName.FIND,findVo)
  1824. GlobalEventSystem:Fire(EventName.STARTAUTOFIGHT)
  1825. return
  1826. end
  1827. else
  1828. local onDelay = function ( )
  1829. self.dtimer = nil
  1830. if self.is_auto_task and not self.is_stop then
  1831. self:GetTaskTarget(true)
  1832. end
  1833. end
  1834. if not self.dtimer then
  1835. self.dtimer = setTimeout(onDelay, 1)
  1836. end
  1837. end
  1838. end
  1839. end
  1840. end
  1841. end
  1842. --获取任务打怪目标,用于自动战斗
  1843. function TaskModel:GetTaskTargetId( )
  1844. local task_data = self:GetCurTask()
  1845. if not task_data then return end
  1846. local params = self:MakeParams(task_data.tipParam)
  1847. if params and task_data.mainTip == false then
  1848. local array=Split(params,",")
  1849. local type=tonumber(array[1])
  1850. if type == TaskTipType.TYPE1 or type == TaskTipType.TYPE6
  1851. and task_data.cur_num<task_data.target_num then
  1852. local id = tonumber(array[3])
  1853. return id
  1854. end
  1855. end
  1856. end
  1857. --是否已接采集任务
  1858. function TaskModel:HaveCaiJiTask(content_id)
  1859. local have = false
  1860. local monster_id = nil
  1861. for i,v in ipairs(self._receivedTaskList) do
  1862. if v.task_kind == TaskKind.CAI_JI_KIND and v.id == self.now_task_id and v.cur_num<v.target_num then
  1863. have = true
  1864. if v.content_id == 0 then
  1865. monster_id = content_id
  1866. else
  1867. monster_id = v.content_id
  1868. end
  1869. break
  1870. end
  1871. end
  1872. return have, monster_id
  1873. end
  1874. --随机场景中某堆怪物, 解决玩家分流问题,避免玩家扎堆杀怪
  1875. function TaskModel:GetTaskMonsterRandomPos(monster_id, sceneId)
  1876. local random_logic_pos, random_real_pos, ignore_rush = nil
  1877. local cfg = Config.ConfigWorldMon.SceneMons[tonumber(sceneId)]
  1878. if cfg and cfg.mon_list then
  1879. local monster_heap = cfg.mon_list[tonumber(monster_id)]
  1880. if monster_heap and #monster_heap.way_point > 0 then
  1881. ignore_rush = monster_heap.ignore_rush
  1882. local pos = monster_heap.way_point[math.random(1, #monster_heap.way_point)]
  1883. if pos then
  1884. random_real_pos = pos
  1885. random_logic_pos = {x = pos.x / SceneObj.LogicRealRatio.x, y = pos.y / SceneObj.LogicRealRatio.y}
  1886. end
  1887. end
  1888. end
  1889. return random_logic_pos, random_real_pos, ignore_rush
  1890. end
  1891. --刷新采集任务怪的名字面板,有相应任务时才显示名字面板
  1892. function TaskModel:RefreshCollectMonsterName(content_id)
  1893. for id, monster in pairs(Scene.Instance:GetMonsterList()) do
  1894. if monster:GetVo().type_id == content_id then
  1895. monster.vo:ChangeVar("name", monster.vo.name, nil, true)
  1896. end
  1897. end
  1898. end
  1899. --找出任务的步骤是否已完成
  1900. function TaskModel:FindTaskTipIsFinish(task)
  1901. local finish = false
  1902. if task and task.taskTips then
  1903. for i,v in ipairs(task.taskTips) do
  1904. if v.isFinish == 1 then
  1905. finish = true
  1906. end
  1907. end
  1908. end
  1909. return finish
  1910. end
  1911. --是否主线任务
  1912. function TaskModel:IsMainTask(id)
  1913. local basedata = ConfigItemMgr.Instance:GetTaskData(id)
  1914. if basedata then
  1915. return basedata.type == TaskType.MAIN_LINE
  1916. end
  1917. end
  1918. --是否跑环任务
  1919. function TaskModel:IsCircleTask(id)
  1920. local basedata = ConfigItemMgr.Instance:GetTaskData(id)
  1921. if basedata then
  1922. return basedata.type == TaskType.BOUNTY_LINE or basedata.type == TaskType.GUILD_LINE
  1923. end
  1924. end
  1925. --是否转职任务
  1926. function TaskModel:IsTurnTask(id)
  1927. local basedata = ConfigItemMgr.Instance:GetTaskData(id)
  1928. if basedata then
  1929. return basedata.type == TaskType.TRUN_LINE
  1930. end
  1931. end
  1932. --是否第一个任务
  1933. function TaskModel:IsFisrtTask()
  1934. for i,v in ipairs(self.all_task_list) do
  1935. if v.type == TaskType.MAIN_LINE then
  1936. if v.id == TaskModel.FirstTaskId then
  1937. return true
  1938. end
  1939. end
  1940. end
  1941. end
  1942. --是否要创建飞龙
  1943. function TaskModel:IsCreateDragonTask()
  1944. return self.last_finish_task_id < TaskModel.DragonTaskId
  1945. end
  1946. --任务进度显示
  1947. function TaskModel:GetTaskProgressTip( taskVo )
  1948. local str = string.format("<color='%s'>进度:(<color='%s'>%s</color>/%s)</color>",
  1949. TaskModel.Color.YELLOW, ColorUtil.RED, 0, 1)
  1950. if taskVo.target_num~=0 then
  1951. local color = ColorUtil.GREEN
  1952. if taskVo.cur_num < taskVo.target_num then
  1953. color = ColorUtil.RED
  1954. end
  1955. --暂时支持一个进度显示
  1956. str = string.format("<color='%s'>进度:(<color='%s'>%s</color>/%s)</color>", TaskModel.Color.YELLOW,
  1957. color, taskVo.cur_num, taskVo.target_num)
  1958. end
  1959. return str
  1960. end
  1961. --获取任务颜色
  1962. function TaskModel:GetColorByTaskType( task_type )
  1963. local color_str
  1964. if task_type == TaskType.MAIN_LINE then
  1965. color_str = TaskModel.Color.YELLOW
  1966. elseif task_type == TaskType.EXTENSION_LINE then
  1967. color_str = TaskModel.Color.BLUE
  1968. elseif task_type == TaskType.BOUNTY_LINE then
  1969. color_str = TaskModel.Color.ORANGE
  1970. elseif task_type == TaskType.GUILD_LINE then
  1971. color_str = TaskModel.Color.ORANGE
  1972. elseif task_type == TaskType.LIMIT_LINE then
  1973. color_str = TaskModel.Color.PINK
  1974. elseif task_type == TaskType.TRUN_LINE then
  1975. color_str = TaskModel.Color.PINK
  1976. elseif task_type == TaskType.ACTIVITY_LINE then
  1977. color_str = TaskModel.Color.BLUE
  1978. elseif task_type == TaskType.TREASURE then
  1979. color_str = TaskModel.Color.ORANGE
  1980. elseif task_type == TaskType.DAILY_ACTIVITE then
  1981. color_str = TaskModel.Color.GREEN
  1982. else
  1983. color_str = TaskModel.Color.GREEN
  1984. end
  1985. return color_str
  1986. end
  1987. --获取任务颜色
  1988. function TaskModel:GetColorValueByTaskType( task_type )
  1989. local color_str
  1990. if task_type == TaskType.MAIN_LINE then
  1991. color_str = TaskModel.ColorNoSymbols.YELLOW
  1992. elseif task_type == TaskType.EXTENSION_LINE then
  1993. color_str = TaskModel.ColorNoSymbols.BLUE
  1994. elseif task_type == TaskType.BOUNTY_LINE then
  1995. color_str = TaskModel.ColorNoSymbols.ORANGE
  1996. elseif task_type == TaskType.GUILD_LINE then
  1997. color_str = TaskModel.ColorNoSymbols.ORANGE
  1998. elseif task_type == TaskType.LIMIT_LINE then
  1999. color_str = TaskModel.ColorNoSymbols.PINK
  2000. elseif task_type == TaskType.TRUN_LINE then
  2001. color_str = TaskModel.ColorNoSymbols.PINK
  2002. elseif task_type == TaskType.ACTIVITY_LINE then
  2003. color_str = TaskModel.ColorNoSymbols.BLUE
  2004. else
  2005. color_str = TaskModel.ColorNoSymbols.GREEN
  2006. end
  2007. return color_str
  2008. end
  2009. --任务是否有红点
  2010. function TaskModel:HasTaskRed( )
  2011. return self:HasMainLineRed() or self:HasExtensionTaskAccept() or self:HasBountyRed() or self:HasGuildRed() or self:HasTurnRed()
  2012. end
  2013. --主线任务是否有红点
  2014. function TaskModel:HasMainLineRed( )
  2015. for _, taskVO in ipairs(self._canTaskList) do
  2016. if taskVO.type == TaskType.MAIN_LINE and taskVO.level<=RoleManager.Instance.mainRoleInfo.level then
  2017. return true
  2018. end
  2019. end
  2020. end
  2021. --支线任务是否有红点
  2022. function TaskModel:HasExtensionTaskAccept( )
  2023. for _, taskVO in ipairs(self._canTaskList) do
  2024. if taskVO.type == TaskType.EXTENSION_LINE and taskVO.level<=RoleManager.Instance.mainRoleInfo.level then
  2025. return true
  2026. end
  2027. end
  2028. end
  2029. --转职任务是否有红点
  2030. function TaskModel:HasTurnRed( )
  2031. for _, taskVO in ipairs(self._canTaskList) do
  2032. if taskVO.type == TaskType.TRUN_LINE and taskVO.level<=RoleManager.Instance.mainRoleInfo.level then
  2033. return true
  2034. end
  2035. end
  2036. end
  2037. --悬赏任务是否有红点
  2038. function TaskModel:HasBountyRed( )
  2039. return self:CanAcceptCircleTask(TaskType.BOUNTY_LINE)
  2040. end
  2041. --社团任务是否有红点
  2042. function TaskModel:HasGuildRed( )
  2043. return self:CanAcceptCircleTask(TaskType.GUILD_LINE)
  2044. end
  2045. --任务进度是否完成
  2046. function TaskModel:IsTaskProgressFinish( task )
  2047. if task and task.taskTips then
  2048. for k,v in pairs(task.taskTips) do
  2049. if v.isFinish==0 and v.type~=TaskTipType.TYPE9 then
  2050. return false
  2051. end
  2052. end
  2053. return true
  2054. end
  2055. end
  2056. --显示小飞鞋的任务类型
  2057. function TaskModel:IsShowFlyShoe( data )
  2058. for k,v in pairs(Config.ConfigTaskEffect.circleRewardTaskId) do
  2059. if data.id == v then
  2060. --两个跑环领奖任务不要显示,但是属于跑环类
  2061. return false
  2062. end
  2063. end
  2064. return Config.ConfigTaskEffect.ShowShoeTaskType[data.tipType]
  2065. and (data.type~=TaskType.EXTENSION_LINE or data.acceptType==0)
  2066. and data.type~=TaskType.TREASURE
  2067. end
  2068. --设置社团/赏金任务进度
  2069. function TaskModel:SetCircleTaskInfo( info )
  2070. local set_auto_task = false--跑环任务变更修改自动任务状态
  2071. if info.task_type == TaskType.BOUNTY_LINE then
  2072. if (info.cur_progress == 10) then
  2073. --某个等级之前,完成10环经验跑环,提示做主线
  2074. if self.lask_bounty_process == 9 and RoleManager.Instance.mainRoleInfo.level <= Config.ConfigTaskEffect.DailyTaskFinishShowMainTipsLevel then
  2075. self:ShowMainLineTips(true)
  2076. end
  2077. else
  2078. self.circle_task_info[info.task_type] = info
  2079. end
  2080. self.lask_bounty_process = info.cur_progress
  2081. elseif info.task_type == TaskType.GUILD_LINE then
  2082. self.circle_task_info[info.task_type] = info
  2083. if (self.lask_guild_process == 9 and info.cur_progress == 10) then
  2084. GlobalEventSystem:Fire(EventName.STOP_AUTO_DO_TASK)
  2085. if SceneManager:getInstance():IsMainCityorYieldScene() then
  2086. GlobalEventSystem:Fire(EventName.OPEN_TASK_CIRCLE_TIPS, info.task_type)
  2087. else
  2088. self.wait_circle_show_award_data = info.task_type
  2089. end
  2090. end
  2091. self.lask_guild_process = info.cur_progress
  2092. end
  2093. GlobalEventSystem:Fire(EventName.REFRESH_TASK_CIRCLE_TIPS)
  2094. self:Fire(TaskEvent.TASK_LIST_INIT)
  2095. end
  2096. function TaskModel:GetCircleTaskInfo( task_type )
  2097. return self.circle_task_info[task_type]
  2098. end
  2099. --能否接社团/赏金任务
  2100. function TaskModel:CanAcceptCircleTask( task_type )
  2101. local info = self:GetCircleTaskInfo(task_type)
  2102. return not self:GetTaskByType(task_type) and info and info.cur_progress and info.cur_progress==0
  2103. and ( (task_type==TaskType.BOUNTY_LINE and GetModuleIsOpen(300,1))
  2104. or (task_type==TaskType.GUILD_LINE and GetModuleIsOpen(300,2) and RoleManager.Instance.mainRoleInfo.guild_id>0) )
  2105. end
  2106. --社团任务红点
  2107. function TaskModel:CanAcceptTaskRed( )
  2108. local info = self:GetCircleTaskInfo(TaskType.GUILD_LINE)
  2109. if not info then return end
  2110. return (self:GetTaskByType(TaskType.GUILD_LINE) ~= nil or (RoleManager.Instance.mainRoleInfo.level >= Config.ConfigOpenLv.Other.guild_task and RoleManager.Instance.mainRoleInfo.guild_id>0) and info.cur_progress == 0 )
  2111. end
  2112. --根据任务类型获取直接完成需要消耗的彩钻
  2113. function TaskModel:GetCostFinishTask( task_type )
  2114. local need = 0
  2115. local cfg = Config.Tasktype[task_type]
  2116. local list = false
  2117. if cfg and cfg.finish_cost then
  2118. list = stringtotable(cfg.finish_cost)
  2119. if list[1] and list[1][3] then
  2120. need = tonumber(list[1][3])
  2121. end
  2122. end
  2123. return need,list[1]
  2124. end
  2125. --飞龙任务
  2126. function TaskModel:IsDragonFlyTask()
  2127. for i,v in ipairs(self.all_task_list) do
  2128. if v.type == TaskType.MAIN_LINE then
  2129. if v.id == TaskModel.DragonTaskId and v.acceptType==0 and v.cur_num<v.target_num then
  2130. return true
  2131. end
  2132. end
  2133. end
  2134. end
  2135. --断级主线任务是否需要显示箭头提醒
  2136. function TaskModel:DefaultTaskShowArrow()
  2137. if not self._nextMain then
  2138. return
  2139. end
  2140. local level = self._nextMain.level
  2141. if level and level~=0 and self.default_task_arrow_list[level] == nil then
  2142. self.default_task_arrow_list[level] = true
  2143. GlobalEventSystem:Fire(EventName.TEST_HELP_STEP, 999991007)
  2144. GlobalEventSystem:Fire(EventName.IS_SHOW_TRUN_MASK_HELPER)
  2145. end
  2146. end
  2147. --20秒不动,自动做任务, 副本,杀怪,采集类优先, 然后才是主线任务
  2148. function TaskModel:AutoDoTaskByType( )
  2149. --SceneManager:getInstance():IsEscortScene() or
  2150. if (not SceneManager:getInstance():IsMainCityorYieldScene() and not self.is_stop and not self.is_auto_task) then
  2151. return
  2152. end
  2153. local list = self:GetMainUITaskData()
  2154. local task_data
  2155. for k,v in pairs(list) do
  2156. if v.tipParam and v.tipParam[1] then
  2157. local tip_type = v.tipParam[1]
  2158. if v.acceptType==0 and (tip_type==TaskTipType.TYPE1
  2159. or tip_type==TaskTipType.TYPE2 or tip_type==TaskTipType.TYPE6
  2160. or tip_type==TaskTipType.TYPE18) and self:IsAutoDoTask(v) then
  2161. task_data = v
  2162. break
  2163. end
  2164. end
  2165. end
  2166. if not task_data then
  2167. task_data = self:GetMainTask()
  2168. end
  2169. if task_data and not task_data.mainTip then
  2170. return task_data
  2171. end
  2172. end
  2173. --是否显示武器, 采集任务完成后才显示
  2174. function TaskModel:IsHideMainRoleWeapon( )
  2175. local is_weapon_task_finish = self:IsTaskFinished(Config.ConfigTaskEffect.MonsterWeaponTaskID)
  2176. if RoleManager.Instance.mainRoleInfo.level<4 and not is_weapon_task_finish then
  2177. return true
  2178. else
  2179. return false
  2180. end
  2181. end
  2182. --获取赏金任务提示
  2183. function TaskModel:GetBountyTipTask( )
  2184. if self:CanAcceptCircleTask(TaskType.BOUNTY_LINE) then
  2185. print('Ych:TaskModel.lua[2216] data', data)
  2186. --当日赏金任务任务未做
  2187. local taskVo = TaskVo.New()
  2188. taskVo.level = Config.ConfigOpenLv.Other.bounty_task
  2189. local str = TaskModel.TaskTypeStr3[TaskType.BOUNTY_LINE]
  2190. local cfg = self:GetTaskAcceptNpcConfig(TaskType.BOUNTY_LINE)
  2191. local temp = ConfigItemMgr.Instance:GetNpcItem(cfg.npc_id)
  2192. if not temp then return end
  2193. taskVo.description = "日常每天做一做,升级快战力高,千万不要错过!每完成10环还有特殊奖励,每天凌晨4点重置日常任务!"
  2194. taskVo.taskName = string.format("%s任务", str)
  2195. taskVo.task_name = string.format("%s任务", str)
  2196. taskVo.type = TaskType.BOUNTY_LINE
  2197. taskVo.isTipTask = true
  2198. taskVo.need_find_way = 1
  2199. taskVo.target_num = 0
  2200. taskVo.order = 0
  2201. taskVo.id = Config.ConfigTaskEffect.bountyTaskTipId
  2202. taskVo.task_id = Config.ConfigTaskEffect.bountyTaskTipId
  2203. taskVo.tips = string.format("寻找<color=#2CF66F>%s</color>", Trim(temp.name))
  2204. taskVo.sortKey = Config.ConfigTaskEffect.TaskTypeSort[taskVo.type] --任务类型排序
  2205. taskVo.taskTips = {}
  2206. taskVo.taskTips[1] = TaskTipsVo.New()
  2207. taskVo.taskTips[1].type = TaskTipType.TYPE0
  2208. taskVo.taskTips[1].id = cfg.npc_id
  2209. taskVo.taskTips[1].sceneId = cfg.scene_id
  2210. taskVo.taskTips[1].need_find_way = 1
  2211. taskVo.tipParam={taskVo.type, cfg.scene_id, cfg.npc_id, taskVo.id}
  2212. -------------------------
  2213. local basedata=ConfigItemMgr.Instance:GetTaskData(70010001)
  2214. if basedata then
  2215. taskVo.award_list = stringtotable(basedata.award_list)
  2216. end
  2217. for k,v in pairs(taskVo.award_list) do
  2218. if tonumber(v[2]) == 100007 then
  2219. v[3] = v[3] + NewMainRoleModel:getInstance():GetRoleActivityBaseExp( ) * DailyModel:GetInstance():GetBackAwardPer( 300, 1 )
  2220. end
  2221. end
  2222. -------------------------
  2223. return taskVo
  2224. end
  2225. end
  2226. --获取社团任务提示
  2227. function TaskModel:GetGuildTipTask( )
  2228. if self:CanAcceptCircleTask(TaskType.GUILD_LINE) then
  2229. --当日社团任务任务未做
  2230. local taskVo = TaskVo.New()
  2231. taskVo.level = Config.ConfigOpenLv.Other.guild_task
  2232. local str = TaskModel.TaskTypeStr3[TaskType.GUILD_LINE]
  2233. local cfg = self:GetTaskAcceptNpcConfig(TaskType.GUILD_LINE)
  2234. local temp = ConfigItemMgr.Instance:GetNpcItem(cfg.npc_id)
  2235. if not temp then return end
  2236. taskVo.description = "凡是会长说的!砸锅卖铁也要干——《社团成员守则节选》!每10环社团任务还会有特殊阶段奖励!撸起袖子加油吧!每周一凌晨4点重置社团任务!"
  2237. taskVo.taskName = string.format("%s任务", str)
  2238. taskVo.task_name = string.format("%s任务", str)
  2239. taskVo.type = TaskType.GUILD_LINE
  2240. taskVo.isTipTask = true
  2241. taskVo.target_num = 0
  2242. taskVo.order = 0
  2243. taskVo.need_find_way = 1
  2244. taskVo.id = Config.ConfigTaskEffect.guildTaskTipId
  2245. taskVo.task_id = Config.ConfigTaskEffect.guildTaskTipId
  2246. taskVo.tips = string.format("寻找<color=#2CF66F>%s</color>", Trim(temp.name))
  2247. taskVo.sortKey = Config.ConfigTaskEffect.TaskTypeSort[taskVo.type] --任务类型排序
  2248. taskVo.taskTips = {}
  2249. taskVo.taskTips[1] = TaskTipsVo.New()
  2250. taskVo.taskTips[1].type = TaskTipType.TYPE0
  2251. taskVo.taskTips[1].id = cfg.npc_id
  2252. taskVo.taskTips[1].sceneId = cfg.scene_id
  2253. taskVo.taskTips[1].need_find_way = 1
  2254. taskVo.tipParam={taskVo.type, cfg.scene_id, cfg.npc_id, taskVo.id}
  2255. -------------------------
  2256. local basedata=ConfigItemMgr.Instance:GetTaskData(60010001)
  2257. if basedata then
  2258. taskVo.award_list = stringtotable(basedata.award_list)
  2259. end
  2260. for k,v in pairs(taskVo.award_list) do
  2261. if tonumber(v[2]) == 100007 then
  2262. v[3] = v[3] + NewMainRoleModel:getInstance():GetRoleActivityBaseExp( ) * DailyModel:GetInstance():GetBackAwardPer( 300, 2 )
  2263. end
  2264. end
  2265. -------------------------
  2266. return taskVo
  2267. end
  2268. end
  2269. --获取特殊支线步骤
  2270. function TaskModel:GetExtendSpecialTip( task )
  2271. if task and task.taskTips then
  2272. for k,v in pairs(task.taskTips) do
  2273. if Config.ConfigTaskEffect.NeedClickTaskType[v.type] then
  2274. return v
  2275. end
  2276. end
  2277. end
  2278. end
  2279. -- 获取下一阶段转职任务(不可接取的情况)
  2280. function TaskModel:GetTurnTipTask( )
  2281. local mainVo = RoleManager.Instance.mainRoleInfo
  2282. -- 当前【转职任务】阶数为0,表示当前还没开始转职任务的第一阶段,第一阶段要到达对应等级直接接任务开始
  2283. if not mainVo.turn_stage or mainVo.turn_stage == 0 then return nil end
  2284. local taskVo = nil
  2285. local key = (mainVo.turn+1).."@"..(mainVo.turn_stage+1)
  2286. local task_cfg = Config.Transfer[key]
  2287. if task_cfg and task_cfg.need_lev > mainVo.level then -- 要确定当前确实不可以接这个任务
  2288. local basedata = ConfigItemMgr.Instance:GetTaskData(tonumber(task_cfg.task_id))
  2289. taskVo = TaskVo.New()
  2290. taskVo.level = task_cfg.need_lev
  2291. local str = TaskModel.TaskTypeStr3[TaskType.TRUN_LINE]
  2292. taskVo.description = "%s级可继续转职任务"
  2293. taskVo.taskName = Trim(basedata.name)
  2294. taskVo.type = TaskType.TRUN_LINE
  2295. taskVo.isTipTask = true
  2296. taskVo.cur_num = mainVo.level
  2297. taskVo.target_num = task_cfg.need_lev
  2298. taskVo.order = 0
  2299. taskVo.need_find_way = 0
  2300. taskVo.id = task_cfg.task_id
  2301. taskVo.tips = string.format("<color=#2CF66F>%s</color>级继续任务", task_cfg.need_lev)
  2302. taskVo.sortKey = Config.ConfigTaskEffect.TaskTypeSort[taskVo.type] or 99 --任务类型排序
  2303. -- taskVo.tipContent="<color="..TaskModel.Color.WHITE..">("..taskVo.cur_num.."/"..taskVo.target_num..")</color>"
  2304. taskVo.tipContent=string.format("<color=#2CF66F>%s</color>级继续任务(<color=#f14041>%s</color>/%s)",
  2305. task_cfg.need_lev, taskVo.cur_num, taskVo.target_num)
  2306. taskVo.taskTips = {}
  2307. -- taskVo.taskTips[1] = TaskTipsVo.New()
  2308. -- taskVo.taskTips[1].type = TaskTipType.TYPE0
  2309. -- taskVo.taskTips[1].id = cfg.npc_id
  2310. -- taskVo.taskTips[1].sceneId = cfg.scene_id
  2311. -- taskVo.taskTips[1].need_find_way = 1
  2312. -- taskVo.tipParam={taskVo.type, cfg.scene_id, cfg.npc_id, taskVo.id}
  2313. end
  2314. return taskVo
  2315. end
  2316. function TaskModel:GetTreasureTask(type)
  2317. self.treasure_task_list = self.treasure_task_list or {}
  2318. if not self.treasure_task_list[type] then
  2319. local treasure_task = TaskVo.New()
  2320. treasure_task.id = Config.ConfigTaskEffect.TreasureMapTaskId
  2321. treasure_task.level = 1
  2322. treasure_task.type = TaskType.TREASURE
  2323. treasure_task.sub_type = type
  2324. treasure_task.taskName = type == TreasureMapConst.Normal and "普通藏宝图" or "高级藏宝图"
  2325. treasure_task.tipContent = ""
  2326. treasure_task.isSend = 1;
  2327. treasure_task.acceptType = 0
  2328. treasure_task.tipType = TaskType.TREASURE
  2329. treasure_task.isFake = true
  2330. treasure_task.sortKey = Config.ConfigTaskEffect.TaskTypeSort[TaskType.TREASURE]
  2331. treasure_task.taskTips = {}
  2332. treasure_task.taskTips[1] = TaskTipsVo.New()
  2333. treasure_task.taskTips[1].type = TaskTipType.TYPE0
  2334. treasure_task.taskTips[1].id = 0
  2335. treasure_task.taskTips[1].sceneId = 0
  2336. treasure_task.taskTips[1].need_find_way = 1
  2337. treasure_task.tipParam = {TaskType.TREASURE, 0, 0, 0};
  2338. self.treasure_task_list[type] = treasure_task
  2339. end
  2340. return self.treasure_task_list[type]
  2341. end
  2342. --获取当前的主线任务id 协议返回的是上一个完成的任务id, 加1就行了, 用于判断任务开放的功能
  2343. function TaskModel:GetMainTaskId( )
  2344. return self.last_finish_task_id + 1
  2345. end
  2346. --获取该npc的任务状态
  2347. function TaskModel:GetNpcState( npc_id )
  2348. for k,v in ipairs(self.all_task_list) do
  2349. if v.taskTips and (v.type==TaskType.GUILD_LINE or v.type==TaskType.BOUNTY_LINE) then
  2350. local len = #v.taskTips
  2351. local start_npc = 0 --非对话步骤,没有npc_id,判断是否和开始npc一样就行了
  2352. for m,n in ipairs(v.taskTips) do
  2353. if n.type==TaskTipType.TYPE8 or n.type==TaskTipType.TYPE7 then
  2354. start_npc = n.id
  2355. break
  2356. end
  2357. end
  2358. -------------------------
  2359. if npc_id == v.tipParam[3] then
  2360. -------------------------
  2361. for m,n in ipairs(v.taskTips) do
  2362. if (n.isFinish==0 or m==len) then
  2363. if n.type==TaskTipType.TYPE8 or n.type==TaskTipType.TYPE7 then
  2364. if n.id==npc_id then
  2365. return 1
  2366. end
  2367. elseif n.type == TaskTipType.TYPE9 then
  2368. if n.id==npc_id then
  2369. return 3
  2370. end
  2371. elseif n.type == TaskTipType.TYPE38 then
  2372. if n.id==npc_id then
  2373. return 3
  2374. end
  2375. else
  2376. if npc_id == start_npc then
  2377. return 2
  2378. end
  2379. end
  2380. end
  2381. end
  2382. end
  2383. end
  2384. end
  2385. end
  2386. --开始做日常任务
  2387. function TaskModel:DoBountyTask( )
  2388. local task
  2389. if self:HasBountyRed() then
  2390. task = self:GetBountyTipTask()
  2391. else
  2392. task = self:GetTaskByType(TaskType.BOUNTY_LINE)
  2393. end
  2394. self:TaskClickFun(task)
  2395. end
  2396. --开始做社团任务
  2397. function TaskModel:DoGuildTask( )
  2398. local task
  2399. if self:HasGuildRed() then
  2400. task = self:GetGuildTipTask()
  2401. else
  2402. task = self:GetTaskByType(TaskType.GUILD_LINE)
  2403. end
  2404. self:TaskClickFun(task)
  2405. end
  2406. --是否自动做的任务
  2407. function TaskModel:IsAutoDoTask( task )
  2408. if task and task.type and task.type==TaskType.LIMIT_LINE then
  2409. return false
  2410. end
  2411. if task and (task.id == Config.ConfigTaskEffect.bountyTaskTipId or task.id == Config.ConfigTaskEffect.guildTaskTipId) then
  2412. return true
  2413. end
  2414. if task and task.tipParam and task.tipParam[1] then
  2415. if task.tipParam[1]==TaskTipType.TYPE2 then
  2416. if task.type == TaskType.EXTENSION_LINE then
  2417. --社团和赏金的副本是需要自动做的
  2418. return false
  2419. else
  2420. return true
  2421. end
  2422. else
  2423. return not Config.ConfigTaskEffect.NotNeedAutoTaskType[task.tipParam[1]]
  2424. end
  2425. end
  2426. end
  2427. --是否点一下才能完成的支线任务
  2428. function TaskModel:IsNeedClickTask( task )
  2429. if task and task.tipParam and task.tipParam[1] then
  2430. if task.tipParam[1]==TaskTipType.TYPE2 then
  2431. if task.type == TaskType.EXTENSION_LINE then
  2432. return true
  2433. else
  2434. return false
  2435. end
  2436. else
  2437. return Config.ConfigTaskEffect.NeedClickTaskType[task.tipParam[1]]
  2438. end
  2439. end
  2440. end
  2441. --是否点一下才能完成的支线任务 步骤
  2442. function TaskModel:IsNeedClickTipTask( tip_type, task_type )
  2443. if tip_type==TaskTipType.TYPE2 then
  2444. if task_type == TaskType.EXTENSION_LINE then
  2445. return true
  2446. else
  2447. return false
  2448. end
  2449. else
  2450. return Config.ConfigTaskEffect.NeedClickTaskType[tip_type]
  2451. end
  2452. end
  2453. --判断是否有转职任务
  2454. function TaskModel:HasTurnLine( )
  2455. for k,v in pairs(self.all_task_list) do
  2456. if v.type == TaskType.TRUN_LINE then
  2457. return true
  2458. end
  2459. end
  2460. end
  2461. ----- 转职任务相关特殊处理 -----
  2462. -- 当前任务是否需要打开转职引导界面
  2463. function TaskModel:NeedOpenTurnMainView(task_vo)
  2464. if not task_vo then return true end
  2465. if Config.ConfigTaskEffect.OpenMainTurnTaskViewId[task_vo.id] then return true end
  2466. return false
  2467. end
  2468. -- 是否是可以继续自动进行的转职任务
  2469. function TaskModel:NeedAutoDoTurnTask(task_vo)
  2470. -- 打怪任务之外,其他的任务均不可自动继续
  2471. if not task_vo then return false end
  2472. local taskTipVO = task_vo.taskTips and task_vo.taskTips[1]
  2473. if taskTipVO and taskTipVO.type == TaskTipType.TYPE1 then --击败怪物
  2474. return true
  2475. end
  2476. if taskTipVO and taskTipVO.isFinish == 1 then -- 任务已经完成,可以自动前往
  2477. return true
  2478. end
  2479. return false
  2480. end
  2481. -- 记录完成转职任务时的等级,用于判断后续接取的任务是不是在卡级阶段
  2482. -- 是的话则不自动进行任务
  2483. function TaskModel:RecordProcessingTurnTaskLevel( )
  2484. self.recorded_finish_turn_task_lv = RoleManager.Instance.mainRoleInfo.level
  2485. end
  2486. -- 当前接取到的转职任务是否时卡级阶段
  2487. function TaskModel:IsNewTurnTaskInLimitLv( )
  2488. -- print("Saber:TaskModel [2699] self.recorded_finish_turn_task_lv: ",self.recorded_finish_turn_task_lv)
  2489. -- print("Saber:TaskModel [2700] RoleManager.Instance.mainRoleInfo.level: ",RoleManager.Instance.mainRoleInfo.level)
  2490. return self.recorded_finish_turn_task_lv < RoleManager.Instance.mainRoleInfo.level
  2491. end
  2492. ----- 转职任务相关特殊处理 -----
  2493. --是否在等待30003或者30004, 如果请求了这两条, 返回后才刷新界面和做任务,否则可能数据是旧的
  2494. function TaskModel:IsWaitProto( )
  2495. return self.wait_30003 or self.wait_30004
  2496. end
  2497. function TaskModel:HideRoleWeapon( )
  2498. --采集完武器,显示武器模型
  2499. local role = Scene.Instance:GetMainRole()
  2500. if role then
  2501. if self:IsHideMainRoleWeapon() then
  2502. role:HideAllWeapon(Character.WeaponHideFlag.Story)
  2503. else
  2504. role:ShowAllWeapon(Character.WeaponHideFlag.Story)
  2505. end
  2506. end
  2507. end
  2508. --获取任务面板的支线数据
  2509. function TaskModel:GetExtensionTabData()
  2510. local tab_data = {
  2511. [1] = {main_tab = "已接支线", sub_tab = {}},
  2512. [2] = {main_tab = "可接支线", sub_tab = {}},
  2513. }
  2514. local one = {}
  2515. local data1 = {}
  2516. local two = {}
  2517. local data2 = {}
  2518. self.all_task_list = self:SortFun(self.all_task_list)
  2519. for i,v in ipairs(self.all_task_list) do
  2520. if v.type == TaskType.EXTENSION_LINE then
  2521. if v.acceptType == 0 then
  2522. table.insert(data1, v)
  2523. else
  2524. table.insert(data2, v)
  2525. end
  2526. end
  2527. end
  2528. tab_data[1].sub_tab = data1
  2529. tab_data[2].sub_tab = data2
  2530. return tab_data
  2531. end
  2532. function TaskModel:GetDoubleExp(id)
  2533. local exp = 0
  2534. local level = 0
  2535. local playerLv = RoleManager:getInstance():GetMainRoleVo().level
  2536. for index,data in pairs(Config.Taskexpmodulelv) do
  2537. if data.module_id == id and playerLv >= data.min_lv and playerLv <= data.max_lv then
  2538. exp = data.exp
  2539. break
  2540. end
  2541. end
  2542. if exp ~= 0 then
  2543. local curr_exp = RoleManager.Instance.mainRoleInfo.exp
  2544. local total_exp = curr_exp + exp
  2545. local need_exp = Config.Exp[playerLv].exp
  2546. --如果不够一级
  2547. if total_exp < need_exp then
  2548. level = GetPreciseDecimal(exp / need_exp,1)
  2549. elseif total_exp == need_exp then
  2550. level = 1
  2551. else
  2552. local len = #Config.Exp - 1 --最后一级是 0
  2553. local lv_exp = nil
  2554. for i = playerLv,len do
  2555. lv_exp = Config.Exp[i].exp
  2556. if total_exp > lv_exp then
  2557. level = level + 1
  2558. total_exp = total_exp - lv_exp
  2559. else
  2560. level = level + GetPreciseDecimal(total_exp / lv_exp,1)
  2561. break
  2562. end
  2563. end
  2564. end
  2565. end
  2566. if level <= 0.1 then
  2567. level = 0.1
  2568. end
  2569. return exp,level
  2570. end
  2571. function TaskModel:SetTaskAutoFlag(bool)
  2572. self.is_auto_task = bool
  2573. end
  2574. --获取是否自动任务中
  2575. function TaskModel:GetTaskAutoFlag()
  2576. return self.is_auto_task
  2577. end
  2578. function TaskModel:IsLoseAutoTaskDungeon(dun_id)
  2579. if SceneManager.Instance:IsGodHoodDungeon(dun_id) or SceneManager.Instance:IsGemDungeon(dun_id) then
  2580. return true
  2581. end
  2582. return false
  2583. end
  2584. --主线是否完成
  2585. function TaskModel:IsMainTaskFinish(task_id)
  2586. if task_id <= self.last_finish_task_id then
  2587. return true
  2588. end
  2589. return false
  2590. end
  2591. --主线是否完成
  2592. function TaskModel:IsEnterDungeonTask()
  2593. local task = TaskModel:getInstance():GetCurTask()
  2594. if task then
  2595. for k,v in pairs(task.taskTips) do
  2596. if v.isFinish == 0 then
  2597. if v.type==TaskTipType.TYPE2 then
  2598. return true
  2599. else
  2600. return false
  2601. end
  2602. end
  2603. end
  2604. end
  2605. return false
  2606. end
  2607. --主线是否完成
  2608. function TaskModel:CanDoTaskInEveryScene(param)
  2609. local array=Split(param,",")
  2610. if array and #array > 0 then
  2611. local type = tonumber(array[1])
  2612. if Config.ConfigTaskEffect.NeedClickTaskType[type] then
  2613. --点击判断是否已经完成任务,是的话发协议完成任务
  2614. local task = TaskModel:getInstance():GetTaskById(tonumber(array[4]))
  2615. if self:IsNeedClickTask(task) then
  2616. local tip = self:GetExtendSpecialTip(task)
  2617. if tip and tip.isFinish==1 then
  2618. return true
  2619. end
  2620. end
  2621. end
  2622. if type == TaskTipType.TYPE41 or type == TaskTipType.TYPE25 or type == TaskTipType.TYPE101 or type == TaskTipType.TYPE104 or type == TaskTipType.TYPE105 or
  2623. type == TaskTipType.TYPE106 or type == TaskTipType.TYPE108 or type == TaskTipType.TYPE109 or type == TaskTipType.TYPE110 or type == TaskTipType.TYPE23 or
  2624. type == TaskTipType.TYPE24 or type == TaskTipType.TYPE26 then
  2625. return true
  2626. end
  2627. end
  2628. return false
  2629. end
  2630. --获取接取任务的npc配置
  2631. function TaskModel:GetTaskAcceptNpcConfig(task_type)
  2632. local npc_cfg = Config.ConfigTaskEffect.npc
  2633. if KfWorldModel:GetInstance():IsKFCityOpen() then
  2634. npc_cfg = Config.ConfigTaskEffect.kfNpc
  2635. end
  2636. if task_type then
  2637. return npc_cfg[task_type]
  2638. else
  2639. return npc_cfg
  2640. end
  2641. end
  2642. --主线是否完成
  2643. function TaskModel:SetNeedTaskFlag(bool)
  2644. self.need_task = bool
  2645. end
  2646. --主线是否完成
  2647. function TaskModel:NeedShowExtendTip()
  2648. local playerLv = RoleManager:getInstance():GetMainRoleVo().level
  2649. if playerLv > 150 then
  2650. return false
  2651. end
  2652. for index,taskVO in pairs(self.all_task_list) do
  2653. if taskVO.type == TaskType.MAIN_LINE or taskVO.type == TaskType.BOUNTY_LINE or taskVO.type == TaskType.GUILD_LINE or taskVO.type == TaskType.TRUN_LINE then
  2654. return false
  2655. end
  2656. end
  2657. if self:GetBountyTipTask() or self:GetGuildTipTask() then
  2658. return false
  2659. end
  2660. return true
  2661. end
  2662. function TaskModel:NeedFindWayTask(type)
  2663. local need = false
  2664. if type == TaskTipType.TYPE0 or type == TaskTipType.TYPE7 or type == TaskTipType.TYPE8 or
  2665. type == TaskTipType.TYPE9 or type == TaskTipType.TYPE1 or type == TaskTipType.TYPE18 or
  2666. type == TaskTipType.TYPE6 or type == TaskTipType.TYPE2 or type == TaskTipType.TYPE38 then
  2667. need = true
  2668. end
  2669. return need
  2670. end
  2671. function TaskModel:SetCollectTaskId(task_id)
  2672. self.collect_task_id = task_id
  2673. end
  2674. function TaskModel:ClearCollectTaskId()
  2675. self.collect_task_id = false
  2676. end
  2677. function TaskModel:GetCollectTaskId()
  2678. return self.collect_task_id
  2679. end
  2680. function TaskModel:IsTaskFinished( id )
  2681. if self.finish_task_list then
  2682. local flag = false
  2683. if self.finish_task_list[id] then
  2684. flag = true
  2685. end
  2686. return flag
  2687. end
  2688. end
  2689. function TaskModel:SetFinishTaskList( list )--已完成任务列表
  2690. self.finish_task_list = list
  2691. GlobalEventSystem:Fire(TaskEvent.ANS_FINISHED_TASK_LIST)
  2692. end
  2693. function TaskModel:AddFinishTask( id )
  2694. local story_id = Config.ConfigTaskEffect.TaskStoryID[id]
  2695. if story_id then
  2696. self:SetTriggerStoryId(story_id)
  2697. end
  2698. self.finish_task_list[id] = id
  2699. if self.task_listen_list and self.task_listen_list[id] then
  2700. GlobalEventSystem:Fire(TaskEvent.ANS_FINISHED_TASK_LIST,id)
  2701. end
  2702. end
  2703. function TaskModel:SetTriggerStoryId( id )
  2704. self.trigger_story_id = id
  2705. end
  2706. function TaskModel:GetTriggerStoryId( )
  2707. return self.trigger_story_id
  2708. end
  2709. -- 2019年11月4日新增 : 获取可选任务内容配置
  2710. function TaskModel:GetOptionalTaskCfg(task_id)
  2711. if not task_id then return nil end
  2712. local talk_cfg = {}
  2713. local choose_talk_cfg = Config.Choosetalk[task_id]
  2714. if choose_talk_cfg then
  2715. talk_cfg.intellect = choose_talk_cfg.intellect
  2716. talk_cfg.nastic = choose_talk_cfg.nastic
  2717. talk_cfg.indecision = choose_talk_cfg.indecision
  2718. talk_cfg.value = choose_talk_cfg.value
  2719. talk_cfg.talk_list = {}
  2720. -- 让对话id小的在前
  2721. -- 1 理性, 2,感性 3中性
  2722. local temp = {}
  2723. temp[choose_talk_cfg.intellect] = 1
  2724. temp[choose_talk_cfg.nastic] = 2
  2725. if choose_talk_cfg.indecision then -- 不一定有第三个选项
  2726. temp[choose_talk_cfg.indecision] = 3
  2727. end
  2728. for k,v in pairsByKeys(temp) do
  2729. local index = #talk_cfg.talk_list+1
  2730. talk_cfg.talk_list[index] = ConfigItemMgr.Instance:GetTalkItem(k)
  2731. talk_cfg.talk_list[index].choose_type = v
  2732. end
  2733. -- if choose_talk_cfg.intellect < choose_talk_cfg.nastic then
  2734. -- talk_cfg.intellect_first = true
  2735. -- talk_cfg.talk_list[#talk_cfg.talk_list+1] = ConfigItemMgr.Instance:GetTalkItem(choose_talk_cfg.intellect)
  2736. -- talk_cfg.talk_list[#talk_cfg.talk_list+1] = ConfigItemMgr.Instance:GetTalkItem(choose_talk_cfg.nastic)
  2737. -- else
  2738. -- talk_cfg.intellect_first = false
  2739. -- talk_cfg.talk_list[#talk_cfg.talk_list+1] = ConfigItemMgr.Instance:GetTalkItem(choose_talk_cfg.nastic)
  2740. -- talk_cfg.talk_list[#talk_cfg.talk_list+1] = ConfigItemMgr.Instance:GetTalkItem(choose_talk_cfg.intellect)
  2741. -- end
  2742. -- talk_cfg.reback = ConfigItemMgr.Instance:GetTalkItem(choose_talk_cfg.reback)
  2743. else
  2744. return nil
  2745. end
  2746. return talk_cfg
  2747. end
  2748. -- 根据npcid获取目标npc身上的任务
  2749. function TaskModel:GetTaskDataByNpcId(npc_id)
  2750. local tb = {}
  2751. if not npc_id then return tb end
  2752. for k, task_vo in pairs(self.all_task_list) do
  2753. if task_vo.end_npc == npc_id then
  2754. tb[#tb+1] = task_vo
  2755. end
  2756. end
  2757. return tb
  2758. end
  2759. --动态任务内容配置
  2760. function TaskModel:DynamicTaskConf( task_id )
  2761. for k,v in pairs(Config.Typetaskdynamic) do
  2762. if v.task_id == task_id then
  2763. return v
  2764. end
  2765. end
  2766. end
  2767. --取得包含该副本id的任务信息
  2768. function TaskModel:GetTaskVoByDungeonID( dun_id )
  2769. for i,v in ipairs(self.all_task_list) do
  2770. if v.tipParam then
  2771. local task_tip_type = v.tipParam[1]
  2772. local is_dun_type = task_tip_type == TaskTipType.TYPE2 or task_tip_type == TaskTipType.TYPE102
  2773. local dun_id_in_task_info = v.tipParam[3]
  2774. if is_dun_type and dun_id_in_task_info == dun_id then
  2775. --副本类型的任务
  2776. return v
  2777. end
  2778. end
  2779. end
  2780. return nil
  2781. end
  2782. --新手期显示章节任务UI
  2783. function TaskModel:IsShowChapterTask( )
  2784. return not self:IsTaskFinished(Config.ConfigTaskEffect.LastChapterTaskId)
  2785. end
  2786. --设置切换场景类型,任务寻路的时候,走到传送阵的时候传送类型是4(无视场景数量,直达最终场景)
  2787. function TaskModel:SetChangeSceneType( type, find_vo )
  2788. self.task_change_scene_type = type
  2789. self.task_change_scene_vo = find_vo
  2790. end
  2791. function TaskModel:GetChangeSceneType( )
  2792. return self.task_change_scene_type, self.task_change_scene_vo
  2793. end
  2794. --获取任务栏item的高度
  2795. function TaskModel:GetTaskItemHeight( data )
  2796. local temp_height = 52 --一行文本
  2797. if not data then
  2798. return temp_height
  2799. end
  2800. if data.tipType == TaskTipType.TYPE40 then --商城购买支线
  2801. if data.is_money_enough or self:IsTaskProgressFinish(data) then
  2802. temp_height = 72 --两行文本
  2803. else
  2804. temp_height = 92 --三行文本
  2805. local equip_type = EquipModel:getInstance():GetEquipType( data.tipParam[3] )
  2806. if equip_type then
  2807. local type_const = EquipModel.EquipType
  2808. if equip_type == type_const.Guard or equip_type == type_const.LeftRing
  2809. or equip_type == type_const.RightRing or equip_type == type_const.Necklace then
  2810. -- 守护戒指耳饰类--项链类
  2811. temp_height = 72
  2812. end
  2813. end
  2814. end
  2815. elseif data.tipType == TaskTipType.TYPE1002 then -- 成就
  2816. local str = DeleteColorTag(data.tipContent)
  2817. local str_width = self:CalStrWidth(str)
  2818. local per_width = 188
  2819. local line_count = math.ceil(str_width / per_width)
  2820. -- print('Msh:TaskModel.lua[2664] data', str_width, per_width, str)
  2821. if line_count == 1 then
  2822. temp_height = 52
  2823. elseif line_count == 2 then
  2824. temp_height = 72
  2825. elseif line_count == 3 then
  2826. temp_height = 92
  2827. end
  2828. elseif data.tipType == TaskTipType.TYPE42 then --亲密度支线
  2829. temp_height = 72
  2830. elseif data.tipType == TaskTipType.TYPE100 then--赏金幻魔
  2831. temp_height = 72
  2832. elseif data.tipType == TaskTipType.TYPE102 then --完成某副本类型
  2833. if data.tipParam[3] == BaseDungeonModel.DUN_TYPE.PersonBoss then
  2834. temp_height = 72
  2835. end
  2836. elseif data.tipType == TaskTipType.TYPE24 then --活跃度
  2837. temp_height = 72
  2838. -- elseif data.type == TaskType.BOUNTY_LINE or data.type == TaskType.GUILD_LINE then --跑环支线
  2839. -- temp_height = 72 --一行文本+按钮
  2840. elseif data.tipType == TaskTipType.TYPE57 then --完成预期任务
  2841. temp_height = 72
  2842. elseif data.tipType == TaskTipType.TYPE48 then --晒娃
  2843. temp_height = 72
  2844. elseif data.tipType == TaskTipType.TYPE58 then --宝宝同心值
  2845. temp_height = 72
  2846. elseif data.tipType == TaskTipType.TYPE59 then --战力
  2847. temp_height = 72
  2848. elseif TaskModel.TaskTurnBossTaskId[data.id] then--转职任务boss战任务id
  2849. temp_height = 72
  2850. end
  2851. return temp_height
  2852. end
  2853. --当前存在此任务列表,并且 有一个任务没完成
  2854. function TaskModel:IsTaskListUnFinished(task_list)
  2855. if not task_list or #task_list == 0 then
  2856. return false
  2857. end
  2858. local is_all_finished = true
  2859. for k,v in pairs(task_list) do
  2860. for ii,vv in ipairs(self.all_task_list) do
  2861. if vv.id == v then
  2862. return true
  2863. end
  2864. end
  2865. end
  2866. return false
  2867. end
  2868. --是否完成了前面一个任务,并且没完成后面一个任务
  2869. function TaskModel:IsBetweenTaskListState(task_list)
  2870. if not task_list or #task_list ~= 2 then
  2871. return false
  2872. end
  2873. local b = false
  2874. local pre_task_id, next_task_id = task_list[1], task_list[2]
  2875. if self:IsTaskFinished(pre_task_id) and not self:IsTaskFinished(next_task_id) then
  2876. b = true
  2877. end
  2878. return b
  2879. end
  2880. --是否可领取跑环奖励
  2881. function TaskModel:CanCircleReward( task_type )
  2882. if not task_type then return end
  2883. local info = self:GetCircleTaskInfo(task_type)
  2884. if not info then
  2885. return false
  2886. end
  2887. local reward_progress = info and info.reward_progress or 0
  2888. if reward_progress == 0 and info.cur_progress >= 10 then
  2889. return reward_progress
  2890. elseif reward_progress <= 1 and info.cur_progress >= 20 then
  2891. return reward_progress
  2892. end
  2893. return false
  2894. end
  2895. --跑环的十环领取任务
  2896. function TaskModel:GetCircleExtraTask( task_type )
  2897. if not task_type then return end
  2898. local can_reward = self:CanCircleReward( task_type ) and true or false
  2899. if can_reward then
  2900. --可领取十环奖励
  2901. local taskVo = TaskVo.New()
  2902. taskVo.level = 1
  2903. local str = TaskModel.TaskTypeStr3[task_type]
  2904. local cfg = self:GetTaskAcceptNpcConfig(task_type)
  2905. local temp = ConfigItemMgr.Instance:GetNpcItem(cfg.npc_id)
  2906. if not temp then return end
  2907. taskVo.description = "每完成10环有特殊奖励!"
  2908. taskVo.taskName = string.format("%s任务", str)
  2909. taskVo.task_name = string.format("%s任务", str)
  2910. taskVo.type = task_type
  2911. taskVo.isTipTask = true
  2912. taskVo.need_find_way = 1
  2913. taskVo.target_num = 0
  2914. taskVo.order = 0
  2915. taskVo.id = Config.ConfigTaskEffect.circleRewardTaskId[task_type]
  2916. taskVo.task_id = Config.ConfigTaskEffect.circleRewardTaskId[task_type]
  2917. taskVo.tips = "领取环数奖励"--string.format("寻找<color=#2CF66F>%s</color>", Trim(temp.name))
  2918. taskVo.sortKey = 0 --任务类型排序
  2919. taskVo.taskTips = {}
  2920. taskVo.taskTips[1] = TaskTipsVo.New()
  2921. taskVo.taskTips[1].type = TaskTipType.TYPE0
  2922. taskVo.taskTips[1].id = cfg.npc_id
  2923. taskVo.taskTips[1].sceneId = cfg.scene_id
  2924. taskVo.taskTips[1].need_find_way = 1
  2925. taskVo.tipParam={taskVo.type, cfg.scene_id, cfg.npc_id, taskVo.id}
  2926. taskVo.award_list = {}
  2927. -------------------------
  2928. return taskVo
  2929. end
  2930. end
  2931. ----------推荐成就-start---------
  2932. -- 直接拉取
  2933. function TaskModel:SetAchiTaskVo( list )
  2934. local level = RoleManager.Instance.mainRoleInfo.level
  2935. if level < 150 then return end
  2936. --如果所有的任务数量,超过6个则不显示可接的成就,否则填充至6个(已经完成的,不算最大数量里面)
  2937. local cur_task_count = #list
  2938. local max_can_get_achitask_count = 6
  2939. local achieve_model = AchieveModel:getInstance()
  2940. local can_get_list = achieve_model:GetCanGetAchiList() or {}
  2941. for i, v in pairs(can_get_list) do
  2942. local taskVo = TaskVo.New()
  2943. taskVo.type = TaskType.ACHIEVE
  2944. taskVo.tipContent = Trim(v.desc) .. "" .. achieve_model:ParseCondition( v )
  2945. taskVo.taskName = Trim(v.name)
  2946. taskVo.achi_data = v
  2947. taskVo.progress_data = achieve_model:GetTargetAchieveData(v.type, v.sub_type)
  2948. taskVo.tipType = TaskTipType.TYPE1002
  2949. taskVo.task_position = 0
  2950. taskVo.progressState = 1
  2951. taskVo.achieve_id = v.type * 10000000000 + v.sub_type
  2952. table.insert(list, taskVo)
  2953. end
  2954. --超过最大数量,就不添加了
  2955. if cur_task_count >= max_can_get_achitask_count then return end
  2956. local recommend_achi = achieve_model:GetRecommendAchiList() or {}
  2957. for pos,v in pairs(recommend_achi) do
  2958. local taskVo = TaskVo.New()
  2959. taskVo.type = TaskType.ACHIEVE
  2960. taskVo.tipContent = Trim(v.desc) .. achieve_model:ParseCondition( v )
  2961. taskVo.taskName = Trim(v.name)
  2962. taskVo.achi_data = v
  2963. taskVo.progress_data = achieve_model:GetTargetAchieveData(v.type, v.sub_type)
  2964. taskVo.tipType = TaskTipType.TYPE1002
  2965. taskVo.task_position = pos
  2966. taskVo.sortKey = Config.ConfigTaskEffect.TaskTypeSort[taskVo.type]
  2967. taskVo.achieve_id = v.type * 10000000000 + v.sub_type
  2968. table.insert(list, taskVo)
  2969. --添加可接成就后,再去判断是否超过最大显示数量
  2970. cur_task_count = cur_task_count + 1
  2971. if cur_task_count >= max_can_get_achitask_count then break end
  2972. end
  2973. end
  2974. -- 日常活跃任务
  2975. function TaskModel:SetDailyActiviteTaskVo( list )
  2976. local level = RoleManager.Instance.mainRoleInfo.level
  2977. if level < Config.ConfigTaskEffect.DailyTaskActiviteCheckLevel then return end
  2978. local is_show_task_finish = TaskModel:getInstance():IsTaskFinished(Config.ConfigTaskEffect.DailyCircleShowTaskId)
  2979. if not is_show_task_finish then return end
  2980. local daily_model = DailyModel.getInstance()
  2981. local show_data = daily_model:GetCommonShowList() or {}
  2982. local daily_list = {}
  2983. self.cur_tips_daily_task_item = false
  2984. for i,v in ipairs(show_data) do
  2985. local taskVo = TaskVo.New()
  2986. -- print('Ych:TaskModel.lua[3107] data', data)
  2987. -- PrintTable(v)
  2988. local task_max = v.show_max_times and v.show_max_times or v.max_times
  2989. local cur_num, max_num = daily_model:DailyCommonTipsCurNumAndMaxNum(v)
  2990. if cur_num < max_num then
  2991. local key = v.module .. "@" .. v.module_sub
  2992. local cfg = Config.ConfigTaskEffect.DailyActiviteTask[key]
  2993. if cfg then
  2994. if cfg.recommend == 1 and (not self.cur_tips_daily_task_item or self.cur_tips_daily_task_item.order < cfg.order) then
  2995. self.cur_tips_daily_task_item = cfg
  2996. end
  2997. taskVo.type = TaskType.DAILY_ACTIVITE
  2998. taskVo.tipContent = Trim(cfg.desc)
  2999. taskVo.taskName = Trim(cfg.name)
  3000. taskVo.achi_data = v
  3001. taskVo.progress_data = 1
  3002. taskVo.tipType = TaskTipType.TYPE9998
  3003. taskVo.task_position = 0
  3004. --竞技场如果处于冷却,排序要降低
  3005. if v.module == 280 and v.module_sub == 0 then
  3006. local is_cd, cd_time = PkRankModel.getInstance():GetChallengeCd()
  3007. if is_cd then
  3008. taskVo.order = 1
  3009. else
  3010. taskVo.order = cfg.order
  3011. end
  3012. --赏金幻魔显示购买次数的时候,置底,并且在竞技场之上
  3013. elseif v.module == 460 and v.module_sub == 3 then
  3014. local left_count, all_count = BossModel:GetInstance():GetMoneyLeftCount()
  3015. if left_count > 0 then
  3016. taskVo.order = cfg.order
  3017. else
  3018. taskVo.order = 2
  3019. end
  3020. else
  3021. taskVo.order = cfg.order
  3022. end
  3023. taskVo.progressState = 0
  3024. taskVo.id = 19000000000 + v.module * 100 + v.module_sub
  3025. taskVo.module = v.module
  3026. taskVo.module_sub = v.module_sub
  3027. table.insert(list, taskVo)
  3028. end
  3029. end
  3030. end
  3031. end
  3032. -- 更新任务数据
  3033. function TaskModel:UpdateSingleAchiTaskVo( taskVo )
  3034. local achieve_model = AchieveModel:getInstance()
  3035. local recommend_data = achieve_model:GetRecommendAchiList()[taskVo.task_position] or {}
  3036. if not recommend_data.name then return end
  3037. taskVo.tipContent = Trim(recommend_data.desc) .. "" .. achieve_model:ParseCondition( recommend_data )
  3038. taskVo.taskName = Trim(recommend_data.name)
  3039. taskVo.achi_data = recommend_data
  3040. taskVo.progress_data = achieve_model:GetTargetAchieveData(recommend_data.type, recommend_data.sub_type)
  3041. end
  3042. -- 更新任务数据
  3043. function TaskModel:UpdateAchiTaskVo( taskVo_list )
  3044. for i,v in ipairs(taskVo_list) do
  3045. if v.type == TaskType.ACHIEVE and v.task_position > 0 then -- 只更新推荐任务栏
  3046. self:UpdateSingleAchiTaskVo(v)
  3047. end
  3048. end
  3049. end
  3050. -- 是否是功能型开放任务
  3051. function TaskModel:IsFuncOpenTask( task_vo )
  3052. local b = false
  3053. if task_vo and Config.ConfigTaskEffect.ModuleOpenTask[task_vo.id] then
  3054. b = true
  3055. end
  3056. return b
  3057. end
  3058. -- 是否是高排序型任务(order 1000 <= order <= 9999)
  3059. function TaskModel:IsHighOrderTask( task_vo )
  3060. local b = false
  3061. if task_vo and task_vo.order >= 1000 and task_vo.order <= 9999 then
  3062. b = true
  3063. end
  3064. return b
  3065. end
  3066. -- 是否是第二排序任务(order 1000 <= order <= 9999)
  3067. function TaskModel:IsSecondOrderTask( task_vo )
  3068. local b = false
  3069. if task_vo and task_vo.order >= 501 and task_vo.order <= 999 then
  3070. b = true
  3071. end
  3072. return b
  3073. end
  3074. -- 是否是日常活跃任务
  3075. function TaskModel:IsDailyActiviteTask( task_vo )
  3076. local b = false
  3077. if task_vo and task_vo.type == TaskType.DAILY_ACTIVITE then
  3078. b = true
  3079. end
  3080. return b
  3081. end
  3082. -- 是否是日常活跃任务中的护送任务
  3083. function TaskModel:IsDailyActiviteEscortTask( task_vo )
  3084. local b = false
  3085. if task_vo and task_vo.type == TaskType.DAILY_ACTIVITE and task_vo.module == 500 and task_vo.module_sub == 0 then
  3086. b = true
  3087. end
  3088. return b
  3089. end
  3090. -- 是否是日常活跃任务中的竞技场任务
  3091. function TaskModel:IsDailyActivitePkrankTask( task_vo )
  3092. local b = false
  3093. if task_vo and task_vo.type == TaskType.DAILY_ACTIVITE and task_vo.module == 280 and task_vo.module_sub == 0 then
  3094. b = true
  3095. end
  3096. return b
  3097. end
  3098. -- 是否是第三排序任务(order 1 <= order <= 500)
  3099. function TaskModel:IsThirdOrderTask( task_vo )
  3100. local b = false
  3101. if task_vo and task_vo.order >= 1 and task_vo.order <= 500 then
  3102. b = true
  3103. end
  3104. return b
  3105. end
  3106. -- 知否是购买型支线,并且已经完成,或者满足完成条件
  3107. function TaskModel:IsBuyGoodsTaskFinished( task_vo )
  3108. local b = false
  3109. if task_vo and task_vo.type == TaskType.EXTENSION_LINE and task_vo.taskTips then
  3110. for key, taskTipVO in ipairs(task_vo.taskTips) do
  3111. if taskTipVO.type == TaskTipType.TYPE40 then
  3112. local need_money = taskTipVO.sceneId --需要的价格
  3113. local shop_key_id = taskTipVO.scene_x --商品id
  3114. local money_type = Config.Shop[shop_key_id] and Config.Shop[shop_key_id].ctype --商品消耗货币类型
  3115. local my_money = GoodsModel:getInstance():GetGoodsNumFromType(money_type) --我的商品消耗货币
  3116. if task_vo.progressState == 1 or taskTipVO.isFinish == 1 or my_money >= need_money then --已完成
  3117. b = true
  3118. end
  3119. end
  3120. end
  3121. end
  3122. return b
  3123. end
  3124. -- 计算任务的长度
  3125. function TaskModel:CalStrWidth( str )
  3126. local key_width = {
  3127. [1] = 14.84, -- 汉字
  3128. [2] = 4.88, -- "("
  3129. [3] = 8.26, -- 数字 1
  3130. [4] = 4.13, --"/"
  3131. }
  3132. local word_offset = 0.197
  3133. if not str then
  3134. return 0
  3135. end
  3136. local char_count = 0
  3137. local width = 0;
  3138. for i=1, #str do
  3139. local curByte = string.byte(str, i)
  3140. local temp_width = 0
  3141. if curByte == nil then
  3142. temp_width = 0
  3143. elseif curByte == 47 then -- "/"
  3144. temp_width = key_width[4]
  3145. char_count = char_count + 1
  3146. elseif curByte == 40 or curByte == 41 then -- "(" ")"
  3147. temp_width = key_width[2]
  3148. char_count = char_count + 1
  3149. elseif curByte>=48 and curByte<=57 then -- 数字
  3150. temp_width = key_width[3]
  3151. char_count = char_count + 1
  3152. elseif curByte>=224 and curByte<=239 then -- 汉字
  3153. temp_width = key_width[1]
  3154. char_count = char_count + 1
  3155. elseif curByte>=240 and curByte<=247 then -- 汉字
  3156. temp_width = key_width[1]
  3157. char_count = char_count + 1
  3158. end
  3159. width = width + temp_width
  3160. end
  3161. --print('Msh:TaskModel.lua[2871] data', char_count, (char_count - 8))
  3162. return width - (char_count - 8) * word_offset
  3163. end
  3164. ----------推荐成就-end-----------
  3165. -- 是否可以去做主线
  3166. function TaskModel:CanSitchToMainLine( target_task_vo)
  3167. local is_can = false
  3168. local cur_main_task = target_task_vo or self:GetMainTask()
  3169. if cur_main_task and RoleManager.Instance.mainRoleInfo.level >= cur_main_task.level then
  3170. local cur_tips_task_id = cur_main_task.tipParam and cur_main_task.tipParam[3] or -1
  3171. -- print('Ych:TaskModel.lua[3296] data', data)
  3172. -- PrintTable(cur_main_task)
  3173. for k,v in pairs(cur_main_task.taskTips) do
  3174. if cur_tips_task_id == v.id then
  3175. if v.type == TaskTipType.TYPE7 or
  3176. v.type == TaskTipType.TYPE8 or
  3177. v.type == TaskTipType.TYPE9 or
  3178. v.type == TaskTipType.TYPE1 then
  3179. is_can = true
  3180. end
  3181. break
  3182. end
  3183. end
  3184. --print('Ych:TaskModel.lua[3308] data', is_can)
  3185. end
  3186. return is_can
  3187. end
  3188. -- 是否可以去做主线
  3189. function TaskModel:JustDoMainLine( )
  3190. local cur_main_task = self:GetMainTask()
  3191. if cur_main_task and RoleManager.Instance.mainRoleInfo.level >= cur_main_task.level then
  3192. self.now_task_id = false
  3193. self:SetTaskAutoFlag(true)
  3194. GlobalEventSystem:Fire(EventName.FORCE_TO_DO_TASK, true, true)
  3195. end
  3196. end
  3197. -- 是否可以日常跑环
  3198. function TaskModel:CanSitchToDailyCircleTask( )
  3199. local task_data = self:GetTaskByType(TaskType.BOUNTY_LINE)
  3200. if task_data then
  3201. return true
  3202. end
  3203. end
  3204. -- 是否可以日常跑环
  3205. function TaskModel:JustDoDailyCircleTask( )
  3206. local task_data = self:GetTaskByType(TaskType.BOUNTY_LINE)
  3207. if task_data then
  3208. self.now_task_id = task_data.id
  3209. self:SetTaskAutoFlag(true)
  3210. GlobalEventSystem:Fire(EventName.FORCE_TO_DO_TASK, true)
  3211. end
  3212. end
  3213. function TaskModel:ShowMainLineTips(is_force)
  3214. local main_task = self:GetMainTask()
  3215. if main_task then
  3216. if (RoleManager.Instance.mainRoleInfo.level >= main_task.level) or is_force then
  3217. self.tip_new_main_line = main_task.id
  3218. GuideController.Instance:TriggerHelper(GuideModel.TASK_TRIGGER_TYPE, 9993150002)
  3219. self:Fire(TaskEvent.SHOW_NEW_MAIN_LINE_TIP)
  3220. end
  3221. end
  3222. end
  3223. -- 第一次登陆游戏做任务
  3224. function TaskModel:FirstLoginGameToDotask( )
  3225. if self.is_first_login_game_to_do_task == true then
  3226. if RoleManager.Instance.mainRoleInfo.level <= Config.ConfigTaskEffect.DailyCircleTaskCheckLevel then
  3227. local is_open_daily,_,_,_,tips_content = self:GetDefalutTaskCurTaskAndDes()
  3228. if not (is_open_daily and not self.cur_tips_daily_task_item) then
  3229. self:ShowMainLineTips(true)
  3230. end
  3231. end
  3232. self.is_first_login_game_to_do_task = false
  3233. end
  3234. end
  3235. -- 获取第一条日常活跃任务的序号
  3236. function TaskModel:GetFirstDailyTaskIndex( )
  3237. local idx = 0
  3238. local task_list = self:GetMainUITaskData(true)
  3239. for i,v in ipairs(task_list) do
  3240. if v.type == TaskType.DAILY_ACTIVITE then
  3241. idx = i
  3242. break
  3243. end
  3244. end
  3245. return idx, #task_list
  3246. end
  3247. ----------七日目标-start---------
  3248. -- 直接拉取
  3249. function TaskModel:SetSevenTargetTaskVo( list )
  3250. local level = RoleManager.Instance.mainRoleInfo.level
  3251. local seven_day_target_model = SevenDayTargetModel:getInstance()
  3252. -- 【少于105级】 或 【没开放七日目标】 都返回
  3253. -- print('=======Msh:TaskModel.lua[3451] =======', seven_day_target_model:IsSevenDayTargetOpen())
  3254. if level < 105 or not seven_day_target_model:IsSevenDayTargetOpen() then
  3255. return
  3256. end
  3257. -- 只拿最新那天
  3258. local login_day = seven_day_target_model:GetSevenDayTargetLoginDay()
  3259. local cfg = seven_day_target_model:GetSevenDayTargetTaskCFGByDay(login_day)
  3260. local server_data = seven_day_target_model:GetSevenDayTargetInfo(login_day) or {}
  3261. local total_num = TableSize(cfg)
  3262. local cur_num = 0
  3263. for i,v in pairs(server_data) do
  3264. local cfg = seven_day_target_model:GetSevenDayTargetTaskOneCFG(v.days, v.mod_id, v.sub_id)
  3265. if cfg then
  3266. if v.progress >= cfg.limit_times then
  3267. cur_num = cur_num + 1
  3268. end
  3269. end
  3270. end
  3271. -- 当天技能领完 就不用显示了
  3272. if total_num == cur_num and total_num > 0 then -- 进度满了 看看技能领没领
  3273. local skill_data = seven_day_target_model:GetSevenDayTargetSkillInfo() or {}
  3274. if skill_data[login_day] then -- 有技能数据就是领了
  3275. return
  3276. end
  3277. end
  3278. -- local color = cur_num == 0 and ColorUtil.RED_DARK or ColorUtil.GREEN_DARK
  3279. local taskVo = TaskVo.New()
  3280. taskVo.type = TaskType.SEVEN_DAY_TARGET
  3281. taskVo.tipContent = string.format("完成本日目标 (%s/%s)", HtmlColorTxt(cur_num, ColorUtil.GREEN_DARK), total_num)
  3282. taskVo.taskName = string.format('七日目标 【第%s日】', login_day)
  3283. taskVo.server_data = server_data
  3284. taskVo.total_num = total_num
  3285. taskVo.cur_num = cur_num
  3286. -- taskVo.seven_cfg = cfg
  3287. taskVo.tipType = TaskTipType.TYPE1004
  3288. taskVo.order = 501 -- 归为第二排序任务
  3289. taskVo.sortKey = 3 -- 排序刚好要在转职后面
  3290. -- taskVo.task_position = 0
  3291. -- taskVo.progressState = 1
  3292. -- taskVo.achieve_id = v.type * 10000000000 + v.sub_type
  3293. table.insert(list, taskVo)
  3294. end
  3295. ----------七日目标-end-----------