首页 攻略 游戏教程 > 骑马与砍杀系列 > 骑马与砍杀原版 《骑马与砍杀》自定义国家阵营颜色

热门资讯

《骑马与砍杀》自定义国家阵营颜色

浏览:3329 评论:0 发表时间:2020-01-03

自定义国家阵营这个功能很多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

复制代码


相关图示:
《骑马与砍杀》自定义国家阵营颜色

 

好了,代码就这么点了,下面看看效果:

 

《骑马与砍杀》自定义国家阵营颜色

《骑马与砍杀》自定义国家阵营颜色


修改之后

《骑马与砍杀》自定义国家阵营颜色

可以了,大家凑合看下吧,晚安,各位。

经过R大的提示,对16进制稍微了解了一下,然后上网搜索了一些16进制的相关知识。我贴一个关于16进制的教程图给大家看看:

《骑马与砍杀》自定义国家阵营颜色

 

于是今晚做了这些改动,效果还可以。代码可能还不是很精简,比如我写的这段get_HEX_code_xw脚本,如果不用这段来对应16进制,我不知道直接用10进制的来和后面的16进制进行一般运算会如何。

不过这个过程,有个问题,我现在还没明白:就是获取阵营颜色时候,用来转换成RGB时候,在获取最左位数的时候,总是会多个4080,比如原来阵营颜色为:0xEE7744,我获取到第一位数的时候,这个来除以0x100000,但是输出来却不是理论的14,而是4094。如果我此时直接在代码中输入0xEE7744,输出第一位数的时候,就能得到正确的14。为这个问题感到很奇怪。所以我加入了一个全局变量来控制这个,是直接输入的16进制还是通过获取阵营颜色得到的,从而判断该不该减掉4080。希望知道的能帮忙解答下,谢谢各位。

这里的调色板,我暂时不改了,就这样吧,算是对python语言和数组的运用练习吧。

这里另附一个我自己用快手写的调色板,虽然这些颜色代码可以在网上查得到,但是有一个工具的话,对于没有自定义颜色功能的MOD,查阅起来也方便。

《骑马与砍杀》自定义国家阵营颜色


 
 

0相关评论