Xin hướng dẫn về viết AI (phục vụ cho việc học tập)

Thảo luận trong 'Starcraft' bắt đầu bởi Karmel, 27/9/11.

  1. Karmel

    Karmel Youtube Master Race

    Tham gia ngày:
    27/9/11
    Bài viết:
    2
    Mình học môn "Knowledge based system", có một bài luận về viết AI cho starcraft 2 :(
    Không biết có bác nào pro món này hoặc có tài liệu món này thì hướng dẫn cho mình với :|
     
  2. Madoi2010

    Madoi2010 Donkey Kong

    Tham gia ngày:
    30/11/09
    Bài viết:
    431
    Nơi ở:
    Hồ Chí Minh
    Đề tài hay nhỉ, AI 2 có kỹ thuật micro và macro tốt nếu bạn mới tập chơi, bạn sẽ bị choáng bởi những đợt kéo quân liên tục, bạn có thể thua chỉ trong vòng 5-10p nếu không có chiến thuật phù hợp, mình chỉ biết nhiêu đó (còn noob mà :)), hy vọng các cao thủ giúp bạn này.
    Mà cái đề tài về game mình mới nghe lần đầu, có thể sẽ giúp bạn kỹ năng Micro và Macro
    Tặng bạn http://teamvk.net/guides/phan-1-cac-khai-niem-co-ban/
     
  3. K3IIy

    K3IIy The Warrior of Light

    Tham gia ngày:
    7/8/11
    Bài viết:
    2,254
    Nơi ở:
    Hà Nội
    Bài luận hay vậy,học ở đâu thế?????????????
     
  4. Karmel

    Karmel Youtube Master Race

    Tham gia ngày:
    27/9/11
    Bài viết:
    2
    Mình học ở ĐH. KHTN HCM.

    ---------- Post added at 23:06 ---------- Previous post was at 23:04 ----------

    Mình học ở ĐH KHTN :)
     
  5. Only_Pass

    Only_Pass Mr & Ms Pac-Man Lão Làng GVN

    Tham gia ngày:
    16/9/04
    Bài viết:
    256
    Nơi ở:
    Hell
    Hay vậy, KHTN giờ tiến bộ vậy, bài luận viết AI cho SC2 luôn ah, bạn xem lại các topic cũ trong đây có người viết AI cho SC2 giỏi lắm đấy
     
  6. IntoTh3Rainbow

    IntoTh3Rainbow ~vkRainbow~ Moderator

    Tham gia ngày:
    8/2/03
    Bài viết:
    5,303
    Nơi ở:
    .
    mà AI cho SC2 thì ko thể gọi là Knowledge Based System dc =)), cái này là Expert System =))
     
  7. Seq

    Seq Youtube Master Race

    Tham gia ngày:
    19/11/10
    Bài viết:
    95
    AI của SC2 hiện giờ khá dơn giản: Easy -> Insane chỉ khác nhau ở build order. Khi máy thực hiện xong build order này thì nó A-move vào nhà mình.
     
  8. ptanhkhoa

    ptanhkhoa GVN D3 CHAMPION

    Tham gia ngày:
    13/7/08
    Bài viết:
    579
    @Seg: Không đơn giản như bạn nghĩ, vì thực chất trong SC2 rất nhiều phương thức định vị. Nếu tận dụng hết có thể viết chiến thuật cho nó dễ dàng.
    @Karmel:
    Mình là tác giả của GT AI. AI trong starcraft 2 được viết dạng tương tự ngôn ngữ C. Nếu bạn rành về C thì chuyển qua viết Starcraft 2 rất dễ.
    Có thể tham khảo thêm bản AI mới của mình ở đây, chạy được trên patch 1.4.0
    http://sc2.nibbits.com/assets/green-tea-ai/
    Nick yahoo : [email protected]
    Một số hàm cơ bản trong SC2 (trích từ natives.galaxy)

    native void AIStart (int player, bool isCampaign, int apm);

    native void AIDisableAllScouting ();

    native bool AIGivingUp (int player);
    native void AIGoodGame (int player);

    native bool AIIsCampaign (int player);
    native bool AIHasHumanAlly (int player);
    native void AISetAPM (int player, int apm);

    native unit AIGrabUnit (int player, string aliasUnitType, int prio, point location);

    native int AIState (int player, int index);
    native void AISetSpecificState (int player, int index, int state);
    native void AISetAllStates (int player, int state);

    native void AISetFlag (int player, int index, bool state);
    native bool AIGetFlag (int player, int index);
    native void AITechFlag (int player, int index, int count, string what, int state);

    native void AIResetUserData (int player);
    native void AISetUserString (int player, int index, string data);
    native string AIGetUserString (int player, int index);
    native void AISetUserInt (int player, int index, int data);
    native int AIGetUserInt (int player, int index);
    native void AIAddStringInt (int player, string data, int change);

    native fixed AIGetTime ();

    const bool c_ignoreEnemyBuildings = true;
    const bool c_includeAllBuildings = false;
    native int AIPathingCostMap (point from, point to);
    native int AIPathingCostUnit (unit u, point to, bool ignoreEnemyBuildings);

    native int AIGetTotalStartLocs ();
    native int AIGetGroundStartLocs (point loc);
    native int AIGetAirStartLocs (point loc);
    native int AIGetTotalTownLocs ();
    native int AIGetGroundTownLocs (point loc);
    native int AIGetAirTownLocs (point loc);

    native int AIRandomVal (int player, int which);
    native void AINewChooseSubState (int player, int which, int min, int max, int defaultSubState);
    native void AISetSubStateChance (int subState, int chance);
    native void AISetSubStateChanceRace (int subState, int randChance, int protChance, int terrChance, int zergChance);
    native int AIChooseSubState ();

    native bool AIWantsMultipleTransport (int player);
    native void AISetWantsMultipleTransport (int player, bool enable);
    native int AIGetNumMobileTransports (int player);

    native int AINumEnemyBuildingsOnSharedIslands (int player);
    native int AINumEnemyBuildingsOnOtherIslands (int player);
    native bool AIEnemyBuildingsOnlyOnOtherIslands (int player);

    native point AIGetBestCreepSpot (int player, unit creator, fixed createRadius);

    native void AIAddDetectionDanger (int player, string unitType);
    native bool AIDefaultSuspectDetectionDanger (int player);

    native bool AIAnyWorkersFleeingNearby (int player, point loc, fixed radius);

    native int AIGetNumEnemies (int player);
    native int AIGetNumAllies (int player);

    native int AIGetEnemyRaceVal (int player);

    native point AIPlacementNearbyFindTest (int player, point loc, fixed range, string unitType);

    native void AIAddToExtraScoutGroup (int player, unit u);
    native bool AIOfferNewScout (int player, unit u);

    native void AIAddHealer (int player, string healer, string healAbil, int healAbilIdx);

    native unit AIGetDropoffWithFewestGuards (int player, string guardType);

    native bool AIHasNearbyAttackers (int player, point loc, fixed range);

    //--------------------------------------------------------------------------------------------------
    // Misc Melee
    //--------------------------------------------------------------------------------------------------

    const int c_skirVeryEasy = 0; // difficulty settings
    const int c_skirEasy = 1;
    const int c_skirMedium = 2;
    const int c_skirHard = 3;
    const int c_skirVeryHard = 4;
    const int c_skirCheater = 5;

    native bool AIAnyAllyAttacking (int player);
    native point AIBestAllyAttackPoint (int player, wave w);
    native bool AIAnyAllyNeedsDefending (int player, wave w);
    native point AIBestAllyDefendPoint (int player, wave w);

    //--------------------------------------------------------------------------------------------------
    // Misc Campaign
    //--------------------------------------------------------------------------------------------------

    const int c_campBeginner = 1; // difficulty settings
    const int c_campNormal = 2;
    const int c_campAdvanced = 3;
    const int c_campExpert = 4;

    native void AIGlobalSuicide (int player);

    native wave AIUnitGetWave (unit u);
    native unitgroup AIWaveGetUnits (wave w);

    native unitgroup AIGetAllEscorts (unit u);
    native unitgroup AIGetAllEscortsGroup (unitgroup ug);

    native void AIRemoveUnitFromAnyWaves (unit u);
    native void AIRemoveGroupFromAnyWaves (unitgroup ug);

    native void AIRemoveUnitFromAnyWavesAndSetHome (unit u, point home);
    native void AIRemoveGroupFromAnyWavesAndSetHome (unitgroup ug, point home);

    native unitgroup AIGetUnitsInWavesWithTarget (int player, wavetarget target);

    native bool AIIsScriptControlled (unit u);
    native void AISetUnitScriptControlled (unit u, bool enable);
    native void AISetGroupScriptControlled (unitgroup ug, bool enable);

    native bool AIIsSuicideUnit (unit u);
    native void AISetUnitSuicide (unit u, bool enable);
    native void AISetGroupSuicide (unitgroup ug, bool enable);

    native bool AIIsNotUsableInWaves (unit u);
    native void AISetUnitNotUsableInWaves (unit u, bool enable);
    native void AISetGroupNotUsableInWaves (unitgroup ug, bool enable);

    native void AISetWantsToUpgrade (unit u);

    native void AISetUnitForceMover (unit u, bool enable);
    native void AISetGroupForceMover (unitgroup ug, bool enable);

    native void AIInitCampaignTowns (int player);
    native void AIInitCampaignHarvest (int player);


    //--------------------------------------------------------------------------------------------------
    // Towns
    //--------------------------------------------------------------------------------------------------
    native void AIDeclareTown (int player, int town, point center);
    native int AIGetMainTown (int player);
    native void AISetMainTown (int player, int maintown);
    native void AIUpdateMainTown (int player);

    native bool AIIsTownFull (int player, int town);
    native int AIGetTownState (int player, int town);
    native fixed AIGetTownEstablishedTime (int player, int town);
    native point AIGetTownLocation (int player, int town);
    native int AIGetClosestTown (int player, point location);
    native int AIGetNextUnusedTownSlot (int player);
    native int AIGetBuildingCountInTown (int player, int town, string aliasUnitType, int countMask);

    native bool AIIsTownHarvestRunning (int player, int town);
    native void AIHarvest (int player, int town);
    native void AIHarvestRate (int player, int rate);
    native void AIHarvestBonus (int player, fixed bonus);
    native void AISetGasPeonCountOverride (int player, int town, int desiredGasCount);

    native int AIGetCurPeonCount (int player, int town);
    native int AIGetMinPeonCount (int player, int town);
    native int AIGetMaxPeonCount (int player, int town);
    native int AIGetMineralAmountLeft (int player, int town);
    native int AIGetGasAmountLeft (int player, int town);
    native int AIGetMineralNumSpots (int player, int town);
    native int AIGetHarvestableGasNumSpots (int player, int town);
    native int AIGetRawGasNumSpots (int player, int town);

    native point AIGetGatherLocation (int player, int town);//xxx remove old functions
    native point AIGetGatherDefLocation (int player, int town);

    native int AIExpand (int player, point searchStart, string firstBuilding);
    native unitgroup AIGetTownThreats (int player, int town);
    native unit AIGetObstruction (int player);
    native bool AIHasNearbyOpenExpansion (int player);

    //-------------------------------------------------------------------------------------------------
    // Scouting
    //--------------------------------------------------------------------------------------------------
    native void AIScout (int player);
    native void AISetNumScouts (int player, int num);
    native void AISetScoutTimes (int player, int starts, int obstructed, int resources, int other);

    native point AIGetNextScoutLoc (int player);
    native void AIClearCampaignScout (int player);

    native void AIEarlyDefenseEnable (int player, bool enableScouting, bool enableDefending);
    native void AIEarlyDefenseProps (int player, fixed scoutRange, fixed peonRange, fixed threatRange);

    //--------------------------------------------------------------------------------------------------
    // Construction
    //--------------------------------------------------------------------------------------------------
    native void AIBuild (int player, int priority, int town, string aliasUnitType, int count, int flags);
    native void AITrain (int player, int priority, int town, string aliasUnitType, int count);
    native void AIResearch (int player, int priority, int town, string aliasUpgradeType);
    native void AIMakeAlways (int player, int priority, int town, string aliasType, int count);
    native void AIMakeOnce (int player, int priority, int town, string aliasType, int count);

    native void AIClearBuildQueue (int player);
    native void AIClearTrainQueue (int player);
    native void AIClearResearchQueue (int player);

    native bool AIHasRes (int player, int minerals, int gas);
    native int AITechCount (int player, string aliasType, int countMask);
    native void AITechCountFixupSingle (int player, string baseUnit, string upgradeOne);
    native void AITechCountFixupEither (int player, string baseUnit, string upgradeOne, string upgradeTwo);
    native void AITechCountFixupInOrder (int player, string baseUnit, string upgradeOne, string upgradeTwo);
    native int AIKnownUnitCount (int player, int testPlayerId, string aliasUnitType);

    native void AIResetCounterUnits (int player);
    native void AICounterUnitSetup (int player, string seeWhat, fixed factorSameTech, string makeWhatSameTech, fixed factorAnyTech, string makeWhatAnyTech);
    native int AICounterUnitsSameTech (int player, int testPlayerId, string makeWhat);
    native int AICounterUnitsSameTechAdjusted (int player, int testPlayerId, string makeWhat);
    native int AICounterUnitsAnyTech (int player, int testPlayerId, string makeWhat);

    native fixed AIFoodCost (int player, string aliasUnitType);

    native point AIGetRallyPoint (unit u);

    native void AISetPowerBuilding (int player, string building);
    native void AISetCreepBuilding (int player, string building, string noCreepBehavior);

    //--------------------------------------------------------------------------------------------------
    // Stock
    //--------------------------------------------------------------------------------------------------
    native void AIClearStock (int player);
    native void AIEnableStock (int player);

    native void AISetStockEx (int player, int town, int count, string aliasType, int buildFlags, int stockFlags);
    native void AISetStock (int player, int count, string aliasType);
    native void AISetStockOpt (int player, int count, string aliasType);
    native void AISetStockUnitNext (int player, int count, string aliasUnitType, bool when);
    native bool AISetStockTown (int player, string aliasUnitTypeTH, string aliasUnitTypeGas);
    native bool AISetStockExpand (int player, string aliasUnitTypeTH, int count);
    native void AISetStockExtra (int player, int count, string aliasUnitType, int minerals);
    native void AISetStockFarms (int player, string aliasUnitType, bool onlyNeeded);
    native void AISetStockPeons (int player, int max, string aliasUnitType, bool onlyMinPeons, bool peonMode);

    native void AINewTechStock (int player);
    native void AITechStockAdd (string upgradeType);
    native void AISetStockTechNext (int player);

    void AISetStockAlias (int player, int count, string makeType, string aliasType) {
    count = count - AITechCount(player, aliasType, c_techCountQueuedOrBetter);
    if (count > 0) {
    AISetStock(player, count + AITechCount(player, makeType, c_techCountQueuedOrBetter), makeType);
    }
    }

    void AISetStockFree (int player, int count, string makeType, string prereq) {
    if (AITechCount(player, prereq, c_techCountCompleteOnly) > 0) {
    AISetStock( player, count, makeType );
    }
    }

    native void AIDefaultEconomy (int player, string hall, string gas, string food, string peon, int cap, bool peonMode);
    native void AIDefaultExpansion (int player, string hall, int minerals, int gas, int expandFlags);

    native void AIClearLimitTech (int player);
    native void AILimitTech (int player, int totalMin, int totalGas, int buildingMin, int buildingGas, int upgradeMin, int upgradeGas);
    native void AIImportantTech (int player, string aliasType);

    native void AILimitStockLarva (int player, string aliasType);

    native bool AIHasStock (int player);
    native bool AIHasStockFromTown (int player, int town);
    native void AIRemoveStockFromTown (int player, int town);

    //--------------------------------------------------------------------------------------------------
    // AI Requirements
    //--------------------------------------------------------------------------------------------------
    native int AIDefaultGetObjectType (int player, string aliasType);
    native string AIDefaultGetMaker (int player, string aliasType);
    native string AIDefaultGetFirstMissingReq (int player, string aliasType);
    native string AIDefaultGetFirstUnfinishedReq (int player, string aliasType);
    native int AIDefaultGetFullMakeTime (int player, string aliasType);

    native string AIGetBaseName (string aliasType);
    native string AIGetBuildAtName (string aliasType);

    native void AIReqCountAsBuiltObject (int player, string aliasType);
    native void AIReqAddSpecialMaker (string objType, string makerType, string abilName, int abilIndex);

    //--------------------------------------------------------------------------------------------------
    // Tactical
    //--------------------------------------------------------------------------------------------------
    native void AIBaseThink (unit who, unitgroup candidates);
    native bool AIEvalTacticalData (unit who, string data);

    const bool c_castRetreat = true;
    const bool c_castHold = false;
    native int AICast (unit u, order o, marker m, bool retreat);
    native int AICastFlee (unit who, unit from, int distance, marker mark);

    const int c_tactTimerFirst = 0;
    const int c_tactTimerSecond = 1;
    const int c_tactTimerThird = 2;
    const int c_tactTimerFourth = 3;
    native int AICastCooldown (unit u, order o, marker m, bool retreat, int timerIdx, fixed cooldown);
    native int AISetCooldown (unit u, int timerIdx, fixed cooldown);
    native bool AITactCooldownAllow (unit u, int timerIdx);

    native bool AINearbyUnits (int player, string unitType, point p, fixed range, int requiredCount);
    native unitgroup AIFindUnits (int player, string unitType, point p, fixed range, int inMaxCount);
    native bool AISameCommand (unit u1, unit u2);

    native unit AILastAttacker (unit u);
    native int AILastAttack (unit u);

    native bool AIControlWantsToMove (unit u);
    native bool AIControlForceToMove (unit u);
    native bool AIControlWantsToUnburrow (unit u);
    native bool AIControlWantsToBurrow (unit u);
    native bool AIControlForceUnburrow (unit u);

    native bool AIUnitIsInCombat (unit u);

    native bool AIIsIgnoredByWave (unit u);
    native void AISetIgnoredByWave (unit u, bool enable);

    native point AIGetHomePosition (unit u);

    native point AIGetCloakedAttacker (int p);
    native void AIClearCloakedAttacker (int p, point pt);
    native bool AISawCloakedUnit (int p);

    native point AIRandomSpawnPoint (
    int player,
    region r,
    fixed minDistFromEnemy,
    fixed maxDistFromEnemy,
    fixed maxDistFromBuilding
    );
    native point AIBestTargetPoint (
    unitgroup group,
    int minHits,
    int damageBase,
    fixed minScore,
    fixed radius,
    point from,
    fixed range,
    int bonusAttri
    );

    native unit AIDefaultCombatPriority (unitgroup attackers, unitgroup enemies, int maxAttackerLimit);

    const int c_cloakMaxRange = 10;
    native bool AICloakEvaluate (unit u, fixed minEnergy, fixed maxLife, fixed range);

    void AISpecifiedHealers (int player);

    //--------------------------------------------------------------------------------------------------
    // Combat
    //--------------------------------------------------------------------------------------------------
    const int c_combatFlagDisable = 0;
    const int c_combatFlagEnable = 1;
    const int c_combatFlagRead = 2;

    void AISetDefaultCombatFlags (int player, bool isMelee);
    native void AISetMaxBestAttackersLimit (int player, int limit);

    native bool AICombatDiffFlagCatSpecialHighPrio (int player, int action);
    native bool AICombatDiffFlagCatSplashHighPrio (int player, int action);
    native bool AICombatDiffFlagCatTimedLowPrio (int player, int action);
    native bool AICombatDiffFlagCatWorkersNormalPrio (int player, int action);
    native bool AICombatDiffFlagCatSortBuildingsPrio (int player, int action);
    native bool AICombatDiffFlagTieBreakHealers (int player, int action);
    native bool AICombatDiffFlagTieBreakBonusDamage (int player, int action);
    native bool AICombatDiffFlagTieBreakLowHP (int player, int action);
    native bool AICombatDiffFlagTieBreakInjured (int player, int action);
    native bool AICombatDiffFlagTieBreakDetector (int player, int action);
    native bool AICombatDiffFlagTieBreakRange (int player, int action);

    //--------------------------------------------------------------------------------------------------
    // Transports
    //--------------------------------------------------------------------------------------------------
    native void AITransportIgnore (int player, string unitType);
    native void AITransportSetPanic (int player, fixed value);
    native void AITransportSetReturn (int player, point center);

    //--------------------------------------------------------------------------------------------------
    // Waves
    //--------------------------------------------------------------------------------------------------
    native waveinfo AIWaveInfoCreate ();
    native waveinfo AIWaveInfo (wave w);

    native void AIWaveInfoAdd (waveinfo info, string unitType, int count);
    native int AIWaveInfoAttack (waveinfo info, int player, point from, wavetarget target, int time);
    native int AIWaveInfoSuicide (waveinfo info, int player, point from, wavetarget target, int time);
    native int AIWaveInfoScout (waveinfo info, int player, point from, int time);

    native string AIWaveToString (wave w);
    native text AIWaveToText (wave w);

    native wave AIWaveCreate (waveinfo info, int player, point from);
    native void AIWaveAddUnit (wave w, unit u);
    native void AIWaveAddUnitPriority (wave w, unit u, int prio);
    native void AIWaveRemoveUnit (wave w, unit u);
    native int AIWaveUnitCount (wave w);
    native int AIWaveDetectorCount (wave w);

    native void AIWaveSetType (wave w, int type, wavetarget target);

    native int AIWaveState (wave w);
    native point AIWaveGoal (wave w);

    native void AIWaveDelete (wave w);

    native wavetarget AIWaveTargetUnit (unit u);
    native wavetarget AIWaveTargetUnitGroup (unitgroup g);
    native wavetarget AIWaveTargetUnitPoint (unit u);
    native wavetarget AIWaveTargetPoint (point p);
    native wavetarget AIWaveTargetPlayer (playergroup players);
    native wavetarget AIWaveTargetMelee (int player);
    native wavetarget AIWaveTargetMeleeHarass (int player);
    native wavetarget AIWaveTargetMeleeDrop (int player, point dropLoc, point goalLoc);
    native wavetarget AIWaveTargetMeleeDefend (int player);
    native wavetarget AIWaveTargetMerge (wave w);
    native wavetarget AIWaveTargetPatrol (int replaceType);
    native wavetarget AIWaveTargetEscort (unitgroup g, int replaceType);
    native wavetarget AIWaveTargetEscortNL (unitgroup g, int replaceType);
    native wavetarget AIWaveTargetGatherO (int player, int town);
    native wavetarget AIWaveTargetGatherD (int player, int town);
    native wavetarget AIWaveTargetRegion (region r, int replaceType);
    native wavetarget AIWaveTargetGuardHomeUnit (unit u);

    native point AIWaveTargetGatherOPoint (int player, int town);
    native point AIWaveTargetGatherDPoint (int player, int town);

    native unit AIWaveTargetGetUnit (wavetarget wt);
    native unitgroup AIWaveTargetGetUnitGroup (wavetarget wt);

    native wavetarget AIWaveHarassRetreat (int player, wave w, fixed range);

    native wavetarget AIWaveGetTarget (wave w);

    native bool AIWaveIsInCombat (wave w);
    native int AIWaveGetTimeInCombat (wave w);
    native int AIWaveGetTimeSinceCombat (wave w);
    native int AIWaveGetTimeSinceOrdered (wave w);

    native int AIWaveGetTimeSinceRetreat (wave w);

    native bool AIShouldHelpUserAlly (int player, wave w);
    native point AIGetBestUserAllyHelpLocation (int player, wave w);
    native bool AIDefenseThreat (int type, int player, wave w);
    native int AISelfDefenseThreatEval (int type, int player);

    native int AIWaveEval (wave w);
    native int AIWaveEvalRatio (wave w, fixed range);
    native int AIUnitAreaEvalRatio (unit u, fixed range);
    native int AIEvalRatio (int player);
    native void AIEvalSetCustomIndex (int index);
    native int AILastWaveEvalStaticRatio ();

    native void AIWaveTargetAddWaypoint (wavetarget wt, point waypoint, bool useTransport, int index);
    native void AIWaveTargetClearWaypoints (wavetarget wt);

    //--- melee games ---
    native wave AIWaveGet (int player, int waveName);
    native void AIWaveSet (int player, int waveName, wave waveRef);
    native int AIWaveType (wave waveRef);
    native void AIWaveSetUserData (wave waveRef, int index, int data);
    native int AIWaveGetUserData (wave waveRef, int index);

    // by default campaign wave and melee suicide/merge waves are deleted when empty,
    // this allows other melee waves to also be deleted when empty.
    native void AIWaveSetDeleteWhenEmpty (wave waveRef, bool turnOnDeleteWhenEmpty);

    native void AIWaveMerge (int player, int waveFrom, int waveInto);
    native void AIWaveMergeMelee (int player);

    native wave WaveLastCreated ();

    native point AIGetBestTarget (int player, playergroup enemies, point gatherPoint, int flags);

    native bool AIFindDropAttackTarget (int player, point gatherPoint);
    native point AILastDropLocation ();
    native point AILastDropGoal ();
    native fixed AIGetNextDropTimeCheck(int player);
    native void AISetNextDropTimeCheck(int player, fixed time);

    native int AILastAttackRatio (wave w);
    native int AILastAttackStartEval (wave w);

    //--------------------------------------------------------------------------------------------------
    // Attack Wave
    //--------------------------------------------------------------------------------------------------

    // Note: The difficulty parameter is a one-based index into
    // the externalized difficulty levels defined in GameData.xml
    //
    const int c_difficultyAll = -1; // Add the same count to all difficulty levels

    native void AIAttackWaveAddUnits (int difficulty, int count, string unitType);

    // External utility function to add four counts to the standard four difficulties
    void AIAttackWaveAddUnits4 (int n1, int n2, int n3, int n4, string unitType) {
    AIAttackWaveAddUnits(2, n1, unitType); // Easy
    AIAttackWaveAddUnits(3, n2, unitType); // Normal
    AIAttackWaveAddUnits(4, n3, unitType); // Hard
    AIAttackWaveAddUnits(5, n4, unitType); // Insane
    }

    // Old external utility function to add three counts to the standard three difficulties
    void AIAttackWaveAddUnits3 (int n1, int n2, int n3, string unitType) {
    AIAttackWaveAddUnits4(n1,n2,n3,n3,unitType);
    }

    native int AIAttackWaveSend (int player, int time, bool wait);

    native void AIAttackWaveCancel (wave waveRef);

    native void AIAttackWaveSetGatherPoint (int player, point gather);

    native void AIAttackWaveUseUnit (int player, unit u);
    native void AIAttackWaveUseGroup (int player, unitgroup ug);

    native void AIAttackWaveAddEscortUnit (int player, unit u, unit escort, fixed offset, fixed angle);
    native void AIAttackWaveAddEscortType (int player, string unitType, unit escort, fixed offset, fixed angle);

    native void AIAttackWaveSetTargetUnit (int player, unit u);
    native void AIAttackWaveSetTargetUnitGroup (int player, unitgroup ug);
    native void AIAttackWaveSetTargetUnitPoint (int player, unit u);
    native void AIAttackWaveSetTargetPoint (int player, point p);
    native void AIAttackWaveSetTargetPlayer (int player, playergroup players);
    native void AIAttackWaveSetTargetMelee (int player);
    native void AIAttackWaveSetTargetMeleeHarass (int player);
    native void AIAttackWaveSetTargetMeleeDrop (int player, point dropLoc, point goalLoc);
    native void AIAttackWaveSetTargetMeleeDefend (int player);
    native void AIAttackWaveSetTargetMerge (int player, wave w);
    native void AIAttackWaveSetTargetPatrol (int player, int replaceType);
    native void AIAttackWaveSetTargetEscort (int player, unitgroup g, int replaceType);
    native void AIAttackWaveSetTargetEscortNL (int player, unitgroup g, int replaceType);
    native void AIAttackWaveSetTargetGatherO (int player, int town);
    native void AIAttackWaveSetTargetGatherD (int player, int town);
    native void AIAttackWaveSetTargetRegion (int player, region r, int replaceType);

    native void AIAttackWaveSetGatherEarlyNoReplace (int player);
    native void AIAttackWaveSetKeepAlive (int player);

    native void AIAttackWaveAddWaypoint (int player, point waypoint, bool useTransport);
    native void AIAttackWaveClearWaypoints (int player);

    //--------------------------------------------------------------------------------------------------
    // Bully Functions
    //--------------------------------------------------------------------------------------------------

    native void AISetMinimumBullyCount (int count, string unitType, int player);

    native void AISetGeneralRebuildCount (int count, bool building, int player);
    native void AISetSpecificRebuildCount (int count, string unitType, int player);

    native void AISetBullyAttackWavePercent (int percent, int player);
    native void AINearestTownLimitWaveGather (int player, bool enable);

    native void AINearestTownBullyRebuild (int player, bool enable);

    native void AIToggleBulliesInRegion (int player, region reg, bool activate);
    native void AIResetBullyRebuildCountsInRegion (int player, region reg);

    native void AIClearAllBullies (int player);
    native void AIAddBully (int player, string unitType, point loc, int rebuildCount);

    native string AIGetBullyType (unit u);
     
  9. UltimaMaster

    UltimaMaster Youtube Master Race

    Tham gia ngày:
    6/8/06
    Bài viết:
    14
    ô bạn ptanhkhoa,những cái code AI này có phải chứa trong TriggerLib của Data Base SC2 ko?
     

Chia sẻ trang này