示例#1
0
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;
}
示例#2
0
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." );
}
示例#3
0
void Ship::RemoveRig( InventoryItemRef item, uint32 inventoryID )
{
    m_ModuleManager->UnfitModule(item->itemID());

    //delete the item
    item->Delete();
}
示例#4
0
void Inventory::StackAll(EVEItemFlags locFlag, uint32 forOwner)
{
    std::map<uint32, InventoryItemRef> types;

    std::map<uint32, InventoryItemRef>::iterator cur, end;
    cur = mContents.begin();
    end = mContents.end();
    for(; cur != end; )
    {
        // Iterator becomes invalid when the item
        // is moved out; we have to increment before
        // calling Merge().
        InventoryItemRef i = cur->second;
        cur++;

        if( !i->singleton() && ( forOwner == 0 || forOwner == i->ownerID() ) )
        {
            std::map<uint32, InventoryItemRef>::iterator res = types.find( i->typeID() );
            if( res == types.end() )
                types.insert( std::make_pair( i->typeID(), i ) );
            else
                res->second->Merge( i );
        }
    }
}
示例#5
0
void Character::AddItem(InventoryItemRef item)
{
    Inventory::AddItem( item );

    if( item->flag() == flagSkill
        || item->flag() == flagSkillInTraining )
    {
        // Skill has been added ...
        if( item->categoryID() != EVEDB::invCategories::Skill ) {
            _log( ITEM__WARNING, "%s (%u): %s has been added with flag %d.", itemName().c_str(), itemID(), item->category().name().c_str(), (int)item->flag() );
        } else
        {
            SkillRef skill = SkillRef::StaticCast( item );

            if( !skill->singleton() )
            {
                _log( ITEM__TRACE, "%s (%u): Injecting %s.", itemName().c_str(), itemID(), item->itemName().c_str() );

                // Make it singleton and set initial skill values.
                skill->ChangeSingleton( true );

                skill->SetAttribute(AttrSkillLevel, 0);
                skill->SetAttribute(AttrSkillPoints, 0);

                if( skill->flag() != flagSkillInTraining )
                    skill->SetAttribute(AttrExpiryTime, 0);
            }
        }
    }
}
示例#6
0
void ModuleManager::UnfitModule(uint32 itemID)
{
    GenericModule * mod = m_Modules->GetModule(itemID);
    if( mod != NULL )
    {
		if( mod->isLoaded() )
		{
			InventoryItemRef loadedChargeRef = mod->getLoadedChargeRef();
			if( IsStation(m_Ship->locationID()) )
				loadedChargeRef->Move(m_Ship->locationID(), flagHangar);		// used to be (m_pOperator->GetLocationID(), flag)
			else
			{
				m_Ship->ValidateAddItem(flagCargoHold,loadedChargeRef);
				//if( m_Ship->ValidateAddItem(flagCargoHold,loadedChargeRef) )
				//{
					loadedChargeRef->Move(m_Ship->itemID(), flagCargoHold);		// used to be (m_pOperator->GetLocationID(), flag)
					mod->unload();
				//}
				//else
				//	throw PyException( MakeCustomError( "Not enough cargo space!") );
			}
		}

		mod->offline();
		m_Modules->RemoveModule(itemID);
    }
}
示例#7
0
bool Ship::ValidateItemSpecifics(InventoryItemRef equip) const
{
    //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;

}
示例#8
0
InventoryItemRef ItemFactory::SpawnItem(ItemData &data) {
    InventoryItemRef i = InventoryItem::Spawn(*this, data);
    if( !i )
        return InventoryItemRef();

    // spawn successful; store the ref
    m_items.insert( std::make_pair( i->itemID(), i ) );
    return i;
}
示例#9
0
InventoryItemRef InventoryItem::LoadEntity(ItemFactory &factory, uint32 itemID, const ItemData &data)
{
    const ItemType *type = factory.GetType( data.typeID );

	InventoryItemRef itemRef = InventoryItemRef( new InventoryItem(factory, itemID, *type, data) );

	itemRef->_Load();

	return itemRef;
}
示例#10
0
void Ship::RemoveRig( InventoryItemRef item, uint32 inventoryID )
{
	m_ModuleManager->UninstallRig(item->itemID());

	//move the item to the void or w/e
	m_pOperator->MoveItem(item->itemID(), inventoryID, flagAutoFit);

	//delete the item
	item->Delete();
}
示例#11
0
bool Character::HasImplant( uint32 implantTypeID )
{
	uint32 i = 0;
	for( i = 0; i < m_implants.size(); i++ )
	{
		InventoryItemRef item = m_factory.GetItem( m_implants.at( i ).itemID );
		if( item->typeID() == implantTypeID ) return true;
	}
	
	return false;
}
示例#12
0
bool Character::HasBooster( uint32 boosterTypeID )
{
	uint32 i = 0;
	for( i = 0; i < m_boosters.size(); i++ )
	{
		InventoryItemRef item = m_factory.GetItem( m_boosters.at( i ).itemID );
		if( item->typeID() == boosterTypeID ) return true;
	}

	return false;
}
示例#13
0
bool ModuleManager::InstallRig(InventoryItemRef item, EVEItemFlags flag)
{
    if(item->groupID() >= 773 && item->groupID() <= 786 && item->groupID() != 783)
    {
        _fitModule(item,flag);
        return true;
    }
    else
        SysLog::Debug("ModuleManager","%s tried to fit item %u, which is not a rig", m_Ship->GetOperator()->GetName(), item->itemID());

    return false;
}
示例#14
0
void Ship::AddItem(InventoryItemRef item)
{
    InventoryEx::AddItem( item );

    if( item->flag() >= flagSlotFirst && 
        item->flag() <= flagSlotLast && 
        item->categoryID() != EVEDB::invCategories::Charge)
    {
        // make singleton
        item->ChangeSingleton( true );
    }
}
示例#15
0
bool ModuleManager::SwapSubSystem(InventoryItemRef item, EVEItemFlags flag)
{
    if(item->groupID() >= 954 && item->groupID() <= 958)
    {
        _fitModule(item,flag);
        return true;
    }
    else
        SysLog::Debug("ModuleManager","%s tried to fit item %u, which is not a subsystem", m_Ship->GetOperator()->GetName(), item->itemID());

    return false;
}
示例#16
0
PyResult Command_createitem( Client* who, CommandDB* db, PyServiceMgr* services, const Seperator& args )
{
	if( args.argCount() < 2 ) {
		throw PyException( MakeCustomError("Correct Usage: /create [typeID]") );
	}
	
	//basically, a copy/paste from Command_create. The client seems to call this multiple times, 
	//each time it creates an item
	if( !args.isNumber( 1 ) )
		throw PyException( MakeCustomError( "Argument 1 must be type ID." ) );
    const uint32 typeID = atoi( args.arg( 1 ).c_str() );
 
	uint32 qty = 1;
    if( 2 < args.argCount() )
    {
	    if( args.isNumber( 2 ) )
		    qty = atoi( args.arg( 2 ).c_str() );
    }

    sLog.Log("command message", "Create %s %u times", args.arg( 1 ).c_str(), qty );

	//create into their cargo hold unless they are docked in a station,
	//then stick it in their hangar instead.
	uint32 locationID;
	EVEItemFlags flag;
	if( who->IsInSpace() )
    {
		locationID = who->GetShipID();
		flag = flagCargoHold;
	}
    else
    {
		locationID = who->GetStationID();
		flag = flagHangar;
	}
	
	ItemData idata(
		typeID,
		who->GetCharacterID(),
		0, //temp location
		flag,
		qty
	);

	InventoryItemRef i = services->item_factory.SpawnItem( idata );
	if( !i )
		throw PyException( MakeCustomError( "Unable to create item of type %s.", args.arg( 1 ).c_str() ) );

	//Move to location
	i->Move( locationID, flag, true );

	return new PyString( "Creation successful." );
}
示例#17
0
void Inventory::AddItem(InventoryItemRef item)
{
    std::map<uint32, InventoryItemRef>::iterator res = mContents.find( item->itemID() );
    if( res == mContents.end() )
    {
        mContents.insert( std::make_pair( item->itemID(), item ) );

        sLog.Debug("Inventory", "Updated location %u to contain item %u with flag %d.", inventoryID(), item->itemID(), (int)item->flag() );
    }
    //else already here
    sLog.Debug("Inventory", "unable to updated location %u to contain item %u with flag %d, because it already happend.", inventoryID(), item->itemID(), (int)item->flag() );
}
示例#18
0
void 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::Charge )
		item->PutOffline();

	item->Move(m_pOperator->GetLocationID(), flag);  //TODO - check this

	m_ModuleManager->FitModule(item);
}
示例#19
0
void Ship::RemoveItem(InventoryItemRef item, uint32 inventoryID, EVEItemFlags flag)
{
	//coming from ship, we need to deactivate it and remove mass if it isn't a charge
	if( item->categoryID() != EVEDB::invCategories::Charge ) {
		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() );
	}

	//Move New item to its new location
	m_pOperator->MoveItem(item->itemID(), inventoryID, flag);
}
示例#20
0
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() ) );
}
示例#21
0
bool InventoryItem::Merge(InventoryItemRef to_merge, int32 qty, bool notify) {
    if(typeID() != to_merge->typeID()) {
        _log(ITEM__ERROR, "%s (%u): Asked to merge with %s (%u).", itemName().c_str(), itemID(), to_merge->itemName().c_str(), to_merge->itemID());
        return false;
    }
    if(locationID() != to_merge->locationID() || flag() != to_merge->flag()) {
        _log(ITEM__ERROR, "%s (%u) in location %u, flag %u: Asked to merge with item %u in location %u, flag %u.", itemName().c_str(), itemID(), locationID(), flag(), to_merge->itemID(), to_merge->locationID(), to_merge->flag());
        return false;
    }
    if(qty == 0)
        qty = to_merge->quantity();
    if(qty <= 0) {
        _log(ITEM__ERROR, "%s (%u): Asked to merge with %d units of item %u.", itemName().c_str(), itemID(), qty, to_merge->itemID());
        return false;
    }
    if(!AlterQuantity(qty, notify)) {
        _log(ITEM__ERROR, "%s (%u): Failed to add quantity %d.", itemName().c_str(), itemID(), qty);
        return false;
    }

    if(qty == to_merge->quantity()) {
        to_merge->Delete();
    } else if(!to_merge->AlterQuantity(-qty, notify)) {
        _log(ITEM__ERROR, "%s (%u): Failed to remove quantity %d.", to_merge->itemName().c_str(), to_merge->itemID(), qty);
        return false;
    }

    return true;
}
示例#22
0
void Inventory::RemoveItem(InventoryItemRef item)
{
    std::map<uint32, InventoryItemRef>::iterator res = mContents.find( item->itemID() );
    if( res != mContents.end() )
    {
        mContents.erase( res );

        sLog.Debug("Inventory", "Updated location %u to no longer contain item %u.", inventoryID(), item->itemID() );
    }
	else
	{
		sLog.Debug("Inventory", "unable to remove %u from %u.", item->itemID(), inventoryID() );
	}
}
示例#23
0
void 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::Charge )
        item->PutOffline();

    // TODO: Somehow, if this returns FALSE, the item->Move() above has to be "undone"... can we do the move AFTER attempting to fit?
    // what if we pass the flag into FitModule().... then if it returns true, the item->Move() can be called
    if( m_ModuleManager->FitModule(item, flag) )
        item->Move(m_pOperator->GetLocationID(), flag);  //TODO - check this
}
示例#24
0
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 );
}
示例#25
0
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;
}
示例#26
0
/*
 * 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 ) );
    }
}
示例#27
0
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_armorDamage = 0.0;
	m_hullDamage = 0.0;

}
示例#28
0
bool ModuleManager::FitModule(InventoryItemRef item, EVEItemFlags flag)
{
    if(item->categoryID() == EVEDB::invCategories::Module)
    {
        // Attempt to fit the module
        if( _fitModule(item, flag) )
        {
            // Now that module is successfully fitted, attempt to put it Online:
            Online(item->itemID());
            return true;
        }
    }
    else
        SysLog::Debug("ModuleManager","%s tried to fit item %u, which is not a module", m_Ship->GetOperator()->GetName(), item->itemID());

    return false;
}
示例#29
0
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 );
}
示例#30
0
void Inventory::List( CRowSet* into, EVEItemFlags _flag, uint32 forOwner ) const
{
    //there has to be a better way to build this...
    std::map<uint32, InventoryItemRef>::const_iterator cur, end;
    cur = mContents.begin();
    end = mContents.end();
    for(; cur != end; cur++)
    {
        InventoryItemRef i = cur->second;

        if(    ( i->flag() == _flag       || _flag == flagAnywhere )
            && ( i->ownerID() == forOwner || forOwner == 0 ) )
        {
			PyPackedRow* row = into->NewRow();
			i->GetItemRow( row );
        }
    }
}