Skip to content

Commit

Permalink
[10325] Improve process for Use() of GAMEOBJECT_TYPE_SUMMONING_RITUAL
Browse files Browse the repository at this point in the history
This allow GO's not summoned by any to be processed and use the spells as defined in GO template as expected.
In addition some new checks to determine if GO should despawn and if group membership should be checked or not to allow use.

Signed-off-by: NoFantasy <nofantasy@nf.no>
  • Loading branch information
NoFantasy committed Aug 6, 2010
1 parent d486072 commit 793f3ae
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 24 deletions.
86 changes: 63 additions & 23 deletions src/game/GameObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ GameObject::GameObject() : WorldObject()
m_spellId = 0;
m_cooldownTime = 0;
m_goInfo = NULL;
m_ritualOwner = NULL;

m_DBTableGuid = 0;
m_rotation = 0;
Expand Down Expand Up @@ -1175,43 +1176,82 @@ 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 (((Player*)caster) == player || !((Player*)caster)->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 == (Player*)owner || (info->summoningRitual.castersGrouped && !player->IsInSameRaidWith(((Player*)owner))))
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 nonexistent 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;

// can be deleted now
SetLootState(GO_JUST_DEACTIVATED);
spellId = info->summoningRitual.spellId;

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;
Expand Down
1 change: 1 addition & 0 deletions src/game/GameObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,7 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject
// 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;

Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10324"
#define REVISION_NR "10325"
#endif // __REVISION_NR_H__

0 comments on commit 793f3ae

Please sign in to comment.