from utilities import *
from toee import *


def san_first_heartbeat( attachee, triggerer ):

	if (attachee.map == 5085 and game.party[0].reputation_has( 23 ) == 1 and game.global_flags[94] == 1 and (game.global_flags[815] == 0 or game.global_flags[814] == 0)):	
		party_level = group_average_level(game.leader)
		game.global_vars[759] = game.global_vars[759] + 1
		if ((game.global_vars[759] <= 2 and game.random_range(1,4) <= 3) or party_level <=5):
			return RUN_DEFAULT
		else:
			attachee.destroy()

	return RUN_DEFAULT



def san_heartbeat( attachee, triggerer ):

	if (attachee.map == 5078):
		for obj in game.obj_list_vicinity(attachee.location,OLC_PC):
			if (obj.distance_to(attachee) <= 15):
				obj.begin_dialog( attachee, 2100 )
		return SKIP_DEFAULT

	if (attachee.map == 5015 and game.global_flags[37] == 0 and game.global_flags[835] == 1):
		attachee.destroy()
#		npc = game.obj_create( 14371, location_from_axis (477L, 488L))
#		npc2 = game.obj_create( 14371, location_from_axis (481L, 475L))
#		npc3 = game.obj_create( 14371, location_from_axis (486L, 479L))
#		npc4 = game.obj_create( 14371, location_from_axis (482L, 486L))



	if (attachee.map == 5014 and game.global_flags[37] == 0 and game.global_flags[835] == 1):
		attachee.destroy()
#		chains = game.obj_create( 2135, location_from_axis (491L, 484L))
#		chains.rotation = 2.5
#		chains = game.obj_create( 2135, location_from_axis (491L, 484L))
#		chains.rotation = 4.5
#		chains = game.obj_create( 2135, location_from_axis (491L, 484L))
#		chains.rotation = 3.5
#		npc = game.obj_create( 14614, location_from_axis (490L, 483L))
#		npc2 = game.obj_create( 14607, location_from_axis (490L, 483L))
#		loc = npc.location
#		npc.stat_level_get(stat_subdual_damage)
#		npc.damage(OBJ_HANDLE_NULL,D20DT_SUBDUAL,dice_new("7d1"),D20DAP_NORMAL)
#		npc.damage( OBJ_HANDLE_NULL, 0, dice_new("52d1"))
#		game.global_vars[758] = 0
#		game.particles( "sp-Hold Person", npc )
#		game.particles( "sp-Bestow Curse", npc )
#		npc2.cast_spell(spell_hold_person, npc)
#		npc.condition_add_with_args( 'sp-Tashas Hideous Laughter', OBJ_HANDLE_NULL, 50000, 0 )
#		npc.condition_add_with_args("Prone",0,5000)

	if (attachee.map == 5080):
		attachee.destroy()
#### creates the trap and the control box
#		game.global_vars[707] = 3
#		robes = game.obj_create( 6213, location_from_axis (510L, 616L))
#		note = game.obj_create( 11008, location_from_axis (511L, 617L))
		npc = game.obj_create( 14458, location_from_axis (479L, 542L))
#		npc = game.obj_create( 12035, location_from_axis (479L, 572L))
#		npc.object_flag_set(OF_CLICK_THROUGH)
#		npc = game.obj_create( 1055, location_from_axis (476L, 586L))
#		npc = game.obj_create( 14605, location_from_axis (481L, 566L))
#		npc = game.obj_create( 1055, location_from_axis (484L, 536L))
#		npc = game.obj_create( 1055, location_from_axis (477L, 586L))
#		npc = game.obj_create( 14605, location_from_axis (476L, 582L))
#		npc = game.obj_create( 1055, location_from_axis (476L, 552L))


	if (attachee.map == 5024):
		attachee.destroy()
	return RUN_DEFAULT

