*Update summon system.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-05-06 13:34:11 -05:00
parent 5d3a64517e
commit fa1dcd16cf
9 changed files with 109 additions and 85 deletions

View File

@@ -1658,8 +1658,9 @@ TempSummon *Map::SummonCreature(uint32 entry, float x, float y, float z, float a
return NULL;
}
summon->InitStats(duration);
Add((Creature*)summon);
summon->InitSummon(duration);
summon->InitSummon();
//ObjectAccessor::UpdateObjectVisibility(summon);
@@ -1781,8 +1782,6 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy
// this enables pet details window (Shift+P)
pet->GetCharmInfo()->SetPetNumber(pet_number, false);
map->Add((Creature*)pet);
pet->setPowerType(POWER_MANA);
pet->SetUInt32Value(UNIT_NPC_FLAGS , 0);
pet->SetUInt32Value(UNIT_FIELD_BYTES_1,0);
@@ -1801,6 +1800,17 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy
pet->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, 1000);
pet->SetHealth(pet->GetMaxHealth());
pet->SetPower(POWER_MANA, pet->GetMaxPower(POWER_MANA));
break;
}
map->Add((Creature*)pet);
switch(petType)
{
case POSSESSED_PET:
pet->SetCharmedOrPossessedBy(this, true);
break;
case SUMMON_PET:
pet->InitPetCreateSpells();
pet->SavePetToDB(PET_SAVE_AS_CURRENT);
PetSpellInitialize();

View File

@@ -261,8 +261,8 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool
SetPower(POWER_MANA, savedmana > GetMaxPower(POWER_MANA) ? GetMaxPower(POWER_MANA) : savedmana);
}
map->Add((Creature*)this);
owner->SetMinion(this, true);
map->Add((Creature*)this);
m_resetTalentsCost = fields[17].GetUInt32();
m_resetTalentsTime = fields[18].GetUInt64();

View File

@@ -3287,10 +3287,13 @@ void Spell::EffectSummonType(uint32 i)
summon->SetHealth(damage);
}
//summon->SetUInt32Value(UNIT_CREATED_BY_SPELL,m_spellInfo->Id);
if(m_originalCaster->GetTypeId() == TYPEID_PLAYER
&& properties->Slot >= SUMMON_SLOT_TOTEM
&& properties->Slot < MAX_TOTEM_SLOT)
{
//summon->SendUpdateToPlayer((Player*)m_originalCaster);
WorldPacket data(SMSG_TOTEM_CREATED, 1+8+4+4);
data << uint8(properties->Slot-1);
data << uint64(m_originalCaster->GetGUID());
@@ -3356,7 +3359,6 @@ void Spell::EffectSummonType(uint32 i)
return;
pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id);
pet->SetCharmedOrPossessedBy(m_caster, true);
break;
}
case SUMMON_CATEGORY_VEHICLE:

View File

@@ -166,7 +166,7 @@ void TempSummon::Update( uint32 diff )
Creature::Update( diff );
}
void TempSummon::InitSummon(uint32 duration)
void TempSummon::InitStats(uint32 duration)
{
assert(!isPet());
@@ -176,6 +176,29 @@ void TempSummon::InitSummon(uint32 duration)
if(m_type == TEMPSUMMON_MANUAL_DESPAWN)
m_type = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN;
if(!m_Properties)
return;
if(uint32 slot = m_Properties->Slot)
{
if(Unit *owner = GetSummoner())
{
if(owner->m_SummonSlot[slot] && owner->m_SummonSlot[slot] != GetGUID())
{
Creature *oldSummon = GetMap()->GetCreature(owner->m_SummonSlot[slot]);
if(oldSummon && oldSummon->isSummon())
((TempSummon*)oldSummon)->UnSummon();
}
owner->m_SummonSlot[slot] = GetGUID();
}
}
if(m_Properties->Faction)
setFaction(m_Properties->Faction);
}
void TempSummon::InitSummon()
{
Unit* owner = GetSummoner();
if(owner)
{
@@ -191,26 +214,6 @@ void TempSummon::InitSummon(uint32 duration)
CastSpell(this, m_spells[0], false, 0, 0, m_summonerGUID);
}
}
if(!m_Properties)
return;
if(uint32 slot = m_Properties->Slot)
{
if(owner)
{
if(owner->m_SummonSlot[slot] && owner->m_SummonSlot[slot] != GetGUID())
{
Creature *oldSummon = GetMap()->GetCreature(owner->m_SummonSlot[slot]);
if(oldSummon && oldSummon->isSummon())
((TempSummon*)oldSummon)->UnSummon();
}
owner->m_SummonSlot[slot] = GetGUID();
}
}
if(m_Properties->Faction)
setFaction(m_Properties->Faction);
}
void TempSummon::SetTempSummonType(TempSummonType type)
@@ -264,9 +267,9 @@ Minion::Minion(SummonPropertiesEntry const *properties, Unit *owner) : TempSummo
m_summonMask |= SUMMON_MASK_MINION;
}
void Minion::InitSummon(uint32 duration)
void Minion::InitStats(uint32 duration)
{
TempSummon::InitSummon(duration);
TempSummon::InitStats(duration);
SetReactState(REACT_PASSIVE);
@@ -276,6 +279,16 @@ void Minion::InitSummon(uint32 duration)
m_owner->SetMinion(this, true);
}
void Minion::InitSummon()
{
TempSummon::InitSummon();
if(m_owner->GetTypeId() == TYPEID_PLAYER
&& m_owner->GetMinionGUID() == GetGUID()
&& !m_owner->GetCharmGUID())
((Player*)m_owner)->CharmSpellInitialize();
}
void Minion::RemoveFromWorld()
{
if(!IsInWorld())
@@ -292,12 +305,12 @@ Guardian::Guardian(SummonPropertiesEntry const *properties, Unit *owner) : Minio
InitCharmInfo();
}
void Guardian::InitSummon(uint32 duration)
void Guardian::InitStats(uint32 duration)
{
Minion::InitStats(duration);
if(m_owner->GetTypeId() == TYPEID_PLAYER)
m_charmInfo->InitCharmCreateSpells();
Minion::InitSummon(duration);
SetReactState(REACT_AGGRESSIVE);
}

