mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-29 23:57:46 +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
e72fe535f6
commit
c7b50ca1e9
4 changed files with 22 additions and 3 deletions
|
@ -41,6 +41,10 @@ void MoveTerritoryTask::execute()
|
|||
if( !pPlayer )
|
||||
return;
|
||||
|
||||
pPlayer->setTargetId( 0 );
|
||||
pPlayer->setStance( Common::Stance::Passive );
|
||||
pPlayer->setAutoattack( false );
|
||||
|
||||
auto inRangePlayerIds = pPlayer->getInRangePlayerIds( true );
|
||||
|
||||
auto warpStart = makeActorControlSelf( pPlayer->getId(), WarpStart, m_warpInfo.m_warpType, 1, 0, m_warpInfo.m_targetTerritoryId, 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;
|
||||
}
|
|
@ -20,6 +20,7 @@ private:
|
|||
bool m_bActive;
|
||||
|
||||
uint16_t m_playerCount;
|
||||
uint32_t m_lastActiveTime;
|
||||
|
||||
public:
|
||||
Cell();
|
||||
|
@ -82,6 +83,9 @@ public:
|
|||
{
|
||||
return m_posY;
|
||||
}
|
||||
|
||||
uint32_t getLastActiveTime() const;
|
||||
void setLastActiveTime( uint32_t lastActiveTime );
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -528,6 +528,7 @@ bool Territory::isCellActive( uint32_t x, uint32_t y )
|
|||
uint32_t posY;
|
||||
|
||||
CellPtr pCell;
|
||||
uint32_t time = Common::Util::getTimeSeconds();
|
||||
|
||||
for( posX = startX; posX <= endX; posX++ )
|
||||
{
|
||||
|
@ -535,7 +536,7 @@ bool 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;
|
||||
}
|
||||
}
|
||||
|
@ -566,13 +567,13 @@ void Territory::updateCellActivity( uint32_t x, uint32_t y, int32_t radius )
|
|||
{
|
||||
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() )
|
||||
{
|
||||
|
@ -581,6 +582,7 @@ void Territory::updateCellActivity( uint32_t x, uint32_t y, int32_t radius )
|
|||
else if( !isCellActive( posX, posY ) && pCell->isActive() )
|
||||
pCell->setActivity( false );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue