[Sub-mod]PoP3.8.4Horse archer AI enhancement for companions and noldors

正在查看此主题的用户

状态
不接受进一步回复。
Savhos 说:
Love the mod, but makes my text crash and it's really annoying because I have to restart the game.

What are those coloured dots that appear on the right?
Sometimes it happens and sometimes not, it was due to the mini map not the AI script, hmm I decide to give out the horse arhcer AI's code now so that dev can read it and decide how they will use that code(to handle it to how many troops as overall enhance is surely unbalance and annoying).
 
插入代码块:
[       
        (set_fixed_point_multiplier, 1000),
        (try_for_agents, ":agent_no"),
            (agent_is_non_player, ":agent_no"),
            (agent_is_alive, ":agent_no"),
            (agent_is_human, ":agent_no"),
            (neg|agent_slot_eq, ":agent_no", 1003, 1),
            (agent_get_horse, ":horse_no", ":agent_no"),
            (try_begin),
                (neg|agent_slot_eq, ":agent_no", slot_agent_is_running_away, 1),
                (gt, ":horse_no", -1),
                (agent_get_team, ":team_no", ":agent_no"),
                (gt, ":team_no", -1),
                (agent_get_division, ":class_no", ":agent_no"),
                (gt, ":class_no", -1),
                (agent_get_combat_state, ":combat_state", ":agent_no"),
                (team_get_weapon_usage_order, ":weapon_usage_order", ":team_no", ":class_no"),
                (team_get_hold_fire_order, ":hold_fire", ":team_no", ":class_no"),
                (agent_get_ammo, ":ammo", ":agent_no", 0),
                (assign, ":thrown_ammo", 0),
                (assign, ":ranged_weapon", -1),
                (assign, ":ranged_weapon_tipe", -1),             
                (try_begin),
                  (try_for_range, ":item", 0, 4),
                    (agent_get_item_slot, ":item_weapon", ":agent_no", ":item"),
                    (gt, ":item_weapon", 0),
                    (item_get_type, ":item_weapon_tipe", ":item_weapon"),
                    (try_begin),
                      (eq, ":item_weapon_tipe", itp_type_thrown),
                      (agent_get_ammo_for_slot, ":ammo_for_slot", ":agent_no", ":item"),
                      (val_add, ":thrown_ammo", ":ammo_for_slot"),
                    (try_end),
                    (try_begin),
                      (eq, ":ranged_weapon", -1),
                      (this_or_next|eq, ":item_weapon_tipe", itp_type_bow),
                      (this_or_next|eq, ":item_weapon_tipe", itp_type_thrown),
                      (this_or_next|eq, ":item_weapon_tipe", itp_type_pistol),
                      (eq, ":item_weapon_tipe", itp_type_musket),
                      (assign, ":ranged_weapon", ":item_weapon"),
                      (assign, ":ranged_weapon_tipe", ":item_weapon_tipe"),
                    (try_end),
                  (try_end),
                (try_end),
                (gt, ":ranged_weapon_tipe", -1),                
                (neg|item_has_property, ":ranged_weapon", itp_cant_reload_on_horseback),
                (assign, ":have_arrow", 1),
                (try_begin),
                    (store_sub, ":arrow", ":ammo", ":thrown_ammo"),
                    (eq, ":arrow", 0),
                    (agent_set_speed_limit, ":agent_no", 1000),
                    (assign, ":have_arrow", 0),
                (try_end),                
                (eq, ":have_arrow", 1),
                (gt, ":ammo", 0),
                (agent_set_slot, ":agent_no", 1003, 2),
                (neg|eq, ":hold_fire", aordr_hold_your_fire),
                (neg|eq, ":weapon_usage_order", wordr_use_melee_weapons),
                (agent_get_wielded_item, ":weapon_hold", ":agent_no", 0),
                (gt, ":weapon_hold", 0),
                (item_get_type, ":weapon_type", ":weapon_hold"),                
                (try_begin),
                    (agent_ai_get_look_target, ":look_target", ":agent_no"),
                    (gt, ":look_target", -1),
                    (agent_is_human, ":look_target"),
                    (agent_is_alive, ":look_target"),
                    (agent_get_team, ":look_target_team", ":look_target"),
                    (gt, ":look_target_team", -1),
                    (neg|teams_are_enemies, ":team_no", ":look_target_team"),
                    (agent_set_look_target_agent, ":agent_no", -1),
                    (agent_force_rethink, ":agent_no"),
                (try_end),
                (assign, ":speed_limit", 1000),
                (agent_get_position, pos50, ":agent_no"), 
                (position_move_z, pos50, 250, 1),
                (assign, ":distance_closest", 100000),#1000m
                (assign, ":enemies_closest", -1),
                (team_get_movement_order, ":movement_order", ":team_no", ":class_no"),
                (eq, ":movement_order", 2),
                (try_for_agents, ":enemies"),
                    (agent_is_alive, ":enemies"),
                    (agent_is_human, ":enemies"),
                    (agent_get_position, pos36, ":enemies"),
                    (agent_get_team, ":enemies_team", ":enemies"),
                    (gt, ":enemies_team", -1),
                    (teams_are_enemies, ":team_no", ":enemies_team"),
                    (get_distance_between_positions, ":distance", pos50, pos36),                                       
                    (try_begin),
                       (agent_slot_eq, ":enemies", slot_agent_is_running_away, 1),
                       (val_add, ":distance", 10000),
                    (try_end),
                    (assign, ":distance_cavalry", 0),
                    (try_begin),
                        (agent_get_horse, ":enemies_horse", ":enemies"),
                        (gt, ":enemies_horse", -1),
                        (store_div, ":distance_cavalry", ":distance", 3),
                        (val_mul, ":distance_cavalry", 2),
                        (val_min, ":distance_cavalry", 2000),
                        (val_sub, ":distance", ":distance_cavalry"),
                        (assign, ":distance_1", ":distance_cavalry"),
                    (try_end),
                    (neg|ge, ":distance", ":distance_closest"),
                    (assign, ":distance_closest", ":distance"),
                    (assign, ":enemies_closest", ":enemies"),                   
                (try_end),
                (neg|eq, ":enemies_closest", -1),
                (agent_get_position, pos51, ":enemies_closest"),
                (try_begin),
                   (agent_get_horse, ":enemies_closest_horse", ":enemies_closest"),
                   (gt, ":enemies_closest_horse", -1),
                   (store_add, ":distance_true", ":distance_1", ":distance_closest"),
                   (position_move_z, pos51, 250, 1),
                (else_try),
                   (assign, ":distance_true", ":distance_closest"),
                   (position_move_z, pos51, 140, 1),
                (try_end),
                (try_begin),
                  (agent_slot_eq, ":enemies_closest", slot_agent_is_running_away, 1),
                  (val_sub, ":distance_true", 10000),
                (else_try),
                  (gt,":distance_true",300),
                  (agent_set_wielded_item, ":agent_no", ":ranged_weapon"),
                (try_end),             
                (try_begin),
                    (this_or_next|eq, ":weapon_type", itp_type_bow),
                    (this_or_next|eq, ":weapon_type", itp_type_pistol),
                    (eq, ":weapon_type", itp_type_musket),
                    (agent_get_attack_action, ":attack_action", ":agent_no"),
                    (position_has_line_of_sight_to_position, pos50, pos51),
                    (agent_set_look_target_agent, ":agent_no", ":enemies_closest"),
                    (try_begin),
                        (eq, ":attack_action", 1),
                        (try_begin),
                          (eq, ":movement_order", 2),
                          (agent_get_speed, pos31, ":agent_no"),
                          (position_get_y,":speed_y",pos31),
                          (try_begin),
                             (gt, ":distance_closest", 700),
                             (lt, ":distance_closest", 6000),
                             (store_div, ":speed_limit", ":speed_y",300),
                             (store_sub, ":speed_limit_distance", ":distance_closest", 2500),
                             (val_div, ":speed_limit_distance", 20),
                             (val_max, ":speed_limit", ":speed_limit_distance"),
                             (val_max, ":speed_limit", 1),
                          (try_end),
                        (try_end),
                        (eq, ":weapon_type", itp_type_bow),
                        (lt, ":distance_true", 4000),
                        (agent_set_attack_action, ":agent_no", 3, 0),
                    (else_try),
                        (eq, ":weapon_type", itp_type_bow),
                        (lt, ":distance_true", 4000),
                        (neq, ":combat_state", 8),
                        (agent_set_attack_action, ":agent_no", 3, 1),
                    (try_end),
                (try_end),                
                (agent_set_speed_limit, ":agent_no", ":speed_limit"),                
                (try_begin),
                    (agent_is_non_player, ":agent_no"),
                    (neg|eq, ":ranged_weapon_tipe", itp_type_thrown),
                    (gt, ":enemies_closest", -1),
                    (try_begin),
                      (eq, ":movement_order", 2),
                      (this_or_next|agent_slot_eq, ":enemies_closest", slot_agent_is_running_away, 1),
                      (lt, ":distance_closest", 10000),
                      (try_begin),
                        (get_scene_boundaries, pos2, pos3),
                        (position_get_x, ":tip_left_x", pos2),
                        (position_get_y, ":tip_left_y", pos2),
                        (position_get_x, ":right_down_x", pos3),
                        (position_get_y, ":right_down_y", pos3),
                        (position_get_x, ":agent_no_poi_x", pos50),
                        (position_get_y, ":agent_no_poi_y", pos50),
                        (position_copy_origin, pos52, pos2),
                        (store_sub, ":left_x", ":agent_no_poi_x", ":tip_left_x"),
                        (store_sub, ":up_y", ":agent_no_poi_y", ":tip_left_y"),
                        (store_sub, ":right_x", ":right_down_x", ":agent_no_poi_x"),
                        (store_sub, ":down_y", ":right_down_y", ":agent_no_poi_y"),
                        (val_abs, ":left_x"),
                        (val_abs, ":up_y"),
                        (val_abs, ":right_x"),
                        (val_abs, ":down_y"),
                        (store_sub, ":map_middle_x", ":right_down_x", ":tip_left_x"),
                        (store_sub, ":map_middle_y", ":right_down_y", ":tip_left_y"),
                        (val_div, ":map_middle_x", 20),
                        (val_div, ":map_middle_y", 20),
                        (position_move_x, pos52, ":map_middle_x", 1),
                        (position_move_y, pos52, ":map_middle_y", 1),
                        (get_distance_between_positions,":distance_middle", pos52, pos50),
                        (position_transform_position_to_local, pos52, pos50, pos52),
                        (position_transform_position_to_local, pos4, pos50, pos51),
                        (position_get_x, ":map_middle_x", pos52),
                        (position_get_y, ":map_middle_y", pos52),
                        (position_get_x, ":enemies_x", pos4),
                        (position_get_y, ":enemies_y", pos4),
                        (assign, ":effect", 0),
                        (try_begin),
                          (neg|gt, ":distance_closest", 1000),
                          (store_sub,":effect", ":distance_closest", 1500),
                          (val_mul,":effect", 60),
                          (val_max, ":effect", -80000),
                          (assign, ":effect", -80000),
                        (else_try),
                          (gt, ":distance_closest", 2500),
                          (store_sub,":effect", ":distance_closest", 0),
                          (val_mul, ":effect", 5),
                          (val_clamp, ":effect", 35000, 90000),
                          (try_begin),
                            (gt,":enemies_closest_horse",-1),
                            (val_sub,":effect",20000),
                          (try_end),
                        (try_end),                       
                        (assign, ":distance_to_boundary", 30000),
                        (val_min, ":distance_to_boundary", ":left_x"),
                        (val_min, ":distance_to_boundary", ":up_y"),
                        (val_min, ":distance_to_boundary", ":right_x"),
                        (val_min, ":distance_to_boundary", ":down_y"),
                        (try_begin),
                          (lt, ":distance_to_boundary", 30000),
                          (lt, ":distance_closest", 1500),
                          (agent_slot_eq, ":enemies_closest", slot_agent_is_running_away, 0),
                          (agent_force_rethink, ":agent_no"),
                          (val_mul, ":map_middle_x", 100),
                          (val_mul, ":map_middle_y", 100),
                          (val_mul, ":enemies_x", 100),
                          (val_mul, ":enemies_y", 100),
                          (store_div,":cos_middle",":map_middle_x",":distance_middle"),
                          (store_div,":sin_middle",":map_middle_y",":distance_middle"),
                          (store_div,":cos_enemies",":enemies_x",":distance_true"),
                          (store_div,":sin_enemies",":enemies_y",":distance_true"),
                          (store_acos, ":angle_cos", ":cos_middle"),
                          (store_asin, ":angle_sin", ":sin_middle"),
                          (store_acos, ":angle_cos_enemies", ":cos_enemies"),
                          (store_asin, ":angle_sin_enemies", ":sin_enemies"),
                          (try_begin),
                            (lt, ":angle_sin", 0),
                            (val_mul,":angle_cos", -1),
                            (val_add,":angle_cos", 360000),
                          (try_end),
                          (try_begin),
                            (lt, ":angle_sin_enemies", 0),
                            (val_mul,":angle_cos_enemies", -1),
                            (val_add,":angle_cos_enemies", 360000),
                          (try_end),
                          (store_sub, ":k2", ":angle_cos", ":angle_cos_enemies"),
                          (val_sub, ":k2", 270000),
                          (val_sub, ":k2", ":effect"),
                          (store_add, ":effect", ":k2", ":effect"),
                          (try_begin),
                            (lt, ":angle_cos", ":angle_cos_enemies"),
                            (val_add, ":effect", 360000),
                          (try_end),
                          (val_clamp,":effect",-210000, 15000),
                          (agent_set_attack_action, ":agent_no", 3, 1),
                        (try_end),                        
                        (store_cos, ":cos", ":effect"),
                        (store_sin, ":sin", ":effect"),
                        (store_mul, ":k_x1", ":cos", ":enemies_y",),
                        (store_mul, ":k_x2", ":sin", ":enemies_x",),
                        (store_mul, ":k_y1", ":sin", ":enemies_y",),
                        (store_mul, ":k_y2", ":cos", ":enemies_x",),
                        (store_add, ":move_x",":k_x1", ":k_x2"),
                        (store_sub, ":move_y",":k_y1", ":k_y2"),
                        (position_move_x, pos50, ":move_x", 0),
                        (position_move_y, pos50, ":move_y", 0),                       
                      (try_end),
                      (agent_set_scripted_destination, ":agent_no", pos50, 1),
                    (else_try),
                        (agent_clear_scripted_mode, ":agent_no"),
                        (agent_force_rethink, ":agent_no"),
                    (try_end),                    
                (try_end),
            (else_try),
                (try_begin),
                  (agent_slot_eq, ":agent_no", 1003, 0),
                  (agent_set_slot, ":agent_no", 1003, 1),
                (else_try),
                  (agent_slot_eq, ":agent_no", 1003, 2),
                  (this_or_next|eq, ":ammo", 0),
                  (this_or_next|neg|gt, ":horse_no", 0),
                  (this_or_next|eq, ":hold_fire", aordr_hold_your_fire),
                  (eq, ":weapon_usage_order", wordr_use_melee_weapons),
                  (agent_force_rethink, ":agent_no"),
                  (agent_clear_scripted_mode, ":agent_no"),
                  (agent_set_speed_limit, ":agent_no", 1000),
                  (agent_set_slot, ":agent_no", 1003, 3),
                (try_end),
            (try_end),
        (try_end),
  ]
