[logic]
active = beh@base
post_combat_time = 0,0
trade = misc\trade\trade_companion.ltx

;======================
; default logic
;======================
[beh@general_no_companion]
sound_idle = state
behavior_state = beh_move
target = waypoint
walk_dist = 100
jog_dist = 220
wait_anim = guard
walk_anim = patrol
jog_anim = patrol
run_anim = rush
delay_anim = guard
meet = meet
combat_ignore_cond = {=actor_enemy =check_enemy_name(actor)} false, true
combat_ignore_keep_when_attacked = true
gather_items_enabled = false
help_wounded_enabled = false
corpse_detection_enabled = false
use_camp = false
invulnerable = true

[beh@general]
combat_ignore_keep_when_attacked = true
combat_ignore_cond = {=check_enemy_name(actor)} true, {-npcx_beh_ignore_combat -npcx_beh_ignore_actor_enemies}  false, {+npcx_beh_ignore_combat +npcx_beh_ignore_actor_enemies} true, {+npcx_beh_ignore_combat -npcx_beh_ignore_actor_enemies =is_enemy_fighting_actor} false, true
meet = meet
gather_items_enabled = {+npcx_beh_gather_items}true, false
corpse_detection_enabled = {+npcx_beh_loot_corpses} true, false
actor_dialogs = actor_dialogs
behavior_state = {+npcx_beh_wait} beh_wait, beh_move
target = {!is_squad_commander} commander, {=is_squad_commander +npcx_beh_patrol_mode} waypoint, actor
walk_dist = {+npcx_beh_patrol_mode} 90, 4
jog_dist = {+npcx_beh_patrol_mode} 150, 8
run_dist = {+npcx_beh_patrol_mode} 250, {=surge_started} 40, 90
keep_distance = {+npcx_beh_distance_far} far, near
near_desired_dist = {+npcx_beh_patrol_mode =is_squad_commander} 1, {!is_squad_commander} 5, 2
far_desired_dist = {+npcx_beh_patrol_mode =is_squad_commander} 1, {!is_squad_commander} 5, 8
wait_anim = {=is_wounded} nil, {+npcx_beh_substate_stealth} hide, guard
walk_anim = {=is_wounded} nil, {+npcx_beh_patrol_mode -npcx_beh_substate_stealth} patrol,{+npcx_beh_substate_stealth} sneak, patrol
jog_anim = {=is_wounded} nil, {+npcx_beh_substate_stealth} sneak_run, rush
run_anim = {=is_wounded} nil, {+npcx_beh_substate_stealth} assault, assault
sprint_anim = {=is_wounded} nil, {+npcx_beh_substate_stealth} sprint, sprint
delay_anim = {=is_wounded} nil, {+npcx_beh_substate_stealth} hide, random_animation
out_restr = {=actor_in_zone(zat_a2_sr_noweap)} zat_a2_sr_noweap, {=actor_in_zone(jup_a6_sr_noweap)} jup_a6_sr_noweap, {=actor_in_zone(jup_b41_sr_noweap)} jup_b41_sr_noweap
[meet]
;reset_distance = 2
abuse = false
snd_on_use 				= {=is_wounded} nil, {!is_squad_commander} meet_use_no_talk_leader
close_distance          = {=is_wounded} 1, {!is_squad_commander} 0, 2
close_anim              = {=is_wounded} nil, {!is_squad_commander} nil, {+npcx_beh_substate_stealth -npcx_beh_substate_relax} hide_no_wpn, guard_na
close_snd_hello         = nil
close_snd_bye           = nil
close_victim			= {=is_wounded} nil, {!is_squad_commander} nil, actor
far_distance			= 0
far_anim				= nil
far_snd					= nil
far_victim				= nil
use 					= {=is_wounded} true, {=dist_to_actor_le(4)} true, false ;{=is_wounded} true, {!is_squad_commander} false, {=dist_to_actor_le(5)} true, false
allow_break				= true
use_text				= nil
trade_enable 			= {=is_wounded} false, true
meet_dialog				= {=is_wounded} axr_companion_medkit, nil

[actor_dialogs]
disable = dm_ordered_task_dialog, dm_traveler_dialog, dm_actor_become_guide_to_companion_dialog, dm_universal_dialog, about_quests_dialog_dolg, about_quests_dialog_freedom, about_quests_dialog_bandit, about_quests_dialog_stalkers

