自定义国家阵营这个功能很多MOD也都有了,如领军者、1257AD等。不过我好像还没看到有人贴到论坛上,于是自己稍微写了下,发到论坛上与各位分享下。
这次代码有简单运用到python的语言
在script上方加上如下语句:
#add by xiaowei begin
def init_color_list():
faction_color_list = []
for color in xrange(len(color_list)):
faction_color_list.append((troop_set_slot, "trp_temp_array_c", color, color_list[color]))
return faction_color_list[:]
#add end by xiaowei
复制代码
然后在script脚本文件里加入以下语句。我放到了末尾的位置:
("init_color_list",init_color_list()),#add by xiaowei
复制代码
("get_HEX_code_xw",[
(store_script_param_1,":value"),
(assign,reg0,0),
(try_begin),
(eq,":value",0),
(assign,reg0,0x0),
(else_try),
(eq,":value",1),
(assign,reg0,0x1),
(else_try),
(eq,":value",2),
(assign,reg0,0x2),
(else_try),
(eq,":value",3),
(assign,reg0,0x3),
(else_try),
(eq,":value",4),
(assign,reg0,0x4),
(else_try),
(eq,":value",5),
(assign,reg0,0x5),
(else_try),
(eq,":value",6),
(assign,reg0,0x6),
(else_try),
(eq,":value",7),
(assign,reg0,0x7),
(else_try),
(eq,":value",8),
(assign,reg0,0x8),
(else_try),
(eq,":value",9),
(assign,reg0,0x9),
(else_try),
(eq,":value",10),
(assign,reg0,0xA),
(else_try),
(eq,":value",11),
(assign,reg0,0xB),
(else_try),
(eq,":value",12),
(assign,reg0,0xC),
(else_try),
(eq,":value",13),
(assign,reg0,0xD),
(else_try),
(eq,":value",14),
(assign,reg0,0xE),
(else_try),
(eq,":value",15),
(assign,reg0,0xF),
(try_end),
]),
复制代码
("change_RGB_to_HEX_xw",[
(store_script_param,":red",1),
(store_script_param,":green",2),
(store_script_param,":blue",3),
(store_div,":r_div_value",":red",16),
(store_mod,":r_mod_value",":red",16),
(store_div,":g_div_value",":green",16),
(store_mod,":g_mod_value",":green",16),
(store_div,":b_div_value",":blue",16),
(store_mod,":b_mod_value",":blue",16),
(call_script,"script_get_HEX_code_xw",":r_div_value"),
(assign,":r_div_value",reg0),
(val_mul,":r_div_value",0x100000),
(call_script,"script_get_HEX_code_xw",":r_mod_value"),
(assign,":r_mod_value",reg0),
(val_mul,":r_mod_value",0x10000),
(call_script,"script_get_HEX_code_xw",":g_div_value"),
(assign,":g_div_value",reg0),
(val_mul,":g_div_value",0x1000),
(call_script,"script_get_HEX_code_xw",":g_mod_value"),
(assign,":g_mod_value",reg0),
(val_mul,":g_mod_value",0x100),
(call_script,"script_get_HEX_code_xw",":b_div_value"),
(assign,":b_div_value",reg0),
(val_mul,":b_div_value",0x10),
(call_script,"script_get_HEX_code_xw",":b_mod_value"),
(assign,":b_mod_value",reg0),
(val_mul,":b_mod_value",0x1),
(assign,reg1,0),
(store_add,reg1,":r_div_value",":r_mod_value"),
(val_add,reg1,":g_div_value"),
(val_add,reg1,":g_mod_value"),
(val_add,reg1,":b_div_value"),
(val_add,reg1,":b_mod_value"),
]),#add by xiaowei
复制代码
("change_HEX_to_RGB_xw",[
(store_script_param,":hex",1),
(assign,":r_div_value",0),
(assign,":r_mod_value",0),
(assign,":g_div_value",0),
(assign,":g_mod_value",0),
(assign,":b_div_value",0),
(assign,":b_mod_value",0),
(assign,reg1,0),
(assign,reg2,0),
(assign,reg3,0),
(store_div,":r_div_value",":hex",0x100000),
(store_mul,":r_div_value_sub",":r_div_value",0x100000),
(store_sub,":hex_5",":hex",":r_div_value_sub"),
(store_div,":r_mod_value",":hex_5",0x10000),
(store_mul,":r_mod_value_sub",":r_mod_value",0x10000),
(store_sub,":hex_4",":hex_5",":r_mod_value_sub"),
(store_div,":g_div_value",":hex_4",0x1000),
(store_mul,":g_div_value_sub",":g_div_value",0x1000),
(store_sub,":hex_3",":hex_4",":g_div_value_sub"),
(store_div,":g_mod_value",":hex_3",0x100),
(store_mul,":g_mod_value_sub",":g_mod_value",0x100),
(store_sub,":hex_2",":hex_3",":g_mod_value_sub"),
(store_div,":b_div_value",":hex_2",0x10),
(store_mul,":b_div_value_sub",":b_div_value",0x10),
(store_sub,":hex_1",":hex_2",":b_div_value_sub"),
(store_div,":b_mod_value",":hex_1",0x1),
(try_begin),
(eq,"$g_is_hex",0),
(val_sub,":r_div_value",4080),
(try_end),
(val_mul,":r_div_value",16),
(store_add,reg1,":r_div_value",":r_mod_value"),
(val_mul,":g_div_value",16),
(store_add,reg2,":g_div_value",":g_mod_value"),
(val_mul,":b_div_value",16),
(store_add,reg3,":b_div_value",":b_mod_value"),
]),#add by xiaowei
复制代码
然后再进行初始化,把上面的init_color_list放到game_start里面
(call_script,"script_init_color_list"),#add by xiaowei
复制代码
相关图示:
图中有一个:from custom_faction_color import *#add by xiaowei
这是我自己编写的另一个py文件,主要存储了颜色的16进制代码,大家也可以到网上寻找相关颜色代码。我这个也是网页上随便搜索的。等会我会把这个颜色代码放到附件里给大家下载
这个怎么加,对于MODDER来说都应该很容易
("custom_faction_color", 0, mesh_load_window,
复制代码
然后加到营地菜单中
#add by xiaowei begin
("custom_faction_color",[],"custom_faction_color",
[
#init
(try_for_range,":cur_faction","fac_player_supporters_faction","fac_undeads"),
(faction_set_slot,":cur_faction",slot_faction_temp_slot,-1),
(try_end),
(start_presentation, "prsnt_custom_faction_color"),]),
#add end by xiaowei
复制代码