本文整理汇总了C++中InventoryItemRef::GetAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ InventoryItemRef::GetAttribute方法的具体用法?C++ InventoryItemRef::GetAttribute怎么用?C++ InventoryItemRef::GetAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InventoryItemRef
的用法示例。
在下文中一共展示了InventoryItemRef::GetAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: source
Damage::Damage(
SystemEntity *_source,
InventoryItemRef _weapon,
EVEEffectID _effect): source(_source), charge(), effect(_effect)
{
if(_weapon->HasAttribute(AttrKineticDamage))
kinetic = _weapon->GetAttribute(AttrKineticDamage).get_float();
else
kinetic = 0.0;
if(_weapon->HasAttribute(AttrThermalDamage))
thermal = _weapon->GetAttribute(AttrThermalDamage).get_float();
else
thermal = 0.0;
if(_weapon->HasAttribute(AttrEmDamage))
em = _weapon->GetAttribute(AttrEmDamage).get_float();
else
em = 0.0;
if(_weapon->HasAttribute(AttrExplosiveDamage))
explosive = _weapon->GetAttribute(AttrExplosiveDamage).get_float();
else
explosive = 0.0;
weapon = _weapon;
}
示例2: ValidateItemSpecifics
bool Ship::ValidateItemSpecifics(InventoryItemRef equip) {
//declaring explicitly as int...not sure if this is needed or not
int groupID = m_pOperator->GetShip()->groupID();
int typeID = m_pOperator->GetShip()->typeID();
EvilNumber canFitShipGroup1 = equip->GetAttribute(AttrCanFitShipGroup1);
EvilNumber canFitShipGroup2 = equip->GetAttribute(AttrCanFitShipGroup2);
EvilNumber canFitShipGroup3 = equip->GetAttribute(AttrCanFitShipGroup3);
EvilNumber canFitShipGroup4 = equip->GetAttribute(AttrCanFitShipGroup4);
EvilNumber canFitShipType1 = equip->GetAttribute(AttrCanFitShipType1);
EvilNumber canFitShipType2 = equip->GetAttribute(AttrCanFitShipType2);
EvilNumber canFitShipType3 = equip->GetAttribute(AttrCanFitShipType3);
EvilNumber canFitShipType4 = equip->GetAttribute(AttrCanFitShipType4);
if( canFitShipGroup1 != 0 || canFitShipGroup2 != 0 || canFitShipGroup3 != 0 || canFitShipGroup4 != 0 )
if( canFitShipGroup1 != groupID && canFitShipGroup2 != groupID && canFitShipGroup3 != groupID && canFitShipGroup4 != groupID )
return false;
/*
if( canFitShipGroup1 != 0 )
if( canFitShipGroup1 != groupID )
return false;
if( canFitShipGroup2 != 0 )
if( canFitShipGroup2 != groupID )
return false;
if( canFitShipGroup3 != 0 )
if( canFitShipGroup3 != groupID )
return false;
if( canFitShipGroup4 != 0 )
if( canFitShipGroup4 != groupID )
return false;
*/
if( canFitShipType1 != 0 || canFitShipType2 != 0 || canFitShipType3 != 0 || canFitShipType4 != 0 )
if( canFitShipType1 != typeID && canFitShipType2 != typeID && canFitShipType3 != typeID && canFitShipType4 != typeID )
return false;
/*
if( canFitShipType1 != 0 )
if( canFitShipType1 != typeID )
return false;
if( canFitShipType2 != 0 )
if( canFitShipType2 != typeID )
return false;
if( canFitShipType3 != 0 )
if( canFitShipType3 != typeID )
return false;
if( canFitShipType4 != 0 )
if( canFitShipType4 != typeID )
return false;
*/
return true;
}
示例3: ValidateAddItem
/*
* InventoryEx
*/
void InventoryEx::ValidateAddItem(EVEItemFlags flag, InventoryItemRef item) const
{
//double volume = item->quantity() * item->volume();
EvilNumber volume = item->GetAttribute(AttrQuantity) * item->GetAttribute(AttrVolume);
double capacity = GetRemainingCapacity( flag );
if( volume > capacity )
{
std::map<std::string, PyRep *> args;
args["available"] = new PyFloat( capacity );
args["volume"] = volume.GetPyObject();
throw PyException( MakeUserError( "NotEnoughCargoSpace", args ) );
}
}
示例4: DynamicSystemEntity
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);
m_destiny->SetPosition(position, false);
/* 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;
}
示例5: GetItemRow
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() ) );
}
示例6: PlugBooster
void Character::PlugBooster( uint32 itemID )
{
// Get itemID, change its location to characterID
// and change the flag to flagBooster
// So now its on character's brain
InventoryItemRef item = m_factory.GetItem( itemID );
// First of all check if we already have this
Boosters::iterator cur, end;
cur = m_boosters.begin();
end = m_boosters.end();
for(; cur != end; cur++ )
{
InventoryItemRef booster = m_factory.GetItem( cur->itemID );
if( booster == NULL ) return;
// Ok, we already have this booster, return
if( item->typeID() == booster->typeID() )return;
}
item->MoveInto( *this, flagBooster );
EvilNumber num = 1;
item->SetAttribute( AttrIsOnline, num, true );
item->SaveAttributes();
cBoosters i;
i.itemID = itemID;
i.plugDate = Win32TimeNow();
i.expiretime = item->GetAttribute( AttrBoosterDuration ).get_int();
m_boosters.push_back( i );
}
示例7: thermal
Damage::Damage(
SystemEntity *_source,
InventoryItemRef _weapon,
EVEEffectID _effect
)
/*: kinetic(_weapon->kineticDamage()),
thermal(_weapon->thermalDamage()),
em(_weapon->emDamage()),
explosive(_weapon->explosiveDamage()),*/
: kinetic(_weapon->GetAttribute(AttrKineticDamage).get_float()),
thermal(_weapon->GetAttribute(AttrThermalDamage).get_float()),
em(_weapon->GetAttribute(AttrEmDamage).get_float()),
explosive(_weapon->GetAttribute(AttrExplosiveDamage).get_float()),
source(_source),
weapon(_weapon),
charge(),
effect(_effect)
{}
示例8: ValidateAddItem
void Structure::ValidateAddItem(EVEItemFlags flag, InventoryItemRef item, Client *c)
{
CharacterRef character = c->GetChar();
if( flag == flagCargoHold )
{
//get all items in cargohold
EvilNumber capacityUsed(0);
std::vector<InventoryItemRef> items;
c->GetShip()->FindByFlag(flag, items);
for(uint32 i = 0; i < items.size(); i++){
capacityUsed += items[i]->GetAttribute(AttrVolume);
}
if( capacityUsed + item->GetAttribute(AttrVolume) > c->GetShip()->GetAttribute(AttrCapacity) )
throw PyException( MakeCustomError( "Not enough cargo space!") );
}
else if( flag == flagSecondaryStorage )
{
//get all items in SecondaryStorage
EvilNumber capacityUsed(0);
std::vector<InventoryItemRef> items;
c->GetShip()->FindByFlag(flag, items);
for(uint32 i = 0; i < items.size(); i++){
capacityUsed += items[i]->GetAttribute(AttrVolume);
}
if( capacityUsed + item->GetAttribute(AttrVolume) > c->GetShip()->GetAttribute(AttrCapacitySecondary) )
throw PyException( MakeCustomError( "Not enough Secondary Storage space!") );
}
else if( flag == flagSpecializedAmmoHold )
{
//get all items in ammo hold
EvilNumber capacityUsed(0);
std::vector<InventoryItemRef> items;
c->GetShip()->FindByFlag(flag, items);
for(uint32 i = 0; i < items.size(); i++){
capacityUsed += items[i]->GetAttribute(AttrVolume);
}
if( capacityUsed + item->GetAttribute(AttrVolume) > c->GetShip()->GetAttribute(AttrAmmoCapacity) )
throw PyException( MakeCustomError( "Not enough Ammo Storage space!") );
}
}
示例9: canActivate
bool MiningLaser::canActivate(SystemEntity *targetEntity)
{
if(targetEntity == nullptr)
{
return false;
}
InventoryItemRef miner = getItem();
bool isIceMiner = (miner->typeID() == 16278 || miner->typeID() == 22229 || miner->typeID() == 28752);
if (isIceMiner)
{
// Only allow ice harvesters to mine ice.
if (targetEntity->Item()->groupID() != EVEDB::invGroups::Ice)
{
SysLog::Error("MiningLaser::Activate()", "ERROR: invalid target!");
throw PyException(MakeCustomError("ERROR! invalid target!"));
}
}
else if (miner->groupID() == EVEDB::invGroups::Gas_Cloud_Harvester)
{
// Gas cloud harvesters only allowed to harvest gas.
if (targetEntity->Item()->groupID() != EVEDB::invGroups::Harvestable_Cloud)
{
SysLog::Error("MiningLaser::Activate()", "ERROR: invalid target!");
throw PyException(MakeCustomError("ERROR! invalid target!"));
}
}
// Only thing left are astroid miners.
else if (targetEntity->Item()->categoryID() != EVEDB::invCategories::Asteroid)
{
// We are not targeting an asteroid.
SysLog::Error("MiningLaser::Activate()", "ERROR: invalid target!");
throw PyException(MakeCustomError("ERROR! invalid target!"));
}
// We have a valid target, are we in range?
double maxRange = miner->GetAttribute(AttrMaxRange).get_float();
double targetRange = targetEntity->DistanceTo2(m_ship->GetOperator()->GetSystemEntity());
targetRange = std::sqrt(targetRange);
targetRange -= targetEntity->GetRadius();
if (targetRange > maxRange)
{
// We are not targeting a valid target.
// TO-DO: send proper out or range response.
SysLog::Error("MiningLaser::Activate()", "ERROR: Cannot activate mining laser target out of range! (%f/%f)", targetRange, maxRange);
throw PyException(MakeCustomError("ERROR! Cannot activate mining laser target out of range! (%f/%f)", targetRange, maxRange));
}
return true;
}
示例10: ValidateAddItem
void CargoContainer::ValidateAddItem(EVEItemFlags flag, InventoryItemRef item, Client *c)
{
CharacterRef character = c->GetChar();
if( flag == flagCargoHold )
{
//get all items in cargohold
EvilNumber capacityUsed(0);
std::vector<InventoryItemRef> items;
c->GetShip()->FindByFlag(flag, items);
for(uint32 i = 0; i < items.size(); i++){
capacityUsed += items[i]->GetAttribute(AttrVolume);
}
if( capacityUsed + item->GetAttribute(AttrVolume) > c->GetShip()->GetAttribute(AttrCapacity) )
throw PyException( MakeCustomError( "Not enough cargo space!") );
}
}
示例11: RemoveItem
void Ship::RemoveItem(InventoryItemRef item, uint32 inventoryID, EVEItemFlags flag)
{
// If item IS a module and it's being removed from a slot:
if( (item->categoryID() == EVEDB::invCategories::Module) && ((item->flag() >= flagLowSlot0) && (item->flag() <= flagHiSlot7)) )
{
m_pOperator->GetShip()->Deactivate( item->itemID(), "online" );
// m_pOperator->GetShip()->Set_mass( m_pOperator->GetShip()->mass() - item->massAddition() );
//m_pOperator->GetShip()->SetAttribute(AttrMass, m_pOperator->GetShip()->GetAttribute(AttrMass) - item->GetAttribute(AttrMassAddition) );
m_pOperator->GetShip()->UnloadModule( item->itemID() );
}
// If item IS a rig and it's being removed from a slot:
if( (item->categoryID() == EVEDB::invCategories::Module) && ((item->flag() >= flagRigSlot0) && (item->flag() <= flagRigSlot7)) )
{
// Don't know what to do when removing a Rig... yet ;)
}
// If item IS a rig and it's being removed from a slot:
if( (item->categoryID() == EVEDB::invCategories::Subsystem) && ((item->flag() >= flagSubSystem0) && (item->flag() <= flagSubSystem7)) )
{
// Don't know what to do when removing a Subsystem... yet ;)
}
// if item being removed IS a charge, it needs to be removed via Module Manager so modules know charge is removed,
// BUT, only if it is loaded into a module in one of the 3 slot banks, so we also check its flag value:
if( (item->categoryID() == EVEDB::invCategories::Charge) && ((item->flag() >= flagLowSlot0) && (item->flag() <= flagHiSlot7)) )
{
m_ModuleManager->UnloadCharge(item->flag());
}
if( item->flag() == flag )
// Item's already been moved, let's return
return;
// Move New item to its new location:
if( !( ((item->flag() >= flagLowSlot0) && (item->flag() <= flagHiSlot7)) || ((item->flag() >= flagRigSlot0) && (item->flag() <= flagRigSlot7))
|| ((item->flag() >= flagSubSystem0) && (item->flag() <= flagSubSystem7)) ) )
{
_DecreaseCargoHoldsUsedVolume( item->flag(), (item->GetAttribute(AttrVolume).get_float() * item->quantity()) );
m_pOperator->MoveItem(item->itemID(), inventoryID, flag);
}
else
{
m_pOperator->MoveItem(item->itemID(), inventoryID, flag);
}
}
示例12: Command_getattr
PyResult Command_getattr( Client* who, CommandDB* db, PyServiceMgr* services, const Seperator& args )
{
if( args.argCount() < 3 ) {
throw PyException( MakeCustomError("Correct Usage: /getattr [itemID] [attributeID]") );
}
if( !args.isNumber( 1 ) )
throw PyException( MakeCustomError( "1st argument must be itemID (got %s).", args.arg( 1 ).c_str() ) );
const uint32 itemID = atoi( args.arg( 1 ).c_str() );
if( !args.isNumber( 2 ) )
throw PyException( MakeCustomError( "2nd argument must be attributeID (got %s).", args.arg( 2 ).c_str() ) );
const ItemAttributeMgr::Attr attribute = (ItemAttributeMgr::Attr)atoi( args.arg( 2 ).c_str() );
InventoryItemRef item = services->item_factory.GetItem( itemID );
if( !item )
throw PyException( MakeCustomError( "Failed to load item %u.", itemID ) );
//return item->attributes.PyGet( attribute );
return item->GetAttribute(attribute).GetPyObject();
}
示例13: CheckAttacks
void NPCAIMgr::CheckAttacks(SystemEntity *target) {
if(m_mainAttackTimer.Check(false)) {
_log(NPC__AI_TRACE, "[%u] Attack timer expired. Attacking %u.", m_npc->GetID(), target->GetID());
InventoryItemRef self = m_npc->Item();
//reset the attack timer.
//NOTE: there is probably a more intelligent way to make this descision.
//if(self->entityAttackDelayMax() <= 0) {
//use speed field...
m_mainAttackTimer.Start(self->GetAttribute(AttrSpeed).get_int());
//} else {
//I think this field is actually meant as a reaction time to the player showing up in range.
// m_mainAttackTimer.Start(MakeRandomInt(
// self->entityAttackDelayMin(),
// self->entityAttackDelayMax() ));
//}
//Do main attack...
//check our attack range...
if(m_npc->DistanceTo2(target) > m_entityAttackRange2.get_float()) {
_log(NPC__AI_TRACE, "[%u] Target (%u) is too far away (%.2f > %.2f)", m_npc->GetID(), target->GetID(), m_npc->DistanceTo2(target), m_entityAttackRange2);
_EnterFollowing(target);
return;
}
//TODO: check to-hit...
//TODO: Need to consult dgmTypeEffects to determine what kind
// of effects to throw for this attack.
_SendWeaponEffect("effects.Laser", target);
Damage d(
m_npc, (InventoryItemRef)self,
effectTargetAttack); //should get this from somewhere.
m_npc->ApplyDamageModifiers(d, m_npc);
target->ApplyDamage(d);
}
}
示例14: SpawnAsteroid
void SpawnAsteroid( SystemManager* system, uint32 typeID, double radius, const GVector& position )
{
//TODO: make item in IsUniverseAsteroid() range...
ItemData idata( typeID,
1 /* who->GetCorporationID() */, //owner
system->GetID(),
flagAutoFit,
"", //name
position );
InventoryItemRef i = system->itemFactory().SpawnItem( idata );
if( !i )
throw PyException( MakeCustomError( "Unable to spawn item of type %u.", typeID ) );
//i->Set_radius( radius );
// Calculate 1/10000th of the volume of a sphere with radius 'radius':
// (this should yield around 90,000 units of Veldspar in an asteroid with 1000.0m radius)
double volume = (1.0/10000.0) * (4.0/3.0) * M_PI * pow(radius,3);
i->SetAttribute(AttrQuantity, EvilNumber(floor(100*(volume/(i->GetAttribute(AttrVolume).get_float())))));
i->SetAttribute(AttrRadius, EvilNumber(radius));
//i->SetAttribute(AttrVolume, EvilNumber(volume));
//i->SetAttribute(AttrIsOnline,EvilNumber(1)); // Is Online
//i->SetAttribute(AttrDamage,EvilNumber(0.0)); // Structure Damage
//i->SetAttribute(AttrShieldCharge,i->GetAttribute(AttrShieldCapacity)); // Shield Charge
//i->SetAttribute(AttrArmorDamage,EvilNumber(0.0)); // Armor Damage
//i->SetAttribute(AttrMass,EvilNumber(i->type().attributes.mass())); // Mass
//i->SetAttribute(AttrRadius,EvilNumber(i->type().attributes.radius())); // Radius
//i->SetAttribute(AttrVolume,EvilNumber(i->type().attributes.volume())); // Volume
// TODO: Rework this code now that
AsteroidEntity* new_roid = NULL;
new_roid = new AsteroidEntity( i, system, *(system->GetServiceMgr()), position );
if( new_roid != NULL )
sLog.Debug( "SpawnAsteroid()", "Spawned new asteroid of radius= %fm and volume= %f m3", radius, volume );
//TODO: check for a local asteroid belt object?
//TODO: actually add this to the asteroid belt too...
system->AddEntity( new_roid );
}
示例15: AddItem
uint32 Ship::AddItem(EVEItemFlags flag, InventoryItemRef item)
{
ValidateAddItem( flag, item );
//it's a new module, make sure it's state starts at offline so that it is added correctly
if( item->categoryID() == EVEDB::invCategories::Module )
item->PutOffline();
switch( item->categoryID() )
{
case EVEDB::invCategories::Charge:
{
m_ModuleManager->LoadCharge(item, flag);
InventoryItemRef loadedChargeOnModule = m_ModuleManager->GetLoadedChargeOnModule(flag);
if( loadedChargeOnModule != NULL )
{
return loadedChargeOnModule->itemID();
}
else
return 0;
}
break;
case EVEDB::invCategories::Module:
if( m_ModuleManager->FitModule(item, flag) )
item->Move(itemID(), flag);
break;
// The default case handles ANY other items added to ship and assumes they go into one of the valid cargo holds on this ship:
default:
//sLog.Error( "Ship::AddItem(flag,item)", "ERROR! Function called with item '%s' (id: %u) of category neither Charge nor Module!", item->itemName().c_str(), item->itemID() );
_IncreaseCargoHoldsUsedVolume( item->flag(), (item->GetAttribute(AttrVolume).get_float() * item->quantity()) );
item->Move(itemID(), flag);
break;
}
return 0;
}