1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-29 07:37:45 +00:00

Merge pull request #28 from amibu01/master

Fix insta cast skills
This commit is contained in:
SapphireMordred 2017-08-11 00:05:40 +02:00 committed by GitHub
commit 3634ccdb4e
4 changed files with 41 additions and 10 deletions

View file

@ -346,6 +346,13 @@ bool Core::Data::ExdData::loadActionInfo()
uint16_t points_cost = getField< uint16_t >( fields, 31 );//29 uint16_t points_cost = getField< uint16_t >( fields, 31 );//29
bool is_instant = getField< bool >( fields, 35 ); bool is_instant = getField< bool >( fields, 35 );
uint8_t typeshift = 0x6;
uint8_t mask = 1 << typeshift;
is_instant &= mask;
bool final = ( is_instant & mask ) == mask;
is_instant = final;
uint16_t cast_time = getField< uint16_t >( fields, 36 ); uint16_t cast_time = getField< uint16_t >( fields, 36 );
uint16_t recast_time = getField< uint16_t >( fields, 37 ); uint16_t recast_time = getField< uint16_t >( fields, 37 );

View file

@ -74,21 +74,20 @@ void Core::Network::GameConnection::skillHandler( Core::Network::Packets::GamePa
} }
else else
{ {
Core::Entity::ActorPtr targetActor; Core::Entity::ActorPtr targetActor = pPlayer;
if( targetId != pPlayer->getId() )
auto inRange = pPlayer->getInRangeActors( true );
for( auto actor : inRange )
{ {
if( actor->getId() == targetId ) targetActor = pPlayer->lookupTargetById( targetId );
{
targetActor = actor;
}
} }
if( targetActor ) if( pPlayer->actionHasCastTime( action ) )
{
g_scriptMgr.onCastFinish( pPlayer, targetActor, action );
}
else
{ {
Action::ActionCastPtr pActionCast( new Action::ActionCast( pPlayer, targetActor, action ) ); Action::ActionCastPtr pActionCast( new Action::ActionCast( pPlayer, targetActor, action ) );
pPlayer->setCurrentAction(pActionCast); pPlayer->setCurrentAction( pActionCast );
pPlayer->sendDebug( "setCurrentAction()" ); pPlayer->sendDebug( "setCurrentAction()" );
pPlayer->getCurrentAction()->onStart(); pPlayer->getCurrentAction()->onStart();
} }

View file

@ -923,6 +923,20 @@ void Core::Entity::Player::despawn( Core::Entity::ActorPtr pTarget )
pPlayer->queuePacket( ActorControlPacket143( getId(), DespawnZoneScreenMsg, 0x04, getId(), 0x01 ) ); pPlayer->queuePacket( ActorControlPacket143( getId(), DespawnZoneScreenMsg, 0x04, getId(), 0x01 ) );
} }
Core::Entity::ActorPtr Core::Entity::Player::lookupTargetById( uint64_t targetId )
{
Core::Entity::ActorPtr targetActor;
auto inRange = getInRangeActors( true );
for( auto actor : inRange )
{
if( actor->getId() == targetId )
{
targetActor = actor;
}
}
return targetActor;
}
void Core::Entity::Player::setLastPing( uint32_t ping ) void Core::Entity::Player::setLastPing( uint32_t ping )
{ {
m_lastPing = ping; m_lastPing = ping;
@ -972,6 +986,11 @@ const uint8_t * Core::Entity::Player::getStateFlags() const
return m_stateFlags; return m_stateFlags;
} }
bool Core::Entity::Player::actionHasCastTime( uint32_t actionId ) //TODO: Add logic for special cases
{
return g_exdData.m_actionInfoMap[actionId].is_instant;
}
bool Core::Entity::Player::hasStateFlag( Core::Common::PlayerStateFlag flag ) const bool Core::Entity::Player::hasStateFlag( Core::Common::PlayerStateFlag flag ) const
{ {
int iFlag = static_cast< uint32_t >( flag ); int iFlag = static_cast< uint32_t >( flag );

View file

@ -452,6 +452,8 @@ public:
void sendUrgent( const std::string& message ); void sendUrgent( const std::string& message );
void sendDebug( const std::string& message ); void sendDebug( const std::string& message );
// Player Battle Handling
//////////////////////////////////////////////////////////////////////////////////////////////////////
void onMobAggro( BattleNpcPtr pBNpc ); void onMobAggro( BattleNpcPtr pBNpc );
void onMobDeaggro( BattleNpcPtr pBNpc ); void onMobDeaggro( BattleNpcPtr pBNpc );
@ -463,6 +465,10 @@ public:
void sendHateList(); void sendHateList();
bool actionHasCastTime( uint32_t actionId );
Core::Entity::ActorPtr lookupTargetById( uint64_t targetId );
bool isLogin() const; bool isLogin() const;
void setIsLogin( bool bIsLogin ); void setIsLogin( bool bIsLogin );