源战役客户端
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

315 Zeilen
11 KiB

  1. --[[
  2. ]]
  3. MonsterVo = MonsterVo or BaseClass(BaseVo)
  4. local MonsterVo = MonsterVo
  5. local UserMsgAdapter_ReadFmt = UserMsgAdapter.ReadFmt
  6. local UserMsgAdapter_ReadFmt2 = UserMsgAdapter.ReadFmt2
  7. MonsterVo.Act_Flag = {
  8. COLLECT = 1, --点击采集
  9. SEAL = 2, --点击封印
  10. }
  11. function MonsterVo:__init()
  12. end
  13. function MonsterVo:__defineVar()
  14. return {
  15. _class_type = self,
  16. --_cid = self._id,
  17. _iid = _in_obj_ins_id,
  18. _use_delete_method = false,
  19. vo_type = SceneBaseType.Monster,
  20. pos_x = 0, --X坐标(int16)
  21. pos_y = 0 ,--Y坐标(int16)
  22. instance_id = 0 , --怪物唯一标识(int32)
  23. type_id = 0 , --怪物类型ID(int32)
  24. hp = 100, --怪物当前血量(int32)
  25. maxHp = 100 ,--怪物最大血量(int32)
  26. level = 1, --怪物等级(int16)
  27. name = "", --怪物名字(string)
  28. move_speed = 160, --怪物速度(int16)
  29. monster_res = 0 ,--怪物资源(int32)
  30. effect_res = "", --特效资源(string)
  31. texture_res = 0,
  32. weapon_id = 0,
  33. attack_mode = 0 ,--攻击类型(int8) 0:近战 1:远程
  34. type = 0, --类型(int8) 0普通怪,1采集怪,2任务采集怪,3护送怪,4拾取怪,6进击怪,7塔防怪,9自动进击怪
  35. quality = 0, --品级(int8) 0白/1绿/2蓝/3紫/4橙
  36. guaji_flag = 0 ,--是否挂机(int8) 0是,1否
  37. boss_type = 0 ,--Boss类型(int8) 0普通怪,1普通野外怪,2精英怪物,3赏金幻魔,4世界BOSS,5不死BOSS,6副本BOSS,7任务BOSS
  38. pick_time = 0, --采集所需时间(int32)
  39. master_id = 0, --主人ID(int32)
  40. can_pick = 1 , --是否可点击(0否 1是)
  41. can_attack = 1,--是否可攻击(0否 1是)
  42. warGroup = 0 , --攻击阵营,默认0为无阵营
  43. realm = 0 , --国家/阵营(1|2|3)
  44. prePoseState = PoseState.STAND,
  45. poseState = PoseState.STAND,
  46. guild_id = 0,
  47. role_id = 0,
  48. birth_angle = nil,
  49. five_element = 0,
  50. title = 0,
  51. protect_time = 0,--无敌特效消失时间
  52. head_wear_id = 0,
  53. head_wear_chartlet_id = 0,
  54. career = 0,
  55. -----------------------------一下是客户端战斗用到的属性------------------------------------------------------------------------
  56. hide_flag = 0, --是否隐藏
  57. ghost_mode = 0, --是否幽灵模式
  58. }
  59. end
  60. function MonsterVo:ResetData()
  61. -- self.pos_x = 0 --X坐标(int16)
  62. -- self.pos_y = 0 --Y坐标(int16)
  63. -- self.instance_id = 0 --怪物唯一标识(int32)
  64. -- self.type_id = 0 --怪物类型ID(int32)
  65. -- self.hp = 100 --怪物当前血量(int32)
  66. -- self.maxHp = 100 --怪物最大血量(int32)
  67. -- self.level = 1 --怪物等级(int16)
  68. -- self.name = "" --怪物名字(string)
  69. -- self.move_speed = 160 --怪物速度(int16)
  70. -- self.monster_res = 0 --怪物资源(int32)
  71. -- self.effect_res = "" --特效资源(string)
  72. -- self.texture_res = 0
  73. -- self.weapon_id = 0
  74. -- self.attack_mode = 0 --攻击类型(int8) 0:近战 1:远程
  75. -- self.type = 0 --类型(int8) 0普通怪,1采集怪,2任务采集怪,3护送怪,4拾取怪,6进击怪,7塔防怪,9自动进击怪
  76. -- self.quality = 0 --品级(int8) 0白/1绿/2蓝/3紫/4橙
  77. -- self.guaji_flag = 0 --是否挂机(int8) 0是,1否
  78. -- self.boss_type = 0 --Boss类型(int8) 0普通怪,1普通野外怪,2精英怪物,3赏金幻魔,4世界BOSS,5不死BOSS,6副本BOSS,7任务BOSS
  79. -- self.pick_time = 0 --采集所需时间(int32)
  80. -- self.master_id = 0 --主人ID(int32)
  81. -- self.can_pick = 1 --是否可点击(0否 1是)
  82. -- self.can_attack = 1--是否可攻击(0否 1是)
  83. -- self.warGroup = 0 --攻击阵营,默认0为无阵营
  84. -- self.realm = 0 --国家/阵营(1|2|3)
  85. -- self.prePoseState = PoseState.STAND
  86. -- self.poseState = PoseState.STAND
  87. -- self.guild_id = 0
  88. -- self.birth_angle = nil
  89. -- self.title = 0
  90. self.owner_id = 0 --怪物所属玩家id
  91. self.owner_name = "" --怪物所属玩家名字
  92. self.cfg_data = nil
  93. self.is_armor = 0 --是否霸体
  94. self.icon_scale = 1
  95. self.is_blood_bar = 1
  96. self.color = 0
  97. self.birth_angle = nil
  98. self.birth_effect_res = nil --出生特效
  99. self.foot_effect_res = nil--脚下特效
  100. self.classification = nil --怪物分类名字
  101. self.load_immediately = 0 --是否立即加载怪物
  102. self.is_hit_ac = 0 --是否需要受击动作
  103. self.is_hide_hp = nil
  104. -- self.hide_flag = 0 --是否隐藏
  105. -- self.ghost_mode = 0 --是否幽灵模式
  106. end
  107. --[[
  108. int:16 X坐标
  109. int:16 Y坐标
  110. int:32
  111. int:32 ID
  112. int:64 hp
  113. int:64 hp_lim
  114. int:16
  115. string
  116. int:16
  117. int:32
  118. int: 8 0 1
  119. int: 8 0 1 2 3
  120. int: 8 0/1绿/2/3/4
  121. int: 8 01
  122. int: 8 BOSS类型 01BOSS2BOSS3BOSS4BOSS5BOSS6BOSS7BOSS
  123. int:32
  124. int:8 (0 1)
  125. int:8 (0 1)
  126. int:8 (01)
  127. int:8 (0, 1)
  128. int:16 id
  129. int:64 id
  130. int:64 id
  131. ]]
  132. function MonsterVo:ReadFromProtocal()
  133. local len
  134. self.pos_x, --X坐标(int16)
  135. self.pos_y, --Y坐标(int16)
  136. self.instance_id, --怪物唯一标识(int32)
  137. self.type_id, --怪物类型ID(int32)
  138. self.hp, --怪物当前血量(int32)
  139. self.maxHp, --怪物最大血量(int32)
  140. self.level, --怪物等级(int16)
  141. self.name, --怪物名字(string)
  142. self.move_speed, --怪物速度(int16)
  143. self.monster_res, --怪物资源(int32)
  144. self.effect_res, --特效资源(string)
  145. self.texture_res, --贴图id(int32)
  146. self.weapon_id, --武器id(int32)
  147. self.attack_mode, --攻击类型(int8) 0:近战 1:远程
  148. self.type, --类型(int8) 0为怪物 1采集 2旗子 3护送车队
  149. self.quality, --品级(int8) 0白/1绿/2蓝/3紫/4橙
  150. self.guaji_flag, --是否挂机(int8) 0是,1否
  151. self.boss_type, --Boss类型(int8) 0普通怪,1普通野外怪,2精英怪物,3本服BOSS,4跨服BOSS,5活动BOSS,6副本BOSS,7任务BOSS
  152. self.pick_time, --采集所需时间(int32)
  153. self.can_pick,
  154. self.can_attack,
  155. self.hide_flag, --是否不可见(int8)
  156. self.ghost_mode, --幽灵状态(int8)
  157. self.warGroup,
  158. self.guild_id, --社团ID
  159. self.role_id, --所属角色ID
  160. self.birth_angle, --出生角度
  161. self.owner_id, --怪物所属玩家id
  162. self.owner_name, --怪物所属玩家名字
  163. self.title,--头衔
  164. self.protect_time, --PK保护结束时间搓
  165. len = UserMsgAdapter_ReadFmt("hhiillhshisiicccccicccclllhlsiih")
  166. self.activity_flags = {}
  167. for i = 1, len do
  168. local obj = {}
  169. obj.key = UserMsgAdapter_ReadFmt("c")
  170. obj.value = UserMsgAdapter_ReadFmt("i")
  171. table.insert(self.activity_flags, obj)
  172. end
  173. self.buff_list = {}
  174. local buff_num = UserMsgAdapter_ReadFmt("h")
  175. for i = 1,buff_num do
  176. buff = FightVo.initBuff()
  177. buff.iconType, --int:16 类型
  178. buff.buff_effect_id, --int:16 特效配置id
  179. buff.id, --int:32 buff技能Id
  180. buff.level, --int:8 buff技能等级
  181. buff.diejia, --int:8 叠加数
  182. buff.integer, --int:32 整数(有符号)
  183. buff.decimals, --int:32 小数(有符号,显示时要除以1000)
  184. buff.period = --int:64 到期unix时间戳, 客户端显示要用这个时间-服务端时间
  185. UserMsgAdapter_ReadFmt2("hhiccIIl")
  186. buff.decimals = UnsignToSigned(buff.decimals)
  187. if self.buff_list[buff.iconType] == nil then
  188. self.buff_list[buff.iconType] = {}
  189. end
  190. self.buff_list[buff.iconType][buff.id] = buff
  191. end
  192. self:SetBasePropertyFromConfig()
  193. if self.boss_type == 3 or self.boss_type == 9 then
  194. -- 根据boss类型设置脚底法阵
  195. self.foot_effect_res = "effect_bossfazhen01"
  196. elseif self.boss_type == 10 then --星域幻魔精英怪
  197. self.foot_effect_res = "effect_bossfazhen02"
  198. end
  199. --武器根据职业显示不同模型
  200. if self.type_id == GuideModel.WeaponMonster then
  201. local career = RoleManager.Instance.mainRoleInfo.career
  202. if career == 1 then
  203. self.monster_res = 5010101
  204. self.icon_scale = 10
  205. self.birth_angle = 0
  206. self.foot_effect_res = "effect_monster_caijiwuchangzhu01"
  207. elseif career == 2 then
  208. self.monster_res = 5110102
  209. self.icon_scale = 10
  210. self.birth_angle = 0
  211. self.foot_effect_res = "effect_monster_caijiwuchangzhu01"
  212. elseif career == 4 then
  213. self.monster_res = 5010104
  214. self.icon_scale = 10
  215. self.birth_angle = 0
  216. self.foot_effect_res = "effect_monster_caijiwuchangzhu01"
  217. end
  218. elseif self.type_id == 2300051 then -- 宝宝副本隐藏宝箱怪
  219. BaseDungeonModel:getInstance():Fire(BaseDungeonModel.SHOW_BABYDUN_SPEICAL_TIP, self.type_id)
  220. elseif self.type == MonsterType.CSGWAR then--跨国团战设置友军不可被点击
  221. local my_group = RoleManager.Instance.mainRoleInfo.warGroup
  222. local same_group = (my_group > 0 and my_group == self.warGroup)
  223. self.can_pick = same_group and 0 or 1
  224. end
  225. -- print("创建怪物:",self.name, self.hp,self.maxHp, self.type_id, self.weapon_id, self.title, self.warGroup)
  226. end
  227. function MonsterVo:SetBasePropertyFromConfig()
  228. self:CacheCfgData()
  229. if self.cfg_data == nil then
  230. return
  231. end
  232. self.is_armor=self.cfg_data.is_armor or 0 --是否霸体
  233. --print("怪物资源缩放:", self.cfg_data.icon_scale, tonumber(self.cfg_data.icon_scale))
  234. self.icon_scale = tonumber(self.cfg_data.icon_scale)
  235. self.is_blood_bar = tonumber(self.cfg_data.is_blood_bar)
  236. self.color = tonumber(self.cfg_data.color)
  237. if self.birth_angle == 0 then
  238. self.birth_angle = tonumber(self.cfg_data.direction)
  239. if self.birth_angle == -1 then
  240. self.birth_angle = nil
  241. end
  242. end
  243. if Config.ConfigGuildWar.MonsterDirection[self.type_id] then
  244. self.birth_angle = Config.ConfigGuildWar.MonsterDirection[self.type_id]
  245. end
  246. if Config.ConfigDungeonClient.monster_direction[self.type_id] then
  247. self.birth_angle = Config.ConfigDungeonClient.monster_direction[self.type_id]
  248. end
  249. if Config.ConfigKFGuildWar.MonsterDirection[self.type_id] then
  250. self.birth_angle = Config.ConfigKFGuildWar.MonsterDirection[self.type_id]
  251. end
  252. if self.type_id == Config.ConfigTaskEffect.MonsterSakuraTypeID then
  253. self.birth_angle = 285
  254. end
  255. self.birth_effect_res = Trim(self.cfg_data.mon_state) or ""
  256. self.classification = Trim(self.cfg_data.classification) or "" --怪物分类名字
  257. self.load_immediately = tonumber(self.cfg_data.load_immediately) or 0 --是否立即加载怪物
  258. self.is_hit_ac = tonumber(self.cfg_data.is_hit_ac) or 0 --是否需要受击动作
  259. self.is_hide_hp = (self.cfg_data.is_hide_hp==1)
  260. self.career = self.cfg_data.career or 1
  261. self.head_wear_id = self.cfg_data.headwear_id or 0
  262. self.head_wear_chartlet_id = self.cfg_data.headwear_texture or 0
  263. -- print("怪物显示血条名字怪物显示血条名字", self.name, self.is_hide_hp, self.birth_angle == -1 , self.is_hit_ac, self.is_hit_ac ~= 0)
  264. end
  265. function MonsterVo:CacheCfgData()
  266. if self.cfg_data == nil then
  267. self.cfg_data = ConfigItemMgr.Instance:GetMonsterDataItem(self.type_id)
  268. end
  269. end
  270. function MonsterVo:GetFashionTextureId()
  271. if self.texture_res and tonumber(self.texture_res) ~= 0 then
  272. return self.monster_res .. self.texture_res
  273. end
  274. end
  275. function MonsterVo:GetRoleHeadId(block)
  276. local show = not block
  277. if show then
  278. return self.head_wear_id,self.head_wear_chartlet_id
  279. end
  280. end
  281. --获取相应标志
  282. -- 活动类型 1:社团争霸 2:护送劫字 3:跨服社团战 4:婚礼 5:巡游 6 大乱斗
  283. -- (0:原形象 1:冲车 2:炮车)
  284. function MonsterVo:GetFlagsByKey(key)
  285. local value = 0
  286. if self.activity_flags then
  287. for i,v in pairs(self.activity_flags) do
  288. if v.key == key then
  289. value = v.value
  290. break
  291. end
  292. end
  293. end
  294. return value
  295. end