void CSoundAnimMarker::addSound(const NLMISC::CSheetId& soundName)
{
	pair<TMarkerSoundSet::iterator, bool> inserted;
	inserted = _Sounds.insert(soundName);
	if (inserted.second == false)
	{
		nlwarning("Duplicate sound (%s)",/* CStringMapper::unmap(soundName).c_str()*/soundName.toString().c_str());
	}
}
Beispiel #2
0
/*
 * PDS is ready
 */
void	CPDSLib::ready(uint32 lastUpdateId)
{
	nlassert(_PDSConnected);

	nlinfo("PDS is ready to work");
	_PDSReady = true;

	// set up next update Id
	_UpdateId = lastUpdateId+1;

	// flush previous messages that have already been written on hd
	if ((sint)lastUpdateId >= 0)
	{
		flushAcknowledged(lastUpdateId);
	}

	// prepare PD string mapper for sheet ids
	CPDStringMapper	sheetIdStringMapper;

	std::vector<NLMISC::CSheetId>	sheetIds;
	NLMISC::CSheetId::buildIdVector(sheetIds);

	uint	i;
	for (i=0; i<sheetIds.size(); ++i)
	{
		NLMISC::CSheetId	sheetId = sheetIds[i];
		sheetIdStringMapper.setMapping(sheetId.toString(), sheetId.asInt());
	}

	CMessage	msgout("PD_SHEETID_MAPPING");
	msgout.serial(_DatabaseId);
	msgout.serial(sheetIdStringMapper);
	CUnifiedNetwork::getInstance()->send("PDS", msgout);

	// if there are still some messages in queue, resend them
	if (!_QueuedMessages.empty())
	{
		// sort them before, so they are in right order
		// this is in theory useless, since new messages are inserted at end
		std::sort(_QueuedMessages.begin(), _QueuedMessages.end(), CQueuedMessagePred());

		TQueuedMessages::iterator	it;
		for (it=_QueuedMessages.begin(); it!=_QueuedMessages.end(); ++it)
		{
			uint32	updateId = (*it).first;

			if (updateId != _UpdateId)
				nlwarning("CPDSLib::ready(): update id '%d' is not consistent with message id '%d' to be sent", _UpdateId, updateId);

			_UpdateId = updateId+1;

			NLNET::CMessage*	msg = (*it).second;
			CUnifiedNetwork::getInstance()->send("PDS", *msg);
		}
	}
}
void CSoundAnimMarker::removeSound(const NLMISC::CSheetId &soundName)
{
	TMarkerSoundSet::iterator iter = _Sounds.find(soundName);
    if (iter != _Sounds.end())
	{
		_Sounds.erase(iter);
	}
	else
	{
		nlwarning("No sound was removed (%s)", soundName.toString().c_str()/*CStringMapper::unmap(soundName).c_str()*/);
	}
}
bool CRingAccess::isSheetClient(const NLMISC::CSheetId& sheet) const
{

	static const std::string racesStr[] = { "matis_", "fyros_", "tryker_", "zorai_"};
	static const uint32 racesLen[] = { 6, 6, 7 ,6 };
	static const std::string sexsStr[] = { "male", "female"};
	static const uint32 sexsLen[] = { 4, 6};
	static const std::string basic = "basic_";
	static const uint32 basicLength = 6;


	std::string sheetStr = sheet.toString();
	uint32 sheetLength = (uint32)sheetStr.length();



	if (sheetLength >= basicLength && sheetStr.substr(0, basicLength) == basic)
	{
		// good thing is a basic_* something
		for (uint32 i = 0; i < 4 ; ++i)
		{
			const uint32 raceLength = racesLen[i];
			if (  sheetLength > basicLength + raceLength && sheetStr.substr(basicLength, raceLength) ==  racesStr[i])
			{

				// good thing is a basic_race_
				for (uint32 j = 0; j < 2 ; ++j)
				{
					uint32 sexLength = sexsLen[j];
					if (sheetLength > basicLength + raceLength + sexLength && sheetStr.substr(basicLength + raceLength, sexLength)  == sexsStr[j])
					{
						return true;
					}
				}
			}
		}
	}

	return false;
}
Beispiel #5
0
//=======================================================
void CSeasonFXSheet::build(const NLGEORGES::UFormElm &item, NLMISC::CSheetId parentId, const std::string &prefix)
{
	bool ok = true;
 	ok &= item.getValueByName(FXName, (prefix + "FXName").c_str());
	if (FXName.empty()) return;
	uint32 fxMode = 0;
	ok &= item.getValueByName(fxMode, (prefix + "Mode").c_str());
	Mode = (TMode) fxMode;
	ok &= item.getValueByName(CycleDuration, (prefix + "CycleDuration").c_str());
	ok &= item.getValueByName(StartHourMin, (prefix + "StartHourMin").c_str());
	ok &= item.getValueByName(StartHourMax, (prefix + "StartHourMax").c_str());
	ok &= item.getValueByName(EndHourMin, (prefix + "EndHourMin").c_str());
	ok &= item.getValueByName(EndHourMax, (prefix + "EndHourMax").c_str());
	ok &= item.getValueByName(InheritScale, (prefix + "InheritScale").c_str());
	ok &= item.getValueByName(InheritRot, (prefix + "InheritRot").c_str());
	ok &= item.getValueByName(AngleMin, (prefix + "AngleMin").c_str());
	ok &= item.getValueByName(AngleMax, (prefix + "AngleMax").c_str());
	ok &= item.getValueByName(DontRotate, (prefix + "DontRotate").c_str());
	ok &= item.getValueByName(DontRotateAroundLocalZ, (prefix + "DontRotateAroundLocalZ").c_str());
	ok &= item.getValueByName(ScaleMin.x, (prefix + "ScaleMinX").c_str());
	ok &= item.getValueByName(ScaleMin.y, (prefix + "ScaleMinY").c_str());
	ok &= item.getValueByName(ScaleMin.z, (prefix + "ScaleMinZ").c_str());
	ok &= item.getValueByName(ScaleMax.x, (prefix + "ScaleMaxX").c_str());
	ok &= item.getValueByName(ScaleMax.y, (prefix + "ScaleMaxY").c_str());
	ok &= item.getValueByName(ScaleMax.z, (prefix + "ScaleMaxZ").c_str());
	ok &= item.getValueByName(UniformScale, (prefix + "UniformScale").c_str());
	ok &= item.getValueByName(WantScaling, (prefix + "WantScaling").c_str());
	ok &= item.getValueByName(AlignOnWater, (prefix + "AlignOnWater").c_str());
	ok &= item.getValueByName(ZOffset, (prefix + "ZOffset").c_str());

	// Anti Crash
	if(CycleDuration<=0)
	{
		nlwarning("FX: CPlantSheet '%s' has a season with a CycleDuration<=0: %f !!!!! setting it to 0.1.",
			parentId.toString().c_str(), CycleDuration);
		CycleDuration= 0.1f;
	}

	StartHourMin = fmodf(StartHourMin, CycleDuration);
	StartHourMax = fmodf(StartHourMax, CycleDuration);
	EndHourMin   = fmodf(EndHourMin, CycleDuration);
	EndHourMax   = fmodf(EndHourMax, CycleDuration);

	nlassert(isValidDouble(StartHourMin));
	nlassert(isValidDouble(StartHourMax));
	nlassert(isValidDouble(EndHourMin));
	nlassert(isValidDouble(EndHourMax));
	nlassert(isValidDouble(CycleDuration));

	for(uint k = 0; k < 4; ++k)
	{
		ok &= item.getValueByName(UserParamsMin[k], (prefix + NLMISC::toString("UserParam%dMin", (int) k)).c_str());
		ok &= item.getValueByName(UserParamsMax[k], (prefix + NLMISC::toString("UserParam%dMax", (int) k)).c_str());
	}
	ok &= item.getValueByName(MinDuration, (prefix + "MinDuration").c_str());
	ok &= item.getValueByName(MaxDuration, (prefix + "MaxDuration").c_str());
	// prevent from overlapping interval
	if (Mode != AlwaysStarted && Mode != UseDuration && Mode != Spawn)
	{
		float startHourMin = StartHourMin;
		float startHourMax = StartHourMax;
		if (startHourMax < startHourMin)
		{
			startHourMax += CycleDuration;
		}
		float endHourMin = EndHourMin;
		float endHourMax = EndHourMax;
		if (endHourMax < endHourMin)
		{
			endHourMax += CycleDuration;
		}
		if (!(startHourMax <= endHourMin || startHourMin >= endHourMax))
		{
			// intervals overlap -> bad
			nlwarning("Overlapping time intervals for fx spawn.");
			if (startHourMin <= endHourMin)
			{
				float inter = endHourMin;
				if (inter >= CycleDuration)
				{
					inter -= CycleDuration;
				}
				StartHourMax = inter;
			}
			else
			{
				float inter = startHourMin;
				if (inter >= CycleDuration)
				{
					inter -= CycleDuration;
				}
				EndHourMax = inter;
			}
		}
	}
	// compute duration of start interval
	float startHourMaxInterval;
	if (StartHourMin <= StartHourMax)
	{
		startHourMaxInterval = StartHourMax - StartHourMin;
	}
	else
	{
		startHourMaxInterval = CycleDuration - StartHourMin + StartHourMax;
	}
	NLMISC::clamp(MinDuration, 0.f, CycleDuration /*- startHourMaxInterval*/);
	NLMISC::clamp(MaxDuration, 0.f, CycleDuration /*- startHourMaxInterval*/);

	if (!ok)
	{
		nldebug("Key not found.");
	}
}
//-----------------------------------------------
// CStaticLightCycle readGeorges
//-----------------------------------------------
void CStaticLightCycle::readGeorges( const NLMISC::CSmartPtr<NLGEORGES::UForm> &form, const NLMISC::CSheetId &sheetId )
{
	if( form )
	{
		UFormElm& root = form->getRootNode();

		vector< string > season;
		season.push_back( string("Spring") );
		season.push_back( string("Summer") );
		season.push_back( string("Autumn") );
		season.push_back( string("Winter") );

		uint NbSeasons = 4;
		LightCycles.resize( NbSeasons );

		for( uint i = 0; i < NbSeasons; ++i )
		{
			UFormElm* SeasonElt = NULL;
			if( ! ( root.getNodeByName( &SeasonElt, season[ i ].c_str() ) && SeasonElt ) )
			{
				nlwarning("<CStaticLightCycle readGeorges> can get node %s in sheet %s", season[ i ].c_str(), sheetId.toString().c_str() );
			}
			else
			{
				// Day hour
				if( ! SeasonElt->getValueByName( LightCycles[ i ].DayHour, "DayHour" ) )
				{
					nlwarning("<CStaticLightCycle readGeorges> can get value DayHour in node %d on SeasonElt structure in sheet %s", i, sheetId.toString().c_str() );
				}

				// Day to dusk hour
				if( ! SeasonElt->getValueByName( LightCycles[ i ].DayToDuskHour, "DayToDuskHour" ) )
				{
					nlwarning("<CStaticLightCycle readGeorges> can get value DayToDuskHour in node %d on SeasonElt structure in sheet %s", i, sheetId.toString().c_str() );
				}

				// Dusk to night hour
				if( ! SeasonElt->getValueByName( LightCycles[ i ].DuskToNightHour, "DuskToNightHour" ) )
				{
					nlwarning("<CStaticLightCycle readGeorges> can get value DuskToNightHour in node %d on SeasonElt structure in sheet %s", i, sheetId.toString().c_str() );
				}

				// Night hour
				if( ! SeasonElt->getValueByName( LightCycles[ i ].NightHour, "NightHour" ) )
				{
					nlwarning("<CStaticLightCycle readGeorges> can get value NightHour in node %d on SeasonElt structure in sheet %s", i, sheetId.toString().c_str() );
				}

				// Night to day hour
				if( ! SeasonElt->getValueByName( LightCycles[ i ].NightToDayHour, "NightToDayHour" ) )
				{
					nlwarning("<CStaticLightCycle readGeorges> can get value NightToDayHour in node %d on SeasonElt structure in sheet %s", i, sheetId.toString().c_str() );
				}
			}
		}
	}
}// CStaticLightCycle readGeorges
//--------------------------------------------------------------
//						loadFromGeorges()  
//--------------------------------------------------------------
void CStaticHarvestable::loadFromGeorges( const UForm &form, const NLMISC::CSheetId &sheetId )
{	
	_Mps.clear();
/*
//	getVarListFromParents	(&form, arrayList,	"Harvest");

	std::set<NLGEORGES::UFormElm*>	arrayList;
	{
		NLGEORGES::UFormElm	*tmpelem=NULL;
		const_cast<NLGEORGES::UFormElm*>(&form.getRootNode())->getNodeByName(&tmpelem, "Harvest");
		if (tmpelem)
		{
			arrayList.insert(tmpelem);
		}
	}

	if (arrayList.empty())
	{
		return;
	}

	for	(std::set<NLGEORGES::UFormElm*>::iterator	it=arrayList.begin(), itEnd=arrayList.end(); it!=itEnd;++it)
	{
		NLGEORGES::UFormElm	*elem=*it;
*/
		{
			string value;
			if	(	form.getRootNode().getValueByName( value, (string("Harvest.")+"Skill").c_str() )
				&&	!value.empty()	)
			{
				_HarvestSkill = SKILLS::toSkill( value );
			}

		}

		// in Georges sheet MP starts with MP1 and ends with MP10
		if (VerboseQuartering)
			nldebug("QRTR: Loading RMs of creatures %s", sheetId.toString().c_str());
		for (uint i = 1 ; i <= NbRawMaterials ; ++i)
		{
			const string mpName=NLMISC::toString("MP%u",i);
			CStaticCreatureRawMaterial	mp;
			
			if( form.getRootNode().getValueByName( mp.MpCommon.AssociatedItemName, ("Harvest." +mpName+".AssociatedItem").c_str())
				&& !mp.MpCommon.AssociatedItemName.empty() )
			{
				if (VerboseQuartering)
					nldebug("QRTR: %s=%s", mpName.c_str(), mp.MpCommon.AssociatedItemName.c_str());

				form.getRootNode().getValueByName( mp.MpCommon.Name,		("Harvest." +mpName+".Name").c_str()			);
				uint16 sheetQuantity;
				form.getRootNode().getValueByName( sheetQuantity,			("Harvest." +mpName+".Quantity").c_str()		);
				if ( sheetQuantity != 0 )
				{
					nlwarning( "Quantity set to %hu in %s", sheetQuantity, sheetId.toString().c_str() );
				}
				form.getRootNode().getValueByName( mp.MpCommon.MinQuality,	("Harvest." +mpName+".MinQuality").c_str()		);
				form.getRootNode().getValueByName( mp.MpCommon.MaxQuality,	("Harvest." +mpName+".MaxQuality").c_str()		);
	//			harvest->getValueByName( mp.PresenceProbabilities,	(mpName+".PresenceProbabilities").c_str()	);

				mp.ItemId = mp.MpCommon.AssociatedItemName;
				if ( mp.MpCommon.MinQuality == 0)
					mp.MpCommon.MinQuality = 1;
				if ( mp.MpCommon.MaxQuality == 0)
					mp.MpCommon.MaxQuality = 5;
				/// end temp hack

				const CStaticItem *staticItem = CSheets::getForm( mp.ItemId );
				if ( staticItem )
				{
					string itemSheetCode = mp.ItemId.toString();

					// Identify the usage of the RM (if it is a raw material for mission or craft) or fixed quantity (for invasion reward)
					if ( ( itemSheetCode.find( "ixx" ) != string::npos) ||
						 ( itemSheetCode.find( "cxx" ) != string::npos ) )
					{
						if (VerboseQuartering)
							nldebug("QRTR: For invasions");

						if( itemSheetCode == "m0077ixxcc01.sitem" )
						{
							mp.UsageAndQuantity.Usage = (uint16)RMUTotalQuantity;
							mp.UsageAndQuantity.QuantityVar = (TRMQuantityVariable)(RMQVForceBase+5);
						}
						else
						{
							// Invasion/goo raw material: fixed quantity, depending on creature local level
							//nldebug( "%s/%s: fixed quantity", sheetId.toString().c_str(), itemSheetCode.c_str() );
							mp.UsageAndQuantity.Usage = (uint16)RMUFixedQuantity;
							string creatureCode = sheetId.toString();
							uint16 creatureLocalLevel;
							form.getRootNode().getValueByName( creatureLocalLevel, "Basics.LocalCode" );
							if ( itemSheetCode.size() >= 12 )
							{
								uint itemVariant = (uint)(itemSheetCode[11] - '0');
								switch ( itemVariant )
								{
								case 1:
									if ( creatureLocalLevel < 5 )
										mp.UsageAndQuantity.QuantityVar = (TRMQuantityVariable)(RMQVForceBase+(uint)creatureLocalLevel) ;
									else if ( creatureLocalLevel < 7 )
										mp.UsageAndQuantity.QuantityVar = RMQVInvasion5;
									else if ( creatureLocalLevel < 9 )
										mp.UsageAndQuantity.QuantityVar = RMQVInvasion7;
									else
									{
										nlwarning( "Invalid creature local level in %s", creatureCode.c_str() );
										mp.UsageAndQuantity.QuantityVar = RMQVForceBase; // 0
									}
									break;
								case 2:
									if ( creatureLocalLevel < 5 )
										mp.UsageAndQuantity.QuantityVar = RMQVForceBase; // 0
									else if ( creatureLocalLevel < 7 )
										mp.UsageAndQuantity.QuantityVar = (TRMQuantityVariable)(RMQVForceBase+1) ;
									else if ( creatureLocalLevel < 9 )
										mp.UsageAndQuantity.QuantityVar = (TRMQuantityVariable)(RMQVForceBase+3) ;
									else
									{
										nlwarning( "Invalid creature local level in %s", creatureCode.c_str() );
										mp.UsageAndQuantity.QuantityVar = RMQVForceBase; // 0
									}
									break;
								default:;
								}
							}
						}
						//nldebug( "Creature: %s, RM: %s, Quantity: %hu", creatureCode.c_str(), itemSheetCode.c_str(), mp.UsageAndQuantity.Quantity );

						// Add item only if it has not a 0 fixed-quantity
						if ( mp.quantityVariable() >= NBRMQuantityVariables )
							nlwarning( "Invalid quantity variable" );
						else if ( mp.quantityVariable() != RMQVForceBase )
							_Mps.push_back( mp );
						else
						{
							if (VerboseQuartering)
								nldebug("QRTR: Qtty=0, not added");
						}

					}
					else if ( staticItem->Mp && (! staticItem->Mp->MpFaberParameters.empty()) )
					{
						if (VerboseQuartering)
							nldebug("QRTR: For craft");

						// Raw material for craft
						mp.UsageAndQuantity.Usage = (uint16)RMUTotalQuantity;
						uint16 creatureLocalLevel;
						form.getRootNode().getValueByName( creatureLocalLevel, "Basics.LocalCode" );
						if ( creatureLocalLevel < 5 )
						{
							// Identify the type of creature
							if ( (itemSheetCode.size() > 7) &&
								((itemSheetCode[6]=='h') || (itemSheetCode[6]=='b') || (itemSheetCode[6]=='p')) )
							{
								mp.UsageAndQuantity.QuantityVar = RMQVHerbivore;
							}
							else
							{
								mp.UsageAndQuantity.QuantityVar = RMQVCarnivore;
							}
						}
						else
						{
							switch ( creatureLocalLevel )
							{
							case 5:
							case 8:
								mp.UsageAndQuantity.QuantityVar = RMQVBoss5;
								break;
							case 7:
								mp.UsageAndQuantity.QuantityVar = RMQVBoss7;
								break;
							default: // 6 and non-nomenclatured sheets
								mp.UsageAndQuantity.QuantityVar = RMQVForceBase;
							}
						}

						// Add item only if it has not a 0 fixed-quantity
						if ( mp.quantityVariable() >= NBRMQuantityVariables )
							nlwarning( "Invalid quantity variable" );
						else if ( mp.quantityVariable() != RMQVForceBase )
							_Mps.push_back( mp );
						else
						{
							if (VerboseQuartering)
								nldebug("QRTR: Qtty=0, not added");
						}
					}
					else
					{
						if (VerboseQuartering)
							nldebug("QRTR: For missions");

						// Raw material or item for mission
						_ItemsForMissions.push_back( mp.ItemId );
					}
				}
				else
				{
					// Cancel adding if item not found
					if (VerboseQuartering)
						nldebug("QRTR: %s not found", mp.MpCommon.AssociatedItemName.c_str());
				}
			}

		}

//	}

} // loadFromGeorges //
Beispiel #8
0
	//////////////////////////////////////////////////////////////////////////////////////////////////////////
	// create a system crafted item
	static CGameItemPtr createSystemCraftedItem( uint16 quantity, const NLMISC::CSheetId& sheet )
	{
		if (quantity == 0) return NULL;
		
		// if quantity > 1, check if item is stackable and check stack quantity
		if (quantity > 1)
		{
			const CStaticItem* form = CSheets::getForm( sheet );
			if( form )
			{
				if( form->Stackable < quantity )
				{
					quantity = (uint16) form->Stackable;
				}
			}
			else
			{
				nlwarning("<CFaberActionCommon::createACraftedItem> can't found form for item %s", sheet.toString().c_str());
			}
		}
		
		if (quantity > 1)
		{
			CSheetId idSheetStack("stack.sitem");
			CGameItemPtr stackItem = GameItemManager.createItem( idSheetStack, (uint16)1, CEntityId::Unknown, (sint16)0, false, CEntityId::Unknown );
			if( stackItem == NULL )
			{
				nlwarning("<CFaberActionCommon::createACraftedItem> Error while creating stack bag %s -> returned a NULL pointer", idSheetStack.toString().c_str() );
				return NULL;
			}
			else
			{
				uint32 hp = 0;
				uint32 hpmax = 0;
				for( int q = 0; q < quantity; ++q )
				{
					CGameItemPtr itemTmp = GameItemManager.createItem( const_cast< CSheetId& > ( sheet ), 1, const_cast<NLMISC::CEntityId&>(stackItem->getId()), (sint16)-1, true, CEntityId::Unknown );
					if (!hp && itemTmp != NULL)
					{
						hp = itemTmp->hp();
						hpmax = itemTmp->standardHP();
					}
				}
				return stackItem;	
			}
		}
		else // do not create a stack, as there is only one object
		{
			CGameItemPtr item = GameItemManager.createItem( const_cast< CSheetId& > ( sheet ), (uint16)1, CEntityId::Unknown, (sint16)0, true, CEntityId::Unknown  );
			if( item == NULL)
			{
				nlwarning("<CFaberActionCommon::createACraftedItem> Error while creating item %s -> returned a NULL pointer", sheet.toString().c_str() );
				return NULL;
			}
			return item;
		}
	} // createSystemCraftedItem //
