diff options
-rw-r--r-- | src/server/game/Entities/GameObject/GameObject.cpp | 100 | ||||
-rw-r--r-- | src/server/game/Entities/GameObject/GameObject.h | 3 |
2 files changed, 77 insertions, 26 deletions
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 61ac5bdd2c8..c89f2b866e3 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -57,6 +57,7 @@ GameObject::GameObject() : WorldObject(), m_goValue(new GameObjectValue) m_spellId = 0; m_cooldownTime = 0; m_goInfo = NULL; + m_ritualOwner = NULL; m_goData = NULL; m_DBTableGuid = 0; @@ -1253,8 +1254,7 @@ void GameObject::Use(Unit* user) GameObject* ok = LookupFishingHoleAround(20.0f + CONTACT_DISTANCE); if (ok) { - player->SendLoot(ok->GetGUID(),LOOT_FISHINGHOLE); - player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_FISH_IN_GAMEOBJECT, ok->GetGOInfo()->id); + ok->Use(player); SetLootState(GO_JUST_DEACTIVATED); } else @@ -1287,43 +1287,80 @@ void GameObject::Use(Unit* user) Player* player = (Player*)user; - Unit* caster = GetOwner(); + Unit* owner = GetOwner(); GameObjectInfo const* info = GetGOInfo(); - if (!caster || caster->GetTypeId() != TYPEID_PLAYER) - return; + // ritual owner is set for GO's without owner (not summoned) + if (!m_ritualOwner && !owner) + m_ritualOwner = player; - // accept only use by player from same group for caster except caster itself - if (caster->ToPlayer() == player || !caster->ToPlayer()->IsInSameRaidWith(player)) - return; + if (owner) + { + if (owner->GetTypeId() != TYPEID_PLAYER) + return; - AddUniqueUse(player); + // accept only use by player from same group as owner, excluding owner itself (unique use already added in spell effect) + if (player == owner->ToPlayer() || (info->summoningRitual.castersGrouped && !player->IsInSameRaidWith(owner->ToPlayer()))) + return; - // full amount unique participants including original summoner - if (GetUniqueUseCount() < info->summoningRitual.reqParticipants) - return; + // expect owner to already be channeling, so if not... + if (!owner->GetCurrentSpell(CURRENT_CHANNELED_SPELL)) + return; - // in case summoning ritual caster is GO creator - spellCaster = caster; + // in case summoning ritual caster is GO creator + spellCaster = owner; + } + else + { + if (player != m_ritualOwner && (info->summoningRitual.castersGrouped && !player->IsInSameRaidWith(m_ritualOwner))) + return; - if (!caster->GetCurrentSpell(CURRENT_CHANNELED_SPELL)) - return; + spellCaster = player; + } + + AddUniqueUse(player); - spellId = info->summoningRitual.spellId; - if (spellId == 62330) // GO store not existed spell, replace by expected + if (info->summoningRitual.animSpell) { - // spell have reagent and mana cost but it not expected use its - // it triggered spell in fact casted at currently channeled GO - spellId = 61993; + player->CastSpell(player, info->summoningRitual.animSpell, true); + + // for this case, summoningRitual.spellId is always triggered triggered = true; } - // finish spell - player->FinishSpell(CURRENT_CHANNELED_SPELL); + // full amount unique participants including original summoner + if (GetUniqueUseCount() == info->summoningRitual.reqParticipants) + { + spellCaster = m_ritualOwner ? m_ritualOwner : spellCaster; + + spellId = info->summoningRitual.spellId; - // can be deleted now - SetLootState(GO_JUST_DEACTIVATED); + if (spellId == 62330) // GO store nonexistent spell, replace by expected + { + // spell have reagent and mana cost but it not expected use its + // it triggered spell in fact casted at currently channeled GO + spellId = 61993; + triggered = true; + } + + // finish owners spell + if (owner) + owner->FinishSpell(CURRENT_CHANNELED_SPELL); + + // can be deleted now, if + if (!info->summoningRitual.ritualPersistent) + SetLootState(GO_JUST_DEACTIVATED); + else + { + // reset ritual for this GO + m_ritualOwner = NULL; + m_unique_users.clear(); + m_usetimes = 0; + } + } + else + return; // go to end function to spell casting break; @@ -1407,6 +1444,19 @@ void GameObject::Use(Unit* user) } break; } + + case GAMEOBJECT_TYPE_FISHINGHOLE: // 25 + { + if (user->GetTypeId() != TYPEID_PLAYER) + return; + + Player* player = (Player*)user; + + player->SendLoot(GetGUID(), LOOT_FISHINGHOLE); + player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_FISH_IN_GAMEOBJECT, GetGOInfo()->id); + return; + } + case GAMEOBJECT_TYPE_FLAGDROP: // 26 { if (user->GetTypeId() != TYPEID_PLAYER) diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h index 400597cfb77..2b48c354c90 100644 --- a/src/server/game/Entities/GameObject/GameObject.h +++ b/src/server/game/Entities/GameObject/GameObject.h @@ -283,7 +283,7 @@ struct GameObjectInfo uint32 openTextID; //6 uint32 losOK; //7 } flagstand; - //25 GAMEOBJECT_TYPE_FISHINGHOLE // not implemented yet + //25 GAMEOBJECT_TYPE_FISHINGHOLE struct { uint32 radius; //0 how close bobber must land for sending loot @@ -755,6 +755,7 @@ class GameObject : public WorldObject, public GridObject<GameObject> // For traps this: spell casting cooldown, for doors/buttons: reset time. std::list<uint32> m_SkillupList; + Player* m_ritualOwner; // used for GAMEOBJECT_TYPE_SUMMONING_RITUAL where GO is not summoned (no owner) std::set<uint32> m_unique_users; uint32 m_usetimes; |