Пример #1
0
	void CastScriptSpell( ScriptSpell* spell )
	{
		_unit->Root();
		uint32 spellid = heroic ? spell->heroic_spellid : spell->normal_spellid;
		Unit* spelltarget = NULL;
		switch( spell->target )
		{
		case SPELL_TARGET_SELF:
			{
				spelltarget = _unit;
			}break;
		case SPELL_TARGET_GENERATE:
			{
				spelltarget = NULL;
			}break;
		case SPELL_TARGET_CURRENT_ENEMY:
			{
				spelltarget = _unit->GetAIInterface()->GetNextTarget();
			}break;
		case SPELL_TARGET_RANDOM_PLAYER:
			{
				spelltarget = GetRandomPlayerTarget();
			}break;
		}
		_unit->CastSpell( spelltarget , spellid, false );
		_unit->Unroot();
	}
	void CastScriptSpell( ScriptSpell* spell )
	{
		_unit->Root();
		uint32 spellid = heroic ? spell->heroic_spellid : spell->normal_spellid;
		UnitPointer spelltarget = NULLUNIT;
		switch( spell->target )
		{
		case SPELL_TARGET_SELF:
			{
				spelltarget = _unit;
			}break;
		case SPELL_TARGET_GENERATE:
			{
				spelltarget = NULLUNIT;
			}break;
		case SPELL_TARGET_CURRENT_ENEMY:
			{
				spelltarget = _unit->GetAIInterface()->GetNextTarget();
			}break;
		case SPELL_TARGET_RANDOM_PLAYER:
			{
				spelltarget = GetRandomPlayerTarget();
			}break;
		case SPELL_TARGET_RANDOM_PLAYER_POSITION:
			{
				PlayerPointer target = GetRandomPlayerTarget();
				if( target )
				{
					SpellPointer sp(new Spell(_unit,dbcSpell.LookupEntry( spellid ),true,NULLAURA));
					SpellCastTargets targets;
					targets.m_destX = target->GetPositionX();
					targets.m_destY = target->GetPositionY();
					targets.m_destZ = target->GetPositionZ();
					targets.m_targetMask = TARGET_FLAG_DEST_LOCATION;
					sp->prepare(&targets);
					_unit->UnRoot();
					return;
				}
			}break;
		}
		_unit->CastSpell( spelltarget , spellid, false );
		_unit->UnRoot();
	}
	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());
						}
					}
				}			
		}
	}
		void CastScriptSpell(ScriptSpell* spell)
		{
			_unit->Root();
			uint32 spellid = heroic ? spell->heroic_spellid : spell->normal_spellid;
			if(spellid == 0)
				return;
			Unit* spelltarget = NULL;
			switch(spell->target)
			{
				case SPELL_TARGET_SELF:
					{
						spelltarget = _unit;
					}
					break;
				case SPELL_TARGET_GENERATE:
					{
						spelltarget = NULL;
					}
					break;
				case SPELL_TARGET_CURRENT_ENEMY:
					{
						spelltarget = _unit->GetAIInterface()->getNextTarget();
					}
					break;
				case SPELL_TARGET_RANDOM_PLAYER:
					{
						spelltarget = GetRandomPlayerTarget();
					}
					break;
				case SPELL_TARGET_CUSTOM:
					{
						spelltarget = _unit->GetMapMgr()->GetInterface()->GetCreatureNearestCoords(_unit->GetPositionX(), _unit->GetPositionY(), _unit->GetPositionZ(), 27733);
					}
					break;
			}
			_unit->CastSpell(spelltarget , spellid, false);
			_unit->Unroot();
		}
