from toee import *

def san_dialog( attachee, triggerer ):
	attachee.turn_towards(triggerer)
	if (attachee.name == 14502):
		return SKIP_DEFAULT
	if (attachee.name == 14501 and attachee.map == 5042):
		jaroo = find_npc_near(attachee, 20001)
		triggerer.begin_dialog(jaroo,1)
		return SKIP_DEFAULT
	if (attachee.name == 14501 and (attachee.map == 5022 or attachee.map == 5001)):
		triggerer.begin_dialog(attachee,2000)
		return SKIP_DEFAULT
	r = game.random_range(1,10)
	if (game.areas[4] == 1 and r >= 8):
		triggerer.begin_dialog(attachee,1500)
	elif (r == 1):
		triggerer.begin_dialog(attachee,1)
	elif (r == 2):
		triggerer.begin_dialog(attachee,10)
	elif (r == 3):
		triggerer.begin_dialog(attachee,20)
	elif (r == 4):
		triggerer.begin_dialog(attachee,30)
	elif (r == 5):
		triggerer.begin_dialog(attachee,40)
	elif (r == 6):
		triggerer.begin_dialog(attachee,50)
	elif (r == 7):
		triggerer.begin_dialog(attachee,60)
	elif (r == 8):
		triggerer.begin_dialog(attachee,70)
	elif (r == 9):
		triggerer.begin_dialog(attachee,80)
	else:
		triggerer.begin_dialog(attachee,90)
	return SKIP_DEFAULT

def san_first_heartbeat( attachee, triggerer ):
#	if (attachee.map == 5001 and is_daytime() == 1 and game.global_vars[702] == 1):
#
#		rr = 0
#		rr = game.random_range(1,30)
#		if (rr == 1):
#			attachee.move(location_from_axis(647, 497))
#		if (rr == 2):
#			attachee.move(location_from_axis(622, 510))
#		if (rr == 3):
#			attachee.move(location_from_axis(635, 490))
#		if (rr == 4):
#			attachee.move(location_from_axis(604, 546))
#		if (rr == 5):
#			attachee.move(location_from_axis(694, 513))
#		if (rr == 6):
#			attachee.move(location_from_axis(646, 498))
#		if (rr == 7):
#			attachee.move(location_from_axis(623, 511))
#		if (rr == 8):
#			attachee.move(location_from_axis(636, 489))
#		if (rr == 9):
#			attachee.move(location_from_axis(606, 545))
#		if (rr == 10):
#			attachee.move(location_from_axis(697, 547))
	
	return RUN_DEFAULT

