Beispiel #1
0
// Assigne une nouvelle MP à une creature
void AssignerMP( const CSString& creatureName, const CSString& materialName )
{
	// on regarde si la créature est dégénérée ou non
	if ( ( creatureName.c_str()[3] != 'c' ) && ( creatureName.c_str()[3] != 'd' ) 
		&& ( creatureName.c_str()[3] != 'f' ) && ( creatureName.c_str()[3] != 'j' )
		&& ( creatureName.c_str()[3] != 'l' ) && ( creatureName.c_str()[3] != 'p' ) )
	{
	}
	else
	{
		// lecture du fichier d'assignement
		CSString fileName = toString( "%s//_%s_mp.creature", RAW_MATERIAL_ASSIGN.c_str(), creatureName.c_str() ); 
		CSString data;

		// création si le fichier n'existe pas
		if(!CFile::fileExists(fileName))
		{
			CSString	str;
			str = "<?xml version=\"1.0\"?>\r\n";
			str+= "<FORM Version=\"0.0\" State=\"modified\">\r\n";
			str+= "  <STRUCT>\r\n";
			str+= "    <STRUCT Name=\"Harvest\">\r\n";
			str+= "    </STRUCT>\r\n";
			str+= "  </STRUCT>\r\n";
			str+= "  <STRUCT/>\r\n";
			str+= "  <STRUCT/>\r\n";
			str+= "  <STRUCT/>\r\n";
			str+= "  <STRUCT/>\r\n";
			str+= "</FORM>\r\n";
			str.writeToFile( fileName );
		}

		// lecture
		data.readFromFile( fileName );

		if ( !data.contains( materialName.c_str() ) )
		{	
			// on recherche le premier numéro de MP non utilisé
			CSString str = data;
			int nb= 0;
			while ( str.contains( "Name=\"MP" ) )
			{
				str = str.splitFrom( "Name=\"MP" );
				nb = str.firstWord().atoi();
			}

			// on insère la nouvelle MP
			str = "      <STRUCT Name=\"MP";
			str += toString( "%d\">\r\n        <ATOM Name=\"AssociatedItem\"", nb+1 );
			str += toString( " Value=\"%s\"/>\r\n      </STRUCT>\r\n    </STRUCT>\r\n  </STRUCT>\r\n", materialName.c_str() );
			
			data = data.replace( "    </STRUCT>\r\n  </STRUCT>\r\n", str.c_str() );
			data.writeToFile( fileName );
		}
	}
}
Beispiel #2
0
// Pour une MP se trouvant sur un créature, génération de ses items
void GenerateCreatureItems( int numMP, CSString& nomMP, const MPCraftStats& craftStats )
{
	map<CSString, ListeCreatureMP>::const_iterator itLCMP;
	int quality;
	static int statQuality[] = { 0, 1, 0, 1, 3, 6, 4, 2 };

	// On obtient la liste des niveau d'item à generer pour la créature
	itLCMP = itemsAGenerer.find( nomMP.firstWord() );

	if ( itLCMP != itemsAGenerer.end() )
	{
		ListeCreatureMP::const_iterator itMP = (*itLCMP).second.begin();

		// pour chaque niveau d'item à générer
		while ( itMP != (*itLCMP).second.end() )
		{
			// on enregistre ses caractéristiques
			char eco = (*itMP)->eco;
			int creatureLevel = (*itMP)->creatureLevel;
			int itemLevel = (*itMP)->itemLevel;
			CSString creatureFileName = "c";
			creatureFileName += (*itMP)->codeCreature.toLower();
			
			if ( craftStats.Craft != "" )
			{
				quality = statQuality[creatureLevel-1];
				if ( quality != 6 )
				{						
					if ( quality < 2 )
					{
						CreateSheet( numMP, nomMP, creatureFileName, 'c', quality, craftStats );

						AssignerMP( (*itMP)->creatureFileName, 
							toString( "m%04d%s%c%c01.sitem", numMP, creatureFileName.c_str(), 'c', 'a' + quality ) );
					}
					else
					{
						CreateSheet( numMP, nomMP, creatureFileName, eco, quality, craftStats );

						AssignerMP( (*itMP)->creatureFileName, 
							toString( "m%04d%s%c%c01.sitem", numMP, creatureFileName.c_str(), eco, 'a' + quality ) );
					}

					currentDocItem.push( DtCreature, (*itMP)->creatureFileName );
				}
			}
			else
			{
				// pas de MP de mission pour les boss
				if ( creatureLevel < 5 )
				{
					CreateSheet( numMP, nomMP, creatureFileName, eco, itemLevel, craftStats ); 

					AssignerMP( (*itMP)->creatureFileName, 
							toString( "m%04d%s%c%c01.sitem", numMP, creatureFileName.c_str(), eco, 'a' + itemLevel ) );

					currentDocItem.push( DtCreature, (*itMP)->creatureFileName );
				}
			}

			itMP++;
		}
	}
}