diff options
author | megamage <none@none> | 2009-03-18 21:39:09 -0600 |
---|---|---|
committer | megamage <none@none> | 2009-03-18 21:39:09 -0600 |
commit | 281d20be0d1c342f01798b1254fccb3b5a202bcd (patch) | |
tree | f2edf7a2f81a625d72f4beacb4523747ee004aad /src | |
parent | 886b2a51e9f3fdbb8f6353e47701be825f8cf4b3 (diff) |
*Allow spells to summon vehicles.
--HG--
branch : trunk
Diffstat (limited to 'src')
-rw-r--r-- | src/game/Object.cpp | 37 | ||||
-rw-r--r-- | src/game/Object.h | 6 | ||||
-rw-r--r-- | src/game/Spell.cpp | 18 | ||||
-rw-r--r-- | src/game/Spell.h | 1 | ||||
-rw-r--r-- | src/game/SpellEffects.cpp | 15 | ||||
-rw-r--r-- | src/game/Unit.cpp | 15 |
6 files changed, 79 insertions, 13 deletions
diff --git a/src/game/Object.cpp b/src/game/Object.cpp index 08615ba3679..a8dff0b73ab 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -1621,6 +1621,43 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa return pCreature; } +Vehicle* WorldObject::SummonVehicle(uint32 entry, float x, float y, float z, float ang) +{ + CreatureInfo const *ci = objmgr.GetCreatureTemplate(entry); + if(!ci) + return false; + + uint32 id = ci->spells[7]; //temp store id here + VehicleEntry const *ve = sVehicleStore.LookupEntry(id); + if(!ve) + return false; + + Vehicle *v = new Vehicle; + Map *map = GetMap(); + uint32 team = 0; + if (GetTypeId()==TYPEID_PLAYER) + team = ((Player*)this)->GetTeam(); + if(!v->Create(objmgr.GenerateLowGuid(HIGHGUID_VEHICLE), map, entry, id, team)) + { + delete v; + return NULL; + } + + v->Relocate(x, y, z, ang); + + if(!v->IsPositionValid()) + { + sLog.outError("ERROR: Vehicle (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)", + v->GetGUIDLow(), v->GetEntry(), v->GetPositionX(), v->GetPositionY()); + delete v; + return NULL; + } + + map->Add((Creature*)v); + + return v; +} + Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetType petType, uint32 duration) { Pet* pet = new Pet(petType); diff --git a/src/game/Object.h b/src/game/Object.h index a8017d3883d..7ae42ea3a70 100644 --- a/src/game/Object.h +++ b/src/game/Object.h @@ -104,6 +104,7 @@ class Player; class UpdateMask; class InstanceData; class GameObject; +class Vehicle; typedef UNORDERED_MAP<Player*, UpdateData> UpdateDataMapType; @@ -498,9 +499,10 @@ class TRINITY_DLL_SPEC WorldObject : public Object Map * GetMap() const; Map const* GetBaseMap() const; - Creature* SummonCreature(uint32 id, float x, float y, float z, float ang,TempSummonType spwtype,uint32 despwtime); + Creature* SummonCreature(uint32 id, float x, float y, float z, float ang,TempSummonType spwtype,uint32 despwtime); + Vehicle* SummonVehicle(uint32 entry, float x, float y, float z, float ang); GameObject* SummonGameObject(uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime); - Creature* SummonTrigger(float x, float y, float z, float ang, uint32 dur, CreatureAI* (*GetAI)(Creature*) = NULL); + Creature* SummonTrigger(float x, float y, float z, float ang, uint32 dur, CreatureAI* (*GetAI)(Creature*) = NULL); bool isActiveObject() const { return m_isActive; } void setActive(bool isActiveObject); void SetWorldObject(bool apply); diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index f352a9571d2..3dd11e105c3 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -4158,9 +4158,6 @@ SpellCastResult Spell::CheckCast(bool strict) { switch(m_spellInfo->EffectMiscValueB[i]) { - case SUMMON_TYPE_POSESSED: - case SUMMON_TYPE_RACE_CONTROLLER: - case SUMMON_TYPE_STEAM_TONK: case SUMMON_TYPE_DEMON: case SUMMON_TYPE_SUMMON: { @@ -4172,6 +4169,21 @@ SpellCastResult Spell::CheckCast(bool strict) break; } } + SummonPropertiesEntry const *SummonProperties = sSummonPropertiesStore.LookupEntry(m_spellInfo->EffectMiscValueB[i]); + if(!SummonProperties) + break; + switch(SummonProperties->Group) + { + case SUMMON_TYPE_POSSESSED: + { + if(m_caster->GetPetGUID()) + return SPELL_FAILED_ALREADY_HAVE_SUMMON; + + if(m_caster->GetCharmGUID()) + return SPELL_FAILED_ALREADY_HAVE_CHARM; + break; + } + } break; } // Not used for summon? diff --git a/src/game/Spell.h b/src/game/Spell.h index 66b98e7d566..ac7106eaa62 100644 --- a/src/game/Spell.h +++ b/src/game/Spell.h @@ -277,6 +277,7 @@ class Spell void EffectPickPocket(uint32 i); void EffectAddFarsight(uint32 i); void EffectSummonPossessed(uint32 i); + void EffectSummonVehicle(uint32 i); void EffectSummonWild(uint32 i); void EffectSummonGuardian(uint32 i); void EffectHealMechanical(uint32 i); diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index ee0ca2784b4..4c717ba924c 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -60,6 +60,7 @@ #include "GridNotifiersImpl.h" #include "SkillDiscovery.h" #include "Formulas.h" +#include "Vehicle.h" pEffect SpellEffects[TOTAL_SPELL_EFFECTS]= { @@ -3366,6 +3367,7 @@ void Spell::EffectSummonType(uint32 i) EffectSummonPossessed(i); break; case SUMMON_TYPE_VEHICLE: + EffectSummonVehicle(i); break; } break; @@ -6776,6 +6778,19 @@ void Spell::EffectSummonPossessed(uint32 i) pet->SetCharmedOrPossessedBy(m_caster, true); } +void Spell::EffectSummonVehicle(uint32 i) +{ + uint32 entry = m_spellInfo->EffectMiscValue[i]; + if(!entry) + return; + + float x, y, z; + m_caster->GetClosePoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE); + Vehicle *vehicle = m_caster->SummonVehicle(entry, x, y, z, m_caster->GetOrientation()); + + vehicle->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id); +} + void Spell::EffectRenamePet(uint32 /*eff_idx*/) { if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT || diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 25370e0f02f..80fee50f19c 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -4379,14 +4379,13 @@ void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode) { for(int i = 0; i < 3; ++i) { - if(AurSpellInfo->Effect[i] == SPELL_EFFECT_SUMMON && - (AurSpellInfo->EffectMiscValueB[i] == SUMMON_TYPE_POSESSED || - AurSpellInfo->EffectMiscValueB[i] == SUMMON_TYPE_RACE_CONTROLLER || - AurSpellInfo->EffectMiscValueB[i] == SUMMON_TYPE_STEAM_TONK)) - { - ((Player*)caster)->StopCastingCharm(); - break; - } + if(AurSpellInfo->Effect[i] == SPELL_EFFECT_SUMMON) + if(SummonPropertiesEntry const *SummonProperties = sSummonPropertiesStore.LookupEntry(AurSpellInfo->EffectMiscValueB[i])) + if(SummonProperties->Group == SUMMON_TYPE_POSSESSED) + { + ((Player*)caster)->StopCastingCharm(); + break; + } } } } |