class 1 party_leader_kill_private : party_leader
{
parameter:
	int	DDMagic = 1032204;
	int	SelfBuff = 1031169;
	int	RespawnTime = 2;
	int	KillPrivateHPRatio = 50;

handler:
	EventHandler CREATED(c0)
	{
		myself.i_ai0 = 0;
		super;
	}

	EventHandler PARTY_ATTACKED(attacker,private,damage,f0)
	{
		if( private != myself.sm )
		{
			if( myself::GetAbnormalLevel(myself.sm,myself::Skill_GetAbnormalType(SelfBuff)) <= 0 && myself::FloatToInt(( ( private.hp / private.max_hp ) * 100 )) <= KillPrivateHPRatio && myself.i_ai0 == 0 )
			{
				myself.i_ai0 = 1;
				if( myself::Skill_GetConsumeMP(DDMagic) < myself.sm.mp && myself::Skill_GetConsumeHP(DDMagic) < myself.sm.hp && myself::Skill_InReuseDelay(DDMagic) == 0 )
				{
					myself::AddUseSkillDesire(private,DDMagic,0,1,1000000);
				}
			}
		}
		super;
	}

	EventHandler USE_SKILL_FINISHED(target,skill_name_id)
	{
		if( skill_name_id == DDMagic )
		{
			if( myself::Skill_GetConsumeMP(SelfBuff) < myself.sm.mp && myself::Skill_GetConsumeHP(SelfBuff) < myself.sm.hp && myself::Skill_InReuseDelay(SelfBuff) == 0 )
			{
				myself::AddUseSkillDesire(myself.sm,SelfBuff,1,1,1000000);
			}
		}
	}

	EventHandler PARTY_DIED(private)
	{
		if( private != myself.sm && private.respawn_time != 0 )
		{
			if( myself.i_ai0 == 1 )
			{
				myself.i_ai0 = 0;
				myself::CreateOnePrivate(private.npc_class_id,private.ai,private.weight_point,RespawnTime);
			}
			else
			{
				myself::CreateOnePrivate(private.npc_class_id,private.ai,private.weight_point,private.respawn_time);
			}
		}
	}

}
