3DMGAME 3DM首页 新闻中心 前瞻 | 评测 游戏库 热门 | 最新 攻略中心 攻略 | 秘籍 下载中心 游戏 | 汉化 购买正版 论坛

注册 登录

QQ登录

只需一步,快速开始

查看: 3617|回复: 17
打印 上一主题 下一主题

[资料] 各位AI作者必看...... 精确控兵的一些方法

[复制链接]

0

主题

267

帖子

449

积分

高级玩家

Rank: 4

贡献度
73
金元
2168
积分
449
精华
0
注册时间
2010-3-21
跳转到指定楼层
主题
发表于 2010-4-8 18:25 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
下载这个新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 {}
}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|3DMGAME ( 京ICP备14006952号-1  沪公网安备 31011202006753号

GMT+8, 2026-4-6 15:30 , Processed in 0.364448 second(s), 18 queries , Memcached On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表