* Process GAMEOBJECT_TYPE_FISHINGHOLE in normal way as for other GO's (thanks NoFantasy)

* Improve process for Use() of GAMEOBJECT_TYPE_SUMMONING_RITUAL (thanks NoFantasy)

--HG--
branch : trunk
This commit is contained in:
azazel
2010-08-09 22:50:30 +06:00
parent 45bb540b02
commit 464c0c1611
2 changed files with 79 additions and 28 deletions

View File

@@ -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;
// 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;
// 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 = owner;
}
else
{
if (player != m_ritualOwner && (info->summoningRitual.castersGrouped && !player->IsInSameRaidWith(m_ritualOwner)))
return;
spellCaster = player;
}
AddUniqueUse(player);
// full amount unique participants including original summoner
if (GetUniqueUseCount() < info->summoningRitual.reqParticipants)
return;
// in case summoning ritual caster is GO creator
spellCaster = caster;
if (!caster->GetCurrentSpell(CURRENT_CHANNELED_SPELL))
return;
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;
// 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;
@@ -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)

View File

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