View File

@@ -29,7 +29,8 @@ class TempSummon : public Creature
explicit TempSummon(SummonPropertiesEntry const *properties, Unit *owner);
virtual ~TempSummon(){};
void Update(uint32 time);
virtual void InitSummon(uint32 lifetime);
virtual void InitStats(uint32 lifetime);
virtual void InitSummon();
void UnSummon();
void RemoveFromWorld();
void SetTempSummonType(TempSummonType type);
@@ -49,7 +50,8 @@ class Minion : public TempSummon
{
public:
Minion(SummonPropertiesEntry const *properties, Unit *owner);
void InitSummon(uint32 duration);
void InitStats(uint32 duration);
void InitSummon();
void RemoveFromWorld();
Unit *GetOwner() { return m_owner; }
protected:
@@ -60,7 +62,7 @@ class Guardian : public Minion
{
public:
Guardian(SummonPropertiesEntry const *properties, Unit *owner);
void InitSummon(uint32 duration);
void InitStats(uint32 duration);
bool InitStatsForLevel(uint32 level);
int32 GetBonusDamage() { return m_bonusdamage; }

View File

@@ -52,9 +52,9 @@ void Totem::Update( uint32 time )
Creature::Update( time );
}
void Totem::InitSummon(uint32 duration)
void Totem::InitStats(uint32 duration)
{
Minion::InitSummon(duration);
Minion::InitStats(duration);
CreatureInfo const *cinfo = GetCreatureInfo();
if (m_owner->GetTypeId()==TYPEID_PLAYER && cinfo)
@@ -80,10 +80,6 @@ void Totem::InitSummon(uint32 duration)
sLog.outErrorDb("Totem::Summon: Missing modelid information for entry %u, team %u, totem will use default values.",GetEntry(),((Player*)m_owner)->GetTeam());
}
WorldPacket data(SMSG_GAMEOBJECT_SPAWN_ANIM_OBSOLETE, 8);
data << GetGUID();
SendMessageToSet(&data,true);
// Get spell casted by totem
SpellEntry const * totemSpell = sSpellStore.LookupEntry(GetSpell());
if (totemSpell)
@@ -93,9 +89,6 @@ void Totem::InitSummon(uint32 duration)
m_type = TOTEM_ACTIVE;
}
if(m_type == TOTEM_PASSIVE)
CastSpell(this, GetSpell(), true);
if(GetEntry() == SENTRY_TOTEM_ENTRY)
SetReactState(REACT_AGGRESSIVE);
@@ -104,6 +97,16 @@ void Totem::InitSummon(uint32 duration)
SetLevel(m_owner->getLevel());
}
void Totem::InitSummon()
{
WorldPacket data(SMSG_GAMEOBJECT_SPAWN_ANIM_OBSOLETE, 8);
data << GetGUID();
SendMessageToSet(&data, true);
if(m_type == TOTEM_PASSIVE)
CastSpell(this, GetSpell(), true);
}
void Totem::UnSummon()
{
SendObjectDeSpawnAnim(GetGUID());

View File

@@ -37,7 +37,8 @@ class Totem : public Minion
explicit Totem(SummonPropertiesEntry const *properties, Unit *owner);
virtual ~Totem(){};
void Update( uint32 time );
void InitSummon(uint32 duration);
void InitStats(uint32 duration);
void InitSummon();
void UnSummon();
uint32 GetSpell() const { return m_spells[0]; }
uint32 GetTotemDuration() const { return m_duration; }

View File

@@ -8183,25 +8183,14 @@ void Unit::SetMinion(Minion *minion, bool apply)
}
}
// Check priority.
if(Minion *oldMinion = GetFirstMinion())
//if(minion->HasSummonMask(SUMMON_MASK_GUARDIAN))
{
if(minion->HasSummonMask(SUMMON_MASK_GUARDIAN)
&& !oldMinion->HasSummonMask(SUMMON_MASK_GUARDIAN))
SetMinionGUID(0);
}
// Set first minion
if(AddUInt64Value(UNIT_FIELD_SUMMON, minion->GetGUID()))
{
if(GetTypeId() == TYPEID_PLAYER && !GetCharmGUID() && minion->HasSummonMask(SUMMON_MASK_GUARDIAN))
if(AddUInt64Value(UNIT_FIELD_SUMMON, minion->GetGUID()))
{
if(minion->isPet())
((Player*)this)->PetSpellInitialize();
else
((Player*)this)->CharmSpellInitialize();
}
}
//else if(minion->m_Properties && minion->m_Properties->Type == SUMMON_TYPE_MINIPET)
// AddUInt64Value(UNIT_FIELD_CRITTER, minion->GetGUID());
// FIXME: hack, speed must be set only at follow
if(HasByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP))
@@ -8227,30 +8216,39 @@ void Unit::SetMinion(Minion *minion, bool apply)
SetPetGUID(0);
}
if(RemoveUInt64Value(UNIT_FIELD_SUMMON, minion->GetGUID()))
//if(minion->HasSummonMask(SUMMON_MASK_GUARDIAN))
{
//Check if there is another minion
for(ControlList::iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr)
if(RemoveUInt64Value(UNIT_FIELD_SUMMON, minion->GetGUID()))
{
if(GetCharmGUID() == (*itr)->GetGUID())
continue;
assert((*itr)->GetOwnerGUID() == GetGUID());
assert((*itr)->GetTypeId() == TYPEID_UNIT);
if(AddUInt64Value(UNIT_FIELD_SUMMON, (*itr)->GetGUID()))
//Check if there is another minion
for(ControlList::iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr)
{
//show another pet bar if there is no charm bar
if(GetTypeId() == TYPEID_PLAYER && !GetCharmGUID() && ((Creature*)(*itr))->HasSummonMask(SUMMON_MASK_GUARDIAN))
if(GetCharmGUID() == (*itr)->GetGUID())
continue;
assert((*itr)->GetOwnerGUID() == GetGUID());
assert((*itr)->GetTypeId() == TYPEID_UNIT);
if(!((Creature*)(*itr))->HasSummonMask(SUMMON_MASK_GUARDIAN))
continue;
if(AddUInt64Value(UNIT_FIELD_SUMMON, (*itr)->GetGUID()))
{
if(((Creature*)(*itr))->isPet())
((Player*)this)->PetSpellInitialize();
else
((Player*)this)->CharmSpellInitialize();
//show another pet bar if there is no charm bar
if(GetTypeId() == TYPEID_PLAYER && !GetCharmGUID() && ((Creature*)(*itr))->HasSummonMask(SUMMON_MASK_GUARDIAN))
{
if(((Creature*)(*itr))->isPet())
((Player*)this)->PetSpellInitialize();
else
((Player*)this)->CharmSpellInitialize();
}
}
break;
}
break;
}
}
//else if(minion->m_Properties && minion->m_Properties->Type == SUMMON_TYPE_MINIPET)
// RemoveUInt64Value(UNIT_FIELD_CRITTER, minion->GetGUID());
}
}