;===============================================
;            		 active sections
;===============================================
[beh@base]:beh@general
on_info1 = {=check_squad_name(ecolog_companion_task_1)} beh@ecolog_companion_task_1, {=check_squad_name(ecolog_companion_task_2)} beh@ecolog_companion_task_2, {=check_squad_name(yan_ecolog_semenov_squad)} beh@yan_ecolog_semenov_task_1
on_info2 = {=check_squad_name(bandit_companion_task_1)} beh@bandit_companion_task_1
on_info3 = {=check_squad_name(army_companion_task_1)} beh@army_companion_task_1
on_info4 = {=check_squad_name(freedom_companion_task_1)} beh@freedom_companion_task_1
on_info5 = {=check_squad_name(dolg_companion_task_1)} beh@dolg_companion_task_1
on_info6 = {=check_squad_name(killer_companion_task_1)} beh@killer_companion_task_1
on_info7 = {=check_squad_name(stalker_companion_task_1)} beh@stalker_companion_task_1
on_info8 = {=check_squad_name(csky_companion_task_1)} beh@csky_companion_task_1
on_info9 = {=check_squad_name(monolith_companion_task_1)} beh@monolith_companion_task_1
on_info10 = {=check_squad_name(ecolog_companion_task_3)} beh@ecolog_companion_task_3
on_info11 = {=check_squad_name(hostage_companion_task_1)} beh@hostage_1
;on_info12 = beh@general       ;IMPORTANT: not a special task squad so use general section; Make sure it's always the last LINE in this section

[meet@ecolog_companion_task_1]:meet
meet_dialog	= {=is_wounded} axr_companion_medkit, {=check_nearest_smart_dist_le(40:mar_smart_terrain_base)} ecolog_companion_task_1_dialog, nil

[meet@ecolog_companion_task_2]:meet
meet_dialog	= {=is_wounded} axr_companion_medkit, {=check_nearest_smart_dist_le(40:jup_b41)} ecolog_companion_task_2_dialog, nil

[meet@ecolog_companion_task_3]:meet
meet_dialog	= {=is_wounded} axr_companion_medkit, {=check_nearest_smart_dist_le(40:yan_smart_terrain_6_4)} ecolog_companion_task_3_dialog, nil

[beh@ecolog_companion_task_1]:beh@general
meet = meet@ecolog_companion_task_1
on_info1 = {=dist_to_task_target_anomaly_le(15)} beh@task_target_anomaly_1, {=squad_commander_active_section(beh@task_target_anomaly_1)} beh@task_target_anomaly_1
on_info2 = {-ecolog_companion_task_1_force_started =dist_to_actor_le(3)} %+ecolog_companion_task_1_force_started =force_talk(true)%
on_info3 = {=check_squad_name(ecolog_companion_task_2)} beh@ecolog_companion_task_2

[beh@ecolog_companion_task_2]:beh@general
meet = meet@ecolog_companion_task_2
on_info1 = {=dist_to_task_target_anomaly_le(15)} beh@task_target_anomaly_1, {=squad_commander_active_section(beh@task_target_anomaly_1)} beh@task_target_anomaly_1
on_info2 = {-ecolog_companion_task_2_force_started =dist_to_actor_le(3)} %+ecolog_companion_task_2_force_started =force_talk(true)%
on_info3 = {=check_squad_name(ecolog_companion_task_1)} beh@ecolog_companion_task_1

[beh@ecolog_companion_task_3]:beh@general
meet = meet@ecolog_companion_task_3
on_info1 = {=dist_to_task_target_anomaly_le(15)} beh@task_target_anomaly_1, {=squad_commander_active_section(beh@task_target_anomaly_1)} beh@task_target_anomaly_1
on_info2 = {-ecolog_companion_task_3_force_started =dist_to_actor_le(3)} %+ecolog_companion_task_3_force_started =force_talk(true)%
on_info3 = {=check_squad_name(ecolog_companion_task_3)} beh@ecolog_companion_task_3

[beh@yan_ecolog_semenov_task_1]:beh@general
mutant_corpse_analysis = {=is_squad_commander =check_task_stage(yan_ecolog_semenov_task_1:0)} true

[meet@bandit_companion_task_1]:meet
meet_dialog	= {=is_wounded} axr_companion_medkit, bandit_companion_task_1_dialog

[meet@army_companion_task_1]:meet
meet_dialog	= {=is_wounded} axr_companion_medkit, army_companion_task_1_dialog

[meet@freedom_companion_task_1]:meet
meet_dialog	= {=is_wounded} axr_companion_medkit, freedom_companion_task_1_dialog

[meet@dolg_companion_task_1]:meet
meet_dialog	= {=is_wounded} axr_companion_medkit, dolg_companion_task_1_dialog

[meet@killer_companion_task_1]:meet
meet_dialog	= {=is_wounded} axr_companion_medkit, killer_companion_task_1_dialog

[meet@stalker_companion_task_1]:meet
meet_dialog	= {=is_wounded} axr_companion_medkit, stalker_companion_task_1_dialog

[meet@csky_companion_task_1]:meet
meet_dialog	= {=is_wounded} axr_companion_medkit, csky_companion_task_1_dialog

