void cTerritories::check( P_CHAR pc ) { cUOSocket* socket = NULL; if ( pc->objectType() == enPlayer ) socket = dynamic_cast<P_PLAYER>( pc )->socket(); cTerritory* currRegion = this->region( pc->pos().x, pc->pos().y, pc->pos().map ); cTerritory* lastRegion = pc->region(); if ( !currRegion ) return; if ( !lastRegion ) { pc->setRegion( currRegion ); return; } if ( currRegion != lastRegion ) { pc->setRegion( currRegion ); if ( socket ) { // If the last region was a cave or if the new region is a cave, // update the lightlevel. if ( ( currRegion->isCave() && !lastRegion->isCave() ) || ( !currRegion->isCave() && lastRegion->isCave() ) ) { socket->updateLightLevel(); } socket->playMusic(); } PyObject* args = Py_BuildValue( "(NNN)", PyGetCharObject( pc ), PyGetRegionObject( lastRegion ), PyGetRegionObject( currRegion ) ); if ( !pc->callEventHandler( EVENT_CHANGEREGION, args ) && socket ) { if ( lastRegion && !lastRegion->name().isEmpty() && !lastRegion->isNoEnterMessage() ) socket->sysMessage( tr( "You have left %1." ).arg( lastRegion->name() ) ); if ( currRegion && !currRegion->name().isEmpty() && !currRegion->isNoEnterMessage() ) socket->sysMessage( tr( "You have entered %1." ).arg( currRegion->name() ) ); if ( ( currRegion->isGuarded() != lastRegion->isGuarded() ) || ( currRegion->isGuarded() && ( currRegion->guardOwner() != lastRegion->guardOwner() ) ) ) { /* Guarded Setting Changes */ if ( currRegion->isGuarded() != lastRegion->isGuarded() ) { if ( lastRegion->isGuarded() && !lastRegion->isNoGuardMessage() ) { if ( lastRegion->guardOwner().isEmpty() ) socket->clilocMessage( 500113 ); // You have left the protection of the town guards. else socket->sysMessage( tr( "You have left the protection of %1 guards." ).arg( lastRegion->guardOwner() ) ); } if ( currRegion->isGuarded() && !currRegion->isNoGuardMessage() ) { if ( currRegion->guardOwner().isEmpty() ) socket->clilocMessage( 500112 ); // You are now under the protection of the town guards else socket->sysMessage( tr( "You are now under the protection of %1 guards." ).arg( currRegion->guardOwner() ) ); } } } /* Remain Guarded */ if ( currRegion->isGuarded() == lastRegion->isGuarded() ) { /* Only show if you haven't gotten a message before. Or, only show if the guard owner changes. */ if ( ( !currRegion->isNoGuardMessage() && !lastRegion->isNoGuardMessage() ) && ( currRegion->guardOwner() != lastRegion->guardOwner() ) ) { if ( currRegion->guardOwner().isEmpty() ) socket->clilocMessage( 500112 ); // You are now under the protection of the town guards else socket->sysMessage( tr( "You are now under the protection of %1 guards." ).arg( currRegion->guardOwner() ) ); } } } Py_DECREF( args ); } }
void cSkills::Snooping( P_PLAYER player, P_ITEM container ) { P_CHAR owner = container->getOutmostChar(); if ( !owner ) return; // Snooping into something thats not equipped?! PyObject *args = Py_BuildValue( "(NNN)", owner->getPyObject(), container->getPyObject(), player->getPyObject() ); // Event prfen if ( player->canHandleEvent( EVENT_SNOOPING ) ) { if ( player->callEventHandler( EVENT_SNOOPING, args ) ) { Py_DECREF( args ); return; } } if ( owner->canHandleEvent( EVENT_SNOOPING ) ) { if ( owner->callEventHandler( EVENT_SNOOPING, args ) ) { Py_DECREF( args ); return; } } Py_DECREF( args ); cUOSocket* socket = player->socket(); if ( !socket ) return; P_CHAR pc_owner = container->getOutmostChar(); P_PLAYER pp_owner = dynamic_cast<P_PLAYER>( pc_owner ); if ( pp_owner && pp_owner->isGMorCounselor() ) { pp_owner->message( tr( "%1 is trying to snoop in your pack" ).arg( player->name() ) ); socket->sysMessage( 500209 ); // You can not peek into the container. return; } else if ( player->checkSkill( SNOOPING, 0, 1000 ) ) { socket->sendContainer( container ); socket->sysMessage( tr( "You successfully peek into that container." ) ); } else { socket->sysMessage( 500210 ); // You failed to peek into the container. if ( !pp_owner ) // is NPC ? { if ( pc_owner ) { pc_owner->talk( tr( "Art thou attempting to disturb my privacy?" ) ); } } else { pp_owner->message( tr( "You notice %1 trying to peek into your pack!" ).arg( player->name() ) ); } } // SetTimerSec(player->objectdelay(), Config::instance()->objectDelay()+Config::instance()->snoopdelay()); player->setObjectDelay( Server::instance()->time() + ( Config::instance()->objectDelay() + Config::instance()->snoopdelay() ) * MY_CLOCKS_PER_SEC ); }