高级玩家

- 贡献度
- 73
- 金元
- 2168
- 积分
- 449
- 精华
- 0
- 注册时间
- 2010-3-21
|
下载这个新AI解开,里面有很多有趣的想法
http://www.sc2mapster.com/assets/hexbox-starcraft-2-ai/files/1-hex-box-sc2-ai-prototype/
贴一点上来
void UnitGroupAttack(int player, unitgroup UGroup, point Targ) {
int i;
unit SelUnit;
int groupSize;
order ord;
i=0;
groupSize = UnitGroupCount(UGroup, c_unitCountAlive);
while (i < groupSize) {
SelUnit = UnitGroupUnit(UGroup,i); //select one muta of the group
//give teh orderz
ord = AICreateOrder(player, c_AB_Attack, 0);
//ord = AICreateOrder(player, "move", 0);
OrderSetTargetPoint(ord, Targ);
if (UnitOrderIsValid(SelUnit, ord)) {
AICast(SelUnit, ord, c_noMarker, c_castHold);
}
else{}
i = i+1;
}
}
//returns true if one of the units in the group has an enemy
//within the given range
bool CheckEnemyInRange(int player, unitgroup UGroup, int givenRange) {
fixed UseRange = IntToFixed(givenRange);
unit SelUnit;
int i;
int groupCount;
unitgroup EnemyGroup;
//parse all units within the group and check
groupCount = UnitGroupCount(UGroup, c_unitCountAlive);
i=0;
while (i < groupCount) {
SelUnit = UnitGroupUnit(UGroup,i); //select one muta of the group
EnemyGroup = UnitGroupAlliance(player, c_unitAllianceEnemy,
RegionCircle(UnitGetPosition(SelUnit), UseRange),
null, c_noMaxCount);
EnemyGroup = UnitGroupFilterThreat(EnemyGroup, SelUnit, null, 0);
if (UnitGroupCount(EnemyGroup, c_unitCountAlive) > 0) {
//we have threats
return true;
}
else { }
i=i+1;
}
return false;
}
point GoPoint(int player, unit EnemyUnit, int UseRange){
region r;
point ELoc = UnitGetPosition(EnemyUnit);
point goodPoint;
int halfRange;
int thirdRange;
int fourthRange;
halfRange = UseRange / 2;
thirdRange = UseRange / 3;
fourthRange = UseRange / 4;
//create a region around the enemy unit
r = RegionCircle(ELoc, IntToFixed(UseRange));
//get a random spawn point in that region that is not close to the enemy unit's location
goodPoint = AIRandomSpawnPoint ( player,
r,
IntToFixed(UseRange),
IntToFixed(UseRange),
IntToFixed(UseRange));
return goodPoint;
}
point GoPointCloseIn(int player, unit EnemyUnit, int UseRange){
region r;
point ELoc = UnitGetPosition(EnemyUnit);
point goodPoint;
int halfRange;
int thirdRange;
int fourthRange;
halfRange = UseRange / 2;
thirdRange = UseRange / 3;
fourthRange = UseRange / 4;
//create a region around the enemy unit
r = RegionCircle(ELoc, IntToFixed(UseRange));
//get a random spawn point in that region that is not close to the enemy unit's location
goodPoint = AIRandomSpawnPoint ( player,
r,
IntToFixed(halfRange),
IntToFixed(halfRange),
IntToFixed(fourthRange));
return goodPoint;
}
void CommandOvie(int player, int CTown){
order ord;
point OTarg;
unit Ovie;
region r;
int WhichOne;
unit nearbyHatch;
//WhichOne = RandomInt(0,2);
nearbyHatch = AIGrabUnit(player, c_ZB_Hatchery_Alias, c_prioScriptControlled, AIGetTownLocation (player, -1));
Ovie = AIGrabUnit(player, c_ZU_Overlord, c_prioWaveIdle, AIGetTownLocation (player, CTown));
//Ovie = AIGrabUnit(player, c_ZU_Overlord, c_prioWaveIdle, null);
r = RegionCircle(UnitGetPosition(nearbyHatch), IntToFixed(20) );
//OTarg = AIGetBestCreepSpot(player, Ovie, IntToFixed(8));
//if (WhichOne == 0) {
// OTarg = AIGetBestCreepSpot(player, Ovie, IntToFixed(8));
//}
//else if (WhichOne == 1) {
// OTarg = AIPlacementNearbyFindTest (player, UnitGetPosition(nearbyHatch), IntToFixed(30), c_ZU_Overlord);
//}
//else {
OTarg = AIRandomSpawnPoint (player, r, IntToFixed(30), IntToFixed(40), IntToFixed(30));
//}
//WhichOne = RandomInt(0,2);
//if (WhichOne == 0) {
// ord = AICreateOrder(player, "stop", 0);//c_AB_Move
// OrderSetTargetPoint(ord, OTarg);
//}
//else {
ord = AICreateOrder(player, c_AB_Move, 0);
OrderSetTargetPoint(ord, OTarg);
//}
if (UnitOrderIsValid(Ovie, ord)) {
AICast(Ovie, ord, c_noMarker, c_castHold);
}
else {}
} |
|