源战役客户端
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 

316 lignes
11 KiB

--[[
服务器下发的怪物信息结构体
]]
MonsterVo = MonsterVo or BaseClass(BaseVo)
local MonsterVo = MonsterVo
local UserMsgAdapter_ReadFmt = UserMsgAdapter.ReadFmt
local UserMsgAdapter_ReadFmt2 = UserMsgAdapter.ReadFmt2
MonsterVo.Act_Flag = {
COLLECT = 1, --点击采集
SEAL = 2, --点击封印
}
function MonsterVo:__init()
end
function MonsterVo:__defineVar()
return {
_class_type = self,
--_cid = self._id,
_iid = _in_obj_ins_id,
_use_delete_method = false,
vo_type = SceneBaseType.Monster,
pos_x = 0, --X坐标(int16)
pos_y = 0 ,--Y坐标(int16)
instance_id = 0 , --怪物唯一标识(int32)
type_id = 0 , --怪物类型ID(int32)
hp = 100, --怪物当前血量(int32)
maxHp = 100 ,--怪物最大血量(int32)
level = 1, --怪物等级(int16)
name = "", --怪物名字(string)
move_speed = 160, --怪物速度(int16)
monster_res = 0 ,--怪物资源(int32)
effect_res = "", --特效资源(string)
texture_res = 0,
weapon_id = 0,
attack_mode = 0 ,--攻击类型(int8) 0:近战 1:远程
type = 0, --类型(int8) 0普通怪,1采集怪,2任务采集怪,3护送怪,4拾取怪,6进击怪,7塔防怪,9自动进击怪
quality = 0, --品级(int8) 0白/1绿/2蓝/3紫/4橙
guaji_flag = 0 ,--是否挂机(int8) 0是,1否
boss_type = 0 ,--Boss类型(int8) 0普通怪,1普通野外怪,2精英怪物,3赏金幻魔,4世界BOSS,5不死BOSS,6副本BOSS,7任务BOSS
pick_time = 0, --采集所需时间(int32)
master_id = 0, --主人ID(int32)
can_pick = 1 , --是否可点击(0否 1是)
can_attack = 1,--是否可攻击(0否 1是)
warGroup = 0 , --攻击阵营,默认0为无阵营
realm = 0 , --国家/阵营(1|2|3)
prePoseState = PoseState.STAND,
poseState = PoseState.STAND,
guild_id = 0,
role_id = 0,
birth_angle = nil,
five_element = 0,
title = 0,
protect_time = 0,--无敌特效消失时间
head_wear_id = 0,
head_wear_chartlet_id = 0,
career = 0,
-----------------------------一下是客户端战斗用到的属性------------------------------------------------------------------------
hide_flag = 0, --是否隐藏
ghost_mode = 0, --是否幽灵模式
}
end
function MonsterVo:ResetData()
-- self.pos_x = 0 --X坐标(int16)
-- self.pos_y = 0 --Y坐标(int16)
-- self.instance_id = 0 --怪物唯一标识(int32)
-- self.type_id = 0 --怪物类型ID(int32)
-- self.hp = 100 --怪物当前血量(int32)
-- self.maxHp = 100 --怪物最大血量(int32)
-- self.level = 1 --怪物等级(int16)
-- self.name = "" --怪物名字(string)
-- self.move_speed = 160 --怪物速度(int16)
-- self.monster_res = 0 --怪物资源(int32)
-- self.effect_res = "" --特效资源(string)
-- self.texture_res = 0
-- self.weapon_id = 0
-- self.attack_mode = 0 --攻击类型(int8) 0:近战 1:远程
-- self.type = 0 --类型(int8) 0普通怪,1采集怪,2任务采集怪,3护送怪,4拾取怪,6进击怪,7塔防怪,9自动进击怪
-- self.quality = 0 --品级(int8) 0白/1绿/2蓝/3紫/4橙
-- self.guaji_flag = 0 --是否挂机(int8) 0是,1否
-- self.boss_type = 0 --Boss类型(int8) 0普通怪,1普通野外怪,2精英怪物,3赏金幻魔,4世界BOSS,5不死BOSS,6副本BOSS,7任务BOSS
-- self.pick_time = 0 --采集所需时间(int32)
-- self.master_id = 0 --主人ID(int32)
-- self.can_pick = 1 --是否可点击(0否 1是)
-- self.can_attack = 1--是否可攻击(0否 1是)
-- self.warGroup = 0 --攻击阵营,默认0为无阵营
-- self.realm = 0 --国家/阵营(1|2|3)
-- self.prePoseState = PoseState.STAND
-- self.poseState = PoseState.STAND
-- self.guild_id = 0
-- self.birth_angle = nil
-- self.title = 0
self.owner_id = 0 --怪物所属玩家id
self.owner_name = "" --怪物所属玩家名字
self.cfg_data = nil
self.is_armor = 0 --是否霸体
self.icon_scale = 1
self.is_blood_bar = 1
self.color = 0
self.birth_angle = nil
self.birth_effect_res = nil --出生特效
self.foot_effect_res = nil--脚下特效
self.classification = nil --怪物分类名字
self.load_immediately = 0 --是否立即加载怪物
self.is_hit_ac = 0 --是否需要受击动作
self.is_hide_hp = nil
-- self.hide_flag = 0 --是否隐藏
-- self.ghost_mode = 0 --是否幽灵模式
end
--[[
int:16 X坐标
int:16 Y坐标
int:32 唯一标识
int:32 怪物ID
int:64 hp
int:64 hp_lim
int:16 等级
string 名字
int:16 速度
int:32 怪物资源
int: 8 0进战 1远程
int: 8 类型 0为怪物 1采集 2旗子 3护送车队
int: 8 0白/1绿/2蓝/3紫/4橙
int: 8 是否挂机:0是,1否
int: 8 BOSS类型 0普通怪,1野外BOSS,2宠物BOSS,3世界BOSS,4社团BOSS,5副本BOSS,6爬塔BOSS,7塔防BOSS
int:32 采集所需时间
int:8 是否可点击(0 不可点击, 1可点击)
int:8 是否可攻击(0 不可攻击, 1可攻击)
int:8 是否隐身(0否,1是)
int:8 是否幽灵(0否, 1是)
int:16 分组id
int:64 所属社团id
int:64 所属玩家id
]]
function MonsterVo:ReadFromProtocal()
local len
self.pos_x, --X坐标(int16)
self.pos_y, --Y坐标(int16)
self.instance_id, --怪物唯一标识(int32)
self.type_id, --怪物类型ID(int32)
self.hp, --怪物当前血量(int32)
self.maxHp, --怪物最大血量(int32)
self.level, --怪物等级(int16)
self.name, --怪物名字(string)
self.move_speed, --怪物速度(int16)
self.monster_res, --怪物资源(int32)
self.effect_res, --特效资源(string)
self.texture_res, --贴图id(int32)
self.weapon_id, --武器id(int32)
self.attack_mode, --攻击类型(int8) 0:近战 1:远程
self.type, --类型(int8) 0为怪物 1采集 2旗子 3护送车队
self.quality, --品级(int8) 0白/1绿/2蓝/3紫/4橙
self.guaji_flag, --是否挂机(int8) 0是,1否
self.boss_type, --Boss类型(int8) 0普通怪,1普通野外怪,2精英怪物,3本服BOSS,4跨服BOSS,5活动BOSS,6副本BOSS,7任务BOSS
self.pick_time, --采集所需时间(int32)
self.can_pick,
self.can_attack,
self.hide_flag, --是否不可见(int8)
self.ghost_mode, --幽灵状态(int8)
self.warGroup,
self.guild_id, --社团ID
self.role_id, --所属角色ID
self.birth_angle, --出生角度
self.owner_id, --怪物所属玩家id
self.owner_name, --怪物所属玩家名字
self.title,--头衔
self.protect_time, --PK保护结束时间搓
len = UserMsgAdapter_ReadFmt("hhiillhshisiicccccicccclllhlsiih")
self.activity_flags = {}
for i = 1, len do
local obj = {}
obj.key = UserMsgAdapter_ReadFmt("c")
obj.value = UserMsgAdapter_ReadFmt("i")
table.insert(self.activity_flags, obj)
end
self.buff_list = {}
local buff_num = UserMsgAdapter_ReadFmt("h")
for i = 1,buff_num do
buff = FightVo.initBuff()
buff.iconType, --int:16 类型
buff.buff_effect_id, --int:16 特效配置id
buff.id, --int:32 buff技能Id
buff.level, --int:8 buff技能等级
buff.diejia, --int:8 叠加数
buff.integer, --int:32 整数(有符号)
buff.decimals, --int:32 小数(有符号,显示时要除以1000)
buff.period = --int:64 到期unix时间戳, 客户端显示要用这个时间-服务端时间
UserMsgAdapter_ReadFmt2("hhiccIIl")
buff.decimals = UnsignToSigned(buff.decimals)
if self.buff_list[buff.iconType] == nil then
self.buff_list[buff.iconType] = {}
end
self.buff_list[buff.iconType][buff.id] = buff
end
self:SetBasePropertyFromConfig()
if self.boss_type == 3 or self.boss_type == 9 then
-- 根据boss类型设置脚底法阵
self.foot_effect_res = "effect_bossfazhen01"
elseif self.boss_type == 10 then --星域幻魔精英怪
self.foot_effect_res = "effect_bossfazhen02"
end
--武器根据职业显示不同模型
if self.type_id == GuideModel.WeaponMonster then
local career = RoleManager.Instance.mainRoleInfo.career
if career == 1 then
self.monster_res = 5010101
self.icon_scale = 10
self.birth_angle = 0
self.foot_effect_res = "effect_monster_caijiwuchangzhu01"
elseif career == 2 then
self.monster_res = 5110102
self.icon_scale = 10
self.birth_angle = 0
self.foot_effect_res = "effect_monster_caijiwuchangzhu01"
elseif career == 4 then
self.monster_res = 5010104
self.icon_scale = 10
self.birth_angle = 0
self.foot_effect_res = "effect_monster_caijiwuchangzhu01"
end
elseif self.type_id == 2300051 then -- 宝宝副本隐藏宝箱怪
BaseDungeonModel:getInstance():Fire(BaseDungeonModel.SHOW_BABYDUN_SPEICAL_TIP, self.type_id)
elseif self.type == MonsterType.CSGWAR then--跨国团战设置友军不可被点击
local my_group = RoleManager.Instance.mainRoleInfo.warGroup
local same_group = (my_group > 0 and my_group == self.warGroup)
self.can_pick = same_group and 0 or 1
end
-- print("创建怪物:",self.name, self.hp,self.maxHp, self.type_id, self.weapon_id, self.title, self.warGroup)
end
function MonsterVo:SetBasePropertyFromConfig()
self:CacheCfgData()
if self.cfg_data == nil then
return
end
self.is_armor=self.cfg_data.is_armor or 0 --是否霸体
--print("怪物资源缩放:", self.cfg_data.icon_scale, tonumber(self.cfg_data.icon_scale))
self.icon_scale = tonumber(self.cfg_data.icon_scale)
self.is_blood_bar = tonumber(self.cfg_data.is_blood_bar)
self.color = tonumber(self.cfg_data.color)
if self.birth_angle == 0 then
self.birth_angle = tonumber(self.cfg_data.direction)
if self.birth_angle == -1 then
self.birth_angle = nil
end
end
if Config.ConfigGuildWar.MonsterDirection[self.type_id] then
self.birth_angle = Config.ConfigGuildWar.MonsterDirection[self.type_id]
end
if Config.ConfigDungeonClient.monster_direction[self.type_id] then
self.birth_angle = Config.ConfigDungeonClient.monster_direction[self.type_id]
end
if Config.ConfigKFGuildWar.MonsterDirection[self.type_id] then
self.birth_angle = Config.ConfigKFGuildWar.MonsterDirection[self.type_id]
end
if self.type_id == Config.ConfigTaskEffect.MonsterSakuraTypeID then
self.birth_angle = 285
end
self.birth_effect_res = Trim(self.cfg_data.mon_state) or ""
self.classification = Trim(self.cfg_data.classification) or "" --怪物分类名字
self.load_immediately = tonumber(self.cfg_data.load_immediately) or 0 --是否立即加载怪物
self.is_hit_ac = tonumber(self.cfg_data.is_hit_ac) or 0 --是否需要受击动作
self.is_hide_hp = (self.cfg_data.is_hide_hp==1)
self.career = self.cfg_data.career or 1
self.head_wear_id = self.cfg_data.headwear_id or 0
self.head_wear_chartlet_id = self.cfg_data.headwear_texture or 0
-- print("怪物显示血条名字怪物显示血条名字", self.name, self.is_hide_hp, self.birth_angle == -1 , self.is_hit_ac, self.is_hit_ac ~= 0)
end
function MonsterVo:CacheCfgData()
if self.cfg_data == nil then
self.cfg_data = ConfigItemMgr.Instance:GetMonsterDataItem(self.type_id)
end
end
function MonsterVo:GetFashionTextureId()
if self.texture_res and tonumber(self.texture_res) ~= 0 then
return self.monster_res .. self.texture_res
end
end
function MonsterVo:GetRoleHeadId(block)
local show = not block
if show then
return self.head_wear_id,self.head_wear_chartlet_id
end
end
--获取相应标志
-- 活动类型 1:社团争霸 2:护送劫字 3:跨服社团战 4:婚礼 5:巡游 6 大乱斗
-- (0:原形象 1:冲车 2:炮车)
function MonsterVo:GetFlagsByKey(key)
local value = 0
if self.activity_flags then
for i,v in pairs(self.activity_flags) do
if v.key == key then
value = v.value
break
end
end
end
return value
end