本文整理汇总了C++中CUnitTypeData::IsMobile方法的典型用法代码示例。如果您正苦于以下问题:C++ CUnitTypeData::IsMobile方法的具体用法?C++ CUnitTypeData::IsMobile怎么用?C++ CUnitTypeData::IsMobile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUnitTypeData
的用法示例。
在下文中一共展示了CUnitTypeData::IsMobile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetDEFENCE
string CUBuild::GetDEFENCE(){
NLOG("CUBuild::GetDEFENCE");
const vector<CommandDescription>* di = G->cb->GetUnitCommands(uid);
if(di == 0) return string("");
list<string> possibles;
int defnum = 0;
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(Useless(p)) continue;
if((p->GetUnitDef()->weapons.empty() == false)&&(!p->GetUnitDef()->isFeature)&&(!p->IsMobile())){
if((G->info->spacemod == true)||(water == true)){
if(G->Pl->feasable(p,utd)==false) continue;
possibles.push_back(p->GetName());
defnum++;
} else if (pd->floater == false){
if(G->Pl->feasable(p,utd)==false) continue;
possibles.push_back(p->GetName());
defnum++;
}
}
}
}
if(possibles.empty() == false){
defnum = G->mrand()%defnum;
int j = 0;
for(list<string>::iterator k = possibles.begin(); k != possibles.end(); ++k){
if(j == defnum){
return *k;
}else{
j++;
}
}
return possibles.front();
}
return string("");
}
示例2: RepairNearbyUnfinishedMobileUnits
bool CActions::RepairNearbyUnfinishedMobileUnits(int uid, float radius){
NLOG("CActions::RepairNearbyUnfinishedMobileUnits");
const UnitDef* udi = G->cb->GetUnitDef(uid);
if(udi == 0) return false;
float3 pos = G->GetUnitPos(uid);
int* hn = new int[10000];
int h = G->cb->GetFriendlyUnits(hn, pos, radius);
if( h>0){
for( int i = 0; i<h; i++){
if(G->cb->UnitBeingBuilt(hn[i]) == true){
CUnitTypeData* btd = G->UnitDefLoader->GetUnitTypeDataByUnitId(hn[i]);
if(!btd->IsMobile()){
continue;
}
float Remainder = 1.0f - G->cb->GetUnitHealth(hn[i]) / G->cb->GetUnitMaxHealth(hn[i]);
float RemainingTime = btd->GetUnitDef()->buildTime / udi->buildSpeed * Remainder;
if (RemainingTime < 30.0f){
continue;
}
float EPerS = btd->GetUnitDef()->energyCost / (btd->GetUnitDef()->buildTime / udi->buildSpeed);
float MPerS = btd->GetUnitDef()->metalCost / (btd->GetUnitDef()->buildTime / udi->buildSpeed);
if (G->cb->GetMetal() + (G->Pl->GetMetalIncome() - MPerS) * RemainingTime > 0 && G->cb->GetEnergy() + (G->Pl->GetEnergyIncome() - EPerS) * RemainingTime > 0){
if (RemainingTime > 120.0f || btd->GetUnitDef()->buildSpeed > 0){
int target = hn[i];
delete [] hn;
return Repair(uid, target);
}
}
}
}
}else{
h = G->cb->GetFriendlyUnits(hn);
if(h <1){
return false;
}
for( int i = 0; i<h; i++){
if((G->cb->UnitBeingBuilt(hn[i])||(G->cb->GetUnitMaxHealth(hn[i])*0.6f > G->cb->GetUnitHealth(hn[i])))&&(G->cb->GetUnitTeam(hn[i]) == G->Cached->team)){
CUnitTypeData* btd = G->UnitDefLoader->GetUnitTypeDataByUnitId(hn[i]);
float Remainder = 1.0f - G->cb->GetUnitHealth(hn[i]) / G->cb->GetUnitMaxHealth(hn[i]);
float RemainingTime = btd->GetUnitDef()->buildTime / udi->buildSpeed * Remainder;
if (RemainingTime < 30.0f){
continue;
}
float EPerS = btd->GetUnitDef()->energyCost / (btd->GetUnitDef()->buildTime / udi->buildSpeed);
float MPerS = btd->GetUnitDef()->metalCost / (btd->GetUnitDef()->buildTime / udi->buildSpeed);
if (G->cb->GetMetal() + (G->Pl->GetMetalIncome() - MPerS) * RemainingTime > 0 && G->cb->GetEnergy() + (G->Pl->GetEnergyIncome() - EPerS) * RemainingTime > 0 ){
if (RemainingTime > 120.0f || btd->GetUnitDef()->buildSpeed > 0) {
int target = hn[i];
delete [] hn;
return Repair(uid, target);
}
}
}
}
}
delete [] hn;
return false;
}
示例3: AttackNear
bool CActions::AttackNear(int unit, float LOSmultiplier){
NLOG("CActions::AttackNear");
const UnitDef* ud = G->GetUnitDef(unit);
if(ud == 0) return false;
CUnitTypeData* utd = G->UnitDefLoader->GetUnitTypeDataById(ud->id);
int* en = new int[10000];
int e = G->GetEnemyUnits(en, G->GetUnitPos(unit), max(G->cb->GetUnitMaxRange(unit), ud->losRadius)*LOSmultiplier);
if(e>0){
float best_score = 0;
int best_target = 0;
float tempscore = 0;
bool mobile = true;
for(int i = 0; i < e; i++){
if(en[i] < 1) continue;
const UnitDef* endi = G->GetEnemyDef(en[i]);
if(endi == 0){
continue;
}else{
CUnitTypeData* etd = G->UnitDefLoader->GetUnitTypeDataById(endi->id);
bool tmobile = false;
tempscore = G->GetTargettingWeight(ud->name, endi->name);
//tempscore = G->Ch->ApplyGrudge(en[i], tempscore);
if(etd->IsMobile()){
if(!G->info->hardtarget){
tempscore = tempscore/4;
}
tmobile = true;
}else if(!endi->weapons.empty()){
tempscore /= 2;
}
if(tempscore > best_score){
best_score = tempscore;
best_target = en[i];
mobile = tmobile;
}
tempscore = 0;
}
}
if(ud->highTrajectoryType == 2){
Trajectory(unit, (int)mobile);
}
if(best_target > 0){
delete [] en;
return Attack(unit, best_target, mobile);
}
delete [] en;
return true;
}else{
delete [] en;
return false;
}
}