本文整理汇总了C++中CUnitTypeData::IsAirCraft方法的典型用法代码示例。如果您正苦于以下问题:C++ CUnitTypeData::IsAirCraft方法的具体用法?C++ CUnitTypeData::IsAirCraft怎么用?C++ CUnitTypeData::IsAirCraft使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUnitTypeData
的用法示例。
在下文中一共展示了CUnitTypeData::IsAirCraft方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DGunNearby
bool CActions::DGunNearby(int uid){
NLOG("CActions::DGunNearby");
CUnitTypeData* utd = G->UnitDefLoader->GetUnitTypeDataByUnitId(uid);
if(utd == 0 ){
G->L.print("Dgunning failed, utd == 0");
return false;
}
if(!utd->CanDGun()){
return false;
}
float3 compos = G->GetUnitPos(uid);
if(G->Map->CheckFloat3(compos)==false){
return false;
}
int* en = new int[10000];
int e = G->GetEnemyUnits(en, compos, G->cb->GetUnitMaxRange(uid)*1.3f); // get all enemy units within weapons range atm
if(e>0){
for(int i = 0; i < e; i++){
if(ValidUnitID(en[i])==false){
continue;
}
CUnitTypeData* edt = G->UnitDefLoader->GetUnitTypeDataByUnitId(en[i]);
//if(endi->isCommander == true) continue; // no dgunning enemy commanders!
// no dgunning enemy commanders is commented out because now if the enemy is a commander the CMD_DGUN is
// changed to CMD_RECLAIM, allowing the enemy commander to be eliminated without causing a wild goose chase of
// building dgunned building dgunned, commander in the way of building dgunned, BANG, both commanders bye bye
// that and the line needs fiddling anyway due to the CUnitTypeData refactor
if(edt->IsAirCraft()&&(edt->GetUnitDef()->speed<3)){
continue;// attempting to dgun an aircraft without predictive dgunning leads to a goose chase
}
int k = en[i];
delete [] en;
if(edt->GetUnitDef()->canDGun){
int r = (int)G->Pl->ReclaimTime(utd->GetUnitDef(), edt->GetUnitDef(), G->chcb->GetUnitHealth(k));
int c = (int)G->Pl->CaptureTime(utd->GetUnitDef(), edt->GetUnitDef(), G->chcb->GetUnitHealth(k));
if (r<(4 SECONDS) && r < c){
return Reclaim(uid, k);
} else {
if (c<(4 SECONDS)){
return Capture(uid, k);
} else {
NLOG("CActions::IfNobodyNearMoveToNearest :: WipePlansForBuilder");
return MoveToStrike(uid, G->Map->nbasepos(compos), false);
}
}
} else {
if (utd->GetDGunCost()<G->cb->GetEnergy()){
return DGun(uid, k);
} else {
int r = (int)G->Pl->ReclaimTime(utd->GetUnitDef(), edt->GetUnitDef(), G->chcb->GetUnitHealth(k));
int c = (int)G->Pl->CaptureTime(utd->GetUnitDef(), edt->GetUnitDef(), G->chcb->GetUnitHealth(k));
if(r<(4 SECONDS) && r < c){
return Reclaim(uid, k);
} else {
if (c<(4 SECONDS)){
return Capture(uid, k);
} else {
return MoveToStrike(uid, G->Map->nbasepos(compos), false);
}
}
}
}
}
}else{
// we aint got enemies within immediate range, however this doesnt mean we're safe.
// check fi there are nearby enemy groups
// check the surrounding units and repair them if necessary.
// if none need repairing then retreat, this may be an enemy base or an incoming army
e = G->GetEnemyUnits(en, compos, G->cb->GetUnitMaxRange(uid)*2.5f); // get all enemy units within weapons range atm
if(e > 0){
float total_enemy_power = 0;
float total_allied_power = 0;
for(int i = 0; i < e; i++){
//.........这里部分代码省略.........