RolandSeige.lua 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128
  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. -- 盟主需要在攻城战副本中
  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.OnQuitDup(actor, mapId, state, nextStateStartTime, configId)
  477. setplayersetting(actor, 1, 5)
  478. end
  479. -- 击杀玩家事件
  480. function RolandSeige.KillPlayer(actor, diePlayer)
  481. local mapId = getbaseinfo(actor, "unimapid")
  482. local dupInfo = getduplicate(mapId)
  483. if dupInfo == nil or dupInfo == "" then
  484. return
  485. end
  486. local type = dupInfo["type"]
  487. if type ~= DuplicateType.ROLAND_SEIGE then
  488. return
  489. end
  490. RoleScoreDTO.addKill(actor, mapId, 1)
  491. this.SendTaskPanel(actor, mapId)
  492. end
  493. -- @description 玩家复活事件
  494. -- @param 玩家对象
  495. function RolandSeige.PlayerRelive(actor)
  496. local mapId = getbaseinfo(actor, "unimapid")
  497. local dupInfo = getduplicate(mapId)
  498. if dupInfo == nil then
  499. return
  500. end
  501. local type = dupInfo["type"]
  502. if type ~= DuplicateType.ROLAND_SEIGE then
  503. return
  504. end
  505. local camp = this.GetCamp(actor, mapId)
  506. -- 复活后传送
  507. local x, y
  508. local taskInfo = this.GetAttackTask(mapId)
  509. local taskId = taskInfo[1]
  510. if camp == RolandConst.CAMP_TYPE.ATTACK then
  511. local relivePointStr = ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.ROLAND_SEIGE.ATTACK_RELIVE_POINT)
  512. local relivePointStrSplit = string.split(relivePointStr, "|")
  513. for _, value in pairs(relivePointStrSplit) do
  514. local valueSplit = string.split(value, "#")
  515. if tonumber(valueSplit[1]) == taskId then
  516. x = valueSplit[1]
  517. y = valueSplit[2]
  518. break
  519. end
  520. end
  521. elseif camp == RolandConst.CAMP_TYPE.DEFEND then
  522. local relivePointStr = ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.ROLAND_SEIGE.DEFEND_RELIVE_POINT)
  523. local relivePointStrSplit = string.split(relivePointStr, "#")
  524. x = relivePointStrSplit[1]
  525. y = relivePointStrSplit[2]
  526. end
  527. if x ~= nil and y ~= nil then
  528. maptransfer(actor, x, y, 0, 0, 0)
  529. else
  530. gameDebug.assertPrintTrace(false, actor:toString() .. "罗兰峡谷攻城战死亡复活传送未找到传送点!camp: " .. camp .. " ;taskId:" .. taskId)
  531. end
  532. end
  533. -- 攻击事件
  534. function RolandSeige.Attack(actor, fightData)
  535. local mapId = getbaseinfo(actor, "unimapid")
  536. local dupInfo = getduplicate(mapId)
  537. if dupInfo == nil then
  538. return
  539. end
  540. local type = dupInfo["type"]
  541. if type ~= DuplicateType.ROLAND_SEIGE then
  542. return
  543. end
  544. local casterType = fightData.castertype
  545. local targetType = fightData.targettype
  546. if casterType ~= MapObjectType.PLAYER and casterType ~= MapObjectType.PET then
  547. return
  548. end
  549. if casterType == MapObjectType.PET or casterType == MapObjectType.PARTNER then
  550. local masterId = getbaseinfo(actor, "master")
  551. actor = getactor(masterId, mapId)
  552. end
  553. local camp = this.GetCamp(actor, mapId)
  554. if camp == RolandConst.CAMP_TYPE.ATTACK and targetType == MapObjectType.MONSTER then
  555. -- 增加攻方攻击建筑的次数
  556. RoleScoreDTO.addAttackBuilding(actor, mapId, 1)
  557. end
  558. -- 累计伤害
  559. RoleScoreDTO.addHurt(actor, mapId, fightData.targethurt)
  560. this.SendTaskPanel(actor, mapId)
  561. end
  562. --------------------------------------------------------------------------------------------------------------------------
  563. -- 初始化攻城战数据
  564. function this.InitRolandData(mapId, configId)
  565. -- 攻守方任务
  566. local firstTaskStr = ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.ROLAND_SEIGE.FIRST_TASK)
  567. local firstTaskStrSplit = string.split(firstTaskStr, "#")
  568. local defendTask = tonumber(firstTaskStrSplit[2])
  569. local attackTask = tonumber(firstTaskStrSplit[1])
  570. this.SetAttackTask(mapId, attackTask)
  571. this.SetDefendTask(mapId, defendTask)
  572. -- 设置守方战盟
  573. local defendUnionId = this.GetLastOccupyUnionId()
  574. if defendUnionId == nil then
  575. defendUnionId = 0
  576. end
  577. this.SetDefendUnionId(mapId, defendUnionId)
  578. if defendUnionId ~= 0 then
  579. local progressDTO = UnionProgressDTO.new(defendUnionId, true)
  580. UnionProgressDTO.set(mapId, defendUnionId, progressDTO)
  581. end
  582. end
  583. function this.GetUnionListInRange(mapId)
  584. local unionIds = {}
  585. local areaStr = ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.ROLAND_SEIGE.OCCUPY_AREA)
  586. local areaStrSplit = string.split(areaStr, "#")
  587. local x = areaStrSplit[1]
  588. local y = areaStrSplit[2]
  589. local range = areaStrSplit[3]
  590. -- 获取圈内所有战盟
  591. local idList = getobjectinmap(mapId, x, y, range)
  592. for _, rid in pairs(idList) do
  593. local actor = getactor(rid, mapId)
  594. local unionId = getbaseinfo(actor, "guildid")
  595. if not table.contains(unionIds, unionId) then
  596. table.insert(unionIds, unionId)
  597. end
  598. end
  599. return unionIds
  600. end
  601. -- 获取个人积分排名
  602. function this.GetPlayerRank(actor, mapId)
  603. local ranking = this.GetPlayerRankList(mapId)
  604. return ranking[actor:toString()]
  605. end
  606. -- 获取玩家的个人积分排名列表
  607. -- @return 列表<玩家id字符串;排名>
  608. function this.GetPlayerRankList(mapId)
  609. local playerList = {}
  610. local allPlayers = this.GetAllParticipatingPlayers(mapId)
  611. for key, actor0 in pairs(allPlayers) do
  612. local score = RoleScoreDTO.calTotalScoreByActor(actor0, mapId)
  613. table.insert(playerList, { rid = actor0:toString(), score = score })
  614. end
  615. table.sort(
  616. playerList,
  617. function(a, b)
  618. return a.score > b.score
  619. end
  620. )
  621. -- 计算排名
  622. local ranks = {}
  623. local rank = 1 -- 当前排名
  624. for i = 1, #playerList do
  625. local player = playerList[i]
  626. -- 每次循环都增加排名
  627. ranks[player.rid] = rank
  628. rank = rank + 1
  629. end
  630. return ranks
  631. end
  632. -- 战盟排名
  633. function this.GetUnionRank(unionId, mapId)
  634. local ranking = this.GetUnionRankMap(mapId)
  635. return ranking[tostring(unionId)]
  636. end
  637. -- 获取战盟积分排名列表
  638. -- @return 列表<战盟id字符串;排名>
  639. function this.GetUnionRankMap(mapId)
  640. local union2Score = {}
  641. local allPlayers = this.GetAllParticipatingPlayers(mapId)
  642. for key, actor0 in pairs(allPlayers) do
  643. local score = RoleScoreDTO.calTotalScoreByActor(actor0, mapId)
  644. local unionId = tostring(getbaseinfo(actor0, "guildid"))
  645. if union2Score[unionId] == nil then
  646. union2Score[unionId] = score
  647. else
  648. union2Score[unionId] = score + union2Score[unionId]
  649. end
  650. end
  651. local scoreArray = {}
  652. for unionId, score in pairs(union2Score) do
  653. table.insert(scoreArray, { unionId = unionId, score = score })
  654. end
  655. table.sort(
  656. scoreArray,
  657. function(a, b)
  658. return a.score > b.score
  659. end
  660. )
  661. -- 计算排名
  662. local ranks = {}
  663. local rank = 1 -- 当前排名
  664. for i = 1, #scoreArray do
  665. local union = scoreArray[i]
  666. -- 每次循环都增加排名
  667. ranks[union.unionId] = rank
  668. rank = rank + 1
  669. end
  670. return ranks
  671. end
  672. -- 获取战盟积分排名列表
  673. -- @return 列表{{ unionId = unionId, score = score },....}
  674. function this.GetUnionRankList(mapId)
  675. local union2Score = {}
  676. local allPlayers = this.GetAllParticipatingPlayers(mapId)
  677. for key, actor0 in pairs(allPlayers) do
  678. local score = RoleScoreDTO.calTotalScoreByActor(actor0, mapId)
  679. local unionId = tostring(getbaseinfo(actor0, "guildid"))
  680. if union2Score[unionId] == nil then
  681. union2Score[unionId] = score
  682. else
  683. union2Score[unionId] = score + union2Score[unionId]
  684. end
  685. end
  686. local scoreArray = {}
  687. for unionId, score in pairs(union2Score) do
  688. table.insert(scoreArray, { unionId = unionId, score = score })
  689. end
  690. table.sort(
  691. scoreArray,
  692. function(a, b)
  693. return a.score > b.score
  694. end
  695. )
  696. return scoreArray
  697. end
  698. -- 是否是最后阶段
  699. function this.IsFinalPhase(mapId)
  700. local attackTaskInfo = this.GetAttackTask(mapId)
  701. local taskId = attackTaskInfo[1]
  702. local nextId = tonumber(ConfigDataManager.getTableValue("cfg_repTask", "nextID", "id", taskId))
  703. if nextId == nil or nextId == 0 then
  704. return true
  705. end
  706. return false
  707. end
  708. -- 结算
  709. function this.Settlement(mapId)
  710. local log = LogRecord.new()
  711. local winUninId
  712. if this.IsFinalPhase(mapId) then
  713. -- 守方战盟为胜利方
  714. local defendUnionId = this.GetDefendUnionId(mapId)
  715. if defendUnionId == nil or defendUnionId == 0 then
  716. -- 无守方
  717. -- 积分第一的为占领战盟,无盟主奖励
  718. local unionRankList = this.GetUnionRankList(mapId)
  719. local unionInfo = unionRankList[1]
  720. winUninId = unionInfo.unionId
  721. log.winType = "积分"
  722. else
  723. local unionInfo = getunioninfo(defendUnionId)
  724. local leaderId = unionInfo.leaderid
  725. local leaderActor = getactor(leaderId, mapId)
  726. local leaderRewardStr = ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.ROLAND_SEIGE.LEADER_REWARD)
  727. local leaderRewardStrSplit = string.toIntIntMap(leaderRewardStr, "#", "|")
  728. sendconfigmailbyrid(leaderActor, leaderActor:toString(), MailConfig.ROLAND_SEIGE_LEADER_REWARD, leaderRewardStrSplit)
  729. winUninId = defendUnionId
  730. log.winType = "占领"
  731. log.leader = leaderId
  732. end
  733. else
  734. winUninId = this.GetLastOccupyUnionId()
  735. end
  736. -- 设置占领战盟
  737. winUninId = winUninId or 0
  738. log.winUninId = winUninId
  739. this.SetLastOccupyUnionId(winUninId)
  740. -- 个人积分奖励
  741. local rank2Reward = {}
  742. local needScore = tonumber(ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.ROLAND_SEIGE.PERSONAL_LIMIT_SCORE))
  743. local personalRewardStr = ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.ROLAND_SEIGE.PERSONAL_REWARD)
  744. local personalRewardStrSplit = string.split(personalRewardStr, "|")
  745. for key, value in pairs(personalRewardStrSplit) do
  746. local valueSplit = string.split(value, "&")
  747. local rankList = string.split(valueSplit[1], "#")
  748. local startRank = tonumber(rankList[1])
  749. local endRank = tonumber(rankList[2])
  750. local totalReward = {}
  751. for j = 2, #valueSplit do
  752. local reward = string.split(valueSplit[j], "#")
  753. totalReward[tonumber(reward[1])] = tonumber(reward[2])
  754. end
  755. table.insert(rank2Reward, { startRank = startRank, endRank = endRank, rewards = totalReward })
  756. end
  757. -- 获取所有参与的玩家
  758. local allPlayers = this.GetAllParticipatingPlayers(mapId)
  759. for _, actor in pairs(allPlayers) do
  760. local selfUnionId = getbaseinfo(actor, "guildid")
  761. if tostring(selfUnionId) == tostring(winUninId) then
  762. -- 获胜
  763. local winRewardStr = ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.ROLAND_SEIGE.WIN_UNION_REWARD)
  764. local winRewardStrSplit = string.toIntIntMap(winRewardStr, "#", "|")
  765. sendconfigmailbyrid(actor, actor:toString(), MailConfig.ROLAND_SEIGE_WIN_UNION_REWARD, winRewardStrSplit)
  766. else
  767. --失败
  768. local failRewardStr = ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.ROLAND_SEIGE.FAIL_UNION_REWARD)
  769. local failRewardStrSplit = string.toIntIntMap(failRewardStr, "#", "|")
  770. sendconfigmailbyrid(actor, actor:toString(), MailConfig.ROLAND_SEIGE_FAIL_UNION_REWARD, failRewardStrSplit)
  771. end
  772. -- 个人积分奖励
  773. local ownScore = RoleScoreDTO.calTotalScoreByActor(actor, mapId)
  774. log.personalScoreList[actor:toString()] = ownScore
  775. local ranking = this.GetPlayerRankList(mapId)
  776. if ownScore >= needScore then
  777. local rank = ranking[actor:toString()]
  778. for _, rewardInfo in ipairs(rank2Reward) do
  779. if rank >= rewardInfo.startRank and rank <= rewardInfo.endRank then
  780. local rewards = rewardInfo.rewards
  781. sendconfigmailbyrid(actor, actor:toString(), MailConfig.ROLAND_SEIGE_PERSONAL_REWARD, rewards, rank)
  782. end
  783. end
  784. end
  785. end
  786. gameDebug.debug(LogRecord.log, log)
  787. end
  788. -- 获取玩家的阵营
  789. function this.GetCamp(actor, mapId)
  790. local defendUnionId = this.GetDefendUnionId(mapId)
  791. local selfUnionId = getbaseinfo(actor, "guildid")
  792. if tostring(defendUnionId) == tostring(selfUnionId) then
  793. return RolandConst.CAMP_TYPE.DEFEND
  794. else
  795. return RolandConst.CAMP_TYPE.ATTACK
  796. end
  797. end
  798. -- 是否可以开启
  799. function RolandSeige.CanOpenActivity()
  800. local openDays = getbaseinfo("serveropendays")
  801. local day, hour, minute = this.GetFirstOpenTime()
  802. if openDays < day then
  803. return false
  804. end
  805. return true
  806. end
  807. -- 获取首次开启时间
  808. function this.GetFirstOpenTime()
  809. local firstOpenTimeString = ConfigDataManager.getTableValue("cfg_repGlobal", "value", "id", RepGlobalConfig.ROLAND_SEIGE.FIRST_OPEN_TIME)
  810. local firstOpenTimeStringSplit = string.split(firstOpenTimeString, "#")
  811. local day = tonumber(firstOpenTimeStringSplit[1])
  812. local hour = tonumber(firstOpenTimeStringSplit[2])
  813. local minute = tonumber(firstOpenTimeStringSplit[3])
  814. return day, hour, minute
  815. end
  816. ---------------------------------------------------------- 响应 -----------------------------------------------------------------
  817. -- 响应单个玩家副本阶段
  818. function this.SendStateInfo(actor, repId, state, nextStateStartTime)
  819. sendluamsg(actor, LuaMessageIdToClient.RES_ROLAND_SEIGE_STATE, { repId, state, tostring(nextStateStartTime) })
  820. end
  821. -- 响应所有玩家副本阶段
  822. function this.SendAllStateInfo(mapId, repId, state, nextStateStartTime)
  823. local allPlayers = getmapplayer(mapId)
  824. if #allPlayers > 0 then
  825. for _, actor in pairs(allPlayers) do
  826. this.SendStateInfo(actor, repId, state, nextStateStartTime)
  827. end
  828. end
  829. end
  830. -- 响应单个玩家任务面板信息
  831. function this.SendTaskPanel(actor, mapId)
  832. local res = {}
  833. local selfCamp = this.GetCamp(actor, mapId)
  834. res.camp = selfCamp
  835. -- 任务信息
  836. local taskInfo
  837. if selfCamp == RolandConst.CAMP_TYPE.ATTACK then
  838. taskInfo = this.GetAttackTask(mapId)
  839. else
  840. taskInfo = this.GetDefendTask(mapId)
  841. end
  842. local taskId = taskInfo[1]
  843. local taskType = taskInfo[2]
  844. if taskType == DuplicateTaskType.KILL_TARGET_MONSTER then
  845. local targetMonCfg = taskInfo[5]
  846. local monsterList = mapbossinfo(mapId, -1, targetMonCfg)
  847. local minHP = 999999999
  848. local maxHP = 999999999
  849. for _, monInfo in pairs(monsterList) do
  850. local monHP = monInfo.hp
  851. if monHP < minHP then
  852. minHP = monHP
  853. end
  854. maxHP = monInfo.maxhp
  855. end
  856. res.nowCount = math.ceil((minHP / maxHP) * 100)
  857. res.totalCount = 100
  858. else
  859. res.nowCount = 0
  860. res.totalCount = 1
  861. end
  862. res.taskId = taskId
  863. -- 占领战盟
  864. local defendUnionId = this.GetDefendUnionId(mapId)
  865. if defendUnionId == nil or defendUnionId == 0 then
  866. res.unionName = "无"
  867. else
  868. --
  869. local progressDTO = UnionProgressDTO.get(mapId, defendUnionId)
  870. res.unionName = progressDTO.unionName
  871. end
  872. -- 所在战盟排名
  873. local unionId = getbaseinfo(actor, "guildid")
  874. res.unionRank = this.GetUnionRank(unionId, mapId)
  875. -- 个人排名
  876. res.selfRank = this.GetPlayerRank(actor, mapId)
  877. -- 个人积分
  878. res.selfScore = RoleScoreDTO.calTotalScoreByActor(actor, mapId)
  879. sendluamsg(actor, LuaMessageIdToClient.RES_ROLAND_SEIGE_TASK_PANEL, res)
  880. end
  881. -- 响应所有玩家任务面板信息
  882. function this.SendAllTaskPanel(mapId)
  883. local allPlayers = getmapplayer(mapId)
  884. if #allPlayers > 0 then
  885. for _, actor in pairs(allPlayers) do
  886. this.SendTaskPanel(actor, mapId)
  887. end
  888. end
  889. end
  890. -- 响应所有玩家战盟占领进度
  891. function this.SendAllUnionProgress(mapId, progressDTO)
  892. local allPlayers = getmapplayer(mapId)
  893. if #allPlayers > 0 then
  894. for _, actor in pairs(allPlayers) do
  895. sendluamsg(actor, LuaMessageIdToClient.RES_ROLAND_PROGRESS_INFO, progressDTO)
  896. end
  897. end
  898. end
  899. -- 响应玩家副本怪物信息
  900. function this.SendMonsterList(actor, mapId)
  901. local res = this.BuildResMonsterList(mapId)
  902. sendluamsg(actor, LuaMessageIdToClient.RES_ROLAND_MONSTER_LIST, res)
  903. end
  904. -- 响应所有玩家副本怪物信息
  905. function this.SendAllPlayMonsterList(mapId)
  906. local res = this.BuildResMonsterList(mapId)
  907. local allPlayers = getmapplayer(mapId)
  908. if #allPlayers > 0 then
  909. for _, actor in pairs(allPlayers) do
  910. sendluamsg(actor, LuaMessageIdToClient.RES_ROLAND_MONSTER_LIST, res)
  911. end
  912. end
  913. end
  914. function this.BuildResMonsterList(mapId)
  915. local res = {}
  916. local monList = getmapmon(mapId)
  917. for _, monActor in pairs(monList) do
  918. local oneRes = {}
  919. local monInfo = getmonsterinfo(monActor)
  920. oneRes.id = monInfo.id
  921. oneRes.cfg = monInfo.cfgid
  922. oneRes.x = monInfo.x
  923. oneRes.y = monInfo.y
  924. table.insert(res, oneRes)
  925. end
  926. return res
  927. end
  928. --------------------------------------------------------------------------------------------------------------------------
  929. ---------------------------------------------------------- 数据 -----------------------------------------------------------------
  930. -- 获取当前进行的攻城战副本id
  931. function this.GetCurrentDupId()
  932. local oldDupId = getsysvar(SystemVarConst.ROLAND_SEIGE.DUPLICATE_ID)
  933. return oldDupId
  934. end
  935. -- 设置当前进行的攻城战副本id
  936. function this.SetCurrentDupId(dupId)
  937. setsysvar(SystemVarConst.ROLAND_SEIGE.DUPLICATE_ID, dupId)
  938. end
  939. -- 获取上次占领战盟Id
  940. function this.GetLastOccupyUnionId()
  941. local unionId = getsysvar(SystemVarConst.ROLAND_SEIGE.LAST_OCCUPY_UNION_ID)
  942. return unionId
  943. end
  944. -- 设置上次占领战盟Id
  945. function this.SetLastOccupyUnionId(unionId)
  946. setsysvar(SystemVarConst.ROLAND_SEIGE.LAST_OCCUPY_UNION_ID, unionId)
  947. end
  948. -- 获取守方战盟id
  949. function this.GetDefendUnionId(mapId)
  950. local unionId = getenvirvar(mapId, DuplicateVarConst.ROLAND_SEIGE.DEFEND_UNION)
  951. return unionId
  952. end
  953. -- 设置守方战盟id
  954. function this.SetDefendUnionId(mapId, unionId)
  955. setenvirvar(mapId, DuplicateVarConst.ROLAND_SEIGE.DEFEND_UNION, unionId)
  956. end
  957. -- 获取守方任务
  958. function this.GetDefendTask(mapId)
  959. local defendTaskInfo = getenvirvar(mapId, DuplicateVarConst.ROLAND_SEIGE.DEFEND_TASK)
  960. return defendTaskInfo
  961. end
  962. -- 设置守方任务
  963. function this.SetDefendTask(mapId, taskId)
  964. local defendTaskInfo = DuplicateCommon.GenDupTaskInfoCommon(taskId)
  965. setenvirvar(mapId, DuplicateVarConst.ROLAND_SEIGE.DEFEND_TASK, defendTaskInfo)
  966. end
  967. -- 获取攻方任务
  968. function this.GetAttackTask(mapId)
  969. local attackTaskInfo = getenvirvar(mapId, DuplicateVarConst.ROLAND_SEIGE.ATTACK_TASK)
  970. return attackTaskInfo
  971. end
  972. -- 设置攻方任务
  973. function this.SetAttackTask(mapId, taskId)
  974. local attackTaskInfo = DuplicateCommon.GenDupTaskInfoCommon(taskId)
  975. setenvirvar(mapId, DuplicateVarConst.ROLAND_SEIGE.ATTACK_TASK, attackTaskInfo)
  976. end
  977. -- 获取所有参与的玩家{actor,...}
  978. function this.GetAllParticipatingPlayers(mapId)
  979. local allPlayers = getdupparticipants(mapId)
  980. return allPlayers
  981. end
  982. -- 获取所有参与的战盟
  983. function this.GetAllParticipatingUnions(mapId)
  984. local allUnion = {}
  985. local allPlayers = this.GetAllParticipatingPlayers(mapId)
  986. for _, actor in pairs(allPlayers) do
  987. local unionId = getbaseinfo(actor, "guildid")
  988. if not table.contains(allUnion, unionId) then
  989. table.insert(allUnion, unionId)
  990. end
  991. end
  992. return allUnion
  993. end
  994. --------------------------------------------------------------------------------------------------------------------------
  995. function testenterroland(actor)
  996. RolandSeige.ReqEnterDupLicate(actor)
  997. end
  998. function testcloseroland(actor)
  999. local mapId = getbaseinfo(actor, "unimapid")
  1000. setduplicatestate(mapId, SetDuplicateStateConst.TO_FINISH)
  1001. end
  1002. function testfightroland(actor)
  1003. local mapId = getbaseinfo(actor, "unimapid")
  1004. setduplicatestate(mapId, SetDuplicateStateConst.TO_FIGHT)
  1005. end
  1006. function testreqroland(actor)
  1007. RolandSeige.ReqMainPanel(actor)
  1008. end
  1009. function testclearroland(actor)
  1010. this.SetLastOccupyUnionId(0)
  1011. end