From 161b18b7603ac4d91deaf93149a91b2039d80366 Mon Sep 17 00:00:00 2001 From: GriffonHeart Date: Mon, 16 Jul 2012 17:18:44 +0200 Subject: [PATCH] [12048] Implement SummonPossessed Version slightly derived from GriffonHeart's version. --- src/game/SharedDefines.h | 2 +- src/game/Spell.h | 1 + src/game/SpellEffects.cpp | 64 +++++++++++++++++++++++++++++++++++++-- src/game/Unit.h | 8 +++-- src/shared/revision_nr.h | 2 +- 5 files changed, 69 insertions(+), 8 deletions(-) diff --git a/src/game/SharedDefines.h b/src/game/SharedDefines.h index 878b8a2c8..d9b9c4adc 100644 --- a/src/game/SharedDefines.h +++ b/src/game/SharedDefines.h @@ -281,7 +281,7 @@ enum SpellAttributesEx SPELL_ATTR_EX_NO_THREAT = 0x00000400, // 10 no generates threat on cast 100% SPELL_ATTR_EX_UNK11 = 0x00000800, // 11 SPELL_ATTR_EX_UNK12 = 0x00001000, // 12 - SPELL_ATTR_EX_UNK13 = 0x00002000, // 13 + SPELL_ATTR_EX_FARSIGHT = 0x00002000, // 13 related to farsight SPELL_ATTR_EX_UNK14 = 0x00004000, // 14 SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY = 0x00008000, // 15 remove auras on immunity SPELL_ATTR_EX_UNAFFECTED_BY_SCHOOL_IMMUNE = 0x00010000, // 16 unaffected by school immunity diff --git a/src/game/Spell.h b/src/game/Spell.h index b1cca52bc..afd8a3513 100644 --- a/src/game/Spell.h +++ b/src/game/Spell.h @@ -664,6 +664,7 @@ class Spell bool DoSummonWild(CreatureSummonPositions& list, SummonPropertiesEntry const* prop, SpellEffectIndex effIdx, uint32 level); bool DoSummonCritter(CreatureSummonPositions& list, SummonPropertiesEntry const* prop, SpellEffectIndex effIdx, uint32 level); bool DoSummonGuardian(CreatureSummonPositions& list, SummonPropertiesEntry const* prop, SpellEffectIndex effIdx, uint32 level); + bool DoSummonPossessed(CreatureSummonPositions& list, SummonPropertiesEntry const* prop, SpellEffectIndex effIdx, uint32 level); }; enum ReplenishType diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index f42b80a4e..6d650e6ef 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -4911,9 +4911,9 @@ void Spell::EffectSummonType(SpellEffectIndex eff_idx) } case SUMMON_PROP_GROUP_CONTROLLABLE: { - // no type here - // maybe wrong - but thats the handler currently used for those - summonResult = DoSummonGuardian(summonPositions, summon_prop, eff_idx, level); + // TODO: Fix spell 46619 + if (m_spellInfo->Id != 46619) + summonResult = DoSummonPossessed(summonPositions, summon_prop, eff_idx, level); break; } case SUMMON_PROP_GROUP_VEHICLE: @@ -5208,6 +5208,64 @@ bool Spell::DoSummonTotem(SpellEffectIndex eff_idx, uint8 slot_dbc) return false; } +bool Spell::DoSummonPossessed(CreatureSummonPositions& list, SummonPropertiesEntry const* prop, SpellEffectIndex effIdx, uint32 level) +{ + MANGOS_ASSERT(!list.empty() && prop); + + uint32 creatureEntry = m_spellInfo->EffectMiscValue[effIdx]; + CreatureInfo const* cInfo = sCreatureStorage.LookupEntry(creatureEntry); + if (!cInfo) + { + sLog.outErrorDb("Spell::DoSummonPossessed: creature entry %u not found for spell %u.", creatureEntry, m_spellInfo->Id); + return false; + } + + Creature* spawnCreature = m_caster->SummonCreature(creatureEntry, list[0].x, list[0].y, list[0].z, m_caster->GetOrientation(), TEMPSUMMON_CORPSE_DESPAWN, 0); + if (!spawnCreature) + { + sLog.outError("Spell::DoSummonPossessed: creature entry %u for spell %u could not be summoned.", creatureEntry, m_spellInfo->Id); + return false; + } + + list[0].creature = spawnCreature; + + // Changes to be sent + spawnCreature->SetCharmerGuid(m_caster->GetObjectGuid()); + spawnCreature->SetCreatorGuid(m_caster->GetObjectGuid()); + spawnCreature->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id); + spawnCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED); + + spawnCreature->SetLevel(level); + + spawnCreature->SetWalk(m_caster->IsWalking()); + // TODO: Set Fly (ie glyph dependend) + + // Internal changes + spawnCreature->addUnitState(UNIT_STAT_CONTROLLED); + + // Changes to owner + if (m_caster->GetTypeId() == TYPEID_PLAYER) + { + Player* player = (Player*)m_caster; + + player->GetCamera().SetView(spawnCreature); + + player->SetCharm(spawnCreature); + player->SetClientControl(spawnCreature, 1); + player->SetMover(spawnCreature); + + if (CharmInfo* charmInfo = spawnCreature->InitCharmInfo(spawnCreature)) + charmInfo->InitPossessCreateSpells(); + player->PossessSpellInitialize(); + } + + // Notify Summoner + if (m_originalCaster && m_originalCaster != m_caster && m_originalCaster->GetTypeId() == TYPEID_UNIT && ((Creature*)m_originalCaster)->AI()) + ((Creature*)m_originalCaster)->AI()->JustSummoned(spawnCreature); + + return true; +} + bool Spell::DoSummonPet(SpellEffectIndex eff_idx) { if (m_caster->GetPetGuid()) diff --git a/src/game/Unit.h b/src/game/Unit.h index d915714a2..717431856 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -147,6 +147,9 @@ enum UnitStandStateType #define MAX_UNIT_STAND_STATE 10 +// byte flags value (UNIT_FIELD_BYTES_1,1) +// This corresponds to free talent points (pet case) + // byte flags value (UNIT_FIELD_BYTES_1,2) enum UnitStandFlags { @@ -158,9 +161,6 @@ enum UnitStandFlags UNIT_STAND_FLAGS_ALL = 0xFF }; -// byte flags value (UNIT_FIELD_BYTES_1,2) -// This corresponds to free talent points (pet case) - // byte flags value (UNIT_FIELD_BYTES_1,3) enum UnitBytes1_Flags { @@ -200,6 +200,8 @@ enum UnitRename UNIT_CAN_BE_ABANDONED = 0x02, }; +// byte flags value (UNIT_FIELD_BYTES_2,3) See enum ShapeshiftForm in SharedDefines.h + #define CREATURE_MAX_SPELLS 4 enum Swing diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index ce96f0c67..77a4ab984 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "12047" + #define REVISION_NR "12048" #endif // __REVISION_NR_H__