*Do not consider possessed creatures as pet. Also fix the bug that possessed creature does not display spells.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-05-25 22:52:08 -05:00
parent 320ac7f91e
commit d971d0121f
11 changed files with 86 additions and 56 deletions
+1
View File
@@ -161,6 +161,7 @@ enum SummonMask
SUMMON_MASK_TOTEM = 0x00000008,
SUMMON_MASK_PET = 0x00000010,
SUMMON_MASK_VEHICLE = 0x00000020,
SUMMON_MASK_PUPPET = 0x00000040,
};
// GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push,N), also any gcc version not support it at some platform
+3 -6
View File
@@ -1768,6 +1768,8 @@ TempSummon *Map::SummonCreature(uint32 entry, float x, float y, float z, float a
|| properties->Type == SUMMON_TYPE_VEHICLE
|| properties->Type == SUMMON_TYPE_VEHICLE2)
mask = SUMMON_MASK_VEHICLE;
else if(properties->Category == SUMMON_CATEGORY_PUPPET)
mask = SUMMON_MASK_PUPPET;
else if(properties->Type == SUMMON_TYPE_MINIPET)
mask = SUMMON_MASK_MINION;
}
@@ -1785,6 +1787,7 @@ TempSummon *Map::SummonCreature(uint32 entry, float x, float y, float z, float a
{
case SUMMON_MASK_SUMMON: summon = new TempSummon (properties, summoner); break;
case SUMMON_MASK_GUARDIAN: summon = new Guardian (properties, summoner); break;
case SUMMON_MASK_PUPPET: summon = new Puppet (properties, summoner); break;
case SUMMON_MASK_TOTEM: summon = new Totem (properties, summoner); break;
case SUMMON_MASK_MINION: summon = new Minion (properties, summoner); break;
default: return NULL;
@@ -1934,9 +1937,6 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy
switch(petType)
{
case POSSESSED_PET:
pet->SetUInt32Value(UNIT_FIELD_FLAGS, 0);
break;
case SUMMON_PET:
// this enables pet details window (Shift+P)
pet->GetCharmInfo()->SetPetNumber(pet_number, true);
@@ -1953,9 +1953,6 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy
switch(petType)
{
case POSSESSED_PET:
pet->SetCharmedOrPossessedBy(this, true);
break;
case SUMMON_PET:
pet->InitPetCreateSpells();
pet->InitTalentForLevel();
-3
View File
@@ -51,9 +51,6 @@ m_declinedname(NULL), m_owner(owner)
m_regenTimer = 4000;
owner->SetPetAtLoginFlag(0);
if(type == POSSESSED_PET) // always passive
SetReactState(REACT_PASSIVE);
}
Pet::~Pet()
-1
View File
@@ -29,7 +29,6 @@ enum PetType
{
SUMMON_PET = 0,
HUNTER_PET = 1,
POSSESSED_PET = 2,
MAX_PET_TYPE = 4,
};
+3 -11
View File
@@ -16643,15 +16643,7 @@ void Player::RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent)
}
// only if current pet in slot
switch(pet->getPetType())
{
case POSSESSED_PET:
pet->RemoveCharmedOrPossessedBy(NULL);
break;
default:
pet->SavePetToDB(mode);
break;
}
pet->SavePetToDB(mode);
SetMinion(pet, false);
@@ -16681,8 +16673,8 @@ void Player::StopCastingCharm()
if(charm->GetTypeId() == TYPEID_UNIT)
{
if(((Creature*)charm)->isPet() && ((Pet*)charm)->getPetType() == POSSESSED_PET)
((Pet*)charm)->Remove(PET_SAVE_AS_DELETED);
if(((Creature*)charm)->HasSummonMask(SUMMON_MASK_PUPPET))
((Puppet*)charm)->UnSummon();
}
if(GetCharmGUID())
{
+1 -1
View File
@@ -2405,7 +2405,7 @@ enum SummonCategory
SUMMON_CATEGORY_WILD = 0,
SUMMON_CATEGORY_ALLY = 1,
SUMMON_CATEGORY_PET = 2,
SUMMON_CATEGORY_POSSESSED = 3,
SUMMON_CATEGORY_PUPPET = 3,
SUMMON_CATEGORY_VEHICLE = 4,
};
+6 -16
View File
@@ -2985,21 +2985,11 @@ void Spell::finish(bool ok)
// Unsummon summon as possessed creatures on spell cancel
if(IsChanneledSpell(m_spellInfo) && m_caster->GetTypeId() == TYPEID_PLAYER)
{
if (Unit * charm = m_caster->GetCharm())
for(int i = 0; i < 3; ++i)
{
if(m_spellInfo->Effect[i] == SPELL_EFFECT_SUMMON)
if(SummonPropertiesEntry const *SummonProperties = sSummonPropertiesStore.LookupEntry(m_spellInfo->EffectMiscValueB[i]))
if(SummonProperties->Category == SUMMON_CATEGORY_POSSESSED)
{
if(charm->GetTypeId() == TYPEID_UNIT)
{
if(((Creature*)charm)->isPet() && ((Pet*)charm)->getPetType() == POSSESSED_PET)
((Pet*)charm)->Remove(PET_SAVE_AS_DELETED);
break;
}
}
}
if(Unit *charm = m_caster->GetCharm())
if(charm->GetTypeId() == TYPEID_UNIT
&& ((Creature*)charm)->HasSummonMask(SUMMON_MASK_PUPPET)
&& charm->GetUInt32Value(UNIT_CREATED_BY_SPELL) == m_spellInfo->Id)
((Puppet*)charm)->UnSummon();
}
// other code related only to successfully finished spells
@@ -4544,7 +4534,7 @@ SpellCastResult Spell::CheckCast(bool strict)
case SUMMON_CATEGORY_PET:
if(m_caster->GetPetGUID())
return SPELL_FAILED_ALREADY_HAVE_SUMMON;
case SUMMON_CATEGORY_POSSESSED:
case SUMMON_CATEGORY_PUPPET:
if(m_caster->GetCharmGUID())
return SPELL_FAILED_ALREADY_HAVE_CHARM;
break;
+17 -16
View File
@@ -3367,23 +3367,9 @@ void Spell::EffectSummonType(uint32 i)
case SUMMON_CATEGORY_PET:
SummonGuardian(entry, properties);
break;
case SUMMON_CATEGORY_POSSESSED:
{
if(m_caster->GetTypeId() != TYPEID_PLAYER)
return;
float x, y, z;
m_caster->GetClosePoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE);
int32 duration = GetSpellDuration(m_spellInfo);
Pet* pet = ((Player*)m_caster)->SummonPet(entry, x, y, z, m_caster->GetOrientation(), POSSESSED_PET, duration);
if(!pet)
return;
pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id);
case SUMMON_CATEGORY_PUPPET:
summon = m_caster->GetMap()->SummonCreature(entry, x, y, z, m_caster->GetOrientation(), properties, duration, m_originalCaster);
break;
}
case SUMMON_CATEGORY_VEHICLE:
{
float x, y, z;
@@ -4877,6 +4863,21 @@ void Spell::EffectScriptEffect(uint32 effIndex)
m_originalCaster->CastSpell(m_originalCaster, damage, false);
break;
}
// Summon Ghouls On Scarlet Crusade
case 51904:
{
if(!m_targets.HasDst())
return;
float x, y, z;
float radius = GetSpellRadius(m_spellInfo, effIndex, true);
for(uint32 i = 0; i < 15; ++i)
{
m_caster->GetRandomPoint(m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, radius, x, y, z);
m_caster->CastSpell(x, y, z, 54522, true);
}
break;
}
// Death Gate
case 52751:
{
+40
View File
@@ -314,3 +314,43 @@ void Guardian::InitStats(uint32 duration)
SetReactState(REACT_AGGRESSIVE);
}
Puppet::Puppet(SummonPropertiesEntry const *properties, Unit *owner) : Minion(properties, owner)
{
assert(owner->GetTypeId() == TYPEID_PLAYER);
m_owner = (Player*)owner;
m_summonMask |= SUMMON_MASK_PUPPET;
InitCharmInfo();
}
void Puppet::InitStats(uint32 duration)
{
Minion::InitStats(duration);
m_charmInfo->InitPossessCreateSpells();
SetReactState(REACT_PASSIVE);
}
void Puppet::InitSummon()
{
Minion::InitSummon();
SetCharmedOrPossessedBy(m_owner, true);
}
void Puppet::Update(uint32 time)
{
Minion::Update(time);
//check if caster is channelling?
if(IsInWorld())
{
}
}
void Puppet::RemoveFromWorld()
{
if(!IsInWorld())
return;
RemoveCharmedOrPossessedBy(NULL);
Minion::RemoveFromWorld();
}
+12
View File
@@ -71,5 +71,17 @@ class Guardian : public Minion
int32 m_bonusdamage;
};
class Puppet : public Minion
{
public:
Puppet(SummonPropertiesEntry const *properties, Unit *owner);
void InitStats(uint32 duration);
void InitSummon();
void Update(uint32 time);
void RemoveFromWorld();
protected:
Player *m_owner;
};
#endif
+3 -2
View File
@@ -8341,7 +8341,7 @@ void Unit::SetMinion(Minion *minion, bool apply)
}
}
//if(minion->HasSummonMask(SUMMON_MASK_GUARDIAN))
if(minion->HasSummonMask(SUMMON_MASK_GUARDIAN))
{
if(AddUInt64Value(UNIT_FIELD_SUMMON, minion->GetGUID()))
{
@@ -8470,7 +8470,8 @@ void Unit::SetCharm(Unit* charm, bool apply)
if(!charm->RemoveUInt64Value(UNIT_FIELD_CHARMEDBY, GetGUID()))
sLog.outCrash("Unit %u is being uncharmed, but it has another charmer %u", charm->GetEntry(), charm->GetCharmerGUID());
m_Controlled.erase(charm);
if(!charm->GetOwnerGUID() == GetGUID())
m_Controlled.erase(charm);
}
}