View File

@@ -226,14 +226,12 @@ template bool WaypointMovementGenerator<Player>::Update(Player &, const uint32 &
template void WaypointMovementGenerator<Player>::MovementInform(Player &);
//----------------------------------------------------//
void
FlightPathMovementGenerator::LoadPath(Player &)
void FlightPathMovementGenerator::LoadPath(Player &)
{
objmgr.GetTaxiPathNodes(i_pathId, i_path,i_mapIds);
}
uint32
FlightPathMovementGenerator::GetPathAtMapEnd() const
uint32 FlightPathMovementGenerator::GetPathAtMapEnd() const
{
if(i_currentNode >= i_mapIds.size())
return i_mapIds.size();
@@ -248,8 +246,7 @@ FlightPathMovementGenerator::GetPathAtMapEnd() const
return i_mapIds.size();
}
void
FlightPathMovementGenerator::Initialize(Player &player)
void FlightPathMovementGenerator::Initialize(Player &player)
{
player.getHostilRefManager().setOnlineOfflineState(false);
player.addUnitState(UNIT_STAT_IN_FLIGHT);
@@ -285,8 +282,7 @@ void FlightPathMovementGenerator::Finalize(Player & player)
}
}
bool
FlightPathMovementGenerator::Update(Player &player, const uint32 &diff)
bool FlightPathMovementGenerator::Update(Player &player, const uint32 &diff)
{
if( MovementInProgress() )
{
@@ -321,8 +317,7 @@ FlightPathMovementGenerator::Update(Player &player, const uint32 &diff)
return false;
}
void
FlightPathMovementGenerator::SetCurrentNodeAfterTeleport()
void FlightPathMovementGenerator::SetCurrentNodeAfterTeleport()
{
if(i_mapIds.empty())
return;