string CUBuild::GetASSAULT(){ NLOG("CUBuild::GetASSAULT"); 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){ const UnitDef* pd = G->GetUnitDef(is->name); if(pd == 0) continue; if(G->Pl->feasable(pd,ud)==false) continue; if(((pd->weapons.empty() == false)&&((pd->movedata)||(pd->canfly == true)))&&((((pd->speed > 70)&&(pd->canfly == false))||((pd->weapons.empty() == true)&&(pd->canfly == true)&&(pd->builder == false)&&(pd->isCommander == false))) == false)&&(pd->transportCapacity == 0)){ srand(uint(time(NULL) + G->Cached->randadd)); G->Cached->randadd++; float temp = G->GetEfficiency(pd->name); temp = temp - rand()%(int)(temp/3); if(temp > best_score){ best_score = temp; best = pd->name; } } } } if(best_score < 30){ return GetRAND_ASSAULT(); } return best; }
string CUBuild::GetASSAULT(){ NLOG("CUBuild::GetASSAULT"); 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){ CUnitTypeData* p = G->UnitDefLoader->GetUnitTypeDataByName(is->name); if(G->Pl->feasable(p,utd)==false){ continue; } if(p->IsAttacker()){ float temp = G->efficiency->GetEfficiency(p->GetName()); temp /= (p->GetUnitDef()->energyCost+(p->GetUnitDef()->metalCost*45)); temp -= (G->mrand()%max(int(temp/4),1)); if(temp > best_score){ best_score = temp; best = p->GetName(); } } } } if(best_score < 30){ return GetRAND_ASSAULT(); } return best; }
string CUBuild::operator() (btype build,float3 pos){// CBuild c; string s = c(btype build); NLOG("CUBuild::operator()"); if(ud->buildOptions.empty() == true) return string(""); switch(build){ case B_MEX :{ return GetMEX(); break; }case B_POWER:{ return GetPOWER(); break; }case B_RAND_ASSAULT:{ return GetRAND_ASSAULT(); break; }case B_ASSAULT:{ return GetASSAULT(); break; }case B_FACTORY_CHEAP:{ return GetFACTORY_CHEAP(); break; }case B_FACTORY:{ return GetFACTORY(); break; }case B_BUILDER:{ return GetBUILDER(); break; }case B_GEO:{ return GetGEO(); break; }case B_SCOUT:{ return GetSCOUT(); break; }case B_RANDOM:{ return GetRANDOM(); break; }case B_DEFENCE:{ return GetDEFENCE(); break; }case B_RADAR:{ return GetRADAR(); break; }case B_ESTORE:{ return GetESTORE(); break; }case B_MSTORE:{ return GetMSTORE(); break; }case B_SILO:{ return GetSILO(); break; }case B_JAMMER:{ return GetJAMMER(); break; }case B_SONAR:{ return GetSONAR(); break; }case B_ANTIMISSILE:{ return GetANTIMISSILE(); break; }case B_ARTILLERY:{ return GetARTILLERY(); break; }case B_FOCAL_MINE:{ return GetFOCAL_MINE(); break; }case B_SUB : { return GetSUB(); break; }case B_AMPHIB: { return GetAMPHIB(); break; }case B_MINE:{ return GetMINE(); break; }case B_CARRIER:{ return GetCARRIER(); break; }case B_METAL_MAKER:{ return GetMETAL_MAKER(); break; }case B_FORTIFICATION:{ return GetFORTIFICATION(); break; }case B_BOMBER:{ return GetBOMBER(); break; }case B_FIGHTER:{ return GetFIGHTER(); break; }case B_GUNSHIP:{ return GetGUNSHIP(); break; }case B_SHIELD:{ return GetSHIELD(); break; }case B_MISSILE_UNIT:{ return GetMISSILE_UNIT(); break; }default:{ return string("nought"); break; } } return string("nought"); }