From 57b8cf02358f1bb5b0d98b8d15af54cad2ce798a Mon Sep 17 00:00:00 2001 From: h0rs Date: Fri, 10 Feb 2017 20:24:17 +0000 Subject: [PATCH] Fix refer a friend Summon --- src/game/Handlers/CharacterHandler.cpp | 20 ++++++++++++++++++++ src/game/Spells/Spell.cpp | 16 ++++++++++++++-- src/game/Spells/SpellEffects.cpp | 10 ++++++++-- 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/src/game/Handlers/CharacterHandler.cpp b/src/game/Handlers/CharacterHandler.cpp index 146840095..08e301742 100644 --- a/src/game/Handlers/CharacterHandler.cpp +++ b/src/game/Handlers/CharacterHandler.cpp @@ -1136,6 +1136,26 @@ void WorldSession::HandlePlayerLoginFromDB(LoginQueryHolder* holder) // Load pet if any (if player not alive and in taxi flight or another then pet will remember as temporary unsummoned) pCurrChar->LoadPet(); + if (pCurrChar->GetSession()->GetRecruiterId() != 0 || pCurrChar->GetSession()->IsARecruiter()) + { + bool isReferrer = pCurrChar->GetSession()->IsARecruiter(); + + for (SessionMap::const_iterator itr = sWorld->GetAllSessions().begin(); itr != sWorld->GetAllSessions().end(); ++itr) + { + if (!itr->second->GetRecruiterId() && !itr->second->IsARecruiter()) + continue; + if (isReferrer && pCurrChar->GetSession()->GetAccountId() == itr->second->GetRecruiterId() || !isReferrer && pCurrChar->GetSession()->GetRecruiterId() == itr->second->GetAccountId()) + { + Player * rf = itr->second->GetPlayer(); + if (rf != NULL) + { + pCurrChar->SendUpdateToPlayer(rf); + rf->SendUpdateToPlayer(pCurrChar); + } + } + } + } + sScriptMgr->OnPlayerLogin(pCurrChar); delete holder; } diff --git a/src/game/Spells/Spell.cpp b/src/game/Spells/Spell.cpp index 9dd72c442..ccc8b2874 100644 --- a/src/game/Spells/Spell.cpp +++ b/src/game/Spells/Spell.cpp @@ -2286,7 +2286,7 @@ void Spell::DoAllEffectOnTarget(TargetInfo* target) uint8 mask = target->effectMask; Unit* effectUnit = m_caster->GetGUID() == target->targetGUID ? m_caster : ObjectAccessor::GetUnit(*m_caster, target->targetGUID); - if (!effectUnit) + if (!effectUnit || m_spellInfo->Id == 45927) { uint8 farMask = 0; // create far target mask @@ -5745,7 +5745,7 @@ SpellCastResult Spell::CheckCast(bool strict) if (!(playerCaster->GetTarget())) return SPELL_FAILED_BAD_TARGETS; - Player* target = playerCaster->GetSelectedPlayer(); + Player* target = ObjectAccessor::FindPlayer(m_caster->ToPlayer()->GetTarget()); if (!target || !(target->GetSession()->GetRecruiterId() == playerCaster->GetSession()->GetAccountId() || target->GetSession()->GetAccountId() == playerCaster->GetSession()->GetRecruiterId())) @@ -7160,6 +7160,18 @@ bool Spell::CheckEffectTarget(Unit const* target, uint32 eff) const if (MMAP::MMapFactory::IsPathfindingEnabled(m_caster->FindMap())) break;*/ // else no break intended + + case SPELL_EFFECT_SUMMON_RAF_FRIEND: + if (m_caster->GetTypeId() != TYPEID_PLAYER || target->GetTypeId() != TYPEID_PLAYER) + return false; + if (m_caster->ToPlayer()->GetSession()->IsARecruiter() && target->ToPlayer()->GetSession()->GetRecruiterId() != m_caster->ToPlayer()->GetSession()->GetAccountId()) + return false; + if (m_caster->ToPlayer()->GetSession()->GetRecruiterId() != target->ToPlayer()->GetSession()->GetAccountId() && target->ToPlayer()->GetSession()->IsARecruiter()) + return false; + if (target->ToPlayer()->getLevel() >= sWorld->getIntConfig(CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL)) + return false; + break; + default: // normal case // Get GO cast coordinates if original caster -> GO WorldObject* caster = NULL; diff --git a/src/game/Spells/SpellEffects.cpp b/src/game/Spells/SpellEffects.cpp index 085245d63..b87ba7653 100644 --- a/src/game/Spells/SpellEffects.cpp +++ b/src/game/Spells/SpellEffects.cpp @@ -6175,6 +6175,12 @@ void Spell::EffectSummonRaFFriend(SpellEffIndex effIndex) if (m_caster->GetTypeId() != TYPEID_PLAYER || !unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER) return; - // Xinef: Unit Target can be on other map, thank god we dont use RaF... - m_caster->CastSpell(unitTarget, m_spellInfo->Effects[effIndex].TriggerSpell, true); + float x, y, z; + m_caster->GetPosition(x, y, z); + unitTarget->ToPlayer()->SetSummonPoint(m_caster->GetMapId(), x, y, z); + WorldPacket data(SMSG_SUMMON_REQUEST, 8 + 4 + 4); + data << uint64(m_caster->GetGUID()); + data << uint32(m_caster->GetZoneId()); + data << uint32(MAX_PLAYER_SUMMON_DELAY*IN_MILLISECONDS); // auto decline after msecs + unitTarget->ToPlayer()->GetSession()->SendPacket(&data); }