Exemplo n.º 1
0
bool ChatHandler::HandleMonsterCastCommand(const char * args, WorldSession * m_session)
{
	UnitPointer crt = getSelectedCreature(m_session, false);
	if(!crt)
	{
		RedSystemMessage(m_session, "Please select a creature before using this command.");
		return true;
	}
	uint32 spellId = (uint32)atoi(args);
	crt->CastSpell(m_session->GetPlayer()->GetGUID(),spellId,true);
	return true;
}
	void OnDamageTaken(UnitPointer mAttacker, float fAmount)
	{
		if( (int)( last_creation_hp - DISPARSE_HP ) >= _unit->GetHealthPct() )
		{
			switch(rand()%2)
			{
			case 0:
				_unit->SendChatMessage( CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "The slightest spark shall be your undoing." );
				break;
			case 1:
				_unit->SendChatMessage( CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "No one is safe!" );
				break;
			}
			spark_timer = getMSTime() + SPARK_PHASE_DURATION;
			last_creation_hp = _unit->GetHealthPct();
			_unit->CastSpell(_unit, 52770, true);//disperse, dummy
			_unit->Root();
			_unit->GetAIInterface()->disable_combat = false;
			_unit->m_invisible = false;
			_unit->UpdateVisibility();
			//disparse
			for( uint8 i=0; i<SPARKS_COUNT; i++)
				if( sparks[i] != 0 )
				{
					UnitPointer Spark = _unit->GetMapMgr()->GetUnit( sparks[i] );
					if( Spark )
					{
						uint32 spellid = heroic ? 59833 : 52667;
						Spark->CastSpell(Spark, spellid, true);
						Spark->UnRoot();
						_unit->GetAIInterface()->disable_combat = false;
						PlayerPointer p_target = GetRandomPlayerTarget();
						if( p_target )
						{
							Spark->GetAIInterface()->MoveTo(p_target->GetPositionX(),p_target->GetPositionY(), p_target->GetPositionZ(), p_target->GetOrientation());
						}
					}
				}			
		}
	}