from toee import *
from utilities import *


def san_dialog( attachee, triggerer ):
	if (game.global_flags[819] == 1):
		attachee.attack(triggerer)
		return SKIP_DEFAULT
	if (attachee.leader_get() != OBJ_HANDLE_NULL):
		triggerer.begin_dialog( attachee, 100 )
	else:
		triggerer.begin_dialog( attachee, 1 )
	return SKIP_DEFAULT

def san_dying( attachee, triggerer ):
	attachee.float_line(12014,triggerer)
	if (attachee.leader_get() != OBJ_HANDLE_NULL):
		game.global_vars[29] = game.global_vars[29] + 1
	return RUN_DEFAULT

def equip_transfer( attachee, triggerer ):
	itemA = attachee.item_find(6081)
	if (itemA != OBJ_HANDLE_NULL):
		itemA.destroy()
		create_item_in_inventory( 6081, triggerer )
	itemB = attachee.item_find(6023)
	if (itemB != OBJ_HANDLE_NULL):
		itemB.destroy()
		create_item_in_inventory( 6023, triggerer )
	itemC = attachee.item_find(4060)
	if (itemC != OBJ_HANDLE_NULL):
		itemC.destroy()
		create_item_in_inventory( 4060, triggerer )
	create_item_in_inventory( 7001, attachee )
	return RUN_DEFAULT

def san_first_heartbeat( attachee, triggerer ):
#	if (attachee.leader_get() == OBJ_HANDLE_NULL and not game.combat_is_active()):
#		game.global_vars[712] = 0
	return RUN_DEFAULT

def san_heartbeat( attachee, triggerer ):
#	if (game.global_vars[712] == 0 and attachee.leader_get() == OBJ_HANDLE_NULL and not game.combat_is_active()):
#		attachee.cast_spell(spell_mage_armor, attachee)
#		attachee.spells_pending_to_memorized()
#		game.global_vars[712] = 1
	return RUN_DEFAULT

def san_new_map( attachee, triggerer ):
	if ((attachee.map == 5006) and (game.global_vars[695] == 1 or game.global_vars[695] == 2)):
		attachee.float_line(12070,triggerer)
	elif ((attachee.map == 5024) and (is_daytime() != 1)):
		attachee.float_line(10019,triggerer)
	return RUN_DEFAULT