RolandSeige.lua 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153
  1. -- 罗兰峡谷攻城战
  2. RolandSeige = {}
  3. local this = {}
  4. -- -----------------------------------------------玩家积分类-----------------------------------------------------
  5. -- 副本玩家积分类
  6. local RoleScoreDTO = {}
  7. RoleScoreDTO.__index = RoleScoreDTO
  8. -- 副本玩家积分对象
  9. function RoleScoreDTO.new(rid, unionId)
  10. local instance = setmetatable({}, RoleScoreDTO)
  11. instance.id = rid
  12. instance.unionId = unionId
  13. instance.attackBuilding = 0 -- 攻方攻击建筑的次数
  14. instance.kill = 0 -- 击杀玩家的次数
  15. instance.hurt = 0 -- 伤害量
  16. instance.occupy = 0 -- 攻方占领次数
  17. instance.stay = 0 -- 守方停留圈内时间(秒)
  18. return instance
  19. end
  20. -- 计算玩家个人积分
  21. function RoleScoreDTO.calTotalScore(roleScoreDTO)
  22. local attackScore = tonumber(ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.ROLAND_SEIGE.ATTACK_BUILDING_SCORE))
  23. local killScore = tonumber(ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.ROLAND_SEIGE.KILL_SCORE))
  24. local hurtScore = tonumber(ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.ROLAND_SEIGE.HURT_SCORE))
  25. local occupyScore = tonumber(ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.ROLAND_SEIGE.OCCUPY_SCORE))
  26. local stayScore = tonumber(ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.ROLAND_SEIGE.STAY_SCORE))
  27. local totalScore = roleScoreDTO.attackBuilding * attackScore
  28. + roleScoreDTO.kill * killScore
  29. + math.floor(roleScoreDTO.hurt / hurtScore)
  30. + roleScoreDTO.occupy * occupyScore
  31. + math.floor(roleScoreDTO.stay / stayScore)
  32. return totalScore
  33. end
  34. function RoleScoreDTO.calTotalScoreByActor(actor, mapId)
  35. local roleScoreDTO = RoleScoreDTO.get(actor, mapId)
  36. return RoleScoreDTO.calTotalScore(roleScoreDTO)
  37. end
  38. function RoleScoreDTO.get(actor, mapId)
  39. return getenvirvar(mapId, DuplicateVarConst.ROLAND_SEIGE.PLAYER_KEY_PREFIX .. actor:toString())
  40. end
  41. function RoleScoreDTO.set(actor, mapId, roleScoreDTO)
  42. setenvirvar(mapId, DuplicateVarConst.ROLAND_SEIGE.PLAYER_KEY_PREFIX .. actor:toString(), roleScoreDTO)
  43. end
  44. function RoleScoreDTO.addAttackBuilding(actor, mapId, times)
  45. local roleScoreDTO = RoleScoreDTO.get(actor, mapId)
  46. roleScoreDTO.attackBuilding = roleScoreDTO.attackBuilding + times
  47. RoleScoreDTO.set(actor, mapId, roleScoreDTO)
  48. end
  49. function RoleScoreDTO.addKill(actor, mapId, times)
  50. local roleScoreDTO = RoleScoreDTO.get(actor, mapId)
  51. roleScoreDTO.kill = roleScoreDTO.kill + times
  52. RoleScoreDTO.set(actor, mapId, roleScoreDTO)
  53. end
  54. function RoleScoreDTO.addHurt(actor, mapId, times)
  55. local roleScoreDTO = RoleScoreDTO.get(actor, mapId)
  56. roleScoreDTO.hurt = roleScoreDTO.hurt + times
  57. RoleScoreDTO.set(actor, mapId, roleScoreDTO)
  58. end
  59. function RoleScoreDTO.addOccuoy(actor, mapId, times)
  60. local roleScoreDTO = RoleScoreDTO.get(actor, mapId)
  61. roleScoreDTO.occupy = roleScoreDTO.occupy + times
  62. RoleScoreDTO.set(actor, mapId, roleScoreDTO)
  63. end
  64. function RoleScoreDTO.addStay(actor, mapId, times)
  65. local roleScoreDTO = RoleScoreDTO.get(actor, mapId)
  66. roleScoreDTO.stay = roleScoreDTO.stay + times
  67. RoleScoreDTO.set(actor, mapId, roleScoreDTO)
  68. end
  69. -- ---------------------------------------------------------------------------------------------------------------------------------------
  70. -- ----------------------------------------------- 战盟进度条类 -----------------------------------------------------
  71. local UnionProgressDTO = {}
  72. UnionProgressDTO.__index = UnionProgressDTO
  73. function UnionProgressDTO.new(unionId, isMax)
  74. local instance = setmetatable({}, RoleScoreDTO)
  75. local needTime = tonumber(ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.ROLAND_SEIGE.OCCUPY_PROGRESS_TIME))
  76. instance.max = needTime
  77. if isMax then
  78. instance.now = needTime
  79. else
  80. instance.now = 0
  81. end
  82. instance.unionId = unionId
  83. local unionInfo = getunioninfo(unionId)
  84. instance.unionName = unionInfo.unionname
  85. return instance
  86. end
  87. function UnionProgressDTO.get(mapId, unionId)
  88. return getenvirvar(mapId, DuplicateVarConst.ROLAND_SEIGE.UNION_SCORE_PREFIX .. tostring(unionId))
  89. end
  90. function UnionProgressDTO.set(mapId, unionId, occupyDTO)
  91. setenvirvar(mapId, DuplicateVarConst.ROLAND_SEIGE.UNION_SCORE_PREFIX .. tostring(unionId), occupyDTO)
  92. end
  93. function UnionProgressDTO.add(mapId, unionId, add)
  94. local occupyDTO = UnionProgressDTO.get(mapId, unionId)
  95. local old = occupyDTO.now
  96. local new = old + add
  97. if new > occupyDTO.max then
  98. new = occupyDTO.max
  99. end
  100. occupyDTO.now = new
  101. UnionProgressDTO.set(mapId, unionId, occupyDTO)
  102. return occupyDTO
  103. end
  104. function UnionProgressDTO.reset(mapId, unionId)
  105. local occupyDTO = UnionProgressDTO.get(mapId, unionId)
  106. occupyDTO.now = 0
  107. UnionProgressDTO.set(mapId, unionId, occupyDTO)
  108. return occupyDTO
  109. end
  110. function UnionProgressDTO.isMax(progressDTO)
  111. if progressDTO.now >= progressDTO.max then
  112. return true
  113. end
  114. return false
  115. end
  116. -- ---------------------------------------------------------------------------------------------------------------------------------------
  117. -- ----------------------------------------------- 战盟进度条类 -----------------------------------------------------
  118. local LogRecord = {}
  119. function LogRecord.new()
  120. local log = {}
  121. log.winUninId = 0
  122. log.winType = "" -- 占领 或 积分
  123. log.leader = 0
  124. log.personalScoreList = {}
  125. return log
  126. end
  127. function LogRecord.log(log)
  128. local content = "本次罗兰峡谷攻城战获胜方战盟ID:" .. log.winUninId .. "(为0表示攻城失败) ;占领类型为:" .. log.winType .. " ;占领战盟盟主为:" .. log.leader .. " ;"
  129. local personalScoreContent = "个人积分如下:"
  130. for rid, score in pairs(log.personalScoreList) do
  131. personalScoreContent = personalScoreContent .. "{" .. rid .. "积分为:" .. score .. " };"
  132. end
  133. content = content .. personalScoreContent
  134. info(content)
  135. logop(LogOpType.ROLAND_SEIGE, content)
  136. end
  137. -- ---------------------------------------------------------------------------------------------------------------------------------------
  138. ---------------------------------------------------------- 请求 -----------------------------------------------------------------
  139. -- 请求主面板信息
  140. function RolandSeige.ReqMainPanel(actor)
  141. local res = {}
  142. -- 上次占领战盟信息
  143. local unionId = this.GetLastOccupyUnionId()
  144. if unionId ~= nil and unionId > 0 then
  145. local union = {}
  146. local unionInfo = getunioninfo(actor, unionId)
  147. union.id = unionId
  148. union.name = unionInfo.unionname
  149. -- 盟主和副盟主
  150. union.leader = unionInfo.leaderid
  151. local memberList = unionInfo.memberinfos
  152. local fuLeaders = {}
  153. for _, memberInfo in pairs(memberList) do
  154. if memberInfo.position == 2 then
  155. table.insert(fuLeaders, memberInfo.rid)
  156. if #fuLeaders >= 2 then
  157. break
  158. end
  159. end
  160. end
  161. union.deputys = fuLeaders
  162. res.union = union
  163. end
  164. -- 活动开启情况,未开启发送下次开启时间戳,区分首次开启
  165. local openTimeSec = math.ceil(getbaseinfo(actor, "serveropentime") / 1000)
  166. local day, hour, minute = this.GetFirstOpenTime()
  167. local firstOpenSec = openTimeSec + (day - 1) * 86400 + hour * 3600 + minute * 60
  168. local nowSec = getbaseinfo("nowsec")
  169. if nowSec <= firstOpenSec then
  170. res.open = false
  171. res.nextTime = firstOpenSec
  172. else
  173. local activityInfo = getactivityinfo(DuplicateType.ROLAND_SEIGE)
  174. if activityInfo.open then
  175. res.open = true
  176. else
  177. res.nextTime = math.ceil(activityInfo.nextopentime / 1000)
  178. res.open = false
  179. end
  180. end
  181. sendluamsg(actor, LuaMessageIdToClient.RES_ROLAND_SEIGE_MAIN_PANEL, res)
  182. end
  183. -- 创建攻城战副本
  184. function RolandSeige.OpenDuplicate(system)
  185. if not RolandSeige.CanOpenActivity() then
  186. info("定时器开启罗兰攻城战,未达到首次开启要求,直接关闭此活动")
  187. closeactivity(DuplicateType.ROLAND_SEIGE)
  188. return
  189. end
  190. local oldDupId = this.GetCurrentDupId()
  191. if oldDupId ~= nil and oldDupId ~= 0 then
  192. gameDebug.assertPrintTrace(false, "罗兰峡谷攻城战副本已创建,重复创建副本!")
  193. return
  194. end
  195. -- 创建全服唯一的副本并储存全局变量
  196. local repId = tonumber(ConfigDataManager.getTableValue("cfg_rep", "id", "type", DuplicateType.ROLAND_SEIGE))
  197. local dupId = DuplicateCommon.CreateDupMapCommon(system, repId, true)
  198. this.SetCurrentDupId(dupId)
  199. end
  200. -- 请求进入攻城战副本
  201. function RolandSeige.ReqEnterDupLicate(actor)
  202. -- 副本需要开启中
  203. local dupId = this.GetCurrentDupId()
  204. if dupId == nil or dupId == 0 then
  205. gameDebug.assertPrintTrace(false, actor:toString() .. "请求进入罗兰峡谷攻城战,副本未开启或已关闭!")
  206. return
  207. end
  208. -- 通用检查
  209. local repId = tonumber(ConfigDataManager.getTableValue("cfg_rep", "id", "type", DuplicateType.ROLAND_SEIGE))
  210. local commonCheck = DuplicateCommon.CheckEnterConditonCommon(actor, repId)
  211. if commonCheck ~= EnterLimitResultConst.ALLOW then
  212. gameDebug.assertPrintTrace(false, actor:toString() .. "请求进入罗兰峡谷攻城战,进入失败!条件不满足:" .. commonCheck)
  213. return
  214. end
  215. --玩家必须加入战盟
  216. local unionId = getbaseinfo(actor, "guildid")
  217. if unionId == 0 then
  218. gameDebug.assertPrintTrace(false, actor:toString() .. "请求进入罗兰峡谷攻城战,未处于一个战盟中!")
  219. return
  220. end
  221. -- 盟主需要在攻城战副本中,4.3版本移除
  222. local unionInfo = getunioninfo(actor)
  223. local leaderId = unionInfo.leaderid
  224. -- if tostring(leaderId) ~= actor:toString() then
  225. -- local leaderActor = getactor(leaderId)
  226. -- local leaderMapId = getbaseinfo(leaderActor, "unimapid")
  227. -- if dupId ~= leaderMapId then
  228. -- tipinfo(actor, "条件不满足!")
  229. -- return
  230. -- end
  231. -- end
  232. -- 战盟人数要求
  233. local needSize = tonumber(ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.ROLAND_SEIGE.NEED_UNION_SIZE))
  234. local unionSize = unionInfo.num
  235. if unionSize < needSize then
  236. tipinfo(actor, "条件不满足!")
  237. info(actor:toString() .. "请求进入罗兰峡谷攻城战,战盟人数不足!当前人数:" .. unionSize .. " ;需要人数:" .. needSize)
  238. return
  239. end
  240. --回蓝回血
  241. DuplicateCommon.RecoverHPMP(actor)
  242. -- 进入副本
  243. local transferPointStr = ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.ROLAND_SEIGE.TRANSFER_POINT)
  244. local transferPointStrSplit = string.split(transferPointStr, "|")
  245. local selfCamp = this.GetCamp(actor, dupId)
  246. local transferStr
  247. if selfCamp == RolandConst.CAMP_TYPE.ATTACK then
  248. transferStr = transferPointStrSplit[1]
  249. else
  250. transferStr = transferPointStrSplit[2]
  251. end
  252. local transferStrSplit = string.split(transferStr, "#")
  253. local x = transferStrSplit[1]
  254. local y = transferStrSplit[2]
  255. enterduplicate(actor, dupId, x, y)
  256. end
  257. -- 玩家是否在罗兰峡谷
  258. function RolandSeige.IsPlayerInRoland(actor)
  259. local mapId = getbaseinfo(actor, "unimapid")
  260. local dupInfo = getduplicate(mapId)
  261. if dupInfo == nil then
  262. return false
  263. end
  264. if dupInfo.type ~= DuplicateType.ROLAND_SEIGE then
  265. return false
  266. end
  267. return true
  268. end
  269. function RolandSeige.CanAttackRolandWall(actor, targetActor, castType, targetType)
  270. if RolandSeige.IsPlayerInRoland(actor) then
  271. if targetType == MapObjectType.MONSTER then
  272. local mapId = getbaseinfo(actor, "unimapid")
  273. if castType == MapObjectType.PET or castType == MapObjectType.PARTNER then
  274. local masterId = getbaseinfo(actor, "master")
  275. actor = getactor(masterId, mapId)
  276. end
  277. local camp = this.GetCamp(actor, mapId)
  278. if camp == RolandConst.CAMP_TYPE.DEFEND then
  279. return false
  280. end
  281. end
  282. end
  283. return true
  284. end
  285. -----------------------------------------------------------------------------------------------------------------------------------------
  286. ---------------------------------------------------------- 事件 -----------------------------------------------------------------
  287. -- 服务器分钟心跳,用于首次开启活动
  288. function RolandSeige.ServerMinuteHeart()
  289. local seconds = getbaseinfo("nowsec")
  290. local now = TimeUtil.timeToDate(seconds)
  291. local nowMin = now.min
  292. local nowHour = now.hour
  293. local day, hour, minute = this.GetFirstOpenTime()
  294. if nowHour == hour and nowMin == minute then
  295. local openDays = getbaseinfo("serveropendays")
  296. if day == openDays then
  297. -- 活动是否开启
  298. local activityInfo = getactivityinfo(DuplicateType.ROLAND_SEIGE)
  299. if activityInfo ~= nil then
  300. local isOpen = activityInfo.open
  301. if isOpen then
  302. gameDebug.assertPrintTrace(false, "首次开启罗兰攻城战时活动已被开启")
  303. return
  304. end
  305. end
  306. -- 开启活动
  307. openactivity(DuplicateType.ROLAND_SEIGE)
  308. end
  309. end
  310. end
  311. -- @description 副本阶段更新
  312. -- @param 系统id;地图唯一id;副本类型;副本阶段(1-准备 2-战斗 3-结算);下一阶段开始时间戳;配置id(cfg_rep的id)
  313. function RolandSeige.DupStateUpdate(system, mapId, state, nextStateStartTime, configId)
  314. if state == DuplicateState.PREPARE then
  315. this.InitRolandData(mapId, configId)
  316. --刷怪
  317. local monsterId = ConfigDataManager.getTableValue("cfg_rep", "monster", "id", configId)
  318. local monsterList = DuplicateCommon.DupGenMonsterCommon(mapId, monsterId)
  319. for _, monActor in pairs(monsterList) do
  320. -- 设置怪物的朝向
  321. setmapobjectdir(monActor, -1)
  322. end
  323. elseif state == DuplicateState.FIGHT then
  324. this.SendAllStateInfo(mapId, configId, state, nextStateStartTime)
  325. elseif state == DuplicateState.FINISH then
  326. this.Settlement(mapId, configId)
  327. elseif state == DuplicateState.CLOSED then
  328. this.SetCurrentDupId(nil)
  329. closeactivity(DuplicateType.ROLAND_SEIGE)
  330. end
  331. end
  332. -- 副本3秒心跳
  333. function RolandSeige.Dup3SecondHeart(mapId, dupConfig, state)
  334. if state == DuplicateState.FIGHT then
  335. this.SendAllTaskPanel(mapId)
  336. end
  337. end
  338. --副本1秒钟心跳
  339. function RolandSeige.DupSecondHeart(mapId, dupConfig, state)
  340. if state == DuplicateState.FIGHT then
  341. if this.IsFinalPhase(mapId) then
  342. local areaStr = ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.ROLAND_SEIGE.OCCUPY_AREA)
  343. local areaStrSplit = string.split(areaStr, "#")
  344. local x = areaStrSplit[1]
  345. local y = areaStrSplit[2]
  346. local range = areaStrSplit[3]
  347. -- 获取圈内所有玩家
  348. local idList = getobjectinmap(mapId, x, y, range)
  349. if #idList <= 0 then
  350. this.SendAllUnionProgress(mapId, nil)
  351. return
  352. end
  353. local unionIds = {}
  354. -- 如果是守方,个人加积分
  355. for _, rid in pairs(idList) do
  356. local actor = getactor(rid, mapId)
  357. if not isdead(actor) then
  358. local camp = this.GetCamp(actor, mapId)
  359. if camp == RolandConst.CAMP_TYPE.DEFEND then
  360. RoleScoreDTO.addStay(actor, mapId, 1)
  361. end
  362. local unionId = getbaseinfo(actor, "guildid")
  363. if not table.contains(unionIds, unionId) then
  364. table.insert(unionIds, unionId)
  365. end
  366. end
  367. end
  368. -- 如果全部是同一个战盟,修改战盟攻守方,增加战盟进度条
  369. if #unionIds == 1 then
  370. local unionId = unionIds[1]
  371. local oldUnionId = this.GetDefendUnionId(mapId)
  372. -- 增加进度条
  373. local progressDTO = UnionProgressDTO.add(mapId, unionId, 1)
  374. if tostring(unionId) ~= tostring(oldUnionId) then
  375. -- 如果不是守方战盟,
  376. --1.清空守方战盟进度条;
  377. if oldUnionId ~= nil and oldUnionId > 0 then
  378. UnionProgressDTO.reset(mapId, oldUnionId)
  379. end
  380. --2.如果self进度条满了,换成守方,清空所有其他战盟进度条
  381. if UnionProgressDTO.isMax(progressDTO) then
  382. this.SetDefendUnionId(mapId, unionId)
  383. local allUnion = this.GetAllParticipatingUnions(mapId)
  384. for _, unionId0 in pairs(allUnion) do
  385. if tostring(unionId) ~= tostring(unionId0) then
  386. UnionProgressDTO.reset(mapId, unionId0)
  387. end
  388. end
  389. end
  390. end
  391. -- 通知全地图进度条信息
  392. this.SendAllUnionProgress(mapId, progressDTO)
  393. else
  394. -- 多个战盟在占领圈内
  395. this.SendAllUnionProgress(mapId, nil)
  396. end
  397. end
  398. end
  399. end
  400. -- 怪物死亡从副本中移除
  401. function RolandSeige.MapMonsterRemove(mapId, killer, monCfgId)
  402. this.SendAllPlayMonsterList(mapId)
  403. local taskInfo = this.GetAttackTask(mapId)
  404. local taskId = taskInfo[1]
  405. local taskType = taskInfo[2]
  406. if taskType == DuplicateTaskType.KILL_TARGET_MONSTER then
  407. local totalCount = taskInfo[3]
  408. local nowCount = taskInfo[4]
  409. local targetCfg = taskInfo[5]
  410. if monCfgId == targetCfg then
  411. nowCount = nowCount + 1
  412. end
  413. if nowCount >= totalCount then
  414. -- 当前任务完成,设置下一个任务
  415. local nextId = tonumber(ConfigDataManager.getTableValue("cfg_repTask", "nextID", "id", taskId))
  416. if nextId ~= nil then
  417. local defendTaskInfo = this.GetDefendTask(mapId)
  418. local nextDeId = tonumber(ConfigDataManager.getTableValue("cfg_repTask", "nextID", "id", defendTaskInfo[1]))
  419. this.SetAttackTask(mapId, nextId)
  420. this.SetDefendTask(mapId, nextDeId)
  421. -- 更新战斗模式
  422. local nextTaskType = ConfigDataManager.getTableValue("cfg_repTask", "type", "id", nextId)
  423. if tonumber(nextTaskType) == DuplicateTaskType.ROLAND_SEIGE_OCCUPY then
  424. -- 修改所有人的战斗模式
  425. local allPlayers = getmapplayer(mapId)
  426. for _, actor in pairs(allPlayers) do
  427. setplayersetting(actor, 1, 5)
  428. end
  429. end
  430. this.SendAllTaskPanel(mapId)
  431. end
  432. end
  433. end
  434. end
  435. -- @description 玩家进入副本后
  436. -- @param 玩家对象;地图唯一id;副本类型;副本阶段(1-准备 2-战斗 3-结算);下一阶段开始时间戳;配置id(cfg_rep的id)
  437. -- @return
  438. function RolandSeige.AfterEnterRoland(actor, mapId, state, nextStateStartTime, configId)
  439. -- 记录参与的玩家
  440. local rid = actor:toString()
  441. local selfUnionId = getbaseinfo(actor, "guildid")
  442. local roleScoreDTO = RoleScoreDTO.get(actor, mapId)
  443. if roleScoreDTO == nil then
  444. -- 不只是积分,需要修改
  445. roleScoreDTO = RoleScoreDTO.new(rid, selfUnionId)
  446. RoleScoreDTO.set(actor, mapId, roleScoreDTO)
  447. end
  448. -- 设置战盟进度条
  449. local progressDTO = UnionProgressDTO.get(mapId, selfUnionId)
  450. if progressDTO == nil then
  451. local dto = UnionProgressDTO.new(selfUnionId, false)
  452. UnionProgressDTO.set(mapId, selfUnionId, dto)
  453. end
  454. -- 修改战斗模式
  455. if this.IsFinalPhase(mapId) then
  456. setplayersetting(actor, 1, 5)
  457. else
  458. if this.GetCamp(actor, mapId) == RolandConst.CAMP_TYPE.ATTACK then
  459. setplayersetting(actor, 1, 11)
  460. else
  461. setplayersetting(actor, 1, 12)
  462. end
  463. end
  464. -- 发送副本阶段
  465. this.SendStateInfo(actor, configId, state, nextStateStartTime)
  466. -- 任务面板
  467. this.SendTaskPanel(actor, mapId)
  468. -- 怪物信息
  469. this.SendMonsterList(actor, mapId)
  470. -- if state == DuplicateState.PREPARE then
  471. -- elseif state == DuplicateState.FIGHT then
  472. -- elseif state == DuplicateState.FINISH then
  473. -- end
  474. end
  475. -- 玩家在罗兰峡谷修改战斗模式
  476. function RolandSeige.RolandSettingChange(actor, cType, value)
  477. if cType ~= 1 or (not RolandSeige.IsPlayerInRoland(actor)) then
  478. return
  479. end
  480. local mapId = getbaseinfo(actor, "unimapid")
  481. if this.IsFinalPhase(mapId) then
  482. if value ~= 5 then
  483. setplayersetting(actor, 1, 5)
  484. end
  485. else
  486. if this.GetCamp(actor, mapId) == RolandConst.CAMP_TYPE.ATTACK then
  487. if value ~= 11 then
  488. setplayersetting(actor, 1, 11)
  489. end
  490. else
  491. if value ~= 12 then
  492. setplayersetting(actor, 1, 12)
  493. end
  494. end
  495. end
  496. end
  497. -- 玩家退出副本
  498. function RolandSeige.OnQuitDup(actor, mapId, state, nextStateStartTime, configId)
  499. setplayersetting(actor, 1, 5)
  500. end
  501. -- 击杀玩家事件
  502. function RolandSeige.KillPlayer(actor, diePlayer)
  503. local mapId = getbaseinfo(actor, "unimapid")
  504. local dupInfo = getduplicate(mapId)
  505. if dupInfo == nil or dupInfo == "" then
  506. return
  507. end
  508. local type = dupInfo["type"]
  509. if type ~= DuplicateType.ROLAND_SEIGE then
  510. return
  511. end
  512. RoleScoreDTO.addKill(actor, mapId, 1)
  513. this.SendTaskPanel(actor, mapId)
  514. end
  515. -- @description 玩家复活事件
  516. -- @param 玩家对象
  517. function RolandSeige.PlayerRelive(actor)
  518. local mapId = getbaseinfo(actor, "unimapid")
  519. local dupInfo = getduplicate(mapId)
  520. if dupInfo == nil then
  521. return
  522. end
  523. local type = dupInfo["type"]
  524. if type ~= DuplicateType.ROLAND_SEIGE then
  525. return
  526. end
  527. local camp = this.GetCamp(actor, mapId)
  528. -- 复活后传送
  529. local x, y
  530. local taskInfo = this.GetAttackTask(mapId)
  531. local taskId = taskInfo[1]
  532. if camp == RolandConst.CAMP_TYPE.ATTACK then
  533. local relivePointStr = ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.ROLAND_SEIGE.ATTACK_RELIVE_POINT)
  534. local relivePointStrSplit = string.split(relivePointStr, "|")
  535. for _, value in pairs(relivePointStrSplit) do
  536. local valueSplit = string.split(value, "#")
  537. if tonumber(valueSplit[1]) == taskId then
  538. x = valueSplit[1]
  539. y = valueSplit[2]
  540. break
  541. end
  542. end
  543. elseif camp == RolandConst.CAMP_TYPE.DEFEND then
  544. local relivePointStr = ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.ROLAND_SEIGE.DEFEND_RELIVE_POINT)
  545. local relivePointStrSplit = string.split(relivePointStr, "#")
  546. x = relivePointStrSplit[1]
  547. y = relivePointStrSplit[2]
  548. end
  549. if x ~= nil and y ~= nil then
  550. maptransfer(actor, x, y, 0, 0, 0)
  551. else
  552. gameDebug.assertPrintTrace(false, actor:toString() .. "罗兰峡谷攻城战死亡复活传送未找到传送点!camp: " .. camp .. " ;taskId:" .. taskId)
  553. end
  554. end
  555. -- 攻击事件
  556. function RolandSeige.Attack(actor, fightData)
  557. local mapId = getbaseinfo(actor, "unimapid")
  558. local dupInfo = getduplicate(mapId)
  559. if dupInfo == nil then
  560. return
  561. end
  562. local type = dupInfo["type"]
  563. if type ~= DuplicateType.ROLAND_SEIGE then
  564. return
  565. end
  566. local casterType = fightData.castertype
  567. local targetType = fightData.targettype
  568. if casterType ~= MapObjectType.PLAYER and casterType ~= MapObjectType.PET then
  569. return
  570. end
  571. if casterType == MapObjectType.PET or casterType == MapObjectType.PARTNER then
  572. local masterId = getbaseinfo(actor, "master")
  573. actor = getactor(masterId, mapId)
  574. end
  575. local camp = this.GetCamp(actor, mapId)
  576. if camp == RolandConst.CAMP_TYPE.ATTACK and targetType == MapObjectType.MONSTER then
  577. -- 增加攻方攻击建筑的次数
  578. RoleScoreDTO.addAttackBuilding(actor, mapId, 1)
  579. end
  580. -- 累计伤害
  581. RoleScoreDTO.addHurt(actor, mapId, fightData.targethurt)
  582. this.SendTaskPanel(actor, mapId)
  583. end
  584. --------------------------------------------------------------------------------------------------------------------------
  585. -- 初始化攻城战数据
  586. function this.InitRolandData(mapId, configId)
  587. -- 攻守方任务
  588. local firstTaskStr = ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.ROLAND_SEIGE.FIRST_TASK)
  589. local firstTaskStrSplit = string.split(firstTaskStr, "#")
  590. local defendTask = tonumber(firstTaskStrSplit[2])
  591. local attackTask = tonumber(firstTaskStrSplit[1])
  592. this.SetAttackTask(mapId, attackTask)
  593. this.SetDefendTask(mapId, defendTask)
  594. -- 设置守方战盟
  595. local defendUnionId = this.GetLastOccupyUnionId()
  596. if defendUnionId == nil then
  597. defendUnionId = 0
  598. end
  599. this.SetDefendUnionId(mapId, defendUnionId)
  600. if defendUnionId ~= 0 then
  601. local progressDTO = UnionProgressDTO.new(defendUnionId, true)
  602. UnionProgressDTO.set(mapId, defendUnionId, progressDTO)
  603. end
  604. end
  605. function this.GetUnionListInRange(mapId)
  606. local unionIds = {}
  607. local areaStr = ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.ROLAND_SEIGE.OCCUPY_AREA)
  608. local areaStrSplit = string.split(areaStr, "#")
  609. local x = areaStrSplit[1]
  610. local y = areaStrSplit[2]
  611. local range = areaStrSplit[3]
  612. -- 获取圈内所有战盟
  613. local idList = getobjectinmap(mapId, x, y, range)
  614. for _, rid in pairs(idList) do
  615. local actor = getactor(rid, mapId)
  616. local unionId = getbaseinfo(actor, "guildid")
  617. if not table.contains(unionIds, unionId) then
  618. table.insert(unionIds, unionId)
  619. end
  620. end
  621. return unionIds
  622. end
  623. -- 获取个人积分排名
  624. function this.GetPlayerRank(actor, mapId)
  625. local ranking = this.GetPlayerRankList(mapId)
  626. return ranking[actor:toString()]
  627. end
  628. -- 获取玩家的个人积分排名列表
  629. -- @return 列表<玩家id字符串;排名>
  630. function this.GetPlayerRankList(mapId)
  631. local playerList = {}
  632. local allPlayers = this.GetAllParticipatingPlayers(mapId)
  633. for key, actor0 in pairs(allPlayers) do
  634. local score = RoleScoreDTO.calTotalScoreByActor(actor0, mapId)
  635. table.insert(playerList, { rid = actor0:toString(), score = score })
  636. end
  637. table.sort(
  638. playerList,
  639. function(a, b)
  640. return a.score > b.score
  641. end
  642. )
  643. -- 计算排名
  644. local ranks = {}
  645. local rank = 1 -- 当前排名
  646. for i = 1, #playerList do
  647. local player = playerList[i]
  648. -- 每次循环都增加排名
  649. ranks[player.rid] = rank
  650. rank = rank + 1
  651. end
  652. return ranks
  653. end
  654. -- 战盟排名
  655. function this.GetUnionRank(unionId, mapId)
  656. local ranking = this.GetUnionRankMap(mapId)
  657. return ranking[tostring(unionId)]
  658. end
  659. -- 获取战盟积分排名列表
  660. -- @return 列表<战盟id字符串;排名>
  661. function this.GetUnionRankMap(mapId)
  662. local union2Score = {}
  663. local allPlayers = this.GetAllParticipatingPlayers(mapId)
  664. for key, actor0 in pairs(allPlayers) do
  665. local score = RoleScoreDTO.calTotalScoreByActor(actor0, mapId)
  666. local unionId = tostring(getbaseinfo(actor0, "guildid"))
  667. if union2Score[unionId] == nil then
  668. union2Score[unionId] = score
  669. else
  670. union2Score[unionId] = score + union2Score[unionId]
  671. end
  672. end
  673. local scoreArray = {}
  674. for unionId, score in pairs(union2Score) do
  675. table.insert(scoreArray, { unionId = unionId, score = score })
  676. end
  677. table.sort(
  678. scoreArray,
  679. function(a, b)
  680. return a.score > b.score
  681. end
  682. )
  683. -- 计算排名
  684. local ranks = {}
  685. local rank = 1 -- 当前排名
  686. for i = 1, #scoreArray do
  687. local union = scoreArray[i]
  688. -- 每次循环都增加排名
  689. ranks[union.unionId] = rank
  690. rank = rank + 1
  691. end
  692. return ranks
  693. end
  694. -- 获取战盟积分排名列表
  695. -- @return 列表{{ unionId = unionId, score = score },....}
  696. function this.GetUnionRankList(mapId)
  697. local union2Score = {}
  698. local allPlayers = this.GetAllParticipatingPlayers(mapId)
  699. for key, actor0 in pairs(allPlayers) do
  700. local score = RoleScoreDTO.calTotalScoreByActor(actor0, mapId)
  701. local unionId = tostring(getbaseinfo(actor0, "guildid"))
  702. if union2Score[unionId] == nil then
  703. union2Score[unionId] = score
  704. else
  705. union2Score[unionId] = score + union2Score[unionId]
  706. end
  707. end
  708. local scoreArray = {}
  709. for unionId, score in pairs(union2Score) do
  710. table.insert(scoreArray, { unionId = unionId, score = score })
  711. end
  712. table.sort(
  713. scoreArray,
  714. function(a, b)
  715. return a.score > b.score
  716. end
  717. )
  718. return scoreArray
  719. end
  720. -- 是否是最后阶段
  721. function this.IsFinalPhase(mapId)
  722. local attackTaskInfo = this.GetAttackTask(mapId)
  723. local taskId = attackTaskInfo[1]
  724. local nextId = tonumber(ConfigDataManager.getTableValue("cfg_repTask", "nextID", "id", taskId))
  725. if nextId == nil or nextId == 0 then
  726. return true
  727. end
  728. return false
  729. end
  730. -- 结算
  731. function this.Settlement(mapId)
  732. local log = LogRecord.new()
  733. local winUninId
  734. if this.IsFinalPhase(mapId) then
  735. -- 守方战盟为胜利方
  736. local defendUnionId = this.GetDefendUnionId(mapId)
  737. if defendUnionId == nil or defendUnionId == 0 then
  738. -- 无守方
  739. -- 积分第一的为占领战盟,无盟主奖励
  740. local unionRankList = this.GetUnionRankList(mapId)
  741. local unionInfo = unionRankList[1]
  742. winUninId = unionInfo.unionId
  743. log.winType = "积分"
  744. else
  745. local unionInfo = getunioninfo(defendUnionId)
  746. local leaderId = unionInfo.leaderid
  747. local leaderActor = getactor(leaderId, mapId)
  748. local leaderRewardStr = ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.ROLAND_SEIGE.LEADER_REWARD)
  749. local leaderRewardStrSplit = string.toIntIntMap(leaderRewardStr, "#", "|")
  750. sendconfigmailbyrid(leaderActor, leaderActor:toString(), MailConfig.ROLAND_SEIGE_LEADER_REWARD, leaderRewardStrSplit)
  751. winUninId = defendUnionId
  752. log.winType = "占领"
  753. log.leader = leaderId
  754. end
  755. else
  756. winUninId = this.GetLastOccupyUnionId()
  757. end
  758. -- 设置占领战盟
  759. winUninId = winUninId or 0
  760. log.winUninId = winUninId
  761. this.SetLastOccupyUnionId(winUninId)
  762. -- 个人积分奖励
  763. local rank2Reward = {}
  764. local needScore = tonumber(ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.ROLAND_SEIGE.PERSONAL_LIMIT_SCORE))
  765. local personalRewardStr = ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.ROLAND_SEIGE.PERSONAL_REWARD)
  766. local personalRewardStrSplit = string.split(personalRewardStr, "|")
  767. for key, value in pairs(personalRewardStrSplit) do
  768. local valueSplit = string.split(value, "&")
  769. local rankList = string.split(valueSplit[1], "#")
  770. local startRank = tonumber(rankList[1])
  771. local endRank = tonumber(rankList[2])
  772. local totalReward = {}
  773. for j = 2, #valueSplit do
  774. local reward = string.split(valueSplit[j], "#")
  775. totalReward[tonumber(reward[1])] = tonumber(reward[2])
  776. end
  777. table.insert(rank2Reward, { startRank = startRank, endRank = endRank, rewards = totalReward })
  778. end
  779. -- 获取所有参与的玩家
  780. local allPlayers = this.GetAllParticipatingPlayers(mapId)
  781. for _, actor in pairs(allPlayers) do
  782. local selfUnionId = getbaseinfo(actor, "guildid")
  783. if tostring(selfUnionId) == tostring(winUninId) then
  784. -- 获胜
  785. local winRewardStr = ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.ROLAND_SEIGE.WIN_UNION_REWARD)
  786. local winRewardStrSplit = string.toIntIntMap(winRewardStr, "#", "|")
  787. sendconfigmailbyrid(actor, actor:toString(), MailConfig.ROLAND_SEIGE_WIN_UNION_REWARD, winRewardStrSplit)
  788. else
  789. --失败
  790. local failRewardStr = ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.ROLAND_SEIGE.FAIL_UNION_REWARD)
  791. local failRewardStrSplit = string.toIntIntMap(failRewardStr, "#", "|")
  792. sendconfigmailbyrid(actor, actor:toString(), MailConfig.ROLAND_SEIGE_FAIL_UNION_REWARD, failRewardStrSplit)
  793. end
  794. -- 个人积分奖励
  795. local ownScore = RoleScoreDTO.calTotalScoreByActor(actor, mapId)
  796. log.personalScoreList[actor:toString()] = ownScore
  797. local ranking = this.GetPlayerRankList(mapId)
  798. if ownScore >= needScore then
  799. local rank = ranking[actor:toString()]
  800. for _, rewardInfo in ipairs(rank2Reward) do
  801. if rank >= rewardInfo.startRank and rank <= rewardInfo.endRank then
  802. local rewards = rewardInfo.rewards
  803. sendconfigmailbyrid(actor, actor:toString(), MailConfig.ROLAND_SEIGE_PERSONAL_REWARD, rewards, rank)
  804. end
  805. end
  806. end
  807. end
  808. gameDebug.debug(LogRecord.log, log)
  809. end
  810. -- 获取玩家的阵营
  811. function this.GetCamp(actor, mapId)
  812. local defendUnionId = this.GetDefendUnionId(mapId)
  813. local selfUnionId = getbaseinfo(actor, "guildid")
  814. if tostring(defendUnionId) == tostring(selfUnionId) then
  815. return RolandConst.CAMP_TYPE.DEFEND
  816. else
  817. return RolandConst.CAMP_TYPE.ATTACK
  818. end
  819. end
  820. -- 是否可以开启
  821. function RolandSeige.CanOpenActivity()
  822. local openDays = getbaseinfo("serveropendays")
  823. local day, hour, minute = this.GetFirstOpenTime()
  824. if openDays < day then
  825. return false
  826. end
  827. return true
  828. end
  829. -- 获取首次开启时间
  830. function this.GetFirstOpenTime()
  831. local firstOpenTimeString = ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.ROLAND_SEIGE.FIRST_OPEN_TIME)
  832. local firstOpenTimeStringSplit = string.split(firstOpenTimeString, "#")
  833. local day = tonumber(firstOpenTimeStringSplit[1])
  834. local hour = tonumber(firstOpenTimeStringSplit[2])
  835. local minute = tonumber(firstOpenTimeStringSplit[3])
  836. return day, hour, minute
  837. end
  838. ---------------------------------------------------------- 响应 -----------------------------------------------------------------
  839. -- 响应单个玩家副本阶段
  840. function this.SendStateInfo(actor, repId, state, nextStateStartTime)
  841. sendluamsg(actor, LuaMessageIdToClient.RES_ROLAND_SEIGE_STATE, { repId, state, tostring(nextStateStartTime) })
  842. end
  843. -- 响应所有玩家副本阶段
  844. function this.SendAllStateInfo(mapId, repId, state, nextStateStartTime)
  845. local allPlayers = getmapplayer(mapId)
  846. if #allPlayers > 0 then
  847. for _, actor in pairs(allPlayers) do
  848. this.SendStateInfo(actor, repId, state, nextStateStartTime)
  849. end
  850. end
  851. end
  852. -- 响应单个玩家任务面板信息
  853. function this.SendTaskPanel(actor, mapId)
  854. local res = {}
  855. local selfCamp = this.GetCamp(actor, mapId)
  856. res.camp = selfCamp
  857. -- 任务信息
  858. local taskInfo
  859. if selfCamp == RolandConst.CAMP_TYPE.ATTACK then
  860. taskInfo = this.GetAttackTask(mapId)
  861. else
  862. taskInfo = this.GetDefendTask(mapId)
  863. end
  864. local taskId = taskInfo[1]
  865. local taskType = taskInfo[2]
  866. if taskType == DuplicateTaskType.KILL_TARGET_MONSTER then
  867. local targetMonCfg = taskInfo[5]
  868. local monsterList = mapbossinfo(mapId, -1, targetMonCfg)
  869. local minHP = 999999999
  870. local maxHP = 999999999
  871. for _, monInfo in pairs(monsterList) do
  872. local monHP = monInfo.hp
  873. if monHP < minHP then
  874. minHP = monHP
  875. end
  876. maxHP = monInfo.maxhp
  877. end
  878. res.nowCount = math.ceil((minHP / maxHP) * 100)
  879. res.totalCount = 100
  880. else
  881. res.nowCount = 0
  882. res.totalCount = 1
  883. end
  884. res.taskId = taskId
  885. -- 占领战盟
  886. local defendUnionId = this.GetDefendUnionId(mapId)
  887. if defendUnionId == nil or defendUnionId == 0 then
  888. res.unionName = "无"
  889. else
  890. --
  891. local progressDTO = UnionProgressDTO.get(mapId, defendUnionId)
  892. res.unionName = progressDTO.unionName
  893. end
  894. -- 所在战盟排名
  895. local unionId = getbaseinfo(actor, "guildid")
  896. res.unionRank = this.GetUnionRank(unionId, mapId)
  897. -- 个人排名
  898. res.selfRank = this.GetPlayerRank(actor, mapId)
  899. -- 个人积分
  900. res.selfScore = RoleScoreDTO.calTotalScoreByActor(actor, mapId)
  901. sendluamsg(actor, LuaMessageIdToClient.RES_ROLAND_SEIGE_TASK_PANEL, res)
  902. end
  903. -- 响应所有玩家任务面板信息
  904. function this.SendAllTaskPanel(mapId)
  905. local allPlayers = getmapplayer(mapId)
  906. if #allPlayers > 0 then
  907. for _, actor in pairs(allPlayers) do
  908. this.SendTaskPanel(actor, mapId)
  909. end
  910. end
  911. end
  912. -- 响应所有玩家战盟占领进度
  913. function this.SendAllUnionProgress(mapId, progressDTO)
  914. local allPlayers = getmapplayer(mapId)
  915. if #allPlayers > 0 then
  916. for _, actor in pairs(allPlayers) do
  917. sendluamsg(actor, LuaMessageIdToClient.RES_ROLAND_PROGRESS_INFO, progressDTO)
  918. end
  919. end
  920. end
  921. -- 响应玩家副本怪物信息
  922. function this.SendMonsterList(actor, mapId)
  923. local res = this.BuildResMonsterList(mapId)
  924. sendluamsg(actor, LuaMessageIdToClient.RES_ROLAND_MONSTER_LIST, res)
  925. end
  926. -- 响应所有玩家副本怪物信息
  927. function this.SendAllPlayMonsterList(mapId)
  928. local res = this.BuildResMonsterList(mapId)
  929. local allPlayers = getmapplayer(mapId)
  930. if #allPlayers > 0 then
  931. for _, actor in pairs(allPlayers) do
  932. sendluamsg(actor, LuaMessageIdToClient.RES_ROLAND_MONSTER_LIST, res)
  933. end
  934. end
  935. end
  936. function this.BuildResMonsterList(mapId)
  937. local res = {}
  938. local monList = getmapmon(mapId)
  939. for _, monActor in pairs(monList) do
  940. local oneRes = {}
  941. local monInfo = getmonsterinfo(monActor)
  942. oneRes.id = monInfo.id
  943. oneRes.cfg = monInfo.cfgid
  944. oneRes.x = monInfo.x
  945. oneRes.y = monInfo.y
  946. table.insert(res, oneRes)
  947. end
  948. return res
  949. end
  950. --------------------------------------------------------------------------------------------------------------------------
  951. ---------------------------------------------------------- 数据 -----------------------------------------------------------------
  952. -- 获取当前进行的攻城战副本id
  953. function this.GetCurrentDupId()
  954. local oldDupId = getsysvar(SystemVarConst.ROLAND_SEIGE.DUPLICATE_ID)
  955. return oldDupId
  956. end
  957. -- 设置当前进行的攻城战副本id
  958. function this.SetCurrentDupId(dupId)
  959. setsysvar(SystemVarConst.ROLAND_SEIGE.DUPLICATE_ID, dupId)
  960. end
  961. -- 获取上次占领战盟Id
  962. function this.GetLastOccupyUnionId()
  963. local unionId = getsysvar(SystemVarConst.ROLAND_SEIGE.LAST_OCCUPY_UNION_ID)
  964. return unionId
  965. end
  966. -- 设置上次占领战盟Id
  967. function this.SetLastOccupyUnionId(unionId)
  968. setsysvar(SystemVarConst.ROLAND_SEIGE.LAST_OCCUPY_UNION_ID, unionId)
  969. end
  970. -- 获取守方战盟id
  971. function this.GetDefendUnionId(mapId)
  972. local unionId = getenvirvar(mapId, DuplicateVarConst.ROLAND_SEIGE.DEFEND_UNION)
  973. return unionId
  974. end
  975. -- 设置守方战盟id
  976. function this.SetDefendUnionId(mapId, unionId)
  977. setenvirvar(mapId, DuplicateVarConst.ROLAND_SEIGE.DEFEND_UNION, unionId)
  978. end
  979. -- 获取守方任务
  980. function this.GetDefendTask(mapId)
  981. local defendTaskInfo = getenvirvar(mapId, DuplicateVarConst.ROLAND_SEIGE.DEFEND_TASK)
  982. return defendTaskInfo
  983. end
  984. -- 设置守方任务
  985. function this.SetDefendTask(mapId, taskId)
  986. local defendTaskInfo = DuplicateCommon.GenDupTaskInfoCommon(taskId)
  987. setenvirvar(mapId, DuplicateVarConst.ROLAND_SEIGE.DEFEND_TASK, defendTaskInfo)
  988. end
  989. -- 获取攻方任务
  990. function this.GetAttackTask(mapId)
  991. local attackTaskInfo = getenvirvar(mapId, DuplicateVarConst.ROLAND_SEIGE.ATTACK_TASK)
  992. return attackTaskInfo
  993. end
  994. -- 设置攻方任务
  995. function this.SetAttackTask(mapId, taskId)
  996. local attackTaskInfo = DuplicateCommon.GenDupTaskInfoCommon(taskId)
  997. setenvirvar(mapId, DuplicateVarConst.ROLAND_SEIGE.ATTACK_TASK, attackTaskInfo)
  998. end
  999. -- 获取所有参与的玩家{actor,...}
  1000. function this.GetAllParticipatingPlayers(mapId)
  1001. local allPlayers = getdupparticipants(mapId)
  1002. return allPlayers
  1003. end
  1004. -- 获取所有参与的战盟
  1005. function this.GetAllParticipatingUnions(mapId)
  1006. local allUnion = {}
  1007. local allPlayers = this.GetAllParticipatingPlayers(mapId)
  1008. for _, actor in pairs(allPlayers) do
  1009. local unionId = getbaseinfo(actor, "guildid")
  1010. if not table.contains(allUnion, unionId) then
  1011. table.insert(allUnion, unionId)
  1012. end
  1013. end
  1014. return allUnion
  1015. end
  1016. --------------------------------------------------------------------------------------------------------------------------
  1017. function testenterroland(actor)
  1018. RolandSeige.ReqEnterDupLicate(actor)
  1019. end
  1020. function testcloseroland(actor)
  1021. local mapId = getbaseinfo(actor, "unimapid")
  1022. setduplicatestate(mapId, SetDuplicateStateConst.TO_FINISH)
  1023. end
  1024. function testfightroland(actor)
  1025. local mapId = getbaseinfo(actor, "unimapid")
  1026. setduplicatestate(mapId, SetDuplicateStateConst.TO_FIGHT)
  1027. end
  1028. function testreqroland(actor)
  1029. RolandSeige.ReqMainPanel(actor)
  1030. end
  1031. function testclearroland(actor)
  1032. this.SetLastOccupyUnionId(0)
  1033. end