mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/GameObject: Implemented OnFlagTaken/OnFlagDropped hooks for GAMEOBJECT_TYPE_FLAGSTAND
This commit is contained in:
@@ -3491,8 +3491,21 @@ void GameObject::Use(Unit* user)
|
||||
SpellCastResult castResult = CastSpell(user, spellId);
|
||||
if (castResult == SPELL_FAILED_SUCCESS)
|
||||
{
|
||||
if (GetGoType() == GAMEOBJECT_TYPE_NEW_FLAG)
|
||||
HandleCustomTypeCommand(GameObjectType::SetNewFlagState(FlagState::Taken, user->ToPlayer()));
|
||||
switch (GetGoType())
|
||||
{
|
||||
case GAMEOBJECT_TYPE_NEW_FLAG:
|
||||
HandleCustomTypeCommand(GameObjectType::SetNewFlagState(FlagState::Taken, user->ToPlayer()));
|
||||
break;
|
||||
case GAMEOBJECT_TYPE_FLAGSTAND:
|
||||
SetFlag(GO_FLAG_IN_USE);
|
||||
if (ZoneScript* zonescript = GetZoneScript())
|
||||
zonescript->OnFlagTaken(this, Object::ToPlayer(user));
|
||||
|
||||
Delete();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,6 +107,11 @@ class TC_GAME_API ZoneScript
|
||||
|
||||
virtual bool CanCaptureFlag([[maybe_unused]] AreaTrigger* areaTrigger, [[maybe_unused]] Player* player) { return false; }
|
||||
virtual void OnCaptureFlag([[maybe_unused]] AreaTrigger* areaTrigger, [[maybe_unused]] Player* player) { }
|
||||
|
||||
// This hook is used with GAMEOBJECT_TYPE_FLAGSTAND. Newer gameobjects use GAMEOBJECT_TYPE_NEW_FLAG and should use `OnFlagStateChange`
|
||||
virtual void OnFlagTaken([[maybe_unused]] GameObject* flag, [[maybe_unused]] Player* player) { }
|
||||
// This hook is used with GAMEOBJECT_TYPE_FLAGSTAND. Newer gameobjects use GAMEOBJECT_TYPE_NEW_FLAG and should use `OnFlagStateChange`. The GameObject doesn't exist anymore, but the ObjectGuid does
|
||||
virtual void OnFlagDropped([[maybe_unused]] ObjectGuid const& flagGuid, [[maybe_unused]] Player* player) { }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6417,13 +6417,24 @@ void AuraEffect::HandleBattlegroundPlayerPosition(AuraApplication const* aurApp,
|
||||
|
||||
if (!apply && aurApp->GetRemoveMode() != AURA_REMOVE_BY_DEFAULT)
|
||||
{
|
||||
if (GameObject* gameObjectCaster = target->GetMap()->GetGameObject(GetCasterGUID()))
|
||||
if (GetCasterGUID().IsGameObject())
|
||||
{
|
||||
if (gameObjectCaster->GetGoType() == GAMEOBJECT_TYPE_NEW_FLAG)
|
||||
if (GameObjectTemplate const* gobTemplate = sObjectMgr->GetGameObjectTemplate(GetCasterGUID().GetEntry()))
|
||||
{
|
||||
gameObjectCaster->HandleCustomTypeCommand(GameObjectType::SetNewFlagState(FlagState::Dropped, target));
|
||||
if (GameObject* droppedFlag = gameObjectCaster->SummonGameObject(gameObjectCaster->GetGOInfo()->newflag.FlagDrop, target->GetPosition(), QuaternionData::fromEulerAnglesZYX(target->GetOrientation(), 0.f, 0.f), Seconds(gameObjectCaster->GetGOInfo()->newflag.ExpireDuration / 1000), GO_SUMMON_TIMED_DESPAWN))
|
||||
droppedFlag->SetOwnerGUID(gameObjectCaster->GetGUID());
|
||||
if (gobTemplate->type == GAMEOBJECT_TYPE_NEW_FLAG)
|
||||
{
|
||||
if (GameObject* gameObjectCaster = target->GetMap()->GetGameObject(GetCasterGUID()))
|
||||
{
|
||||
gameObjectCaster->HandleCustomTypeCommand(GameObjectType::SetNewFlagState(FlagState::Dropped, target));
|
||||
if (GameObject* droppedFlag = gameObjectCaster->SummonGameObject(gameObjectCaster->GetGOInfo()->newflag.FlagDrop, target->GetPosition(), QuaternionData::fromEulerAnglesZYX(target->GetOrientation(), 0.f, 0.f), Seconds(gameObjectCaster->GetGOInfo()->newflag.ExpireDuration / 1000), GO_SUMMON_TIMED_DESPAWN))
|
||||
droppedFlag->SetOwnerGUID(gameObjectCaster->GetGUID());
|
||||
}
|
||||
}
|
||||
else if (gobTemplate->type == GAMEOBJECT_TYPE_FLAGSTAND)
|
||||
{
|
||||
if (ZoneScript* zonescript = target->FindZoneScript())
|
||||
zonescript->OnFlagDropped(GetCasterGUID(), target);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user