Missile::Missile(const ShipType::Id &shipId, Body *owner, int power)//: Ship(shipId) { if (power < 0) { m_power = 0; if (shipId == ShipType::MISSILE_GUIDED) m_power = 1; if (shipId == ShipType::MISSILE_SMART) m_power = 2; if (shipId == ShipType::MISSILE_NAVAL) m_power = 3; } else m_power = power; m_owner = owner; m_type = &ShipType::types[shipId]; SetMass(m_type->hullMass*1000); SetModel(m_type->modelName.c_str()); SetMassDistributionFromModel(); SetLabel(Lang::MISSILE); Disarm(); SetFuel(1.0); SetFuelReserve(0.0); m_curAICmd = 0; m_aiMessage = AIERROR_NONE; m_decelerating = false; Propulsion::Init( this, GetModel(), m_type->fuelTankMass, m_type->effectiveExhaustVelocity, m_type->linThrust, m_type->angThrust ); }
void CargoBody::Init() { m_hitpoints = 1.0f; SetLabel(Equip::types[m_type].name); SetModel("cargo"); SetMassDistributionFromModel(); }
void Ship::Init() { // XXX the animation namespace must match that in LuaConstants // note: this must be set before generating the collision mesh // (which happens in SetModel()) and before rendering GetLmrObjParams().animationNamespace = "ShipAnimation"; GetLmrObjParams().equipment = &m_equipment; const ShipType &stype = GetShipType(); // Dirty hack: Always use gear-down mesh for collision detection // necessary because some ships have non-docking meshes too large for docking float temp = GetLmrObjParams().animValues[ANIM_WHEEL_STATE]; GetLmrObjParams().animValues[ANIM_WHEEL_STATE] = 1.0f; SetModel(stype.lmrModelName.c_str()); GetLmrObjParams().animValues[ANIM_WHEEL_STATE] = temp; SetMassDistributionFromModel(); UpdateStats(); m_stats.hull_mass_left = float(stype.hullMass); m_stats.shield_mass_left = 0; m_hyperspace.now = false; // TODO: move this on next savegame change, maybe m_hyperspaceCloud = 0; m_landingGearAnimation = 0; SceneGraph::Model *nmodel = dynamic_cast<SceneGraph::Model*>(GetModel()); if (nmodel) { m_landingGearAnimation = nmodel->FindAnimation("gear_down"); } }
void Ship::Init() { const ShipType &stype = GetShipType(); SetModel(stype.lmrModelName.c_str()); SetMassDistributionFromModel(); UpdateMass(); m_stats.hull_mass_left = float(stype.hullMass); m_stats.shield_mass_left = 0; }
void CargoBody::Init() { m_hitpoints = 1.0f; SetLabel(Equip::types[m_type].name); SetMassDistributionFromModel(); std::vector<Color4ub> colors; //metallic blue-orangeish color scheme colors.push_back(Color4ub(255, 198, 64)); colors.push_back(Color4ub(0, 222, 255)); colors.push_back(Color4ub(255, 255, 255)); GetModel()->SetColors(colors); }
void Ship::Init() { const ShipType &stype = GetShipType(); SetModel(stype.modelName.c_str()); SetMassDistributionFromModel(); UpdateStats(); m_stats.hull_mass_left = float(stype.hullMass); m_stats.shield_mass_left = 0; m_hyperspace.now = false; // TODO: move this on next savegame change, maybe m_hyperspaceCloud = 0; m_landingGearAnimation = GetModel()->FindAnimation("gear_down"); }
void CargoBody::Init() { m_hitpoints = 1.0f; SetLabel(Equip::types[m_type].name); SetMassDistributionFromModel(); std::vector<Color> colors; //metallic blue-orangeish color scheme colors.push_back(Color(255, 198, 64)); colors.push_back(Color(0, 222, 255)); colors.push_back(Color(255, 255, 255)); SceneGraph::ModelSkin skin; skin.SetColors(colors); skin.SetDecal("pioneer"); skin.Apply(GetModel()); GetModel()->SetColors(colors); Properties().Set("type", EnumStrings::GetString("EquipType", m_type)); }
void CargoBody::Init() { m_hitpoints = 1.0f; SetLabel(ScopedTable(m_cargo).CallMethod<std::string>("GetName")); SetMassDistributionFromModel(); m_hasSelfdestruct = true; std::vector<Color> colors; //metallic blue-orangeish color scheme colors.push_back(Color(255, 198, 64)); colors.push_back(Color(0, 222, 255)); colors.push_back(Color(255, 255, 255)); SceneGraph::ModelSkin skin; skin.SetColors(colors); skin.SetDecal("pioneer"); skin.Apply(GetModel()); GetModel()->SetColors(colors); Properties().Set("type", ScopedTable(m_cargo).CallMethod<std::string>("GetName")); }
void Ship::Init() { m_invulnerable = false; m_sensors.reset(new Sensors(this)); m_navLights.reset(new NavLights(GetModel())); m_navLights->SetEnabled(true); SetMassDistributionFromModel(); UpdateEquipStats(); m_stats.hull_mass_left = float(m_type->hullMass); m_stats.shield_mass_left = 0; PropertyMap &p = Properties(); p.Set("hullMassLeft", m_stats.hull_mass_left); p.Set("hullPercent", 100.0f * (m_stats.hull_mass_left / float(m_type->hullMass))); p.Set("shieldMassLeft", m_stats.shield_mass_left); p.Set("fuelMassLeft", m_stats.fuel_tank_mass_left); p.Set("shipName", m_shipName); m_hyperspace.now = false; // TODO: move this on next savegame change, maybe m_hyperspaceCloud = 0; m_landingGearAnimation = GetModel()->FindAnimation("gear_down"); InitGun("tag_gunmount_0", 0); InitGun("tag_gunmount_1", 1); // If we've got the tag_landing set then use it for an offset otherwise grab the AABB const SceneGraph::MatrixTransform *mt = GetModel()->FindTagByName("tag_landing"); if( mt ) { m_landingMinOffset = mt->GetTransform().GetTranslate().y; } else { m_landingMinOffset = GetAabb().min.y; } InitMaterials(); }