void ManufacturingSchematic::prepareCraftingAttributes()
{
	DraftSchematic*				draftSchematic		= gSchematicManager->getSchematicBySlotId(mDynamicInt32);
	CraftBatches*				expCraftBatches		= draftSchematic->getCraftBatches();
	CraftBatches::iterator		expCraftBatchIt		= expCraftBatches->begin();

	while(expCraftBatchIt != expCraftBatches->end())
	{
		string						attName		= gSchematicManager->getExpGroup((*expCraftBatchIt)->getExpGroup());
		ExperimentationProperty*	expProperty	= new ExperimentationProperty(attName.getAnsi(),(*expCraftBatchIt)->getCraftWeights(),(*expCraftBatchIt)->getCraftAttributes(),0.0f,0.0f,0.0f);

		mExperimentationProperties.push_back(expProperty);

		++expCraftBatchIt;
	}

	//for(uint32 i = 8;i < 15;i++)
	//	mUpdateCounter[i] = mExperimentationProperties.size();

	mExpFailureChance = 90.0f;

	// ----------------------------------------------------------------
	// collect the *unique* exp properties in a list for easy reference
	// so we can bundle them on sending the deltas / baseline

	ExperimentationProperties*			expProp				= getExperimentationProperties();
	ExperimentationProperties::iterator	epIt				= expProp->begin();

	epIt	= expProp->begin();
	while(epIt != expProp->end())
	{
		// do we have this exp property already??

		if(!expPropStorefind((*epIt)->mExpAttributeName.getCrc()))
		{
			// add it
			expPropStore.push_back(std::make_pair((*epIt)->mExpAttributeName.getCrc(),(*epIt)));
		}

		++epIt;
	}
}
void ManufacturingSchematic::ModifyBlueBars(float mod)
{
	ExperimentationProperties*			expPropertiesList	= getExperimentationProperties();
	ExperimentationProperties::iterator	expIt				= expPropertiesList->begin();

	while(expIt!= expPropertiesList->end())
	{
		(*expIt)->mBlueBarSize = ((*expIt)->mBlueBarSize * mod);

		++expIt;
	}
}
uint8 CraftingSession::getExperimentationRoll(ExperimentationProperty* expProperty, uint8 expPoints)
{
    ExperimentationProperties*			expAllProps = mManufacturingSchematic->getExperimentationProperties();
    ExperimentationProperties::iterator itAll		=	 expAllProps->begin();
    uint8 roll;

    if(expProperty->mRoll == -1)
    {
        DLOG(INFO) << "CraftingSession:: expProperty is a Virgin!";

        // get our Roll and take into account the relevant modifiers
        roll			= _experimentRoll(expPoints);

        // now go through all properties and mark them when its this one!
        // so we dont experiment two times on it!
        itAll =	 expAllProps->begin();
        while(itAll != expAllProps->end())
        {
            ExperimentationProperty* tempProperty = (*itAll);

            if(expProperty->mExpAttributeName.getCrc() == tempProperty->mExpAttributeName.getCrc())
            {
                tempProperty->mRoll = roll;
            }

            itAll++;
        }

    }
    else
    {
        roll = static_cast<uint8>(expProperty->mRoll);
        DLOG(INFO) << "CraftingSession:: experiment expProperty isnt a virgin anymore ...(roll:" << roll;
    }

    return roll;

}
Ejemplo n.º 4
0
bool MessageLib::sendAttributeDeltasMSCO_7(ManufacturingSchematic* manSchem,PlayerObject* playerObject)
{
	// this updates the attributes properties when they have changed on experimentation
	// updated are the attributes value, the bluebarsize or the attribute(indicator of the % of the max value reached)
	// as well as the maxvalue in theory reachable

	if(!(playerObject->isConnected()))
		return(false);

	Message*							newMessage;
	Message*							finalMessage ;

	ExperimentationProperties*			expProp				= manSchem->getExperimentationProperties();
	ExperimentationProperties::iterator	epIt				= expProp->begin();

	ExperimentationPropertiesStore::iterator	epStoreIt	= manSchem->expPropStore.begin();

	uint32								objectcount			= 1;

	manSchem->mExpAttributeValueChange = false;
	manSchem->mMaxExpValueChange = false;
	manSchem->mBlueBarSizeChange = false;

	//we MUST make sure that we only update values which have changed!!!
	//otherwise we will desynchronize our list and are stuck without being able to update the client

	epIt	= expProp->begin();
	while(epIt != expProp->end())
	{

		if ((*epIt)->mExpAttributeValueOld != (*epIt)->mExpAttributeValue)
		{
			manSchem->mExpAttributeValueChange = true;

		}

		if ((*epIt)->mBlueBarSizeOld != (*epIt)->mBlueBarSize)
			manSchem->mBlueBarSizeChange = true;

		if ((*epIt)->mMaxExpValueOld != (*epIt)->mMaxExpValue)
		{
			manSchem->mMaxExpValueChange = true;

		}

		++epIt;
	}

	//that is the attribute - not the experimental property!!!
	if(manSchem->mExpAttributeValueChange)
	{
		objectcount ++;
	}

	if(manSchem->mBlueBarSizeChange)
	{
		objectcount ++;
	}

	if(manSchem->mMaxExpValueChange)
	{
		objectcount ++;
	}


	//start writing the messages body
	mMessageFactory->StartMessage();

	mMessageFactory->addUint16(static_cast<uint16>(objectcount));

	// experimentation/assembly percentage
	if(manSchem->mExpAttributeValueChange)
	{
		mMessageFactory->addUint16(9);

		manSchem->mUpdateCounter[9] += (manSchem->expPropStore.size());
		mMessageFactory->addUint32(manSchem->expPropStore.size());

		mMessageFactory->addUint32(manSchem->mUpdateCounter[9]);

		manSchem->mUpdateCounter[9] += 1;//(craftAtts->size());


		// ´send the *unique* exp properties
		// we send the values of the first of the propertie(s) that comes our way - so the experiment code needs to sort that
		// the reason we do this is that we might have exp properties with attributes affected by differing resource weights

		mMessageFactory->addUint8(3);//3 as in write new 2 was change
		mMessageFactory->addUint16(manSchem->expPropStore.size());

		epStoreIt	= manSchem->expPropStore.begin();
		while(epStoreIt != manSchem->expPropStore.end())
		{

			(*epStoreIt).second->mExpAttributeValueOld = (*epStoreIt).second->mExpAttributeValue;

			if(manSchem->hasPPAttribute(gWorldManager->getAttributeKey((*epStoreIt).first)))
			{
				float attributeValue = (*epStoreIt).second->mExpAttributeValue;
				float attributeAddValue = manSchem->getPPAttribute<float>(gWorldManager->getAttributeKey((*epStoreIt).first));
				mMessageFactory->addFloat(attributeValue+attributeAddValue);
			}
			else
				mMessageFactory->addFloat((*epStoreIt).second->mExpAttributeValue);

			//mMessageFactory->addFloat((*epStoreIt).second->mExpAttributeValue);
			++epStoreIt;
		}
	}

	//	BlueBarSizeList
	if(manSchem->mBlueBarSizeChange)
	{
		mMessageFactory->addUint16(11);

		mMessageFactory->addUint32(manSchem->expPropStore.size());

		manSchem->mUpdateCounter[11] += manSchem->expPropStore.size();
		mMessageFactory->addUint32(manSchem->mUpdateCounter[11]);
		//manSchem->mUpdateCounter[11] += 1;//(exProp->size());


		mMessageFactory->addUint8(3);//3 as in write new 2 was change
		mMessageFactory->addUint16(manSchem->expPropStore.size());

		epStoreIt	= manSchem->expPropStore.begin();

		while(epStoreIt != manSchem->expPropStore.end())
		{
			mMessageFactory->addFloat((*epStoreIt).second->mBlueBarSize);
			(*epStoreIt).second->mBlueBarSizeOld = (*epStoreIt).second->mBlueBarSize;

			++epStoreIt;
		}
	}

	// max values MaxExperimentationList
	if(manSchem->mMaxExpValueChange)
	{
		mMessageFactory->addUint16(12);

		mMessageFactory->addUint32(manSchem->expPropStore.size());

		manSchem->mUpdateCounter[12] += manSchem->expPropStore.size();
		mMessageFactory->addUint32(manSchem->mUpdateCounter[12]);
		//manSchem->mUpdateCounter[12] += 1;


		mMessageFactory->addUint8(3);//3 as in write new; 2 was change
		mMessageFactory->addUint16(expProp->size());

		epStoreIt			= manSchem->expPropStore.begin();

		while(epStoreIt != manSchem->expPropStore.end())
		{

			(*epStoreIt).second->mMaxExpValueOld = (*epStoreIt).second->mMaxExpValue;
			mMessageFactory->addFloat((*epStoreIt).second->mMaxExpValue);
			++epStoreIt;
		}
	}

	// success chance
	mMessageFactory->addUint16(18);

	mMessageFactory->addFloat(manSchem->getExpFailureChance());

	newMessage = mMessageFactory->EndMessage();



	mMessageFactory->StartMessage();
	mMessageFactory->addUint32(opDeltasMessage);
	mMessageFactory->addUint64(manSchem->getId());
	mMessageFactory->addUint32(opMSCO);
	mMessageFactory->addUint8(7);

	mMessageFactory->addUint32(newMessage->getSize());
	mMessageFactory->addData(newMessage->getData(),newMessage->getSize());

	finalMessage = mMessageFactory->EndMessage();

	newMessage->setPendingDelete(true);

	(playerObject->getClient())->SendChannelA(finalMessage ,playerObject->getAccountId(),CR_Client,5);

	return(true);
}