[meet@monolith_companion_task_1]:meet
meet_dialog	= {=is_wounded} axr_companion_medkit, monolith_companion_task_1_dialog

;TODO: Add logic to rob stalkers
[beh@bandit_companion_task_1]:beh@general
meet = meet@bandit_companion_task_1
;on_info1 = 
on_info2 = {-bandit_companion_task_1_force_started =dist_to_actor_le(3)} %+bandit_companion_task_1_force_started =force_talk(true)%
corpse_detection_enabled = true

[beh@army_companion_task_1]:beh@general
meet = meet@army_companion_task_1
;on_info1 = 
on_info2 = {-army_companion_task_1_force_started =dist_to_actor_le(3)} %+army_companion_task_1_force_started =force_talk(true)%
corpse_detection_enabled = true

[beh@freedom_companion_task_1]:beh@general
meet = meet@freedom_companion_task_1
;on_info1 = 
on_info2 = {-freedom_companion_task_1_force_started =dist_to_actor_le(3)} %+freedom_companion_task_1_force_started =force_talk(true)%
corpse_detection_enabled = true

[beh@dolg_companion_task_1]:beh@general
meet = meet@dolg_companion_task_1
;on_info1 = 
on_info2 = {-dolg_companion_task_1_force_started =dist_to_actor_le(3)} %+dolg_companion_task_1_force_started =force_talk(true)%
corpse_detection_enabled = true

[beh@killer_companion_task_1]:beh@general
meet = meet@killer_companion_task_1
;on_info1 = 
on_info2 = {-killer_companion_task_1_force_started =dist_to_actor_le(3)} %+killer_companion_task_1_force_started =force_talk(true)%
corpse_detection_enabled = true

[beh@stalker_companion_task_1]:beh@general
meet = meet@stalker_companion_task_1
;on_info1 = 
on_info2 = {-stalker_companion_task_1_force_started =dist_to_actor_le(3)} %+stalker_companion_task_1_force_started =force_talk(true)%
corpse_detection_enabled = true

[beh@csky_companion_task_1]:beh@general
meet = meet@csky_companion_task_1
;on_info1 = 
on_info2 = {-csky_companion_task_1_force_started =dist_to_actor_le(3)} %+csky_companion_task_1_force_started =force_talk(true)%
corpse_detection_enabled = true

[beh@monolith_companion_task_1]:beh@general
meet = meet@monolith_companion_task_1
;on_info1 = 
on_info2 = {-monolith_companion_task_1_force_started =dist_to_actor_le(3)} %+monolith_companion_task_1_force_started =force_talk(true)%
corpse_detection_enabled = true

;====================================================================
; 				special scenario active sections
;====================================================================
[meet@hostage_companion_task_1]:meet
meet_dialog	= {=is_wounded} axr_companion_medkit, hostage_companion_task_1_dialog
meet_on_talking = false 

[beh@hostage_1]:beh@general_no_companion
target = task_target_hostage
wait_anim = prisoner
combat_ignore_cond = {=actor_enemy =check_enemy_name(actor)} false, true
combat_ignore_keep_when_attacked = true
gather_items_enabled = false
help_wounded_enabled = false
corpse_detection_enabled = false
enemy_ignore_cond = true
on_info1 = {+hostage_companion_task_1_hostage_rescued} beh@hostage_companion_task_1
meet = meet@hostage_companion_task_1

[beh@hostage_companion_task_1]:beh@general


[beh@task_target_anomaly_1]:beh@general_no_companion
target = task_target_anomaly
wait_anim = scaner_crouch
on_info1 = {=is_squad_commander} beh@task_target_anomaly_2 %=play_sound(jup_b6_stalker_1_first_measurement_begin)%
on_info2 = {!has_task_target_anomaly =check_squad_name(ecolog_companion_task_1)} beh@ecolog_companion_task_1, {!has_task_target_anomaly =check_squad_name(ecolog_companion_task_2)} beh@ecolog_companion_task_2, {!has_task_target_anomaly =check_squad_name(ecolog_companion_task_3)} beh@ecolog_companion_task_3

[beh@task_target_anomaly_2]:beh@general_no_companion
target = task_target_anomaly
wait_anim = scaner_crouch
on_game_timer = 900 | %=play_sound(jup_b6_stalker_1_measurements_done) =reset_task_target_anomaly%
on_info2 = {!has_task_target_anomaly =check_squad_name(ecolog_companion_task_1)} beh@ecolog_companion_task_1, {!has_task_target_anomaly =check_squad_name(ecolog_companion_task_2)} beh@ecolog_companion_task_2, {!has_task_target_anomaly =check_squad_name(ecolog_companion_task_3)} beh@ecolog_companion_task_3