2017-08-17 00:00:41 +02:00
|
|
|
#include <Server_Common/Common.h>
|
|
|
|
#include <Server_Common/CommonNetwork.h>
|
2017-08-17 18:12:29 +02:00
|
|
|
#include <Server_Common/ExdData.h>
|
2017-08-17 00:00:41 +02:00
|
|
|
#include <Server_Common/GamePacketNew.h>
|
|
|
|
#include <Server_Common/PacketContainer.h>
|
2017-08-17 18:12:29 +02:00
|
|
|
#include <Server_Common/Logger.h>
|
2017-08-17 00:00:41 +02:00
|
|
|
|
|
|
|
#include <boost/format.hpp>
|
|
|
|
|
|
|
|
#include "GameConnection.h"
|
|
|
|
|
|
|
|
#include "Session.h"
|
|
|
|
|
|
|
|
#include "ServerNoticePacket.h"
|
|
|
|
#include "ActorControlPacket142.h"
|
|
|
|
#include "ActorControlPacket143.h"
|
|
|
|
#include "ActorControlPacket144.h"
|
|
|
|
|
2017-08-17 18:12:29 +02:00
|
|
|
#include "PlayerStateFlagsPacket.h"
|
2017-08-17 00:00:41 +02:00
|
|
|
|
|
|
|
#include "GameCommandHandler.h"
|
|
|
|
|
|
|
|
#include "Player.h"
|
|
|
|
|
|
|
|
#include "Forwards.h"
|
|
|
|
|
|
|
|
#include "Action.h"
|
|
|
|
#include "ActionTeleport.h"
|
|
|
|
#include "ActionCast.h"
|
2017-08-17 18:12:29 +02:00
|
|
|
#include "ScriptManager.h"
|
2017-08-17 00:00:41 +02:00
|
|
|
|
|
|
|
|
2017-08-17 18:12:29 +02:00
|
|
|
extern Core::Scripting::ScriptManager g_scriptMgr;
|
|
|
|
extern Core::Data::ExdData g_exdData;
|
|
|
|
extern Core::Logger g_log;
|
2017-08-17 00:00:41 +02:00
|
|
|
|
|
|
|
using namespace Core::Common;
|
|
|
|
using namespace Core::Network::Packets;
|
|
|
|
using namespace Core::Network::Packets::Server;
|
|
|
|
|
2017-08-17 17:45:45 +02:00
|
|
|
void Core::Network::GameConnection::skillHandler( const Packets::GamePacket& inPacket,
|
|
|
|
Entity::PlayerPtr pPlayer )
|
2017-08-17 00:00:41 +02:00
|
|
|
{
|
|
|
|
|
2017-08-17 17:30:00 +02:00
|
|
|
uint32_t action = inPacket.getValAt< uint32_t >( 0x24 );
|
|
|
|
uint32_t useCount = inPacket.getValAt< uint32_t >( 0x28 );
|
2017-08-17 00:00:41 +02:00
|
|
|
|
2017-08-17 17:30:00 +02:00
|
|
|
uint64_t targetId = inPacket.getValAt< uint64_t >( 0x30 );
|
2017-08-17 00:00:41 +02:00
|
|
|
|
|
|
|
if( action < 1000000 ) // normal action
|
|
|
|
{
|
|
|
|
std::string actionIdStr = boost::str( boost::format( "%|04X|" ) % action );
|
|
|
|
pPlayer->sendDebug( "---------------------------------------" );
|
2017-08-17 17:45:45 +02:00
|
|
|
pPlayer->sendDebug( "ActionHandler ( " + actionIdStr + " | " +
|
|
|
|
g_exdData.m_actionInfoMap[action].name +
|
|
|
|
" | " + std::to_string( targetId ) + " )" );
|
2017-08-17 00:00:41 +02:00
|
|
|
|
|
|
|
pPlayer->queuePacket( ActorControlPacket142( pPlayer->getId(), ActorControlType::ActionStart, 0x01, action ) );
|
|
|
|
|
|
|
|
if( action == 5 )
|
|
|
|
{
|
|
|
|
auto currentAction = pPlayer->getCurrentAction();
|
|
|
|
|
|
|
|
// we should always have an action here, if not there is a bug
|
|
|
|
assert( currentAction );
|
|
|
|
currentAction->onStart();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Core::Entity::ActorPtr targetActor = pPlayer;
|
|
|
|
if( targetId != pPlayer->getId() )
|
|
|
|
{
|
|
|
|
targetActor = pPlayer->lookupTargetById( targetId );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !pPlayer->actionHasCastTime( action ) )
|
|
|
|
{
|
|
|
|
g_scriptMgr.onCastFinish( pPlayer, targetActor, action );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Action::ActionCastPtr pActionCast( new Action::ActionCast( pPlayer, targetActor, action ) );
|
|
|
|
pPlayer->setCurrentAction( pActionCast );
|
|
|
|
pPlayer->sendDebug( "setCurrentAction()" );
|
|
|
|
pPlayer->getCurrentAction()->onStart();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( action < 2000000 ) // craft action
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
else if( action < 3000000 ) // item action
|
|
|
|
{
|
|
|
|
auto info = g_exdData.getEventItemInfo( action );
|
|
|
|
if( info )
|
|
|
|
{
|
|
|
|
g_log.debug( info->name );
|
|
|
|
g_scriptMgr.onEventItem( pPlayer, action, info->eventId, info->castTime, targetId );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( action > 3000000 ) // unknown
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|