Ejemplo n.º 1
0
	string CUBuild::GetMEX(){
		NLOG("CUBuild::GetMEX");
		// Find all metal extractors this unit can build and add them to a list.
		float highscore= 0;
		string highest="";
		for(map<int,string>::const_iterator is = utd->GetUnitDef()->buildOptions.begin(); is != utd->GetUnitDef()->buildOptions.end();++is){

			CUnitTypeData* p = G->UnitDefLoader->GetUnitTypeDataByName(is->second);

			if(p->IsMex()){
				if(Useless(p)){
					continue;
				}

				float score = (p->GetUnitDef()->extractsMetal+1)*1000;
				if(p->GetUnitDef()->weapons.empty()==false){
					score *= 1.2f;
				}

				if(p->GetUnitDef()->canCloak==true){
					score *= 1.2f;
				}

				score /= (p->GetUnitDef()->energyCost+(p->GetUnitDef()->metalCost*45));
				if(score > highscore){
					highscore = score;
					highest = p->GetUnitDef()->name;
				}

				continue;
			}

			if((p->GetUnitDef()->metalMake > 5)&&(p->GetUnitDef()->builder == false)&&(p->GetUnitDef()->movedata == 0 )&&(p->GetUnitDef()->canfly == false)){
				float score = p->GetUnitDef()->metalMake;
				if(p->GetUnitDef()->weapons.empty()==false){
					score *= 1.2f;
				}
				if(p->GetUnitDef()->canCloak==true){
					score *= 1.2f;
				}
				score /= (p->GetUnitDef()->energyCost+(p->GetUnitDef()->metalCost*45));
				if(score > highscore){
					highscore = score;
					highest = p->GetUnitDef()->name;
				}
				continue;
			}
		}
		return highest;
	}