2017-12-18 12:36:52 +01:00
|
|
|
#include <common/Common.h>
|
|
|
|
#include <common/Network/CommonNetwork.h>
|
2018-01-31 11:43:22 +01:00
|
|
|
#include <common/Exd/ExdDataGenerated.h>
|
2017-12-18 12:36:52 +01:00
|
|
|
#include <common/Network/GamePacketNew.h>
|
|
|
|
#include <common/Network/PacketContainer.h>
|
|
|
|
#include <common/Logging/Logger.h>
|
2017-08-17 00:00:41 +02:00
|
|
|
|
|
|
|
#include <boost/format.hpp>
|
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
#include "Network/GameConnection.h"
|
2017-08-17 00:00:41 +02:00
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
#include "Session.h"
|
2017-08-17 00:00:41 +02:00
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
#include "Network/PacketWrappers/ServerNoticePacket.h"
|
|
|
|
#include "Network/PacketWrappers/ActorControlPacket142.h"
|
|
|
|
#include "Network/PacketWrappers/ActorControlPacket143.h"
|
|
|
|
#include "Network/PacketWrappers/ActorControlPacket144.h"
|
|
|
|
#include "Network/PacketWrappers/MoveActorPacket.h"
|
2017-08-17 00:00:41 +02:00
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
#include "Network/PacketWrappers/PlayerStateFlagsPacket.h"
|
2017-08-17 00:00:41 +02:00
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
#include "DebugCommand/DebugCommandHandler.h"
|
2017-08-17 00:00:41 +02:00
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
#include "Actor/Player.h"
|
2017-08-17 00:00:41 +02:00
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
#include "Forwards.h"
|
2017-08-17 00:00:41 +02:00
|
|
|
|
2017-12-08 15:38:25 +01:00
|
|
|
#include "Action/Action.h"
|
|
|
|
#include "Action/ActionCast.h"
|
|
|
|
#include "Action/ActionMount.h"
|
|
|
|
#include "Script/ScriptManager.h"
|
2017-08-17 00:00:41 +02:00
|
|
|
|
|
|
|
|
2017-08-17 18:12:29 +02:00
|
|
|
extern Core::Scripting::ScriptManager g_scriptMgr;
|
2018-01-31 11:43:22 +01:00
|
|
|
extern Core::Data::ExdDataGenerated g_exdDataGen;
|
2017-08-17 18:12:29 +02:00
|
|
|
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,
|
2017-12-08 11:46:47 +01:00
|
|
|
Entity::Player& player )
|
2017-08-17 00:00:41 +02:00
|
|
|
{
|
2017-10-17 21:31:00 +02:00
|
|
|
uint8_t type = inPacket.getValAt< uint32_t >( 0x21 );
|
|
|
|
|
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
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
player.sendDebug( "Skill type:" + std::to_string( type ) );
|
2017-10-17 21:31:00 +02:00
|
|
|
|
|
|
|
switch( type )
|
|
|
|
{
|
|
|
|
case Common::SkillType::Normal:
|
|
|
|
|
2017-08-17 00:00:41 +02:00
|
|
|
if( action < 1000000 ) // normal action
|
|
|
|
{
|
|
|
|
std::string actionIdStr = boost::str( boost::format( "%|04X|" ) % action );
|
2017-12-08 11:46:47 +01:00
|
|
|
player.sendDebug( "---------------------------------------" );
|
|
|
|
player.sendDebug( "ActionHandler ( " + actionIdStr + " | " +
|
2018-02-14 12:31:47 +01:00
|
|
|
g_exdDataGen.get< Core::Data::Action >( action )->name +
|
2017-12-08 11:46:47 +01:00
|
|
|
" | " + std::to_string( targetId ) + " )" );
|
2017-08-17 00:00:41 +02:00
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
player.queuePacket( ActorControlPacket142( player.getId(), ActorControlType::ActionStart, 0x01, action ) );
|
2017-08-17 00:00:41 +02:00
|
|
|
|
|
|
|
if( action == 5 )
|
|
|
|
{
|
2017-12-08 11:46:47 +01:00
|
|
|
auto currentAction = player.getCurrentAction();
|
2017-08-17 00:00:41 +02:00
|
|
|
|
|
|
|
// we should always have an action here, if not there is a bug
|
|
|
|
assert( currentAction );
|
|
|
|
currentAction->onStart();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-02-22 15:31:10 +01:00
|
|
|
Core::Entity::ActorPtr targetActor = player.getAsPlayer();
|
2017-12-08 11:46:47 +01:00
|
|
|
if( targetId != player.getId() )
|
2017-08-17 00:00:41 +02:00
|
|
|
{
|
2017-12-08 11:46:47 +01:00
|
|
|
targetActor = player.lookupTargetById( targetId );
|
2017-08-17 00:00:41 +02:00
|
|
|
}
|
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
if( !player.actionHasCastTime( action ) )
|
2017-08-17 00:00:41 +02:00
|
|
|
{
|
2018-02-22 15:31:10 +01:00
|
|
|
g_scriptMgr.onCastFinish( player, targetActor->getAsChara(), action );
|
2017-08-17 00:00:41 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-02-22 15:31:10 +01:00
|
|
|
auto pActionCast = Action::make_ActionCast( player.getAsPlayer(), targetActor->getAsChara(), action );
|
2017-12-08 11:46:47 +01:00
|
|
|
player.setCurrentAction( pActionCast );
|
|
|
|
player.sendDebug( "setCurrentAction()" );
|
|
|
|
player.getCurrentAction()->onStart();
|
2017-08-17 00:00:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( action < 2000000 ) // craft action
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
else if( action < 3000000 ) // item action
|
|
|
|
{
|
2018-02-14 12:31:47 +01:00
|
|
|
auto info = g_exdDataGen.get< Core::Data::EventItem >( action );
|
2017-08-17 00:00:41 +02:00
|
|
|
if( info )
|
|
|
|
{
|
|
|
|
g_log.debug( info->name );
|
2018-01-31 11:43:22 +01:00
|
|
|
g_scriptMgr.onEventItem( player, action, info->quest, info->castTime, targetId );
|
2017-08-17 00:00:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if( action > 3000000 ) // unknown
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-10-17 21:31:00 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Common::SkillType::MountSkill:
|
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
player.sendDebug( "Request mount " + std::to_string( action ) );
|
2017-10-17 21:31:00 +02:00
|
|
|
|
2018-02-10 01:21:31 +01:00
|
|
|
auto pActionMount = Action::make_ActionMount( player.getAsPlayer(), action );
|
2017-12-08 11:46:47 +01:00
|
|
|
player.setCurrentAction( pActionMount );
|
|
|
|
player.sendDebug( "setCurrentAction()" );
|
|
|
|
player.getCurrentAction()->onStart();
|
2017-10-17 23:03:47 +02:00
|
|
|
|
2017-10-17 21:31:00 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-12-08 11:46:47 +01:00
|
|
|
}
|