Beispiel #9
0
// ***************************************************************************
void CSheetManagerEntry::readGeorges (const NLMISC::CSmartPtr<NLGEORGES::UForm> &form, const NLMISC::CSheetId &sheetId)
{
	// Load the form with given sheet id
	if (form)
	{
//		if (EntitySheet != NULL)
//			delete EntitySheet;

		CEntitySheet *sheet = NULL;

		std::string extension = NLMISC::CSheetId::fileExtensionFromType(sheetId.getSheetType());

		// create the new structure
		if (extension == "creature")
			sheet = new CCharacterSheet;
		else if(extension == "player")
			sheet = new CPlayerSheet;
		else if(extension == "fx")
			sheet = new CFXSheet;
		else if(extension == "building")
			sheet = new CBuildingSheet;
		else if(extension == "sitem" || extension == "item" )
			sheet = new CItemSheet;
		else if(extension == "plant")
			sheet = new CPlantSheet;
		else if(extension == "death_impact")
			sheet = new CPactSheet;
		else if(extension == "mission")
			sheet = new CMissionSheet;
		else if(extension == "race_stats")
			sheet = new CRaceStatsSheet;
		else if(extension == "light_cycle")
			sheet = new CLightCycleSheet;
		else if(extension == "weather_setup")
			sheet = new CWeatherSetupSheet;
		else if(extension == "continent")
			sheet = new CContinentSheet;
		else if(extension == "world")
			sheet = new CWorldSheet;
		else if(extension == "weather_function_params")
			sheet = new CWeatherFunctionParamsSheet;
		else if(extension == "mission_icon")
			sheet = new CMissionIconSheet;
		else if(extension == "sbrick")
			sheet = new CSBrickSheet;
		else if(extension == "sphrase")
			sheet = new CSPhraseSheet;
		else if(extension == "skill_tree")
			sheet = new CSkillsTreeSheet;
		else if(extension == "titles")
			sheet = new CUnblockTitlesSheet;
		else if(extension == "succes_chances_table")
			sheet = new CSuccessTableSheet;
		else if(extension == "automaton_list")
			sheet = new CAutomatonListSheet;
		else if(extension == "animset_list")
			sheet = new CAnimationSetListSheet;
		else if(extension == "animation_fx")
			sheet = new CAnimationFXSheet;
		else if(extension == "id_to_string_array")
			sheet = new CIDToStringArraySheet;
		else if(extension == "emot")
			sheet = new CEmotListSheet;
		else if(extension == "forage_source")
			sheet = new CForageSourceSheet;
		else if(extension == "flora")
			sheet = new CFloraSheet;
		else if(extension == "animation_fx_set")
			sheet = new CAnimationFXSetSheet;
		else if(extension == "attack_list")
			sheet = new CAttackListSheet;
		else if(extension == "text_emotes")
			sheet = new CTextEmotListSheet;
		else if(extension == "sky")
			sheet = new CSkySheet;
		else if(extension == "outpost")
			sheet = new COutpostSheet;
		else if(extension == "outpost_building")
			sheet = new COutpostBuildingSheet;
		else if(extension == "outpost_squad")
			sheet = new COutpostSquadSheet;
		else if(extension == "faction")
			sheet = new CFactionSheet;
		else
		{
			nlwarning("CSheetManager::loadSheet: Do not know how to create the class from the sheet '%s'.", sheetId.toString().c_str());
			return;
		}

		// Build the sheet from an external file.
		sheet->Id = sheetId;
		sheet->build(form->getRootNode());

		EntitySheet = sheet;
		SheetMngr.processSheet(EntitySheet);
	}
	// Error while loading the form.
	else
	{
//		nlwarning("CSheetManager::loadSheet: Cannot load the form '%s'.", filename.c_str());
		EntitySheet = 0;
	}
}
Beispiel #10
0
//-----------------------------------------------
// CFaberPhrase systemCraftItem:
//-----------------------------------------------
CGameItemPtr CFaberPhrase::systemCraftItem( const NLMISC::CSheetId& sheet, const std::vector< NLMISC::CSheetId >& Mp, const std::vector< NLMISC::CSheetId >& MpFormula )
{
	H_AUTO(CFaberPhrase_systemCraftItem);

	std::vector< const CStaticBrick* > bricks;
	_RootFaberPlan = CSheets::getSBrickForm( sheet );
	const CStaticBrick * rootFaberBricks = CSheets::getSBrickForm( CSheetId("bcpa01.sbrick") );
	if( rootFaberBricks )
	{
		_RootFaberBricks = true;
	}
	else
	{
		nlwarning("<CFaberPhrase::systemCraftItem> Can't found form of root faber brick bcpa01.sbrick");
		return 0;
	}

	CGameItemPtr craftedItem = 0;

	if( _RootFaberPlan && _RootFaberPlan->Faber )
	{
		_CraftedItemStaticForm = CSheets::getForm( _RootFaberPlan->Faber->CraftedItem );
		if( _CraftedItemStaticForm == 0 )
		{
			return 0;
		}

		bricks.push_back( rootFaberBricks );
		bricks.push_back( _RootFaberPlan );

		for( vector< NLMISC::CSheetId >::const_iterator it = Mp.begin(); it != Mp.end(); ++it )
		{
			const CStaticItem * mp = CSheets::getForm( (*it) );
			if( mp == 0 )
			{
				nlwarning("<CFaberPhrase::systemCraftItem> Can't found form for Mp %s for craft %s item", (*it).toString().c_str(), sheet.toString().c_str() );
				return 0;
			}
			_Mps.push_back( mp );
		}

		// Check quantity of gived Mps
		if( _RootFaberPlan->Faber->NeededMps.size() > _Mps.size() )
		{
			nlwarning("<CFaberPhrase::systemCraftItem> Not enought gived RM for crafting %s (gived Mp %d, Needed Mp %d)", sheet.toString().c_str(), _Mps.size(), _RootFaberPlan->Faber->NeededMps.size() );
			return 0;
		}

		for( vector< NLMISC::CSheetId >::const_iterator it = MpFormula.begin(); it != MpFormula.end(); ++it )
		{
			const CStaticItem * mp = CSheets::getForm( (*it) );
			if( mp == 0 )
			{
				nlwarning("<CFaberPhrase::systemCraftItem> Can't found form for Mp Formula %s for craft %s item", (*it).toString().c_str(), sheet.toString().c_str() );
				return 0;
			}
			_MpsFormula.push_back( mp );
		}

		// Check quantity of gived Mps formula
		if( _RootFaberPlan->Faber->NeededMpsFormula.size() > _MpsFormula.size() )
		{
			nlwarning("<CFaberPhrase::systemCraftItem> Not enought gived RM formula for crafting %s (gived Mp %d, Needed Mp %d)", sheet.toString().c_str(), _MpsFormula.size(), _RootFaberPlan->Faber->NeededMpsFormula.size() );
			return 0;
		}

		// build the craft action
		_FaberAction = IFaberActionFactory::buildAction( _ActorRowId, this, _CraftedItemStaticForm->Type );
		if ( !_FaberAction )
		{
			nlwarning( "<CFaberPhrase build> could not build action for root faber %s", _RootFaberPlan->SheetId.toString().c_str() );
			return 0;
		}
		_FaberAction->systemApply(this);
		if( _CraftedItem != 0 )
		{
			_CraftedItem->setDefaultColor();
		}
		craftedItem = _CraftedItem;
		_CraftedItem = 0;
	}
	return craftedItem;
} // systemCraftItem //
Beispiel #11
0
//-----------------------------------------------
// createInGameItem
//-----------------------------------------------
CGameItemPtr CGameItemManager::createInGameItem( uint16 quality, uint32 quantity, const NLMISC::CSheetId &sheet, const CEntityId &creatorId , const std::string * phraseId)
{
	H_AUTO(GIM_createInGameItem);

	static const CSheetId preorderSheetId("pre_order.sitem");
	
	if ( quantity == 0 || quality ==0 )
		return NULL;

//	static const CSheetId idSheetStack("stack.sitem");
	const CStaticItem* form = CSheets::getForm( sheet );
	if (!form)
	{
		nlwarning("<CCharacter::createInGameItem> Cannot find form of item %s", sheet.toString().c_str());
		return NULL;
	}

	CGameItemPtr item;
	CGameItemPtr sellingItem;
	// if item can be sold, get it in the sold items list
	if (	form->Family != ITEMFAMILY::RAW_MATERIAL 
		&&	form->Family != ITEMFAMILY::HARVEST_TOOL
		&&	form->Family != ITEMFAMILY::CRAFTING_TOOL
		&&	form->Family != ITEMFAMILY::CRYSTALLIZED_SPELL
		&&	form->Family != ITEMFAMILY::ITEM_SAP_RECHARGE
		&&	form->Family != ITEMFAMILY::FOOD
		)
	{
		vector< CGameItemPtr >::const_iterator it;
		const vector< CGameItemPtr >::const_iterator itEnd = CStaticItems::getStaticItems().end();
		for( it = CStaticItems::getStaticItems().begin(); it != itEnd; ++it )
		{
			if( (*it)->getSheetId() == sheet )
			{
				sellingItem = *it;
				break;
			}
		}
	}

	switch( form->Family )
	{
		case ITEMFAMILY::CRAFTING_TOOL:
		case ITEMFAMILY::HARVEST_TOOL:
		case ITEMFAMILY::RAW_MATERIAL:
		case ITEMFAMILY::TELEPORT:
		case ITEMFAMILY::CRYSTALLIZED_SPELL:
		case ITEMFAMILY::ITEM_SAP_RECHARGE:
		case ITEMFAMILY::MISSION_ITEM:
		case ITEMFAMILY::PET_ANIMAL_TICKET:
		case ITEMFAMILY::HANDLED_ITEM:
		case ITEMFAMILY::CONSUMABLE:
		case ITEMFAMILY::XP_CATALYSER:
		case ITEMFAMILY::SCROLL:
		case ITEMFAMILY::FOOD:
		case ITEMFAMILY::SCROLL_R2:
		case ITEMFAMILY::GENERIC_ITEM:
		{
			item = GameItemManager.createItem( const_cast< CSheetId& > ( sheet ), quality, true, true, creatorId);
		}
		break;
	default:
		{
			if( sellingItem != NULL )
			{
				item = sellingItem->getItemCopy();
				item->quality( quality );
				if ( phraseId )
					item->setPhraseId(*phraseId);
			}
			else if (sheet == preorderSheetId)
			{
				item = GameItemManager.createItem(sheet, quality, true, form->DropOrSell, creatorId);
			}
		}
		if( item == NULL)
		{
			nlwarning("<CCharacter::createInGameItem> Error while creating item : NULL pointer");
			return NULL;
		}
	}
	quantity = min(quantity, item->getMaxStackSize());
	item->setStackSize(quantity);
	return item;
} // createInGameItem //
Beispiel #12
0
//-----------------------------------------------
// readGeorges for CStaticSkillsTree
//
//-----------------------------------------------
void CStaticSkillsTree::readGeorges( const NLMISC::CSmartPtr<NLGEORGES::UForm> &form, const NLMISC::CSheetId &sheetId )
{
	if( form )
	{
		UFormElm& root = form->getRootNode();
		
		UFormElm *arraySkillElt = NULL;
		if( root.getNodeByName( &arraySkillElt, "SkillData" ) )
		{
			if( arraySkillElt )
			{
				uint NbSkills;
				nlverify( arraySkillElt->getArraySize( NbSkills ) );

				nlassertex( NbSkills == SKILLS::NUM_SKILLS, ("(%u != %u) Please synchronise game_share/skill.* with leveldesign/game_element/xp_table/skills.skill_tree (use skill_extractor.exe)", NbSkills, SKILLS::NUM_SKILLS));

				SkillsTree.resize( NbSkills );
				
				for( uint i = 0; i < NbSkills; ++i )
				{
					UFormElm* SkillElt = NULL;
					if( ! ( arraySkillElt->getArrayNode( &SkillElt, i ) && SkillElt ) )
					{
						nlwarning("<CStaticSkillsTree::readGeorges> can't get array node of SkillElt in sheet %s", sheetId.toString().c_str() );
					}
					else
					{
						// Skill
						string SkillName;
						SkillElt->getValueByName( SkillName, "Skill" );
						SKILLS::ESkills skill = SKILLS::toSkill( SkillName );
						nlassert( skill != SKILLS::unknown );
						if (skill == SKILLS::unknown)
						{
							continue;
						}
						SkillsTree[ skill ].Skill = skill;

						if( ! SkillElt->getValueByName( SkillsTree[ skill ].SkillCode, "SkillCode" ) )
						{
							nlwarning("<CStaticSkillsTree::readGeorges> can't get node SkillCode in sheet %s", sheetId.toString().c_str() );
						}

						// Skill Code
						if( ! SkillElt->getValueByName( SkillsTree[ skill ].SkillCode, "SkillCode" ) )
						{
							nlwarning("<CStaticSkillsTree::readGeorges> can't get node SkillCode in sheet %s", sheetId.toString().c_str() );
						}

						// Max skill value
						if( ! SkillElt->getValueByName( SkillsTree[ skill ].MaxSkillValue, "MaxSkillValue" ) )
						{
							nlwarning("<CStaticSkillsTree::readGeorges> can't get node MaxSkillValue in sheet %s", sheetId.toString().c_str() );
						}

						// Type of stage
						if( ! SkillElt->getValueByName( SkillsTree[ skill ].StageType, "Type of Stage" ) )
						{
							nlwarning("<CStaticSkillsTree::readGeorges> can't get node 'Type of Stage' in sheet %s", sheetId.toString().c_str() );
						}

						// ParentSkill
						if( ! SkillElt->getValueByName( SkillName, "ParentSkill" ) )
						{
							nlwarning("<CStaticSkillsTree::readGeorges> can't get node ParentSkills in sheet %s", sheetId.toString().c_str() );
						}
						else
						{	
							SkillsTree[ skill ].ParentSkill = SKILLS::toSkill( SkillName );
						}

						// ChildSkills
						UFormElm *arrayChildSkillElt = NULL;
						if( SkillElt->getNodeByName( &arrayChildSkillElt, "ChildSkills" ) )
						{
							if( arrayChildSkillElt )
							{
								uint NbChildSkills;
								nlverify( arrayChildSkillElt->getArraySize( NbChildSkills ) );
								
								SkillsTree[ skill ].ChildSkills.resize( NbChildSkills );
								
								for( uint i = 0; i < NbChildSkills; ++i )
								{
									string childSkillName;
									arrayChildSkillElt->getArrayValue( childSkillName, i );
									SKILLS::ESkills childSkill = SKILLS::toSkill( childSkillName );
									nlassert( childSkill != SKILLS::unknown );
									if (skill == SKILLS::unknown)
									  {
										continue;
									  }
									SkillsTree[ skill ].ChildSkills[ i ] = childSkill;
								}
							}
						}
					}
				}
			}
		}
	}
}