Here goes the code of the horse arhcer AI itself only, however need to add the determine for wanted troops so that it wont work for every troops but some speical troops like heros and noldors to make the script enjoyable. :wink:
Have a look if you are free and interested  :grin:(ps: ignore the chinese words if I fail to delete all of them, those were for the learning of our moders :facepalm:)
@K0nr@d @MitchyMatt @Snouz
 
Latis the Darkgryphon 说:
插入代码块:
[       
        (set_fixed_point_multiplier, 1000),
        (try_for_agents, ":agent_no"),
            (agent_is_non_player, ":agent_no"),
            (agent_is_alive, ":agent_no"),
            (agent_is_human, ":agent_no"),
            (neg|agent_slot_eq, ":agent_no", 1003, 1),
            (agent_get_horse, ":horse_no", ":agent_no"),
            (try_begin),
                (neg|agent_slot_eq, ":agent_no", slot_agent_is_running_away, 1),
                (gt, ":horse_no", -1),
                (agent_get_team, ":team_no", ":agent_no"),
                (gt, ":team_no", -1),
                (agent_get_division, ":class_no", ":agent_no"),
                (gt, ":class_no", -1),
                (agent_get_combat_state, ":combat_state", ":agent_no"),
                (team_get_weapon_usage_order, ":weapon_usage_order", ":team_no", ":class_no"),
                (team_get_hold_fire_order, ":hold_fire", ":team_no", ":class_no"),
                (agent_get_ammo, ":ammo", ":agent_no", 0),
                (assign, ":thrown_ammo", 0),
                (assign, ":ranged_weapon", -1),
                (assign, ":ranged_weapon_tipe", -1),             
                (try_begin),
                  (try_for_range, ":item", 0, 4),
                    (agent_get_item_slot, ":item_weapon", ":agent_no", ":item"),
                    (gt, ":item_weapon", 0),
                    (item_get_type, ":item_weapon_tipe", ":item_weapon"),
                    (try_begin),
                      (eq, ":item_weapon_tipe", itp_type_thrown),
                      (agent_get_ammo_for_slot, ":ammo_for_slot", ":agent_no", ":item"),
                      (val_add, ":thrown_ammo", ":ammo_for_slot"),
                    (try_end),
                    (try_begin),
                      (eq, ":ranged_weapon", -1),
                      (this_or_next|eq, ":item_weapon_tipe", itp_type_bow),
                      (this_or_next|eq, ":item_weapon_tipe", itp_type_thrown),
                      (this_or_next|eq, ":item_weapon_tipe", itp_type_pistol),
                      (eq, ":item_weapon_tipe", itp_type_musket),
                      (assign, ":ranged_weapon", ":item_weapon"),
                      (assign, ":ranged_weapon_tipe", ":item_weapon_tipe"),
                    (try_end),
                  (try_end),
                (try_end),
                (gt, ":ranged_weapon_tipe", -1),                
                (neg|item_has_property, ":ranged_weapon", itp_cant_reload_on_horseback),
                (assign, ":have_arrow", 1),
                (try_begin),
                    (store_sub, ":arrow", ":ammo", ":thrown_ammo"),
                    (eq, ":arrow", 0),
                    (agent_set_speed_limit, ":agent_no", 1000),
                    (assign, ":have_arrow", 0),
                (try_end),                
                (eq, ":have_arrow", 1),
                (gt, ":ammo", 0),
                (agent_set_slot, ":agent_no", 1003, 2),
                (neg|eq, ":hold_fire", aordr_hold_your_fire),
                (neg|eq, ":weapon_usage_order", wordr_use_melee_weapons),
                (agent_get_wielded_item, ":weapon_hold", ":agent_no", 0),
                (gt, ":weapon_hold", 0),
                (item_get_type, ":weapon_type", ":weapon_hold"),                
                (try_begin),
                    (agent_ai_get_look_target, ":look_target", ":agent_no"),
                    (gt, ":look_target", -1),
                    (agent_is_human, ":look_target"),
                    (agent_is_alive, ":look_target"),
                    (agent_get_team, ":look_target_team", ":look_target"),
                    (gt, ":look_target_team", -1),
                    (neg|teams_are_enemies, ":team_no", ":look_target_team"),
                    (agent_set_look_target_agent, ":agent_no", -1),
                    (agent_force_rethink, ":agent_no"),
                (try_end),
                (assign, ":speed_limit", 1000),
                (agent_get_position, pos50, ":agent_no"), 
                (position_move_z, pos50, 250, 1),
                (assign, ":distance_closest", 100000),#1000m
                (assign, ":enemies_closest", -1),
                (team_get_movement_order, ":movement_order", ":team_no", ":class_no"),
                (eq, ":movement_order", 2),
                (try_for_agents, ":enemies"),
                    (agent_is_alive, ":enemies"),
                    (agent_is_human, ":enemies"),
                    (agent_get_position, pos36, ":enemies"),
                    (agent_get_team, ":enemies_team", ":enemies"),
                    (gt, ":enemies_team", -1),
                    (teams_are_enemies, ":team_no", ":enemies_team"),
                    (get_distance_between_positions, ":distance", pos50, pos36),                                       
                    (try_begin),
                       (agent_slot_eq, ":enemies", slot_agent_is_running_away, 1),
                       (val_add, ":distance", 10000),
                    (try_end),
                    (assign, ":distance_cavalry", 0),
                    (try_begin),
                        (agent_get_horse, ":enemies_horse", ":enemies"),
                        (gt, ":enemies_horse", -1),
                        (store_div, ":distance_cavalry", ":distance", 3),
                        (val_mul, ":distance_cavalry", 2),
                        (val_min, ":distance_cavalry", 2000),
                        (val_sub, ":distance", ":distance_cavalry"),
                        (assign, ":distance_1", ":distance_cavalry"),
                    (try_end),
                    (neg|ge, ":distance", ":distance_closest"),
                    (assign, ":distance_closest", ":distance"),
                    (assign, ":enemies_closest", ":enemies"),                   
                (try_end),
                (neg|eq, ":enemies_closest", -1),
                (agent_get_position, pos51, ":enemies_closest"),
                (try_begin),
                   (agent_get_horse, ":enemies_closest_horse", ":enemies_closest"),
                   (gt, ":enemies_closest_horse", -1),
                   (store_add, ":distance_true", ":distance_1", ":distance_closest"),
                   (position_move_z, pos51, 250, 1),
                (else_try),
                   (assign, ":distance_true", ":distance_closest"),
                   (position_move_z, pos51, 140, 1),
                (try_end),
                (try_begin),
                  (agent_slot_eq, ":enemies_closest", slot_agent_is_running_away, 1),
                  (val_sub, ":distance_true", 10000),
                (else_try),
                  (gt,":distance_true",300),
                  (agent_set_wielded_item, ":agent_no", ":ranged_weapon"),
                (try_end),             
                (try_begin),
                    (this_or_next|eq, ":weapon_type", itp_type_bow),
                    (this_or_next|eq, ":weapon_type", itp_type_pistol),
                    (eq, ":weapon_type", itp_type_musket),
                    (agent_get_attack_action, ":attack_action", ":agent_no"),
                    (position_has_line_of_sight_to_position, pos50, pos51),
                    (agent_set_look_target_agent, ":agent_no", ":enemies_closest"),
                    (try_begin),
                        (eq, ":attack_action", 1),
                        (try_begin),
                          (eq, ":movement_order", 2),
                          (agent_get_speed, pos31, ":agent_no"),
                          (position_get_y,":speed_y",pos31),
                          (try_begin),
                             (gt, ":distance_closest", 700),
                             (lt, ":distance_closest", 6000),
                             (store_div, ":speed_limit", ":speed_y",300),
                             (store_sub, ":speed_limit_distance", ":distance_closest", 2500),
                             (val_div, ":speed_limit_distance", 20),
                             (val_max, ":speed_limit", ":speed_limit_distance"),
                             (val_max, ":speed_limit", 1),
                          (try_end),
                        (try_end),
                        (eq, ":weapon_type", itp_type_bow),
                        (lt, ":distance_true", 4000),
                        (agent_set_attack_action, ":agent_no", 3, 0),
                    (else_try),
                        (eq, ":weapon_type", itp_type_bow),
                        (lt, ":distance_true", 4000),
                        (neq, ":combat_state", 8),
                        (agent_set_attack_action, ":agent_no", 3, 1),
                    (try_end),
                (try_end),                
                (agent_set_speed_limit, ":agent_no", ":speed_limit"),                
                (try_begin),
                    (agent_is_non_player, ":agent_no"),
                    (neg|eq, ":ranged_weapon_tipe", itp_type_thrown),
                    (gt, ":enemies_closest", -1),
                    (try_begin),
                      (eq, ":movement_order", 2),
                      (this_or_next|agent_slot_eq, ":enemies_closest", slot_agent_is_running_away, 1),
                      (lt, ":distance_closest", 10000),
                      (try_begin),
                        (get_scene_boundaries, pos2, pos3),
                        (position_get_x, ":tip_left_x", pos2),
                        (position_get_y, ":tip_left_y", pos2),
                        (position_get_x, ":right_down_x", pos3),
                        (position_get_y, ":right_down_y", pos3),
                        (position_get_x, ":agent_no_poi_x", pos50),
                        (position_get_y, ":agent_no_poi_y", pos50),
                        (position_copy_origin, pos52, pos2),
                        (store_sub, ":left_x", ":agent_no_poi_x", ":tip_left_x"),
                        (store_sub, ":up_y", ":agent_no_poi_y", ":tip_left_y"),
                        (store_sub, ":right_x", ":right_down_x", ":agent_no_poi_x"),
                        (store_sub, ":down_y", ":right_down_y", ":agent_no_poi_y"),
                        (val_abs, ":left_x"),
                        (val_abs, ":up_y"),
                        (val_abs, ":right_x"),
                        (val_abs, ":down_y"),
                        (store_sub, ":map_middle_x", ":right_down_x", ":tip_left_x"),
                        (store_sub, ":map_middle_y", ":right_down_y", ":tip_left_y"),
                        (val_div, ":map_middle_x", 20),
                        (val_div, ":map_middle_y", 20),
                        (position_move_x, pos52, ":map_middle_x", 1),
                        (position_move_y, pos52, ":map_middle_y", 1),
                        (get_distance_between_positions,":distance_middle", pos52, pos50),
                        (position_transform_position_to_local, pos52, pos50, pos52),
                        (position_transform_position_to_local, pos4, pos50, pos51),
                        (position_get_x, ":map_middle_x", pos52),
                        (position_get_y, ":map_middle_y", pos52),
                        (position_get_x, ":enemies_x", pos4),
                        (position_get_y, ":enemies_y", pos4),
                        (assign, ":effect", 0),
                        (try_begin),
                          (neg|gt, ":distance_closest", 1000),
                          (store_sub,":effect", ":distance_closest", 1500),
                          (val_mul,":effect", 60),
                          (val_max, ":effect", -80000),
                          (assign, ":effect", -80000),
                        (else_try),
                          (gt, ":distance_closest", 2500),
                          (store_sub,":effect", ":distance_closest", 0),
                          (val_mul, ":effect", 5),
                          (val_clamp, ":effect", 35000, 90000),
                          (try_begin),
                            (gt,":enemies_closest_horse",-1),
                            (val_sub,":effect",20000),
                          (try_end),
                        (try_end),                       
                        (assign, ":distance_to_boundary", 30000),
                        (val_min, ":distance_to_boundary", ":left_x"),
                        (val_min, ":distance_to_boundary", ":up_y"),
                        (val_min, ":distance_to_boundary", ":right_x"),
                        (val_min, ":distance_to_boundary", ":down_y"),
                        (try_begin),
                          (lt, ":distance_to_boundary", 30000),
                          (lt, ":distance_closest", 1500),
                          (agent_slot_eq, ":enemies_closest", slot_agent_is_running_away, 0),
                          (agent_force_rethink, ":agent_no"),
                          (val_mul, ":map_middle_x", 100),
                          (val_mul, ":map_middle_y", 100),
                          (val_mul, ":enemies_x", 100),
                          (val_mul, ":enemies_y", 100),
                          (store_div,":cos_middle",":map_middle_x",":distance_middle"),
                          (store_div,":sin_middle",":map_middle_y",":distance_middle"),
                          (store_div,":cos_enemies",":enemies_x",":distance_true"),
                          (store_div,":sin_enemies",":enemies_y",":distance_true"),
                          (store_acos, ":angle_cos", ":cos_middle"),
                          (store_asin, ":angle_sin", ":sin_middle"),
                          (store_acos, ":angle_cos_enemies", ":cos_enemies"),
                          (store_asin, ":angle_sin_enemies", ":sin_enemies"),
                          (try_begin),
                            (lt, ":angle_sin", 0),
                            (val_mul,":angle_cos", -1),
                            (val_add,":angle_cos", 360000),
                          (try_end),
                          (try_begin),
                            (lt, ":angle_sin_enemies", 0),
                            (val_mul,":angle_cos_enemies", -1),
                            (val_add,":angle_cos_enemies", 360000),
                          (try_end),
                          (store_sub, ":k2", ":angle_cos", ":angle_cos_enemies"),
                          (val_sub, ":k2", 270000),
                          (val_sub, ":k2", ":effect"),
                          (store_add, ":effect", ":k2", ":effect"),
                          (try_begin),
                            (lt, ":angle_cos", ":angle_cos_enemies"),
                            (val_add, ":effect", 360000),
                          (try_end),
                          (val_clamp,":effect",-210000, 15000),
                          (agent_set_attack_action, ":agent_no", 3, 1),
                        (try_end),                        
                        (store_cos, ":cos", ":effect"),
                        (store_sin, ":sin", ":effect"),
                        (store_mul, ":k_x1", ":cos", ":enemies_y",),
                        (store_mul, ":k_x2", ":sin", ":enemies_x",),
                        (store_mul, ":k_y1", ":sin", ":enemies_y",),
                        (store_mul, ":k_y2", ":cos", ":enemies_x",),
                        (store_add, ":move_x",":k_x1", ":k_x2"),
                        (store_sub, ":move_y",":k_y1", ":k_y2"),
                        (position_move_x, pos50, ":move_x", 0),
                        (position_move_y, pos50, ":move_y", 0),                       
                      (try_end),
                      (agent_set_scripted_destination, ":agent_no", pos50, 1),
                    (else_try),
                        (agent_clear_scripted_mode, ":agent_no"),
                        (agent_force_rethink, ":agent_no"),
                    (try_end),                    
                (try_end),
            (else_try),
                (try_begin),
                  (agent_slot_eq, ":agent_no", 1003, 0),
                  (agent_set_slot, ":agent_no", 1003, 1),
                (else_try),
                  (agent_slot_eq, ":agent_no", 1003, 2),
                  (this_or_next|eq, ":ammo", 0),
                  (this_or_next|neg|gt, ":horse_no", 0),
                  (this_or_next|eq, ":hold_fire", aordr_hold_your_fire),
                  (eq, ":weapon_usage_order", wordr_use_melee_weapons),
                  (agent_force_rethink, ":agent_no"),
                  (agent_clear_scripted_mode, ":agent_no"),
                  (agent_set_speed_limit, ":agent_no", 1000),
                  (agent_set_slot, ":agent_no", 1003, 3),
                (try_end),
            (try_end),
        (try_end),
  ]
