uint32 Ship::FindAvailableModuleSlot( InventoryItemRef item ) { uint32 slotFound = flagIllegal; // 1) get slot bank (low, med, high, rig, subsystem) from dgmTypeEffects using item->itemID() // 2) query this ship's ModuleManager to determine if there are any free slots in that bank, // it should return a slot flag number for the next available slot starting at the lowest number // for that bank // 3) return that slot flag number if (item->type()->hasEffect(Effect_loPower)) { slotFound = m_ModuleManager->GetAvailableSlotInBank(Effect_loPower); } else if (item->type()->hasEffect(Effect_medPower)) { slotFound = m_ModuleManager->GetAvailableSlotInBank(Effect_medPower); } else if (item->type()->hasEffect(Effect_hiPower)) { slotFound = m_ModuleManager->GetAvailableSlotInBank(Effect_hiPower); } else if (item->type()->hasEffect(Effect_subSystem)) { slotFound = m_ModuleManager->GetAvailableSlotInBank(Effect_subSystem); } else if (item->type()->hasEffect(Effect_rigSlot)) { slotFound = m_ModuleManager->GetAvailableSlotInBank(Effect_rigSlot); } else { // ERROR: This is not a module that fits in any of the slot banks } return slotFound; }
NPC::NPC( SystemManager *system, PyServiceMgr &services, InventoryItemRef self, uint32 corporationID, uint32 allianceID, const GPoint &position, SpawnEntry *spawner) : DynamicSystemEntity(new DestinyManager(this, system), self), m_system(system), m_services(services), m_spawner(spawner), // m_itemID(self->itemID()), // m_typeID(self->typeID()), // m_ownerID(self->ownerID()), m_corporationID(corporationID), m_allianceID(allianceID), m_orbitingID(0) { //NOTE: this is bad if we inherit NPC! m_AI = new NPCAIMgr(this); // SET ALL ATTRIBUTES MISSING FROM DATABASE BEFORE USING THEM FOR ANYTHING: // Create default dynamic attributes in the AttributeMap: self->SetAttribute(AttrIsOnline, 1); // Is Online self->SetAttribute(AttrShieldCharge, self->GetAttribute(AttrShieldCapacity)); // Shield Charge self->SetAttribute(AttrArmorDamage, 0.0); // Armor Damage self->SetAttribute(AttrMass, self->type().attributes.mass()); // Mass self->SetAttribute(AttrRadius, self->type().attributes.radius()); // Radius self->SetAttribute(AttrVolume, self->type().attributes.volume()); // Volume self->SetAttribute(AttrCapacity, self->type().attributes.capacity()); // Capacity self->SetAttribute(AttrInertia, 1); // Inertia self->SetAttribute(AttrCharge, self->GetAttribute(AttrCapacitorCapacity)); // Set Capacitor Charge to the Capacitor Capacity self->SetAttribute(AttrShieldCharge, self->GetAttribute(AttrShieldCapacity)); // Shield Charge // Agility - WARNING! NO NPC Ships have Agility, so we're setting it to 1 for ALL NPC ships if( !(self->HasAttribute(AttrAgility)) ) self->SetAttribute(AttrAgility, 1 ); // Hull Damage if( !(self->HasAttribute(AttrDamage)) ) self->SetAttribute(AttrDamage, 0 ); // AttrHullEmDamageResonance if( !(self->HasAttribute(AttrHullEmDamageResonance)) ) self->SetAttribute(AttrHullEmDamageResonance, 0.0); // AttrHullExplosiveDamageResonance if( !(self->HasAttribute(AttrHullExplosiveDamageResonance)) ) self->SetAttribute(AttrHullExplosiveDamageResonance, 0.0); // AttrHullKineticDamageResonance if( !(self->HasAttribute(AttrHullKineticDamageResonance)) ) self->SetAttribute(AttrHullKineticDamageResonance, 0.0); // AttrHullThermalDamageResonance if( !(self->HasAttribute(AttrHullThermalDamageResonance)) ) self->SetAttribute(AttrHullThermalDamageResonance, 0.0); // AttrOrbitRange if( !(self->HasAttribute(AttrOrbitRange)) ) self->SetAttribute(AttrOrbitRange, 5000); // Set internal and Destiny values FROM these Attributes, now that they are all setup: m_destiny->SetPosition(position, false); m_destiny->SetShipCapabilities(self); m_destiny->SetSpeedFraction(1.0); m_destiny->Halt(); /* Gets the value from the NPC and put on our own vars */ //m_shieldCharge = self->shieldCharge(); m_shieldCharge = self->GetAttribute(AttrShieldCharge).get_float(); m_armorDamage = 0.0; m_hullDamage = 0.0; }
bool RamProxyService::_Calculate(const Call_InstallJob &args, InventoryItemRef installedItem, Client *const c, Rsp_InstallJob &into) { if(!m_db.GetAssemblyLineProperties(args.installationAssemblyLineID, into.materialMultiplier, into.timeMultiplier, into.installCost, into.usageCost)) return false; const ItemType *productType; // perform some activity-specific actions switch(args.activityID) { /* * Manufacturing */ case ramActivityManufacturing: { BlueprintRef bp = BlueprintRef::StaticCast( installedItem ); productType = &bp->productType(); into.productionTime = bp->type().productionTime(); into.materialMultiplier *= bp->materialMultiplier(); into.timeMultiplier *= bp->timeMultiplier(); into.charMaterialMultiplier = c->GetChar()->GetAttribute(AttrManufactureCostMultiplier).get_float(); into.charTimeMultiplier = c->GetChar()->GetAttribute(AttrManufactureTimeMultiplier).get_float(); switch(productType->race()) { case raceCaldari: into.charTimeMultiplier *= double(c->GetChar()->GetAttribute(AttrCaldariTechTimePercent).get_int()) / 100.0; break; case raceMinmatar: into.charTimeMultiplier *= double(c->GetChar()->GetAttribute(AttrMinmatarTechTimePercent).get_int()) / 100.0; break; case raceAmarr: into.charTimeMultiplier *= double(c->GetChar()->GetAttribute(AttrAmarrTechTimePercent).get_int()) / 100.0; break; case raceGallente: into.charTimeMultiplier *= double(c->GetChar()->GetAttribute(AttrGallenteTechTimePercent).get_int()) / 100.0; break; case raceJove: break; case racePirate: break; } break; } /* * Time productivity research */ case ramActivityResearchingTimeProductivity: { BlueprintRef bp = BlueprintRef::StaticCast( installedItem ); productType = &installedItem->type(); into.productionTime = bp->type().researchProductivityTime(); into.charMaterialMultiplier = double(c->GetChar()->GetAttribute(AttrResearchCostPercent).get_int()) / 100.0; into.charTimeMultiplier = c->GetChar()->GetAttribute(AttrManufacturingTimeResearchSpeed).get_float(); break; } /* * Material productivity research */ case ramActivityResearchingMaterialProductivity: { BlueprintRef bp = BlueprintRef::StaticCast( installedItem ); productType = &installedItem->type(); into.productionTime = bp->type().researchMaterialTime(); into.charMaterialMultiplier = double(c->GetChar()->GetAttribute(AttrResearchCostPercent).get_int()) / 100.0; into.charTimeMultiplier = c->GetChar()->GetAttribute(AttrMineralNeedResearchSpeed).get_float(); break; } /* * Copying */ case ramActivityCopying: { BlueprintRef bp = BlueprintRef::StaticCast( installedItem ); productType = &installedItem->type(); // no ceil() here on purpose into.productionTime = (bp->type().researchCopyTime() / bp->type().maxProductionLimit()) * args.licensedProductionRuns; into.charMaterialMultiplier = double(c->GetChar()->GetAttribute(AttrResearchCostPercent).get_int()) / 100.0; into.charTimeMultiplier = c->GetChar()->GetAttribute(AttrCopySpeedPercent).get_float(); break; } default: { productType = &installedItem->type(); into.charMaterialMultiplier = 1.0; into.charTimeMultiplier = 1.0; break; } } if(!m_db.MultiplyMultipliers(args.installationAssemblyLineID, productType->groupID(), into.materialMultiplier, into.timeMultiplier)) return false; // calculate the remaining things into.productionTime *= static_cast<int32>(into.timeMultiplier * into.charTimeMultiplier * args.runs); into.usageCost *= ceil(into.productionTime / 3600.0); into.cost = into.installCost + into.usageCost; // I "hope" this is right, simple tells client how soon will his job be started // Unfortunately, rounding done on client's side causes showing "Start time: 0 seconds" when he has to wait less than minute // I have no idea how to avoid this ... into.maxJobStartTime = m_db.GetNextFreeTime(args.installationAssemblyLineID); return true; }