Скрипты AI от представителей КНР
camera_set_position = (
0, 0, ti_once,[(main_hero_fallen),],
[
(display_message, "@Use the direction key in order to adjust the angle of view.", 0x0000FF),
(display_message, "@Space and Ctrl for control height", 0x0000FF),
(display_message, "@WSAD for movement", 0x0000FF),
(get_player_agent_no, ":player_agent"),
(agent_get_look_position, pos1, ":player_agent"),
(position_set_z_to_ground_level,pos1),
(position_move_z, pos1, 300,1),
(position_move_y, pos1, -300,0),
(copy_position,pos47,pos1),
]
)
custom_commander_camera = (
0, 0, 0, [
(main_hero_fallen),
(this_or_next|key_is_down, key_up),
(this_or_next|key_is_down, key_down),
(this_or_next|key_is_down, key_left),
(this_or_next|key_is_down, key_right),
(this_or_next|game_key_is_down, gk_move_forward),
(this_or_next|game_key_is_down, gk_move_backward),
(this_or_next|game_key_is_down, gk_move_left),
(this_or_next|game_key_is_down, gk_move_right),
(this_or_next|key_is_down, key_left_control),
(key_is_down, key_space ),
],
[
(get_player_agent_no, ":player_agent"),
(neg|agent_is_alive, ":player_agent"),
(assign, ":g_camera_R_x", 0),
(assign, ":g_camera_R_z", 0),
(assign, ":g_camera_y", 0),
(assign, ":g_camera_x", 0),
(assign, ":g_camera_z", 0),
(mission_cam_set_mode, 1),
(try_begin),
(key_is_down, key_up),
(assign, ":g_camera_R_x", 1),
(try_end),
(try_begin),
(key_is_down, key_down),
(assign, ":g_camera_R_x", -1),
(try_end),
(try_begin),
(key_is_down, key_left),
(assign, ":g_camera_R_z", 1),
(try_end),
(try_begin),
(key_is_down, key_right),
(assign, ":g_camera_R_z", -1),
(try_end),
(try_begin),
(game_key_is_down, gk_move_forward),
(assign, ":g_camera_y", 20),
(try_end),
(try_begin),
(game_key_is_down, gk_move_backward),
(assign, ":g_camera_y", -20),
(try_end),
(try_begin),
(game_key_is_down, gk_move_left),
(assign, ":g_camera_x", -20),
(try_end),
(try_begin),
(game_key_is_down, gk_move_right),
(assign, ":g_camera_x", 20),
(try_end),
(try_begin),
(key_is_down, key_left_control),
(assign, ":g_camera_z", -20),
(try_end),
(try_begin),
(key_is_down, key_space ),
(assign, ":g_camera_z", 20),
(try_end),
(position_move_x, pos47, ":g_camera_x",0),
(position_move_y, pos47, ":g_camera_y",0),
(position_move_z, pos47, ":g_camera_z",1),
(position_rotate_z, pos47, ":g_camera_R_z",1),
(position_rotate_x, pos47, ":g_camera_R_x"),
(mission_cam_set_position, pos47),
(try_begin),
(this_or_next|game_key_clicked, gk_view_char),
(game_key_clicked, gk_cam_toggle),
(mission_cam_set_mode, 0),
(try_end),
])
horse_fall_damage=(ti_on_agent_dismount, 0, 0, [],
[
(store_trigger_param_1, ":agent_no"),
(store_trigger_param_2, ":horse_no"),
(set_fixed_point_multiplier,1000),
(neg|agent_is_alive,":horse_no"),
(agent_get_troop_id, ":troop_no", ":agent_no"),
(store_skill_level, ":riding", skl_riding, ":troop_no"),
(store_agent_hit_points,":hp",":agent_no",1),
(agent_get_speed,pos1,":agent_no"),
(position_get_y,":speed_y",pos1),
(store_div,":speed_addation",":speed_y",1000),
(val_mul,":speed_addation", 2),#0-20
(store_random_in_range, ":rand", -5,5),
(val_add,":rand", 10),
(store_add, ":damage_to_rider", ":speed_addation", ":rand"),#
(val_div,":riding", 2),
(store_sub,":real_damage_to_rider", 10, ":riding"),
(val_mul,":real_damage_to_rider", ":damage_to_rider"),
(val_div,":real_damage_to_rider", 10), #(damage_to_rider)(1-riding/1050%)=(damage_to_rider)*(10-riding/2)/10
(val_sub,":hp",":real_damage_to_rider"),
(agent_set_hit_points,":agent_no", ":hp",1),
(agent_deliver_damage_to_agent,":horse_no", ":agent_no"),
(assign, reg1, ":real_damage_to_rider"),
(get_player_agent_no, ":player"),
(eq,":agent_no",":player"),
(display_message,"@You fell from horse, and got {reg1} damage", 0xFF0000),
])
("set_agent_aiming_time",
[
(store_script_param, ":agent_no", 1),
(store_script_param, ":weapon", 2),
(item_get_type,":weapon_type",":weapon"),
(try_begin),
(eq,":weapon_type",itp_type_bow),
(assign,":dest",wpt_archery),
(else_try),
(eq,":weapon_type",itp_type_crossbow),
(assign,":dest",wpt_crossbow),
(else_try),
(this_or_next|eq,":weapon_type",itp_type_musket),
(eq,":weapon_type",itp_type_pistol),
(assign,":dest",wpt_firearm),
(else_try),
(eq,":weapon_type",itp_type_thrown),
(assign,":dest",wpt_throwing),
(try_end),
(agent_get_troop_id,":trp_no",":agent_no"),
(store_proficiency_level, ":pro", ":trp_no", ":dest"),
(item_get_speed_rating,":speed",":weapon"),
(assign,":end",4),
(try_for_range,":slot",0,":end"),
(troop_get_inventory_slot, ":item", ":trp_no", ":slot"),
(eq,":item",":weapon"),
(try_begin),
(troop_get_inventory_slot_modifier, ":modify", ":trp_no", ":slot"),
(eq,":modify",imod_masterwork),
(val_add,":speed",1),
(else_try),
(troop_get_inventory_slot_modifier, ":modify", ":trp_no", ":slot"),
(eq,":modify",imod_heavy),
(val_add,":speed",-2),
(else_try),
(troop_get_inventory_slot_modifier, ":modify", ":trp_no", ":slot"),
(eq,":modify",imod_strong),
(val_add,":speed",-3),
(else_try),
(troop_get_inventory_slot_modifier, ":modify", ":trp_no", ":slot"),
(eq,":modify",imod_bent),
(val_add,":speed",-3),
(else_try),
(troop_get_inventory_slot_modifier, ":modify", ":trp_no", ":slot"),
(eq,":modify",imod_balanced),
(val_add,":speed",3),
(else_try),#you will never know what players would do
(troop_get_inventory_slot_modifier, ":modify", ":trp_no", ":slot"),
(eq,":modify",imod_lame),
(val_add,":speed",-10),
(else_try),
(troop_get_inventory_slot_modifier, ":modify", ":trp_no", ":slot"),
(eq,":modify",imod_swaybacked),
(val_add,":speed",-4),
(else_try),
(troop_get_inventory_slot_modifier, ":modify", ":trp_no", ":slot"),
(eq,":modify",imod_spirited),
(val_add,":speed",2),
(else_try),
(troop_get_inventory_slot_modifier, ":modify", ":trp_no", ":slot"),
(eq,":modify",imod_champion),
(val_add,":speed",4),
(try_end),
(assign,":end",0),#break
(try_end),
(set_fixed_point_multiplier,10000),
(try_begin),
(eq,":weapon_type",itp_type_bow),
(val_mul,":pro",123),#每100点熟练度+12.3%速度
(val_div,":pro",10),
(val_add,":pro",10000),
(val_mul,":speed",":pro"),
(store_div,":r_time",100000*10000,":speed"),
(val_add,":r_time",1000),
#(val_min,":r_time",14800),
#(store_div,":p_time",167300*10000,":speed"),
#(store_div,":t1",163609*10000,":speed"),
#(store_mod, ":mod", 163609*10000, ":speed"),
#(val_sub,":t1",9953),
#(store_pow, ":r_time", ":speed", ":t1"),
#(val_mul,":r_time",":mod"),
#(convert_from_fixed_point,":r_time"),
(else_try),
(this_or_next|eq,":weapon_type",itp_type_pistol),
(this_or_next|eq,":weapon_type",itp_type_musket),
(eq,":weapon_type",itp_type_crossbow),
(store_add,":crossbow_fix",":pro",100),
(store_div,":crossbow_fix",80000,":crossbow_fix"),
(store_add,":r_time",1100,":crossbow_fix"),
#(val_min,":r_time",3000),
#(val_mul,":pro",74),#每100点熟练度+7.4%速度
#(val_div,":pro",10),#这些是算准备时间的
#(val_add,":pro",10000),
#(val_mul,":speed",":pro"),
#(store_div,":p_time",32300*10000,":speed"),
#(store_div,":t1",32639*10000,":speed"),
#(store_mod, ":mod", 32639*10000, ":speed"),
#(val_sub,":t1",1004),
#(store_pow, ":r_time", ":speed", ":t1"),
#(val_mul,":r_time",":mod"),
#(convert_from_fixed_point,":r_time"),
(else_try),#奇怪,投掷好像没有收缩的过程,直接是扩大到极限值
(eq,":weapon_type",itp_type_thrown),
(val_mul,":pro",8),#每100点熟练度+8%速度
(val_add,":pro",10000),
(val_mul,":speed",":pro"),
(store_div,":r_time",64000*10000,":speed"),
(val_add,":r_time",400),#蓄力0.4s
#(val_min,":r_time",5900),
(try_end),
(store_random_in_range,":random",5,16),
(val_mul,":random",10),
(val_add,":r_time",":random"),
# (assign,reg0,":r_time"),
# (display_message,"@{reg0}"),
(store_mission_timer_c_msec,":time_n"),
(val_add,":r_time",":time_n"),
(agent_set_slot,":agent_no",slot_next_shoot_time,":r_time"),
]),
("get_power_skill_fix",
[
(store_script_param_1, ":pow_level"),
(store_script_param_2, ":skill"),
(assign,":pd_level_fix",10000),
# (try_begin),
# (gt,":pow_level",0),
# (store_mul,":pd_level_sq",":pow_level",":pow_level"),
# (store_mul,":pd_level_cb",":pd_level_sq",":pow_level"),
# (val_mul,":pd_level_cb",230),#10^7
# (val_mul,":pd_level_sq",12573),
# (store_mul,":pd_level",584791,":pow_level"),
# (store_add,":pd_level_fix",10012436,":pd_level"),
# (val_add,":pd_level_fix",":pd_level_sq"),
# (val_add,":pd_level_fix",":pd_level_cb"),
# (val_div,":pd_level_fix",1000),
# (try_end),
(try_begin),
(eq,":skill",skl_power_draw),
(try_begin),
(eq,":pow_level",1),
(assign,":pd_level_fix",10580),
(else_try),
(eq,":pow_level",2),
(assign,":pd_level_fix",11137),
(else_try),
(eq,":pow_level",3),
(assign,":pd_level_fix",11663),
(else_try),
(eq,":pow_level",4),
(assign,":pd_level_fix",12166),
(else_try),
(eq,":pow_level",5),
(assign,":pd_level_fix",12649),
(else_try),
(eq,":pow_level",6),
(assign,":pd_level_fix",13115),
(else_try),
(eq,":pow_level",7),
(assign,":pd_level_fix",13567),
(else_try),
(eq,":pow_level",8),
(assign,":pd_level_fix",13997),
(else_try),
(eq,":pow_level",9),
(assign,":pd_level_fix",14425),
(else_try),
(eq,":pow_level",10),
(assign,":pd_level_fix",14834),
(else_try),
(eq,":pow_level",11),
(assign,":pd_level_fix",15237),
(else_try),
(eq,":pow_level",12),
(assign,":pd_level_fix",15613),
(else_try),
(eq,":pow_level",13),
(assign,":pd_level_fix",15992),
(else_try),
(eq,":pow_level",14),
(assign,":pd_level_fix",16364),
(else_try),
(eq,":pow_level",15),
(assign,":pd_level_fix",16730),
(try_end),
(else_try),
(eq,":skill",skl_power_throw),
(try_begin),
(eq,":pow_level",1),
(assign,":pd_level_fix",10484),
(else_try),
(eq,":pow_level",2),
(assign,":pd_level_fix",10954),
(else_try),
(eq,":pow_level",3),
(assign,":pd_level_fix",11400),
(else_try),
(eq,":pow_level",4),
(assign,":pd_level_fix",11833),
(else_try),
(eq,":pow_level",5),
(assign,":pd_level_fix",12245),
(else_try),
(eq,":pow_level",6),
(assign,":pd_level_fix",12648),
(else_try),
(eq,":pow_level",7),
(assign,":pd_level_fix",13037),
(else_try),
(eq,":pow_level",8),
(assign,":pd_level_fix",13416),
(else_try),
(eq,":pow_level",9),
(assign,":pd_level_fix",13786),
(else_try),
(eq,":pow_level",10),
(assign,":pd_level_fix",14141),
(else_try),
(eq,":pow_level",11),
(assign,":pd_level_fix",14494),
(else_try),
(eq,":pow_level",12),
(assign,":pd_level_fix",14835),
(else_try),
(eq,":pow_level",13),
(assign,":pd_level_fix",15160),
(else_try),
(eq,":pow_level",14),
(assign,":pd_level_fix",15491),
(else_try),
(eq,":pow_level",15),
(assign,":pd_level_fix",15815),
(try_end),
(try_end),
(assign,reg0,":pd_level_fix"),
]),
("get_skill_h_archer_fix",
[
(store_script_param_1, ":h_archery_level"),
(assign,":h_a_l_fix",10000),
(try_begin),
(eq,":h_archery_level",0),
(assign,":h_a_l_fix",8938),#8938
(else_try),
(eq,":h_archery_level",1),
(assign,":h_a_l_fix",9040),
(else_try),
(eq,":h_archery_level",2),
(assign,":h_a_l_fix",9147),#9147
(else_try),
(eq,":h_archery_level",3),
(assign,":h_a_l_fix",9253),#9253
(else_try),
(eq,":h_archery_level",4),
(assign,":h_a_l_fix",9356),#9256
(else_try),
(eq,":h_archery_level",5),
(assign,":h_a_l_fix",9455),#9255
(else_try),
(eq,":h_archery_level",6),
(assign,":h_a_l_fix",9555),#9555
(else_try),
(eq,":h_archery_level",7),
(assign,":h_a_l_fix",9654),#9654
(else_try),
(eq,":h_archery_level",8),
(assign,":h_a_l_fix",9751),#9751
(else_try),
(eq,":h_archery_level",9),
(assign,":h_a_l_fix",9850),#9850
(else_try),
(eq,":h_archery_level",10),
(assign,":h_a_l_fix",9945),#9945
(try_end),
(assign,reg0,":h_a_l_fix"),
]),
#input :agent_no, range_weapon_no ,is_rain
#out:missile_speed m/s *10^4 除以10^4后单位为m/s
("get_agent_shoot_speed",
[
(store_script_param_1, ":agent_no"),
(store_script_param_2, ":ranged_weapon"),
(store_script_param, ":is_rain", 3),
(set_fixed_point_multiplier, 10000),
(item_get_type,":weapon_type",":ranged_weapon"),
(try_begin),
(this_or_next|eq,":weapon_type",itp_type_crossbow),
(this_or_next|eq,":weapon_type",itp_type_polearm),
(eq,":weapon_type",itp_type_pistol),
(item_get_missile_speed,":speed",":ranged_weapon"),
(try_begin),
(eq,":weapon_type",itp_type_crossbow),
(eq,":is_rain",1),
(val_mul,":speed",8645),
(else_try),
(convert_to_fixed_point,":speed"),
(try_end),
(val_mul,":speed",120),
(val_div,":speed",100),
(assign,reg0,":speed"),
(else_try),#bow or throw
(this_or_next|eq,":weapon_type",itp_type_thrown),
(eq,":weapon_type",itp_type_bow),
(assign,":h_a_l_fix",1),
(assign,":pd_level_fix",1),
(assign,":rain_fix",1),
(convert_to_fixed_point, ":h_a_l_fix"),
(convert_to_fixed_point, ":pd_level_fix"),
(convert_to_fixed_point, ":rain_fix"),
(agent_get_troop_id,":trp_no",":agent_no"),
(try_begin),
(agent_get_horse, ":horse_no",":agent_no"),
(gt,":horse_no",-1),
(store_skill_level, ":h_archery_level", skl_horse_archery, ":trp_no"),
(call_script,"script_get_skill_h_archer_fix",":h_archery_level"),
(assign,":h_a_l_fix",reg0),
(try_end),
(try_begin),
(eq,":is_rain",1),
(eq,":weapon_type",itp_type_bow),
(assign,":rain_fix",9480),
(try_end),
(try_begin),
(eq,":weapon_type",itp_type_bow),
(store_skill_level, ":pow_level", skl_power_draw, ":trp_no"),
(item_get_difficulty,":diff",":ranged_weapon"),
(val_add,":diff",4),
(assign,":end",4),#只找第一个符合的,找到后跳出循环,避免重复计算(但仍然可能出问题,身上带着不止一把相同的弓,当前使用的弓不是第一个,前缀不一的情况下)最好的办法是手动切换武器,并且切换时设置一个slot标志所在槽的位置
(try_for_range,":slot",0,":end"),
(troop_get_inventory_slot, ":item", ":trp_no", ":slot"),
(eq,":item",":ranged_weapon"),
(try_begin),#modifier_fix 你不知道我发现这个的过程有多么曲折痛苦崩溃
(troop_get_inventory_slot_modifier, ":modify", ":trp_no", ":slot"),
(eq,":modify",imod_masterwork),
(val_add,":diff",4),
(else_try),
(troop_get_inventory_slot_modifier, ":modify", ":trp_no", ":slot"),
(eq,":modify",imod_strong),
(val_add,":diff",2),
(else_try),#you will never know what players would do,so emmm......
(troop_get_inventory_slot_modifier, ":modify", ":trp_no", ":slot"),
(eq,":modify",imod_heavy),
(val_add,":diff",1),
(else_try),
(troop_get_inventory_slot_modifier, ":modify", ":trp_no", ":slot"),
(eq,":modify",imod_stubborn),
(val_add,":diff",1),
(else_try),
(troop_get_inventory_slot_modifier, ":modify", ":trp_no", ":slot"),
(eq,":modify",imod_timid),
(val_add,":diff",-1),
(else_try),
(troop_get_inventory_slot_modifier, ":modify", ":trp_no", ":slot"),
(eq,":modify",imod_spirited),
(val_add,":diff",1),
(else_try),
(troop_get_inventory_slot_modifier, ":modify", ":trp_no", ":slot"),
(eq,":modify",imod_champion),
(val_add,":diff",2),
(try_end),
(assign,":end",0),#break
(try_end),
(val_min,":pow_level",":diff"),
(call_script,"script_get_power_skill_fix",":pow_level",skl_power_draw),
(assign,":pd_level_fix",reg0),
(else_try),
(eq,":weapon_type",itp_type_thrown),
(store_skill_level, ":pow_level", skl_power_throw, ":trp_no"),
(call_script,"script_get_power_skill_fix",":pow_level",skl_power_throw),
(assign,":pd_level_fix",reg0),
(try_end),
(item_get_missile_speed,":speed",":ranged_weapon"),
(convert_to_fixed_point, ":speed"),
(val_mul,":speed",120),
(val_div,":speed",100),
(val_mul,":speed",":pd_level_fix"),
(convert_from_fixed_point, ":speed"),
(val_mul,":speed",":rain_fix"),
(convert_from_fixed_point, ":speed"),
(val_mul,":speed",":h_a_l_fix"),
(convert_from_fixed_point, ":speed"),
(assign,reg0,":speed"),
(try_end),
]),
("get_agent_throw_time",
[
(store_script_param, ":agent_no", 1),
(store_script_param, ":weapon", 2),
(agent_get_troop_id,":trp_no",":agent_no"),
(item_get_speed_rating,":speed",":weapon"),
(assign,":end",4),
(try_for_range,":slot",0,":end"),#fix_modifiy
(troop_get_inventory_slot, ":item", ":trp_no", ":slot"),
(eq,":item",":weapon"),
(try_begin),
(troop_get_inventory_slot_modifier, ":modify", ":trp_no", ":slot"),
(eq,":modify",imod_masterwork),
(val_add,":speed",1),
(else_try),
(troop_get_inventory_slot_modifier, ":modify", ":trp_no", ":slot"),
(eq,":modify",imod_heavy),
(val_add,":speed",-2),
(else_try),
(troop_get_inventory_slot_modifier, ":modify", ":trp_no", ":slot"),
(eq,":modify",imod_strong),
(val_add,":speed",-3),
(else_try),
(troop_get_inventory_slot_modifier, ":modify", ":trp_no", ":slot"),
(eq,":modify",imod_bent),
(val_add,":speed",-3),
(else_try),
(troop_get_inventory_slot_modifier, ":modify", ":trp_no", ":slot"),
(eq,":modify",imod_balanced),
(val_add,":speed",3),
(else_try),#you will never know what players would do
(troop_get_inventory_slot_modifier, ":modify", ":trp_no", ":slot"),
(eq,":modify",imod_lame),
(val_add,":speed",-10),
(else_try),
(troop_get_inventory_slot_modifier, ":modify", ":trp_no", ":slot"),
(eq,":modify",imod_swaybacked),
(val_add,":speed",-4),
(else_try),
(troop_get_inventory_slot_modifier, ":modify", ":trp_no", ":slot"),
(eq,":modify",imod_spirited),
(val_add,":speed",2),
(else_try),
(troop_get_inventory_slot_modifier, ":modify", ":trp_no", ":slot"),
(eq,":modify",imod_champion),
(val_add,":speed",4),
(try_end),
(assign,":end",0),#break
(try_end),
(store_proficiency_level, ":pro", ":trp_no", wpt_throwing),
(val_mul,":pro",8),#每100点熟练度加8%速度
(val_add,":pro",10000),
(set_fixed_point_multiplier,10000),
(val_mul,":speed",":pro"),
(store_div,":t1",23394*10000,":speed"),
(store_mod, ":mod", 23394*10000, ":speed"),
(val_sub,":t1",9884),
#(convert_to_fixed_point,":speed"),
(store_pow, ":throw_time", ":speed", ":t1"),
(val_mul,":throw_time",":mod"),
(convert_from_fixed_point,":throw_time"),
(assign,reg0,":throw_time"),
]),
#if a agent want to shoot certain pos exactly ,this script get the pos he should look at
#return pos1 as the pos agent should look at
#reg0 used for script_agent_set_shoot_target
#use pos2 and pos3 and return pos1
("agent_get_shoot_pos",
[
(store_script_param, ":agent_no", 1),
(store_script_param, ":pos", 2),
(store_script_param, ":ranged_weapon", 3),
(set_fixed_point_multiplier, 10000),
(copy_position, pos1, ":pos"),#避免后续获取pos时覆盖了这个":pos"
(position_get_x,":x1",pos1),
(position_get_y,":y1",pos1),
(position_get_z,":z1",pos1),
(agent_get_bone_position, pos2, ":agent_no", 9, 1),
(agent_get_look_position, pos3, ":agent_no"),
(position_copy_rotation, pos2, pos3),
(position_copy_rotation, pos1, pos3),
(try_begin),
(agent_is_non_player,":agent_no"),
(position_move_z, pos2, 14, 0),
(try_end),
(position_get_x,":x2",pos2),
(position_get_y,":y2",pos2),
(position_get_z,":z2",pos2),
(store_sub,":z",":z1",":z2"),
(store_sub,":x",":x1",":x2"),
(store_sub,":y",":y1",":y2"),
(store_mul,":x_sq",":x",":x"),
(store_mul,":y_sq",":y",":y"),
(store_add,":d_sq",":x_sq",":y_sq"),
(call_script,"script_get_agent_shoot_speed",":agent_no",":ranged_weapon",0),
(assign,":v",reg0), #1_fp
(store_mul,":v_sq",":v",":v"), #2_fp
(assign,":g",10),
(convert_to_fixed_point,":g"), #1_fp
(store_div,":t",":v_sq",":g"), #1_fp
(store_mul,":t_sq",":t",":t"), #2_fp
(store_mul,":2ty",":t",":z"), #2_fp
(val_mul,":2ty",2),
(store_sub,":delta",":t_sq",":d_sq"), #2_fp
(val_sub,":delta",":2ty"),
(try_begin),
(gt,":delta",0),
(set_fixed_point_multiplier, 1),
(store_sqrt, ":delta_sqrt", ":delta"),
(store_sub,":res",":t",":delta_sqrt"),
(try_begin), #agent采用触发器迭代调精度
(agent_is_non_player,":agent_no"),
(val_sub,":res",":z"),#m*10^4=cm*10^2
(val_div,":res",100),#change to cm
(position_move_z, pos1, ":res", 1),
(position_move_z,pos1,-14,0),
(else_try),#for player #玩家则手动迭代
(try_begin),
(is_camera_in_first_person),
(assign,":view_fix",50),#cm
(else_try),
(assign,":view_fix",14),#cm
(try_end),
(try_for_range,":unused",0,3),#3 times
(store_mul, ":h_sq", ":res",":res"), #2_fp
(store_add,":L_sq",":h_sq",":d_sq"), #2_fp
(set_fixed_point_multiplier, 1),
(store_sqrt,":L",":L_sq"),#fx_point=1 1_fp *_fp的意思是fix_point的*次方级
(store_sqrt,":d",":d_sq"),#fx_point=1 1_fp
(set_fixed_point_multiplier, 10000),
(convert_to_fixed_point,":res"), #2_fp
(convert_to_fixed_point,":d"), #2_fp
(store_div,":sin",":res",":L"), #1_fp
(store_div,":cos",":d",":L"), #1_fp
(val_mul,":sin",":view_fix"), #1_fp
(val_div,":sin",100), #change to cm
(val_mul,":cos",":view_fix"), #1_fp
(val_div,":cos",100), #change to cm
(store_sub,":h1",":z",":sin"), #1_fp
(store_add,":d1",":d",":cos"), #1_fp
(store_mul,":d1_sq",":d1",":d1"),
(store_mul,":2ty",":t",":h1"),
(val_mul,":2ty",2),
(store_sub,":delta",":t_sq",":d1_sq"), #2_fp
(val_sub,":delta",":2ty"),
(set_fixed_point_multiplier, 1),
(store_sqrt, ":delta_sqrt", ":delta"),
(store_sub,":res",":t",":delta_sqrt"),
(try_end),
(val_sub,":res",":z"),#m*10^4=cm*10^2
(val_div,":res",100),#change to cm
(position_move_z, pos1, ":res", 1),
(try_end),
#(set_spawn_position,pos1),
#(spawn_scene_prop, "spr_stone_ball"),
(assign,reg0,":v"),
(else_try),
(assign,reg0,-1),
#(display_message,"@you need to get closer"),
(try_end),
]),
("agent_set_shoot_target",
[
(store_script_param_1,":agent_no"),
(store_script_param_2,":target"),
(store_script_param,":ranged_weapon",3),#just to save code
(agent_get_bone_position,pos5,":target",8,1),#胸部(似乎为右胸)
(call_script,"script_agent_get_shoot_pos",":agent_no",pos5,":ranged_weapon"),
(assign,":v",reg0),
(try_begin),
(gt,":v",0),#先算出静止时该瞄准的点,然后据此估算击中时间,再根据速度做偏移
(set_fixed_point_multiplier,1000),
(agent_get_speed, pos0, ":target"),
(position_get_x,":speed_x",pos0),#m/s *fixed*ms /(10000)=cm
(position_get_y,":speed_y",pos0),
(get_distance_between_positions, ":dist", pos1, pos2),#cm
(val_mul,":dist",100000),
(store_div,":m_second",":dist",":v"),
(try_begin),#投掷有个出手时间,这里修正一下
(item_get_type,":weapon_type",":ranged_weapon"),
(eq,":weapon_type",itp_type_thrown),
(call_script,"script_get_agent_throw_time",":agent_no",":ranged_weapon"),
(val_add,":m_second",reg0),
(try_end),
(assign,reg0,":m_second"),#可以据此判断是否要射击
(try_begin),
(position_normalize_origin,":speed",pos0),
(ge,":speed",500),#0.5m/s
(agent_get_position,pos4,":agent_no"),
(agent_get_position,pos3,":target"),#traget面朝方向(速度方向)
(position_transform_position_to_local,pos0,pos4,pos3),
(position_get_rotation_around_z, ":angle_1", pos0),#顺时针旋转x度到正北
(store_sub,":angle_2",":angle_1",90),
(convert_to_fixed_point, ":angle_1"),
(convert_to_fixed_point, ":angle_2"),
(store_cos, ":cos", ":angle_1"),
(store_sin, ":sin", ":angle_1"),
(position_get_x, ":x1", pos0),
(position_get_y, ":y1", pos0),
(position_normalize_origin, ":d1", pos0),
(store_mul, ":k1", ":x1", ":cos"),
(store_mul, ":k2", ":y1", ":sin"),
(store_add, ":speed_1", ":k1", ":k2"),
(store_mul, ":k1", ":x1", ":sin"),
(store_mul, ":k2", ":y1", ":cos"),
(store_sub, ":speed_2", ":k1", ":k2"),
(val_mul, ":speed_1", ":speed_y"),
(val_mul, ":speed_2", ":speed_x"),
(store_add,":speed_r",":speed_1",":speed_2"),
(val_div, ":speed_r", ":d1"),#正左负右
(convert_from_fixed_point, ":speed_r"),
(val_div,":speed_r",90),
(val_abs,":speed_r"),
(val_add,":m_second",":speed_r"),
# (try_begin),
# (key_clicked,key_m),
# (assign,reg0,":speed_r"),
# (display_message,"@{reg0}"),
# (try_end),
# (store_random_in_range,":random",-20,21),
# (val_add,":m_second",":random"),
(val_mul,":speed_x",":m_second"),
(val_mul,":speed_y",":m_second"),
(val_div,":speed_x",10000),
(val_div,":speed_y",10000),
(position_copy_rotation,pos5,pos3),
(position_get_distance_to_terrain, ":z", pos5),#粗略修正下地形影响
(position_move_x,pos5,":speed_x",0),
(position_move_y,pos5,":speed_y",0),
(position_get_distance_to_terrain, ":z1", pos5),
(val_sub,":z",":z1"),
(val_div,":z",10),
(position_move_z,pos5,":z",1),
#二次迭代减少误差
(call_script,"script_agent_get_shoot_pos",":agent_no",pos5,":ranged_weapon"),
(assign,reg0,":m_second"),
(try_end),
# (store_random_in_range,":random",-20,21),
# (position_move_x,pos1,":random",0),
# (store_random_in_range,":random",-20,21),
# (position_move_y,pos1,":random",0),
# (store_random_in_range,":random",-20,0),
# (position_move_z,pos1,":random",1),
# (agent_set_look_target_position,":agent_no",pos1),
(else_try),
(assign,reg0,99999),
(try_end),
]),
shoot_ai = (
0,0,0,[],
[
(eq,0,0),
(store_mission_timer_c_msec,":time_n"),
(try_for_agents,":agent_no"),
(agent_is_alive,":agent_no"),
(agent_slot_eq,":agent_no",slot_agent_archer_state,2),
(agent_get_wielded_item,":weapon",":agent_no",0),
(gt,":weapon",0),
(item_get_type,":item_type",":weapon"),
(this_or_next|eq,":item_type",itp_type_bow),
(this_or_next|eq,":item_type",itp_type_thrown),
(this_or_next|eq,":item_type",itp_type_pistol),
(this_or_next|eq,":item_type",itp_type_musket),
(eq,":item_type",itp_type_crossbow),
(try_begin),
(assign,":continue",0),
(agent_ai_get_look_target,":target",":agent_no"),
(try_begin),
(gt,":target",-1),
(agent_is_alive,":target"),
(else_try),#无目标则自己找一个
(agent_ai_get_num_cached_enemies, ":num", ":agent_no"),
(try_for_range,":index",0,":num"),#get target
(store_random_in_range,":index",0,":num"),
(agent_ai_get_cached_enemy, reg0, ":agent_no", ":index"),
(agent_is_alive, reg0),
(assign,":target",reg0),
(agent_set_look_target_agent,":agent_no",":target"),
(assign,":num",-1),#break
(try_end),
(try_end),
(gt,":target",-1),
(agent_is_alive,":target"),
(agent_get_bone_position, pos1, ":agent_no", 9, 1),
(agent_get_bone_position, pos2, ":target", 9, 1),
(position_has_line_of_sight_to_position,pos1,pos2),
(assign,":continue",1),
(agent_get_attack_action,":attack_action",":agent_no"),
(call_script,"script_agent_set_shoot_target",":agent_no",":target",":weapon"),
(try_begin),
(eq,":attack_action",0),#free
(lt,reg0,2500),
(neg|agent_slot_ge,":agent_no",slot_next_shoot_time,":time_n"),
(agent_set_defend_action,":agent_no",-2,1),
(agent_set_attack_action,":agent_no",3,1),
(call_script,"script_set_agent_aiming_time",":agent_no",":weapon"),
(else_try),
(eq,":attack_action",1),
(lt,reg0,2500),
(agent_set_attack_action,":agent_no",3,1),
(agent_set_look_target_position,":agent_no",pos1),
(agent_get_speed,pos0,":agent_no"),
(set_fixed_point_multiplier,1000),
(position_normalize_origin,":speed",pos0),
(lt,":speed",2000),#2m/s
(try_begin),
(agent_slot_eq,":agent_no",slot_agent_next_release_time,0),
(store_add,":stand_t",":time_n",700),#站0.7s让准星收缩
(agent_set_slot,":agent_no",slot_agent_next_release_time,":stand_t"),
(try_end),
(neg|agent_slot_ge,":agent_no",slot_next_shoot_time,":time_n"),
(neg|agent_slot_ge,":agent_no",slot_agent_next_release_time,":time_n"),
(agent_set_attack_action,":agent_no",3,0),
(agent_set_slot,":agent_no",slot_agent_next_release_time,0),#reset
(store_random_in_range,":random",5,16),
(val_mul,":random",10),
(val_add,":time_n",":random"),
(agent_set_slot,":agent_no",slot_next_shoot_time,":time_n"),
(try_end),
#
#使用原版的抬手系统
# (try_begin),
# (agent_set_defend_action,":agent_no",-2,1),
# (eq,":attack_action",1),
# (agent_set_look_target_position,":agent_no",pos1),
# (try_begin),
# (agent_slot_eq,":agent_no",slot_next_shoot_time,0),
# (call_script,"script_set_agent_aiming_time",":agent_no",":weapon"),
# (agent_set_attack_action,":agent_no",3,1),
# (else_try),
# (set_fixed_point_multiplier,1000),
# (agent_get_speed,pos0,":agent_no"),
# (position_normalize_origin,":speed",pos0),
# (lt,":speed",1000),
# (try_begin),
# (agent_slot_eq,":agent_no",slot_agent_next_release_time,0),
# (val_add,":time_n",700),#站0.7s让准星收缩
# (agent_set_slot,":agent_no",slot_agent_next_release_time,":time_n"),
# (try_end),
# (neg|agent_slot_ge,":agent_no",slot_next_shoot_time,":time_n"),
# (neg|agent_slot_ge,":agent_no",slot_agent_next_release_time,":time_n"),
# (agent_set_attack_action,":agent_no",3,0),
# (agent_set_slot,":agent_no",slot_agent_next_release_time,0),#reset
# (agent_set_slot,":agent_no",slot_agent_next_release_time,0),
# (try_end),
# (try_end),
(else_try),
(neg|agent_slot_eq,":agent_no",slot_next_shoot_time,0),
(this_or_next|all_enemies_defeated),
(eq,":continue",0),
(agent_set_attack_action, ":agent_no", -2, 1),#cancel shoot
(agent_set_defend_action,":agent_no",3,1),
(try_end),
(else_try),
(agent_slot_eq,":agent_no",slot_agent_archer_state,2),
(agent_set_attack_action, ":agent_no", -2, 0),
(agent_set_attack_action, ":agent_no", -2, 1),
(agent_set_defend_action,":agent_no",-2,1),
(agent_force_rethink,":agent_no"),
(agent_clear_scripted_mode,":agent_no"),
(agent_set_slot,":agent_no",slot_agent_archer_state,3),
(try_end),
])
archer_ai = (
0.5, 0, 0, [],
[
#(key_is_down,key_t),
(try_for_agents,":agent_no"),
(neg|agent_slot_eq,":agent_no",slot_agent_archer_state,1),
(agent_is_ally,":agent_no"),
(agent_is_alive,":agent_no"),
(agent_is_human,":agent_no"),
(agent_is_non_player,":agent_no"),
(agent_slot_eq, ":agent_no", slot_agent_is_running_away, 0),
(agent_get_ammo,":ammo",":agent_no",0),
(agent_get_horse,":horse_no",":agent_no"),
(gt,":ammo",0),
(assign,":continue",0),
(try_begin),
(agent_slot_eq,":agent_no",slot_agent_archer_state,0),#init
(try_for_range,":slot",0,4),
(agent_get_item_slot,":item_id",":agent_no",":slot"),
(gt,":item_id",0),
(item_get_type,":item_type",":item_id"),
(this_or_next|eq,":item_type",itp_type_bow),
(this_or_next|eq,":item_type",itp_type_thrown),
(this_or_next|eq,":item_type",itp_type_pistol),
(this_or_next|eq,":item_type",itp_type_musket),
(eq,":item_type",itp_type_crossbow),
(assign,":continue",1),
(try_end),
(eq,":continue",1),
(agent_set_slot,":agent_no",slot_agent_archer_state,2),
(else_try),#for
(agent_get_wielded_item,":weapon",":agent_no",0),
(gt,":weapon",0),
(item_get_type,":item_type",":weapon"),
(this_or_next|eq,":item_type",itp_type_bow),
(this_or_next|eq,":item_type",itp_type_thrown),
(this_or_next|eq,":item_type",itp_type_pistol),
(this_or_next|eq,":item_type",itp_type_musket),
(eq,":item_type",itp_type_crossbow),
(assign,":continue",1),
(agent_set_slot,":agent_no",slot_agent_archer_state,2),
(try_end),
(eq,":continue",1),
(lt,":horse_no",0),
(agent_ai_get_num_cached_enemies, ":num", ":agent_no"),
(assign,":target",-1),
(try_for_range,":index",0,":num"),#get target
(agent_ai_get_cached_enemy, ":enemies", ":agent_no", ":index"),
(agent_is_alive,":enemies"),
(assign,":target",":enemies"),
(agent_set_look_target_agent,":agent_no",":target"),
(assign,":num",-1),#break
(try_end),
(gt,":target",-1),
(agent_get_bone_position, pos1, ":agent_no", 9, 1),
(agent_get_bone_position, pos2, ":target", 9, 1),
(try_begin),
(eq,0,0),
(agent_get_team,":team_no",":agent_no"),
(agent_get_division,":class_no",":agent_no"),
(team_get_movement_order,":movement_order",":team_no",":class_no"),
(eq,":movement_order",mordr_charge),
(position_has_line_of_sight_to_position,pos1,pos2),
(agent_get_look_position, pos3, ":agent_no"),
(position_copy_rotation,pos3,pos1),
(get_distance_between_positions,":dist",pos1,pos2),#cm
(assign,":dist_fix",0),
(try_begin),
(lt,":dist",1500),#15m
(store_sub,":dist_fix",":dist",2000),
(else_try),
(gt,":dist",6000),#60m
(store_sub,":dist_fix",":dist",6000),
(else_try),
(store_random_in_range,":random",0,1000),#大概是每8s前进两米
(assign,":possible",8),
(val_mul,":possible",1000),
(val_div,":possible",500),#这里填触发间隔 单位mm
(val_max,":possible",1),
(store_div,":possible",1000,":possible"),
(le,":random",":possible"),
(assign,":dist_fix",200),
(try_end),
(position_move_y,pos3,":dist_fix",0),
(agent_set_scripted_destination,":agent_no",pos3,1),
(try_end),
(try_begin),
(eq,0,0),
(position_has_line_of_sight_to_position,pos1,pos2),
(agent_get_attack_action,":attack_action",":agent_no"),
(this_or_next|eq,":attack_action",5),#reloading
(eq,":attack_action",1),
(agent_get_position,pos0,":agent_no"),
(agent_set_scripted_destination,":agent_no",pos0,1),
(else_try),
(agent_clear_scripted_mode, ":agent_no"),
(agent_force_rethink,":agent_no"),
(try_end),
(else_try),
(try_begin),
(agent_slot_eq,":agent_no",slot_agent_archer_state,0),
(agent_set_slot,":agent_no",slot_agent_archer_state,1),
(else_try),
(agent_slot_eq,":agent_no",slot_agent_archer_state,2),
(this_or_next|agent_slot_eq, ":agent_no", slot_agent_is_running_away, 1),
(this_or_next|eq, ":ammo", 0),
(this_or_next|eq,":target",-1),
(eq,":continue",0),
(lt,":horse_no",0),
(agent_clear_scripted_mode,":agent_no"),
(agent_force_rethink,":agent_no"),
(agent_set_slot,":agent_no",slot_agent_archer_state,3),
(try_end),
(try_end),
])
Спросить автора прежде чем использовать! Это не является открытым ОСП.
Родная страница
Комментариев 1
Посетители, находящиеся в группе Гости, не могут оставлять комментарии к данной публикации.