mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-03 09:17:47 +00:00
Keep cells active for 20 seconds even after all players left.
Also reset target and autoattack state on player on change zone.
This commit is contained in:
parent
4ceb771a16
commit
7580e12aad
5 changed files with 22 additions and 4 deletions
|
@ -511,7 +511,7 @@ void Sapphire::Entity::BNpc::doDefaultBNpcUpdate( uint64_t tickCount )
|
|||
|
||||
auto pHatedActor = hateListGetHighest();
|
||||
|
||||
while( pHatedActor && !pHatedActor->isAlive() )
|
||||
while( pHatedActor && ( !pHatedActor->isAlive() || getCurrentTerritory()->getGuId() != pHatedActor->getCurrentTerritory()->getGuId() ) )
|
||||
{
|
||||
hateListRemove( pHatedActor );
|
||||
pHatedActor = hateListGetHighest();
|
||||
|
|
|
@ -1871,6 +1871,10 @@ void Sapphire::Entity::Player::sendZonePackets()
|
|||
|
||||
sendInventory();
|
||||
|
||||
setTargetId( INVALID_GAME_OBJECT_ID64 );
|
||||
setStance( Common::Stance::Passive );
|
||||
setAutoattack( false );
|
||||
|
||||
if( isLogin() )
|
||||
{
|
||||
queuePacket( makeActorControlSelf( getId(), SetCharaGearParamUI, m_equipDisplayFlags, 1 ) );
|
||||
|
|
|
@ -102,3 +102,12 @@ void Sapphire::Cell::unload()
|
|||
removeActors();
|
||||
}
|
||||
|
||||
uint32_t Sapphire::Cell::getLastActiveTime() const
|
||||
{
|
||||
return m_lastActiveTime;
|
||||
}
|
||||
|
||||
void Sapphire::Cell::setLastActiveTime( uint32_t lastActiveTime )
|
||||
{
|
||||
m_lastActiveTime = lastActiveTime;
|
||||
}
|
|
@ -23,6 +23,7 @@ private:
|
|||
bool m_bActive;
|
||||
|
||||
uint16_t m_playerCount;
|
||||
uint32_t m_lastActiveTime;
|
||||
|
||||
public:
|
||||
Cell();
|
||||
|
@ -85,6 +86,9 @@ public:
|
|||
{
|
||||
return m_posY;
|
||||
}
|
||||
|
||||
uint32_t getLastActiveTime() const;
|
||||
void setLastActiveTime( uint32_t lastActiveTime );
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -539,6 +539,7 @@ bool Sapphire::Territory::isCellActive( uint32_t x, uint32_t y )
|
|||
uint32_t posY;
|
||||
|
||||
Cell* pCell;
|
||||
uint32_t time = Common::Util::getTimeSeconds();
|
||||
|
||||
for( posX = startX; posX <= endX; posX++ )
|
||||
{
|
||||
|
@ -546,7 +547,7 @@ bool Sapphire::Territory::isCellActive( uint32_t x, uint32_t y )
|
|||
{
|
||||
pCell = getCellPtr( posX, posY );
|
||||
|
||||
if( pCell && ( pCell->hasPlayers() || pCell->isForcedActive() ) )
|
||||
if( pCell && ( pCell->hasPlayers() || pCell->isForcedActive() || ( time - pCell->getLastActiveTime() ) < 20 ) )
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -577,13 +578,13 @@ void Sapphire::Territory::updateCellActivity( uint32_t x, uint32_t y, int32_t ra
|
|||
{
|
||||
pCell = create( posX, posY );
|
||||
pCell->init( posX, posY );
|
||||
|
||||
pCell->setActivity( true );
|
||||
|
||||
pCell->setLastActiveTime( Common::Util::getTimeSeconds() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pCell->setLastActiveTime( Common::Util::getTimeSeconds() );
|
||||
//Cell is now active
|
||||
if( isCellActive( posX, posY ) && !pCell->isActive() )
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue