class 1 ssq_event_bomb : ssq_event_basic_warrior
{
parameter:
	int	DDMagic = 1024257;

handler:
	EventHandler SCRIPT_EVENT(script_event_arg1,script_event_arg2)
	{
		if( script_event_arg1 == 10007 )
		{
			if( myself.p_state != 3 && myself.p_state != 10 )
			{
				myself::AddMoveToDesire(myself.sm.param1,script_event_arg2,myself::FloatToInt(myself.sm.z),50);
			}
		}
		super;
	}

	EventHandler MOVE_TO_FINISHED(x,y,z)
	{
		if( myself::Skill_GetConsumeMP(DDMagic) < myself.sm.mp && myself::Skill_GetConsumeHP(DDMagic) < myself.sm.hp && myself::Skill_InReuseDelay(DDMagic) == 0 )
		{
			myself::AddUseSkillDesire(myself.sm,DDMagic,0,1,1000000);
		}
	}

	EventHandler USE_SKILL_FINISHED(success)
	{
		if( success == 1 )
		{
			myself::Suicide();
		}
	}

	EventHandler CLAN_ATTACKED(attacker,damage)
	{
	}

	EventHandler DESIRE_MANIPULATION(speller,desire)
	{
	}

	EventHandler ATTACKED(attacker,party0,party1)
	{
		if( RoomIndex != 0 && SSQPart != 0 )
		{
			if( myself::InMyTerritory(attacker) == 0 )
			{
				myself.i_ai1 = 1;
			}
			else
			{
				party0 = myself::GetPartyFromEventRoom(RoomIndex,SSQPart);
				party1 = myself::GetParty(attacker);
				if( myself::IsNullParty(party0) || myself::IsNullParty(party1) )
				{
					myself.i_ai1 = 1;
				}
				else if( party0.id != party1.id && attacker.is_pc == 1 )
				{
					myself.i_ai1 = 1;
				}
			}
		}
		else
		{
			myself::Say("Puncture: It drives and it sprouts, affiliation indistinctness");
		}
		if( myself::IsInCategory(23,attacker.npc_class_id) )
		{
			myself.i_ai1 = 1;
		}
	}

	EventHandler MY_DYING(c0,c1,party0,i1,i2)
	{
		if( myself.i_ai1 == 1 )
		{
			c0 = myself::GetLastAttacker();
			if( c0.is_pc == 0 )
			{
				c0 = c0.master;
			}
			if( myself::IsNullCreature(c0) == 0 )
			{
				c0 = myself::Party_GetLeader(c0);
			}
			party0 = myself::GetPartyFromEventRoom(RoomIndex,SSQPart);
			c1 = myself::GetLeaderOfParty(party0);
			if( myself::IsNullCreature(c0) == 0 && myself::IsNullCreature(c1) == 0 )
			{
				if( c0 == c1 )
				{
					if( myself::HaveMemo(c0,505) )
					{
						i1 = ( 3 + myself::FloatToInt(( ( 3 * 25 ) / 100 )) );
						if( myself::IsInCategory(2,c0.occupation) )
						{
							if( myself::DistFromMe(c0) < 40 )
							{
								i1 = ( i1 + myself::FloatToInt(( ( i1 * 30 ) / 100 )) );
							}
						}
						else if( myself::DistFromMe(c0) < 80 )
						{
							i1 = ( i1 + myself::FloatToInt(( ( i1 * 30 ) / 100 )) );
						}
						if( myself::IsInCategory(2,c0.occupation) )
						{
							if( gg::Rand(2) > 0 )
							{
								i1 = ( i1 + myself::FloatToInt(( ( i1 * 7 ) / 100 )) );
							}
							else
							{
								i1 = ( i1 - myself::FloatToInt(( ( i1 * 15 ) / 100 )) );
							}
						}
						else if( gg::Rand(2) > 0 )
						{
							i1 = ( i1 + myself::FloatToInt(( ( i1 * 15 ) / 100 )) );
						}
						else
						{
							i1 = ( i1 - myself::FloatToInt(( ( i1 * 7 ) / 100 )) );
						}
						myself::ShowSysMsgToParty2(party0,2,1381,3,5901,1,i1);
						myself::GiveItem1(c0,5901,i1);
					}
				}
			}
		}
		else
		{
			c0 = myself::GetLastAttacker();
			if( c0.is_pc == 0 )
			{
				c0 = c0.master;
			}
			if( myself::IsNullCreature(c0) == 0 )
			{
				c0 = myself::Party_GetLeader(c0);
			}
			party0 = myself::GetPartyFromEventRoom(RoomIndex,SSQPart);
			c1 = myself::GetLeaderOfParty(party0);
			if( myself::IsNullCreature(c0) == 0 && myself::IsNullCreature(c1) == 0 )
			{
				if( c0 == c1 )
				{
					if( myself::HaveMemo(c0,505) )
					{
						i1 = ( 30 + myself::FloatToInt(( ( 30 * 25 ) / 100 )) );
						if( myself::IsInCategory(2,c0.occupation) )
						{
							if( myself::DistFromMe(c0) < 40 )
							{
								i1 = ( i1 + myself::FloatToInt(( ( i1 * 30 ) / 100 )) );
							}
						}
						else if( myself::DistFromMe(c0) < 80 )
						{
							i1 = ( i1 + myself::FloatToInt(( ( i1 * 30 ) / 100 )) );
						}
						if( myself::IsInCategory(2,c0.occupation) )
						{
							if( gg::Rand(2) > 0 )
							{
								i1 = ( i1 + myself::FloatToInt(( ( i1 * 7 ) / 100 )) );
							}
							else
							{
								i1 = ( i1 - myself::FloatToInt(( ( i1 * 15 ) / 100 )) );
							}
						}
						else if( gg::Rand(2) > 0 )
						{
							i1 = ( i1 + myself::FloatToInt(( ( i1 * 15 ) / 100 )) );
						}
						else
						{
							i1 = ( i1 - myself::FloatToInt(( ( i1 * 7 ) / 100 )) );
						}
						myself::ShowSysMsgToParty2(party0,2,1381,3,5901,1,i1);
						myself::GiveItem1(c0,5901,i1);
					}
				}
			}
		}
	}

}
