mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-28 07:07:45 +00:00
Some refactoring and TODO tags
This commit is contained in:
parent
0474a6f9ce
commit
69a7076e36
4 changed files with 62 additions and 63 deletions
|
@ -54,6 +54,7 @@ Core::Entity::BattleNpc::BattleNpc( uint32_t modelId, uint32_t nameid, const Com
|
||||||
m_type = ActorType::BattleNpc;
|
m_type = ActorType::BattleNpc;
|
||||||
|
|
||||||
m_mode = MODE_IDLE;
|
m_mode = MODE_IDLE;
|
||||||
|
m_targetId = INVALID_GAME_OBJECT_ID;
|
||||||
|
|
||||||
m_maxHp = 150;
|
m_maxHp = 150;
|
||||||
m_maxMp = 100;
|
m_maxMp = 100;
|
||||||
|
@ -229,7 +230,7 @@ void Core::Entity::BattleNpc::setOwner( Core::Entity::PlayerPtr pPlayer )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GamePacketNew< FFXIVIpcActorOwner, ServerZoneIpcType > setOwnerPacket(getId(), INVALID_GAME_OBJECT_ID);
|
GamePacketNew< FFXIVIpcActorOwner, ServerZoneIpcType > setOwnerPacket(getId(), INVALID_GAME_OBJECT_ID );
|
||||||
setOwnerPacket.data().type = 0x01;
|
setOwnerPacket.data().type = 0x01;
|
||||||
setOwnerPacket.data().actorId = INVALID_GAME_OBJECT_ID;
|
setOwnerPacket.data().actorId = INVALID_GAME_OBJECT_ID;
|
||||||
sendToInRangeSet( setOwnerPacket );
|
sendToInRangeSet( setOwnerPacket );
|
||||||
|
@ -251,15 +252,15 @@ bool Core::Entity::BattleNpc::moveTo( Common::FFXIVARR_POSITION3& pos )
|
||||||
// reached destination
|
// reached destination
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
float rot = Math::Util::calcAngFrom(getPos().x, getPos().z, pos.x, pos.z);
|
float rot = Math::Util::calcAngFrom( getPos().x, getPos().z, pos.x, pos.z );
|
||||||
float newRot = PI - rot + (PI / 2);
|
float newRot = PI - rot + (PI / 2);
|
||||||
|
|
||||||
face( pos );
|
face( pos );
|
||||||
float angle = Math::Util::calcAngFrom( getPos().x, getPos().z, pos.x, pos.z ) + PI;
|
float angle = Math::Util::calcAngFrom( getPos().x, getPos().z, pos.x, pos.z ) + PI;
|
||||||
|
|
||||||
float x = static_cast< float >( cosf(angle) * 1.1f );
|
float x = static_cast< float >( cosf( angle ) * 1.1f );
|
||||||
float y = ( getPos().y + pos.y ) * 0.5f; // fake value while there is no collision
|
float y = ( getPos().y + pos.y ) * 0.5f; // fake value while there is no collision
|
||||||
float z = static_cast< float >( sinf(angle) * 1.1f );
|
float z = static_cast< float >( sinf( angle ) * 1.1f );
|
||||||
|
|
||||||
Common::FFXIVARR_POSITION3 newPos;
|
Common::FFXIVARR_POSITION3 newPos;
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,6 @@ uint32_t CalcBattle::calculateMaxMp( PlayerPtr pPlayer )
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32_t CalcBattle::calculateHealValue( PlayerPtr pPlayer, uint32_t potency )
|
uint32_t CalcBattle::calculateHealValue( PlayerPtr pPlayer, uint32_t potency )
|
||||||
{
|
{
|
||||||
auto classInfoIt = g_exdData.m_classJobInfoMap.find( pPlayer->getClass() );
|
auto classInfoIt = g_exdData.m_classJobInfoMap.find( pPlayer->getClass() );
|
||||||
|
|
|
@ -192,7 +192,7 @@ void Core::Entity::Player::prepareZoning( uint16_t targetZone, bool fadeOut, uin
|
||||||
preparePacket.data().targetZone = targetZone;
|
preparePacket.data().targetZone = targetZone;
|
||||||
preparePacket.data().fadeOutTime = fadeOutTime;
|
preparePacket.data().fadeOutTime = fadeOutTime;
|
||||||
preparePacket.data().animation = animation;
|
preparePacket.data().animation = animation;
|
||||||
preparePacket.data().fadeOut = fadeOut == true ? 1 : 0;
|
preparePacket.data().fadeOut = static_cast< uint8_t >( fadeOut ? 1 : 0 );
|
||||||
queuePacket( preparePacket );
|
queuePacket( preparePacket );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -398,7 +398,7 @@ void Core::Entity::Player::setZone( uint32_t zoneId )
|
||||||
if( isLogin() )
|
if( isLogin() )
|
||||||
{
|
{
|
||||||
GamePacketNew< FFXIVIpcCFAvailableContents, ServerZoneIpcType > contentFinderList( getId() );
|
GamePacketNew< FFXIVIpcCFAvailableContents, ServerZoneIpcType > contentFinderList( getId() );
|
||||||
for( auto i = 0; i < 72; i++ )
|
for( auto i = 0; i < sizeof( contentFinderList.data().contents ); i++ )
|
||||||
{
|
{
|
||||||
// unlock all contents for now
|
// unlock all contents for now
|
||||||
contentFinderList.data().contents[i] = 0xFF;
|
contentFinderList.data().contents[i] = 0xFF;
|
||||||
|
@ -632,7 +632,9 @@ void Core::Entity::Player::gainExp( uint32_t amount )
|
||||||
if( ( currentExp + amount ) >= neededExpToLevel )
|
if( ( currentExp + amount ) >= neededExpToLevel )
|
||||||
{
|
{
|
||||||
// levelup
|
// levelup
|
||||||
amount = ( currentExp + amount - neededExpToLevel ) > neededExpToLevelplus1 ? neededExpToLevelplus1 - 1 : ( currentExp + amount - neededExpToLevel );
|
amount = ( currentExp + amount - neededExpToLevel ) > neededExpToLevelplus1 ?
|
||||||
|
neededExpToLevelplus1 - 1 :
|
||||||
|
( currentExp + amount - neededExpToLevel );
|
||||||
setExp( amount );
|
setExp( amount );
|
||||||
gainLevel();
|
gainLevel();
|
||||||
queuePacket( ActorControlPacket143( getId(), UpdateUiExp, static_cast< uint8_t >( getClass() ), amount ) );
|
queuePacket( ActorControlPacket143( getId(), UpdateUiExp, static_cast< uint8_t >( getClass() ), amount ) );
|
||||||
|
@ -791,50 +793,6 @@ void Core::Entity::Player::setLevelForClass( uint8_t level, Core::Common::ClassJ
|
||||||
setSyncFlag( PlayerSyncFlags::ExpLevel );
|
setSyncFlag( PlayerSyncFlags::ExpLevel );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Entity::Player::eventActionStart( uint32_t eventId,
|
|
||||||
uint32_t action,
|
|
||||||
ActionCallback finishCallback,
|
|
||||||
ActionCallback interruptCallback,
|
|
||||||
uint64_t additional )
|
|
||||||
{
|
|
||||||
Action::ActionPtr pEventAction( new Action::EventAction( shared_from_this(), eventId, action,
|
|
||||||
finishCallback, interruptCallback, additional ) );
|
|
||||||
|
|
||||||
setCurrentAction( pEventAction );
|
|
||||||
auto pEvent = getEvent( eventId );
|
|
||||||
|
|
||||||
if( !pEvent && getEventCount() )
|
|
||||||
{
|
|
||||||
// We're trying to play a nested event, need to start it first.
|
|
||||||
eventStart( getId(), eventId, Event::Event::Nest, 0, 0 );
|
|
||||||
pEvent = getEvent( eventId );
|
|
||||||
}
|
|
||||||
else if( !pEvent )
|
|
||||||
{
|
|
||||||
g_log.error( "Could not find event " + std::to_string( eventId ) + ", event has not been started!" );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( pEvent )
|
|
||||||
pEvent->setPlayedScene( true );
|
|
||||||
pEventAction->onStart();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Core::Entity::Player::eventItemActionStart( uint32_t eventId,
|
|
||||||
uint32_t action,
|
|
||||||
ActionCallback finishCallback,
|
|
||||||
ActionCallback interruptCallback,
|
|
||||||
uint64_t additional )
|
|
||||||
{
|
|
||||||
Action::ActionPtr pEventItemAction( new Action::EventItemAction( shared_from_this(), eventId, action,
|
|
||||||
finishCallback, interruptCallback, additional ) );
|
|
||||||
|
|
||||||
setCurrentAction( pEventItemAction );
|
|
||||||
|
|
||||||
pEventItemAction->onStart();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Core::Entity::Player::sendModel()
|
void Core::Entity::Player::sendModel()
|
||||||
{
|
{
|
||||||
ModelEquipPacket modelEquip( getAsPlayer() );
|
ModelEquipPacket modelEquip( getAsPlayer() );
|
||||||
|
@ -973,7 +931,7 @@ void Core::Entity::Player::setGcRankAt( uint8_t index, uint8_t rank )
|
||||||
setSyncFlag( PlayerSyncFlags::GC );
|
setSyncFlag( PlayerSyncFlags::GC );
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint8_t * Core::Entity::Player::getStateFlags() const
|
const uint8_t* Core::Entity::Player::getStateFlags() const
|
||||||
{
|
{
|
||||||
return m_stateFlags;
|
return m_stateFlags;
|
||||||
}
|
}
|
||||||
|
@ -1086,21 +1044,16 @@ void Core::Entity::Player::update( int64_t currTime )
|
||||||
|
|
||||||
m_lastUpdate = currTime;
|
m_lastUpdate = currTime;
|
||||||
|
|
||||||
// @TODO needs to happen in a if check. Don't want autoattacking while an action is being performed.
|
|
||||||
if( !checkAction() )
|
if( !checkAction() )
|
||||||
{
|
{
|
||||||
if( m_targetId )
|
if( m_targetId && m_currentStance == Entity::Actor::Stance::Active && isAutoattackOn() )
|
||||||
{
|
{
|
||||||
auto mainWeap = m_pInventory->getItemAt( Inventory::GearSet0, Inventory::EquipSlot::MainHand );
|
auto mainWeap = m_pInventory->getItemAt( Inventory::GearSet0, Inventory::EquipSlot::MainHand );
|
||||||
|
|
||||||
|
// @TODO i dislike this, iterating over all in range actors when you already know the id of the actor you need...
|
||||||
for( auto actor : m_inRangeActors )
|
for( auto actor : m_inRangeActors )
|
||||||
{
|
{
|
||||||
if( isAutoattackOn() &&
|
if( actor->getId() == m_targetId && actor->isAlive() && mainWeap )
|
||||||
actor->getId() == m_targetId &&
|
|
||||||
actor->isAlive() &&
|
|
||||||
mainWeap &&
|
|
||||||
m_currentStance == Entity::Actor::Stance::Active
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
// default autoattack range
|
// default autoattack range
|
||||||
// TODO make this dependant on bnpc size
|
// TODO make this dependant on bnpc size
|
||||||
|
@ -1644,9 +1597,7 @@ uint32_t Core::Entity::Player::getCFPenaltyMinutes() const
|
||||||
|
|
||||||
// check if penalty timestamp already passed current time
|
// check if penalty timestamp already passed current time
|
||||||
if (currentTimestamp > endTimestamp)
|
if (currentTimestamp > endTimestamp)
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
auto deltaTime = endTimestamp - currentTimestamp;
|
auto deltaTime = endTimestamp - currentTimestamp;
|
||||||
return static_cast< uint32_t > ( ceil( static_cast< float > (deltaTime) / 60 ) );
|
return static_cast< uint32_t > ( ceil( static_cast< float > (deltaTime) / 60 ) );
|
||||||
|
|
|
@ -18,6 +18,10 @@
|
||||||
#include "src/servers/Server_Zone/Network/PacketWrappers/EventPlayPacket.h"
|
#include "src/servers/Server_Zone/Network/PacketWrappers/EventPlayPacket.h"
|
||||||
#include "src/servers/Server_Zone/Network/PacketWrappers/EventFinishPacket.h"
|
#include "src/servers/Server_Zone/Network/PacketWrappers/EventFinishPacket.h"
|
||||||
|
|
||||||
|
#include "src/servers/Server_Zone/Action/EventAction.h"
|
||||||
|
#include "src/servers/Server_Zone/Action/EventItemAction.h"
|
||||||
|
|
||||||
|
#include "src/servers/Server_Zone/Event/Event.h"
|
||||||
#include "src/servers/Server_Zone/Event/Event.h"
|
#include "src/servers/Server_Zone/Event/Event.h"
|
||||||
#include "Server_Zone/ServerZone.h"
|
#include "Server_Zone/ServerZone.h"
|
||||||
|
|
||||||
|
@ -230,6 +234,50 @@ void Core::Entity::Player::eventFinish( uint32_t eventId, uint32_t freePlayer )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Core::Entity::Player::eventActionStart( uint32_t eventId,
|
||||||
|
uint32_t action,
|
||||||
|
ActionCallback finishCallback,
|
||||||
|
ActionCallback interruptCallback,
|
||||||
|
uint64_t additional )
|
||||||
|
{
|
||||||
|
Action::ActionPtr pEventAction( new Action::EventAction( shared_from_this(), eventId, action,
|
||||||
|
finishCallback, interruptCallback, additional ) );
|
||||||
|
|
||||||
|
setCurrentAction( pEventAction );
|
||||||
|
auto pEvent = getEvent( eventId );
|
||||||
|
|
||||||
|
if( !pEvent && getEventCount() )
|
||||||
|
{
|
||||||
|
// We're trying to play a nested event, need to start it first.
|
||||||
|
eventStart( getId(), eventId, Event::Event::Nest, 0, 0 );
|
||||||
|
pEvent = getEvent( eventId );
|
||||||
|
}
|
||||||
|
else if( !pEvent )
|
||||||
|
{
|
||||||
|
g_log.error( "Could not find event " + std::to_string( eventId ) + ", event has not been started!" );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( pEvent )
|
||||||
|
pEvent->setPlayedScene( true );
|
||||||
|
pEventAction->onStart();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Core::Entity::Player::eventItemActionStart( uint32_t eventId,
|
||||||
|
uint32_t action,
|
||||||
|
ActionCallback finishCallback,
|
||||||
|
ActionCallback interruptCallback,
|
||||||
|
uint64_t additional )
|
||||||
|
{
|
||||||
|
Action::ActionPtr pEventItemAction( new Action::EventItemAction( shared_from_this(), eventId, action,
|
||||||
|
finishCallback, interruptCallback, additional ) );
|
||||||
|
|
||||||
|
setCurrentAction( pEventItemAction );
|
||||||
|
|
||||||
|
pEventItemAction->onStart();
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void Core::Entity::Player::onLogin()
|
void Core::Entity::Player::onLogin()
|
||||||
|
|
Loading…
Add table
Reference in a new issue