diff options
author | megamage <none@none> | 2009-03-20 14:01:46 -0600 |
---|---|---|
committer | megamage <none@none> | 2009-03-20 14:01:46 -0600 |
commit | 8f627853dfaab8bfecd24bfd96ad02c6503d517e (patch) | |
tree | ab518e88d6bfd462e50998541cbcc1575134ce66 /src/game/Object.cpp | |
parent | 7cd9a01954f6905dfb0e6a113b5799cc2442a39e (diff) |
*More work on summon system.
--HG--
branch : trunk
Diffstat (limited to 'src/game/Object.cpp')
-rw-r--r-- | src/game/Object.cpp | 89 |
1 files changed, 71 insertions, 18 deletions
diff --git a/src/game/Object.cpp b/src/game/Object.cpp index eda29509b8c..770c2d14899 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -44,6 +44,7 @@ #include "GridNotifiersImpl.h" #include "TemporarySummon.h" +#include "Totem.h" uint32 GuidHigh2TypeId(uint32 guid_hi) { @@ -1578,34 +1579,88 @@ void WorldObject::AddObjectToRemoveList() map->AddObjectToRemoveList(this); } -TempSummon* WorldObject::SummonCreature(uint32 id, float x, float y, float z, float ang,TempSummonType spwtype,uint32 despwtime) +TempSummon *Map::SummonCreature(uint32 entry, float x, float y, float z, float angle, SummonPropertiesEntry const *properties, uint32 duration, Unit *summoner) { - TempSummon* pCreature = new TempSummon(GetGUID()); + uint32 mask = SUMMON_MASK_SUMMON; + if(properties) + { + if(properties->Category == SUMMON_CATEGORY_GUARDIAN + || properties->Type == SUMMON_TYPE_GUARDIAN + || properties->Type == SUMMON_TYPE_MINION) + mask = SUMMON_MASK_GUARDIAN; + else if(properties->Type == SUMMON_TYPE_TOTEM) + mask = SUMMON_MASK_TOTEM; + else if(properties->Category == SUMMON_CATEGORY_VEHICLE + || properties->Type == SUMMON_TYPE_VEHICLE) + mask = SUMMON_MASK_VEHICLE; + } - uint32 team = 0; - if (GetTypeId()==TYPEID_PLAYER) - team = ((Player*)this)->GetTeam(); + TempSummon *summon = NULL; + bool ok = true; + uint32 phase = PHASEMASK_NORMAL, team = 0; + if(summoner) + { + phase = summoner->GetPhaseMask(); + if(summoner->GetTypeId() == TYPEID_PLAYER) + team = ((Player*)summoner)->GetTeam(); + } - if (!pCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), GetMap(), GetPhaseMask(), id, team)) + switch(mask) { - delete pCreature; + case SUMMON_MASK_SUMMON: + summon = new TempSummon(properties, summoner); + ok = summon->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), this, phase, entry, team); + break; + case SUMMON_MASK_GUARDIAN: + summon = new Guardian(properties, summoner); + team = objmgr.GeneratePetNumber(); + ok = summon->Create(objmgr.GenerateLowGuid(HIGHGUID_PET), this, phase, entry, team); + // this enables pet details window (Shift+P) + summon->GetCharmInfo()->SetPetNumber(team, false); + break; + case SUMMON_MASK_TOTEM: + summon = new Totem(properties, summoner); + ok = summon->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), this, phase, entry, team); + break; + default: + return NULL; + } + if(!ok) + { + delete summon; return NULL; } - if (x == 0.0f && y == 0.0f && z == 0.0f) - GetClosePoint(x, y, z, pCreature->GetObjectSize()); - - pCreature->Relocate(x, y, z, ang); - - if(!pCreature->IsPositionValid()) + summon->Relocate(x, y, z, angle); + if(!summon->IsPositionValid()) { - sLog.outError("ERROR: Creature (guidlow %d, entry %d) not summoned. Suggested coordinates isn't valid (X: %f Y: %f)",pCreature->GetGUIDLow(),pCreature->GetEntry(),pCreature->GetPositionX(),pCreature->GetPositionY()); - delete pCreature; + sLog.outError("ERROR: Creature (guidlow %d, entry %d) not summoned. Suggested coordinates isn't valid (X: %f Y: %f)",summon->GetGUIDLow(),summon->GetEntry(),summon->GetPositionX(),summon->GetPositionY()); + delete summon; return NULL; } + summon->InitSummon(duration); + + Add((Creature*)summon); + + return summon; +} + +TempSummon* WorldObject::SummonCreature(uint32 entry, float x, float y, float z, float ang, TempSummonType spwtype, uint32 duration) +{ + if(!IsInWorld()) + return NULL; + + if (x == 0.0f && y == 0.0f && z == 0.0f) + GetClosePoint(x, y, z, GetObjectSize()); + + TempSummon *pCreature = GetMap()->SummonCreature(entry, x, y, z, ang, NULL, duration, GetTypeId() == TYPEID_UNIT ? (Unit*)this : NULL); + if(!pCreature) + return NULL; + pCreature->SetHomePosition(x, y, z, ang); - pCreature->Summon(spwtype, despwtime); + pCreature->InitSummon(duration); + pCreature->SetTempSummonType(spwtype); if(GetTypeId()==TYPEID_UNIT && ((Creature*)this)->IsAIEnabled) ((Creature*)this)->AI()->JustSummoned(pCreature); @@ -1617,7 +1672,6 @@ TempSummon* WorldObject::SummonCreature(uint32 id, float x, float y, float z, fl pCreature->CastSpell(pCreature, pCreature->m_spells[0], false, 0, 0, GetGUID()); } - //return the creature therewith the summoner has access to it return pCreature; } @@ -1727,7 +1781,6 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy switch(petType) { - case GUARDIAN_PET: case POSSESSED_PET: pet->SetUInt32Value(UNIT_FIELD_FLAGS,0); AddGuardian(pet); |