Тема: [fix] Mirror Image
Показать сообщение отдельно
Старый 12.03.2010, 04:21   #2
MaxXx2021
Ученый
 
Аватар для MaxXx2021
 
Регистрация: 09.03.2010
Адрес: Кыргызстан
Сообщений: 266
Сказал(а) спасибо: 41
Поблагодарили 115 раз(а) в 34 сообщениях
MaxXx2021 Скоро придёт к известности
По умолчанию

Код:
enum
{
   SPELL_FROSTBOLT         = 59638,
   SPELL_FIREBALL          = 59637
};

/*######
## npc_mirror_image
######*/

struct MANGOS_DLL_DECL npc_mirror_imageAI : public ScriptedAI
{
    npc_mirror_imageAI(Creature* pCreature) : ScriptedAI(pCreature) {Reset();}

	uint32 m_uiFrostboltTimer;
	uint32 m_uiFireblastTimer;
	bool inCombat;
                uint32 LifeTime;

    void Reset() 
	{
                                LifeTime = 30000;
		Unit *owner = m_creature->GetOwner();
		if (!owner)
			return;

		if (owner && !m_creature->hasUnitState(UNIT_STAT_FOLLOW))
		{
			m_creature->GetMotionMaster()->Clear(false);
			m_creature->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE);
		}
		// Inherit Master's Threat List (not yet implemented)
		//owner->CastSpell((Unit*)NULL, 58838, true);
		// here mirror image casts on summoner spell (not present in client dbc) 49866
		// here should be auras (not present in client dbc): 35657, 35658, 35659, 35660 selfcasted by mirror images (stats related?)
		// Clone Me!
		m_uiFrostboltTimer = 0;
		m_uiFireblastTimer = 6100;
		inCombat = false;
	}

	void AttackStart(Unit* pWho)
	{
		if (!pWho)
			return;

		if (m_creature->Attack(pWho, true))
		{
            m_creature->clearUnitState(UNIT_STAT_FOLLOW);
            // TMGs call CreatureRelocation which via MoveInLineOfSight can call this function
            // thus with the following clear the original TMG gets invalidated and crash, doh
            // hope it doesn't start to leak memory without this :-/
            //i_pet->Clear();
            m_creature->GetMotionMaster()->MoveChase(pWho);
            m_creature->getVictim()->AddThreat(m_creature);
            inCombat = true;
        }
	}

	void EnterEvadeMode()
	{
		if (m_creature->IsInEvadeMode() || !m_creature->isAlive())
			return;

		inCombat = false;
		Unit *owner = m_creature->GetCharmerOrOwner();

		m_creature->AttackStop();
		m_creature->CombatStop(true);
		if (owner && !m_creature->hasUnitState(UNIT_STAT_FOLLOW))
		{
			m_creature->GetMotionMaster()->Clear(false);
			m_creature->GetMotionMaster()->MoveFollow(owner, PET_FOLLOW_DIST,PET_FOLLOW_ANGLE);
		}
	}

	void UpdateAI(const uint32 diff)
	{

		if (LifeTime < diff)
		{
			m_creature->RemoveFromWorld();
		} else LifeTime -= diff;
		
		if (/*!m_creature->SelectHostileTarget() || */!m_creature->getVictim())
		{
			Unit *owner = m_creature->GetCharmerOrOwner();
			if (owner && owner->getVictim())
				m_creature->AI()->AttackStart(owner->getVictim());
		}

		if (inCombat && !m_creature->getVictim())
		{
			EnterEvadeMode();
			return;
		}

		if (/*!m_creature->SelectHostileTarget() || */!m_creature->getVictim())
			return;

		if (m_uiFrostboltTimer <= diff)
		{
			DoCast(m_creature->getVictim(),59638);
			m_uiFrostboltTimer = 3100;
		}else m_uiFrostboltTimer -= diff;

		if (m_uiFireblastTimer <= diff)
		{
			DoCast(m_creature->getVictim(),59637,true);
			m_uiFireblastTimer = 6000;
		}else m_uiFireblastTimer -= diff;

		DoMeleeAttackIfReady();
	}
};

CreatureAI* GetAI_npc_mirror_image(Creature* pCreature)
{
    return new npc_mirror_imageAI(pCreature);
}
Код:
    newscript = new Script;
    newscript->Name = "npc_mirror_image";
    newscript->GetAI = &GetAI_npc_mirror_image;
    newscript->RegisterSelf();
это в SpecialNPC - спасибо Set за предоставленый скрипт. Я чуток подогнал его под свой патч.

Последний раз редактировалось MaxXx2021; 17.03.2010 в 04:01.
MaxXx2021 вне форума   Ответить с цитированием