from toee import *
from utilities import *

def san_dialog( attachee, triggerer ):
	if (attachee.leader_get() != OBJ_HANDLE_NULL):
		triggerer.begin_dialog( attachee, 210 )
	elif (game.party[0].reputation_has( 27 ) == 1): 
		triggerer.begin_dialog( attachee, 11002 )
	else:
		triggerer.begin_dialog( attachee, 1 )
	return SKIP_DEFAULT

def san_dying( attachee, triggerer ):
	game.global_flags[336] = 1
	if (attachee.leader_get() == OBJ_HANDLE_NULL and attachee.item_find(5009) == OBJ_HANDLE_NULL and game.global_flags[850] == 1):
		game.global_flags[850] = 0
		create_item_in_inventory( 5009, attachee )
	if (attachee.leader_get() == OBJ_HANDLE_NULL):
		game.global_vars[23] = game.global_vars[23] + 1
		if (game.global_vars[23] >= 2):
			game.party[0].reputation_add( 1 )
	else:
		game.global_vars[29] = game.global_vars[29] + 1
	return RUN_DEFAULT

def san_enter_combat( attachee, triggerer ):
	if (attachee.leader_get() == OBJ_HANDLE_NULL and attachee.item_find(5009) != OBJ_HANDLE_NULL and game.global_flags[850] == 0):
		attachee.item_find(5009).destroy()
		game.global_flags[850] = 1
	return RUN_DEFAULT


def san_new_map( attachee, triggerer ):
	if ( attachee.stat_level_get(stat_level_fighter) >= 8 ):
		game.leader.begin_dialog( attachee, 230 )
	return SKIP_DEFAULT
