[10325] Improve process for Use() of GAMEOBJECT_TYPE_SUMMONING_RITUAL

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>
This commit is contained in:
NoFantasy 2010-08-06 14:33:37 +02:00
parent edace1948e
commit 027261e295
3 changed files with 67 additions and 26 deletions

View file

@ -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;
@ -1175,30 +1176,55 @@ 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)
// ritual owner is set for GO's without owner (not summoned)
if (!m_ritualOwner && !owner)
m_ritualOwner = player;
if (owner)
{
if (owner->GetTypeId() != TYPEID_PLAYER)
return;
// accept only use by player from same group for caster except caster itself
if (((Player*)caster) == player || !((Player*)caster)->IsInSameRaidWith(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;
AddUniqueUse(player);
// full amount unique participants including original summoner
if (GetUniqueUseCount() < info->summoningRitual.reqParticipants)
// 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;
if (!caster->GetCurrentSpell(CURRENT_CHANNELED_SPELL))
spellCaster = owner;
}
else
{
if (player != m_ritualOwner && (info->summoningRitual.castersGrouped && !player->IsInSameRaidWith(m_ritualOwner)))
return;
spellCaster = player;
}
AddUniqueUse(player);
if (info->summoningRitual.animSpell)
{
player->CastSpell(player, info->summoningRitual.animSpell, true);
// for this case, summoningRitual.spellId is always triggered
triggered = true;
}
// full amount unique participants including original summoner
if (GetUniqueUseCount() == info->summoningRitual.reqParticipants)
{
spellCaster = m_ritualOwner ? m_ritualOwner : spellCaster;
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
@ -1207,11 +1233,25 @@ void GameObject::Use(Unit* user)
triggered = true;
}
// finish spell
player->FinishSpell(CURRENT_CHANNELED_SPELL);
// finish owners spell
if (owner)
owner->FinishSpell(CURRENT_CHANNELED_SPELL);
// can be deleted now
// 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;

View file

@ -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;

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10324"
#define REVISION_NR "10325"
#endif // __REVISION_NR_H__