mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-21 17:54:48 +01:00
Core/Garrisons: Implemented activating buildings
This commit is contained in:
@@ -133,7 +133,7 @@ bool Garrison::LoadFromDB(PreparedQueryResult garrison, PreparedQueryResult blue
|
||||
return true;
|
||||
}
|
||||
|
||||
void Garrison::SaveToDB(SQLTransaction& trans)
|
||||
void Garrison::SaveToDB(SQLTransaction trans)
|
||||
{
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHARACTER_GARRISON);
|
||||
stmt->setUInt64(0, _owner->GetGUID().GetCounter());
|
||||
@@ -431,6 +431,27 @@ void Garrison::CancelBuildingConstruction(uint32 garrPlotInstanceId)
|
||||
_owner->SendDirectMessage(buildingRemoved.Write());
|
||||
}
|
||||
|
||||
void Garrison::ActivateBuilding(uint32 garrPlotInstanceId)
|
||||
{
|
||||
if (Plot* plot = GetPlot(garrPlotInstanceId))
|
||||
{
|
||||
if (plot->BuildingInfo.CanActivate() && plot->BuildingInfo.PacketInfo && !plot->BuildingInfo.PacketInfo->Active)
|
||||
{
|
||||
plot->BuildingInfo.PacketInfo->Active = true;
|
||||
if (Map* map = FindMap())
|
||||
{
|
||||
plot->DeleteGameObject(map);
|
||||
if (GameObject* go = plot->CreateGameObject(map, GetFaction()))
|
||||
map->AddToMap(go);
|
||||
}
|
||||
|
||||
WorldPackets::Garrison::GarrisonBuildingActivated buildingActivated;
|
||||
buildingActivated.GarrPlotInstanceID = garrPlotInstanceId;
|
||||
_owner->SendDirectMessage(buildingActivated.Write());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Garrison::AddFollower(uint32 garrFollowerId)
|
||||
{
|
||||
WorldPackets::Garrison::GarrisonAddFollowerResult addFollowerResult;
|
||||
|
||||
@@ -109,7 +109,7 @@ public:
|
||||
|
||||
bool LoadFromDB(PreparedQueryResult garrison, PreparedQueryResult blueprints, PreparedQueryResult buildings,
|
||||
PreparedQueryResult followers, PreparedQueryResult abilities);
|
||||
void SaveToDB(SQLTransaction& trans);
|
||||
void SaveToDB(SQLTransaction trans);
|
||||
|
||||
bool Create(uint32 garrSiteId);
|
||||
void Upgrade();
|
||||
@@ -129,6 +129,7 @@ public:
|
||||
void UnlearnBlueprint(uint32 garrBuildingId);
|
||||
void PlaceBuilding(uint32 garrPlotInstanceId, uint32 garrBuildingId);
|
||||
void CancelBuildingConstruction(uint32 garrPlotInstanceId);
|
||||
void ActivateBuilding(uint32 garrPlotInstanceId);
|
||||
|
||||
// Followers
|
||||
void AddFollower(uint32 garrFollowerId);
|
||||
|
||||
@@ -245,3 +245,10 @@ WorldPacket const* WorldPackets::Garrison::GarrisonAddFollowerResult::Write()
|
||||
|
||||
return &_worldPacket;
|
||||
}
|
||||
|
||||
WorldPacket const* WorldPackets::Garrison::GarrisonBuildingActivated::Write()
|
||||
{
|
||||
_worldPacket << uint32(GarrPlotInstanceID);
|
||||
|
||||
return &_worldPacket;
|
||||
}
|
||||
|
||||
@@ -279,6 +279,16 @@ namespace WorldPackets
|
||||
GarrisonFollower Follower;
|
||||
uint32 Result = 0;
|
||||
};
|
||||
|
||||
class GarrisonBuildingActivated final : public ServerPacket
|
||||
{
|
||||
public:
|
||||
GarrisonBuildingActivated() : ServerPacket(SMSG_GARRISON_BUILDING_ACTIVATED, 4) { }
|
||||
|
||||
WorldPacket const* Write() override;
|
||||
|
||||
uint32 GarrPlotInstanceID = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1113,7 +1113,7 @@ void OpcodeTable::Initialize()
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_GARRISON_ADD_FOLLOWER_RESULT, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_GARRISON_ADD_MISSION_RESULT, STATUS_UNHANDLED, CONNECTION_TYPE_INSTANCE);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_GARRISON_ASSIGN_FOLLOWER_TO_BUILDING_RESULT, STATUS_UNHANDLED, CONNECTION_TYPE_INSTANCE);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_GARRISON_BUILDING_ACTIVATED, STATUS_UNHANDLED, CONNECTION_TYPE_INSTANCE);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_GARRISON_BUILDING_ACTIVATED, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_GARRISON_BUILDING_LANDMARKS, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_GARRISON_BUILDING_REMOVED, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
|
||||
DEFINE_SERVER_OPCODE_HANDLER(SMSG_GARRISON_BUILDING_SET_ACTIVE_SPECIALIZATION_RESULT, STATUS_UNHANDLED, CONNECTION_TYPE_INSTANCE);
|
||||
|
||||
@@ -409,6 +409,7 @@ class Spell
|
||||
void EffectLearnGarrisonBuilding(SpellEffIndex effIndex);
|
||||
void EffectCreateGarrison(SpellEffIndex effIndex);
|
||||
void EffectAddGarrisonFollower(SpellEffIndex effIndex);
|
||||
void EffectActivateGarrisonBuilding(SpellEffIndex effIndex);
|
||||
|
||||
typedef std::set<Aura*> UsedSpellMods;
|
||||
|
||||
|
||||
@@ -299,7 +299,7 @@ pEffect SpellEffects[TOTAL_SPELL_EFFECTS]=
|
||||
&Spell::EffectNULL, //221 SPELL_EFFECT_221
|
||||
&Spell::EffectNULL, //222 SPELL_EFFECT_CREATE_HEIRLOOM_ITEM
|
||||
&Spell::EffectNULL, //223 SPELL_EFFECT_CHANGE_ITEM_BONUSES
|
||||
&Spell::EffectNULL, //224 SPELL_EFFECT_ACTIVATE_GARRISON_BUILDING
|
||||
&Spell::EffectActivateGarrisonBuilding, //224 SPELL_EFFECT_ACTIVATE_GARRISON_BUILDING
|
||||
&Spell::EffectNULL, //225 SPELL_EFFECT_GRANT_BATTLEPET_LEVEL
|
||||
&Spell::EffectNULL, //226 SPELL_EFFECT_226
|
||||
&Spell::EffectNULL, //227 SPELL_EFFECT_227
|
||||
@@ -5859,3 +5859,15 @@ void Spell::EffectAddGarrisonFollower(SpellEffIndex effIndex)
|
||||
if (Garrison* garrison = unitTarget->ToPlayer()->GetGarrison())
|
||||
garrison->AddFollower(GetEffect(effIndex)->MiscValue);
|
||||
}
|
||||
|
||||
void Spell::EffectActivateGarrisonBuilding(SpellEffIndex effIndex)
|
||||
{
|
||||
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
|
||||
return;
|
||||
|
||||
if (!unitTarget || unitTarget->GetTypeId() != TYPEID_PLAYER)
|
||||
return;
|
||||
|
||||
if (Garrison* garrison = unitTarget->ToPlayer()->GetGarrison())
|
||||
garrison->ActivateBuilding(GetEffect(effIndex)->MiscValue);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user