Пример #5
0
	//type: 1 - normal, 0 - handler
	void SpawnInvader(uint32 type)
	{
		_unit->SendChatMessage( CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Bolster my defenses! Hurry, curse you!");
		//x				y				z
		//-379.101227f	-824.835449f	60.0f
		uint32 mob_entry = 0;
		if( type )
		{
			mob_entry = 26627;
			CreatureProto *cp = CreatureProtoStorage.LookupEntry(mob_entry);
			CreatureInfo *ci = CreatureNameStorage.LookupEntry(mob_entry);
			Creature* c = NULL;
			if (cp && ci)
			{
				c = _unit->GetMapMgr()->CreateCreature( mob_entry );
				if (c) {
					//position is guessed
					c->Load(cp,-379.101227f, -824.835449f, 60.0f, 0.0f);
					c->PushToWorld(_unit->GetMapMgr());
					c->SetSummonedByGUID(_unit->GetGUID());
					//path finding would be usefull :)
					Player* p_target = GetRandomPlayerTarget();
					if( p_target )
					{
						c->GetAIInterface()->m_moveRun = true;
						c->GetAIInterface()->MoveTo(p_target->GetPositionX(), p_target->GetPositionY(), p_target->GetPositionZ(), p_target->GetOrientation());
					}
				}
			}
		}else
		{
			for( uint8 i=0; i<INVADERS_COUNT; i++ )
			{
				mob_entry = 0;
				if( Rand( ELITE_CHANCE ) )
					mob_entry = 27597;
				else
				{
					uint32 mobs[2] = {27598, 27600};
					mob_entry = mobs[Rand(1)];
				}
				CreatureProto *cp = CreatureProtoStorage.LookupEntry(mob_entry);
				CreatureInfo *ci = CreatureNameStorage.LookupEntry(mob_entry);
				Creature* c = NULL;
				if (cp && ci)
				{
					c = _unit->GetMapMgr()->CreateCreature( mob_entry );
					if (c) {
						//position is guessed
						c->Load(cp,-379.101227f, -824.835449f, 60.0f, 0.0f);
						c->PushToWorld(_unit->GetMapMgr());
						//path finding would be usefull :)
						Player* p_target = GetRandomPlayerTarget();
						if( p_target )
						{
							c->GetAIInterface()->m_moveRun = true;
							c->GetAIInterface()->MoveTo(p_target->GetPositionX(), p_target->GetPositionY(), p_target->GetPositionZ(), p_target->GetOrientation());
						}
					}
				}
			}
		}
	}
 //type: 1 - normal, 0 - handler
 void SpawnInvader(uint32 type)
 {
     _unit->SendScriptTextChatMessage(SAY_NOVOS_SUMMONER_04);
     //x                y                z
     //-379.101227f    -824.835449f    60.0f
     uint32 mob_entry = 0;
     if (type)
     {
         mob_entry = 26627;
         CreatureProto* cp = CreatureProtoStorage.LookupEntry(mob_entry);
         CreatureInfo* ci = CreatureNameStorage.LookupEntry(mob_entry);
         Creature* c = NULL;
         if (cp && ci)
         {
             c = _unit->GetMapMgr()->CreateCreature(mob_entry);
             if (c)
             {
                 //position is guessed
                 c->Load(cp, -379.101227f, -824.835449f, 60.0f, 0.0f);
                 c->PushToWorld(_unit->GetMapMgr());
                 c->SetSummonedByGUID(_unit->GetGUID());
                 //path finding would be usefull :)
                 Player* p_target = GetRandomPlayerTarget();
                 if (p_target)
                 {
                     c->GetAIInterface()->SetRun();
                     c->GetAIInterface()->MoveTo(p_target->GetPositionX(), p_target->GetPositionY(), p_target->GetPositionZ(), p_target->GetOrientation());
                 }
             }
         }
     }
     else
     {
         for (uint8 i = 0; i < INVADERS_COUNT; i++)
         {
             mob_entry = 0;
             if (Rand(ELITE_CHANCE))
                 mob_entry = 27597;
             else
             {
                 uint32 mobs[2] = { 27598, 27600 };
                 mob_entry = mobs[RandomUInt(1)];
             }
             CreatureProto* cp = CreatureProtoStorage.LookupEntry(mob_entry);
             CreatureInfo* ci = CreatureNameStorage.LookupEntry(mob_entry);
             Creature* c = NULL;
             if (cp && ci)
             {
                 c = _unit->GetMapMgr()->CreateCreature(mob_entry);
                 if (c)
                 {
                     //position is guessed
                     c->Load(cp, -379.101227f, -824.835449f, 60.0f, 0.0f);
                     c->PushToWorld(_unit->GetMapMgr());
                     //path finding would be usefull :)
                     Player* p_target = GetRandomPlayerTarget();
                     if (p_target)
                     {
                         c->GetAIInterface()->SetRun();
                         c->GetAIInterface()->MoveTo(p_target->GetPositionX(), p_target->GetPositionY(), p_target->GetPositionZ(), p_target->GetOrientation());
                     }
                 }
             }
         }
     }
 }