Damage::Damage( SystemEntity *_source, InventoryItemRef _weapon, InventoryItemRef _charge, EVEEffectID _effect): source(_source), charge(_charge), effect(_effect) { if(_charge->HasAttribute(AttrKineticDamage)) kinetic = (_charge->GetAttribute(AttrKineticDamage) * _weapon->GetAttribute(AttrDamageMultiplier)).get_float(); else kinetic = 0.0; if(_charge->HasAttribute(AttrThermalDamage)) thermal = (_charge->GetAttribute(AttrThermalDamage) * _weapon->GetAttribute(AttrDamageMultiplier)).get_float(); else thermal = 0.0; if(_charge->HasAttribute(AttrEmDamage)) em = (_charge->GetAttribute(AttrEmDamage) * _weapon->GetAttribute(AttrDamageMultiplier)).get_float(); else em = 0.0; if(_charge->HasAttribute(AttrExplosiveDamage)) explosive = (_charge->GetAttribute(AttrExplosiveDamage) * _weapon->GetAttribute(AttrDamageMultiplier)).get_float(); else explosive = 0.0; weapon = _weapon; }
void Contract::GetItemRow( InventoryItemRef item, PyPackedRow* into ) const { into->SetField( "contractID", new PyInt( contractID() ) ); into->SetField( "itemID", new PyInt( item->itemID() ) ); into->SetField( "quantity", new PyInt( item->quantity() ) ); into->SetField( "itemTypeID", new PyInt( item->typeID() ) ); into->SetField( "inCrate", new PyBool( true ) ); if( item->categoryID() == EVEDB::invCategories::Blueprint ) { BlueprintRef bp = m_itemFactory.GetBlueprint( item->itemID() ); into->SetField( "parentID", new PyInt( bp->parentBlueprintTypeID() ) ); into->SetField( "productivityLevel", new PyInt( bp->productivityLevel() ) ); into->SetField( "materialLevel", new PyInt( bp->materialLevel() ) ); into->SetField( "copy", new PyInt( bp->copy() ) ); into->SetField( "licensedProductionRunsRemaining", new PyInt( bp->licensedProductionRunsRemaining() ) ); } else { into->SetField( "parentID", new PyInt( 0 ) ); into->SetField( "productivityLevel", new PyInt( 0 ) ); into->SetField( "materialLevel", new PyInt( 0 ) ); into->SetField( "copy", new PyInt( 0 ) ); into->SetField( "licensedProductionRunsRemaining", new PyInt( 0 ) ); } if( item->HasAttribute( AttrDamage ) ) into->SetField( "damage", new PyInt( item->GetAttribute( AttrDamage ).get_int() ) ); else into->SetField( "damage", new PyInt( 0 ) ); into->SetField( "flagID", new PyInt( item->flag() ) ); }
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; }
PyResult ContractMgrService::Handle_GetContract( PyCallArgs& call ) { Call_SingleIntegerArg arg; PyDict* _contract = new PyDict; if( !arg.Decode( &call.tuple ) ) { codelog(SERVICE__ERROR, "%s: Bad arguments to GetContract in contractMgr", call.client->GetCharacterName() ); return NULL; } // Manual creation of PyPackedRow DBRowDescriptor *header = new DBRowDescriptor(); header->AddColumn( "contractID", DBTYPE_I4 ); header->AddColumn( "issuerID", DBTYPE_I4 ); header->AddColumn( "issuerCorpID", DBTYPE_I4 ); header->AddColumn( "type", DBTYPE_UI1 ); header->AddColumn( "availability", DBTYPE_I4 ); header->AddColumn( "assigneeID", DBTYPE_I4 ); header->AddColumn( "numDays", DBTYPE_I4 ); header->AddColumn( "startStationID", DBTYPE_I4 ); header->AddColumn( "endStationID", DBTYPE_I4 ); header->AddColumn( "startSolarSystemID", DBTYPE_I4 ); header->AddColumn( "endSolarSystemID", DBTYPE_I4 ); header->AddColumn( "startRegionID", DBTYPE_I4 ); header->AddColumn( "endRegionID", DBTYPE_I4 ); header->AddColumn( "price", DBTYPE_CY ); header->AddColumn( "reward", DBTYPE_CY ); header->AddColumn( "collateral", DBTYPE_CY ); header->AddColumn( "title", DBTYPE_WSTR ); header->AddColumn( "description", DBTYPE_WSTR ); header->AddColumn( "forCorp", DBTYPE_BOOL ); header->AddColumn( "status", DBTYPE_UI1 ); header->AddColumn( "acceptorID", DBTYPE_I4 ); header->AddColumn( "dateIssued", DBTYPE_FILETIME ); header->AddColumn( "dateExpired", DBTYPE_FILETIME ); header->AddColumn( "dateAccepted", DBTYPE_FILETIME ); header->AddColumn( "dateCompleted", DBTYPE_FILETIME ); header->AddColumn( "volume", DBTYPE_R8 ); header->AddColumn( "issuerAllianceID", DBTYPE_I4 ); header->AddColumn( "issuerWalletKey", DBTYPE_I4 ); header->AddColumn( "acceptorWalletKey", DBTYPE_I4 ); header->AddColumn( "crateID", DBTYPE_I4 ); ContractRef contract = m_contractManager->GetContract( arg.arg ); uint32 n = 0; PyPackedRow* into = new PyPackedRow( header ); into->SetField( "contractID", new PyInt( contract->contractID() ) ); into->SetField( "issuerID", new PyInt( contract->issuerID() ) ); into->SetField( "issuerCorpID", new PyInt( contract->issuerCorpID() ) ); into->SetField( "type", new PyInt( contract->type() ) ); into->SetField( "availability", new PyInt( contract->avail() ) ); into->SetField( "assigneeID", new PyInt( contract->assigneeID() ) ); into->SetField( "numDays", new PyInt( 0 ) ); into->SetField( "startStationID", new PyInt( contract->startStationID() ) ); into->SetField( "endStationID", new PyInt( contract->endStationID() ) ); into->SetField( "startSolarSystemID", new PyInt( contract->startSolarSystemID() ) ); into->SetField( "endSolarSystemID", new PyInt( contract->endSolarSystemID() ) ); into->SetField( "startRegionID", new PyInt( contract->startRegionID() ) ); into->SetField( "endRegionID", new PyInt( contract->endRegionID() ) ); into->SetField( "price", new PyFloat( contract->price() ) ); into->SetField( "reward", new PyFloat( contract->reward() ) ); into->SetField( "collateral", new PyFloat( contract->collateral() ) ); into->SetField( "title", new PyString( "title" ) ); into->SetField( "description", new PyString( "description" ) ); into->SetField( "forCorp", new PyBool( contract->forCorp() ) ); into->SetField( "status", new PyInt( contract->status() ) ); into->SetField( "acceptorID", new PyInt( contract->acceptorID() ) ); into->SetField( "dateIssued", new PyLong( contract->dateIssued() ) ); into->SetField( "dateExpired", new PyLong( contract->dateExpired() ) ); into->SetField( "dateAccepted", new PyLong( contract->dateAccepted() ) ); into->SetField( "dateCompleted", new PyLong( contract->dateCompleted() ) ); into->SetField( "volume", new PyFloat( contract->volume() ) ); into->SetField( "issuerAllianceID", new PyInt( contract->issuerAllianceID() ) ); into->SetField( "issuerWalletKey", new PyInt( contract->issuerWalletKey() ) ); into->SetField( "acceptorWalletKey", new PyInt( 0 ) ); into->SetField( "crateID", new PyInt( 0 ) ); PyList* itemList = new PyList; DBRowDescriptor *itemHeader = new DBRowDescriptor(); itemHeader->AddColumn( "contractID", DBTYPE_I4 ); itemHeader->AddColumn( "itemID", DBTYPE_I4 ); itemHeader->AddColumn( "quantity", DBTYPE_I4 ); itemHeader->AddColumn( "itemTypeID", DBTYPE_I4 ); itemHeader->AddColumn( "inCrate", DBTYPE_BOOL ); itemHeader->AddColumn( "parentID", DBTYPE_I4 ); itemHeader->AddColumn( "productivityLevel", DBTYPE_I4 ); itemHeader->AddColumn( "materialLevel", DBTYPE_I4 ); itemHeader->AddColumn( "copy", DBTYPE_I4 ); itemHeader->AddColumn( "licensedProductionRunsRemaining", DBTYPE_I4 ); itemHeader->AddColumn( "damage", DBTYPE_R8 ); itemHeader->AddColumn( "flagID", DBTYPE_I2 ); std::map<uint32, ContractGetItemsRef>::const_iterator cur, end; std::map<uint32, ContractGetItemsRef> items = contract->items(); cur = items.begin(); end = items.end(); for(; cur != end; cur++ ) { PyPackedRow* data = new PyPackedRow( itemHeader ); InventoryItemRef item = m_manager->item_factory.GetItem( cur->second->m_itemID ); data->SetField( "contractID", new PyInt( contract->contractID() ) ); data->SetField( "itemID", new PyInt( item->itemID() ) ); data->SetField( "quantity", new PyInt( cur->second->m_quantity ) ); data->SetField( "itemTypeID", new PyInt( item->typeID() ) ); data->SetField( "inCrate", new PyBool( true ) ); if( item->categoryID() == EVEDB::invCategories::Blueprint ) { BlueprintRef bp = m_manager->item_factory.GetBlueprint( item->itemID() ); data->SetField( "parentID", new PyInt( bp->parentBlueprintTypeID() ) ); data->SetField( "productivityLevel", new PyInt( bp->productivityLevel() ) ); data->SetField( "materialLevel", new PyInt( bp->materialLevel() ) ); data->SetField( "copy", new PyInt( bp->copy() ) ); data->SetField( "licensedProductionRunsRemaining", new PyInt( bp->licensedProductionRunsRemaining() ) ); if( bp->HasAttribute( 3 ) ) data->SetField( "damage", new PyFloat( bp->GetAttribute( 3 ).get_float() ) ); else data->SetField( "damage", new PyFloat( 0.0 ) ); data->SetField( "flagID", new PyInt( bp->flag() ) ); } else { data->SetField( "parentID", new PyInt( 0 ) ); data->SetField( "productivityLevel", new PyInt( 0 ) ); data->SetField( "materialLevel", new PyInt( 0 ) ); data->SetField( "copy", new PyInt( 0 ) ); data->SetField( "licensedProductionRunsRemaining", new PyInt( 0 ) ); if( item->HasAttribute( 3 ) ) data->SetField( "damage", new PyFloat( item->GetAttribute( 3 ).get_float() ) ); else data->SetField( "damage", new PyFloat( 0.0 ) ); data->SetField( "flagID", new PyInt( item->flag() ) ); } itemList->AddItem( data ); } std::map<uint32, ContractRequestItemRef>::const_iterator c, e; std::map<uint32, ContractRequestItemRef> requestItems = contract->requestItems(); c = requestItems.begin(); e = requestItems.end(); for(; c != e; c++ ) { PyPackedRow* data = new PyPackedRow( itemHeader ); data->SetField( "contractID", new PyInt( arg.arg ) ); data->SetField( "itemID", new PyInt( 0 ) ); data->SetField( "quantity", new PyInt( c->second->m_quantity ) ); data->SetField( "itemTypeID", new PyInt( c->second->m_typeID ) ); data->SetField( "inCrate", new PyBool( false ) ); data->SetField( "parentID", new PyInt( 0 ) ); data->SetField( "productivityLevel", new PyInt( 0 ) ); data->SetField( "materialLevel", new PyInt( 0 ) ); data->SetField( "copy", new PyInt( 0 ) ); data->SetField( "licensedProductionRunsRemaining", new PyInt( 0 ) ); data->SetField( "damage", new PyFloat( 0.0 ) ); data->SetField( "flagID", new PyInt( 0 ) ); itemList->AddItem( data ); } DBRowDescriptor *bidsHeader = new DBRowDescriptor(); bidsHeader->AddColumn( "bidID", DBTYPE_I4 ); bidsHeader->AddColumn( "contractID", DBTYPE_I4 ); bidsHeader->AddColumn( "issuerID", DBTYPE_I4 ); bidsHeader->AddColumn( "quantity", DBTYPE_I4 ); bidsHeader->AddColumn( "issuerCorpID", DBTYPE_I4 ); bidsHeader->AddColumn( "issuerStationID", DBTYPE_I4 ); bidsHeader->AddColumn( "issuerSolarSystemID", DBTYPE_I4 ); bidsHeader->AddColumn( "issuerRegionID", DBTYPE_I4 ); CRowSet *bids_rowset = new CRowSet( &bidsHeader ); _contract->SetItemString( "items", itemList ); _contract->SetItemString( "bids", bids_rowset ); _contract->SetItemString( "contract", into); PyObject* res = new PyObject( new PyString( "util.KeyVal" ), _contract ); return res; }