*Fix the bug that summoner cannot attack summoned creatures. This bug was introduced in 4481. Note the difference between "summoner" and "owner".

*Valkyr script updated.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-08-14 22:25:12 -05:00
parent b8222df247
commit 43d35de4ff
2 changed files with 20 additions and 37 deletions
@@ -1352,13 +1352,11 @@ CreatureAI* GetAI_npc_dkc1_gothik(Creature* pCreature)
#define SPELL_REVIVE 51918 #define SPELL_REVIVE 51918
#define VALK_WHISPER "It is not yet your time, champion. Rise! Rise and fight once more!" #define VALK_WHISPER "It is not yet your time, champion. Rise! Rise and fight once more!"
struct TRINITY_DLL_DECL npc_valkyr_battle_maidenAI : public ScriptedAI struct TRINITY_DLL_DECL npc_valkyr_battle_maidenAI : public PassiveAI
{ {
npc_valkyr_battle_maidenAI(Creature *c) : ScriptedAI(c) {} npc_valkyr_battle_maidenAI(Creature *c) : PassiveAI(c) {}
Player *Owner;
uint32 FlyBackTimer; uint32 FlyBackTimer;
uint64 TargetGUID;
float x, y, z; float x, y, z;
uint32 phase; uint32 phase;
@@ -1370,76 +1368,59 @@ struct TRINITY_DLL_DECL npc_valkyr_battle_maidenAI : public ScriptedAI
FlyBackTimer = 500; FlyBackTimer = 500;
phase = 0; phase = 0;
Owner = NULL;
m_creature->GetPosition(x, y, z); m_creature->GetPosition(x, y, z);
z += 4; x -= 3.5; y -= 5; z += 4; x -= 3.5; y -= 5;
m_creature->GetMotionMaster()->Clear(false); m_creature->GetMotionMaster()->Clear(false);
m_creature->GetMap()->CreatureRelocation(m_creature, x, y, z, 0.0f); m_creature->GetMap()->CreatureRelocation(m_creature, x, y, z, 0.0f);
} }
void Aggro(Unit *who){}
void AttackStart(Unit *who){}
void UpdateAI(const uint32 diff) void UpdateAI(const uint32 diff)
{ {
if (!Owner) if(FlyBackTimer < diff)
{ {
TargetGUID = m_creature->GetOwnerGUID(); Player *plr = NULL;
Owner = Unit::GetPlayer(TargetGUID); if(me->isSummon())
return; if(Unit *summoner = CAST_SUM(me)->GetSummoner())
} if(summoner->GetTypeId() == TYPEID_PLAYER)
plr = CAST_PLR(summoner);
if (Owner->isAlive()) if(!plr)
phase = 4; phase = 3;
if (FlyBackTimer < diff)
{
switch(phase) switch(phase)
{ {
case 0: case 0:
m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE); m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
m_creature->HandleEmoteCommand(EMOTE_STATE_FLYGRABCLOSED); m_creature->HandleEmoteCommand(EMOTE_STATE_FLYGRABCLOSED);
FlyBackTimer = 500; FlyBackTimer = 500;
phase = 1;
break; break;
case 1: case 1:
Owner->GetClosePoint(x,y,z, m_creature->GetObjectSize()); plr->GetClosePoint(x,y,z, m_creature->GetObjectSize());
z += 2.5; x -= 2; y -= 1.5; z += 2.5; x -= 2; y -= 1.5;
m_creature->GetMotionMaster()->MovePoint(0, x, y, z); m_creature->GetMotionMaster()->MovePoint(0, x, y, z);
m_creature->SetUInt64Value(UNIT_FIELD_TARGET, Owner->GetGUID()); m_creature->SetUInt64Value(UNIT_FIELD_TARGET, plr->GetGUID());
m_creature->SetVisibility(VISIBILITY_ON); m_creature->SetVisibility(VISIBILITY_ON);
FlyBackTimer = 4500; FlyBackTimer = 4500;
phase = 2;
break; break;
case 2: case 2:
if (!Owner->isRessurectRequested()) if (!plr->isRessurectRequested())
{ {
m_creature->HandleEmoteCommand(EMOTE_ONESHOT_CUSTOMSPELL01); m_creature->HandleEmoteCommand(EMOTE_ONESHOT_CUSTOMSPELL01);
DoCast(Owner, SPELL_REVIVE,true); DoCast(plr, SPELL_REVIVE, true);
m_creature->MonsterWhisper(VALK_WHISPER, Owner->GetGUID()); m_creature->MonsterWhisper(VALK_WHISPER, plr->GetGUID());
} }
FlyBackTimer = 5000; FlyBackTimer = 5000;
phase = 3;
break; break;
case 3: case 3:
m_creature->SetVisibility(VISIBILITY_OFF); me->DisappearAndDie();
FlyBackTimer = 2000;
phase = 4;
break;
case 4:
m_creature->setDeathState(JUST_DIED);
m_creature->RemoveCorpse();
break; break;
default: default:
//Nothing To DO //Nothing To DO
break; break;
} }
++phase;
}else FlyBackTimer-=diff; }else FlyBackTimer-=diff;
} }
void MoveInLineOfSight(Unit *who){}
}; };
CreatureAI* GetAI_npc_valkyr_battle_maiden(Creature* pCreature) CreatureAI* GetAI_npc_valkyr_battle_maiden(Creature* pCreature)
+3 -1
View File
@@ -3424,9 +3424,11 @@ void Spell::EffectSummonType(uint32 i)
TempSummon * summon = m_originalCaster->SummonCreature(entry,px,py,pz,m_caster->GetOrientation(),summonType,duration); TempSummon * summon = m_originalCaster->SummonCreature(entry,px,py,pz,m_caster->GetOrientation(),summonType,duration);
if (!summon) if (!summon)
continue; continue;
summon->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, m_originalCaster->GetGUID());
if (properties->Category == SUMMON_CATEGORY_ALLY) if (properties->Category == SUMMON_CATEGORY_ALLY)
{
summon->SetUInt64Value(UNIT_FIELD_SUMMONEDBY, m_originalCaster->GetGUID());
summon->setFaction(m_originalCaster->getFaction()); summon->setFaction(m_originalCaster->getFaction());
}
} }
break; break;
} }