def san_heartbeat( attachee, triggerer ):
#	if (attachee.name == 14502 and game.quests[101].state == qs_botched):
#		attachee.object_flag_set(OF_OFF)
#	if (game.global_flags[862] == 1 and attachee.name == 14501):
#		attachee.object_flag_set(OF_OFF)
#		return RUN_DEFAULT
#	if (is_daytime() == 1 and attachee.map == 5022 and game.quests[101].state == qs_completed and attachee.name == 14501):
#		attachee.object_flag_set(OF_OFF)
#	if (is_daytime() == 0 and attachee.map == 5022 and game.quests[101].state == qs_completed and attachee.name == 14501):
#		attachee.object_flag_unset(OF_OFF)
#	if (is_daytime() == 0 and attachee.map == 5001 and game.quests[101].state == qs_completed and attachee.name == 14501):
#		attachee.object_flag_set(OF_OFF)
#	if (is_daytime() == 1 and attachee.map == 5001 and game.quests[101].state == qs_completed and attachee.name == 14501):
#		attachee.object_flag_unset(OF_OFF)
#	if (is_daytime() == 1 and attachee.map == 5022 and attachee.name == 14502):
#		attachee.object_flag_set(OF_OFF)
#	if (is_daytime() == 0 and attachee.map == 5022 and attachee.name == 14502):
#		attachee.object_flag_unset(OF_OFF)
#	if (attachee.name == 14501 and (attachee.map == 5022 or attachee.map == 5001 or attachee.map == 5042)):
#		return RUN_DEFAULT
#	if (attachee.name == 14502):
#		return RUN_DEFAULT
#	for obj in game.obj_list_vicinity(attachee.location,OLC_PC):
#		if (obj.distance_to(attachee) <= 30 and game.global_vars[702] == 0 and critter_is_unconscious(obj) != 1):
#			if (obj.stat_level_get(stat_race) == race_halfling):
#				game.global_vars[702] = 1
#				attachee.turn_towards(obj)
#				obj.begin_dialog(attachee,500)
#			elif (obj.stat_level_get(stat_race) == race_halforc):
#				game.global_vars[702] = 1
#				attachee.turn_towards(obj)
#				obj.begin_dialog(attachee,600)
#			elif (obj.stat_level_get(stat_level_paladin) >= 1):
#				game.global_vars[702] = 1
#				attachee.turn_towards(obj)
#				obj.begin_dialog(attachee,200)
#			elif (obj.stat_level_get(stat_level_wizard) >= 1):
#				game.global_vars[702] = 1
#				attachee.turn_towards(obj)
#				obj.begin_dialog(attachee,300)
#			elif (obj.stat_level_get(stat_level_bard) >= 1):
#				game.global_vars[702] = 1
#				attachee.turn_towards(obj)
#				obj.begin_dialog(attachee,400)
#			else:
#				game.global_vars[702] = 1
#				attachee.turn_towards(obj)
#				obj.begin_dialog(attachee,100)
#		if (obj.distance_to(attachee) <= 25 and game.global_vars[702] == 3):
#			attachee.runoff(attachee.location+3)
#
#	if (is_daytime() == 1 and attachee.map != 5001):
#		attachee.object_flag_set(OF_OFF)
#	if (is_daytime() == 0 and attachee.map != 5001):
#		attachee.object_flag_unset(OF_OFF)
#	if (is_daytime() == 0 and attachee.map == 5001):
#		attachee.object_flag_set(OF_OFF)
#	if (is_daytime() == 1 and attachee.map == 5001):
#		attachee.object_flag_unset(OF_OFF)
#	if (attachee.map == 5001 and is_daytime() == 1 and game.global_vars[702] == 1):
#		rr = game.random_range(1,200)
#		if (rr == 1):
#			attachee.standpoint_set( STANDPOINT_NIGHT, 278 )
#			attachee.standpoint_set( STANDPOINT_DAY, 278 )
#		if (rr == 2):
#			attachee.standpoint_set( STANDPOINT_NIGHT, 279 )
#			attachee.standpoint_set( STANDPOINT_DAY, 279 )
#		if (rr == 3):
#			attachee.standpoint_set( STANDPOINT_NIGHT, 280 )
#			attachee.standpoint_set( STANDPOINT_DAY, 280 )
#		if (rr == 4):
#			attachee.standpoint_set( STANDPOINT_NIGHT, 281 )
#			attachee.standpoint_set( STANDPOINT_DAY, 281 )
#		if (rr == 5):
#			attachee.standpoint_set( STANDPOINT_NIGHT, 282 )
#			attachee.standpoint_set( STANDPOINT_DAY, 282 )
#		if (rr == 6):
#			attachee.standpoint_set( STANDPOINT_NIGHT, 283 )
#			attachee.standpoint_set( STANDPOINT_DAY, 283 )
#		if (rr == 7):
#			attachee.standpoint_set( STANDPOINT_NIGHT, 284 )
#			attachee.standpoint_set( STANDPOINT_DAY, 284 )
#		if (rr == 8):
#			attachee.standpoint_set( STANDPOINT_NIGHT, 285 )
#			attachee.standpoint_set( STANDPOINT_DAY, 285 )
#		if (rr == 9):
#			attachee.standpoint_set( STANDPOINT_NIGHT, 286 )
#			attachee.standpoint_set( STANDPOINT_DAY, 286 )
#		if (rr == 10):
#			attachee.standpoint_set( STANDPOINT_NIGHT, 287 )
#			attachee.standpoint_set( STANDPOINT_DAY, 287 )
#		if (rr == 11):
#			attachee.standpoint_set( STANDPOINT_NIGHT, 221 )
#			attachee.standpoint_set( STANDPOINT_DAY, 221 )
#		if (rr == 12):
#			attachee.standpoint_set( STANDPOINT_NIGHT, 222 )
#			attachee.standpoint_set( STANDPOINT_DAY, 222 )
#		if (rr == 13):
#			attachee.standpoint_set( STANDPOINT_NIGHT, 223 )
#			attachee.standpoint_set( STANDPOINT_DAY, 223 )
#		if (rr == 14):
#			attachee.standpoint_set( STANDPOINT_NIGHT, 224 )
#			attachee.standpoint_set( STANDPOINT_DAY, 224 )
#		if (rr == 15):
#			attachee.standpoint_set( STANDPOINT_NIGHT, 225 )
#			attachee.standpoint_set( STANDPOINT_DAY, 225 )
#		if (rr == 16):
#			attachee.standpoint_set( STANDPOINT_NIGHT, 226 )
#			attachee.standpoint_set( STANDPOINT_DAY, 226 )
#		if (rr == 17):
#			attachee.standpoint_set( STANDPOINT_NIGHT, 227 )
#			attachee.standpoint_set( STANDPOINT_DAY, 227 )
#		if (rr == 18):
#			attachee.standpoint_set( STANDPOINT_NIGHT, 228 )
#			attachee.standpoint_set( STANDPOINT_DAY, 228 )
#		for obj in game.obj_list_vicinity(attachee.location,OLC_PC):
#			if (obj.distance_to(attachee) <= 10 and game.global_vars[702] == 1):
#				rrr = game.random_range(1,3)
#				if (rrr == 1):
#					attachee.turn_towards(obj)
#				return RUN_DEFAULT
#	attachee.float_line(1,triggerer)

	return RUN_DEFAULT

