common_automatic = (0.005,0,0, [(get_player_agent_no,":p"), (try_begin), (key_is_down,key_right_mouse_button), # (neg|key_is_down,key_left_mouse_button), # (agent_set_attack_action, ":p", 1), (agent_set_animation, ":p", "anim_ready_musket", 1), (try_end), ],[ (try_for_agents,":attacker_agent"), (agent_is_human,":attacker_agent"), (agent_is_alive,":attacker_agent"), (agent_get_wielded_item,":agent_cur_weapon",":attacker_agent"), (gt,":agent_cur_weapon",0), (item_get_type, ":item_type", ":agent_cur_weapon"), (eq,":item_type",itp_type_musket), (agent_get_slot,":automatic_ticker_time",":attacker_agent",slot_agent_automatic_ticker_time), (agent_get_attack_action, ":action_state", ":attacker_agent"), (try_begin), (agent_is_non_player, ":attacker_agent"), (try_begin), (gt,":action_state",0),#free (neq,":action_state",5),#reloading (neq,":action_state",7),#cancelling (agent_set_attack_action, ":attacker_agent", 0), (try_end), (else_try),#player simulate attack (eq,":action_state",1),#readying #ticker trigger (try_begin), (le,":automatic_ticker_time",0), #ticker trigger (item_get_speed_rating,":automatic_ticker_time",":agent_cur_weapon"), (val_max,":automatic_ticker_time",1), (store_div,":automatic_ticker_time",200,":automatic_ticker_time"), (agent_set_slot,":attacker_agent",slot_agent_automatic_ticker_time,":automatic_ticker_time"), (agent_get_item_cur_ammo, ":cur_ammo", ":attacker_agent"), (gt,":cur_ammo",0), #match the right ammmo type (assign,":cur_ammo_id",-1), (assign,":item_slot_num",4), (try_for_range,":cur_item_slot",0,":item_slot_num"), (agent_get_item_slot, ":item_no", ":attacker_agent", ":cur_item_slot"), (ge,":item_no",0), (item_get_type, ":item_type", ":item_no"), (eq,":item_type",itp_type_bullets), (assign,":cur_ammo_id",":item_no"), (assign,":item_slot_num",0),#break (try_end), (try_begin), (lt,":cur_ammo_id",0), (assign,":cur_ammo_id","itm_ha_cartridges"),#as default (try_end), #get original position of weapon (agent_get_look_position,pos24,":attacker_agent"), (item_get_weapon_length,":length",":agent_cur_weapon"), (position_move_y, pos24,":length"), (position_move_y, pos24,40), (agent_get_horse,":attacker_agent_horse",":attacker_agent"), (try_begin), (agent_get_crouch_mode,":crouch_mode",":attacker_agent"), (eq, ":crouch_mode", 1), (position_move_z,pos24,115,1), (else_try), (lt,":attacker_agent_horse",0), (position_move_z,pos24,170,1), (else_try), (position_move_z,pos24,270,1), (try_end), ##get weapon position after calculating accuracy (copy_position,pos25,pos24), (item_get_accuracy,":accuracy",":agent_cur_weapon"), (val_max,":accuracy",1), (store_div,":randomize_value",500,":accuracy"), (store_random_in_range,":z",0,":randomize_value"), (store_random_in_range,":x",0,":randomize_value"), (position_rotate_z,pos25,":z"), (position_rotate_x,pos25,":x"), #create particle,animation and sound effect of weapon (agent_set_animation, ":attacker_agent", "anim_release_musket", 1), (item_get_slot,":shoot_sound",":agent_cur_weapon",slot_item_shot_sound), (play_sound_at_position, ":shoot_sound", pos24), # (particle_system_burst, "psys_rifle_smoke", pos24, 10), # (particle_system_burst, "psys_gun_fire", pos24, 20), (particle_system_burst, "psys_rifle_smoke", pos1, 1), (particle_system_burst, "psys_gun_fire", pos1, 3), (item_get_missile_speed,":missile_speed",":agent_cur_weapon"), (set_fixed_point_multiplier,1), (add_missile, ":attacker_agent", pos25, ":missile_speed", ":agent_cur_weapon", imod_plain, ":cur_ammo_id",imod_plain), #reduce ammo (val_sub,":cur_ammo",1), (agent_set_ammo,":attacker_agent",":agent_cur_weapon",":cur_ammo"), (else_try), (val_sub,":automatic_ticker_time",1), (agent_set_slot,":attacker_agent",slot_agent_automatic_ticker_time,":automatic_ticker_time"), (try_end), (else_try), (item_get_speed_rating,":automatic_ticker_time",":agent_cur_weapon"), (val_max,":automatic_ticker_time",1), (store_div,":automatic_ticker_time",400,":automatic_ticker_time"), (agent_set_slot,":attacker_agent",slot_agent_automatic_ticker_time,":automatic_ticker_time"), (try_end), (try_end), (try_for_agents,":attacker_agent"), (agent_is_human,":attacker_agent"), (agent_is_alive,":attacker_agent"), (agent_get_wielded_item,":agent_cur_weapon",":attacker_agent"), (gt,":agent_cur_weapon",0), (item_get_type, ":item_type", ":agent_cur_weapon"), (eq,":item_type",itp_type_musket), (agent_get_slot,":automatic_ticker_time",":attacker_agent",slot_agent_automatic_ticker_time), (agent_get_attack_action, ":action_state", ":attacker_agent"), (try_begin), (agent_is_non_player, ":attacker_agent"), (try_begin), (gt,":action_state",0),#free (neq,":action_state",5),#reloading (neq,":action_state",7),#cancelling (agent_set_attack_action, ":attacker_agent", 0), (try_end), (else_try),#player simulate attack (eq,":action_state",1),#readying #ticker trigger (try_begin), (le,":automatic_ticker_time",0), #ticker trigger (item_get_speed_rating,":automatic_ticker_time",":agent_cur_weapon"), (val_max,":automatic_ticker_time",1), (store_div,":automatic_ticker_time",200,":automatic_ticker_time"), (agent_set_slot,":attacker_agent",slot_agent_automatic_ticker_time,":automatic_ticker_time"), (agent_get_item_cur_ammo, ":cur_ammo", ":attacker_agent"), (gt,":cur_ammo",0), #match the right ammmo type (assign,":cur_ammo_id",-1), (assign,":item_slot_num",4), (try_for_range,":cur_item_slot",0,":item_slot_num"), (agent_get_item_slot, ":item_no", ":attacker_agent", ":cur_item_slot"), (ge,":item_no",0), (item_get_type, ":item_type", ":item_no"), (eq,":item_type",itp_type_bullets), (assign,":cur_ammo_id",":item_no"), (assign,":item_slot_num",0),#break (try_end), (try_begin), (lt,":cur_ammo_id",0), (assign,":cur_ammo_id","itm_ha_cartridges"),#as default (try_end), #get original position of weapon (agent_get_look_position,pos24,":attacker_agent"), (item_get_weapon_length,":length",":agent_cur_weapon"), (position_move_y, pos24,":length"), (position_move_y, pos24,40), (agent_get_horse,":attacker_agent_horse",":attacker_agent"), (try_begin), (agent_get_crouch_mode,":crouch_mode",":attacker_agent"), (eq, ":crouch_mode", 1), (position_move_z,pos24,115,1), (else_try), (lt,":attacker_agent_horse",0), (position_move_z,pos24,170,1), (else_try), (position_move_z,pos24,270,1), (try_end), ##get weapon position after calculating accuracy (copy_position,pos25,pos24), (item_get_accuracy,":accuracy",":agent_cur_weapon"), (val_max,":accuracy",1), (store_div,":randomize_value",500,":accuracy"), (store_random_in_range,":z",0,":randomize_value"), (store_random_in_range,":x",0,":randomize_value"), (position_rotate_z,pos25,":z"), (position_rotate_x,pos25,":x"), #create particle,animation and sound effect of weapon (agent_set_animation, ":attacker_agent", "anim_release_musket", 1), (item_get_slot,":shoot_sound",":agent_cur_weapon",slot_item_shot_sound), (play_sound_at_position, ":shoot_sound", pos24), # (particle_system_burst, "psys_rifle_smoke", pos24, 10), # (particle_system_burst, "psys_gun_fire", pos24, 20), (particle_system_burst, "psys_rifle_smoke", pos1, 1), (particle_system_burst, "psys_gun_fire", pos1, 3), (item_get_missile_speed,":missile_speed",":agent_cur_weapon"), (set_fixed_point_multiplier,1), (add_missile, ":attacker_agent", pos25, ":missile_speed", ":agent_cur_weapon", imod_plain, ":cur_ammo_id",imod_plain), #reduce ammo (val_sub,":cur_ammo",1), (agent_set_ammo,":attacker_agent",":agent_cur_weapon",":cur_ammo"), (else_try), (val_sub,":automatic_ticker_time",1), (agent_set_slot,":attacker_agent",slot_agent_automatic_ticker_time,":automatic_ticker_time"), (try_end), (else_try), (item_get_speed_rating,":automatic_ticker_time",":agent_cur_weapon"), (val_max,":automatic_ticker_time",1), (store_div,":automatic_ticker_time",400,":automatic_ticker_time"), (agent_set_slot,":attacker_agent",slot_agent_automatic_ticker_time,":automatic_ticker_time"), (try_end), (try_end), ])