class 1 party_private_casting_ddmagic_curse : party_private
{
parameter:
	int	DDMagic = 1033473;
	int	DeBuff = 1046529;

handler:
	EventHandler ATTACKED(attacker,damage,i0)
	{
		if( gg::Rand(100) < 33 )
		{
			if( myself::Skill_GetConsumeMP(DDMagic) < myself.sm.mp && myself::Skill_GetConsumeHP(DDMagic) < myself.sm.hp && myself::Skill_InReuseDelay(DDMagic) == 0 )
			{
				myself::AddUseSkillDesire(attacker,DDMagic,0,1,1000000);
			}
		}
		if( attacker.is_pc != 0 || myself::IsInCategory(11,attacker.npc_class_id) )
		{
			if( myself::IsNullCreature(myself.top_desire_target) == 0 )
			{
				if( gg::Rand(100) < 33 && myself::GetAbnormalLevel(attacker,myself::Skill_GetAbnormalType(DeBuff)) <= 0 && myself.top_desire_target == attacker )
				{
					if( myself::Skill_GetConsumeMP(DeBuff) < myself.sm.mp && myself::Skill_GetConsumeHP(DeBuff) < myself.sm.hp && myself::Skill_InReuseDelay(DeBuff) == 0 )
					{
						myself::AddUseSkillDesire(attacker,DeBuff,0,1,1000000);
					}
				}
			}
		}
		super;
	}

	EventHandler PARTY_ATTACKED(attacker,private,damage,i0)
	{
		if( gg::Rand(100) < 33 && myself.p_state != 3 )
		{
			if( myself::Skill_GetConsumeMP(DDMagic) < myself.sm.mp && myself::Skill_GetConsumeHP(DDMagic) < myself.sm.hp && myself::Skill_InReuseDelay(DDMagic) == 0 )
			{
				myself::AddUseSkillDesire(attacker,DDMagic,0,1,1000000);
			}
		}
		if( attacker.is_pc != 0 || myself::IsInCategory(11,attacker.npc_class_id) )
		{
			if( myself::IsNullCreature(myself.top_desire_target) == 0 )
			{
				if( myself::GetAbnormalLevel(attacker,myself::Skill_GetAbnormalType(DeBuff)) <= 0 && myself.top_desire_target == attacker && gg::Rand(100) < 33 )
				{
					if( myself::Skill_GetConsumeMP(DeBuff) < myself.sm.mp && myself::Skill_GetConsumeHP(DeBuff) < myself.sm.hp && myself::Skill_InReuseDelay(DeBuff) == 0 )
					{
						myself::AddUseSkillDesire(attacker,DeBuff,0,1,1000000);
					}
				}
			}
		}
		super;
	}

}
