*Cleanups and Fixes in Mirror Image script.

--HG--
branch : trunk
This commit is contained in:
QAston
2009-07-28 21:34:18 +02:00
parent cf0d8a2b03
commit c15c25aca4
7 changed files with 104 additions and 24 deletions
@@ -1636,7 +1636,7 @@ CreatureAI* GetAI_mob_mojo(Creature *_Creature)
return new mob_mojoAI (_Creature); return new mob_mojoAI (_Creature);
} }
struct TRINITY_DLL_DECL npc_mirror_image : public SpellAI struct TRINITY_DLL_DECL npc_mirror_image : SpellAI
{ {
npc_mirror_image(Creature *c) : SpellAI(c) {} npc_mirror_image(Creature *c) : SpellAI(c) {}
@@ -1647,7 +1647,6 @@ struct TRINITY_DLL_DECL npc_mirror_image : public SpellAI
owner = ((TempSummon*)me)->GetOwner(); owner = ((TempSummon*)me)->GetOwner();
if (!owner) if (!owner)
return; return;
me->SetDisplayId(owner->GetDisplayId());
owner->SetLevel(owner->getLevel()); owner->SetLevel(owner->getLevel());
// Inherit Master's Threat List (not yet implemented) // Inherit Master's Threat List (not yet implemented)
owner->CastSpell((Unit*)NULL, 58838, true); owner->CastSpell((Unit*)NULL, 58838, true);
@@ -1656,6 +1655,43 @@ struct TRINITY_DLL_DECL npc_mirror_image : public SpellAI
// Clone Me! // Clone Me!
owner->CastSpell(me, 45204, false); owner->CastSpell(me, 45204, false);
} }
void EnterCombat(Unit *who)
{
if (spells.empty())
return;
uint32 spell = rand() % spells.size();
uint32 count = 0;
for(SpellVct::iterator itr = spells.begin(); itr != spells.end(); ++itr, ++count)
{
uint32 cooldown = GetAISpellInfo(*itr)->cooldown;
if (count == spell)
{
DoCast(spells[spell]);
cooldown += me->GetCurrentSpellCastTime(*itr);
}
events.ScheduleEvent(*itr, cooldown);
}
}
void UpdateAI(const uint32 diff)
{
if(!UpdateVictim())
return;
events.Update(diff);
if(me->hasUnitState(UNIT_STAT_CASTING))
return;
if(uint32 spellId = events.ExecuteEvent())
{
DoCast(spellId);
uint32 casttime = me->GetCurrentSpellCastTime(spellId);
events.ScheduleEvent(spellId, casttime ? casttime : 500 + GetAISpellInfo(spellId)->cooldown);
}
}
}; };
CreatureAI* GetAI_npc_mirror_image(Creature *_Creature) CreatureAI* GetAI_npc_mirror_image(Creature *_Creature)
+1 -1
View File
@@ -48,7 +48,7 @@ class TRINITY_DLL_SPEC SpellAI : public CreatureAI
void JustDied(Unit *killer); void JustDied(Unit *killer);
void UpdateAI(const uint32 diff); void UpdateAI(const uint32 diff);
static int Permissible(const Creature *); static int Permissible(const Creature *);
private: protected:
EventMap events; EventMap events;
SpellVct spells; SpellVct spells;
}; };
+10
View File
@@ -928,6 +928,16 @@ bool Guardian::InitStatsForLevel(uint32 petlevel)
SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel * 4 + petlevel)); SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel * 4 + petlevel));
break; break;
} }
case 31216: // Mirror Image
{
SetBonusDamage( int32(m_owner->SpellBaseDamageBonus(SPELL_SCHOOL_MASK_FROST) * 0.33f));
if(!pInfo)
{
SetCreateMana(28 + 30*petlevel);
SetCreateHealth(28 + 10*petlevel);
}
break;
}
default: default:
{ {
if(!pInfo) if(!pInfo)
+1 -1
View File
@@ -1296,7 +1296,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask, bool
} }
if( unit->isInCombat() && !(m_spellInfo->AttributesEx3 & SPELL_ATTR_EX3_NO_INITIAL_AGGRO) ) if( unit->isInCombat() && !(m_spellInfo->AttributesEx3 & SPELL_ATTR_EX3_NO_INITIAL_AGGRO) )
{ {
m_caster->SetInCombatState(unit->GetCombatTimer() > 0); m_caster->SetInCombatState(unit->GetCombatTimer() > 0, unit);
unit->getHostilRefManager().threatAssist(m_caster, 0.0f); unit->getHostilRefManager().threatAssist(m_caster, 0.0f);
} }
} }
+30 -5
View File
@@ -7514,8 +7514,10 @@ void AuraEffect::HandleReflectSpells( bool Apply, bool Real , bool /*changeAmoun
} }
void AuraEffect::HandleAuraInitializeImages( bool Apply, bool Real , bool /*changeAmount*/) void AuraEffect::HandleAuraInitializeImages( bool Apply, bool Real , bool /*changeAmount*/)
{ {
if (!Real || !Apply) if (!Real)
return; return;
if (Apply)
{
Unit * caster = GetCaster(); Unit * caster = GetCaster();
if (!caster) if (!caster)
return; return;
@@ -7527,25 +7529,48 @@ void AuraEffect::HandleAuraInitializeImages( bool Apply, bool Real , bool /*chan
if (Item const * item = ((Player *)caster)->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND)) if (Item const * item = ((Player *)caster)->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND))
m_target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, item->GetProto()->ItemId); m_target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, item->GetProto()->ItemId);
} }
else else // TYPEID_UNIT
{ {
m_target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, caster->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID)); m_target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, caster->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID));
m_target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, caster->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1)); m_target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, caster->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1));
m_target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2, caster->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2)); m_target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2, caster->GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 2));
} }
}
else
{
// Remove equipment visual
if (m_target->GetTypeId() == TYPEID_PLAYER)
{
for (uint8 i = 0; i < 3; ++i)
m_target->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + i, 0);
}
else // TYPEID_UNIT
{
((Creature*)m_target)->LoadEquipment(((Creature*)m_target)->GetEquipmentId());
}
}
} }
void AuraEffect::HandleAuraCloneCaster( bool Apply, bool Real , bool /*changeAmount*/) void AuraEffect::HandleAuraCloneCaster( bool Apply, bool Real , bool /*changeAmount*/)
{ {
if (!Real || !Apply) if (!Real)
return; return;
if (Apply)
{
Unit * caster = GetCaster(); Unit * caster = GetCaster();
if (!caster) if (!caster)
return; return;
// Set item visual // Set display id (probably for portrait?)
m_target->SetDisplayId(caster->GetDisplayId()); m_target->SetDisplayId(caster->GetDisplayId());
m_target->SetUInt32Value(UNIT_FIELD_FLAGS_2, 2064); m_target->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_MIRROR_IMAGE);
}
else
{
m_target->SetDisplayId(m_target->GetNativeDisplayId());
m_target->RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_MIRROR_IMAGE);
}
} }
int32 AuraEffect::CalculateCrowdControlAuraAmount(Unit * caster) int32 AuraEffect::CalculateCrowdControlAuraAmount(Unit * caster)
{ {
// Damage cap for CC effects // Damage cap for CC effects
+7
View File
@@ -3521,6 +3521,13 @@ Spell* Unit::FindCurrentSpellBySpellId(uint32 spell_id) const
return NULL; return NULL;
} }
int32 Unit::GetCurrentSpellCastTime(uint32 spell_id) const
{
if (Spell const * spell = FindCurrentSpellBySpellId(spell_id))
return spell->GetCastTime();
return 0;
}
bool Unit::isInFrontInMap(Unit const* target, float distance, float arc) const bool Unit::isInFrontInMap(Unit const* target, float distance, float arc) const
{ {
return IsWithinDistInMap(target, distance) && HasInArc( arc, target ); return IsWithinDistInMap(target, distance) && HasInArc( arc, target );
+2
View File
@@ -583,6 +583,7 @@ enum UnitFlags2
UNIT_FLAG2_FEIGN_DEATH = 0x00000001, UNIT_FLAG2_FEIGN_DEATH = 0x00000001,
UNIT_FLAG2_UNK1 = 0x00000002, // Hide unit model (show only player equip) UNIT_FLAG2_UNK1 = 0x00000002, // Hide unit model (show only player equip)
UNIT_FLAG2_COMPREHEND_LANG = 0x00000008, UNIT_FLAG2_COMPREHEND_LANG = 0x00000008,
UNIT_FLAG2_MIRROR_IMAGE = 0x00000010,
UNIT_FLAG2_FORCE_MOVE = 0x00000040, UNIT_FLAG2_FORCE_MOVE = 0x00000040,
UNIT_FLAG2_DISARM_OFFHAND = 0x00000080, UNIT_FLAG2_DISARM_OFFHAND = 0x00000080,
UNIT_FLAG2_DISARM_RANGED = 0x00000400, //this does not disable ranged weapon display (maybe additional flag needed?) UNIT_FLAG2_DISARM_RANGED = 0x00000400, //this does not disable ranged weapon display (maybe additional flag needed?)
@@ -1497,6 +1498,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid = 0, bool withInstant = true); void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid = 0, bool withInstant = true);
Spell* FindCurrentSpellBySpellId(uint32 spell_id) const; Spell* FindCurrentSpellBySpellId(uint32 spell_id) const;
int32 GetCurrentSpellCastTime(uint32 spell_id) const;
Spell* m_currentSpells[CURRENT_MAX_SPELL]; Spell* m_currentSpells[CURRENT_MAX_SPELL];