Here goes the code of the horse arhcer AI itself only, however need to add the determine for wanted troops so that it wont work for every troops but some speical troops like heros and noldors to make the script enjoyable. :wink:
Have a look if you are free and interested  :grin:(ps: ignore the chinese words if I fail to delet all of them, those was for the learning of our moders :facepalm:)
@K0nr@d @MitchyMatt @Snouz

Ok thanks, I'm not that good with scripts though. It's ok for me to have it just for heroes and noldors, what should I do with it?
 
Savhos 说:
Latis the Darkgryphon 说:
插入代码块:
[       
        (set_fixed_point_multiplier, 1000),
        (try_for_agents, ":agent_no"),
            (agent_is_non_player, ":agent_no"),
            (agent_is_alive, ":agent_no"),
            (agent_is_human, ":agent_no"),
            (neg|agent_slot_eq, ":agent_no", 1003, 1),
            (agent_get_horse, ":horse_no", ":agent_no"),
            (try_begin),
                (neg|agent_slot_eq, ":agent_no", slot_agent_is_running_away, 1),
                (gt, ":horse_no", -1),
                (agent_get_team, ":team_no", ":agent_no"),
                (gt, ":team_no", -1),
                (agent_get_division, ":class_no", ":agent_no"),
                (gt, ":class_no", -1),
                (agent_get_combat_state, ":combat_state", ":agent_no"),
                (team_get_weapon_usage_order, ":weapon_usage_order", ":team_no", ":class_no"),
                (team_get_hold_fire_order, ":hold_fire", ":team_no", ":class_no"),
                (agent_get_ammo, ":ammo", ":agent_no", 0),
                (assign, ":thrown_ammo", 0),
                (assign, ":ranged_weapon", -1),
                (assign, ":ranged_weapon_tipe", -1),             
                (try_begin),
                  (try_for_range, ":item", 0, 4),
                    (agent_get_item_slot, ":item_weapon", ":agent_no", ":item"),
                    (gt, ":item_weapon", 0),
                    (item_get_type, ":item_weapon_tipe", ":item_weapon"),
                    (try_begin),
                      (eq, ":item_weapon_tipe", itp_type_thrown),
                      (agent_get_ammo_for_slot, ":ammo_for_slot", ":agent_no", ":item"),
                      (val_add, ":thrown_ammo", ":ammo_for_slot"),
                    (try_end),
                    (try_begin),
                      (eq, ":ranged_weapon", -1),
                      (this_or_next|eq, ":item_weapon_tipe", itp_type_bow),
                      (this_or_next|eq, ":item_weapon_tipe", itp_type_thrown),
                      (this_or_next|eq, ":item_weapon_tipe", itp_type_pistol),
                      (eq, ":item_weapon_tipe", itp_type_musket),
                      (assign, ":ranged_weapon", ":item_weapon"),
                      (assign, ":ranged_weapon_tipe", ":item_weapon_tipe"),
                    (try_end),
                  (try_end),
                (try_end),
                (gt, ":ranged_weapon_tipe", -1),                
                (neg|item_has_property, ":ranged_weapon", itp_cant_reload_on_horseback),
                (assign, ":have_arrow", 1),
                (try_begin),
                    (store_sub, ":arrow", ":ammo", ":thrown_ammo"),
                    (eq, ":arrow", 0),
                    (agent_set_speed_limit, ":agent_no", 1000),
                    (assign, ":have_arrow", 0),
                (try_end),                
                (eq, ":have_arrow", 1),
                (gt, ":ammo", 0),
                (agent_set_slot, ":agent_no", 1003, 2),
                (neg|eq, ":hold_fire", aordr_hold_your_fire),
                (neg|eq, ":weapon_usage_order", wordr_use_melee_weapons),
                (agent_get_wielded_item, ":weapon_hold", ":agent_no", 0),
                (gt, ":weapon_hold", 0),
                (item_get_type, ":weapon_type", ":weapon_hold"),                
                (try_begin),
                    (agent_ai_get_look_target, ":look_target", ":agent_no"),
                    (gt, ":look_target", -1),
                    (agent_is_human, ":look_target"),
                    (agent_is_alive, ":look_target"),
                    (agent_get_team, ":look_target_team", ":look_target"),
                    (gt, ":look_target_team", -1),
                    (neg|teams_are_enemies, ":team_no", ":look_target_team"),
                    (agent_set_look_target_agent, ":agent_no", -1),
                    (agent_force_rethink, ":agent_no"),
                (try_end),
                (assign, ":speed_limit", 1000),
                (agent_get_position, pos50, ":agent_no"), 
                (position_move_z, pos50, 250, 1),
                (assign, ":distance_closest", 100000),#1000m
                (assign, ":enemies_closest", -1),
                (team_get_movement_order, ":movement_order", ":team_no", ":class_no"),
                (eq, ":movement_order", 2),
                (try_for_agents, ":enemies"),
                    (agent_is_alive, ":enemies"),
                    (agent_is_human, ":enemies"),
                    (agent_get_position, pos36, ":enemies"),
                    (agent_get_team, ":enemies_team", ":enemies"),
                    (gt, ":enemies_team", -1),
                    (teams_are_enemies, ":team_no", ":enemies_team"),
                    (get_distance_between_positions, ":distance", pos50, pos36),                                       
                    (try_begin),
                       (agent_slot_eq, ":enemies", slot_agent_is_running_away, 1),
                       (val_add, ":distance", 10000),
                    (try_end),
                    (assign, ":distance_cavalry", 0),
                    (try_begin),
                        (agent_get_horse, ":enemies_horse", ":enemies"),
                        (gt, ":enemies_horse", -1),
                        (store_div, ":distance_cavalry", ":distance", 3),
                        (val_mul, ":distance_cavalry", 2),
                        (val_min, ":distance_cavalry", 2000),
                        (val_sub, ":distance", ":distance_cavalry"),
                        (assign, ":distance_1", ":distance_cavalry"),
                    (try_end),
                    (neg|ge, ":distance", ":distance_closest"),
                    (assign, ":distance_closest", ":distance"),
                    (assign, ":enemies_closest", ":enemies"),                   
                (try_end),
                (neg|eq, ":enemies_closest", -1),
                (agent_get_position, pos51, ":enemies_closest"),
                (try_begin),
                   (agent_get_horse, ":enemies_closest_horse", ":enemies_closest"),
                   (gt, ":enemies_closest_horse", -1),
                   (store_add, ":distance_true", ":distance_1", ":distance_closest"),
                   (position_move_z, pos51, 250, 1),
                (else_try),
                   (assign, ":distance_true", ":distance_closest"),
                   (position_move_z, pos51, 140, 1),
                (try_end),
                (try_begin),
                  (agent_slot_eq, ":enemies_closest", slot_agent_is_running_away, 1),
                  (val_sub, ":distance_true", 10000),
                (else_try),
                  (gt,":distance_true",300),
                  (agent_set_wielded_item, ":agent_no", ":ranged_weapon"),
                (try_end),             
                (try_begin),
                    (this_or_next|eq, ":weapon_type", itp_type_bow),
                    (this_or_next|eq, ":weapon_type", itp_type_pistol),
                    (eq, ":weapon_type", itp_type_musket),
                    (agent_get_attack_action, ":attack_action", ":agent_no"),
                    (position_has_line_of_sight_to_position, pos50, pos51),
                    (agent_set_look_target_agent, ":agent_no", ":enemies_closest"),
                    (try_begin),
                        (eq, ":attack_action", 1),
                        (try_begin),
                          (eq, ":movement_order", 2),
                          (agent_get_speed, pos31, ":agent_no"),
                          (position_get_y,":speed_y",pos31),
                          (try_begin),
                             (gt, ":distance_closest", 700),
                             (lt, ":distance_closest", 6000),
                             (store_div, ":speed_limit", ":speed_y",300),
                             (store_sub, ":speed_limit_distance", ":distance_closest", 2500),
                             (val_div, ":speed_limit_distance", 20),
                             (val_max, ":speed_limit", ":speed_limit_distance"),
                             (val_max, ":speed_limit", 1),
                          (try_end),
                        (try_end),
                        (eq, ":weapon_type", itp_type_bow),
                        (lt, ":distance_true", 4000),
                        (agent_set_attack_action, ":agent_no", 3, 0),
                    (else_try),
                        (eq, ":weapon_type", itp_type_bow),
                        (lt, ":distance_true", 4000),
                        (neq, ":combat_state", 8),
                        (agent_set_attack_action, ":agent_no", 3, 1),
                    (try_end),
                (try_end),                
                (agent_set_speed_limit, ":agent_no", ":speed_limit"),                
                (try_begin),
                    (agent_is_non_player, ":agent_no"),
                    (neg|eq, ":ranged_weapon_tipe", itp_type_thrown),
                    (gt, ":enemies_closest", -1),
                    (try_begin),
                      (eq, ":movement_order", 2),
                      (this_or_next|agent_slot_eq, ":enemies_closest", slot_agent_is_running_away, 1),
                      (lt, ":distance_closest", 10000),
                      (try_begin),
                        (get_scene_boundaries, pos2, pos3),
                        (position_get_x, ":tip_left_x", pos2),
                        (position_get_y, ":tip_left_y", pos2),
                        (position_get_x, ":right_down_x", pos3),
                        (position_get_y, ":right_down_y", pos3),
                        (position_get_x, ":agent_no_poi_x", pos50),
                        (position_get_y, ":agent_no_poi_y", pos50),
                        (position_copy_origin, pos52, pos2),
                        (store_sub, ":left_x", ":agent_no_poi_x", ":tip_left_x"),
                        (store_sub, ":up_y", ":agent_no_poi_y", ":tip_left_y"),
                        (store_sub, ":right_x", ":right_down_x", ":agent_no_poi_x"),
                        (store_sub, ":down_y", ":right_down_y", ":agent_no_poi_y"),
                        (val_abs, ":left_x"),
                        (val_abs, ":up_y"),
                        (val_abs, ":right_x"),
                        (val_abs, ":down_y"),
                        (store_sub, ":map_middle_x", ":right_down_x", ":tip_left_x"),
                        (store_sub, ":map_middle_y", ":right_down_y", ":tip_left_y"),
                        (val_div, ":map_middle_x", 20),
                        (val_div, ":map_middle_y", 20),
                        (position_move_x, pos52, ":map_middle_x", 1),
                        (position_move_y, pos52, ":map_middle_y", 1),
                        (get_distance_between_positions,":distance_middle", pos52, pos50),
                        (position_transform_position_to_local, pos52, pos50, pos52),
                        (position_transform_position_to_local, pos4, pos50, pos51),
                        (position_get_x, ":map_middle_x", pos52),
                        (position_get_y, ":map_middle_y", pos52),
                        (position_get_x, ":enemies_x", pos4),
                        (position_get_y, ":enemies_y", pos4),
                        (assign, ":effect", 0),
                        (try_begin),
                          (neg|gt, ":distance_closest", 1000),
                          (store_sub,":effect", ":distance_closest", 1500),
                          (val_mul,":effect", 60),
                          (val_max, ":effect", -80000),
                          (assign, ":effect", -80000),
                        (else_try),
                          (gt, ":distance_closest", 2500),
                          (store_sub,":effect", ":distance_closest", 0),
                          (val_mul, ":effect", 5),
                          (val_clamp, ":effect", 35000, 90000),
                          (try_begin),
                            (gt,":enemies_closest_horse",-1),
                            (val_sub,":effect",20000),
                          (try_end),
                        (try_end),                       
                        (assign, ":distance_to_boundary", 30000),
                        (val_min, ":distance_to_boundary", ":left_x"),
                        (val_min, ":distance_to_boundary", ":up_y"),
                        (val_min, ":distance_to_boundary", ":right_x"),
                        (val_min, ":distance_to_boundary", ":down_y"),
                        (try_begin),
                          (lt, ":distance_to_boundary", 30000),
                          (lt, ":distance_closest", 1500),
                          (agent_slot_eq, ":enemies_closest", slot_agent_is_running_away, 0),
                          (agent_force_rethink, ":agent_no"),
                          (val_mul, ":map_middle_x", 100),
                          (val_mul, ":map_middle_y", 100),
                          (val_mul, ":enemies_x", 100),
                          (val_mul, ":enemies_y", 100),
                          (store_div,":cos_middle",":map_middle_x",":distance_middle"),
                          (store_div,":sin_middle",":map_middle_y",":distance_middle"),
                          (store_div,":cos_enemies",":enemies_x",":distance_true"),
                          (store_div,":sin_enemies",":enemies_y",":distance_true"),
                          (store_acos, ":angle_cos", ":cos_middle"),
                          (store_asin, ":angle_sin", ":sin_middle"),
                          (store_acos, ":angle_cos_enemies", ":cos_enemies"),
                          (store_asin, ":angle_sin_enemies", ":sin_enemies"),
                          (try_begin),
                            (lt, ":angle_sin", 0),
                            (val_mul,":angle_cos", -1),
                            (val_add,":angle_cos", 360000),
                          (try_end),
                          (try_begin),
                            (lt, ":angle_sin_enemies", 0),
                            (val_mul,":angle_cos_enemies", -1),
                            (val_add,":angle_cos_enemies", 360000),
                          (try_end),
                          (store_sub, ":k2", ":angle_cos", ":angle_cos_enemies"),
                          (val_sub, ":k2", 270000),
                          (val_sub, ":k2", ":effect"),
                          (store_add, ":effect", ":k2", ":effect"),
                          (try_begin),
                            (lt, ":angle_cos", ":angle_cos_enemies"),
                            (val_add, ":effect", 360000),
                          (try_end),
                          (val_clamp,":effect",-210000, 15000),
                          (agent_set_attack_action, ":agent_no", 3, 1),
                        (try_end),                        
                        (store_cos, ":cos", ":effect"),
                        (store_sin, ":sin", ":effect"),
                        (store_mul, ":k_x1", ":cos", ":enemies_y",),
                        (store_mul, ":k_x2", ":sin", ":enemies_x",),
                        (store_mul, ":k_y1", ":sin", ":enemies_y",),
                        (store_mul, ":k_y2", ":cos", ":enemies_x",),
                        (store_add, ":move_x",":k_x1", ":k_x2"),
                        (store_sub, ":move_y",":k_y1", ":k_y2"),
                        (position_move_x, pos50, ":move_x", 0),
                        (position_move_y, pos50, ":move_y", 0),                       
                      (try_end),
                      (agent_set_scripted_destination, ":agent_no", pos50, 1),
                    (else_try),
                        (agent_clear_scripted_mode, ":agent_no"),
                        (agent_force_rethink, ":agent_no"),
                    (try_end),                    
                (try_end),
            (else_try),
                (try_begin),
                  (agent_slot_eq, ":agent_no", 1003, 0),
                  (agent_set_slot, ":agent_no", 1003, 1),
                (else_try),
                  (agent_slot_eq, ":agent_no", 1003, 2),
                  (this_or_next|eq, ":ammo", 0),
                  (this_or_next|neg|gt, ":horse_no", 0),
                  (this_or_next|eq, ":hold_fire", aordr_hold_your_fire),
                  (eq, ":weapon_usage_order", wordr_use_melee_weapons),
                  (agent_force_rethink, ":agent_no"),
                  (agent_clear_scripted_mode, ":agent_no"),
                  (agent_set_speed_limit, ":agent_no", 1000),
                  (agent_set_slot, ":agent_no", 1003, 3),
                (try_end),
            (try_end),
        (try_end),
  ]
