from toee import *

def san_dialog( attachee, triggerer ):
	if (attachee.map == 5121):
		leader = attachee.leader_get()
		if (leader != OBJ_HANDLE_NULL):
			leader.begin_dialog( attachee, 60 )
	else:
		triggerer.begin_dialog( attachee, 1 )
	return SKIP_DEFAULT

def san_new_map( attachee, triggerer ):
	if (attachee.map == 5121):
		leader = attachee.leader_get()
		if (leader != OBJ_HANDLE_NULL):
			leader.begin_dialog( attachee, 60 )
	return SKIP_DEFAULT

def run_off( attachee, triggerer ):
	for pc in game.party:
		attachee.ai_shitlist_remove( pc )
	attachee.runoff(attachee.location-3)
	Timed_Destroy(attachee, 5000)
	return RUN_DEFAULT

def san_heartbeat( attachee, triggerer ):
	leader = attachee.leader_get()
	if ((attachee.map == 5066) and (leader != OBJ_HANDLE_NULL)):
		attachee.object_flag_unset(OF_OFF)
	if ((attachee.map == 5066) and (leader == OBJ_HANDLE_NULL)):
		attachee.object_flag_set(OF_OFF)
	if ((attachee.map == 5067) and (game.global_flags[996] == 1 )):
		attachee.object_flag_set(OF_OFF)
	if ((attachee.map == 5067) and (game.global_flags[996] == 0 )):
		attachee.object_flag_unset(OF_OFF)
	return RUN_DEFAULT

def npc_check1 (attachee, triggerer, line):
	npc = find_npc_near(attachee,14250)
	if (npc != OBJ_HANDLE_NULL):
		triggerer.begin_dialog(npc,line)
		npc.turn_towards(attachee)
		attachee.turn_towards(npc)
	else:
		triggerer.begin_dialog(attachee,90)
	return SKIP_DEFAULT

def npc_check2 (attachee, triggerer,line):
	npc = find_npc_near(attachee,14430)
	if (npc != OBJ_HANDLE_NULL):
		triggerer.begin_dialog(npc,line)
		npc.turn_towards(attachee)
		attachee.turn_towards(npc)
	else:
		triggerer.begin_dialog(attachee,60)
	return SKIP_DEFAULT

def npc_check3 (attachee, triggerer, line):
	npc = find_npc_near(attachee,14251)
	if (npc != OBJ_HANDLE_NULL):
		triggerer.begin_dialog(npc,line)
		npc.turn_towards(attachee)
		attachee.turn_towards(npc)
	else:
		triggerer.begin_dialog(attachee,100)
	return SKIP_DEFAULT
