mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 01:37:00 +00:00
[12693] Improvements for NPC summoning code
* Inherit faction for guardians and similar - this will prevent a bunch of pet faction related error messages * Inherit level from responsible caster and not only caster * Improve default position selection for summon spells for GO-casts \n (original author @Schmoozerd)
This commit is contained in:
parent
edd057033a
commit
c51359a547
2 changed files with 24 additions and 9 deletions
|
|
@ -5029,8 +5029,20 @@ void Spell::EffectSummonType(SpellEffectEntry const* effect)
|
||||||
if (summon_prop->Group == SUMMON_PROP_GROUP_VEHICLE)
|
if (summon_prop->Group == SUMMON_PROP_GROUP_VEHICLE)
|
||||||
amount = 1;
|
amount = 1;
|
||||||
|
|
||||||
|
// Get casting object
|
||||||
|
WorldObject* realCaster = GetCastingObject();
|
||||||
|
if (!realCaster)
|
||||||
|
{
|
||||||
|
sLog.outError("EffectSummonType: No Casting Object found for spell %u, (caster = %s)", m_spellInfo->Id, m_caster->GetGuidStr().c_str());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Unit* responsibleCaster = m_originalCaster;
|
||||||
|
if (realCaster->GetTypeId() == TYPEID_GAMEOBJECT)
|
||||||
|
responsibleCaster = ((GameObject*)realCaster)->GetOwner();
|
||||||
|
|
||||||
// Expected Level (Totem, Pet and Critter may not use this)
|
// Expected Level (Totem, Pet and Critter may not use this)
|
||||||
uint32 level = m_caster->getLevel();
|
uint32 level = responsibleCaster ? responsibleCaster->getLevel() : m_caster->getLevel();
|
||||||
// level of creature summoned using engineering item based at engineering skill level
|
// level of creature summoned using engineering item based at engineering skill level
|
||||||
if (m_caster->GetTypeId() == TYPEID_PLAYER && m_CastItem)
|
if (m_caster->GetTypeId() == TYPEID_PLAYER && m_CastItem)
|
||||||
{
|
{
|
||||||
|
|
@ -5051,7 +5063,7 @@ void Spell::EffectSummonType(SpellEffectEntry const* effect)
|
||||||
m_targets.getDestination(summonPositions[0].x, summonPositions[0].y, summonPositions[0].z);
|
m_targets.getDestination(summonPositions[0].x, summonPositions[0].y, summonPositions[0].z);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_caster->GetPosition(summonPositions[0].x, summonPositions[0].y, summonPositions[0].z);
|
realCaster->GetPosition(summonPositions[0].x, summonPositions[0].y, summonPositions[0].z);
|
||||||
|
|
||||||
// TODO - Is this really an error?
|
// TODO - Is this really an error?
|
||||||
sLog.outDebug("Spell Effect EFFECT_SUMMON (%u) - summon without destination (spell id %u, effIndex %u)", effect->Effect, m_spellInfo->Id, SpellEffectIndex(effect->EffectIndex));
|
sLog.outDebug("Spell Effect EFFECT_SUMMON (%u) - summon without destination (spell id %u, effIndex %u)", effect->Effect, m_spellInfo->Id, SpellEffectIndex(effect->EffectIndex));
|
||||||
|
|
@ -5064,15 +5076,15 @@ void Spell::EffectSummonType(SpellEffectEntry const* effect)
|
||||||
{
|
{
|
||||||
if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION || radius > 1.0f)
|
if (m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION || radius > 1.0f)
|
||||||
{
|
{
|
||||||
m_caster->GetRandomPoint(summonPositions[0].x, summonPositions[0].y, summonPositions[0].z, radius, itr->x, itr->y, itr->z);
|
realCaster->GetRandomPoint(summonPositions[0].x, summonPositions[0].y, summonPositions[0].z, radius, itr->x, itr->y, itr->z);
|
||||||
if (m_caster->GetMap()->GetHitPosition(summonPositions[0].x, summonPositions[0].y, summonPositions[0].z, itr->x, itr->y, itr->z, m_caster->GetPhaseMask(), -0.5f))
|
if (realCaster->GetMap()->GetHitPosition(summonPositions[0].x, summonPositions[0].y, summonPositions[0].z, itr->x, itr->y, itr->z, m_caster->GetPhaseMask(), -0.5f))
|
||||||
m_caster->UpdateAllowedPositionZ(itr->x, itr->y, itr->z);
|
realCaster->UpdateAllowedPositionZ(itr->x, itr->y, itr->z);
|
||||||
}
|
}
|
||||||
else // Get a point near the caster
|
else // Get a point near the caster
|
||||||
{
|
{
|
||||||
m_caster->GetClosePoint(itr->x, itr->y, itr->z, 0.0f, radius, frand(0.0f, 2 * M_PI_F));
|
realCaster->GetRandomPoint(summonPositions[0].x, summonPositions[0].y, summonPositions[0].z, radius, itr->x, itr->y, itr->z);
|
||||||
if (m_caster->GetMap()->GetHitPosition(summonPositions[0].x, summonPositions[0].y, summonPositions[0].z, itr->x, itr->y, itr->z, m_caster->GetPhaseMask(), -0.5f))
|
if (realCaster->GetMap()->GetHitPosition(summonPositions[0].x, summonPositions[0].y, summonPositions[0].z, itr->x, itr->y, itr->z, m_caster->GetPhaseMask(), -0.5f))
|
||||||
m_caster->UpdateAllowedPositionZ(itr->x, itr->y, itr->z);
|
realCaster->UpdateAllowedPositionZ(itr->x, itr->y, itr->z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -5198,6 +5210,9 @@ void Spell::EffectSummonType(SpellEffectEntry const* effect)
|
||||||
|
|
||||||
if (summon_prop->FactionId)
|
if (summon_prop->FactionId)
|
||||||
itr->creature->setFaction(summon_prop->FactionId);
|
itr->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(responsibleCaster ? responsibleCaster->getFaction() : m_caster->getFaction());
|
||||||
|
|
||||||
if (!itr->creature->IsTemporarySummon())
|
if (!itr->creature->IsTemporarySummon())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "12692"
|
#define REVISION_NR "12693"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue