aboutsummaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authormegamage <none@none>2009-05-06 13:34:11 -0500
committermegamage <none@none>2009-05-06 13:34:11 -0500
commitfa1dcd16cf8bc09cd0c0878020b59e7128e71d09 (patch)
tree46062e99b9b8494520351b83e8f71a8e77e2a818 /src/game
parent5d3a64517eff8db5781f299ece29a338b6e2f7a2 (diff)
*Update summon system.
--HG-- branch : trunk
Diffstat (limited to 'src/game')
-rw-r--r--src/game/Object.cpp16
-rw-r--r--src/game/Pet.cpp2
-rw-r--r--src/game/SpellEffects.cpp4
-rw-r--r--src/game/TemporarySummon.cpp59
-rw-r--r--src/game/TemporarySummon.h8
-rw-r--r--src/game/Totem.cpp21
-rw-r--r--src/game/Totem.h3
-rw-r--r--src/game/Unit.cpp60
-rw-r--r--src/game/WaypointMovementGenerator.cpp15
9 files changed, 106 insertions, 82 deletions
diff --git a/src/game/Object.cpp b/src/game/Object.cpp
index 7adc7d306bb..cb16a38baff 100644
--- a/src/game/Object.cpp
+++ b/src/game/Object.cpp
@@ -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();
diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp
index 1c67eadb07f..1fc33a3ccb6 100644
--- a/src/game/Pet.cpp
+++ b/src/game/Pet.cpp
@@ -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();
diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp
index d6196468972..ffb3a38c9fb 100644
--- a/src/game/SpellEffects.cpp
+++ b/src/game/SpellEffects.cpp
@@ -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:
diff --git a/src/game/TemporarySummon.cpp b/src/game/TemporarySummon.cpp
index 034bf492e1c..170e590fd9c 100644
--- a/src/game/TemporarySummon.cpp
+++ b/src/game/TemporarySummon.cpp
@@ -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,28 +176,12 @@ void TempSummon::InitSummon(uint32 duration)
if(m_type == TEMPSUMMON_MANUAL_DESPAWN)
m_type = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN;
- Unit* owner = GetSummoner();
- if(owner)
- {
- if(owner->GetTypeId()==TYPEID_UNIT && ((Creature*)owner)->IsAIEnabled)
- ((Creature*)owner)->AI()->JustSummoned(this);
-
- if(GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER && m_spells[0])
- {
- setFaction(owner->getFaction());
- if(m_spells[1] && GetMap()->IsHeroic())
- CastSpell(this, m_spells[1], false, 0, 0, m_summonerGUID);
- else
- CastSpell(this, m_spells[0], false, 0, 0, m_summonerGUID);
- }
- }
-
if(!m_Properties)
return;
if(uint32 slot = m_Properties->Slot)
{
- if(owner)
+ if(Unit *owner = GetSummoner())
{
if(owner->m_SummonSlot[slot] && owner->m_SummonSlot[slot] != GetGUID())
{
@@ -213,6 +197,25 @@ void TempSummon::InitSummon(uint32 duration)
setFaction(m_Properties->Faction);
}
+void TempSummon::InitSummon()
+{
+ Unit* owner = GetSummoner();
+ if(owner)
+ {
+ if(owner->GetTypeId()==TYPEID_UNIT && ((Creature*)owner)->IsAIEnabled)
+ ((Creature*)owner)->AI()->JustSummoned(this);
+
+ if(GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER && m_spells[0])
+ {
+ setFaction(owner->getFaction());
+ if(m_spells[1] && GetMap()->IsHeroic())
+ CastSpell(this, m_spells[1], false, 0, 0, m_summonerGUID);
+ else
+ CastSpell(this, m_spells[0], false, 0, 0, m_summonerGUID);
+ }
+ }
+}
+
void TempSummon::SetTempSummonType(TempSummonType type)
{
m_type = 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);
}
diff --git a/src/game/TemporarySummon.h b/src/game/TemporarySummon.h
index 1a3dfef1c7d..09e7f22afb0 100644
--- a/src/game/TemporarySummon.h
+++ b/src/game/TemporarySummon.h
@@ -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; }
diff --git a/src/game/Totem.cpp b/src/game/Totem.cpp
index c7a81be29ef..3cdc8050d53 100644
--- a/src/game/Totem.cpp
+++ b/src/game/Totem.cpp
@@ -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());
diff --git a/src/game/Totem.h b/src/game/Totem.h
index 4287ddc50e6..134ca6d6d3f 100644
--- a/src/game/Totem.h
+++ b/src/game/Totem.h
@@ -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; }
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 85b5c04e545..4003a769284 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -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());
}
}
diff --git a/src/game/WaypointMovementGenerator.cpp b/src/game/WaypointMovementGenerator.cpp
index 6aba7def916..7cabd63acf1 100644
--- a/src/game/WaypointMovementGenerator.cpp
+++ b/src/game/WaypointMovementGenerator.cpp
@@ -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;