void NewGameState::_changeCharacter() { auto dude = _characters.at(_selectedCharacter); std::stringstream ss; auto msg = ResourceManager::msgFileType("text/english/game/stat.msg"); ss << msg->message(100)->text() << " " << (dude->stat(0) < 10 ? "0" : "") << dude->stat(0) << "\n" << msg->message(101)->text() << " " << (dude->stat(1) < 10 ? "0" : "") << dude->stat(1) << "\n" << msg->message(102)->text() << " " << (dude->stat(2) < 10 ? "0" : "") << dude->stat(2) << "\n" << msg->message(103)->text() << " " << (dude->stat(3) < 10 ? "0" : "") << dude->stat(3) << "\n" << msg->message(104)->text() << " " << (dude->stat(4) < 10 ? "0" : "") << dude->stat(4) << "\n" << msg->message(105)->text() << " " << (dude->stat(5) < 10 ? "0" : "") << dude->stat(5) << "\n" << msg->message(106)->text() << " " << (dude->stat(6) < 10 ? "0" : "") << dude->stat(6) << "\n"; getTextArea("stats_1")->setText(ss.str()); ss.str(""); ss << _statToString(dude->stat(0)) << "\n" << _statToString(dude->stat(1)) << "\n" << _statToString(dude->stat(2)) << "\n" << _statToString(dude->stat(3)) << "\n" << _statToString(dude->stat(4)) << "\n" << _statToString(dude->stat(5)) << "\n" << _statToString(dude->stat(6)) << "\n"; getTextArea("stats_2")->setText(ss.str()); getTextArea("bio")->setText(dude->biography()); getTextArea("name")->setText(dude->name()); getImageList("images")->setCurrentImage(_selectedCharacter); auto msgMisc = ResourceManager::msgFileType("text/english/game/misc.msg"); std::string stats3 = msgMisc->message(16)->text() + "\n" // Hit Points + msg->message(109)->text() + "\n" // Armor Class + msgMisc->message(15)->text() + "\n" // Action Points + msg->message(111)->text() + "\n"; // Melee Damage std::string stats3_values = std::to_string(dude->hitPointsMax()) + "/" + std::to_string(dude->hitPointsMax()) + "\n" + std::to_string(dude->armorClass()) + "\n" + std::to_string(dude->actionPoints()) + "\n" + std::to_string(dude->meleeDamage()) + "\n"; for (unsigned int i=0; i != 17; ++i) if (dude->skill(i)) { stats3 += "\n" + ResourceManager::msgFileType("text/english/game/skill.msg")->message(100 + i)->text(); stats3_values += "\n" + std::to_string(dude->skillValue(i)) + "%"; } for (unsigned int i=0; i != 16; ++i) if (dude->trait(i)) { stats3 += "\n" + ResourceManager::msgFileType("text/english/game/trait.msg")->message(100 + i)->text(); } getTextArea("stats_3")->setText(stats3); getTextArea("stats3_values")->setText(stats3_values); }
void cPlayer::talk( const QString& message, UI16 color, quint8 type, bool autospam, cUOSocket* socket ) { Q_UNUSED( autospam ); if ( color == 0xFFFF ) color = saycolor_; QByteArray lang; if ( socket_ ) lang = socket_->lang(); cUOTxUnicodeSpeech::eSpeechType speechType; // Lets try the Range of Speech unsigned int speechrange = Config::instance()->SpeechNormalRange(); switch ( type ) { case 0x01: speechType = cUOTxUnicodeSpeech::Broadcast; break; case 0x06: speechType = cUOTxUnicodeSpeech::System; break; case 0x09: speechType = cUOTxUnicodeSpeech::Yell; speechrange = Config::instance()->SpeechYellRange();; break; case 0x02: speechType = cUOTxUnicodeSpeech::Emote; break; case 0x08: speechType = cUOTxUnicodeSpeech::Whisper; speechrange = Config::instance()->SpeechWhisperRange();; break; case 0x0A: speechType = cUOTxUnicodeSpeech::Spell; break; default: speechType = cUOTxUnicodeSpeech::Regular; break; }; cUOTxUnicodeSpeech textSpeech; textSpeech.setSource( serial() ); textSpeech.setModel( body_ ); textSpeech.setFont( 3 ); // Default Font textSpeech.setType( speechType ); textSpeech.setLanguage( lang ); textSpeech.setName( name() ); textSpeech.setColor( color ); textSpeech.setText( message ); QString ghostSpeech; bool gmSpiritSpeak = skillValue( SPIRITSPEAK ) >= 1000; // Generate the ghost-speech *ONCE* if ( isDead() && !gmSpiritSpeak ) { for ( qint32 gI = 0; gI < message.length(); ++gI ) { if ( message[gI].isSpace() ) ghostSpeech.append( message[gI] ); else ghostSpeech.append( ( RandomNum( 0, 1 ) == 0 ) ? "o" : "O" ); } } if ( socket ) { // Take the dead-status into account if ( isDead() && !gmSpiritSpeak ) if ( !socket->player()->isDead() && !socket->player()->isGMorCounselor() && socket->player()->skillValue( SPIRITSPEAK ) < 1000 ) textSpeech.setText( ghostSpeech ); else textSpeech.setText( message ); socket->send( &textSpeech ); } else { // Send to all clients in range QList<cUOSocket*> sockets = Network::instance()->sockets(); foreach ( cUOSocket* mSock, sockets ) { if ( mSock->player() && ( mSock->player()->dist( this ) < speechrange ) ) { // Take the dead-status into account if ( isDead() && !gmSpiritSpeak ) if ( !mSock->player()->isDead() && !mSock->player()->isGMorCounselor() && mSock->player()->skillValue( SPIRITSPEAK ) < 1000 ) textSpeech.setText( ghostSpeech ); else textSpeech.setText( message ); mSock->send( &textSpeech ); } } } }
void PlayerCreateState::think() { State::think(); auto player = Game::getInstance()->player(); auto msgEditor = ResourceManager::msgFileType("text/english/game/editor.msg"); _labels.at("name")->setText(player->name()); _labels.at("age")->setText(msgEditor->message(104))->appendText(" ")->appendText(std::to_string(player->age())); _labels.at("gender")->setText(msgEditor->message(player->gender() == 0 ? 107 : 108)); // 0 - male 1 - female _counters.at("statsPoints")->setNumber(player->statsPoints()); _counters.at("skillsPoints")->setNumber(player->skillsPoints()); _labels.at("health_1")->setText(msgEditor->message(300))->appendText(" ")->appendText(std::to_string(player->hitPointsMax()))->appendText("/")->appendText(std::to_string(player->hitPointsMax())); _labels.at("params_1_value")->setText(player->armorClass()); _labels.at("params_2_value")->setText(player->actionPoints()); _labels.at("params_3_value")->setText(player->carryWeightMax()); _labels.at("params_4_value")->setText(player->meleeDamage()); _labels.at("params_5_value")->setText(player->damageResistance())->appendText("%"); _labels.at("params_6_value")->setText(player->poisonResistance())->appendText("%"); _labels.at("params_7_value")->setText(player->radiationResistance())->appendText("%"); _labels.at("params_8_value")->setText(player->sequence()); _labels.at("params_9_value")->setText(player->healingRate()); _labels.at("params_10_value")->setText(player->criticalChance())->appendText("%"); // Stats counters and labels for (unsigned int i = 0; i < 7; i++) { std::stringstream ss; ss << "stats_" << (i+1); unsigned int val = player->statTotal(i); _counters.at(ss.str())->setNumber(val); _counters.at(ss.str())->setColor(BigCounter::COLOR_WHITE); if (val > 10) { val = 10; _counters.at(ss.str())->setColor(BigCounter::COLOR_RED); } _labels.at(ss.str())->setText(msgEditor->message(199 + (val < 1 ? 1 : val))); } // Skills values for (unsigned int i = 0; i != 18; ++i) { std::stringstream ss; ss << "skills_" << (i + 1) << "_value"; _labels.at(ss.str())->setText(player->skillValue(i))->appendText("%"); } // Default labels colors for(auto it = _labels.begin(); it != _labels.end(); ++it) { std::string name = it->first; auto font1_3ff800ff = ResourceManager::font("font1.aaf", 0x3ff800ff); auto font1_a0a0a0ff = ResourceManager::font("font1.aaf", 0xa0a0a0ff); auto font1_183018ff = ResourceManager::font("font1.aaf", 0x183018ff); if (name.find("stats_") == 0 || name.find("params_") == 0) { it->second->setFont(font1_3ff800ff); } if (name.find("traits_") == 0) { unsigned int number = atoi(name.substr(7).c_str()); it->second->setFont(player->trait(number - 1) ? font1_a0a0a0ff : font1_3ff800ff); } if (name.find("skills_") == 0) { unsigned int number = atoi(name.substr(7).c_str()); it->second->setFont(player->skill(number - 1) ? font1_a0a0a0ff : font1_3ff800ff); } if (name.find("health_") == 0) { it->second->setFont(name.compare("health_1") == 0 ? font1_3ff800ff : font1_183018ff); } } // Selected labels colors for(auto it = _labels.begin(); it != _labels.end(); ++it) { if (_selectedLabel != it->second) continue; std::string name = it->first; _title->setText(_titles.at(name)); _description->setText(_descriptions.at(name)); _selectedImage->setTexture(_images.at(name)->texture()); auto font1_ffff7fff = ResourceManager::font("font1.aaf", 0xffff7fff); auto font1_ffffffff = ResourceManager::font("font1.aaf", 0xffffffff); auto font1_707820ff = ResourceManager::font("font1.aaf", 0x707820ff); if (name.find("stats_") == 0) { it->second->setFont(font1_ffff7fff); } if (name.find("params_") == 0) { it->second->setFont(font1_ffff7fff); _labels.at(name+"_value")->setFont(font1_ffff7fff); } if (name.find("traits_") == 0) { unsigned int number = atoi(name.substr(7).c_str()); it->second->setFont(player->trait(number - 1) ? font1_ffffffff : font1_ffff7fff); } if (name.find("skills_") == 0) { unsigned int number = atoi(name.substr(7).c_str()); it->second->setFont(player->skill(number - 1) ? font1_ffffffff : font1_ffff7fff); _labels.at(name+"_value")->setFont(player->skill(number - 1) ? font1_ffffffff : font1_ffff7fff); } if (name.find("health_") == 0) { it->second->setFont(name.compare("health_1") == 0 ? font1_ffff7fff : font1_707820ff); } } }