feat: add incoming messages to bot

This commit is contained in:
k0t9i
2023-02-09 18:30:07 +04:00
parent 130cdc6bca
commit eefb5d40ae
27 changed files with 25280 additions and 111 deletions

View File

@@ -17,11 +17,12 @@
#include "Repositories/ItemRepository.h"
#include "Repositories/AbnormalEffectRepository.h"
#include "Repositories/ChatMessageRepository.h"
#include "Services/HeroService.h"
#include "GameStructs/NetworkHandlerWrapper.h"
#include "GameStructs/GameEngineWrapper.h"
#include "GameStructs/L2GameDataWrapper.h"
#include "GameStructs/FName.h"
#include "../../Services/EntityHandler.h"
#include "../../Services/EntityFinder.h"
#include "Helpers/EnchantHelper.h"
namespace Interlude
@@ -40,22 +41,22 @@ namespace Interlude
HeroRepository& GetHeroRepository() const override
{
static auto factory = HeroFactory();
static EntityHandler handler;
static EntityFinder finder;
static auto result = HeroRepository(
GetNetworkHandler(),
factory,
handler
finder
);
return result;
}
DropRepository& GetDropRepository() const override
{
static auto factory = DropFactory(GetL2GameData(), GetFName());
static EntityHandler handler;
static EntityFinder finder;
static auto result = DropRepository(
GetNetworkHandler(),
factory,
handler,
finder,
m_Radius
);
return result;
@@ -63,11 +64,11 @@ namespace Interlude
NPCRepository& GetNPCRepository() const override
{
static auto factory = NPCFactory();
static EntityHandler handler;
static EntityFinder finder;
static auto result = NPCRepository(
GetNetworkHandler(),
factory,
handler,
finder,
m_Radius
);
return result;
@@ -75,11 +76,11 @@ namespace Interlude
PlayerRepository& GetPlayerRepository() const override
{
static auto factory = PlayerFactory();
static EntityHandler handler;
static EntityFinder finder;
static auto result = PlayerRepository(
GetNetworkHandler(),
factory,
handler,
finder,
m_Radius
);
return result;
@@ -87,11 +88,11 @@ namespace Interlude
SkillRepository& GetSkillRepository() const override
{
static auto factory = SkillFactory(GetL2GameData(), GetFName());
static EntityHandler handler;
static EntityFinder finder;
static auto result = SkillRepository(
GetNetworkHandler(),
factory,
handler
finder
);
return result;
}
@@ -99,21 +100,21 @@ namespace Interlude
{
static EnchantHelper enchantHelper;
static auto factory = ItemFactory(GetL2GameData(), GetFName(), enchantHelper);
static EntityHandler handler;
static EntityFinder finder;
static auto result = ItemRepository(
GetNetworkHandler(),
factory,
handler
finder
);
return result;
}
AbnormalEffectRepository& GetAbnormalEffectRepository() const override
{
static auto factory = AbnormalEffectFactory(GetL2GameData(), GetFName());
static EntityHandler handler;
static EntityFinder finder;
static auto result = AbnormalEffectRepository(
factory,
handler
finder
);
return result;
}
@@ -125,6 +126,15 @@ namespace Interlude
);
return result;
}
Services::HeroServiceInterface& GetHeroService() const override
{
static auto result = HeroService(
GetNetworkHandler(),
GetItemRepository(),
GetL2GameData()
);
return result;
}
NetworkHandlerWrapper& GetNetworkHandler() const override
{
static NetworkHandlerWrapper result;

View File

@@ -14,7 +14,15 @@ namespace Interlude
Item* (__thiscall* NetworkHandlerWrapper::__GetNextItem)(NetworkHandler*, float, int) = 0;
User* (__thiscall* NetworkHandlerWrapper::__GetNextCreature)(NetworkHandler*, float, int) = 0;
int(__thiscall* NetworkHandlerWrapper::__AddNetworkQueue)(NetworkHandler*, L2::NetworkPacket*) = 0;
int(__thiscall* NetworkHandlerWrapper::__RequestItemList)(NetworkHandler*);
int(__thiscall* NetworkHandlerWrapper::__RequestItemList)(NetworkHandler*) = 0;
User* (__thiscall* NetworkHandlerWrapper::__GetUser)(NetworkHandler*, int) = 0;
Item* (__thiscall* NetworkHandlerWrapper::__GetItem)(NetworkHandler*, int) = 0;
void(__thiscall* NetworkHandlerWrapper::__Action)(NetworkHandler*, int, L2::FVector, int) = 0;
void(__thiscall* NetworkHandlerWrapper::__MTL)(NetworkHandler*, APawn*, L2::FVector, L2::FVector, void*, int) = 0;
void(__thiscall* NetworkHandlerWrapper::__RequestMagicSkillUse)(NetworkHandler*, L2ParamStack&) = 0;
int(__thiscall* NetworkHandlerWrapper::__RequestUseItem)(NetworkHandler*, L2ParamStack&) = 0;
void(__thiscall* NetworkHandlerWrapper::__RequestAutoSoulShot)(NetworkHandler*, L2ParamStack&) = 0;
void(__thiscall* NetworkHandlerWrapper::__ChangeWaitType)(NetworkHandler*, int) = 0;
//todo exception
Item* NetworkHandlerWrapper::GetNextItem(float_t radius, int prevId) const
@@ -51,6 +59,65 @@ namespace Interlude
return 0;
}
User* NetworkHandlerWrapper::GetUser(int objectId) const
{
if (__GetUser && _target) {
return (*__GetUser)(_target, objectId);
}
return 0;
}
Item* NetworkHandlerWrapper::GetItem(int objectId) const
{
if (__GetItem && _target) {
return (*__GetItem)(_target, objectId);
}
return 0;
}
void NetworkHandlerWrapper::MTL(APawn* self, L2::FVector dst, L2::FVector src, void* terrainInfo, int unk1) const
{
if (__MTL && _target) {
(*__MTL)(_target, self, dst, src, terrainInfo, unk1);
}
}
void NetworkHandlerWrapper::Action(int objectId, L2::FVector objectLocation, int unk) const
{
if (__Action && _target) {
(*__Action)(_target, objectId, objectLocation, unk);
}
}
void NetworkHandlerWrapper::RequestMagicSkillUse(L2ParamStack& stack) const
{
if (__RequestMagicSkillUse && _target) {
(*__RequestMagicSkillUse)(_target, stack);
}
}
int NetworkHandlerWrapper::RequestUseItem(L2ParamStack& stack) const
{
if (__RequestUseItem && _target) {
return (*__RequestUseItem)(_target, stack);
}
return 0;
}
void NetworkHandlerWrapper::RequestAutoSoulShot(L2ParamStack& stack) const
{
if (__RequestAutoSoulShot && _target) {
(*__RequestAutoSoulShot)(_target, stack);
}
}
void NetworkHandlerWrapper::ChangeWaitType(int type) const
{
if (__ChangeWaitType && _target) {
(*__ChangeWaitType)(_target, type);
}
}
int NetworkHandlerWrapper::RequestItemList() const
{
if (__RequestItemList && _target) {
@@ -68,7 +135,13 @@ namespace Interlude
(FARPROC&)__GetNextItem = GetProcAddress(hModule, "?GetNextItem@UNetworkHandler@@UAEPAUItem@@MH@Z");
(FARPROC&)__GetNextCreature = GetProcAddress(hModule, "?GetNextCreature@UNetworkHandler@@UAEPAUUser@@MH@Z");
(FARPROC&)__RequestItemList = GetProcAddress(hModule, "?RequestItemList@UNetworkHandler@@UAEHXZ");
(FARPROC&)__GetUser = GetProcAddress(hModule, "?GetUser@UNetworkHandler@@UAEPAUUser@@H@Z");
(FARPROC&)__MTL = GetProcAddress(hModule, "?MTL@UNetworkHandler@@UAEXPAVAActor@@VFVector@@10H@Z");
(FARPROC&)__Action = GetProcAddress(hModule, "?Action@UNetworkHandler@@UAEXHVFVector@@H@Z");
(FARPROC&)__RequestMagicSkillUse = GetProcAddress(hModule, "?RequestMagicSkillUse@UNetworkHandler@@UAEXAAVL2ParamStack@@@Z");
(FARPROC&)__RequestUseItem = GetProcAddress(hModule, "?RequestUseItem@UNetworkHandler@@UAEHAAVL2ParamStack@@@Z");
(FARPROC&)__RequestAutoSoulShot = GetProcAddress(hModule, "?RequestAutoSoulShot@UNetworkHandler@@UAEXAAVL2ParamStack@@@Z");
(FARPROC&)__ChangeWaitType = GetProcAddress(hModule, "?ChangeWaitType@UNetworkHandler@@UAEXH@Z");
(FARPROC&)__AddNetworkQueue = (FARPROC)splice(
GetProcAddress(hModule, "?AddNetworkQueue@UNetworkHandler@@UAEHPAUNetworkPacket@@@Z"), __AddNetworkQueue_hook

View File

@@ -22,7 +22,15 @@ namespace Interlude
Item* GetNextItem(float_t radius, int prevId) const;
User* GetNextCreature(float_t radius, int prevId) const;
User* GetHero() const;
User* GetUser(int objectId) const;
Item* GetItem(int objectId) const;
int RequestItemList() const;
void MTL(APawn* self, L2::FVector dst, L2::FVector src, void* terrainInfo, int unk1) const;
void Action(int objectId, L2::FVector objectLocation, int unk) const;
void RequestMagicSkillUse(L2ParamStack& stack) const;
int RequestUseItem(L2ParamStack& stack) const;
void RequestAutoSoulShot(L2ParamStack& stack) const;
void ChangeWaitType(int type) const;
private:
static void __fastcall __Init_hook(NetworkHandler* This, int /*edx*/, float unk);
@@ -33,6 +41,18 @@ namespace Interlude
static User* (__thiscall* __GetNextCreature)(NetworkHandler*, float, int);
static int(__thiscall* __AddNetworkQueue)(NetworkHandler*, L2::NetworkPacket*);
static int(__thiscall* __RequestItemList)(NetworkHandler*);
static User* (__thiscall* __GetUser)(NetworkHandler*, int);
static Item* (__thiscall* __GetItem)(NetworkHandler*, int);
static void(__thiscall* __MTL)(NetworkHandler*, APawn*, L2::FVector, L2::FVector, void*, int);
static void(__thiscall* __Action)(NetworkHandler*, int, L2::FVector, int);
//stack skillId, isForce, isShiftPressed
static void(__thiscall* __RequestMagicSkillUse)(NetworkHandler*, L2ParamStack&);
static int(__thiscall* __RequestUseItem)(NetworkHandler*, L2ParamStack&);
//stack itemId, on/off
static void(__thiscall* __RequestAutoSoulShot)(NetworkHandler*, L2ParamStack&);
//params objectId, unk
static void(__thiscall* __ChangeWaitType)(NetworkHandler*, int);
private:
static void* originalInitAddress;
static NetworkHandler* _target;

View File

@@ -9,7 +9,7 @@
#include "../../../Events/HeroDeletedEvent.h"
#include "../../../Events/EventDispatcher.h"
#include "../GameStructs/NetworkHandlerWrapper.h"
#include "../../../Services/EntityHandler.h"
#include "../../../Services/EntityFinder.h"
using namespace L2Bot::Domain;
@@ -28,7 +28,7 @@ namespace Interlude
skillPtrs[kvp.first] = kvp.second.get();
}
const auto objects = m_EntityHandler.GetEntities<Entities::AbnormalEffect*>(skillPtrs, [this](Entities::AbnormalEffect* item) {
const auto objects = m_EntityFinder.FindEntities<Entities::AbnormalEffect*>(skillPtrs, [this](Entities::AbnormalEffect* item) {
return std::make_unique<Entities::AbnormalEffect>(item);
});
@@ -42,9 +42,9 @@ namespace Interlude
return result;
}
AbnormalEffectRepository(const AbnormalEffectFactory& factory, EntityHandler& handler) :
AbnormalEffectRepository(const AbnormalEffectFactory& factory, EntityFinder& finder) :
m_Factory(factory),
m_EntityHandler(handler)
m_EntityFinder(finder)
{
EventDispatcher::GetInstance().Subscribe(AbnormalEffectChangedEvent::name, [this](const Event& evt) {
OnEffectToggled(evt);
@@ -115,6 +115,6 @@ namespace Interlude
const AbnormalEffectFactory& m_Factory;
std::map<uint32_t, std::unique_ptr<Entities::AbnormalEffect>> m_Effects;
std::shared_timed_mutex m_Mutex;
EntityHandler& m_EntityHandler;
EntityFinder& m_EntityFinder;
};
}

View File

@@ -8,7 +8,7 @@
#include "../Factories/DropFactory.h"
#include "../../GameStructs/FindObjectsTrait.h"
#include "../GameStructs/NetworkHandlerWrapper.h"
#include "../../../Services/EntityHandler.h"
#include "../../../Services/EntityFinder.h"
using namespace L2Bot::Domain;
@@ -24,7 +24,7 @@ namespace Interlude
const std::map<uint32_t, Item*> items = FindAllObjects<Item*>(m_Radius, [this](float_t radius, int32_t prevId) {
return m_NetworkHandler.GetNextItem(radius, prevId);
});
const auto objects = m_Container.GetEntities<Item*>(items, [this](Item* item) {
const auto objects = m_EntityFinder.FindEntities<Item*>(items, [this](Item* item) {
return m_Factory.Create(item);
});
@@ -41,14 +41,14 @@ namespace Interlude
void Reset() override
{
std::shared_lock<std::shared_timed_mutex>(m_Mutex);
m_Container.Reset();
m_EntityFinder.Reset();
}
DropRepository(const NetworkHandlerWrapper& networkHandler, const DropFactory& factory, EntityHandler& handler, const uint16_t radius) :
DropRepository(const NetworkHandlerWrapper& networkHandler, const DropFactory& factory, EntityFinder& finder, const uint16_t radius) :
m_NetworkHandler(networkHandler),
m_Factory(factory),
m_Radius(radius),
m_Container(handler)
m_EntityFinder(finder)
{
}
@@ -60,7 +60,7 @@ namespace Interlude
const NetworkHandlerWrapper& m_NetworkHandler;
const DropFactory& m_Factory;
const uint16_t m_Radius;
EntityHandler& m_Container;
EntityFinder& m_EntityFinder;
std::shared_timed_mutex m_Mutex;
};
}

View File

@@ -7,7 +7,7 @@
#include "../../../Events/HeroCreatedEvent.h"
#include "../../../Events/HeroDeletedEvent.h"
#include "../GameStructs/NetworkHandlerWrapper.h"
#include "../../../Services/EntityHandler.h"
#include "../../../Services/EntityFinder.h"
using namespace L2Bot::Domain;
@@ -39,7 +39,7 @@ namespace Interlude
items.emplace(hero->objectId, hero);
}
const auto objects = m_EntityHandler.GetEntities<User*>(items, [this](User* item) {
const auto objects = m_EntityFinder.FindEntities<User*>(items, [this](User* item) {
return m_Factory.Create(item);
});
@@ -56,13 +56,13 @@ namespace Interlude
void Reset() override
{
std::shared_lock<std::shared_timed_mutex>(m_Mutex);
m_EntityHandler.Reset();
m_EntityFinder.Reset();
}
HeroRepository(const NetworkHandlerWrapper& networkHandler, const HeroFactory& factory, EntityHandler& handler) :
HeroRepository(const NetworkHandlerWrapper& networkHandler, const HeroFactory& factory, EntityFinder& finder) :
m_NetworkHandler(networkHandler),
m_Factory(factory),
m_EntityHandler(handler)
m_EntityFinder(finder)
{
}
@@ -74,7 +74,7 @@ namespace Interlude
const HeroFactory& m_Factory;
const NetworkHandlerWrapper& m_NetworkHandler;
User* m_PrevHero = nullptr;
EntityHandler& m_EntityHandler;
EntityFinder& m_EntityFinder;
std::shared_timed_mutex m_Mutex;
};
}

View File

@@ -6,7 +6,7 @@
#include "Domain/Repositories/EntityRepositoryInterface.h"
#include "../Factories/ItemFactory.h"
#include "../GameStructs/NetworkHandlerWrapper.h"
#include "../../../Services/EntityHandler.h"
#include "../../../Services/EntityFinder.h"
#include "../../../Events/ItemCreatedEvent.h"
#include "../../../Events/ItemUpdatedEvent.h"
#include "../../../Events/ItemDeletedEvent.h"
@@ -32,7 +32,7 @@ namespace Interlude
itemPtrs[kvp.first] = kvp.second.get();
}
const auto objects = m_EntityHandler.GetEntities<Entities::BaseItem*>(itemPtrs, [this](Entities::BaseItem* item) {
const auto objects = m_EntityFinder.FindEntities<Entities::BaseItem*>(itemPtrs, [this](Entities::BaseItem* item) {
return m_Factory.CreateFromPointer(item);
});
@@ -46,10 +46,19 @@ namespace Interlude
return result;
}
ItemRepository(const NetworkHandlerWrapper& networkHandler, const ItemFactory& factory, EntityHandler& handler) :
const Entities::BaseItem& GetItem(uint32_t objectId) const
{
if (m_Items.find(objectId) != m_Items.end())
{
return m_Items.at(objectId).get();
}
return Entities::BaseItem();
}
ItemRepository(const NetworkHandlerWrapper& networkHandler, const ItemFactory& factory, EntityFinder& finder) :
m_NetworkHandler(networkHandler),
m_Factory(factory),
m_EntityHandler(handler)
m_EntityFinder(finder)
{
EventDispatcher::GetInstance().Subscribe(ItemCreatedEvent::name, [this](const Event& evt) {
OnItemCreated(evt);
@@ -208,6 +217,6 @@ namespace Interlude
uint32_t m_UsedSkillId = 0;
const NetworkHandlerWrapper& m_NetworkHandler;
std::shared_timed_mutex m_Mutex;
EntityHandler& m_EntityHandler;
EntityFinder& m_EntityFinder;
};
}

View File

@@ -9,7 +9,7 @@
#include "../../../Events/SpoiledEvent.h"
#include "../../../Events/CreatureDiedEvent.h"
#include "../../GameStructs/FindObjectsTrait.h"
#include "../../../Services/EntityHandler.h"
#include "../../../Services/EntityFinder.h"
using namespace L2Bot::Domain;
@@ -35,7 +35,7 @@ namespace Interlude
}
}
const auto objects = m_EntityHandler.GetEntities<User*>(items, [this](User* item) {
const auto objects = m_EntityFinder.FindEntities<User*>(items, [this](User* item) {
const auto spoilState = m_Spoiled.find(item->objectId) == m_Spoiled.end() ? Enums::SpoilStateEnum::none : m_Spoiled.at(item->objectId);
return m_Factory.Create(item, spoilState);
});
@@ -53,14 +53,14 @@ namespace Interlude
void Reset() override
{
std::shared_lock<std::shared_timed_mutex>(m_Mutex);
m_EntityHandler.Reset();
m_EntityFinder.Reset();
}
NPCRepository(const NetworkHandlerWrapper& networkHandler, const NPCFactory& factory, EntityHandler& handler, const uint16_t radius) :
NPCRepository(const NetworkHandlerWrapper& networkHandler, const NPCFactory& factory, EntityFinder& finder, const uint16_t radius) :
m_NetworkHandler(networkHandler),
m_Factory(factory),
m_Radius(radius),
m_EntityHandler(handler)
m_EntityFinder(finder)
{
EventDispatcher::GetInstance().Subscribe(SpoiledEvent::name, [this](const Event& evt) {
OnSpoiled(evt);
@@ -115,7 +115,7 @@ namespace Interlude
std::map<uint32_t, Enums::SpoilStateEnum> m_Spoiled;
const NetworkHandlerWrapper& m_NetworkHandler;
const uint16_t m_Radius = 0;
EntityHandler& m_EntityHandler;
EntityFinder& m_EntityFinder;
std::shared_timed_mutex m_Mutex;
};
}

View File

@@ -5,7 +5,7 @@
#include "../Factories/PlayerFactory.h"
#include "../../GameStructs/FindObjectsTrait.h"
#include "../GameStructs/NetworkHandlerWrapper.h"
#include "../../../Services/EntityHandler.h"
#include "../../../Services/EntityFinder.h"
using namespace L2Bot::Domain;
@@ -31,7 +31,7 @@ namespace Interlude
}
}
const auto objects = m_EntityHandler.GetEntities<User*>(items, [this](User* item) {
const auto objects = m_EntityFinder.FindEntities<User*>(items, [this](User* item) {
return m_Factory.Create(item);
});
@@ -48,14 +48,14 @@ namespace Interlude
void Reset() override
{
std::shared_lock<std::shared_timed_mutex>(m_Mutex);
m_EntityHandler.Reset();
m_EntityFinder.Reset();
}
PlayerRepository(const NetworkHandlerWrapper& networkHandler, const PlayerFactory& factory, EntityHandler& handler, const uint16_t radius) :
PlayerRepository(const NetworkHandlerWrapper& networkHandler, const PlayerFactory& factory, EntityFinder& finder, const uint16_t radius) :
m_NetworkHandler(networkHandler),
m_Factory(factory),
m_Radius(radius),
m_EntityHandler(handler)
m_EntityFinder(finder)
{
}
@@ -67,7 +67,7 @@ namespace Interlude
const PlayerFactory& m_Factory;
const NetworkHandlerWrapper& m_NetworkHandler;
const uint16_t m_Radius;
EntityHandler& m_EntityHandler;
EntityFinder& m_EntityFinder;
std::shared_timed_mutex m_Mutex;
};
}

View File

@@ -14,7 +14,7 @@
#include "../../../Events/EventDispatcher.h"
#include "../GameStructs/NetworkHandlerWrapper.h"
#include "../../../Common/TimerMap.h"
#include "../../../Services/EntityHandler.h"
#include "../../../Services/EntityFinder.h"
using namespace L2Bot::Domain;
@@ -33,7 +33,7 @@ namespace Interlude
skillPtrs[kvp.first] = kvp.second.get();
}
const auto objects = m_EntityHandler.GetEntities<Entities::Skill*>(skillPtrs, [this](Entities::Skill* item) {
const auto objects = m_EntityFinder.FindEntities<Entities::Skill*>(skillPtrs, [this](Entities::Skill* item) {
return std::make_unique<Entities::Skill>(item);
});
@@ -47,10 +47,10 @@ namespace Interlude
return result;
}
SkillRepository(const NetworkHandlerWrapper& networkHandler, const SkillFactory& factory, EntityHandler& handler) :
SkillRepository(const NetworkHandlerWrapper& networkHandler, const SkillFactory& factory, EntityFinder& finder) :
m_NetworkHandler(networkHandler),
m_Factory(factory),
m_EntityHandler(handler)
m_EntityFinder(finder)
{
EventDispatcher::GetInstance().Subscribe(SkillCreatedEvent::name, [this](const Event& evt) {
OnSkillCreated(evt);
@@ -253,6 +253,6 @@ namespace Interlude
TimerMap m_ReloadingTimers;
TimerMap m_CastingTimers;
std::shared_timed_mutex m_Mutex;
EntityHandler& m_EntityHandler;
EntityFinder& m_EntityFinder;
};
}

View File

@@ -0,0 +1,132 @@
#pragma once
#include "Domain/Services/HeroServiceInterface.h"
#include "../Repositories/ItemRepository.h"
#include "../GameStructs/NetworkHandlerWrapper.h"
#include "../GameStructs/L2GameDataWrapper.h"
using namespace L2Bot::Domain;
namespace Interlude
{
class HeroService : public Services::HeroServiceInterface
{
public:
HeroService(const NetworkHandlerWrapper& networkHandler, const ItemRepository& itemRespository, const L2GameDataWrapper& l2GameData) :
m_NetworkHandler(networkHandler),
m_ItemRespository(itemRespository),
m_L2GameData(l2GameData)
{
}
HeroService() = delete;
virtual ~HeroService() = default;
void Move(ValueObjects::Vector3 location) const override
{
auto hero = m_NetworkHandler.GetHero();
if (hero) {
m_NetworkHandler.MTL(
hero->pawn,
{ location.GetX(), location.GetY(), location.GetZ() },
hero->pawn->Location,
hero->pawn->terrainInfo,
0
);
}
}
void AcquireTarget(int objectId) const override
{
auto target = m_NetworkHandler.GetUser(objectId);
if (target) {
if (target->objectId == objectId) {
auto hero = m_NetworkHandler.GetHero();
// Reset target
if (hero)
{
m_NetworkHandler.Action(hero->objectId, hero->pawn->Location, 0);
}
}
m_NetworkHandler.Action(objectId, target->pawn->Location, 0);
}
}
void Attack(int objectId) const override
{
auto target = m_NetworkHandler.GetUser(objectId);
if (target) {
// Acquire target
m_NetworkHandler.Action(objectId, target->pawn->Location, 0);
// Attack
m_NetworkHandler.Action(objectId, target->pawn->Location, 0);
}
}
void Pickup(int objectId) const override
{
auto target = m_NetworkHandler.GetItem(objectId);
if (target) {
m_NetworkHandler.Action(objectId, target->pawn->Location, 0);
}
}
void UseSkill(int skillId, bool isForced, bool isShiftPressed) const override
{
L2ParamStack* stack = new L2ParamStack(3);
stack->PushBack((void*)skillId);
stack->PushBack((void*)(isForced ? 1 : 0));
stack->PushBack((void*)(isShiftPressed ? 1 : 0));
m_NetworkHandler.RequestMagicSkillUse(*stack);
delete stack;
}
void UseItem(int objectId) const override
{
L2ParamStack* stack = new L2ParamStack(1);
stack->PushBack((void*)objectId);
m_NetworkHandler.RequestUseItem(*stack);
delete stack;
}
void ToggleAutouseSoulshot(int objectId) const override
{
const auto item = m_ItemRespository.GetItem(objectId);
if (item.GetId())
{
const auto etcItem = static_cast<const Entities::EtcItem&>(item);
L2ParamStack* stack = new L2ParamStack(2);
stack->PushBack((void*)etcItem.GetItemId());
stack->PushBack((void*)(etcItem.IsAutoused() ? 0 : 1));
m_NetworkHandler.RequestAutoSoulShot(*stack);
delete stack;
}
}
void Sit() const override
{
m_NetworkHandler.ChangeWaitType(0);
}
void Stand() const override
{
m_NetworkHandler.ChangeWaitType(1);
}
private:
const NetworkHandlerWrapper& m_NetworkHandler;
const ItemRepository& m_ItemRespository;
const L2GameDataWrapper& m_L2GameData;
};
}

View File

@@ -2,6 +2,7 @@
#include "Domain/Repositories/EntityRepositoryInterface.h"
#include "Domain/Repositories/ChatMessageRepositoryInterface.h"
#include "Domain/Services/HeroServiceInterface.h"
#include "GameStructs/NetworkHandlerInterface.h"
#include "GameStructs/GameEngineInterface.h"
#include "GameStructs/L2GameDataInterface.h"
@@ -25,6 +26,7 @@ public:
virtual Repositories::EntityRepositoryInterface& GetItemRepository() const = 0;
virtual Repositories::EntityRepositoryInterface& GetAbnormalEffectRepository() const = 0;
virtual Repositories::ChatMessageRepositoryInterface& GetChatMessageRepository() const = 0;
virtual Services::HeroServiceInterface& GetHeroService() const = 0;
virtual NetworkHandlerInterface& GetNetworkHandler() const = 0;
virtual GameEngineInterface& GetGameEngine() const = 0;
virtual L2GameDataInterface& GetL2GameData() const = 0;