Ejemplo n.º 1
0
	string CUBuild::GetAIRSUPPORT(){
		NLOG("CUBuild::GetAIRSUPPORT");

		const vector<CommandDescription>* di = G->cb->GetUnitCommands(uid);
		if(di == 0) return string("");
		list<string> possibles;
		float best_score = 0;
		string best = "";

		for(vector<CommandDescription>::const_iterator is = di->begin(); is != di->end();++is){
			if(is->id<0){

				// retrieve the unit type information
				CUnitTypeData* p =G->UnitDefLoader->GetUnitTypeDataByName(is->name);
				const UnitDef* pd = p->GetUnitDef();

				if(p->IsHub()){
					if(G->Pl->feasable(p,utd)==false) continue;
					if(p->IsUWStructure()!=(water||G->info->spacemod)) continue;
					float temp = G->efficiency->GetEfficiency(pd->name);
					temp /= (pd->energyCost+(pd->metalCost*45));
					int r = G->mrand()%max(int(temp/4),1)+1;
					temp += (float)abs(r);
					if(temp > best_score){
						best_score = temp;
						best = p->GetName();
					}
				}
			}
		}
		return best;
	}