Here goes the code of the horse arhcer AI itself only, however need to add the determine for wanted troops so that it wont work for every troops but some speical troops like heros and noldors to make the script enjoyable. :wink:
Have a look if you are free and interested  :grin:(ps: ignore the chinese words if I fail to delet all of them, those was for the learning of our moders :facepalm:)
@K0nr@d @MitchyMatt @Snouz

Ok thanks, I'm not that good with scripts though. It's ok for me to have it just for heroes and noldors, what should I do with it?

That's not for you, thats for devs (he even named them hoping for some reply). That's the code they have to add in the .py files so that when they compile the program, its all added. The "how to apply it for myself" is in OP (the post that made the thread).
 
People in forge should know how to write that, show the code and ask for help there may get the answer, however don't forget the name of original author, 君悦, in case someone may interest in it.
 
Sorry for my ignorance, but is there a way to write author's name suing western alphabet (both versions will be added to 3.8.5 credits).
 
k0nr@d 说:
Sorry for my ignorance, but is there a way to write author's name suing western alphabet (both versions will be added to 3.8.5 credits).
Sure ! Thanks!
Jun Yue (君悦) :mrgreen:
That words means "please you"(make you happy) by the way :fruity:
 
Actually,there is a bug.This code "(position_move_z, pos50, 250, 1),",i put it on the wrong place before.it should be placed behind the code that calculating the distance to enemy.(such as"(neg|eq, ":enemies_closest", -1),")
 
