*Allow spells to summon vehicles.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-03-18 21:39:09 -06:00
parent 886b2a51e9
commit 281d20be0d
6 changed files with 79 additions and 13 deletions
+37
View File
@@ -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);
+4 -2
View File
@@ -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);
+15 -3
View File
@@ -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?
+1
View File
@@ -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);
+15
View File
@@ -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 ||
+7 -8
View File
@@ -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;
}
}
}
}