源战役客户端
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

624 righe
14 KiB

4 settimane fa
  1. SkillVo = SkillVo or BaseClass()
  2. local SkillVo = SkillVo
  3. local string_len = string.len
  4. local string_sub = string.sub
  5. local table_insert = table.insert
  6. local math_max = math.max
  7. local tonumber = tonumber
  8. SkillVo.SkillType =
  9. {
  10. Initiative = 1, --主动
  11. Passitive = 2, --被动
  12. Assist = 3, --辅助
  13. Menpai = 4, --门派技能
  14. }
  15. --怒气技能id列表
  16. SkillVo.AngerSkillId =
  17. {
  18. [101091] = true,
  19. [102091] = true,
  20. [103091] = true,
  21. [104091] = true,
  22. }
  23. function SkillVo:__init(skillId)
  24. self.id = skillId --技能id
  25. self.level= 0 --技能等级
  26. self.useTime = 0 --技能触发时间
  27. self:getComboSkill()
  28. self.canLearn = false
  29. end
  30. function SkillVo:__defineVar()
  31. return {
  32. _class_type = self,
  33. --_cid = self._id,
  34. _iid = _in_obj_ins_id,
  35. id = 1,
  36. level = 0,
  37. totalLevel = 1,
  38. canLearn = false,
  39. skill_link = nil,
  40. useTime = 0,
  41. }
  42. end
  43. function SkillVo:getName()
  44. if self.name == nil then
  45. self.name = self:getBasic("name")
  46. if self.name ~= nil then
  47. self.name = Trim(self.name)
  48. end
  49. end
  50. return self.name
  51. end
  52. --角色
  53. function SkillVo:getCarrer()
  54. if self.career == nil then
  55. self.career = self:getBasic("career")
  56. end
  57. return self.career
  58. end
  59. -- 技能类型 1主动技能,2被动技能,3辅助技能,4增益技能
  60. function SkillVo:GetSkillType()
  61. if self.type == nil then
  62. self.type = self:getBasic("type")
  63. end
  64. return self.type
  65. end
  66. --获取技能类型字符串
  67. function SkillVo:GetSkillTypeStr()
  68. return WordManager:GetSkillTypeStr(self:GetSkillType())
  69. end
  70. --是否是幻光技能
  71. function SkillVo:IsDailyLightSkill()
  72. if self.is_daily_litght_skill == nil then
  73. self.is_daily_litght_skill = self:getCarrer() == 13
  74. end
  75. return self.is_daily_litght_skill
  76. end
  77. --攻击参照类型 1自己 2选取对象
  78. function SkillVo:GetSkillAttObj()
  79. if self.att_obj == nil then
  80. self.att_obj = self:getBasic("att_obj")
  81. end
  82. return self.att_obj
  83. end
  84. --是否是特殊技能(永恒回复)
  85. function SkillVo:IsSpecialSkill()
  86. return self.id == 109100
  87. end
  88. --是否是禁跳技能
  89. function SkillVo:IsForbidJumpSkill()
  90. return self.id == 109101
  91. end
  92. --是否是被动技能
  93. function SkillVo:IsPassitiveSkill()
  94. return self:GetSkillType() == SkillVo.SkillType.Passitive
  95. end
  96. --是否普攻
  97. function SkillVo:IsNormal()
  98. if self.is_normal == nil then
  99. self.is_normal = self:getBasic("is_normal")
  100. end
  101. return self.is_normal == 1
  102. end
  103. --是否副技能
  104. function SkillVo:IsComboSkill()
  105. if self.is_combo == nil then
  106. self.is_combo = self:getBasic("is_combo")
  107. end
  108. return self.is_combo == 1
  109. end
  110. --是否怒气技能
  111. function SkillVo:IsAngerSkill()
  112. return SkillVo.AngerSkillId[self.id]
  113. end
  114. --选取模式 1自己,2最近敌方,3最近队友
  115. function SkillVo:GetSelectType()
  116. if self.obj == nil then
  117. self.obj = self:getBasic("obj")
  118. end
  119. return self.obj
  120. end
  121. --(0客户端直接播放,1等服务端返回播)
  122. function SkillVo:GetBroadcast()
  123. if self.broadcast == nil then
  124. self.broadcast = self:getBasic("broadcast")
  125. end
  126. return self.broadcast
  127. end
  128. --(是否前摇技能)
  129. function SkillVo:IsPreSwingSkill()
  130. if self.is_shake_pre == nil then
  131. self.is_shake_pre = self:getBasic("is_shake_pre")
  132. end
  133. return self.is_shake_pre == 1
  134. end
  135. --获取蓄能连招
  136. function SkillVo:getSkillLink()
  137. if self.skill_link == nil then
  138. self.skill_link = {}
  139. local link_str = self:getBasic("skill_link")
  140. if link_str and string_len(link_str) > 4 then
  141. link_str = string_sub(link_str, 3, -3)
  142. local tmp_arr = Split(link_str, ",")
  143. for i=1, #tmp_arr do
  144. local s = tmp_arr[i]
  145. table_insert(self.skill_link, tonumber(s))
  146. end
  147. end
  148. end
  149. return self.skill_link
  150. end
  151. --获取攻击目标数量
  152. function SkillVo:GetAttackNum(level)
  153. --假定攻击数量不受等级影响
  154. if not self.attack_role_num then
  155. self.attack_role_num, self.attack_mon_num = 0,0
  156. local level_vo = self:getLevelVo(level)
  157. if level_vo then
  158. local num_str = level_vo.num
  159. if num_str and string_len(num_str) > 4 then
  160. num_str = string_sub(num_str, 3, -3)
  161. local tmp_arr = Split(num_str, ",")
  162. self.attack_role_num, self.attack_mon_num = tonumber(tmp_arr[1]) or 0,tonumber(tmp_arr[2]) or 0
  163. end
  164. end
  165. end
  166. return self.attack_role_num, self.attack_mon_num
  167. --[[
  168. level = level or self.level
  169. local level_vo = self:getLevelVo(level)
  170. -- print("获取攻击目标数量", self.id, self.level, level_vo)
  171. if level_vo then
  172. local num_str = level_vo.num
  173. local role_num,mon_num = 0,0
  174. if num_str and string_len(num_str) > 4 then
  175. num_str = string_sub(num_str, 3, -3)
  176. local tmp_arr = Split(num_str, ",")
  177. role_num,mon_num = tonumber(tmp_arr[1]) or 0,tonumber(tmp_arr[2]) or 0
  178. end
  179. return role_num,mon_num
  180. else
  181. return 0,0
  182. end
  183. ]]
  184. end
  185. --是否群攻模式
  186. function SkillVo:IsAoeMode()
  187. if self.is_aoe_mode == nil then
  188. local mod = self:getBasic("mod")
  189. if mod then
  190. mod = tonumber(mod)
  191. if mod == 1 then
  192. self.is_aoe_mode = false
  193. else
  194. self.is_aoe_mode = true
  195. end
  196. else
  197. self.is_aoe_mode = true
  198. end
  199. end
  200. return self.is_aoe_mode
  201. end
  202. --AOE时选取目标的方式
  203. function SkillVo:GetAoeMode()
  204. if self.aoe_mod == nil then
  205. local str = self:getBasic("range")
  206. if str then
  207. self.aoe_mod = tonumber(str)
  208. if self.aoe_mod == 0 then
  209. self.aoe_mod = 1
  210. end
  211. else
  212. self.aoe_mod = 1
  213. end
  214. end
  215. return self.aoe_mod
  216. end
  217. --CD时间,配置的
  218. function SkillVo:getCd(level)
  219. level = level or self.level
  220. local level_vo = self:getLevelVo(level)
  221. if level_vo and level_vo.cd then
  222. self.cd = tonumber(level_vo.cd) or 0
  223. else
  224. self.cd = 0
  225. end
  226. return self.cd
  227. end
  228. function SkillVo:startCD()
  229. self.useTime = Status.NowTime
  230. end
  231. function SkillVo:clearCD()
  232. self.useTime = 0
  233. end
  234. function SkillVo:refreshCD(time)
  235. self.useTime = self.useTime - time
  236. end
  237. --真实的cd时间
  238. function SkillVo:getRealCD()
  239. local ret_cd = 0
  240. local cfg_cd = self:getCd()
  241. if self.useTime ~= 0 then
  242. if Status.NowTime - self.useTime > ((self:getCd() / 1000) - 0.5) then
  243. ret_cd = 0
  244. else
  245. ret_cd = math.max(0,(self:getCd() / 1000) - ( Status.NowTime - self.useTime ))
  246. end
  247. end
  248. return ret_cd
  249. end
  250. function SkillVo:CoolDown()
  251. local cd_info = SkillManager:getInstance().cd_skill_list[self.id]
  252. local last_release_time = SkillManager:getInstance():GetReleaseMainSkill(self.id)
  253. if (cd_info and cd_info:IsPlaying()) or self:getRealCD() > 0 then --or Status.NowTime - last_release_time < 1.5 then
  254. return false
  255. end
  256. return true
  257. end
  258. function SkillVo:getLevelVo(level)
  259. -- print("= = =SkillVo:getLevelVo:", self.id, level)
  260. level = (level == nil or level == 0) and 1 or level
  261. local lvs = self:getBasic("lvs")
  262. if lvs ~= nil and level <= tonumber(lvs.lvs_total) then
  263. return lvs[level]
  264. end
  265. return nil
  266. end
  267. function SkillVo:GetTotalLevel()
  268. local lvs = self:getBasic("lvs")
  269. return tonumber(lvs.lvs_total)
  270. end
  271. function SkillVo:IsMaxLevel()
  272. local max_lv = self:GetTotalLevel()
  273. return self.level and self.level >= max_lv
  274. end
  275. --取攻击距离
  276. function SkillVo:GetDistance(level)
  277. if not self.attack_distance then
  278. level = level or self.level
  279. local level_vo = self:getLevelVo(level)
  280. if level_vo then
  281. local distance = tonumber(level_vo.distance)
  282. if distance == nil then
  283. distance = 50
  284. end
  285. self.attack_distance = distance
  286. else
  287. self.attack_distance = 50
  288. end
  289. end
  290. return self.attack_distance
  291. --[[
  292. level = level or self.level
  293. local level_vo = self:getLevelVo(level)
  294. if level_vo then
  295. local distance = tonumber(level_vo.distance)
  296. if distance == nil then
  297. distance = 50
  298. end
  299. return distance
  300. else
  301. return 50
  302. end
  303. ]]
  304. end
  305. --攻击范围
  306. function SkillVo:GetArea(level)
  307. if not self.attack_area then
  308. level = level or self.level
  309. local level_vo = self:getLevelVo(level)
  310. if level_vo then
  311. self.attack_area = tonumber(level_vo.area)
  312. end
  313. end
  314. return self.attack_area
  315. --[[
  316. level = level or self.level
  317. local level_vo = self:getLevelVo(level)
  318. if level_vo then
  319. local area = tonumber(level_vo.area)
  320. return area
  321. end
  322. return 0
  323. ]]
  324. end
  325. --获取combo技(类似战士旋风,需要客户端自动每隔一段时间发一次技能)
  326. function SkillVo:getComboSkill()
  327. if self.combo_skills == nil then
  328. self.combo_skills = {}
  329. local skillCfg = SkillManager.Instance:GetFightSkillMovie(self.id)
  330. local comboSkills = skillCfg and skillCfg.comboSkills
  331. if comboSkills then
  332. local time = 0
  333. local info = nil
  334. for i = 1, #comboSkills do
  335. local delta = tonumber(comboSkills[i][1]) / 1000
  336. local skill_id = tonumber(comboSkills[i][2])
  337. time = time + delta
  338. info = {time = time,
  339. skill_id = skill_id}
  340. table_insert(self.combo_skills, info)
  341. end
  342. end
  343. end
  344. return self.combo_skills
  345. end
  346. --获取多段伤害的段数跟间隔,返回值:段数(默认1,大于1才算多段伤害),时间间隔
  347. function SkillVo:getMultiHurtInfo( )
  348. if not self.multi_segment then
  349. self.multi_segment = self:getBasic("multistage")
  350. end
  351. if self.multi_segment and self.multi_segment > 1 then
  352. if not self.multi_interval then
  353. self.multi_interval = tonumber(self:getBasic("stage_cd")) or 0
  354. self.multi_interval = self.multi_interval / 1000 --毫秒转秒
  355. end
  356. return self.multi_segment, self.multi_interval
  357. end
  358. return 1, 0
  359. end
  360. --[[
  361. .
  362. zsm
  363. ]]
  364. function SkillVo:getBasic(str)
  365. local basic = SkillManager.getInstance():getSkillFromConfig(self.id)
  366. if basic == nil then
  367. return nil
  368. end
  369. return basic[str]
  370. end
  371. function SkillVo:__delete( )
  372. end
  373. function SkillVo:GetNeedLevel( level )
  374. level = level or self.level
  375. local levelVo = self:getLevelVo( level)
  376. local lv = 0
  377. if levelVo then
  378. lv = levelVo.condition.lv
  379. end
  380. return lv or 0
  381. end
  382. function SkillVo:GetNeedCoin( level )
  383. level = level or self.level
  384. local levelVo = self:getLevelVo( level)
  385. local coin = 0
  386. if levelVo then
  387. coin = levelVo.condition.coin
  388. end
  389. return coin or 0
  390. end
  391. function SkillVo:GetCondition()
  392. local levelVo = self:getLevelVo(level or self.level)
  393. if levelVo then
  394. cdt = levelVo.condition
  395. if cdt.lv then
  396. return "level",cdt.lv
  397. elseif cdt.turn then
  398. return "turn",cdt.turn
  399. elseif cdt.yhbg then
  400. return "yhbg",cdt.yhbg
  401. elseif cdt.finish_dun then
  402. return "finish_dun",cdt.finish_dun
  403. end
  404. end
  405. end
  406. function SkillVo:GetNextConditionByKey(key, level)
  407. level = level or self.level
  408. local total_level = self:GetTotalLevel()
  409. if level >= total_level then
  410. return false
  411. end
  412. local levelVo = self:getLevelVo( level + 1)
  413. if levelVo then
  414. cdt = levelVo.condition
  415. if cdt.lv and key == "level" then
  416. return cdt.lv
  417. elseif cdt.turn and key == "turn" then
  418. return cdt.turn
  419. elseif cdt.vip and key == "vip" then
  420. return cdt.vip
  421. elseif cdt.goods and key == "goods" then
  422. return cdt.goods
  423. end
  424. end
  425. return false
  426. end
  427. function SkillVo:getAnger(level)
  428. level = level or self.level
  429. local vo= self:getLevelVo(level);
  430. if vo==nil then
  431. return -1
  432. end
  433. local use_str = Trim(vo.use)
  434. local mp_str = string_sub(use_str, 2, -2)
  435. if string_len(mp_str)==0 then
  436. -- print("技能不耗怒气~~", self.id)
  437. return 0
  438. else
  439. mp_str = string_sub(mp_str, 2, -2)
  440. local tmp_strs = Split(mp_str, ",")
  441. if #tmp_strs >= 2 then
  442. for i = 1,#tmp_strs do
  443. if tmp_strs[i] == "anger" then
  444. return tonumber(tmp_strs[i+1]) or 0
  445. end
  446. end
  447. end
  448. end
  449. return 0
  450. end
  451. function SkillVo:GetDesc(level)
  452. level = level or self.level
  453. local vo= self:getLevelVo(level);
  454. if vo == nil then
  455. return -1
  456. end
  457. return Trim(vo.desc)
  458. end
  459. function SkillVo:GetPower(level)
  460. local is_have = true
  461. level = level or self.level
  462. if level == 0 then
  463. is_have = false
  464. level = 1
  465. end
  466. local _,power = GetSkillAttrBySkill( self.id, level, true, is_have)
  467. return power
  468. end
  469. function SkillVo:GetAttrOffsetByLevel(cur_level, next_level)
  470. local t = {}
  471. if cur_level == 0 then
  472. local next_vo = self:getLevelVo(next_level)
  473. local next_attr = Trim(next_vo.base_attr)
  474. if next_attr ~= "" and next_attr ~= "[]" then
  475. local next_attr_list =ErlangParser:GetInstance():Parse(next_attr)
  476. t = next_attr_list
  477. end
  478. elseif next_level > cur_level then
  479. local next_vo = self:getLevelVo(next_level)
  480. local cur_vo = self:getLevelVo(cur_level)
  481. local next_attr = Trim(next_vo.base_attr)
  482. local cur_attr = Trim(cur_vo.base_attr)
  483. if next_attr ~= "" and next_attr ~= "[]" and cur_attr ~= "" and cur_attr ~= "[]" then
  484. local next_attr_list =ErlangParser:GetInstance():Parse(next_attr)
  485. local cur_attr_list =ErlangParser:GetInstance():Parse(cur_attr)
  486. for i,v in ipairs(next_attr_list) do
  487. t[i] = v
  488. for _i,_v in ipairs(cur_attr_list) do
  489. if v[2] == _v[2] then
  490. t[i][3] = math.abs(v[3]-_v[3])
  491. end
  492. end
  493. end
  494. end
  495. end
  496. return t
  497. end
  498. --是否可以升级
  499. function SkillVo:CanUp(level)
  500. local b = false
  501. level = level or self.level
  502. local total_level = self:GetTotalLevel()
  503. if level < total_level then
  504. local is_enable = true
  505. --还没有达到技能的学习条件
  506. is_enable = self:CanUpButGoods(level)
  507. if not is_enable then
  508. return false
  509. end
  510. --判断是否有足够的材料升级
  511. local goods = self:GetNextConditionByKey("goods", level)
  512. if goods then
  513. for i,v in ipairs(goods) do
  514. local own_count = GoodsModel:getInstance():GetTypeGoodsNum(v[1])
  515. if own_count and tonumber(v[2]) and own_count < tonumber(v[2]) then
  516. is_enable = false
  517. break
  518. end
  519. end
  520. b = is_enable
  521. end
  522. end
  523. return b
  524. end
  525. --除了道具可以升级
  526. function SkillVo:CanUpButGoods(level)
  527. local b = true
  528. level = level or self.level
  529. local total_level = self:GetTotalLevel()
  530. -- print(">>> 00 = ",level , total_level, level < total_level )
  531. if level < total_level then
  532. --比较条件
  533. local t = {
  534. level = RoleManager.Instance:GetMainRoleVo().level,
  535. turn = RoleManager.Instance:GetMainRoleVo().turn,
  536. vip = RoleManager.Instance:GetMainRoleVo().vip_flag,
  537. }
  538. for k,v in pairs(t) do
  539. local _value = self:GetNextConditionByKey(k, level)
  540. _value = tonumber(_value)
  541. if _value and _value > v then
  542. return false
  543. end
  544. end
  545. else
  546. return false
  547. end
  548. return b
  549. end
  550. function SkillVo:GetSkillAttrList(ignore_list, have_level)
  551. local attrs = {}
  552. local total_level = self:GetTotalLevel()
  553. for i=1,total_level do
  554. if not ignore_list or ignore_list[i] == nil then
  555. local des = self:GetDesc(i)
  556. if have_level then
  557. local t =
  558. {
  559. level = i,
  560. des = des,
  561. }
  562. table_insert(attrs, t)
  563. else
  564. table_insert(attrs, des)
  565. end
  566. end
  567. end
  568. return attrs
  569. end