君悦 说:
Actually,there is a bug.This code "(position_move_z, pos50, 250, 1),",i put it on the wrong place before.it should be placed behind the code that calculating the distance to enemy.(such as"(neg|eq, ":enemies_closest", -1),")
Thx for bug fix :grin: Feel free for further explanations.
@k0nr@d
Should be useful
 
This is the improved version of the code.
插入代码块:
 [       
        (set_fixed_point_multiplier, 1000),
        (try_for_agents, ":agent_no"),
            (agent_is_non_player, ":agent_no"),
            (agent_is_alive, ":agent_no"),
            (agent_is_human, ":agent_no"),
            (neg|agent_slot_eq, ":agent_no", 1003, 1),
            (agent_get_horse, ":horse_no", ":agent_no"),
            (try_begin),
                (neg|agent_slot_eq, ":agent_no", slot_agent_is_running_away, 1),
                (gt, ":horse_no", -1),
                (agent_get_team, ":team_no", ":agent_no"),
                (gt, ":team_no", -1),
                (agent_get_division, ":class_no", ":agent_no"),
                (gt, ":class_no", -1),
                (agent_get_combat_state, ":combat_state", ":agent_no"),
                (team_get_weapon_usage_order, ":weapon_usage_order", ":team_no", ":class_no"),
                (team_get_hold_fire_order, ":hold_fire", ":team_no", ":class_no"),
                (agent_get_ammo, ":ammo", ":agent_no", 0),
                (assign, ":thrown_ammo", 0),
                (assign, ":ranged_weapon", -1),
                (assign, ":ranged_weapon_tipe", -1),
                (try_begin),
                  (try_for_range, ":item", 0, 4),
                    (agent_get_item_slot, ":item_weapon", ":agent_no", ":item"),
                    (gt, ":item_weapon", 0),
                    (item_get_type, ":item_weapon_tipe", ":item_weapon"),
                    (try_begin),
                      (eq, ":item_weapon_tipe", itp_type_thrown),
                      (agent_get_ammo_for_slot, ":ammo_for_slot", ":agent_no", ":item"),
                      (val_add, ":thrown_ammo", ":ammo_for_slot"),
                    (try_end),
                    (try_begin),
                      (eq, ":ranged_weapon", -1),
                      (this_or_next|eq, ":item_weapon_tipe", itp_type_bow),
                      (this_or_next|eq, ":item_weapon_tipe", itp_type_thrown),
                      (this_or_next|eq, ":item_weapon_tipe", itp_type_pistol),
                      (eq, ":item_weapon_tipe", itp_type_musket),
                      (assign, ":ranged_weapon", ":item_weapon"),
                      (assign, ":ranged_weapon_tipe", ":item_weapon_tipe"),
                    (try_end),
                  (try_end),
                (try_end),
                (gt, ":ranged_weapon_tipe", -1),                
                (neg|item_has_property, ":ranged_weapon", itp_cant_reload_on_horseback),
                (assign, ":have_arrow", 1),
                (try_begin),
                    (store_sub, ":arrow", ":ammo", ":thrown_ammo"),
                    (eq, ":arrow", 0),
                    (agent_set_speed_limit, ":agent_no", 1000),
                    (assign, ":have_arrow", 0),
                (try_end),                
                (eq, ":have_arrow", 1),
                (gt, ":ammo", 0),
                (agent_set_slot, ":agent_no", 1003, 2),
                (neg|eq, ":hold_fire", aordr_hold_your_fire),
                (neg|eq, ":weapon_usage_order", wordr_use_melee_weapons),
                (agent_get_wielded_item, ":weapon_hold", ":agent_no", 0),
                (gt, ":weapon_hold", 0),
                (item_get_type, ":weapon_type", ":weapon_hold"),
                (try_begin),
                    (agent_ai_get_look_target, ":look_target", ":agent_no"),
                    (gt, ":look_target", -1),
                    (agent_is_human, ":look_target"),
                    (agent_is_alive, ":look_target"),
                    (agent_get_team, ":look_target_team", ":look_target"),
                    (gt, ":look_target_team", -1),
                    (neg|teams_are_enemies, ":team_no", ":look_target_team"),
                    (agent_set_look_target_agent, ":agent_no", -1),
                    (agent_force_rethink, ":agent_no"),
                (try_end),
                (assign, ":speed_limit", 1000),
                (agent_get_position, pos50, ":agent_no"), 
                (assign, ":distance_closest", 100000),#1000m
                (assign, ":enemies_closest", -1),
                (team_get_movement_order, ":movement_order", ":team_no", ":class_no"),
                (eq, ":movement_order", 2),
                (try_for_agents, ":enemies"),
                    (agent_is_alive, ":enemies"),
                    (agent_is_human, ":enemies"),
                    (agent_get_position, pos36, ":enemies"),
                    (agent_get_team, ":enemies_team", ":enemies"),
                    (gt, ":enemies_team", -1),
                    (teams_are_enemies, ":team_no", ":enemies_team"),
                    (get_distance_between_positions, ":distance", pos50, pos36),                             
                    (try_begin),
                       (agent_slot_eq, ":enemies", slot_agent_is_running_away, 1),
                       (val_add, ":distance", 10000),
                    (try_end),
                    (assign, ":distance_cavalry", 0),
                    (try_begin),
                        (agent_get_horse, ":enemies_horse", ":enemies"),
                        (gt, ":enemies_horse", -1),
                        (store_div, ":distance_cavalry", ":distance", 3),
                        (val_mul, ":distance_cavalry", 2),
                        (val_min, ":distance_cavalry", 2000),
                        (val_sub, ":distance", ":distance_cavalry"),
                        (assign, ":distance_1", ":distance_cavalry"),
                    (try_end),
                    (neg|ge, ":distance", ":distance_closest"),
                    (assign, ":distance_closest", ":distance"),
                    (assign, ":enemies_closest", ":enemies"),
                (try_end),
                (neg|eq, ":enemies_closest", -1),
                (position_move_z, pos50, 250, 1),
                (agent_get_position, pos51, ":enemies_closest"),
                (try_begin),
                   (agent_get_horse, ":enemies_closest_horse", ":enemies_closest"),
                   (gt, ":enemies_closest_horse", -1),
                   (store_add, ":distance_true", ":distance_1", ":distance_closest"),
                   (position_move_z, pos51, 250, 1),
                (else_try),
                   (assign, ":distance_true", ":distance_closest"),
                   (position_move_z, pos51, 140, 1),
                (try_end),
                (try_begin),
                  (agent_slot_eq, ":enemies_closest", slot_agent_is_running_away, 1),
                  (val_sub, ":distance_true", 10000),
                (else_try),
                  (gt,":distance_true",300),
                  (agent_set_wielded_item, ":agent_no", ":ranged_weapon"),
                (try_end),
                (try_begin),
                    (this_or_next|eq, ":weapon_type", itp_type_bow),
                    (this_or_next|eq, ":weapon_type", itp_type_pistol),
                    (eq, ":weapon_type", itp_type_musket),
                    (agent_get_attack_action, ":attack_action", ":agent_no"),
                    (position_has_line_of_sight_to_position, pos50, pos51),
                    (agent_set_look_target_agent, ":agent_no", ":enemies_closest"),
                    (try_begin),
                        (eq, ":attack_action", 1),
                        (try_begin),
                          (eq, ":movement_order", 2),
                          (agent_get_speed, pos31, ":agent_no"),
                          (position_get_y,":speed_y",pos31),
                          (try_begin),
                             (gt, ":distance_closest", 700),
                             (lt, ":distance_closest", 6000),
                             (store_div, ":speed_limit", ":speed_y",300),#除以3
                             (store_sub, ":speed_limit_distance", ":distance_closest", 2500),
                             (val_div, ":speed_limit_distance", 20),
                             (val_max, ":speed_limit", ":speed_limit_distance"),
                             (val_max, ":speed_limit", 1),
                          (try_end),
                        (try_end),
                        (eq, ":weapon_type", itp_type_bow),
                        (lt, ":distance_true", 4000),
                        (agent_set_attack_action, ":agent_no", 3, 0),
                    (else_try),
                        (eq, ":weapon_type", itp_type_bow),
                        (lt, ":distance_true", 4000),
                        (neq, ":combat_state", 8),
                        (agent_set_attack_action, ":agent_no", 3, 1),
                    (try_end),
                (try_end),
                (agent_set_speed_limit, ":agent_no", ":speed_limit"),
                (try_begin),
                    (agent_is_non_player, ":agent_no"),
                    (neg|eq, ":ranged_weapon_tipe", itp_type_thrown),
                    (gt, ":enemies_closest", -1),
                    (try_begin),
                      (eq, ":movement_order", 2),
                      (this_or_next|agent_slot_eq, ":enemies_closest", slot_agent_is_running_away, 1),
                      (lt, ":distance_closest", 10000),
                      (try_begin),
                        (get_scene_boundaries, pos2, pos3),
                        (position_get_x, ":tip_left_x", pos2),
                        (position_get_y, ":tip_left_y", pos2),
                        (position_get_x, ":right_down_x", pos3),
                        (position_get_y, ":right_down_y", pos3),
                        (position_get_x, ":agent_no_poi_x", pos50),
                        (position_get_y, ":agent_no_poi_y", pos50),
                        (position_copy_origin, pos52, pos2),
                        (store_sub, ":left_x", ":agent_no_poi_x", ":tip_left_x"),
                        (store_sub, ":up_y", ":agent_no_poi_y", ":tip_left_y"),
                        (store_sub, ":right_x", ":right_down_x", ":agent_no_poi_x"),
                        (store_sub, ":down_y", ":right_down_y", ":agent_no_poi_y"),
                        (val_abs, ":left_x"),
                        (val_abs, ":up_y"),
                        (val_abs, ":right_x"),
                        (val_abs, ":down_y"),
                        (store_sub, ":map_middle_x", ":right_down_x", ":tip_left_x"),
                        (store_sub, ":map_middle_y", ":right_down_y", ":tip_left_y"),
                        (val_div, ":map_middle_x", 20),
                        (val_div, ":map_middle_y", 20),
                        (position_move_x, pos52, ":map_middle_x", 1),
                        (position_move_y, pos52, ":map_middle_y", 1),
                        (get_distance_between_positions,":distance_middle", pos52, pos50),
                        (position_transform_position_to_local, pos52, pos50, pos52),
                        (position_transform_position_to_local, pos4, pos50, pos51),
                        (position_get_x, ":map_middle_x", pos52),
                        (position_get_y, ":map_middle_y", pos52),
                        (position_get_x, ":enemies_x", pos4),
                        (position_get_y, ":enemies_y", pos4),
                        (assign, ":effect", 0),
                        (try_begin),
                          (neg|gt, ":distance_closest", 1000),
                          (store_sub,":effect", ":distance_closest", 1500),
                          (val_mul,":effect", 60),
                          (val_max, ":effect", -80000),
                          (assign, ":effect", -80000),
                        (else_try),
                          (gt, ":distance_closest", 2500),
                          (store_sub,":effect", ":distance_closest", 0),
                          (val_mul, ":effect", 5),
                          (val_clamp, ":effect", 35000, 90000),
                          (try_begin),
                            (gt,":enemies_closest_horse",-1),
                            (val_sub,":effect",20000),
                          (try_end),
                        (try_end),
                        (assign, ":distance_to_boundary", 30000),
                        (val_min, ":distance_to_boundary", ":left_x"),
                        (val_min, ":distance_to_boundary", ":up_y"),
                        (val_min, ":distance_to_boundary", ":right_x"),
                        (val_min, ":distance_to_boundary", ":down_y"),
                        (try_begin),
                          (lt, ":distance_to_boundary", 30000),
                          (lt, ":distance_closest", 1500),
                          (agent_slot_eq, ":enemies_closest", slot_agent_is_running_away, 0),
                          (agent_force_rethink, ":agent_no"),
                          (val_mul, ":map_middle_x", 100),
                          (val_mul, ":map_middle_y", 100),
                          (val_mul, ":enemies_x", 100),
                          (val_mul, ":enemies_y", 100),
                          (store_div,":cos_middle",":map_middle_x",":distance_middle"),
                          (store_div,":sin_middle",":map_middle_y",":distance_middle"),
                          (store_div,":cos_enemies",":enemies_x",":distance_true"),
                          (store_div,":sin_enemies",":enemies_y",":distance_true"),
                          (store_acos, ":angle_cos", ":cos_middle"),
                          (store_asin, ":angle_sin", ":sin_middle"),
                          (store_acos, ":angle_cos_enemies", ":cos_enemies"),
                          (store_asin, ":angle_sin_enemies", ":sin_enemies"),
                          (try_begin),
                            (lt, ":angle_sin", 0),
                            (val_mul,":angle_cos", -1),
                            (val_add,":angle_cos", 360000),
                          (try_end),
                          (try_begin),
                            (lt, ":angle_sin_enemies", 0),
                            (val_mul,":angle_cos_enemies", -1),
                            (val_add,":angle_cos_enemies", 360000),
                          (try_end),
                          (store_sub, ":k2", ":angle_cos", ":angle_cos_enemies"),
                          (val_sub, ":k2", 270000),
                          (val_sub, ":k2", ":effect"),
                          (store_add, ":effect", ":k2", ":effect"),
                          (try_begin),
                            (lt, ":angle_cos", ":angle_cos_enemies"),
                            (val_add, ":effect", 360000),
                          (try_end),
                          (val_clamp,":effect",-210000, 15000),
                          (agent_set_attack_action, ":agent_no", 3, 1),
                        (try_end),
                        (store_cos, ":cos", ":effect"),
                        (store_sin, ":sin", ":effect"),
                        (store_mul, ":k_x1", ":cos", ":enemies_y",),
                        (store_mul, ":k_x2", ":sin", ":enemies_x",),
                        (store_mul, ":k_y1", ":sin", ":enemies_y",),
                        (store_mul, ":k_y2", ":cos", ":enemies_x",),
                        (store_add, ":move_x",":k_x1", ":k_x2"),
                        (store_sub, ":move_y",":k_y1", ":k_y2"),
                        (position_move_x, pos50, ":move_x", 0),
                        (position_move_y, pos50, ":move_y", 0),
                      (try_end),
                      (agent_set_scripted_destination, ":agent_no", pos50, 1),
                    (else_try),
                        (agent_clear_scripted_mode, ":agent_no"),
                        (agent_force_rethink, ":agent_no"),
                    (try_end),
                (try_end),
            (else_try),
                (try_begin),
                  (agent_slot_eq, ":agent_no", 1003, 0),
                  (agent_set_slot, ":agent_no", 1003, 1),
                (else_try),
                  (agent_slot_eq, ":agent_no", 1003, 2),
                  (this_or_next|eq, ":ammo", 0),
                  (this_or_next|neg|gt, ":horse_no", 0),
                  (this_or_next|eq, ":hold_fire", aordr_hold_your_fire),
                  (eq, ":weapon_usage_order", wordr_use_melee_weapons),
                  (agent_clear_scripted_mode, ":agent_no"),
                  (agent_set_speed_limit, ":agent_no", 1000),
                  (agent_force_rethink, ":agent_no"),
                  (agent_set_slot, ":agent_no", 1003, 3),
                (try_end),
            (try_end),
        (try_end),
  ])
