gameMapController.lua 86 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457
  1. local gameMapController = class("gameMapController")
  2. gameMapController.NAME = "gameMapController"
  3. local optionsUtils = requireProxy("optionsUtils")
  4. local cjson = require("cjson")
  5. local fireSet = {
  6. [4] = 27, -- 困魔咒
  7. [5] = 36, -- 正常火墙
  8. }
  9. -- 转换race, 这些是守卫
  10. local convertDefenderRace =
  11. {
  12. [11] = 1,
  13. [55] = 1,
  14. [110] = 1,
  15. [111] = 1,
  16. [112] = 1,
  17. }
  18. local function converActorData(msgHdr, jsonData)
  19. -- 为了服务器下发的数据包更小,同时为了客户端的逻辑改动更小,将受到的数据转化一下
  20. ---------------------------------------------------------------------------
  21. -- json数组 -> json对象
  22. jsonData.RaceServer = jsonData.rs
  23. if jsonData.info then
  24. jsonData.UserID = jsonData.info[1]
  25. jsonData.Name = jsonData.info[2]
  26. jsonData.sex = jsonData.info[3]
  27. jsonData.Hair = jsonData.info[4]
  28. jsonData.Job = jsonData.info[5]
  29. end
  30. if jsonData.sp then
  31. jsonData.WalkCurrSpeed = jsonData.sp[1]
  32. jsonData.RunCurrSpeed = jsonData.sp[2]
  33. jsonData.AttackCurrSpeed = jsonData.sp[3]
  34. jsonData.MagicCurrSpeed = jsonData.sp[4]
  35. end
  36. if jsonData.id then
  37. jsonData.clothID = jsonData.id[1]
  38. jsonData.weaponID = jsonData.id[2]
  39. jsonData.Cap = jsonData.id[3]
  40. jsonData.clothEff = jsonData.id[4]
  41. jsonData.weaponEff = jsonData.id[5]
  42. jsonData.shieldID = jsonData.id[6]
  43. jsonData.shieldEffect = jsonData.id[7]
  44. end
  45. if jsonData.wex then --左武器外观ID
  46. jsonData.leftWeaponID = jsonData.wex
  47. end
  48. if jsonData.wfex then --左武器外观特效
  49. jsonData.leftWeaponEff = jsonData.wfex
  50. end
  51. if jsonData.horse then
  52. jsonData.mountID = jsonData.horse[1]
  53. jsonData.mountEff = jsonData.horse[2]
  54. jsonData.mountCloth = jsonData.horse[3]
  55. jsonData.doubleTag = jsonData.horse[4]
  56. jsonData.doubleUserId = jsonData.horse[5]
  57. end
  58. if jsonData.cg then
  59. jsonData.ShenMiRen = bit.band(bit.rshift(jsonData.cg, 0), 1)
  60. jsonData.RangeCanFindMe = bit.band(bit.rshift(jsonData.cg, 1), 1)
  61. jsonData.OffLine = bit.band(bit.rshift(jsonData.cg, 2), 1)
  62. end
  63. if jsonData.state then
  64. jsonData.Group = jsonData.state[1]
  65. jsonData.stallname = jsonData.state[2]
  66. jsonData.castlename = jsonData.state[3]
  67. jsonData.Candle = tonumber(jsonData.state[4])
  68. end
  69. if jsonData.guild then
  70. jsonData.GuildID = jsonData.guild[1]
  71. jsonData.GuildName = jsonData.guild[2]
  72. jsonData.Rank = jsonData.guild[3]
  73. jsonData.RankName = jsonData.guild[4]
  74. end
  75. if jsonData.ms then
  76. jsonData.MasterId = jsonData.ms[1]
  77. end
  78. if jsonData.ow then
  79. jsonData.OwnerID = jsonData.ow[1]
  80. jsonData.OwnerName = jsonData.ow[2]
  81. end
  82. if jsonData.data then
  83. jsonData.nLevel = jsonData.data[1]
  84. jsonData.Hp = jsonData.data[2]
  85. jsonData.MaxHp = jsonData.data[3]
  86. jsonData.Color = jsonData.data[4]
  87. jsonData.StoneMode = jsonData.data[5]
  88. jsonData.pklv = jsonData.data[6]
  89. jsonData.Through = jsonData.data[7]
  90. jsonData.ActionType = jsonData.data[8]
  91. jsonData.Mp = jsonData.data[9]
  92. jsonData.MaxMp = jsonData.data[10]
  93. end
  94. if jsonData.NoShow and jsonData.NoShow ~= "" then
  95. local paramArray = string.split(jsonData.NoShow,"#")
  96. jsonData.noShowName = tonumber(paramArray[1])
  97. jsonData.noShowHPBar = tonumber(paramArray[2])
  98. end
  99. if jsonData.csd then
  100. jsonData.gmData = jsonData.csd
  101. end
  102. ---------------------------------------------------------------------------
  103. ---------------------------------------------------------------------------
  104. -- 消息头数据
  105. -- race & raceImg
  106. local recog = msgHdr.recog
  107. jsonData.race = L16Bit(recog)
  108. jsonData.raceImg = H16Bit(recog)
  109. -- nActorId
  110. local param1 = msgHdr.param1
  111. jsonData.nActorId = param1
  112. -- x y
  113. local param2 = msgHdr.param2
  114. jsonData.X = L16Bit(param2)
  115. jsonData.Y = H16Bit(param2)
  116. -- dir & type
  117. local param3 = msgHdr.param3
  118. jsonData.type = L16Bit(param3)
  119. jsonData.Dir = H16Bit(param3)
  120. ---------------------------------------------------------------------------
  121. ---------------------------------------------------------------------------
  122. -- 守卫,客户端通过RaceServer动态改变race
  123. if jsonData.RaceServer and convertDefenderRace[jsonData.RaceServer] then
  124. jsonData.race = global.MMO.ACTOR_RACE_DEFENDER
  125. end
  126. ---------------------------------------------------------------------------
  127. ---------------------------------------------------------------------------
  128. local cs = jsonData.cs or 0
  129. local caved = bit.band(bit.rshift(cs, 0), 1) == 1 -- 洞穴,被隐藏
  130. local skeleton = bit.band(bit.rshift(cs, 1), 1) == 1 -- 死亡,骨头
  131. local die = bit.band(bit.rshift(cs, 2), 1) == 1 -- 死亡,躺下
  132. jsonData.caved = caved
  133. jsonData.skeleton = skeleton
  134. jsonData.die = die
  135. ---------------------------------------------------------------------------
  136. return jsonData
  137. end
  138. function gameMapController:ctor()
  139. self.mNetActorMap = {}
  140. self.mBoundaryL = nil
  141. self.mBoundaryR = nil
  142. self.mBoundaryT = nil
  143. self.mBoundaryB = nil
  144. self.mViewCentOffset = cc.p( 0.0, 0.0 )
  145. self.mCamera = nil
  146. self.mViewSize = nil
  147. self.mFollowActorPos = cc.p( 0.0, 0.0 )
  148. self.mNetMsgHandle = {}
  149. self:Init()
  150. self:RegisterMsgHandler()
  151. end
  152. function gameMapController:destory()
  153. if gameMapController.instance then
  154. gameMapController.instance = nil
  155. end
  156. end
  157. function gameMapController:Inst()
  158. if not gameMapController.instance then
  159. gameMapController.instance = gameMapController.new()
  160. end
  161. return gameMapController.instance
  162. end
  163. -----------------------------------------------------------------------------
  164. function gameMapController:Init()
  165. self:initMapScrollFollow()
  166. end
  167. -----------------------------------------------------------------------------
  168. function gameMapController:initMapScrollFollow()
  169. local winSize = global.Director:getWinSize()
  170. self.mFullScreenSize = cc.p( winSize.width, winSize.height )
  171. self.mHalfScreenSize = cc.pMul( self.mFullScreenSize, 0.5 )
  172. local pcOffset = cc.p(-22, -80)
  173. if global.isWinPlayMode and SL:GetMetaValue("GAME_DATA", "PCMapCenterOffset") then
  174. local valueList = string.split(SL:GetMetaValue("GAME_DATA", "PCMapCenterOffset"), "|")
  175. if tonumber(valueList[1]) and tonumber(valueList[2]) then
  176. pcOffset = cc.p(tonumber(valueList[1]), tonumber(valueList[2]))
  177. end
  178. end
  179. local offset = global.isWinPlayMode and pcOffset or cc.p(0.0, 0.0)
  180. self:SetViewCenterOffset( offset.x, offset.y )
  181. end
  182. -----------------------------------------------------------------------------
  183. function gameMapController:SetViewCamera( camera )
  184. self.mCamera = camera
  185. if self.mCamera then
  186. self.mCamera:retain()
  187. end
  188. end
  189. -----------------------------------------------------------------------------
  190. function gameMapController:GetViewCamera()
  191. return self.mCamera
  192. end
  193. -----------------------------------------------------------------------------
  194. function gameMapController:SetViewSize( size )
  195. self.mViewSize = size
  196. end
  197. -----------------------------------------------------------------------------
  198. function gameMapController:GetViewSize()
  199. if self.mViewSize then
  200. return self.mViewSize
  201. end
  202. local size = global.Director:getWinSize()
  203. if self.mCamera then
  204. local scaleX, scaleY = CalcCameraZoom(self.mCamera)
  205. size.width = math.ceil(size.width * scaleX)
  206. size.height = math.ceil(size.height * scaleY)
  207. end
  208. self.mViewSize = size
  209. return self.mViewSize
  210. end
  211. -----------------------------------------------------------------------------
  212. function gameMapController:SetViewCenterOffset( x, y )
  213. self.mViewCentOffset.x = x
  214. self.mViewCentOffset.y = y
  215. global.sceneManager:SetViewCenterOffset( self.mViewCentOffset.x, self.mViewCentOffset.y )
  216. end
  217. function gameMapController:GetViewCenterOffset()
  218. return self.mViewCentOffset
  219. end
  220. -----------------------------------------------------------------------------
  221. function gameMapController:followMainPlayer()
  222. if not global.gamePlayerController:GetMainPlayer() then return end
  223. if not self.mBoundaryB then return end
  224. local mainPlayer = global.gamePlayerController:GetMainPlayer()
  225. local playerPos = mainPlayer:getPosition()
  226. if self.mFollowActorPos.x == playerPos.x and self.mFollowActorPos.y == playerPos.y then
  227. return
  228. end
  229. self.mFollowActorPos.x = playerPos.x
  230. self.mFollowActorPos.y = playerPos.y
  231. if self.mCamera then
  232. local tempPos = cc.pAdd( playerPos, self.mViewCentOffset )
  233. self.mCamera:setPosition( tempPos )
  234. end
  235. end
  236. -----------------------------------------------------------------------------
  237. function gameMapController:calcMapFollowParam( width, height )
  238. self.mBoundaryL = self.mHalfScreenSize.x
  239. self.mBoundaryR = math.max(width - self.mHalfScreenSize.x, 0)
  240. self.mBoundaryT = -self.mHalfScreenSize.y
  241. self.mBoundaryB = math.min(-(height - self.mHalfScreenSize.y), 0)
  242. end
  243. -----------------------------------------------------------------------------
  244. function gameMapController:Cleanup()
  245. self:CleanupActor(true)
  246. self.mNetActorMap = {}
  247. if self.mCamera then
  248. self.mCamera:autorelease()
  249. self.mCamera = nil
  250. end
  251. end
  252. -----------------------------------------------------------------------------
  253. function gameMapController:CleanupActor(cleanMainPlayer)
  254. global.npcManager:Cleanup()
  255. global.playerManager:Cleanup()
  256. global.monsterManager:Cleanup( false )
  257. global.dropItemManager:Cleanup()
  258. global.sceneEffectManager:Cleanup()
  259. global.netMonsterController:Cleanup( false )
  260. global.netPlayerController:Cleanup( false )
  261. -- clean up
  262. if global.gamePlayerController:GetMainPlayer() then
  263. local mainPlayer = global.gamePlayerController:GetMainPlayer()
  264. if not cleanMainPlayer then
  265. self.mNetActorMap[mainPlayer:GetID()] = nil
  266. end
  267. -- remove actors trace
  268. local noticeData = {
  269. actorID = nil,
  270. }
  271. local mapData = global.sceneManager:GetMapData2DPtr()
  272. for k,v in pairs(self.mNetActorMap) do
  273. noticeData.actor = v
  274. noticeData.actorID = v:GetID()
  275. global.Facade:sendNotification(global.NoticeTable.ActorOutOfView, noticeData )
  276. end
  277. self.mNetActorMap = {}
  278. -- release all actor
  279. global.actorManager:RemoveAllActor( (not cleanMainPlayer) and mainPlayer:GetID() or 0 )
  280. -- keep trace main player
  281. if not cleanMainPlayer then
  282. global.playerManager:SetMainPlayerID( mainPlayer:GetID() )
  283. global.playerManager:AddPlayer( mainPlayer )
  284. self.mNetActorMap[mainPlayer:GetID()] = mainPlayer
  285. else
  286. global.gamePlayerController:CleanupMainPlayer()
  287. global.playerManager:CleanupMainPlayer()
  288. end
  289. end
  290. end
  291. -----------------------------------------------------------------------------
  292. function gameMapController:handle_MSG_SC_MAP_ACTOR_CLEANUP( msg )
  293. self:CleanupActor( false )
  294. return 1
  295. end
  296. -----------------------------------------------------------------------------
  297. function gameMapController:handleMessage(msg)
  298. local msgHdr = msg:GetHeader()
  299. local msgLen = msg:GetDataLength()
  300. local msgData = (msgLen > 0 and msg:GetData():ReadString(msgLen) or "")
  301. if self.mNetMsgHandle[msgHdr.msgId] then
  302. self.mNetMsgHandle[msgHdr.msgId](msgHdr, msgData)
  303. end
  304. end
  305. -----------------------------------------------------------------------------
  306. function gameMapController:Tick( dt )
  307. self:followMainPlayer()
  308. end
  309. -----------------------------------------------------------------------------
  310. function gameMapController:handle_MSG_SC_CREATE_MAIN_PLAYER( msg )
  311. -- 创建主玩家
  312. local msgHdr = msg:GetHeader()
  313. local msgLen = msg:GetDataLength()
  314. local msgData = (msgLen > 0 and msg:GetData():ReadString(msgLen) or "")
  315. self:handle_InOfView(msgHdr, msgData)
  316. local AuthProxy = global.Facade:retrieveProxy(global.ProxyTable.AuthProxy)
  317. AuthProxy:RequestIsCloudLogin() --进入游戏上报云手机信息
  318. end
  319. -----------------------------------------------------------------------------
  320. function gameMapController:refreshActor( actor, msgHdr, jsonData, action, stopAnimFrame )
  321. -- set actor property
  322. SetActorProperty( actor, jsonData )
  323. actor:SetAction( action, true )
  324. actor:stopAnimToFrame( stopAnimFrame )
  325. actor:dirtyAnimFlag()
  326. -- refresh pos
  327. local actorPos = cc.p(0,0)
  328. local mapX = jsonData.X
  329. local mapY = jsonData.Y
  330. actorPos = global.sceneManager:MapPos2WorldPos( mapX, mapY, true )
  331. actor:setPosition( actorPos.x, actorPos.y )
  332. global.actorManager:SetActorMapXY( actor, mapX, mapY )
  333. -- 非主玩家,强刷坐标时清理动作队列
  334. if actor:IsMonster() then
  335. global.netMonsterController:cleanupCacheByActorID(actor:GetID())
  336. elseif actor:IsPlayer() and not actor:IsMainPlayer() then
  337. global.netPlayerController:cleanupCacheByActorID(actor:GetID())
  338. end
  339. end
  340. -----------------------------------------------------------------------------
  341. function gameMapController:handle_InOfView(msgHdr, msgData)
  342. if msgData == "" then
  343. return nil
  344. end
  345. local jsonData = cjson.decode(msgData)
  346. if not jsonData then
  347. return nil
  348. end
  349. converActorData(msgHdr, jsonData)
  350. local actorID = jsonData.UserID
  351. if not actorID then
  352. return nil
  353. end
  354. -- 初始action
  355. local action = global.MMO.ACTION_IDLE
  356. local stopAnimFrame = nil
  357. if jsonData.StoneMode == 1 then
  358. -- 1:祖玛雕像的石化状态
  359. action = global.MMO.ACTION_BORN
  360. stopAnimFrame = 1
  361. elseif jsonData.caved == true then
  362. -- 触龙神/食人花在地下隐藏状态
  363. action = global.MMO.ACTION_CAVE
  364. stopAnimFrame = 1
  365. elseif jsonData.skeleton == true then
  366. -- 死亡, 骨头
  367. action = global.MMO.ACTION_DEATH
  368. elseif jsonData.die == true then
  369. action = global.MMO.ACTION_DIE
  370. stopAnimFrame = -1
  371. end
  372. local actor = global.actorManager:GetActor( actorID )
  373. if actor then
  374. print("--------------- IN OF VIEW, ACTOR IS EXIST, 联系SFY", actorID, actor:GetName(), msgHdr.msgId)
  375. -- if msgHdr.msgId == global.MsgType.MSG_SC_CREATE_MAIN_PLAYER and actor:IsPlayer() then
  376. -- global.playerManager:SetMainPlayerID( actorID )
  377. -- global.gamePlayerController:BindMainActor( actor )
  378. -- global.actorManager:UpdateLockFrameT()
  379. -- end
  380. -- if actor:IsWall() and jsonData.Dir then
  381. -- stopAnimFrame = jsonData.Dir + 1
  382. -- end
  383. -- -- 城墙怪特殊,服务器先发死亡后发出生,导致状态不对,但是又要显示站立的模型,这儿要特殊处理
  384. -- if actor:IsWall() and (actor:IsDeath() or actor:IsDie()) then
  385. -- action = global.MMO.ACTION_DEATH
  386. -- end
  387. -- self:refreshActor( actor, msgHdr, jsonData, action, stopAnimFrame )
  388. -- SetActorName(actor, jsonData)
  389. -- global.Facade:sendNotification( global.NoticeTable.DelayRefreshHUDLabel, { actor = actor, actorID = actorID, hudParam = jsonData } )
  390. -- global.Facade:sendNotification( global.NoticeTable.DelayRefreshHUDTitle, { actor = actor, actorID = actorID, hudParam = jsonData } )
  391. -- if actor:IsWall() then
  392. -- -- 城墙怪,如果是死亡状态,模型使用站立
  393. -- if (actor:IsDeath() or actor:IsDie()) then
  394. -- actor:SetAnimAct(global.MMO.ANIM_IDLE)
  395. -- end
  396. -- actor:updateAnimation()
  397. -- actor:SetKeyValue(global.MMO.Is_Wall, true)
  398. -- end
  399. return actor
  400. end
  401. local race = jsonData.race
  402. local isPlayer = false
  403. local isNpc = false
  404. local isMonster = false
  405. -- 0:player;1:hero;150:humanoid
  406. if race == 0 or race == 1 or race == 150 then
  407. isPlayer = true
  408. elseif race == 50 then
  409. isNpc = true
  410. else
  411. isMonster = true
  412. end
  413. local initParam = {
  414. actorID = actorID,
  415. mapX = jsonData.X or 0,
  416. mapY = jsonData.Y or 0,
  417. action = action,
  418. dir = jsonData.Dir or 0,
  419. clothID = jsonData.clothID,
  420. }
  421. local actor = nil
  422. local race = jsonData.race
  423. -- 0:player;1:hero;150:humanoid
  424. if isPlayer then
  425. actor = global.netPlayerController:AddNetPlayerToWorld( initParam )
  426. elseif isNpc then
  427. actor = global.netNpcController:AddNetNpcToWorld( initParam )
  428. else
  429. actor = global.netMonsterController:AddNetMonsterToWorld( initParam )
  430. end
  431. if nil == actor then
  432. return nil
  433. end
  434. -- 主玩家,绑定创建
  435. if msgHdr.msgId == global.MsgType.MSG_SC_CREATE_MAIN_PLAYER and actor:IsPlayer() then
  436. global.playerManager:SetMainPlayerID( actorID )
  437. global.gamePlayerController:BindMainActor( actor )
  438. global.actorManager:UpdateLockFrameT()
  439. end
  440. ------------------------------------------------------------
  441. -- 是城墙
  442. if actor:IsWall() then
  443. if jsonData.Dir then
  444. stopAnimFrame = jsonData.Dir + 1
  445. end
  446. actor:SetKeyValue(global.MMO.Is_Wall, true)
  447. end
  448. -- restore actor data
  449. self:refreshActor( actor, msgHdr, jsonData, action, stopAnimFrame )
  450. -- 是沙巴克大门
  451. if actor:IsGate() then
  452. if jsonData.Dir then
  453. local isOpen = jsonData.Dir >= 3
  454. actor:setGateOpenState(isOpen)
  455. end
  456. actor:SetKeyValue(global.MMO.Is_Gate, true)
  457. end
  458. if actor:IsMonster() then
  459. -- Add to monster manager
  460. global.monsterManager:AddMonster( actor )
  461. elseif actor:IsPlayer() then
  462. -- Add to player manager
  463. global.playerManager:AddPlayer( actor )
  464. elseif actor:IsNPC() then
  465. -- Add to npc manager
  466. global.npcManager:AddNpc( actor )
  467. end
  468. -- Track Npc, NetPlayer, monster....
  469. self.mNetActorMap[actorID] = actor
  470. local noticeData = {
  471. actorID = actorID,
  472. actor = actor,
  473. hudParam = jsonData,
  474. }
  475. global.Facade:sendNotification(global.NoticeTable.ActorInOfView, noticeData)
  476. if jsonData.Effect then
  477. global.ActorEffectManager:ActorEffectRefresh({action = 1, items = jsonData.Effect})
  478. end
  479. self:refreshHorse(actor, jsonData)
  480. SLBridge:onLUAEvent(LUA_EVENT_ACTOR_IN_OF_VIEW, {id = actorID})
  481. return actor
  482. end
  483. function gameMapController:handle_DeathFallDown(msgHdr, msgData)
  484. if msgData == "" then
  485. return nil
  486. end
  487. local actorID = msgData
  488. local actor = global.actorManager:GetActor(actorID)
  489. if nil == actor then
  490. return nil
  491. end
  492. if actor:IsPlayer() then
  493. if actor:IsMainPlayer() then
  494. global.gamePlayerController:handle_Die(actor, msgHdr)
  495. global.Facade:sendNotification(global.NoticeTable.Audio_Play_BGM, {type = global.MMO.SND_TYPE_BGM_DIE})
  496. local PlayerPropertyProxy = global.Facade:retrieveProxy(global.ProxyTable.PlayerProperty)
  497. PlayerPropertyProxy:setAlive(false)
  498. else
  499. global.netPlayerController:handle_Die(actor, msgHdr)
  500. SLBridge:onLUAEvent(LUA_EVENT_NET_PLAYER_DIE, {id = actorID})
  501. end
  502. global.Facade:sendNotification(global.NoticeTable.ActorPlayerDie, {actorID = actorID, actor = actor})
  503. global.Facade:sendNotification(global.NoticeTable.Audio_Play, {type = global.MMO.SND_TYPE_PLAYER_DIE, index=actor:GetSexID()})
  504. elseif actor:IsMonster() then
  505. global.netMonsterController:handle_Die(actor, msgHdr)
  506. global.Facade:sendNotification(global.NoticeTable.ActorMonsterDie, {actorID = actorID, actor = actor})
  507. local clothID = actor:GetAnimationID()
  508. global.Facade:sendNotification(global.NoticeTable.Audio_Play, {type = global.MMO.SND_TYPE_MON_DIE, index = clothID})
  509. SLBridge:onLUAEvent(LUA_EVENT_MONSTER_DIE, {id = actorID})
  510. end
  511. global.Facade:sendNotification(global.NoticeTable.ActorDie, {actorID = actorID, actor = actor})
  512. end
  513. function gameMapController:handle_DeathSkeleton(msgHdr, msgData)
  514. if msgData == "" then
  515. return nil
  516. end
  517. local actorID = msgData
  518. local actor = global.actorManager:GetActor(actorID)
  519. if nil == actor then
  520. return nil
  521. end
  522. -- monster only.
  523. if actor:IsMonster() then
  524. global.netMonsterController:handle_DeathSkeleton(actor, msgHdr)
  525. global.Facade:sendNotification(global.NoticeTable.ActorMonsterDeath, {actorID = actorID, actor = actor})
  526. end
  527. end
  528. function gameMapController:handle_Revive(msgHdr, msgData)
  529. if msgData == "" then
  530. return nil
  531. end
  532. local jsonData = cjson.decode(msgData)
  533. if not jsonData then
  534. return nil
  535. end
  536. local actor = global.actorManager:GetActor( jsonData.UserID )
  537. if nil == actor then
  538. return nil
  539. end
  540. if actor:IsPlayer() then
  541. if actor:IsMainPlayer() then
  542. global.gamePlayerController:handle_Revive(actor, jsonData)
  543. else
  544. global.netPlayerController:handle_Revive(actor, jsonData)
  545. SLBridge:onLUAEvent(LUA_EVENT_NET_PLAYER_REVIVE, {id = actor:GetID()})
  546. end
  547. elseif actor:IsMonster() then
  548. global.netMonsterController:handle_Revive(actor, jsonData)
  549. SLBridge:onLUAEvent(LUA_EVENT_MONSTER_REVIVE, {id = actor:GetID()})
  550. end
  551. end
  552. function gameMapController:handle_OutOfView(msgHdr, msgData)
  553. if msgData == "" then
  554. return nil
  555. end
  556. local jsonData = cjson.decode(msgData)
  557. if not jsonData then
  558. return nil
  559. end
  560. local actorID = jsonData.UserID
  561. local actor = global.actorManager:GetActor( actorID )
  562. if nil == actor then
  563. return nil
  564. end
  565. if nil == self.mNetActorMap[actorID] then
  566. return nil
  567. end
  568. self.mNetActorMap[actorID] = nil
  569. -- Remove from monster manager
  570. if actor:IsMonster() then
  571. global.monsterManager:RmvMonster( actorID )
  572. global.netMonsterController:handleActorOutOfView( actor )
  573. elseif actor:IsPlayer() then
  574. if actor:IsMainPlayer() then
  575. -- effect
  576. local mainPlayer = global.gamePlayerController:GetMainPlayer()
  577. if mainPlayer and msgHdr.recog ~= 1 then
  578. global.Facade:sendNotification(global.NoticeTable.ActorFlyOut, mainPlayer, 0)
  579. end
  580. return 1
  581. end
  582. -- 恢复攻击状态和护身
  583. actor:SetDamage()
  584. actor:SetHuShen()
  585. global.playerManager:RmvPlayer( actorID )
  586. global.netPlayerController:handleActorOutOfView( actor )
  587. elseif actor:IsNPC() then
  588. global.npcManager:RmvNpc( actorID )
  589. end
  590. local noticeData = {
  591. actor = actor,
  592. actorID = actorID,
  593. msgID = msgHdr.msgId,
  594. recog = msgHdr.recog
  595. }
  596. global.Facade:sendNotification(global.NoticeTable.ActorOutOfView, noticeData)
  597. SLBridge:onLUAEvent(LUA_EVENT_ACTOR_OUT_OF_VIEW, {id = actorID})
  598. return global.actorManager:RemoveActor( actorID )
  599. end
  600. function gameMapController:handle_FlyIn(msgHdr, msgData)
  601. local mapX = msgHdr.param1
  602. local mapY = msgHdr.param2
  603. local dir = msgHdr.param3
  604. local effectType = msgHdr.recog
  605. local noShow = effectType == 1
  606. -- dump(msgHdr, "___handle_FlyIn")
  607. -- dump(msgData)
  608. -- audio
  609. global.Facade:sendNotification( global.NoticeTable.Audio_Play, {type = global.MMO.SND_TYPE_FLY_IN} )
  610. -- effect
  611. if not noShow then
  612. local effectId = effectType > 1 and effectType
  613. global.Facade:sendNotification( global.NoticeTable.ActorFlyIn, {x = mapX, y = mapY}, effectId or 0)
  614. end
  615. -- 如果有actor,强行刷坐标
  616. if msgData == "" then
  617. return nil
  618. end
  619. local jsonData = cjson.decode(msgData)
  620. if not jsonData then
  621. return nil
  622. end
  623. local actor = global.actorManager:GetActor(jsonData.UserID)
  624. if not actor then
  625. return nil
  626. end
  627. -- 主玩家不需要强拉坐标,切地图时已经带了坐标
  628. if actor:IsPlayer() and actor:IsMainPlayer() then
  629. return nil
  630. end
  631. if actor:IsMonster() then
  632. global.netMonsterController:handle_FlyIn(actor, msgHdr )
  633. elseif actor:IsPlayer() then
  634. global.netPlayerController:handle_FlyIn(actor, msgHdr )
  635. end
  636. global.Facade:sendNotification(global.NoticeTable.ActorMoveForce, {actorID = jsonData.UserID, actor = actor})
  637. end
  638. function gameMapController:handle_FlyIn2(msgHdr, msgData)
  639. local mapX = msgHdr.param1
  640. local mapY = msgHdr.param2
  641. local dir = msgHdr.param3
  642. local effectType = msgHdr.recog
  643. local noShow = effectType == 1
  644. -- audio
  645. global.Facade:sendNotification( global.NoticeTable.Audio_Play, {type = global.MMO.SND_TYPE_FLY_IN} )
  646. -- effect
  647. if not noShow then
  648. local effectId = effectType > 1 and effectType
  649. global.Facade:sendNotification( global.NoticeTable.ActorFlyIn, {x = mapX, y = mapY}, effectId or 1)
  650. end
  651. -- 如果有actor,强行刷坐标
  652. if msgData == "" then
  653. return nil
  654. end
  655. local jsonData = cjson.decode(msgData)
  656. if not jsonData then
  657. return nil
  658. end
  659. local actor = global.actorManager:GetActor(jsonData.UserID)
  660. if not actor then
  661. return nil
  662. end
  663. -- 主玩家不需要强拉坐标,切地图时已经带了坐标
  664. if actor:IsPlayer() and actor:IsMainPlayer() then
  665. return nil
  666. end
  667. if actor:IsMonster() then
  668. global.netMonsterController:handle_FlyIn2(actor, msgHdr )
  669. elseif actor:IsPlayer() then
  670. global.netPlayerController:handle_FlyIn2(actor, msgHdr )
  671. end
  672. global.Facade:sendNotification(global.NoticeTable.ActorMoveForce, {actorID = jsonData.UserID, actor = actor})
  673. end
  674. function gameMapController:handle_FlyOut(msgHdr, msgData)
  675. local effectType = msgHdr.recog
  676. local noShow = effectType == 1
  677. if msgData == "" then
  678. return nil
  679. end
  680. local jsonData = cjson.decode(msgData)
  681. if not jsonData then
  682. return nil
  683. end
  684. local actor = global.actorManager:GetActor(jsonData.UserID)
  685. if not actor then
  686. return nil
  687. end
  688. -- audio
  689. global.Facade:sendNotification(global.NoticeTable.Audio_Play, {type = global.MMO.SND_TYPE_FLY_OUT})
  690. -- effect
  691. if not noShow then
  692. local effectId = effectType > 1 and effectType
  693. global.Facade:sendNotification(global.NoticeTable.ActorFlyOut, actor, effectId or 0)
  694. end
  695. end
  696. function gameMapController:handle_FlyOut2(msgHdr, msgData)
  697. local effectType = msgHdr.recog
  698. local noShow = effectType == 1
  699. if msgData == "" then
  700. return nil
  701. end
  702. local jsonData = cjson.decode(msgData)
  703. if not jsonData then
  704. return nil
  705. end
  706. local actor = global.actorManager:GetActor(jsonData.UserID)
  707. if not actor then
  708. return nil
  709. end
  710. -- audio
  711. global.Facade:sendNotification(global.NoticeTable.Audio_Play, {type = global.MMO.SND_TYPE_FLY_OUT})
  712. -- effect
  713. if not noShow then
  714. local effectId = effectType > 1 and effectType
  715. global.Facade:sendNotification(global.NoticeTable.ActorFlyOut, actor, effectId or 1)
  716. end
  717. end
  718. function gameMapController:handle_FeatureChanged(header, msgData)
  719. if msgData == "" then
  720. return nil
  721. end
  722. local actor = global.actorManager:GetActor( msgData )
  723. if nil == actor then
  724. print( "illegal actorID in handle_MSG_SC_ACTOR_FEATURE_CHANGED", msgData )
  725. return nil
  726. end
  727. local ftype = header.recog
  728. local value = header.param1
  729. local value1 = header.param2
  730. if ftype == global.MMO.ACTOR_FTCHANGE_CLOTH then
  731. if actor:IsMonster() then
  732. actor:SetClothID(value)
  733. global.Facade:sendNotification(global.NoticeTable.DelayDirtyFeature, {actorID = actor:GetID(), actor = actor})
  734. return
  735. end
  736. -- 衣服
  737. local actorAttr = GetActorAttrByID(actor:GetID(), global.MMO.ACTOR_ATTR_FEATURE) or {}
  738. actorAttr.clothID = value
  739. SetActorAttrByID(actor:GetID(), global.MMO.ACTOR_ATTR_FEATURE, actorAttr)
  740. global.Facade:sendNotification( global.NoticeTable.DelayActorFeatureChange, actorAttr )
  741. elseif ftype == global.MMO.ACTOR_FTCHANGE_CLOTH_EFF then
  742. -- 衣服特效/翅膀 ???
  743. local actorAttr = GetActorAttrByID(actor:GetID(), global.MMO.ACTOR_ATTR_FEATURE) or {}
  744. actorAttr.clothEff = value
  745. SetActorAttrByID(actor:GetID(), global.MMO.ACTOR_ATTR_FEATURE, actorAttr)
  746. global.Facade:sendNotification( global.NoticeTable.DelayActorFeatureChange, actorAttr )
  747. elseif ftype == global.MMO.ACTOR_FTCHANGE_WEAPON then
  748. -- 武器
  749. local actorAttr = GetActorAttrByID(actor:GetID(), global.MMO.ACTOR_ATTR_FEATURE) or {}
  750. actorAttr.weaponID = value
  751. if value1 then --左手武器
  752. actorAttr.leftWeaponID = value1
  753. end
  754. SetActorAttrByID(actor:GetID(), global.MMO.ACTOR_ATTR_FEATURE, actorAttr)
  755. global.Facade:sendNotification( global.NoticeTable.DelayActorFeatureChange, actorAttr )
  756. elseif ftype == global.MMO.ACTOR_FTCHANGE_WEAPON_EFF then
  757. -- 武器特效
  758. local actorAttr = GetActorAttrByID(actor:GetID(), global.MMO.ACTOR_ATTR_FEATURE) or {}
  759. actorAttr.weaponEff = value
  760. if value1 then --左手武器
  761. actorAttr.leftWeaponEff = value1
  762. end
  763. SetActorAttrByID(actor:GetID(), global.MMO.ACTOR_ATTR_FEATURE, actorAttr)
  764. global.Facade:sendNotification( global.NoticeTable.DelayActorFeatureChange, actorAttr )
  765. elseif ftype == global.MMO.ACTOR_FTCHANGE_HAIR then
  766. -- 发型
  767. local actorAttr = GetActorAttrByID(actor:GetID(), global.MMO.ACTOR_ATTR_FEATURE) or {}
  768. actorAttr.Hair = value
  769. SetActorAttrByID(actor:GetID(), global.MMO.ACTOR_ATTR_FEATURE, actorAttr)
  770. global.Facade:sendNotification( global.NoticeTable.DelayActorFeatureChange, actorAttr )
  771. elseif ftype == global.MMO.ACTOR_FTCHANGE_CAP then
  772. -- 斗笠
  773. local actorAttr = GetActorAttrByID(actor:GetID(), global.MMO.ACTOR_ATTR_FEATURE) or {}
  774. actorAttr.Cap = value
  775. SetActorAttrByID(actor:GetID(), global.MMO.ACTOR_ATTR_FEATURE, actorAttr)
  776. global.Facade:sendNotification( global.NoticeTable.DelayActorFeatureChange, actorAttr )
  777. elseif ftype == global.MMO.ACTOR_FTCHANGE_TEAMSTATE then
  778. -- 组队状态
  779. local lastGroup = actor:GetTeamState()
  780. actor:SetTeamState(value)
  781. if actor:IsPlayer() and actor:IsMainPlayer() and actor:GetTeamState() == 0 then
  782. local TeamProxy = global.Facade:retrieveProxy(global.ProxyTable.TeamProxy)
  783. TeamProxy:ClearTeamMember()
  784. SLBridge:onLUAEvent(LUA_EVENT_TEAM_MEMBER_UPDATE)
  785. SLBridge:onLUAEvent(LUA_EVENT_LEAVETEAM, actor:GetName())
  786. end
  787. --
  788. if actor:IsPlayer() then
  789. if lastGroup ~= value then
  790. if global.gamePlayerController:GetMainPlayerID() == actor:GetID() then
  791. SL:onLUAEvent(LUA_EVENT_PLAYER_TEAM_STATUS_CHANGE)
  792. else
  793. SL:onLUAEvent(LUA_EVENT_NET_PLAYER_TEAM_STATUS_CHANGE, {id = actor:GetID()})
  794. end
  795. end
  796. end
  797. elseif ftype == global.MMO.ACTOR_FTCHANGE_SEX then
  798. -- sex
  799. actor:SetSexID(value)
  800. actor:dirtyHair()
  801. actor:dirtyCloth()
  802. local actorAttr = GetActorAttrByID(actor:GetID(), global.MMO.ACTOR_ATTR_FEATURE) or {}
  803. global.Facade:sendNotification( global.NoticeTable.DelayActorFeatureChange, actorAttr )
  804. elseif ftype == global.MMO.ACTOR_FTCHANGE_SHIELD then
  805. --盾牌 盾牌特效
  806. local actorAttr = GetActorAttrByID(actor:GetID(), global.MMO.ACTOR_ATTR_FEATURE) or {}
  807. actorAttr.shieldID = value
  808. actorAttr.shieldEffect = value1
  809. SetActorAttrByID(actor:GetID(), global.MMO.ACTOR_ATTR_FEATURE, actorAttr)
  810. global.Facade:sendNotification( global.NoticeTable.DelayActorFeatureChange, actorAttr )
  811. end
  812. return 1
  813. end
  814. function gameMapController:handle_Walk(msgHdr, msgData)
  815. if msgData == "" then
  816. return nil
  817. end
  818. local jsonData = cjson.decode(msgData)
  819. if not jsonData then
  820. return nil
  821. end
  822. local actorID = jsonData.UserID
  823. local actor = global.actorManager:GetActor( actorID )
  824. if nil == actor then
  825. return nil
  826. end
  827. if actor:IsMonster() then
  828. local mainPlayerID = global.gamePlayerController:GetMainPlayerID()
  829. if actor:GetMasterID() == mainPlayerID then --宝宝触发
  830. ssr.ssrBridge:OnPetActionBegin(actorID, 1, actor:GetMapX(), actor:GetMapY(), actor:GetName())
  831. end
  832. return global.netMonsterController:handle_MSG_SC_ACTOR_WALK(actor, msgHdr )
  833. elseif actor:IsPlayer() then
  834. return global.netPlayerController:handle_MSG_SC_ACTOR_WALK(actor, msgHdr )
  835. end
  836. end
  837. function gameMapController:handle_Run(msgHdr, msgData, isRunOne)
  838. if msgData == "" then
  839. return nil
  840. end
  841. local jsonData = cjson.decode(msgData)
  842. if not jsonData then
  843. return nil
  844. end
  845. local actorID = jsonData.UserID
  846. local actor = global.actorManager:GetActor( actorID )
  847. if nil == actor then
  848. return nil
  849. end
  850. actor:SetKeyValue(global.MMO.IS_RUN_ONE, isRunOne)
  851. if actor:IsMonster() then
  852. local mainPlayerID = global.gamePlayerController:GetMainPlayerID()
  853. if actor:GetMasterID() == mainPlayerID then --宝宝触发
  854. ssr.ssrBridge:OnPetActionBegin(actorID, 2, actor:GetMapX(), actor:GetMapY(), actor:GetName())
  855. end
  856. return global.netMonsterController:handle_MSG_SC_ACTOR_RUN(actor, msgHdr )
  857. elseif actor:IsPlayer() then
  858. return global.netPlayerController:handle_MSG_SC_ACTOR_RUN(actor, msgHdr )
  859. end
  860. end
  861. function gameMapController:handle_RideRun(msgHdr, msgData)
  862. if msgData == "" then
  863. return nil
  864. end
  865. local jsonData = cjson.decode(msgData)
  866. if not jsonData then
  867. return nil
  868. end
  869. local actorID = jsonData.UserID
  870. local actor = global.actorManager:GetActor( actorID )
  871. if nil == actor then
  872. return nil
  873. end
  874. if actor:IsPlayer() then
  875. return global.netPlayerController:handle_MSG_SC_ACTOR_RIDE_RUN(actor, msgHdr )
  876. end
  877. end
  878. function gameMapController:handle_Turn(msgHdr, msgData)
  879. if msgData == "" then
  880. return nil
  881. end
  882. local actorID = msgData
  883. local actor = global.actorManager:GetActor( actorID )
  884. if nil == actor then
  885. return nil
  886. end
  887. local dir = msgHdr.recog
  888. local mapX = msgHdr.param1
  889. local mapY = msgHdr.param2
  890. if actor:GetMapX() ~= mapX or actor:GetMapY() ~= mapY then
  891. local pos = global.sceneManager:MapPos2WorldPos( mapX, mapY, true )
  892. if actor.GetRaceServer and actor:GetRaceServer() ~= global.MMO.ACTOR_SERVER_RACE_KNIEF then
  893. actor:setPosition( pos.x, pos.y )
  894. actor:SetDirection( dir )
  895. else
  896. SetActorAttrByID(actorID, global.MMO.ACTOR_ATTR_DIR, dir)
  897. end
  898. else
  899. actor:SetDirection(dir)
  900. end
  901. global.actorManager:SetActorMapXY( actor, mapX, mapY )
  902. actor:dirtyAnimFlag()
  903. global.BuffManager:UpdateBuffSfxDir(actorID)
  904. global.ActorEffectManager:UpdateEffectDir(actor, actorID)
  905. end
  906. function gameMapController:handle_PickCorpse( msgHdr, msgData )
  907. if msgData == "" then
  908. return nil
  909. end
  910. local jsonData = cjson.decode(msgData)
  911. if not jsonData then
  912. return nil
  913. end
  914. local actorID = jsonData.UserID
  915. local actor = global.actorManager:GetActor( actorID )
  916. if nil == actor then
  917. return nil
  918. end
  919. local ret = -3
  920. if actor:IsPlayer() then
  921. if not actor:IsMainPlayer() then
  922. if msgHdr.param1 == 1 then
  923. --挖矿
  924. ret = global.netPlayerController:handleActorMining( actor, jsonData )
  925. else
  926. --挖尸体
  927. ret = global.netPlayerController:handleActorSitdown( actor, jsonData )
  928. end
  929. end
  930. if msgHdr.param2 >= 1 then
  931. if actor:IsMainPlayer() then
  932. --挖矿 起灰特效
  933. local present =
  934. {
  935. skillID = 999,
  936. launchX = actor:GetMapX(),
  937. launchY = actor:GetMapY(),
  938. hitX = actor:GetMapX(),
  939. hitY = actor:GetMapY(),
  940. dir = actor:GetDirection(),
  941. skillStage = 3,
  942. launcherID = actor:GetID()
  943. }
  944. global.Facade:sendNotification(global.NoticeTable.RequestSkillPresent, present)
  945. -- 挖矿 起灰音效
  946. global.Facade:sendNotification(global.NoticeTable.Audio_Play, {type=global.MMO.SND_TYPE_MINING_DROP})
  947. end
  948. --挖矿 广播土堆
  949. local item =
  950. {
  951. id = msgHdr.param3,
  952. type = global.MMO.EFFECT_TYPE_MINING_HIT,
  953. x = actor:GetMapX(),
  954. y = actor:GetMapY(),
  955. param = msgHdr.param2,
  956. }
  957. self:addSpecialEffect( item )
  958. end
  959. end
  960. end
  961. function gameMapController:handle_RefreshHP( msgHdr, msgData )
  962. if msgData == "" then
  963. return false
  964. end
  965. local newArray = string.split( msgData,"|" )
  966. local dataStrArray = string.split(newArray[1] or "","&")
  967. local actorID = dataStrArray[1]
  968. local HP = tonumber(dataStrArray[2]) or 0
  969. local maxHP = tonumber(dataStrArray[3]) or 0
  970. local MP = tonumber(dataStrArray[4]) or 0
  971. local maxMP = tonumber(dataStrArray[5]) or 0
  972. local actor = global.actorManager:GetActor( actorID )
  973. if not actor then
  974. --自己的英雄不在视野内也要刷新血量
  975. local HeroPropertyProxy = global.Facade:retrieveProxy(global.ProxyTable.HeroPropertyProxy)
  976. local HeroID = HeroPropertyProxy:GetRoleUID()
  977. if HeroID and HeroID == actorID then
  978. HeroPropertyProxy:SetRoleMana(HP, maxHP, MP, maxMP)
  979. end
  980. return false
  981. end
  982. local power = newArray[2]
  983. -- 1 受击
  984. local unAattack = L16Bit(msgHdr.recog) == 1
  985. -- 飘字类型
  986. local throwType = msgHdr.param2
  987. -- 飘字的值
  988. local throwPower = tonumber(power) or msgHdr.param3
  989. local nData = {
  990. actorID = actorID,
  991. HP = HP,
  992. maxHP = maxHP,
  993. MP = MP,
  994. maxMP = maxMP,
  995. isDamage = false,
  996. unAattack = unAattack,
  997. level = msgHdr.param1, -- 等级
  998. }
  999. if unAattack then
  1000. nData.huShen = H16Bit(msgHdr.recog)
  1001. end
  1002. local oldHP = actor:GetHP() or 0
  1003. local oldMP = actor:GetMP() or 0
  1004. global.Facade:sendNotification(global.NoticeTable.RefreshActorHP, nData)
  1005. JudgeIsRefreshTargetHP(nData)
  1006. -- 飘字
  1007. if throwType > 0 then
  1008. if throwType == 110 then
  1009. local changeHp = HP - oldHP
  1010. local hpTypeID = changeHp > 0 and 4 or (changeHp < 0 and 1 or 0)
  1011. if hpTypeID > 0 then
  1012. global.Facade:sendNotification(global.NoticeTable.ShowThrowDamage, {Id = hpTypeID, UserID = actorID, Power = math.abs(changeHp)})
  1013. end
  1014. local changeMp = MP - oldMP
  1015. local mpTypeID = changeMp > 0 and 12 or (changeMp < 0 and 11 or 0)
  1016. if mpTypeID > 0 then
  1017. global.Facade:sendNotification(global.NoticeTable.ShowThrowDamage, {Id = mpTypeID, UserID = actorID, Power = math.abs(changeMp)})
  1018. end
  1019. else
  1020. global.Facade:sendNotification(global.NoticeTable.ShowThrowDamage, {Id = throwType, UserID = actorID, Power = throwPower})
  1021. end
  1022. end
  1023. end
  1024. function gameMapController:handle_Damage(msgHdr, msgData)
  1025. if msgData == "" then
  1026. return false
  1027. end
  1028. local jsonData = cjson.decode(msgData)
  1029. if not jsonData then
  1030. return false
  1031. end
  1032. local actorID = jsonData.UserID
  1033. local actor = global.actorManager:GetActor(actorID)
  1034. if not actor then
  1035. return false
  1036. end
  1037. local HP = jsonData.Hp or 0
  1038. local maxHP = jsonData.MaxHp or 0
  1039. local MP = jsonData.Mp or 0
  1040. local maxMP = jsonData.MaxMp or 0
  1041. local nData = {
  1042. actorID = actorID,
  1043. HP = HP,
  1044. maxHP = maxHP,
  1045. MP = MP,
  1046. maxMP = maxMP,
  1047. isDamage = true,
  1048. unAattack = true,
  1049. huShen = H16Bit(msgHdr.recog)
  1050. }
  1051. -- 飘字类型
  1052. local throwType = L16Bit(msgHdr.recog)
  1053. -- 飘字的值
  1054. local throwPower = tonumber(jsonData.Damage) or msgHdr.param1
  1055. -- 后仰
  1056. local struck = 1 -- 默认后仰
  1057. local struchRules = jsonData.Struck or 0
  1058. local isMain = (actor:IsPlayer() and actor:IsMainPlayer()) or false
  1059. -- 以前是后端判断, 改成前端自行判断
  1060. if (isMain and CheckBit(struchRules, 0)) or ((actor:IsPlayer() or actor:IsHero()) and CheckBit(struchRules, 1)) or (actor:IsMonster() and CheckBit(struchRules, 2)) then
  1061. struck = 0
  1062. end
  1063. if struck == 1 then -- 后仰状态
  1064. self:handle_Stuck(msgHdr, msgData)
  1065. end
  1066. -- 音效 ????
  1067. global.Facade:sendNotification(global.NoticeTable.Audio_Play, {type = global.MMO.SND_TYPE_SCREAM, index = jsonData.Weapon, param = actorID})
  1068. if jsonData.Magic ~= 1 then
  1069. global.Facade:sendNotification(global.NoticeTable.Audio_Play, {type = global.MMO.SND_TYPE_STUCK, index = jsonData.Weapon, param = actorID})
  1070. end
  1071. global.Facade:sendNotification(global.NoticeTable.RefreshActorHP, nData)
  1072. JudgeIsRefreshTargetHP(nData)
  1073. -- 飘字
  1074. if throwType > 0 then
  1075. global.Facade:sendNotification(global.NoticeTable.ShowThrowDamage, {Id = throwType, UserID = actorID, Power = throwPower, TargetID = jsonData.AttackUserID})
  1076. end
  1077. -- 刷新内力值
  1078. local data = {
  1079. curInternalForce = jsonData.InternalForce,
  1080. maxInternalForce = jsonData.MaxInternalForce
  1081. }
  1082. if next(data) then
  1083. data.actorID = actorID
  1084. global.Facade:sendNotification(global.NoticeTable.RefreshActorIForce, data)
  1085. end
  1086. global.Facade:sendNotification(global.NoticeTable.AutoFightBack, {attackActorID = jsonData.AttackUserID, actorID = actorID})
  1087. end
  1088. -- 护身状态掉蓝由服务端直接通知反击
  1089. function gameMapController:handle_MSG_SC_FIGHT_BACK_ID(msg)
  1090. local header = msg:GetHeader()
  1091. local msgLen = msg:GetDataLength()
  1092. if msgLen <= 0 then
  1093. return
  1094. end
  1095. local attackActorID = msg:GetData():ReadString(msgLen)
  1096. local actor = global.actorManager:GetActor(attackActorID)
  1097. if not actor then
  1098. return
  1099. end
  1100. if not actor:IsPlayer() then
  1101. return
  1102. end
  1103. global.Facade:sendNotification(global.NoticeTable.AutoFightBack, {attackActorID = attackActorID})
  1104. end
  1105. function gameMapController:handle_Stuck( msgHdr, msgData )
  1106. if msgData == "" then
  1107. return nil
  1108. end
  1109. local jsonData = cjson.decode(msgData)
  1110. if not jsonData then
  1111. return nil
  1112. end
  1113. local actorID = jsonData.UserID
  1114. local actor = global.actorManager:GetActor( actorID )
  1115. if nil == actor or actor:IsDie() then
  1116. return nil
  1117. end
  1118. if actor:IsMonster() then
  1119. return global.netMonsterController:handle_MSG_SC_ACTOR_STUCK( actor )
  1120. elseif actor:IsPlayer() then
  1121. if actor:IsMainPlayer() then
  1122. return global.gamePlayerController:handle_MSG_SC_ACTOR_STUCK( actor )
  1123. else
  1124. return global.netPlayerController:handle_MSG_SC_ACTOR_STUCK( actor )
  1125. end
  1126. end
  1127. end
  1128. function gameMapController:handle_RefreshSpeed( msgHdr, msgData )
  1129. if msgData == "" then
  1130. return nil
  1131. end
  1132. -- recog 走
  1133. -- param1 跑
  1134. -- param2 攻击
  1135. -- param3 施法
  1136. -- Str UserID
  1137. local header = msgHdr
  1138. local actorID = msgData
  1139. local actor = global.actorManager:GetActor(actorID)
  1140. if not actor then
  1141. return nil
  1142. end
  1143. print("速度改变 ", actorID, header.recog, header.param1, header.param2, header.param3)
  1144. -- 走速度
  1145. if header.recog > 0 then
  1146. if actor:IsPlayer() and actor:IsMainPlayer() then
  1147. actor:SetWalkSpeed(actor:GetWalkStepTime() / (header.recog * 0.001 + global.MMO.NETWORK_DELAY))
  1148. else
  1149. actor:SetWalkSpeed(actor:GetWalkStepTime() / (header.recog * 0.001 + global.ConstantConfig.NetPlayerDelayTime * 0.001))
  1150. end
  1151. end
  1152. -- 跑速度
  1153. if header.param1 > 0 then
  1154. if actor:IsPlayer() and actor:IsMainPlayer() then
  1155. actor:SetRunSpeed(actor:GetRunStepTime() / (header.param1 * 0.001 + global.MMO.NETWORK_DELAY))
  1156. else
  1157. actor:SetRunSpeed(actor:GetRunStepTime() / (header.param1 * 0.001 + global.ConstantConfig.NetPlayerDelayTime * 0.001))
  1158. end
  1159. end
  1160. -- 攻击速度
  1161. -- 飞扬ios数据流量放火墙往相反方向跑出现空气墙,增加网络延迟误差
  1162. local delay = SL:GetMetaValue("GAME_DATA", "attack_network_delay") == 1 and global.MMO.NETWORK_DELAY or 0
  1163. if header.param2 > 0 then
  1164. actor:SetAttackSpeed(actor:GetAttackStepTime() / (header.param2 * 0.001 + delay))
  1165. end
  1166. -- 魔法速度
  1167. if header.param3 > 0 then
  1168. actor:SetMagicSpeed(actor:GetMagicStepTime() / (header.param3 * 0.001 + delay))
  1169. end
  1170. -- 同步主玩家锁帧时间
  1171. if actor:IsPlayer() and actor:IsMainPlayer() then
  1172. global.actorManager:UpdateLockFrameT()
  1173. end
  1174. end
  1175. function gameMapController:handle_RefreshMonsterSpeed( msgHdr, msgData )
  1176. if msgData == "" then
  1177. return nil
  1178. end
  1179. local header = msgHdr
  1180. local actorID = msgData
  1181. local actor = global.actorManager:GetActor(actorID)
  1182. if not actor then
  1183. return nil
  1184. end
  1185. print("怪物速度改变 ", actorID, header.recog, header.param1)
  1186. -- 走速度
  1187. if header.recog > 0 then
  1188. actor:SetWalkSpeed(actor:GetWalkStepTime() / (header.recog * 0.001 + global.MMO.NETWORK_DELAY))
  1189. end
  1190. -- 攻击速度
  1191. if header.param1 > 0 then
  1192. actor:SetAttackSpeed(actor:GetAttackStepTime() / (header.recog * 0.001))
  1193. end
  1194. end
  1195. function gameMapController:handle_RefreshName(msgHdr, msgData)
  1196. if msgData == "" then
  1197. return nil
  1198. end
  1199. local jsonData = cjson.decode(msgData)
  1200. if not jsonData then
  1201. return nil
  1202. end
  1203. local actorID = jsonData.UserID
  1204. local actor = global.actorManager:GetActor( actorID )
  1205. if not actor then
  1206. return nil
  1207. end
  1208. local guildID = actor:IsPlayer() and actor:GetGuildID() or nil
  1209. SetActorProperty(actor, jsonData)
  1210. SetActorName(actor, jsonData)
  1211. global.Facade:sendNotification( global.NoticeTable.DelayRefreshHUDLabel, { actor = actor, actorID = actorID, hudParam = jsonData } )
  1212. global.Facade:sendNotification( global.NoticeTable.DelayRefreshHUDTitle, { actor = actor, actorID = actorID, hudParam = jsonData } )
  1213. local newGuildID = actor:IsPlayer() and actor:GetGuildID() or nil
  1214. if guildID ~= newGuildID then
  1215. local guilds = {}
  1216. if guildID and guildID ~= "" then
  1217. guilds[guildID] = true
  1218. end
  1219. if newGuildID and newGuildID ~= "" then
  1220. guilds[newGuildID] = true
  1221. end
  1222. if next(guilds) then
  1223. global.Facade:sendNotification( global.NoticeTable.RefreshGuildActorColor, {guilds=guilds} )
  1224. end
  1225. end
  1226. end
  1227. function gameMapController:handle_Sell(header, msgData)
  1228. if msgData == "" then
  1229. return nil
  1230. end
  1231. local jsonData = cjson.decode(msgData)
  1232. if not jsonData then
  1233. return nil
  1234. end
  1235. local actorID = jsonData.userid
  1236. local actor = global.actorManager:GetActor( actorID )
  1237. if not actor then
  1238. return -1
  1239. end
  1240. local sellStatus = jsonData.open
  1241. actor:SetAction(global.MMO.ACTION_IDLE)
  1242. if sellStatus == 1 then
  1243. local pos = global.sceneManager:MapPos2WorldPos( jsonData.x, jsonData.y, true )
  1244. actor:setPosition( pos.x, pos.y )
  1245. actor:SetDirection( jsonData.dir )
  1246. actor:dirtyAnimFlag()
  1247. global.actorManager:SetActorMapXY( actor, jsonData.x, jsonData.y, true )
  1248. end
  1249. --摆摊状态 (0, 1)
  1250. actor:SetSellStatus(sellStatus)
  1251. --摊位名字
  1252. actor:SetStallName(jsonData.stallname)
  1253. if actorID == global.gamePlayerController:GetMainPlayerID() then
  1254. local StallProxy = global.Facade:retrieveProxy(global.ProxyTable.StallProxy)
  1255. StallProxy:SetMyTradingStatus(sellStatus == 1)
  1256. if sellStatus == 0 then --取消摆摊
  1257. StallProxy:CleanMySellData() --返回摆摊物品
  1258. end
  1259. end
  1260. global.Facade:sendNotification(global.NoticeTable.Layer_StallLayer_StatusChange, {status = sellStatus, userid = actorID})
  1261. global.Facade:sendNotification(global.NoticeTable.PlayerStallStatucChange, {actorID = actorID, actor = actor})
  1262. global.Facade:sendNotification(global.NoticeTable.RefreshActorBooth, {actorID = actorID, actor = actor})
  1263. if actorID == global.gamePlayerController:GetMainPlayerID() then
  1264. SLBridge:onLUAEvent(LUA_EVENT_PLAYER_STALL_STATUS_CHANGE)
  1265. else
  1266. SLBridge:onLUAEvent(LUA_EVENT_NET_PLAYER_STALL_STATUS_CHANGE, {id = actorID})
  1267. end
  1268. end
  1269. function gameMapController:handle_MSG_SC_NET_MONSTER_BORN(msg)
  1270. local msgLen = msg:GetDataLength()
  1271. if msgLen <= 0 then
  1272. return
  1273. end
  1274. local msgHdr = msg:GetHeader()
  1275. local msgData = msg:GetData():ReadString(msgLen)
  1276. local actorID = msgData
  1277. local actor = global.actorManager:GetActor( actorID )
  1278. if not actor then
  1279. print("[出生 20] 没有发现ACTOR", actorID)
  1280. return nil
  1281. end
  1282. if not actor:IsMonster() then
  1283. return nil
  1284. end
  1285. global.netMonsterController:handle_MSG_SC_NET_MONSTER_BORN(actor, msgHdr, msgData)
  1286. end
  1287. function gameMapController:handle_MSG_SC_NET_MONSTER_CAVE(msg)
  1288. local msgLen = msg:GetDataLength()
  1289. if msgLen <= 0 then
  1290. return
  1291. end
  1292. local msgHdr = msg:GetHeader()
  1293. local msgData = msg:GetData():ReadString(msgLen)
  1294. local actorID = msgData
  1295. local actor = global.actorManager:GetActor( actorID )
  1296. if not actor then
  1297. print("[钻回 21] 没有发现ACTOR", actorID)
  1298. return nil
  1299. end
  1300. if not actor:IsMonster() then
  1301. return nil
  1302. end
  1303. global.netMonsterController:handle_MSG_SC_NET_MONSTER_CAVE(actor, msgHdr, msgData)
  1304. end
  1305. function gameMapController:handle_Icons(msgHdr, msgData)
  1306. if msgData == "" then
  1307. return nil
  1308. end
  1309. local jsonData = cjson.decode(msgData)
  1310. if not jsonData then
  1311. return nil
  1312. end
  1313. local actorID = jsonData.UserID
  1314. local actor = global.actorManager:GetActor( actorID )
  1315. if not actor then
  1316. return nil
  1317. end
  1318. SetActorAttrByID( actorID, global.MMO.ACTOR_ATTR_HUDICONS, jsonData.icons or {} )
  1319. global.Facade:sendNotification( global.NoticeTable.DelayRefreshHUDTitle, { actor = actor, actorID = actorID } )
  1320. end
  1321. function gameMapController:handle_Title(msgHdr, msgData)
  1322. if msgData == "" then
  1323. return nil
  1324. end
  1325. local jsonData = cjson.decode(msgData)
  1326. if not jsonData then
  1327. return nil
  1328. end
  1329. local actorID = jsonData.UserID
  1330. local actor = global.actorManager:GetActor( actorID )
  1331. if not actor then
  1332. return nil
  1333. end
  1334. SetActorAttrByID( actorID, global.MMO.ACTOR_ATTR_HUDTITLE, jsonData.title or {} )
  1335. global.Facade:sendNotification( global.NoticeTable.DelayRefreshHUDTitle, { actor = actor, actorID = actorID } )
  1336. end
  1337. -- 挖矿
  1338. function gameMapController:handle_AutoMining(msgHdr, msgData)
  1339. local mainPlayer = global.gamePlayerController:GetMainPlayer()
  1340. if not mainPlayer then
  1341. return
  1342. end
  1343. local inputProxy = global.Facade:retrieveProxy( global.ProxyTable.PlayerInputProxy )
  1344. local x = msgHdr.param1
  1345. local y = msgHdr.param2
  1346. local dest = cc.p(x, y)
  1347. local src = cc.p(mainPlayer:GetMapX(), mainPlayer:GetMapY())
  1348. local dir = inputProxy:calcMapDirection(dest, src)
  1349. local autoProxy = global.Facade:retrieveProxy(global.ProxyTable.Auto)
  1350. autoProxy:SetAutoMining(dir,dest)
  1351. local mapProxy = global.Facade:retrieveProxy(global.ProxyTable.Map)
  1352. local mapID = mapProxy:GetMapID()
  1353. local movePos =
  1354. {
  1355. mapID = mapID,
  1356. x = dest.x,
  1357. y = dest.y,
  1358. type = global.MMO.INPUT_MOVE_TYPE_AUTOMOVE,
  1359. }
  1360. global.Facade:sendNotification(global.NoticeTable.InputMove, movePos)
  1361. end
  1362. -- actor 转生
  1363. function gameMapController:handle_ActorReLevel(msgHdr, msgData)
  1364. if not msgData then
  1365. return false
  1366. end
  1367. local actor = global.actorManager:GetActor(msgData)
  1368. if not actor then
  1369. return false
  1370. end
  1371. if not actor:IsPlayer() then
  1372. return false
  1373. end
  1374. actor:SetReLevel(msgHdr.recog)
  1375. end
  1376. -----------------------------------------------------------------------------
  1377. --- 开门 关门
  1378. function gameMapController:handle_MSG_SC_OPEN_DOOR_NOTICE(msg)
  1379. local header = msg:GetHeader()
  1380. global.sceneManager:openDoor( header.param1, header.param2 )
  1381. end
  1382. function gameMapController:handle_MSG_SC_CLOSE_DOOR_NOTICE(msg)
  1383. local header = msg:GetHeader()
  1384. global.sceneManager:closeDoor( header.param1, header.param2 )
  1385. end
  1386. -----------------------------------------------------------------------------
  1387. -----------------------------------------------------------------------------
  1388. -- 场景特效
  1389. function gameMapController:handle_MSG_SC_MAP_ADD_SPECIAL_EFFECT( msg )
  1390. local jsonData = ParseRawMsgToJson(msg)
  1391. if not jsonData then
  1392. return nil
  1393. end
  1394. local len = #jsonData
  1395. local data = nil
  1396. local item = nil
  1397. for i = 1, len do
  1398. data = jsonData[i]
  1399. local item =
  1400. {
  1401. id = data.Id,
  1402. type = data.Type,
  1403. x = data.X,
  1404. y = data.Y,
  1405. param = data.Param,
  1406. sfxId = data.EffId,
  1407. TopType = data.TopType,
  1408. DuranceID = data.DuranceID or global.gamePlayerController:GetMainPlayerID()
  1409. }
  1410. if item.TopType == 2 then
  1411. SL:AddMapSpecialEffect(item.id, SL:GetMetaValue("MAP_ID"), item.sfxId, item.x, item.y, true, item.TopType)
  1412. else
  1413. self:addSpecialEffect( item )
  1414. end
  1415. end
  1416. end
  1417. function gameMapController:handle_MSG_SC_MAP_RMV_SPECIAL_EFFECT( msg )
  1418. local jsonData = ParseRawMsgToJson(msg)
  1419. if not jsonData then
  1420. return nil
  1421. end
  1422. local len = #jsonData
  1423. local data = nil
  1424. local actorID = nil
  1425. for i = 1, len do
  1426. data = jsonData[i]
  1427. actorID = data.Id
  1428. local sfxActor = self.mNetActorMap[actorID]
  1429. if (sfxActor) then
  1430. -- notice
  1431. global.Facade:sendNotification(global.NoticeTable.ActorEffectOutOfView, {actorID = actorID, actor = sfxActor})
  1432. end
  1433. self.mNetActorMap[actorID] = nil
  1434. global.sceneEffectManager:RmvSceneEffect( actorID )
  1435. global.actorManager:RemoveActor( actorID )
  1436. local sceneImprisonEffectProxy = global.Facade:retrieveProxy(global.ProxyTable.SceneImprisonEffectProxy)
  1437. sceneImprisonEffectProxy:RmImprison( actorID )
  1438. end
  1439. end
  1440. function gameMapController:addSpecialEffect( item )
  1441. local isInit = true
  1442. local actorID = item.id
  1443. local needLight = false
  1444. -- find it
  1445. local sfxActor = global.actorManager:GetActor( actorID )
  1446. if nil ~= sfxActor then
  1447. sfxActor:GetNode():setVisible( true )
  1448. isInit = false
  1449. -----lightID
  1450. if not sfxActor:GetLightID() then
  1451. needLight = true
  1452. end
  1453. else
  1454. -- New special effect actor
  1455. local paramSfx = {}
  1456. paramSfx.type = global.MMO.EFFECT_TYPE_NORMAL
  1457. local limitCount = 200
  1458. local actorCount = global.actorManager:GetActorNum()
  1459. local isBehind = false
  1460. local isFront = false
  1461. local effectRace = item.type
  1462. if fireSet[effectRace] then
  1463. paramSfx.sfxId = fireSet[effectRace]
  1464. paramSfx.isLoop = true
  1465. isBehind = (actorCount>limitCount)
  1466. paramSfx.type = global.MMO.EFFECT_TYPE_FIRE
  1467. -----lightID
  1468. needLight = true
  1469. local sfxId = item.sfxId and tonumber(item.sfxId)
  1470. if sfxId and sfxId > 0 then
  1471. paramSfx.sfxId = sfxId
  1472. end
  1473. elseif effectRace == 1 then -- 僵尸2 出生洞
  1474. paramSfx.sfxId = global.MMO.SFX_MONSTER_BORN1
  1475. paramSfx.isLoop = false
  1476. isBehind = true
  1477. elseif effectRace == global.MMO.EFFECT_TYPE_MINING_HIT then
  1478. -- 土(静态特效)(ps: 以前是挖矿 sfxid:999)
  1479. paramSfx.type = global.MMO.EFFECT_TYPE_MINING_HIT
  1480. paramSfx.sfxId = 2208
  1481. paramSfx.isLoop = true
  1482. paramSfx.param = item.param
  1483. isBehind = true
  1484. elseif effectRace == 27 or effectRace == 50 then
  1485. -- 传送门
  1486. paramSfx.sfxId = global.MMO.SFX_PORTAL
  1487. paramSfx.isLoop = true
  1488. isBehind = true
  1489. paramSfx.type = global.MMO.EFFECT_TYPE_PORTAL
  1490. needLight = true
  1491. elseif effectRace == global.MMO.EFFECT_TYPE_SFX then
  1492. -- 通用特效
  1493. paramSfx.type = global.MMO.EFFECT_TYPE_SFX
  1494. paramSfx.sfxId = item.sfxId
  1495. paramSfx.isLoop = true
  1496. isBehind = item.TopType == 0
  1497. isFront = item.TopType == 1
  1498. elseif effectRace == global.MMO.EFFECT_TYPE_EMPTY then
  1499. -- 禁锢 设置动态阻挡
  1500. paramSfx.type = global.MMO.EFFECT_TYPE_EMPTY
  1501. paramSfx.sfxId = item.sfxId
  1502. paramSfx.isLoop = true
  1503. paramSfx.DuranceID = item.DuranceID
  1504. isBehind = false
  1505. else
  1506. return -1
  1507. end
  1508. sfxActor = global.actorManager:CreateActor( actorID, global.MMO.ACTOR_SEFFECT, paramSfx, isBehind ,isFront)
  1509. if nil == sfxActor then
  1510. return -1
  1511. end
  1512. end
  1513. -- To map grid position.
  1514. local mapX = item.x
  1515. local mapY = item.y
  1516. local actorPos = global.sceneManager:MapPos2WorldPos( mapX, mapY, true )
  1517. sfxActor:setPosition( actorPos.x, actorPos.y )
  1518. global.actorManager:SetActorMapXY( sfxActor, mapX, mapY )
  1519. -- feature
  1520. global.Facade:sendNotification( global.NoticeTable.DelayDirtyFeature, {actorID = actorID, actor = sfxActor})
  1521. if isInit then
  1522. -- Track effect.
  1523. self.mNetActorMap[actorID] = sfxActor
  1524. global.sceneEffectManager:AddSceneEffect( sfxActor )
  1525. end
  1526. global.Facade:sendNotification(global.NoticeTable.ActorEffectInOfView, {actorID = actorID, actor = sfxActor, needLight = needLight})
  1527. end
  1528. -- 场景添加特效
  1529. function gameMapController:addEffectToMap( animID, mapX, mapY )
  1530. if not animID or not mapX or not mapY then
  1531. return
  1532. end
  1533. -- 播放特效
  1534. local sfxAnim = global.FrameAnimManager:CreateSFXAnim(animID)
  1535. if not sfxAnim then
  1536. return
  1537. end
  1538. local root = global.sceneGraphCtl:GetSceneNode( global.MMO.NODE_SKILL_BEHIND )
  1539. local sfxParent = root:getChildByName("MAP_SFX_PARENT")
  1540. if not sfxParent then
  1541. sfxParent = cc.Node:create()
  1542. sfxParent:setName("MAP_SFX_PARENT")
  1543. root:addChild( sfxParent, 999 )
  1544. end
  1545. sfxParent:addChild(sfxAnim, animID)
  1546. local sfxPos = global.sceneManager:MapPos2WorldPos( mapX, mapY )
  1547. sfxAnim:setPosition( sfxPos.x, sfxPos.y)
  1548. sfxAnim:Play(0, 0)
  1549. local function removeEvent()
  1550. sfxAnim:removeFromParent()
  1551. end
  1552. sfxAnim:SetAnimEventCallback( removeEvent )
  1553. end
  1554. -----------------------------------------------------------------------------
  1555. -- 掉落物
  1556. function gameMapController:addDropItem( item )
  1557. local id = item.Id
  1558. local Idx = item.Idx
  1559. local code = global.dropItemController:AddDropItemToWorld( item )
  1560. if code == 2 then -- refresh drop item ownerID
  1561. global.Facade:sendNotification(global.NoticeTable.RefreshDropItem, id)
  1562. return nil
  1563. elseif code ~= 1 then
  1564. return nil
  1565. end
  1566. -- Track Npc, NetPlayer, monster....
  1567. local dropItem = global.actorManager:GetActor( id )
  1568. self.mNetActorMap[ id ] = dropItem
  1569. -- type index
  1570. dropItem:SetTypeIndex( Idx )
  1571. local noticeData = {
  1572. actorID = id,
  1573. color = item.Color or 255,
  1574. jipin = item.jipin,
  1575. count = item.cnt,
  1576. itemName = item.Name,
  1577. }
  1578. global.Facade:sendNotification(global.NoticeTable.DropItemInOfView, noticeData)
  1579. global.Facade:sendNotification(global.NoticeTable.DelayDirtyFeature, {actorID = id, actor = dropItem})
  1580. SLBridge:onLUAEvent(LUA_EVENT_DROPITEM_IN_OF_VIEW, {actorID = id, item = item})
  1581. end
  1582. function gameMapController:rmvDropItem( id )
  1583. -- Drop item
  1584. if nil == id then
  1585. return nil
  1586. end
  1587. local it = self.mNetActorMap[id]
  1588. if nil == it then
  1589. return nil
  1590. end
  1591. self.mNetActorMap[id] = nil
  1592. global.Facade:sendNotification(global.NoticeTable.DropItemOutOfView, {actorID = id})
  1593. global.dropItemController:RmvDroItemFromWorld( id )
  1594. SLBridge:onLUAEvent(LUA_EVENT_DROPITEM_OUT_OF_VIEW, {actorID = id})
  1595. end
  1596. function gameMapController:handle_MSG_SC_MAP_ITEM_DROP_BATCH( msg )
  1597. local jsonData = ParseRawMsgToJson( msg )
  1598. if not jsonData or next(jsonData) == nil then
  1599. return nil
  1600. end
  1601. local len = #jsonData
  1602. local item = nil
  1603. for i = 1, len do
  1604. item = jsonData[i]
  1605. self:addDropItem(item)
  1606. end
  1607. end
  1608. function gameMapController:handle_MSG_SC_MAP_ITEM_REMOVE_BATCH( msg )
  1609. local jsonData = ParseRawMsgToJson( msg )
  1610. if not jsonData or next(jsonData) == nil then
  1611. return nil
  1612. end
  1613. local len = #jsonData
  1614. local item = nil
  1615. local itemID = nil
  1616. for i = 1, len do
  1617. item = jsonData[i]
  1618. itemID = tonumber(item.Id)
  1619. self:rmvDropItem( itemID )
  1620. end
  1621. end
  1622. -----------------------------------------------------------------------------
  1623. -----------------------------------------------------------------------------
  1624. --移动特效、足迹
  1625. function gameMapController:handle_MSG_SC_ACTOR_MOVE_EFF(msg)
  1626. local msgLen = msg:GetDataLength()
  1627. if msgLen <= 0 then
  1628. return
  1629. end
  1630. local msgHdr = msg:GetHeader()
  1631. local userid = msg:GetData():ReadString(msgLen)
  1632. local effID = msgHdr.recog
  1633. local skipWalk = msgHdr.param1
  1634. local actor = global.actorManager:GetActor(userid)
  1635. if not actor then
  1636. return
  1637. end
  1638. if actor:IsPlayer() then
  1639. actor:SetMoveEff(effID)
  1640. actor:SetEffSkipWalkSwitch(skipWalk)
  1641. end
  1642. end
  1643. -----------------------------------------------------------------------------
  1644. -- 强制移动
  1645. function gameMapController:handle_MSG_SC_NET_PLAYER_MOVE_FORCE(msg)
  1646. local msgLen = msg:GetDataLength()
  1647. if msgLen <= 0 then
  1648. return
  1649. end
  1650. local msgData = msg:GetData():ReadString(msgLen)
  1651. if msgData == "" then
  1652. return nil
  1653. end
  1654. local jsonData = cjson.decode(msgData)
  1655. if not jsonData then
  1656. return nil
  1657. end
  1658. local actor = global.actorManager:GetActor(jsonData.UserID)
  1659. if not actor then
  1660. return nil
  1661. end
  1662. local msgHdr = msg:GetHeader()
  1663. local mapX = msgHdr.param1
  1664. local mapY = msgHdr.param2
  1665. local dir = msgHdr.param3
  1666. local data = {
  1667. mapX = msgHdr.param1,
  1668. mapY = msgHdr.param2,
  1669. dir = msgHdr.param3
  1670. }
  1671. if actor:IsPlayer() then
  1672. if actor:IsMainPlayer() then
  1673. global.gamePlayerController:handle_Move_Force(actor,data)
  1674. else
  1675. global.netPlayerController:handle_Move_Force(actor, data)
  1676. end
  1677. else
  1678. global.netMonsterController:handle_Move_Force(actor, data)
  1679. end
  1680. global.Facade:sendNotification(global.NoticeTable.ActorMoveForce, {actorID = jsonData.UserID, actor = actor})
  1681. end
  1682. ----------------------------------------------------------------------------
  1683. function gameMapController:handle_MSG_SC_OPENHEALTH( msg )
  1684. local msgLen = msg:GetDataLength()
  1685. local msgData = (msgLen > 0 and msg:GetData():ReadString(msgLen) or "")
  1686. local actorID = msgData
  1687. dump(msgData,"handle_MSG_SC_OPENHEALTH")
  1688. if not actorID then
  1689. return
  1690. end
  1691. local actor = global.actorManager:GetActor( actorID )
  1692. if nil == actor or 0 == actor then
  1693. return
  1694. end
  1695. actor:setVisibleServerHpLabel(true)
  1696. optionsUtils:InitHUDVisibleValue(actor, global.MMO.HUD_HMPLabel_VISIBLE)
  1697. optionsUtils:refreshHUDHMpLabelVisible(actor)
  1698. end
  1699. function gameMapController:handle_MSG_SC_CLOSEHEALTH( msg )
  1700. local msgLen = msg:GetDataLength()
  1701. local msgData = (msgLen > 0 and msg:GetData():ReadString(msgLen) or "")
  1702. local actorID = msgData
  1703. dump(msgData,"handle_MSG_SC_CLOSEHEALTH")
  1704. if not actorID then
  1705. return
  1706. end
  1707. local actor = global.actorManager:GetActor( actorID )
  1708. if nil == actor or 0 == actor then
  1709. return
  1710. end
  1711. actor:setVisibleServerHpLabel(false)
  1712. optionsUtils:InitHUDVisibleValue(actor, global.MMO.HUD_HMPLabel_VISIBLE)
  1713. optionsUtils:refreshHUDHMpLabelVisible(actor)
  1714. end
  1715. -----------------------------------------------------------------------------
  1716. -- 技能
  1717. function gameMapController:handle_MSG_SC_PLAYER_SKILL_LAUNCH_SUCCESS(msg)
  1718. local msgHdr = msg:GetHeader()
  1719. local jsonData = ParseRawMsgToJson(msg)
  1720. if not jsonData then
  1721. return -1
  1722. end
  1723. local actorID = jsonData.UserID
  1724. -- can't find actor
  1725. local actor = global.actorManager:GetActor( actorID )
  1726. if nil == actor then
  1727. return
  1728. end
  1729. -- ignore main player
  1730. if actor:IsPlayer() and actor:IsMainPlayer() then
  1731. return
  1732. end
  1733. if actor:IsMonster() then
  1734. global.netMonsterController:handle_MSG_SC_PLAYER_SKILL_LAUNCH_SUCCESS(actor, msgHdr, jsonData)
  1735. elseif actor:IsPlayer() then
  1736. global.netPlayerController:handle_MSG_SC_PLAYER_SKILL_LAUNCH_SUCCESS(actor, msgHdr, jsonData)
  1737. end
  1738. end
  1739. function gameMapController:handle_MSG_SC_NET_PLAYER_ATTACK(msg)
  1740. local msgHdr = msg:GetHeader()
  1741. local jsonData = ParseRawMsgToJson(msg)
  1742. if not jsonData then
  1743. return -1
  1744. end
  1745. local actorID = jsonData.UserID
  1746. -- can't find actor
  1747. local actor = global.actorManager:GetActor( actorID )
  1748. if nil == actor then
  1749. return
  1750. end
  1751. -- ignore main player
  1752. if actor:IsPlayer() and actor:IsMainPlayer() then
  1753. return
  1754. end
  1755. if actor:IsMonster() then
  1756. global.netMonsterController:handle_MSG_SC_NET_PLAYER_ATTACK(actor, msgHdr, jsonData)
  1757. elseif actor:IsPlayer() then
  1758. global.netPlayerController:handle_MSG_SC_NET_PLAYER_ATTACK(actor, msgHdr, jsonData)
  1759. end
  1760. end
  1761. function gameMapController:handle_MSG_SC_PLAYER_SKILL_MAGIC_SUCCESS(msg)
  1762. local msgHdr = msg:GetHeader()
  1763. local jsonData = ParseRawMsgToJson(msg)
  1764. if not jsonData then
  1765. return -1
  1766. end
  1767. local actorID = jsonData.UserID
  1768. -- can't find actor
  1769. local actor = global.actorManager:GetActor( actorID )
  1770. if nil == actor then
  1771. return
  1772. end
  1773. jsonData.showSkillMaigc = msgHdr.recog == 1
  1774. if actor:IsMonster() then
  1775. global.netMonsterController:handle_MSG_SC_PLAYER_SKILL_MAGIC_SUCCESS(actor, msgHdr, jsonData)
  1776. elseif actor:IsPlayer() then
  1777. if actor:IsMainPlayer() then
  1778. global.gamePlayerController:handle_MSG_SC_PLAYER_SKILL_MAGIC_SUCCESS(actor, msgHdr, jsonData)
  1779. else
  1780. global.netPlayerController:handle_MSG_SC_PLAYER_SKILL_MAGIC_SUCCESS(actor, msgHdr, jsonData)
  1781. end
  1782. end
  1783. end
  1784. function gameMapController:handle_MSG_SC_MAINPLAYER_MAGIC(msg)
  1785. local header = msg:GetHeader()
  1786. local x = header.param1
  1787. local y = header.param2
  1788. local sfxID = header.param3
  1789. local offset = global.MMO.PLAYER_AVATAR_OFFSET
  1790. local dest = global.sceneManager:MapPos2WorldPos(x, y, true)
  1791. local root = global.sceneGraphCtl:GetSceneNode(global.MMO.NODE_SKILL)
  1792. local sfx = global.FrameAnimManager:CreateSkillEffAnim(sfxID, 0)
  1793. root:addChild(sfx)
  1794. sfx:setLocalZOrder(sfxID)
  1795. sfx:Play(0, 0, true)
  1796. sfx:setPosition(cc.pAdd(dest, offset))
  1797. sfx:SetAnimEventCallback(
  1798. function(_, eventType)
  1799. sfx:removeFromParent()
  1800. sfx = nil
  1801. end
  1802. )
  1803. end
  1804. -----------------------------------------------------------------------------
  1805. ----------------------------------刷新骑马 BEGIN----------------------------------
  1806. function gameMapController:refreshHorse( actor,jsonData )
  1807. if not actor or not actor:IsPlayer() then
  1808. return
  1809. end
  1810. local isMainHorse = jsonData.mountID and jsonData.mountID > 0
  1811. local actorid = {
  1812. [1] = isMainHorse and jsonData.UserID or jsonData.doubleUserId,
  1813. [2] = not isMainHorse and jsonData.UserID or jsonData.doubleUserId
  1814. }
  1815. for i,v in ipairs(actorid) do
  1816. local actor = v and global.actorManager:GetActor(v) or nil
  1817. if actor then
  1818. actor:SetKeyValue(global.MMO.HORSE_MAIN, actorid[1])
  1819. actor:SetKeyValue(global.MMO.HORSE_COPILOT, actorid[2])
  1820. actor:SetDoubleHorse( jsonData.doubleTag )
  1821. local data = {
  1822. mountID = jsonData.mountID,
  1823. mountEff = jsonData.mountEff,
  1824. mountCloth = jsonData.mountCloth,
  1825. hairID = actor:GetAnimationHairID()
  1826. }
  1827. local buffData =
  1828. {
  1829. actorID = actor:GetID(),
  1830. buffID = global.MMO.BUFF_ID_HORSE,
  1831. param = {
  1832. feature = data,
  1833. }
  1834. }
  1835. global.Facade:sendNotification(global.NoticeTable.AddBuffEntity, buffData)
  1836. end
  1837. end
  1838. end
  1839. ----------------------------------刷新骑马 END----------------------------------
  1840. --------------------------------------------------------------------------------
  1841. --- gm数据更新
  1842. function gameMapController:MSG_SC_ACTOR_GMDATA_UPDATE(msg)
  1843. local msgLen = msg:GetDataLength()
  1844. if msgLen <= 0 then
  1845. return
  1846. end
  1847. local msgData = msg:GetData():ReadString(msgLen)
  1848. local slices = string.split(msgData, "|")
  1849. local actorID = slices[1]
  1850. local actor = global.actorManager:GetActor(actorID)
  1851. if not actor or not (actor:IsPlayer() or actor:IsMonster()) then
  1852. return
  1853. end
  1854. local items = {}
  1855. for i = 2, 6 do
  1856. items[i-1] = tonumber(slices[i])
  1857. end
  1858. actor:SetGMData(items)
  1859. -- SL 广播
  1860. SLBridge:onLUAEvent(LUA_EVENT_ACTOR_GMDATA_UPDATE, {id = actorID, data = actor:GetGMData()})
  1861. end
  1862. -- 玩家内力值更新
  1863. function gameMapController:handle_MSG_SC_ACTOR_INTERNAL_FORCE_UPDATE(msg)
  1864. local header = msg:GetHeader()
  1865. local msgLen = msg:GetDataLength()
  1866. if msgLen <= 0 then
  1867. return
  1868. end
  1869. local actorID = msg:GetData():ReadString(msgLen)
  1870. local actor = global.actorManager:GetActor(actorID)
  1871. if not actor then
  1872. return
  1873. end
  1874. if not (actor:IsPlayer() or actor:IsHero()) then
  1875. return
  1876. end
  1877. local maxForce = header.recog
  1878. local curForce = header.param1
  1879. actor:SetNGHUD(curForce, maxForce)
  1880. end
  1881. -----------------------------------------------------------------------------
  1882. -----------------------------------------------------------------------------
  1883. -----------------------------------------------------------------------------
  1884. function gameMapController:RegisterMsgHandler()
  1885. LuaRegisterMsgHandler( global.MsgType.MSG_SC_CREATE_MAIN_PLAYER, handler( self, self.handle_MSG_SC_CREATE_MAIN_PLAYER) )
  1886. LuaRegisterMsgHandler( global.MsgType.MSG_SC_NET_PLAYER_IN_OF_VIEW, handler( self, self.handleMessage) )
  1887. LuaRegisterMsgHandler( global.MsgType.MSG_SC_NET_PLAYER_FLY_IN, handler( self, self.handleMessage) )
  1888. LuaRegisterMsgHandler( global.MsgType.MSG_SC_NET_PLAYER_FLY_IN_2, handler( self, self.handleMessage) )
  1889. LuaRegisterMsgHandler( global.MsgType.MSG_SC_ACTOR_BUFF_INIT, handler( self, self.handleMessage) )
  1890. LuaRegisterMsgHandler( global.MsgType.MSG_SC_ACTOR_BUFF_ADD, handler( self, self.handleMessage) )
  1891. LuaRegisterMsgHandler( global.MsgType.MSG_SC_ACTOR_BUFF_RMV, handler( self, self.handleMessage) )
  1892. LuaRegisterMsgHandler( global.MsgType.MSG_SC_ACTOR_EFFECT_UPDATE, handler( self, self.handleMessage) )
  1893. LuaRegisterMsgHandler( global.MsgType.MSG_SC_PLAYER_FEATURE_CHANGED, handler( self, self.handleMessage) )
  1894. LuaRegisterMsgHandler( global.MsgType.MSG_SC_NET_PLAYER_WALK, handler( self, self.handleMessage) )
  1895. LuaRegisterMsgHandler( global.MsgType.MSG_SC_NET_PLAYER_RUN, handler( self, self.handleMessage) )
  1896. LuaRegisterMsgHandler( global.MsgType.MSG_SC_NET_PLAYER_RIDE_RUN, handler( self, self.handleMessage) )
  1897. LuaRegisterMsgHandler( global.MsgType.MSG_SC_NET_ACTOR_TURN, handler( self, self.handleMessage) )
  1898. LuaRegisterMsgHandler( global.MsgType.MSG_SC_WALKEX, handler( self, self.handleMessage) )
  1899. LuaRegisterMsgHandler( global.MsgType.MSG_SC_PLAYER_HP_MP, handler( self, self.handleMessage) )
  1900. LuaRegisterMsgHandler( global.MsgType.MSG_SC_DAMAGE_HP, handler( self, self.handleMessage) )
  1901. LuaRegisterMsgHandler( global.MsgType.MSG_SC_ACTOR_REFRESH_ACTOR_SPEED, handler( self, self.handleMessage) )
  1902. LuaRegisterMsgHandler( global.MsgType.MSG_SC_REFRESH_MONSTER_SPEED, handler( self, self.handleMessage) )
  1903. LuaRegisterMsgHandler( global.MsgType.MSG_SC_NET_MONSTER_BORN, handler( self, self.handle_MSG_SC_NET_MONSTER_BORN) )
  1904. LuaRegisterMsgHandler( global.MsgType.MSG_SC_NET_MONSTER_CAVE, handler( self, self.handle_MSG_SC_NET_MONSTER_CAVE) )
  1905. LuaRegisterMsgHandler( global.MsgType.MSG_SC_ACTOR_NAME, handler( self, self.handleMessage) ) -- 角色头顶数据(名子、称号等)
  1906. LuaRegisterMsgHandler( global.MsgType.MSG_SC_SELL_NOTICE, handler( self, self.handleMessage) )
  1907. LuaRegisterMsgHandler( global.MsgType.MSG_SC_ACTION_PICK_CORPSE, handler( self, self.handleMessage) )
  1908. LuaRegisterMsgHandler( global.MsgType.MSG_SC_NET_ACTOR_DEATH_FALL_DOWN, handler( self, self.handleMessage) )
  1909. LuaRegisterMsgHandler( global.MsgType.MSG_SC_NET_ACTOR_DEATH_SKELETON, handler( self, self.handleMessage) )
  1910. LuaRegisterMsgHandler( global.MsgType.MSG_SC_NET_PLAYER_REVIVE, handler( self, self.handleMessage) )
  1911. LuaRegisterMsgHandler( global.MsgType.MSG_SC_NET_PLAYER_OUT_OF_VIEW, handler( self, self.handleMessage) )
  1912. LuaRegisterMsgHandler( global.MsgType.MSG_SC_NET_PLAYER_FLY_OUT, handler( self, self.handleMessage) )
  1913. LuaRegisterMsgHandler( global.MsgType.MSG_SC_NET_PLAYER_FLY_OUT_2, handler( self, self.handleMessage) )
  1914. LuaRegisterMsgHandler( global.MsgType.MSG_SC_ACTOR_ICONS_UPDATE, handler( self, self.handleMessage) )
  1915. LuaRegisterMsgHandler( global.MsgType.MSG_SC_ACTOR_TITLE_UPDATE, handler( self, self.handleMessage) )
  1916. LuaRegisterMsgHandler( global.MsgType.MSG_SM_ACTOR_AUTO_MINING, handler( self, self.handleMessage) )
  1917. LuaRegisterMsgHandler( global.MsgType.MSG_SC_ACTOR_RELEVEL, handler( self, self.handleMessage) )
  1918. -----------------------------------------------------------------------------
  1919. -- main player
  1920. LuaRegisterMsgHandler( global.MsgType.MSG_SC_MAP_ACTOR_CLEANUP, handler( self, self.handle_MSG_SC_MAP_ACTOR_CLEANUP) )
  1921. -----------------------------------------------------------------------------
  1922. -----------------------------------------------------------------------------
  1923. -- scene effect
  1924. LuaRegisterMsgHandler( global.MsgType.MSG_SC_MAP_ADD_SPECIAL_EFFECT, handler( self, self.handle_MSG_SC_MAP_ADD_SPECIAL_EFFECT) )
  1925. LuaRegisterMsgHandler( global.MsgType.MSG_SC_MAP_RMV_SPECIAL_EFFECT, handler( self, self.handle_MSG_SC_MAP_RMV_SPECIAL_EFFECT) )
  1926. -----------------------------------------------------------------------------
  1927. -----------------------------------------------------------------------------
  1928. -- drop item
  1929. LuaRegisterMsgHandler( global.MsgType.MSG_SC_MAP_ITEM_DROP_BATCH, handler( self, self.handle_MSG_SC_MAP_ITEM_DROP_BATCH) )
  1930. LuaRegisterMsgHandler( global.MsgType.MSG_SC_MAP_ITEM_REMOVE_BATCH, handler( self, self.handle_MSG_SC_MAP_ITEM_REMOVE_BATCH) )
  1931. -----------------------------------------------------------------------------
  1932. -----------------------------------------------------------------------------
  1933. LuaRegisterMsgHandler( global.MsgType.MSG_SC_OPEN_DOOR_NOTICE, handler( self, self.handle_MSG_SC_OPEN_DOOR_NOTICE) )
  1934. LuaRegisterMsgHandler( global.MsgType.MSG_SC_CLOSE_DOOR_NOTICE, handler( self, self.handle_MSG_SC_CLOSE_DOOR_NOTICE) )
  1935. -----------------------------------------------------------------------------
  1936. LuaRegisterMsgHandler( global.MsgType.MSG_SC_OPENHEALTH, handler( self, self.handle_MSG_SC_OPENHEALTH) )
  1937. LuaRegisterMsgHandler( global.MsgType.MSG_SC_CLOSEHEALTH, handler( self, self.handle_MSG_SC_CLOSEHEALTH) )
  1938. -----------------------------------------------------------------------------
  1939. -----------------------------------------------------------------------------
  1940. -- 技能释放成功,进入释放动作
  1941. LuaRegisterMsgHandler( global.MsgType.MSG_SC_PLAYER_SKILL_LAUNCH_SUCCESS,handler(self, self.handle_MSG_SC_PLAYER_SKILL_LAUNCH_SUCCESS))
  1942. -- 攻击成功,进入攻击动作+播放攻击特效
  1943. LuaRegisterMsgHandler( global.MsgType.MSG_SC_NET_PLAYER_ATTACK, handler(self, self.handle_MSG_SC_NET_PLAYER_ATTACK))
  1944. -- 技能释放成功,播放释放特效
  1945. LuaRegisterMsgHandler( global.MsgType.MSG_SC_PLAYER_SKILL_MAGIC_SUCCESS, handler(self, self.handle_MSG_SC_PLAYER_SKILL_MAGIC_SUCCESS))
  1946. -- 地图某个位置播放一个特效
  1947. LuaRegisterMsgHandler( global.MsgType.MSG_SC_MAINPLAYER_MAGIC, handler(self, self.handle_MSG_SC_MAINPLAYER_MAGIC))
  1948. -----------------------------------------------------------------------------
  1949. -----------------------------------------------------------------------------
  1950. -- 移动特效、足迹
  1951. LuaRegisterMsgHandler( global.MsgType.MSG_SC_ACTOR_MOVE_EFF, handler(self, self.handle_MSG_SC_ACTOR_MOVE_EFF))
  1952. -----------------------------------------------------------------------------
  1953. -----------------------------------------------------------------------------
  1954. -- 强制移动
  1955. LuaRegisterMsgHandler( global.MsgType.MSG_SC_NET_PLAYER_MOVE_FORCE, handler(self, self.handle_MSG_SC_NET_PLAYER_MOVE_FORCE))
  1956. ------------------------------------------------------------------------------
  1957. -----------------------------------------------------------------------------
  1958. -- gmdata 更新
  1959. LuaRegisterMsgHandler( global.MsgType.MSG_SC_ACTOR_GMDATA_UPDATE, handler(self, self.MSG_SC_ACTOR_GMDATA_UPDATE))
  1960. -- 内力值 更新
  1961. LuaRegisterMsgHandler(global.MsgType.MSG_SC_ACTOR_INTERNAL_FORCE_UPDATE, handler(self, self.handle_MSG_SC_ACTOR_INTERNAL_FORCE_UPDATE))
  1962. -- 通知反击 特殊
  1963. LuaRegisterMsgHandler(global.MsgType.MSG_SC_FIGHT_BACK_ID, handler(self, self.handle_MSG_SC_FIGHT_BACK_ID))
  1964. ------------------------------------------------------------------------------
  1965. -- in of view
  1966. self.mNetMsgHandle[global.MsgType.MSG_SC_NET_PLAYER_IN_OF_VIEW] = function(msgHdr, msgData)
  1967. self:handle_InOfView(msgHdr, msgData)
  1968. end
  1969. -- fly in effect
  1970. self.mNetMsgHandle[global.MsgType.MSG_SC_NET_PLAYER_FLY_IN] = function(msgHdr, msgData)
  1971. self:handle_FlyIn(msgHdr, msgData)
  1972. end
  1973. self.mNetMsgHandle[global.MsgType.MSG_SC_NET_PLAYER_FLY_IN_2] = function(msgHdr, msgData)
  1974. self:handle_FlyIn2(msgHdr, msgData)
  1975. end
  1976. -- feature changed
  1977. self.mNetMsgHandle[global.MsgType.MSG_SC_PLAYER_FEATURE_CHANGED] = function(msgHdr, msgData)
  1978. self:handle_FeatureChanged(msgHdr, msgData)
  1979. end
  1980. -- walk
  1981. self.mNetMsgHandle[global.MsgType.MSG_SC_NET_PLAYER_WALK] = function(msgHdr, msgData)
  1982. self:handle_Walk(msgHdr, msgData)
  1983. end
  1984. -- run
  1985. self.mNetMsgHandle[global.MsgType.MSG_SC_NET_PLAYER_RUN] = function(msgHdr, msgData)
  1986. self:handle_Run(msgHdr, msgData)
  1987. end
  1988. -- 跑一格
  1989. self.mNetMsgHandle[global.MsgType.MSG_SC_WALKEX] = function(msgHdr, msgData)
  1990. self:handle_Run(msgHdr, msgData, true)
  1991. end
  1992. -- rile run
  1993. self.mNetMsgHandle[global.MsgType.MSG_SC_NET_PLAYER_RIDE_RUN] = function(msgHdr, msgData)
  1994. self:handle_RideRun(msgHdr, msgData)
  1995. end
  1996. -- turn
  1997. self.mNetMsgHandle[global.MsgType.MSG_SC_NET_ACTOR_TURN] = function(msgHdr, msgData)
  1998. self:handle_Turn(msgHdr, msgData)
  1999. end
  2000. -- refresh hp
  2001. self.mNetMsgHandle[global.MsgType.MSG_SC_PLAYER_HP_MP] = function(msgHdr, msgData)
  2002. self:handle_RefreshHP(msgHdr, msgData)
  2003. end
  2004. -- damage hp
  2005. self.mNetMsgHandle[global.MsgType.MSG_SC_DAMAGE_HP] = function(msgHdr, msgData)
  2006. self:handle_Damage(msgHdr, msgData)
  2007. end
  2008. -- refresh speed
  2009. self.mNetMsgHandle[global.MsgType.MSG_SC_ACTOR_REFRESH_ACTOR_SPEED] = function(msgHdr, msgData)
  2010. self:handle_RefreshSpeed(msgHdr, msgData)
  2011. end
  2012. -- refresh monster speed
  2013. self.mNetMsgHandle[global.MsgType.MSG_SC_REFRESH_MONSTER_SPEED] = function(msgHdr, msgData)
  2014. self:handle_RefreshMonsterSpeed(msgHdr, msgData)
  2015. end
  2016. -- refresh name
  2017. self.mNetMsgHandle[global.MsgType.MSG_SC_ACTOR_NAME] = function(msgHdr, msgData)
  2018. self:handle_RefreshName(msgHdr, msgData)
  2019. end
  2020. -- sell
  2021. self.mNetMsgHandle[global.MsgType.MSG_SC_SELL_NOTICE] = function(msgHdr, msgData)
  2022. self:handle_Sell(msgHdr, msgData)
  2023. end
  2024. -- pick corpse
  2025. self.mNetMsgHandle[global.MsgType.MSG_SC_ACTION_PICK_CORPSE] = function(msgHdr, msgData)
  2026. self:handle_PickCorpse(msgHdr, msgData)
  2027. end
  2028. -- death fall down
  2029. self.mNetMsgHandle[global.MsgType.MSG_SC_NET_ACTOR_DEATH_FALL_DOWN] = function(msgHdr, msgData)
  2030. self:handle_DeathFallDown(msgHdr, msgData)
  2031. end
  2032. self.mNetMsgHandle[global.MsgType.MSG_SC_NET_ACTOR_DEATH_SKELETON] = function(msgHdr, msgData)
  2033. self:handle_DeathSkeleton(msgHdr, msgData)
  2034. end
  2035. -- death fall down
  2036. self.mNetMsgHandle[global.MsgType.MSG_SC_NET_PLAYER_REVIVE] = function(msgHdr, msgData)
  2037. self:handle_Revive(msgHdr, msgData)
  2038. end
  2039. -- out of view
  2040. self.mNetMsgHandle[global.MsgType.MSG_SC_NET_PLAYER_OUT_OF_VIEW] = function(msgHdr, msgData)
  2041. self:handle_OutOfView(msgHdr, msgData)
  2042. end
  2043. -- fly out effect
  2044. self.mNetMsgHandle[global.MsgType.MSG_SC_NET_PLAYER_FLY_OUT] = function(msgHdr, msgData)
  2045. self:handle_FlyOut(msgHdr, msgData)
  2046. end
  2047. self.mNetMsgHandle[global.MsgType.MSG_SC_NET_PLAYER_FLY_OUT_2] = function(msgHdr, msgData)
  2048. self:handle_FlyOut2(msgHdr, msgData)
  2049. end
  2050. -- buff update
  2051. self.mNetMsgHandle[global.MsgType.MSG_SC_ACTOR_BUFF_INIT] = function(msgHdr, msgData)
  2052. global.BuffManager:handleBuffInit(msgHdr, msgData)
  2053. end
  2054. self.mNetMsgHandle[global.MsgType.MSG_SC_ACTOR_BUFF_ADD] = function(msgHdr, msgData)
  2055. global.BuffManager:handleBuffAdd(msgHdr, msgData)
  2056. end
  2057. self.mNetMsgHandle[global.MsgType.MSG_SC_ACTOR_BUFF_RMV] = function(msgHdr, msgData)
  2058. global.BuffManager:handleBuffRmv(msgHdr, msgData)
  2059. end
  2060. -- actor icons
  2061. self.mNetMsgHandle[global.MsgType.MSG_SC_ACTOR_ICONS_UPDATE] = function(msgHdr, msgData)
  2062. self:handle_Icons(msgHdr, msgData)
  2063. end
  2064. -- actor title
  2065. self.mNetMsgHandle[global.MsgType.MSG_SC_ACTOR_TITLE_UPDATE] = function(msgHdr, msgData)
  2066. self:handle_Title(msgHdr, msgData)
  2067. end
  2068. -- actor effect
  2069. self.mNetMsgHandle[global.MsgType.MSG_SC_ACTOR_EFFECT_UPDATE] = function(msgHdr, msgData)
  2070. global.ActorEffectManager:handle_ActorEffectUpdate(msgHdr, msgData)
  2071. end
  2072. -- actor auto mining
  2073. self.mNetMsgHandle[global.MsgType.MSG_SM_ACTOR_AUTO_MINING] = function(msgHdr, msgData)
  2074. self:handle_AutoMining(msgHdr, msgData)
  2075. end
  2076. -- actor relevel
  2077. self.mNetMsgHandle[global.MsgType.MSG_SC_ACTOR_RELEVEL] = function(msgHdr, msgData)
  2078. self:handle_ActorReLevel(msgHdr, msgData)
  2079. end
  2080. end
  2081. return gameMapController