Skip to content

Commit

Permalink
Spell: Implement all tbc required SummonPropFlags and add wotlk enum
Browse files Browse the repository at this point in the history
  • Loading branch information
killerwife committed Jan 11, 2022
1 parent d2e5d16 commit ff6a55e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 24 deletions.
32 changes: 17 additions & 15 deletions src/game/Server/DBCEnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -457,21 +457,23 @@ enum UnitNameSummonTitle
// SummonProperties.dbc, col 5 == Flags (m_flags)
enum SummonPropFlags
{
SUMMON_PROP_FLAG_NONE = 0x0000, // 1342 spells in 3.0.3
SUMMON_PROP_FLAG_UNK1 = 0x0001, // 75 spells in 3.0.3, something unfriendly
SUMMON_PROP_FLAG_UNK2 = 0x0002, // 616 spells in 3.0.3, something friendly
SUMMON_PROP_FLAG_UNK3 = 0x0004, // 22 spells in 3.0.3, no idea...
SUMMON_PROP_FLAG_UNK4 = 0x0008, // 49 spells in 3.0.3, some mounts
SUMMON_PROP_FLAG_UNK5 = 0x0010, // 25 spells in 3.0.3, quest related?
SUMMON_PROP_FLAG_CANT_BE_DISMISSED = 0x0020, // 0 spells in 3.0.3, unused
SUMMON_PROP_FLAG_UNK7 = 0x0040, // 12 spells in 3.0.3, no idea
SUMMON_PROP_FLAG_UNK8 = 0x0080, // 4 spells in 3.0.3, no idea
SUMMON_PROP_FLAG_UNK9 = 0x0100, // 51 spells in 3.0.3, no idea, many quest related
SUMMON_PROP_FLAG_INHERIT_FACTION = 0x0200, // 51 spells in 3.0.3, something defensive (Faction inheriting is much guesswork)
SUMMON_PROP_FLAG_UNK11 = 0x0400, // 3 spells, requires something near?
SUMMON_PROP_FLAG_UNK12 = 0x0800, // 30 spells in 3.0.3, no idea
SUMMON_PROP_FLAG_UNK13 = 0x1000, // 8 spells in 3.0.3, siege vehicle
SUMMON_PROP_FLAG_UNK14 = 0x2000, // 2 spells in 3.0.3, escort?
SUMMON_PROP_FLAG_NONE = 0x0000,
SUMMON_PROP_FLAG_ATTACK_SUMMONER = 0x0001,
SUMMON_PROP_FLAG_HELP_WHEN_SUMMONED_IN_COMBAT = 0x0002,
SUMMON_PROP_FLAG_USE_LEVEL_OFFSET = 0x0004, // Implemented differently in tbc core
SUMMON_PROP_FLAG_DESPAWN_ON_SUMMONER_DEATH = 0x0008, // NYI
SUMMON_PROP_FLAG_ONLY_VISIBLE_TO_SUMMONER = 0x0010, // NYI
SUMMON_PROP_FLAG_CANNOT_DISMISS_PET = 0x0020, // NYI
SUMMON_PROP_FLAG_USE_DEMON_TIMEOUT = 0x0040, // NYI
SUMMON_PROP_FLAG_UNLIMITED_SUMMONS = 0x0080, // NYI
SUMMON_PROP_FLAG_USE_CREATURE_LEVEL = 0x0100, // NYI
SUMMON_PROP_FLAG_JOIN_SUMMONERS_SPAWN_GROUP = 0x0200, // NYI
SUMMON_PROP_FLAG_DO_NOT_TOGGLE = 0x0400, // NYI
SUMMON_PROP_FLAG_DESPAWN_WHEN_EXPIRED = 0x0800, // NYI
SUMMON_PROP_FLAG_USE_SUMMONER_FACTION = 0x1000,
SUMMON_PROP_FLAG_DO_NOT_FOLLOW_MOUNTED_SUMMONER = 0x2000, // NYI
SUMMON_PROP_FLAG_SAVE_PET_AUTOCAST = 0x4000, // NYI
SUMMON_PROP_FLAG_IGNORE_SUMMONERS_PHASE = 0x8000, // NYI Wild Only
};

enum SpellEffectIndex
Expand Down
28 changes: 19 additions & 9 deletions src/game/Spells/SpellEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6293,24 +6293,25 @@ void Spell::EffectSummonType(SpellEffectIndex eff_idx)

for (itr = summonPositions.begin(); itr != summonPositions.end(); ++itr)
{
MANGOS_ASSERT(itr->creature || itr != summonPositions.begin());
if (!itr->creature)
Creature* creature = itr->creature;
MANGOS_ASSERT(creature || itr != summonPositions.begin());
if (!creature)
{
sLog.outError("EffectSummonType: Expected to have %u NPCs summoned, but some failed (Spell id %u)", amount, m_spellInfo->Id);
continue;
}

if (summon_prop->FactionId)
itr->creature->setFaction(summon_prop->FactionId);
creature->setFaction(summon_prop->FactionId);
// Else set faction to summoner's faction for pet-like summoned
else if ((summon_prop->Flags & SUMMON_PROP_FLAG_INHERIT_FACTION) || !itr->creature->IsTemporarySummon())
itr->creature->setFaction(petInvoker->GetFaction());
else if ((summon_prop->Flags & SUMMON_PROP_FLAG_USE_SUMMONER_FACTION) || !creature->IsTemporarySummon())
creature->setFaction(petInvoker->GetFaction());

if (!itr->creature->IsTemporarySummon())
if (!creature->IsTemporarySummon())
{
m_trueCaster->GetMap()->Add(itr->creature);

itr->creature->AIM_Initialize();
creature->AIM_Initialize();

// Notify original caster if not done already
if (caster && caster->AI())
Expand All @@ -6322,8 +6323,17 @@ void Spell::EffectSummonType(SpellEffectIndex eff_idx)
m_originalCaster->AI()->JustSummoned(itr->creature);
}

OnSummon(itr->creature);
m_spellLog.AddLog(uint32(SPELL_EFFECT_SUMMON), itr->creature->GetPackGUID());
OnSummon(creature);

m_spellLog.AddLog(uint32(SPELL_EFFECT_SUMMON), creature->GetPackGUID());

if (summon_prop->Flags & SUMMON_PROP_FLAG_ATTACK_SUMMONER && m_caster)
if (m_caster->CanEnterCombat() && creature->CanEnterCombat() && creature->CanAttack(m_caster))
creature->AI()->AttackStart(m_caster);

if (summon_prop->Flags & SUMMON_PROP_FLAG_HELP_WHEN_SUMMONED_IN_COMBAT && m_caster)
if (m_caster->CanEnterCombat() && creature->CanEnterCombat() && creature->CanAssist(m_caster) && m_caster->GetVictim())
creature->AI()->AttackStart(m_caster->GetVictim()); // maybe needs to help with everything around not just main target
}
}

Expand Down

0 comments on commit ff6a55e

Please sign in to comment.