1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-29 15:47:46 +00:00

Merge branch 'master'

This commit is contained in:
Maru 2017-10-01 21:52:00 -03:00
commit 5c23d1a6f3
16 changed files with 143 additions and 127 deletions

View file

@ -34,7 +34,7 @@ class OpeningGridaniaDef
def Scene00000( player ) def Scene00000( player )
{ {
player.eventPlay( this.id, 0, 0x2001, 0, 1, player.eventPlay( this.id, 0, 0x04AC05, 0, 1,
fun( player, eventId, param1, param2, param3 ) fun( player, eventId, param1, param2, param3 )
{ {
player.setOpeningSequence( 1 ); player.setOpeningSequence( 1 );

View file

@ -72,7 +72,6 @@ class OpeningLimsaLominsaDef
player.eventPlay( this.id, 40, 1, 2, 1, player.eventPlay( this.id, 40, 1, 2, 1,
fun( player, eventId, param1, param2, param3 ) fun( player, eventId, param1, param2, param3 )
{ {
player.eventFinish( eventId, UNLOCK );
if( player.getOpeningSequence() == 2 ) if( player.getOpeningSequence() == 2 )
{ {
// update the instance boundaries // update the instance boundaries

View file

@ -35,7 +35,7 @@ class OpeningUldahDef
def Scene00000( player ) def Scene00000( player )
{ {
player.eventPlay( this.id, 0, 0x2001, 0, 1, player.eventPlay( this.id, 0, 0x04AC05, 0, 1,
fun( player, eventId, param1, param2, param3 ) fun( player, eventId, param1, param2, param3 )
{ {
player.setOpeningSequence( 1 ); player.setOpeningSequence( 1 );

View file

@ -74,7 +74,6 @@ class ManFst003Def
def checkQuestCompletion( player, varIdx ) def checkQuestCompletion( player, varIdx )
{ {
print( varIdx );
if (varIdx == 3) if (varIdx == 3)
{ {
player.questMessage(this.id, 1, 0, 0, 0 ); player.questMessage(this.id, 1, 0, 0, 0 );
@ -118,8 +117,8 @@ class ManFst003Def
player.eventPlay( this.id, 1, 0x0EFB/*flags*/, 0/*unk*/, 0/*unk*/, player.eventPlay( this.id, 1, 0x0EFB/*flags*/, 0/*unk*/, 0/*unk*/,
fun( player, eventId, param1, param2, param3 ) fun( player, eventId, param1, param2, param3 )
{ {
player.setQuestUI8AL( ManFst004.id, 1 ); player.setQuestUI8AL( ManFst003.id, 1 );
ManFst003.checkQuestCompletion( player, 1 ); ManFst003.checkQuestCompletion( player, 0 );
}); });
} }
@ -128,7 +127,7 @@ class ManFst003Def
player.eventPlay( this.id, 2, 0, 0, 0, player.eventPlay( this.id, 2, 0, 0, 0,
fun( player, eventId, param1, param2, param3 ) fun( player, eventId, param1, param2, param3 )
{ {
player.setQuestUI8BH( ManFst004.id, 1 ); player.setQuestUI8BH( ManFst003.id, 1 );
ManFst003.checkQuestCompletion( player, 3 ); ManFst003.checkQuestCompletion( player, 3 );
}); });
} }
@ -207,8 +206,8 @@ class ManFst003Def
player.eventPlay( this.id, 100, 0x0EFB, 0, 0, player.eventPlay( this.id, 100, 0x0EFB, 0, 0,
fun( player, eventId, param1, param2, param3 ) fun( player, eventId, param1, param2, param3 )
{ {
player.setQuestUI8CH( ManFst004.id, 0 ); // remove key item, since we have just traded it player.setQuestUI8CH( ManFst003.id, 0 ); // remove key item, since we have just traded it
player.setQuestUI8BL( ManFst004.id, 1 ); player.setQuestUI8BL( ManFst003.id, 1 );
ManFst003.checkQuestCompletion(player, 2 ); ManFst003.checkQuestCompletion(player, 2 );
}); });
} }
@ -237,7 +236,6 @@ class ManFst003Def
}, },
fun( player, eventId, additional ) {}, fun( player, eventId, additional ) {},
eventId ); eventId );
player.unlock();
} }
else if( actor == this.ACTOR2 ) else if( actor == this.ACTOR2 )
{ {
@ -257,4 +255,3 @@ class ManFst003Def
}; };
GLOBAL ManFst003 = ManFst003Def(); GLOBAL ManFst003 = ManFst003Def();

View file

@ -51,11 +51,12 @@ class ManSea001Def
// Available Scenes in this quest, not necessarly all are used // Available Scenes in this quest, not necessarly all are used
def Scene00000( player ) def Scene00000( player )
{ {
player.eventPlay( this.id, 0, HIDE_HOTBAR, 0/*unk*/, 0/*unk*/, player.eventPlay( this.id, 0, 0x2000, 0, 0,
fun( player, eventId, param1, param2, param3 ) fun( player, eventId, param1, param2, param3 )
{ {
if( param2 == 1 ) if( param2 == 1 )
{ {
player.setOpeningSequence( 2 );
ManSea001.Scene00001( player ); ManSea001.Scene00001( player );
} }
}); });
@ -63,7 +64,7 @@ class ManSea001Def
def Scene00001( player ) def Scene00001( player )
{ {
player.eventPlay( this.id, 1, HIDE_HOTBAR, 0/*unk*/, 0/*unk*/, player.eventPlay( this.id, 1, 0xF8482EFB, 0, 0,
fun( player, eventId, param1, param2, param3 ) fun( player, eventId, param1, param2, param3 )
{ {
ManSea001.Scene00002( player ); ManSea001.Scene00002( player );
@ -81,13 +82,13 @@ class ManSea001Def
def Scene00003( player ) def Scene00003( player )
{ {
player.eventPlay( this.id, 3, NONE, 0/*unk*/, 0/*unk*/, player.eventPlay( this.id, 3, NONE, 0, 0,
fun( player, eventId, param1, param2, param3 ) fun( player, eventId, param1, param2, param3 )
{ {
player.questUpdate( ManSea001.id, 0x01 ); // add quest to player. player.questUpdate( ManSea001.id, 0x01 ); // add quest to player.
// update the instance boundaries, call to the opening event // update the instance boundaries, call to the opening event
//player.eventPlay( ManSea001.OPENING_EVENT_HANDLER, 0x1E, HIDE_HOTBAR, 1, 0); player.eventPlay( ManSea001.OPENING_EVENT_HANDLER, 0x1E, 0x2001, 1, 0);
}); });
} }
@ -107,7 +108,7 @@ class ManSea001Def
def Scene00006( player ) def Scene00006( player )
{ {
player.eventPlay( this.id, 6, NONE, 0/*unk*/, 0/*unk*/, player.eventPlay( this.id, 6, 0x20, 0/*unk*/, 0/*unk*/,
fun( player, eventId, param1, param2, param3 ) fun( player, eventId, param1, param2, param3 )
{ {
if( param2 == 1 ) if( param2 == 1 )
@ -141,7 +142,7 @@ class ManSea001Def
def Scene00011( player ) def Scene00011( player )
{ {
player.eventPlay( this.id, 11, NONE, 0, 0, player.eventPlay( this.id, 11, 0x2c02, 0, 0,
fun( player, eventId, param1, param2, param3 ) fun( player, eventId, param1, param2, param3 )
{ {
ManSea001.Scene00012( player ); ManSea001.Scene00012( player );
@ -150,7 +151,7 @@ class ManSea001Def
def Scene00012( player ) def Scene00012( player )
{ {
player.eventPlay( this.id, 12, NONE, 0, 0, player.eventPlay( this.id, 12, 0x20, 0, 0,
fun( player, eventId, param1, param2, param3 ) fun( player, eventId, param1, param2, param3 )
{ {
if( param2 == 1 ) if( param2 == 1 )

View file

@ -49,11 +49,12 @@ class ManWil001Def
// Available Scenes in this quest, not necessarly all are used // Available Scenes in this quest, not necessarly all are used
def Scene00000( player ) def Scene00000( player )
{ {
player.eventPlay( this.id, 0, 0, 0, 0, player.eventPlay( this.id, 0, 0x2000, 0, 0,
fun( player, eventId, param1, param2, param3 ) fun( player, eventId, param1, param2, param3 )
{ {
if( param2 == 1 ) // accept quest if( param2 == 1 ) // accept quest
{ {
player.setOpeningSequence( 2 );
ManWil001.Scene00001( player ); ManWil001.Scene00001( player );
} }
}); });
@ -61,7 +62,7 @@ class ManWil001Def
def Scene00001( player ) def Scene00001( player )
{ {
player.eventPlay( this.id, 1, 0, 0, 0, player.eventPlay( this.id, 1, 0xF8482EFB, 0, 0,
fun( player, eventId, param1, param2, param3 ) fun( player, eventId, param1, param2, param3 )
{ {
ManWil001.Scene00002( player ); ManWil001.Scene00002( player );
@ -70,10 +71,10 @@ class ManWil001Def
def Scene00002( player ) def Scene00002( player )
{ {
player.eventPlay( this.id, 2, 0, 0, 0, player.eventPlay( this.id, 2, NONE, 0, 0,
fun( player, eventId, param1, param2, param3 ) fun( player, eventId, param1, param2, param3 )
{ {
player.questUpdate( ManWil001.id, ManWil001Obj.SEQ_FINISH );// add quest to player. player.questUpdate( ManWil001.id, ManWil001.SEQ_FINISH );// add quest to player.
player.eventPlay( ManWil001.OPENING_EVENT_HANDLER, 0x1E, 0x2001, 0, 0 ); player.eventPlay( ManWil001.OPENING_EVENT_HANDLER, 0x1E, 0x2001, 0, 0 );
}); });
} }
@ -85,7 +86,7 @@ class ManWil001Def
def Scene00004( player ) def Scene00004( player )
{ {
player.eventPlay( this.id, 4, 0, 0, 0, player.eventPlay( this.id, 4, 0x2c02, 0, 0,
fun( player, eventId, param1, param2, param3 ) fun( player, eventId, param1, param2, param3 )
{ {
ManWil001.Scene00005( player ); ManWil001.Scene00005( player );
@ -94,7 +95,7 @@ class ManWil001Def
def Scene00005( player ) def Scene00005( player )
{ {
player.eventPlay( this.id, 5, 0/*flags*/, 0/*unk*/, 0/*unk*/, player.eventPlay( this.id, 5, 0x20/*flags*/, 0/*unk*/, 0/*unk*/,
fun( player, eventId, param1, param2, param3 ) fun( player, eventId, param1, param2, param3 )
{ {
if( param2 == 1 ) // clicked finish button if( param2 == 1 ) // clicked finish button

View file

@ -636,6 +636,7 @@ namespace Core {
enum struct PlayerStateFlag : uint8_t enum struct PlayerStateFlag : uint8_t
{ {
SomeFlag,
NoCombat, NoCombat,
Combat, Combat,
Casting, Casting,
@ -643,9 +644,9 @@ namespace Core {
StatusAffliction1, StatusAffliction1,
Occupied, Occupied,
Occupied1, Occupied1,
Occupied2, Occupied2,
Occupied3, Occupied3,
BoundByDuty, BoundByDuty,
Occupied4, Occupied4,
DuelingArea, DuelingArea,
@ -656,6 +657,7 @@ namespace Core {
PreparingToCraft, PreparingToCraft,
Gathering, Gathering,
Fishing, Fishing,
BeingRaised, BeingRaised,
BetweenAreas, BetweenAreas,
Stealthed, Stealthed,
@ -666,9 +668,9 @@ namespace Core {
BetweenAreas1, BetweenAreas1,
SystemError, SystemError,
LoggingOut, LoggingOut,
InvalidLocation, InvalidLocation,
WaitingForDuty, WaitingForDuty,
BoundByDuty1, BoundByDuty1,
Mounting, Mounting,
WatchingCutscene, WatchingCutscene,
@ -686,9 +688,9 @@ namespace Core {
FreeTrail, FreeTrail,
BeingMoved, BeingMoved,
Mounting2, Mounting2,
StatusAffliction3, StatusAffliction3,
StatusAffliction4, StatusAffliction4,
RegisteringRaceOrMatch, RegisteringRaceOrMatch,
WaitingForRaceOrMatch, WaitingForRaceOrMatch,
WaitingForTripleTriadMatch, WaitingForTripleTriadMatch,

View file

@ -345,7 +345,6 @@ bool Core::Data::ExdData::loadActionInfo()
uint8_t points_type = getField< uint8_t >( fields, 30 ); // 30 uint8_t points_type = getField< uint8_t >( fields, 30 ); // 30
uint16_t points_cost = getField< uint16_t >( fields, 31 ); // 31 uint16_t points_cost = getField< uint16_t >( fields, 31 ); // 31
bool is_instant = getField< bool >( fields, 35 ); // 35 bool is_instant = getField< bool >( fields, 35 ); // 35
uint16_t cast_time = getField< uint16_t >( fields, 36 ); // 36 uint16_t cast_time = getField< uint16_t >( fields, 36 ); // 36
uint16_t recast_time = getField< uint16_t >( fields, 37 ); // 37 uint16_t recast_time = getField< uint16_t >( fields, 37 ); // 37

View file

@ -57,13 +57,13 @@ std::string Core::Entity::Actor::getName() const
/*! \return true if the actor is of type player */ /*! \return true if the actor is of type player */
bool Core::Entity::Actor::isPlayer() const bool Core::Entity::Actor::isPlayer() const
{ {
return ( m_type == ActorType::Player ? true : false ); return m_type == ActorType::Player;
} }
/*! \return true if the actor is of type mob */ /*! \return true if the actor is of type mob */
bool Core::Entity::Actor::isMob() const bool Core::Entity::Actor::isMob() const
{ {
return ( m_type == ActorType::BattleNpc ? true : false ); return m_type == ActorType::BattleNpc;
} }
/*! \return list of actors currently in range */ /*! \return list of actors currently in range */
@ -244,10 +244,7 @@ bool Core::Entity::Actor::face( const Common::FFXIVARR_POSITION3& p )
setRotation( newRot ); setRotation( newRot );
if( oldRot != newRot ) return oldRot != newRot ? true : false;
return true;
return false;
} }
/*! /*!
@ -762,7 +759,8 @@ void Core::Entity::Actor::addStatusEffect( StatusEffect::StatusEffectPtr pEffect
/*! \param StatusEffectPtr to be applied to the actor */ /*! \param StatusEffectPtr to be applied to the actor */
void Core::Entity::Actor::addStatusEffectById( uint32_t id, int32_t duration, Entity::Actor& pSource, uint16_t param ) void Core::Entity::Actor::addStatusEffectById( uint32_t id, int32_t duration, Entity::Actor& pSource, uint16_t param )
{ {
StatusEffect::StatusEffectPtr effect( new StatusEffect::StatusEffect( id, pSource.shared_from_this(), shared_from_this(), duration, 3000 ) ); StatusEffect::StatusEffectPtr effect( new StatusEffect::StatusEffect( id, pSource.shared_from_this(),
shared_from_this(), duration, 3000 ) );
effect->setParam( param ); effect->setParam( param );
addStatusEffect( effect ); addStatusEffect( effect );
} }
@ -772,7 +770,8 @@ void Core::Entity::Actor::addStatusEffectByIdIfNotExist( uint32_t id, int32_t du
{ {
if( !m_pStatusEffectContainer->hasStatusEffect( id ) ) if( !m_pStatusEffectContainer->hasStatusEffect( id ) )
{ {
StatusEffect::StatusEffectPtr effect( new StatusEffect::StatusEffect( id, pSource.shared_from_this(), shared_from_this(), duration, 3000 ) ); StatusEffect::StatusEffectPtr effect( new StatusEffect::StatusEffect( id, pSource.shared_from_this(),
shared_from_this(), duration, 3000 ) );
effect->setParam( param ); effect->setParam( param );
addStatusEffect( effect ); addStatusEffect( effect );
} }

View file

@ -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;

View file

@ -104,7 +104,7 @@ private:
uint32_t m_unk2; uint32_t m_unk2;
std::set< HateListEntry* > m_hateList; std::set< HateListEntry* > m_hateList;
ActorPtr m_pOwner; ActorPtr m_pOwner;
int32_t m_timeOfDeath; uint32_t m_timeOfDeath;
uint32_t m_mobType; uint32_t m_mobType;
}; };

View file

@ -111,7 +111,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() );

View file

@ -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
@ -1536,9 +1489,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 ) );

View file

@ -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()

View file

@ -41,7 +41,8 @@ Core::LinkshellMgr g_linkshellMgr;
Core::ServerZone::ServerZone( const std::string& configPath, uint16_t serverId ) Core::ServerZone::ServerZone( const std::string& configPath, uint16_t serverId )
: m_configPath( configPath ) : m_configPath( configPath ),
m_bRunning( true )
{ {
m_pConfig = XMLConfigPtr( new XMLConfig ); m_pConfig = XMLConfigPtr( new XMLConfig );
} }
@ -224,18 +225,32 @@ void Core::ServerZone::run( int32_t argc, char* argv[] )
g_scriptMgr.init(); g_scriptMgr.init();
std::vector< std::thread > thread_list; std::vector< std::thread > thread_list;
thread_list.push_back( std::thread( std::bind( &Network::Hive::Run, hive.get() ) ) ); thread_list.emplace_back( std::thread( std::bind( &Network::Hive::Run, hive.get() ) ) );
g_log.info( "Server listening on port: " + std::to_string( m_port ) ); g_log.info( "Server listening on port: " + std::to_string( m_port ) );
g_log.info( "Ready for connections..." ); g_log.info( "Ready for connections..." );
while( true ) mainLoop();
for( auto& thread_entry : thread_list )
{ {
std::this_thread::sleep_for( std::chrono::milliseconds( 50 ) ); thread_entry.join();
}
}
void Core::ServerZone::mainLoop()
{
while( isRunning() )
{
this_thread::sleep_for( chrono::milliseconds( 50 ) );
g_zoneMgr.updateZones(); g_zoneMgr.updateZones();
std::lock_guard<std::mutex> lock( m_sessionMutex );
for( auto sessionIt : m_sessionMap ) auto currTime = static_cast< uint32_t >( time( nullptr ) );
lock_guard< std::mutex > lock( this->m_sessionMutex );
for( auto sessionIt : this->m_sessionMap )
{ {
auto session = sessionIt.second; auto session = sessionIt.second;
if( session && session->getPlayer() ) if( session && session->getPlayer() )
@ -247,9 +262,9 @@ void Core::ServerZone::run( int32_t argc, char* argv[] )
} }
} }
uint32_t currTime = static_cast< uint32_t >( time( nullptr ) );
auto it = m_sessionMap.begin(); auto it = this->m_sessionMap.begin();
for( ; it != m_sessionMap.end(); ) for( ; it != this->m_sessionMap.end(); )
{ {
uint32_t diff = currTime - it->second->getLastDataTime(); uint32_t diff = currTime - it->second->getLastDataTime();
@ -257,11 +272,11 @@ void Core::ServerZone::run( int32_t argc, char* argv[] )
if( diff > 20 ) if( diff > 20 )
{ {
g_log.info( "[" + std::to_string( it->second->getId() ) + "] Session time out" ); g_log.info("[" + std::to_string(it->second->getId() ) + "] Session time out" );
it->second->close(); it->second->close();
// if( it->second.unique() ) // if( it->second.unique() )
{ {
it = m_sessionMap.erase( it ); it = this->m_sessionMap.erase(it );
} }
} }
else else
@ -272,13 +287,6 @@ void Core::ServerZone::run( int32_t argc, char* argv[] )
} }
} }
// currently never reached, need a "stopServer" variable to break out of the above while loop
/*for( auto& thread_entry : thread_list )
{
thread_entry.join();
}*/
} }
bool Core::ServerZone::createSession( uint32_t sessionId ) bool Core::ServerZone::createSession( uint32_t sessionId )
@ -364,3 +372,8 @@ void Core::ServerZone::updateSession( std::string playerName )
it->second->loadPlayer(); it->second->loadPlayer();
} }
bool Core::ServerZone::isRunning() const
{
return m_bRunning;
}

View file

@ -40,12 +40,18 @@ namespace Core {
Entity::BattleNpcTemplatePtr getBnpcTemplate( std::string templateName ); Entity::BattleNpcTemplatePtr getBnpcTemplate( std::string templateName );
void mainLoop();
bool isRunning() const;
private: private:
uint16_t m_port; uint16_t m_port;
std::string m_ip; std::string m_ip;
bool m_bRunning;
std::string m_configPath; std::string m_configPath;
XMLConfigPtr m_pConfig; XMLConfigPtr m_pConfig;