Files
fc/server/tools/gen_data/cfg/unit_other_part_data.erl
2026-05-23 22:10:14 +08:00

294 lines
13 KiB
Erlang

%%----------------------------------------------------
%% 数据配置文件
%% @author whjing2011@gmail.com
%%----------------------------------------------------
-module(unit_other_part_data).
-export([cfg/0]).
-include("data_config.hrl").
-include("common.hrl").
cfg() ->
#data_cfg{
name = unit_data
,lua_name = unit_data
,desc = "单位配置数据"
,source = "unit_other_part_data.xml"
,target = "unit_data.erl"
,inc = ["common.hrl", "unit.hrl", "attr.hrl"]
,callback = [
{{check_unit_data, 0, ""}, cb_fun, handle, {get_all_fun, "
check_unit_data() ->
[check_unit_data_id(Id) || Id <- all_ids()].
check_unit_data_id(Id) ->
case unit_data:get_monsters(Id) of
[_ | _] ->
check_unit_data_id_scene(Id);
_ ->
case unit_data:get_attr(Id) of
#attr{atk = Atk} when Atk > 0 ->
check_unit_data_id_combat(Id);
_ -> pass
end
end."}}
,{check_unit_data_id_scene, cb_fun, handle, {get_all_fun,"
check_unit_data_id_scene(Id) ->
case is_check_data({unit_id_scene, Id}) of
true ->
case unit_data:get(Id) of
#unit_data{} ->
[check_unit_data_id_combat(Id1) || Id1 <- unit_data:get_monsters(Id), Id1 > 0];
_ ->
ok
end;
_ -> pass
end.
check_unit_data_id_combat(Id) ->
case is_check_data({unit_id_combat, Id}) of
true ->
case unit_data:get(Id) of
#unit_data{} ->
Attr = case unit_data:get_attr_mode(Id) of
0 -> unit_data:get_attr(Id);
{lev, ModeId, _} ->
unit_data:get_attr_by_lev(ModeId, 1);
ModeId ->
unit_data:get_attr_by_lev(ModeId, 1)
end,
case Attr of
#attr{hp_max = 0} -> ?DATA_ERR(\"unit_id ~w, hp_max:0\", [Id]);
_ -> pass
end,
case unit_data:get_skill_order(Id) of
L1 = [_ | _] ->
[skill_data:check_skill_data_active(SkillId, {unit_data_skill_order, Id}) || SkillId <- L1];
_ -> pass
end,
skill_data:check_skill_data_normal(unit_data:get_active_skills(Id), {unit_data_id, Id}),
[skill_data:check_skill_data_active(SkillId, {unit_data_active_skill, Id}) || SkillId <- unit_data:get_active_skills(Id)],
[skill_data:check_skill_data_passive(SkillId, {unit_data_passive_skill, Id}) || SkillId <- unit_data:get_passive_skills(Id)];
_ -> pass
end;
_ -> pass
end.
is_check_data(Key) ->
Map = erlang:get(check_info),
put(check_info, maps:put(Key, 1, Map)),
maps:get(Key, Map, 0) =:= 0.
all_ids() ->
lists:concat([
list_ids0()
,unit_part1_data:all_ids()
,unit_part2_data:all_ids()
,unit_part3_data:all_ids()
]).
list_ids0() -> []."}}
,{get, cb_fun, handle, {get_all_fun, "
get(UnitId) ->
case unit_part1_data:get(UnitId) of
undefined ->
case unit_part2_data:get(UnitId) of
undefined -> unit_part3_data:get(UnitId);
Ret -> Ret
end;
Ret -> Ret
end."
}}
,{get_attr, cb_fun, handle, {get_all_fun,"
get_attr(UnitId) ->
case unit_part1_data:get_attr(UnitId) of
undefined ->
case unit_part2_data:get_attr(UnitId) of
undefined -> unit_part3_data:get_attr(UnitId);
Ret -> Ret
end;
Ret -> Ret
end.
"}}
,{get_active_skills, cb_fun, handle, {get_all_fun, "
get_active_skills(UnitId) ->
case unit_part1_data:get_active_skills(UnitId) of
[] ->
case unit_part2_data:get_active_skills(UnitId) of
[] -> unit_part3_data:get_active_skills(UnitId);
Ret -> Ret
end;
Ret -> Ret
end.
"}}
,{get_passive_skills, cb_fun, handle, {get_all_fun, "
get_passive_skills(UnitId) ->
case unit_part1_data:get_passive_skills(UnitId) of
[] ->
case unit_part2_data:get_passive_skills(UnitId) of
[] -> unit_part3_data:get_passive_skills(UnitId);
Ret -> Ret
end;
Ret -> Ret
end.
"}}
,{get_skill_show, cb_fun, handle, {get_all_fun, "
get_skill_show(UnitId) ->
case unit_part1_data:get_skill_show(UnitId) of
[] ->
case unit_part2_data:get_skill_show(UnitId) of
[] -> unit_part3_data:get_skill_show(UnitId);
Ret -> Ret
end;
Ret -> Ret
end.
"}}
,{get_monsters, cb_fun, handle, {get_all_fun, "
get_monsters(UnitId) ->
case unit_part1_data:get_monsters(UnitId) of
undefined ->
case unit_part2_data:get_monsters(UnitId) of
undefined -> unit_part3_data:get_monsters(UnitId);
Ret -> Ret
end;
Ret -> Ret
end.
"}}
,{get_attr_mode, cb_fun, handle, {get_all_fun, "
get_attr_mode(UnitId) ->
case unit_part1_data:get_attr_mode(UnitId) of
0 ->
case unit_part2_data:get_attr_mode(UnitId) of
0 -> unit_part3_data:get_attr_mode(UnitId);
Ret -> Ret
end;
Ret -> Ret
end.
"}}
,{get_multi_wave, cb_fun, handle, {get_all_fun, "
get_multi_wave(UnitId) ->
case unit_part1_data:get_multi_wave(UnitId) of
[] ->
case unit_part2_data:get_multi_wave(UnitId) of
[] -> unit_part3_data:get_multi_wave(UnitId);
Ret -> Ret
end;
Ret -> Ret
end.
"}}
,{get_combat_map, cb_fun, handle, {get_all_fun, "
get_combat_map(UnitId) ->
case unit_part1_data:get_combat_map(UnitId) of
90001 ->
case unit_part2_data:get_combat_map(UnitId) of
90001 -> unit_part3_data:get_combat_map(UnitId);
Ret -> Ret
end;
Ret -> Ret
end.
"}}
,{get_skill_order, cb_fun, handle, {get_all_fun, "
get_skill_order(UnitId) ->
case unit_part1_data:get_skill_order(UnitId) of
undefined ->
case unit_part2_data:get_skill_order(UnitId) of
undefined -> unit_part3_data:get_skill_order(UnitId);
Ret -> Ret
end;
Ret -> Ret
end.
"}}
,{get_mon_ai, cb_fun, handle, {get_all_fun, "
get_mon_ai(UnitId) ->
case unit_part1_data:get_mon_ai(UnitId) of
undefined ->
case unit_part2_data:get_mon_ai(UnitId) of
undefined -> unit_part3_data:get_mon_ai(UnitId);
Ret -> Ret
end;
Ret -> Ret
end.
"}}
,{{get_attr_by_lev, 2, "get_attr_by_lev(Id, Lev)->?ERR(\"get attr by lev error id ~w, lev ~w\", [Id, Lev]),#attr{}."},
cb_fun, handle, {get_fun, ["属性模型"], "get_attr_by_lev(~s, Lev) when Lev =< ~s ->
#attr{atk = ~s
,def = ~s
,def_p = ~s
,def_s = ~s
,hp_max = ~s
,speed = ~s
,hit_rate = ~s
,dodge_rate = ~s
,crit_rate = ~s
,crit_ratio = ~s
,hit_magic = ~s
,dodge_magic = ~s
,dam = ~s
,res = ~s
,cure = ~s
,be_cure = ~s};", [id, lev, atk, def, def_p, def_s, hp_max, speed, hit_rate, dodge_rate, crit_rate, crit_ratio, hit_magic, dodge_magic, dam, res, cure, be_cure]}}
]
,callback_cli = [
{unit1, cb_fun_lua, handle, {val_str, ["NPC", "ELEM"], [bid], {mod,[all,client,monster,multi_wave]}}}
, {button, cb_fun_lua, handle, {key_val, ["按钮配置"], [id], all}}
]
,callback_json = [
{unit1, cb_fun_json, handle, {val, ["NPC", "ELEM"], [bid], {mod,[all,client,monster,multi_wave]}}}
]
,sheet = [
{["NPC", "ELEM"], [
#f_column{type = int, name = bid, desc = "编号", primary = true, mod = all}
,#f_column{type = bstr, name = name, desc = "名称", mod = all}
,#f_column{type = int, name = career, desc = "职业", mod = all}
,#f_column{type = kv, name = sex, desc = "性别", kv_type = sex, mod = all}
,#f_column{type = int, name = lev, desc = "等级", mod = all}
,#f_column{type = kv, name = type, desc = "类型", kv_type = unit_type, mod = server}
,#f_column{type = kv, name = sub_type, desc = "类型(客)", kv_type = unit_type_cli, mod = client}
,#f_column{type = kv, name = minor_type, desc = "逻辑类型", kv_type = [{"神界冒险",2},{"其他", 1}], mod = server}
,#f_column{type = kv, name = lock, desc = "是否独占", kv_type = bool, mod = server}
,#f_column{type = term, name = data, desc = "扩展字段", mod = server}
,#f_column{type = term, name = args, desc = "客户端字段", mod = client}
,#f_column{type = bstr, name = halo_id, desc = "光环", mod = client}
,#f_column{type = bstr, name = body_id, desc = "资源ID", mod = client}
,#f_column{type = term, name = talk, desc = "说话列表", mod = client}
,#f_column{type = term, name = button, desc = "固定按钮", mod = client}
,#f_column{type = int, name = model_size, desc = "模型大小", mod = client}
,#f_column{type = kv, name = dir, desc = "场景朝向", kv_type = [{"右下", 4}, {"正下", 5}, {"左下", 6}], mod = client}
,#f_column{type = kv, name = cli_create, desc = "客户端创建", kv_type = bool, mod = all}
]}
, {["按钮配置"], [
#f_column{type = int, name = id, desc = "编号", primary = true, mod = client}
,#f_column{type = bstr, name = name, desc = "名称", mod = client}
,#f_column{type = int, name = type, desc = "类型", mod = client}
,#f_column{type = int, name = priority, desc = "优先级", mod = client}
,#f_column{type = kv, kv_type = bool, name = is_auto, desc = "是否自动", mod = client}
,#f_column{type = term, name = ext, desc = "扩展参数", mod = client}
,#f_column{type = term, name = condition, desc = "限制", mod = client}
,#f_column{type = term, name = show_cond, desc = "显示限制", mod = client}
]}
,{["属性模型"], [
#f_column{type = int, name = id, desc = "ID", mod = all}
,#f_column{type = int, name = lev, desc = "等级", mod = attr}
,#f_column{type = int, name = atk, desc = "攻击", mod = attr, val = "0"}
,#f_column{type = int, name = def, desc = "防御", mod = attr, val = "0"}
,#f_column{type = int, name = def_p, desc = "物理防御", mod = attr, val = "0"}
,#f_column{type = int, name = def_s, desc = "法术防御", mod = attr, val = "0"}
,#f_column{type = int, name = hp_max, desc = "气血上限", mod = attr, val = "0"}
,#f_column{type = int, name = speed, desc = "速度", mod = attr, val = "0"}
,#f_column{type = int, name = hit_rate, desc = "命中", mod = attr, val = "0"}
,#f_column{type = int, name = dodge_rate, desc = "闪避", mod = attr, val = "0"}
,#f_column{type = int, name = crit_rate, desc = "暴击", mod = attr, val = "0"}
,#f_column{type = int, name = crit_ratio, desc = "暴伤", mod = attr, val = "0"}
,#f_column{type = int, name = hit_magic, desc = "效果命中", mod = attr, val = "0"}
,#f_column{type = int, name = dodge_magic, desc = "效果闪避", mod = attr, val = "0"}
,#f_column{type = int, name = dam, desc = "易伤", mod = attr, val = "0"}
,#f_column{type = int, name = res, desc = "免伤", mod = attr, val = "0"}
,#f_column{type = int, name = cure, desc = "治疗提升", val = "0"}
,#f_column{type = int, name = be_cure, desc = "被治疗提升", val = "0"}
]}
]
}.