/** * Initializes a UFO of the specified type. * @param rules Pointer to ruleset. */ Ufo::Ufo(const RuleUfo *rules, bool createEscorts, int escortId) : MovingTarget(), _rules(rules), _id(0), _crashId(0), _landId(0), _damage(0), _direction("STR_NORTH"), _altitude("STR_HIGH_UC"), _status(FLYING), _secondsRemaining(0), _inBattlescape(false), _mission(0), _trajectory(0), _trajectoryPoint(0), _detected(false), _hyperDetected(false), _processedIntercept(false), _shootingAt(0), _hitFrame(0), _fireCountdown(0), _escapeCountdown(0), _stats(), _shield(-1), _shieldRechargeHandle(0), _tractorBeamSlowdown(0), _retreating(false), _escorting(nullptr), _escortId(escortId), _weapons() { _stats = rules->getStats(); for (const std::string &weaponType : rules->getWeapons()) { RuleCraftWeapon *weaponRule = Game::getMod()->getCraftWeapon(weaponType, true); _weapons.push_back(new CraftWeapon(weaponRule, weaponRule->getAmmoMax())); } if(createEscorts) { int escortId = 1; for (const std::string &escortType : rules->getEscorts()) { _escorts.push_back(new Ufo(Game::getMod()->getUfo(escortType, true), false, escortId)); ++escortId; } } }
ArticleStateCraftWeapon::ArticleStateCraftWeapon(ArticleDefinitionCraftWeapon *defs) : ArticleState(defs->id) { RuleCraftWeapon *weapon = _game->getMod()->getCraftWeapon(defs->id); // add screen elements _txtTitle = new Text(200, 32, 5, 24); // Set palette setPalette("PAL_BATTLEPEDIA"); ArticleState::initLayout(); // add other elements add(_txtTitle); // Set up objects _game->getMod()->getSurface(defs->image_id)->blit(_bg); _btnOk->setColor(Palette::blockOffset(1)); _btnPrev->setColor(Palette::blockOffset(1)); _btnNext->setColor(Palette::blockOffset(1)); _txtTitle->setColor(Palette::blockOffset(14)+15); _txtTitle->setBig(); _txtTitle->setWordWrap(true); _txtTitle->setText(tr(defs->title)); _txtInfo = new Text(310, 32, 5, 160); add(_txtInfo); _txtInfo->setColor(Palette::blockOffset(14)+15); _txtInfo->setWordWrap(true); _txtInfo->setText(tr(defs->text)); _lstInfo = new TextList(250, 111, 5, 80); add(_lstInfo); _lstInfo->setColor(Palette::blockOffset(14)+15); _lstInfo->setColumns(2, 180, 70); _lstInfo->setDot(true); _lstInfo->setBig(); _lstInfo->addRow(2, tr("STR_DAMAGE").c_str(), Text::formatNumber(weapon->getDamage()).c_str()); _lstInfo->setCellColor(0, 1, Palette::blockOffset(15)+4); _lstInfo->addRow(2, tr("STR_RANGE").c_str(), tr("STR_KILOMETERS").arg(weapon->getRange()).c_str()); _lstInfo->setCellColor(1, 1, Palette::blockOffset(15)+4); _lstInfo->addRow(2, tr("STR_ACCURACY").c_str(), Text::formatPercentage(weapon->getAccuracy()).c_str()); _lstInfo->setCellColor(2, 1, Palette::blockOffset(15)+4); _lstInfo->addRow(2, tr("STR_RE_LOAD_TIME").c_str(), tr("STR_SECONDS").arg(weapon->getStandardReload()).c_str()); _lstInfo->setCellColor(3, 1, Palette::blockOffset(15)+4); _lstInfo->addRow(2, tr("STR_ROUNDS").c_str(), Text::formatNumber(weapon->getAmmoMax()).c_str()); _lstInfo->setCellColor(4, 1, Palette::blockOffset(15)+4); centerAllSurfaces(); }