本文整理汇总了C++中InventoryItemRef::SetAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ InventoryItemRef::SetAttribute方法的具体用法?C++ InventoryItemRef::SetAttribute怎么用?C++ InventoryItemRef::SetAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InventoryItemRef
的用法示例。
在下文中一共展示了InventoryItemRef::SetAttribute方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PlugImplant
void Character::PlugImplant( uint32 itemID )
{
// Get itemID, change its location to characterID
// and change the flag to flagImplant
// So now its on character's brain
InventoryItemRef item = m_factory.GetItem( itemID );
// First of all check if we already have this
Implants::iterator cur, end;
cur = m_implants.begin();
end = m_implants.end();
for(; cur != end; cur++ )
{
InventoryItemRef implant = m_factory.GetItem( cur->itemID );
if( implant == NULL ) return;
// Ok, we already have this booster, return
if( item->typeID() == implant->typeID() ) return;
}
item->MoveInto( *this, flagImplant );
EvilNumber num = 1;
item->SetAttribute( AttrIsOnline, num, true );
item->SaveAttributes();
cImplants i;
i.itemID = itemID;
m_implants.push_back( i );
}
示例2: 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 );
}
示例3: Command_setattr
PyResult Command_setattr( Client* who, CommandDB* db, PyServiceMgr* services, const Seperator& args )
{
if( args.argCount() < 4 ) {
throw PyException( MakeCustomError("Correct Usage: /setattr [itemID] [attributeID] [value]") );
}
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() );
if( !args.isNumber( 3 ) )
throw PyException( MakeCustomError( "3rd argument must be value (got %s).", args.arg( 3 ).c_str() ) );
const double value = atof( args.arg( 3 ).c_str() );
InventoryItemRef item = services->item_factory.GetItem( itemID );
if( !item )
throw PyException( MakeCustomError( "Failed to load item %u.", itemID ) );
//item->attributes.SetReal( attribute, value );
sLog.Warning( "GMCommands: Command_dogma()", "This command will modify attribute and send change to client, but change does not take effect in client for some reason." );
item->SetAttribute(attribute, (float)value);
return new PyString( "Operation successful." );
}
示例4: Command_dogma
PyResult Command_dogma( Client* who, CommandDB* db, PyServiceMgr* services, const Seperator& args )
{
//"dogma" "140019878" "agility" "=" "0.2"
if( !(args.argCount() == 5) ) {
throw PyException( MakeCustomError("Correct Usage: /dogma [itemID] [attributeName] = [value]") );
}
if( !args.isNumber( 1 ) ){
throw PyException( MakeCustomError("Invalid itemID. \n Correct Usage: /dogma [itemID] [attributeName] = [value]") );
}
uint32 itemID = atoi( args.arg( 1 ).c_str() );
if( args.isNumber( 2 ) ) {
throw PyException( MakeCustomError("Invalid attributeName. \n Correct Usage: /dogma [itemID] [attributeName] = [value]") );
}
const char *attributeName = args.arg( 2 ).c_str();
if( !args.isNumber( 4 ) ){
throw PyException( MakeCustomError("Invalid attribute value. \n Correct Usage: /dogma [itemID] [attributeName] = [value]") );
}
double attributeValue = atof( args.arg( 4 ).c_str() );
//get item
InventoryItemRef item = services->item_factory.GetItem( itemID );
//get attributeID
uint32 attributeID = db->GetAttributeID( attributeName );
sLog.Warning( "GMCommands: Command_dogma()", "This command will modify attribute and send change to client, but change does not take effect in client for some reason." );
item->SetAttribute( attributeID, attributeValue );
return NULL;
}
示例5: 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 );
}
示例6: SpawnAsteroid
void SpawnAsteroid( SystemManager* system, uint32 typeID, double radius, const GVector& position )
{
ItemData idata( typeID,
1,
system->GetID(),
flagAutoFit,
"", //name
position );
InventoryItemRef i = ItemFactory::SpawnItem(idata);
if (!i)
{
throw PyException(MakeCustomError("Unable to spawn item of type %u.", typeID));
}
// 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/100000.0) * (4.0/3.0) * M_PI * pow(radius,3);
//uint32 qty = floor((volume/(i->GetAttribute(AttrVolume).get_float())));
uint32 qty = (radius * 10) / std::sqrt(i->GetAttribute(AttrVolume).get_float());
if (i->groupID() == EVEDB::invGroups::Veldspar)
{
qty *= 2;
}
i->SetAttribute(AttrQuantity, qty);
i->SetAttribute(AttrRadius, radius);
// Create astroid srvEntity.
AsteroidEntity* new_roid = new AsteroidEntity(i, system, position);
if (new_roid != nullptr)
{
SysLog::Debug("SpawnAsteroid()", "Spawned new asteroid of radius= %fm and volume= %f m3", radius, volume);
// Add srvEntity to system.
system->AddEntity(new_roid);
}
}
示例7: 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);
// 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;
}
示例8: endCycle
//.........这里部分代码省略.........
{
double usedTime = getElapsedCycleTimeMS();
percent = usedTime / cycleTime;
// Limit to range 0.0 - 1.0.
percent = std::min(1.0, std::max(0.0, percent));
if(percent == 0.0)
{
percent = 1.0;
}
}
// Round down to next lowest integer value.
oreUnitsToPull = floor(oreUnitsToPull * percent);
// Limit to units remaining in asteroid.
oreUnitsToPull = std::min(oreUnitsToPull, (double) remainingOreUnits);
// Find what cargo hold to use.
EVEItemFlags cargoFlag = flagCargoHold;
// Check for specialized cargo hold.
if (m_ship->HasAttribute(AttrSpecialOreHoldCapacity))
{
// We have a specialized ore hold all or goes here.
cargoFlag = flagSpecializedOreHold;
}
// Get cargo hold and remaining capacity.
double remainingCargoVolume = m_ship->GetRemainingVolumeByFlag(cargoFlag);
// Do we have enough room for the whole stack?
if (remainingCargoVolume < (floor((oreUnitsToPull * oreUnitVolume) * 100.0)/100.0))
{
// No, Do we have room for at least one unit?
if (remainingCargoVolume < oreUnitVolume)
{
// No, Send cargo full message.
PyDict *dict = new PyDict();
PyTuple *tuple = new PyTuple(2);
tuple->SetItem(0, new PyInt(MOD_ACTIVATED)); //???? what is this really?
tuple->SetItem(1, new PyInt(m_item->typeID()));
dict->SetItem(new PyString("modulename"), tuple);
PyTuple *error = new PyTuple(2);
error->SetItem(0, new PyString("MiningDronesDeactivatedCargoHoldNowFull"));
error->SetItem(1, dict);
m_error = error;
return false;
}
// Yes, reduce the stack size.
oreUnitsToPull = floor(remainingCargoVolume / oreUnitVolume);
}
// Are we actually pulling anything?
if (oreUnitsToPull <= 0.0)
{
// No, hmmm... thats bad!
// TO-DO: send client miner deactivated because hold full message.
SysLog::Warning("MiningLaser::DoCycle()", "Somehow MiningLaser could not extract ore from current target asteroid '%s' (id %u)", m_targetEntity->Item()->itemName().c_str(), m_targetEntity->GetID());
checkAsteroidDepleted(remainingOreUnits);
return false;
}
// Check for an existing ore item in the cargo.
InventoryItemRef existing = m_ship->GetByTypeFlag(asteroidRef->typeID(), cargoFlag);
if (existing.get() != nullptr)
{
// We have an existing ore sample, add to it.
m_ship->AlterCargoQty(existing, oreUnitsToPull);
}
else
{
// No existing ore sample, create one.
ItemData idata(
asteroidRef->typeID(),
m_ship->ownerID(),
0, //temp location
cargoFlag,
oreUnitsToPull
);
InventoryItemRef ore = ItemFactory::SpawnItem(idata);
if (ore)
{
m_ship->AddItem(cargoFlag, ore);
}
else
{
SysLog::Error("MiningLaser::DoCycle()", "ERROR: Could not create ore stack for '%s' ship (id %u)!", m_ship->itemName().c_str(), m_ship->itemID());
return false;
}
}
// Finally, reduce the amount of ore in the asteroid by how much we took out:
remainingOreUnits -= oreUnitsToPull;
asteroidRef->SetAttribute(AttrQuantity, remainingOreUnits);
// Check to see is ship is full or asteroid depleted.
remainingCargoVolume = m_ship->GetRemainingVolumeByFlag(cargoFlag);
if ((remainingCargoVolume < oreUnitVolume) || remainingOreUnits == 0)
{
// Asteroid is empty OR cargo hold is entirely full, either way, DEACTIVATE module immediately!
checkAsteroidDepleted(remainingOreUnits);
return false;
}
return true;
}