@LabelIndex 66503
@StringIndex 10793
class 0 summoner_primeval : citizen {
parameter:
	int	EffectSkill1 = 335609857;
	int	Pos_x = 0;
	int	Pos_y = 0;
	int	Pos_z = 0;
	int	commission = 10;
	string	fnHi2 = "vervato002.htm";
	string	fnHi3 = "vervato003.htm";
	string	fnHi4 = "vervato004.htm";
	int	is_dbg = 0;

handler:
	EventHandler CREATED(s0) {
		if( is_dbg > 2 ) {
			s0 = "[DBG3]" + "[" + gg::IntToStr(myself.sm.class_id) + "]" + myself.sm.name + ": created";
			myself::Say(s0);
			s0 = "";
		}
		myself.c_ai0 = myself.sm;
	}

	EventHandler TALKED(talker,s0) {
		if( is_dbg > 2 ) {
			s0 = "[DBG3]" + "[" + gg::IntToStr(myself.sm.class_id) + "]" + myself.sm.name + ": talked:" + talker.name;
			myself::Say(s0);
			s0 = "";
		}
		myself::ShowPage(talker,fnHi);
	}

	EventHandler MENU_SELECTED(talker,ask,reply,i0,c0,s0,i1,i2) {
		if( is_dbg > 2 ) {
			myself::Say("get party number by i0");
			i0 = gg::Party_GetCount(talker);
			myself::SayInt(i0);
			myself::Say("get party number direct");
			myself::SayInt(gg::Party_GetCount(talker));
		}
		if( talker == myself.sm ) {
			myself::Say("no proper target");
			return;
		}
		i2 = 0;
		for(i1 = 0; i1 < gg::Party_GetCount(talker); i1++) {
			c0 = gg::Party_GetCreature(talker,i1);
			if( myself::IsNullCreature(c0) == 0 ) {
				if( c0.hp <= 0 && myself::InMyTerritory(c0) ) {
					i2 = ( i2 + 1 );
				}
			}
		}
		if( is_dbg > 2 ) {
			myself::Say("i2:");
			myself::SayInt(i2);
		}
		if( ask == -505 && reply == 1 ) {
			if( i2 == 0 ) {
				myself::ShowPage(talker,fnHi2);
			} else if( gg::OwnItemCount(talker,57) >= commission ) {
				myself::DeleteItem1(talker,57,commission);
				myself::AddLogByNpc(415,talker,commission,myself.sm.id);
				if( EffectSkill1 != 458752001 ) {
					myself.c_ai0 = talker;
					if( is_dbg > 1 ) {
						s0 = "[DBG2]" + "[" + gg::IntToStr(myself.sm.class_id) + "]" + myself.sm.name + ": use_skill::" + "skill_id" + "[" + gg::IntToStr(EffectSkill1) + "]" + "target:" + myself.sm.name;
						myself::Say(s0);
						s0 = "";
					}
					if( myself::Skill_GetConsumeMP(EffectSkill1) < myself.sm.mp && myself::Skill_GetConsumeHP(EffectSkill1) < myself.sm.hp && myself::Skill_InReuseDelay(EffectSkill1) == 0 ) {
						myself::AddUseSkillDesire(myself.sm,EffectSkill1,1,1,1000000);
					}
				}
			} else {
				myself::ShowPage(talker,fnHi3);
			}
		}
	}

	EventHandler USE_SKILL_FINISHED(target,skill_name_id,c0,s0,i1) {
		if( is_dbg > 2 ) {
			s0 = "[DBG3]" + "[" + gg::IntToStr(myself.sm.class_id) + "]" + myself.sm.name + ": use_skill_finished:" + "target:" + target.name + "skill_name_id:" + "[" + gg::IntToStr(skill_name_id) + "]";
			myself::Say(s0);
			s0 = "";
		}
		if( skill_name_id == EffectSkill1 ) {
			if( myself.c_ai0 != myself.sm ) {
			}
			for(i1 = 0; i1 < gg::Party_GetCount(myself.c_ai0); i1++) {
				c0 = gg::Party_GetCreature(myself.c_ai0,i1);
				if( myself::IsNullCreature(c0) == 0 ) {
					if( c0.hp <= 0 && myself::InMyTerritory(c0) ) {
						myself::InstantTeleport(c0,Pos_x,Pos_y,Pos_z);
						myself::AddLogByNpc(416,myself.c_ai0,c0.id,myself.sm.id);
					}
				}
			}
			myself::AddTimerEx(2005,( 3 * 1000 ));
		}
	}

	EventHandler TIMER_FIRED_EX(timer_id) {
		if( timer_id == 2005 ) {
			if( myself.c_ai0 != myself.sm ) {
				myself::ShowPage(myself.c_ai0,fnHi4);
			}
		}
	}

}
