好久没在中文站发过帖子了,骑砍2出来后感觉制作区讨论战团的帖子貌似也少了挺多(个人感觉)。
最近重拾起之前拖了很久还没发布的的mod项目,遇到了新增城镇需要设置一些贸易路线的问题。所以想到干脆一不做二不休,直接将每局游戏的贸易路线变成完全随机,顺便也可以在制作区发个帖子。
和之前发的 “使每局游戏的城镇各个场景随机化” 一样,主要是给大伙提供思路,还有拓展空间,比如设置随机城镇贸易的最长距离...
写的也很简单,就修改了module_scripts自带的一个脚本(我习惯性称为脚本):initialize_trade_routes
将该脚本自带的所有代码全部删除或者注释,替换成:
- # 设置 随机的贸易路线
- ("initialize_trade_routes",
- [
- (store_sub, ":towns_number", towns_end, towns_begin), # 获取城镇数量
- (store_div, ":min_routes", ":towns_number", 10), # 最小贸易路线
- (store_div, ":max_routes", ":towns_number", 5), # 最大贸易路线
- (try_for_range, ":town_no", towns_begin, towns_end), # 循环城镇
- (store_random_in_range, ":routes_max_number", ":min_routes", ":max_routes"), # 设置最大贸易路线
- (try_for_range, reg1, 0, ":routes_max_number"),
- (store_random_in_range, ":town_no_2", towns_begin, towns_end), # 随机城镇
- (assign, ":temp_1", 0),
- (try_for_range, ":cur_slot", slot_town_trade_routes_begin, slot_town_trade_routes_end), # 循环所有贸易路线槽
- (this_or_next|party_slot_eq, ":town_no", ":cur_slot", ":town_no_2"), # 如果循环城镇有贸易路线槽已经设置了该贸易路线
- (party_slot_eq, ":town_no_2", ":cur_slot", ":town_no"), # 如果随机城镇有贸易路线槽已经设置了该贸易路线
- (assign, ":temp_1", 1), # 无法正常设置
- (try_end),
- (str_store_party_name, s1, ":town_no"),
- (str_store_party_name, s2, ":town_no_2"),
- (try_begin),
- (eq, ":town_no", ":town_no_2"), # 如果随机的城镇是当前循环城镇
- (try_begin),
- # (this_or_next|eq, "$csmoshi", 1), # 如果处于调试模式
- (ge, "$cheat_mode", 1),
- (display_message, "@{!}失 败!贸 易 路 线:{s1} - {s2}"),
- (try_end),
- (val_add, ":routes_max_number", 1),
- (else_try),
- (eq, ":temp_1", 0),
- (try_begin),
- # (this_or_next|eq, "$csmoshi", 1), # 如果处于调试模式
- (ge, "$cheat_mode", 1),
- (display_message, "@{!}成 功!贸 易 路 线:{s1} - {s2}"),
- (try_end),
- (call_script, "script_set_trade_route_between_centers", ":town_no", ":town_no_2"),
- (try_end),
- (try_end),
- (try_end),
- ]),
复制代码
|