def san_dying( attachee, triggerer ):
	if (game.global_flags[862] == 0 and attachee.name == 14501):
		game.global_flags[862] = 1
	game.global_vars[23] = game.global_vars[23] + 1
	if (game.global_vars[23] >= 1):
		game.party[0].reputation_add( 1 )
	return RUN_DEFAULT

def	make_kids( attachee, triggerer ):
#	mxcr = game.obj_create( 14002, location_from_axis (674L, 511L) )
#	mxcr.rotation = 1
#	mqcr = game.obj_create( 14003, location_from_axis (672L, 505L) )
#	mqcr.move(location_from_axis(647, 497))
#	macr = game.obj_create( 14003, location_from_axis (673L, 513L) )
#	macr.rotation = 3.5
#	mbcr = game.obj_create( 14002, location_from_axis (682L, 508L) )
#	mbcr.rotation = 1.5
#	mccr = game.obj_create( 14003, location_from_axis (681L, 502L) )
#	mccr.move(location_from_axis(604, 546))
#	mdcr = game.obj_create( 14003, location_from_axis (677L, 513L) )
#	mdcr.move(location_from_axis(623, 511))
#	mecr = game.obj_create( 14002, location_from_axis (679L, 513L) )
#	mecr.rotation = 2.5
#
#	mxcr = game.obj_create( 14002, location_from_axis (672L, 512L) )
#	mxcr.rotation = 1
#	mqcr = game.obj_create( 14003, location_from_axis (676L, 513L) )
#	mqcr.move(location_from_axis(647, 497))
#	macr = game.obj_create( 14003, location_from_axis (673L, 516L) )
#	macr.rotation = 3.5
#	mbcr = game.obj_create( 14002, location_from_axis (667L, 514L) )
#	mbcr.rotation = 1.5
#	mccr = game.obj_create( 14003, location_from_axis (665L, 516L) )
#	mccr.move(location_from_axis(604, 546))
#	mdcr = game.obj_create( 14003, location_from_axis (671L, 520L) )
#	mdcr.move(location_from_axis(623, 511))
#	mecr = game.obj_create( 14002, location_from_axis (668L, 522L) )
#	mecr.rotation = 2.5
	return RUN_DEFAULT

def talk_nps( attachee, triggerer):
	npc1 = find_npc_near(triggerer,8002)
	if (npc1 != OBJ_HANDLE_NULL):
		triggerer.begin_dialog(npc1,5000)
		npc1.turn_towards(attachee)

	npc2 = find_npc_near(triggerer,14037)
	if (npc2 != OBJ_HANDLE_NULL):
		triggerer.begin_dialog(npc2,5000)
		npc2.turn_towards(triggerer)

	npc3 = find_npc_near(triggerer,8050)
	if (npc3 != OBJ_HANDLE_NULL):
		triggerer.begin_dialog(npc3,5000)
		npc3.turn_towards(triggerer)

	npc4 = find_npc_near(triggerer,8062)
	if (npc4 != OBJ_HANDLE_NULL):
		triggerer.begin_dialog(npc4,5000)
		npc4.turn_towards(triggerer)

	npc5 = find_npc_near(triggerer,8010)
	if (npc5 != OBJ_HANDLE_NULL):
		triggerer.begin_dialog(npc5,5000)
		npc5.turn_towards(triggerer)

	npc6 = find_npc_near(triggerer,20032)
	if (npc6 != OBJ_HANDLE_NULL):
		triggerer.begin_dialog(npc6,5000)
		npc6.turn_towards(triggerer)

	npc7 = find_npc_near(triggerer,8015)
	if (npc7 != OBJ_HANDLE_NULL):
		triggerer.begin_dialog(npc7,5000)
		npc7.turn_towards(triggerer)

	npc8 = find_npc_near(triggerer,8003)
	if (npc8 != OBJ_HANDLE_NULL):
		triggerer.begin_dialog(npc8,5000)
		npc8.turn_towards(triggerer)

	npc9 = find_npc_near(triggerer,8004)
	if (npc9 != OBJ_HANDLE_NULL):
		triggerer.begin_dialog(npc9,5000)
		npc9.turn_towards(triggerer)

	return SKIP_DEFAULT

