bool InputSpeech( cUOSocket* socket, P_PLAYER pChar, const QString& speech ) { if ( pChar->inputMode() == cPlayer::enNone ) return false; P_ITEM pItem = FindItemBySerial( pChar->inputItem() ); if ( !pItem ) return false; //bool ok = false; //Q_INT32 num = speech.toInt( &ok ); // Generally try to convert it QString notification; switch ( pChar->inputMode() ) { // Pricing an item - PlayerVendors case cPlayer::enPricing: socket->sysMessage( "Ops, sorry not implemented" ); pChar->setInputMode( cPlayer::enDescription ); socket->sysMessage( tr( "Enter a description for this item." ) ); break; // Describing an item case cPlayer::enDescription: socket->sysMessage( "Description is not used anywhere :( not implemented right now" ); socket->sysMessage( tr( "This item is now described as %1." ).arg( speech ) ); pChar->setInputMode( cPlayer::enNone ); pChar->setInputItem( INVALID_SERIAL ); break; // Renaming ourself case cPlayer::enNameDeed: pChar->setName( speech ); socket->sysMessage( tr( "Your new name is: %1" ).arg( speech ) ); pChar->setInputMode( cPlayer::enNone ); pChar->setInputItem( INVALID_SERIAL ); break; // Renaming a house sign case cPlayer::enHouseSign: pItem->setName( speech ); socket->sysMessage( tr( "Your house has been renamed to: %1" ).arg( speech ) ); pChar->setInputMode( cPlayer::enNone ); pChar->setInputItem( INVALID_SERIAL ); break; default: break; // do nothing } return true; }
void Human_Stablemaster::handleTargetInput( P_PLAYER player, cUORxTarget* target ) { if ( !player ) return; P_ITEM pPack = m_npc->getBankbox(); if ( !pPack ) return; P_NPC pPet = dynamic_cast<P_NPC>( World::instance()->findChar( target->serial() ) ); if ( !pPet ) { m_npc->talk( tr( "I cannot stable that!" ) ); return; } if ( pPet->owner() != player ) { m_npc->talk( tr( "This does not belong to you!" ) ); return; } // we spawn a worldgem in the stablemasters bankbox for the pet // it does only hold the serial of it, the serial of the owner and the // number of refresh signals since begin of stabling // the pet becomes "free", which means, that it isnt in the world // but will still be saved. P_ITEM pGem = new cItem(); pGem->Init( true ); pGem->setTag( "player", cVariant( player->serial() ) ); pGem->setTag( "pet", cVariant( pPet->serial() ) ); pGem->setId( 0x1ea7 ); pGem->setName( tr( "petitem: %1" ).arg( pPet->name() ) ); pGem->setVisible( 2 ); // gm visible pPack->addItem( pGem ); pGem->update(); //pPet->free = true; MapObjects::instance()->remove( pPet ); pPet->setStablemasterSerial( this->m_npc->serial() ); pPet->removeFromView(); // we need this for db saves m_npc->talk( tr( "Say release to get your pet back!" ) ); }
bool InputSpeech( cUOSocket *socket, P_PLAYER pChar, const QString &speech ) { if( pChar->inputMode() == cPlayer::enNone ) return false; P_ITEM pItem = FindItemBySerial( pChar->inputItem() ); if( !pItem ) return false; bool ok; INT32 num = speech.toInt( &ok ); // Generally try to convert it QString notification; switch (pChar->inputMode()) { // Pricing an item - PlayerVendors case cPlayer::enPricing: if (ok) { pItem->setPrice( num ); socket->sysMessage( tr( "This item's price has been set to %1." ).arg( num ) ); } else socket->sysMessage( tr( "You have to enter a numeric price" ) ); pChar->setInputMode(cPlayer::enDescription); socket->sysMessage( tr( "Enter a description for this item." ) ); break; // Describing an item case cPlayer::enDescription: pItem->setDescription( speech ); socket->sysMessage( tr( "This item is now described as %1." ).arg( speech ) ); pChar->setInputMode(cPlayer::enNone); pChar->setInputItem(INVALID_SERIAL); break; // Renaming a rune case cPlayer::enRenameRune: pItem->setName( tr( "Rune to: %1" ).arg( speech ) ); socket->sysMessage( tr( "Rune renamed to: Rune to: %1" ).arg( speech ) ); pChar->setInputMode(cPlayer::enNone); pChar->setInputItem(INVALID_SERIAL); break; // Renaming ourself case cPlayer::enNameDeed: pChar->setName( speech ); socket->sysMessage( tr( "Your new name is: %1" ).arg( speech ) ); pChar->setInputMode(cPlayer::enNone); pChar->setInputItem(INVALID_SERIAL); break; // Renaming a house sign case cPlayer::enHouseSign: pItem->setName( speech ); socket->sysMessage( tr( "Your house has been renamed to: %1" ).arg( speech ) ); pChar->setInputMode(cPlayer::enNone); pChar->setInputItem(INVALID_SERIAL); break; // Paging a GM case cPlayer::enPageGM: { cPage* pPage = new cPage( pChar->serial(), PT_GM, speech, pChar->pos() ); cPagesManager::getInstance()->push_back( pPage ); notification = tr( "GM Page from %1: %2" ).arg( pChar->name() ).arg( speech ); for ( cUOSocket *mSock = cNetwork::instance()->first(); mSock; mSock = cNetwork::instance()->next()) if( mSock->player() && mSock->player()->isGM() ) mSock->sysMessage( notification ); if( cNetwork::instance()->count() > 0 ) socket->sysMessage( tr( "Available Game Masters have been notified of your request." ) ); else socket->sysMessage( tr( "There was no Game Master available, page queued." ) ); pChar->setInputMode(cPlayer::enNone); } break; // Paging a Counselor case cPlayer::enPageCouns: { cPage* pPage = new cPage( pChar->serial(), PT_COUNSELOR, speech, pChar->pos() ); cPagesManager::getInstance()->push_back( pPage ); notification = tr( "Counselor Page from %1: %2" ).arg( pChar->name() ).arg( speech ); for ( cUOSocket *mSock = cNetwork::instance()->first(); mSock; mSock = cNetwork::instance()->next()) if( mSock->player() && (socket->player()->isCounselor() || socket->player()->isGM()) ) mSock->sysMessage( notification ); if( cNetwork::instance()->count() > 0 ) socket->sysMessage( tr( "Available Counselors have been notified of your request." ) ); else socket->sysMessage( tr( "There was no Counselor available, page queued." ) ); pChar->setInputMode(cPlayer::enNone); } break; default: break; // do nothing } return true; }