本帖最后由 战争傀儡阿格兰 于 2023-2-21 20:17 编辑
代码环境1.171。
代码是怎么判断攻防时候双方军事力量对比?具体的数据是用module_scripts.py里"party_calculate_strength"脚本计算得出。概括一下:设一个兵种等级为x,那么其战斗力y=(x+4)*(x+4)/50,如果y小于1,则直接取1。所有兵种的y加起来就是部队战斗力值,储存在目标party的 slot_party_cached_strength,slot代号56。
应用实例:
1、为啥海寇一个飞斧就能带走一个汉子,ai领主却能无伤解决?因为海寇等级低;
2、为什么ai喜欢烧村子?因为村子战斗力直接为10,相当于1个19级的兵;
(try_begin),
(is_between, ":potential_target", villages_begin, villages_end),
(assign, ":enemy_strength", 10),
3、城堡什么肯定不光光算守军,还要算驻军;
(else_try),
(party_get_slot, ":enemy_strength", ":potential_target", slot_party_cached_strength),
(party_get_slot, ":enemy_strength_nearby", ":potential_target", slot_party_nearby_friend_strength),
(val_add, ":enemy_strength", ":enemy_strength_nearby"),
(try_end),
【END】
研究代码ing,希望战团还有研究代码的人吧!
("party_calculate_strength",
[
(store_script_param_1, ":party"), #Party_id
(store_script_param_2, ":exclude_leader"), #Party_id
(assign, reg0,0),
(party_get_num_companion_stacks, ":num_stacks", ":party"),
(assign, ":first_stack", 0),
(try_begin),
(neq, ":exclude_leader", 0),
(assign, ":first_stack", 1),
(try_end),
(try_for_range, ":i_stack", ":first_stack", ":num_stacks"),
(party_stack_get_troop_id, ":stack_troop",":party", ":i_stack"),
(store_character_level, ":stack_strength", ":stack_troop"),
(val_add, ":stack_strength", 4), #new was 12 (patch 1.125)
(val_mul, ":stack_strength", ":stack_strength"),
(val_mul, ":stack_strength", 2), #new (patch 1.125)
(val_div, ":stack_strength", 100),
(val_max, ":stack_strength", 1), #new (patch 1.125)
(try_begin),
(neg|troop_is_hero, ":stack_troop"),
(party_stack_get_size, ":stack_size",":party",":i_stack"),
(party_stack_get_num_wounded, ":num_wounded",":party",":i_stack"),
(val_sub, ":stack_size", ":num_wounded"),
(val_mul, ":stack_strength", ":stack_size"),
(else_try),
(troop_is_wounded, ":stack_troop"), #hero & wounded
(assign, ":stack_strength", 0),
(try_end),
(val_add, reg0, ":stack_strength"),
(try_end),
(party_set_slot, ":party", slot_party_cached_strength, reg0),
]),
|