Oraginal py file:https://mega.nz/#!noVSXYZD!nGSojRJ64VQaEjinjZ8s7EfyjvDGfG7EpdjIpvsebVQ
Optimized lancer's fix and the determine to heros and noldors should be checked here(with bug for Horse archer's AI but the part of lancer's fix and the determine of troops can be useful):
https://mega.nz/#!69smEQzA!B_PNXDt2NLyEWb4ZELjET8LFFjvP0JsRSEiCH8s-USo
 
It seems that the code provided here and the code used in mission_templates.txt is different (287 vs 290 instructions). Anyway, I used the code provided in your mission_templates and also moved the one instruction as suggested to the new place. Unfortunately I can't tell if it worked or not. Yet, now my Heroes behave as described. I left out all of the minimap-thing, because I believe this is what caused the problems so far.

I tried to use a hoster to upload my modified file, but I'm not really familiar with these things:
mission_templates.zip
h**ps://www.file-upload.net/download-12574347/mission_templates.zip.html

If it doesen't work, the main thing I did was to copy&paste the two sets of code (one with 290 instructions and the other with 146 instructions) provided by the file of Jun Yue to the following two scenes:

mst_lead_charge lead_charge 65538  8
mst_village_attack_bandits village_attack_bandits 65538  8
(don't forget to upgrade the respective numbers of code as well 61 -> 63 and 19 -> 21)

He does some other changes in the mission_templates as well, which belong only to the minimap, I think. That's why I left them out. I played a couple of hours with no problems so far. So maybe someone else is interested in and wants to try it out.
 
Noldor Twilight Knights, Asp Vanguards, Omen Seekers, Aeldarian, Ithilrandir, Maltise, Lethaldiran, Sheik Shalavan, Meregan Kierlic, Heroine Adventurers, Hero Adventurers and Burilgi should have this 'buff'.

Maybe Noldor Noble and Maiden Ranger as well, but IMO, only the top ones should. But this will make both Noldor unique spawns very very deadly and annoying to deal against, as they both have a huge amount of Maiden Rangers.
 
Hmm it should be further discussed.
My opinion is:
1.Every hero(NPCs), so that player will be willing to raise horse-archer companions.
Or can add some requirement, like when heros have 5+ horse archer(but need to make leth have this buff at start anyway, make sure he meet the requirement)  and 200+ pros they will behave the clever way.
It makes players fight with leth at early game feel amazing, "damn this elf behave like a player!".
2.Every noldor, the number of noldors in spams and armies can be adjusted as their elite will fit their name now, but after player are not supposed to fight noldor, but use them, and I think few of experienced players will change noldor noble or twilight knights with gen, this buff shall change that.
3.CKO will have the access to have it, the author make this AI connected with noldor arrows, that's very clever imo, I think dev can keep it. CKO can always be insane monsters, so it won't matter for that AI, experience players like me sometimes just not use that for game play.
Btw, as your trainers are clever horse archers, your CKO should have this.
However, as noldor arrow will be so remarkable now, the access to noldor weapons for CKO can be harder, my idea is:
1.At least win for 1+ times in noldor city tournament.
2.80+relations.
3.player won't gain relation with noldor anymore by releasing them when they have 20+ relations.
That's enough imo
4.some special rare troops like HAs(should remove the Xbow from heroine as this script for some reason not work for them).
 
I disagree with every companion having it. I dont think Leslie is talented enough or has experience to do these advanced tactics. Only some should, the most veteran, and player decides if they should be horse archers or remain like the knights they are.

So any companion or troops that uses Noldor Arrows will kite the enemy like it happens in the video?

Noldor Arrows were not obtainable for CKO in 3.8.4, however they were added to the receipts given by Calanon upon hitting with 70 relations with the Noldor. I think that's fine, its hard enough to get from -20 to +70, its a 90 relation gain.

Hero Adventurers have 4 different bows, very different stats-wise within each other. A 500 top tier unit shouldnt go around with a Short Composite bow, the other 3 bows are fine.
Heroine Adventurers have the strongest horse-able crossbow, but thats still very weak compared to the dps an Ebon Bow/Hawkstorm or even better bow have. Add a new crossbow for these but make it alike Asp Thrown Axes, that the player can not obtain it. Else, switch her to archery alike his counterpart, the Hero Adventurer.

--------------------------

@君悦 can this work with archers? So that they kite back whilst they fire?
 
Even Ansen can be a knight, why lesi cannot be a good horse archer? That's for game play, these companions are heros, they share 3 times looting than a normal troop and always piss player off by crying,  they deserve better AI :fruity:
Background wise, with the dusk of twilight, there is no such limit on companions, tbh I think the drinks from gem are turning player and companions into super human.
And not handle the AI to many troops is for play-wise not realistic wise.
 
Latis the Darkgryphon 说:
Even Ansen can be a knight, why lesi cannot be a good horse archer? That's for game play, these companions are heros, they share 3 times looting than a normal troop and always piss player off by crying,  they deserve better AI :fruity:
Background wise, with the dusk of twilight, there is no such limit on companions, tbh I think the drinks from gem are turning player and companions into super human.
And not handle the AI to many troops is for play-wise not realistic wise.

Do you think a weak merchant like Leslie has the experience to kite around like a veteran warrior will?
Sure, companions soak more loot than a normal troop, but they offer many benefits as well:
  • They will never die.
  • You can make them whichever troop-type you want them to. You need him/her to be Archer? Fine. Footman? Fine.
  • Their party skills affect the party. You dont want to spend your points into wound treatment or Engineering? Fine, they will do it for you.
  • They have limitless potential, as they will keep growing and growing with enough time and exp. For example, a mystmountain raider can be upgraded to mystmountain warrior and thats all.
  • They can be sent to send message to vassals or to gather Right to Rule.
  • They can become vassals later on, some will have extra household troops or troops from another faction.

Justifying that they will all act like experienced horse archers just because they all take more loot is not a solid statement. If you want to make it through, make it reasonable. But who cares, if its linked to Noldor Arrows and not specific troops, everyone can play it smart when being horse archers.

PS: will your chinese friend come back and reply?
 
As I said, for reasonable it can add stats requirement, like 5 HA, 200 bow pros, and companions in warband always share the better AI overall if I am not wrong.
For the advantage of companions:
In PoP, troops share the model, it means most companions share the worse stats than troops, the most negative one is Horse Archer skill, even pendor foot Knight has 9 horse archery , and the most "talented" leth who killed a lot of noldors including even some famous nobles only have around 5 horse archery, nevertheless he only has 4 IF, 7 PD, he only have 21 Agi which is the lowest among the whole noldor army, Sir Roland the paladin of Dawn is weaker than every single KoD, is that balance or realistic?
-------------------------------------
It depends on himself, he is busy at study. And archer is different from horse archer, as archers always stand and shooting, there is no AI buff to make them accurate.
And I am not special to him.
Ps: for realistic most horse archers will have this, becuz most troops in game lived for a long time, struggled for dozen of years and survived, so they should be clever, but it makes the game really really hard/annoying and make horse archers overall too strong.
Handle it to special troops is in order to make game enjoyable by making some troops special in AI.
Even for realistic lesi, a merchant should have the good ability to learn, and I swear move slower to shoot more accurately requires not much experience.
 
I think it would be cool to limit it to certain companions only, like Ediz and Leth or whatever. It would go a good way towards differentiating the companions' fighting styles and make them feel more unique.

Now if only we could add talents like Silverstag...
 
状态
不接受进一步回复。
后退
顶部 底部