| 01-29-2003, 04:42 PM | #1 |
1. Do all the functions and types in Blizzard.j also work in common.j and common.ai? Also, do any functions defined in common.j and .ai work in each other? 2. I am hoping to get a list of the native functions in common.ai and what they do. Here are some of my guesses. If you know what one is, please tell me. Code:
native DebugS takes string str returns nothing Code:
native DebugFI takes string str, integer val returns nothing Code:
native DebugUnitID takes string str, integer val returns nothing Code:
native DisplayText takes integer p, string str returns nothing Code:
native DisplayTextI takes integer p, string str, integer val returns nothing Code:
native DoAiScriptDebug takes nothing returns boolean Code:
native GetAiPlayer takes nothing returns integer Code:
native GetHeroId takes nothing returns integer Code:
native GetHeroLevelAI takes nothing returns integer Thanks in advance. - Newtfeet |
| 01-29-2003, 10:20 PM | #2 |
1. The functions in blizzard.j can be copied and work in common.ai . You can access functions in common.j from an AI script. There are some functions in common.j that do not work properly from AI scripts. 2. The debug functions seem to require a special debug mode. It is unknown how to activate it. Without the debug mode they do nothing. DoAiScriptDebug should probably return if the script is run in debug mode. GetHeroId and GetHeroLevelAI are only needed for skilling the hero. GetHeroId returns the type of hero that should be skilled and GetHeroLevelAI returns the current level of the hero. |
| 01-30-2003, 02:35 AM | #3 | |
Quote:
-Newtfeet |
| 01-30-2003, 06:23 AM | #4 |
if no hero has any skill points the function is'nt even called(so it cannot return 0) normally it would look like this (for humans) globals integer array skillspaladin integer array skillsking integer array skillsmage endglobals function SetSkills takes nothing returns nothing // here you can define the order in which the skill points will be invested by the different types of hero set skillspaladin[1] = DIVINE_SHIELD set skillspaladin[2] = HOLY_LIGHT ... and so on ... endfunction function LevelUp takes nothing returns integer // only called when hero gains level and returns the skill defined in SetSkills() for that level local integer hero = GetHeroId() local integer level = GetHeroLevelAI() if hero == PALADIN then return skillspaladin[level] elseif hero == MTN_KING then return skillsking[level] else return skillsmage[level] endif endfunction function BuildLoop takes nothing returns nothing // would build Paladins, so the comp has always one Paladin loop if GetUnitCountDone(PALADIN) < 1 then call SetProduce(1,PALADIN,-1) endif endloop endfunction function main takes nothing returns nothing call SetSkills() call SetHeroLevels(function LevelUp) // this only calls the levelup function when a hero gains a level (points are then invested according to the list in LevelUp) call BuildLoop() endfunction |
| 01-30-2003, 10:24 PM | #5 |
Ok, thanks! That helps a lot. Here is another section of common.ai: Code:
native GetUnitCount takes integer unitid returns integer Code:
native GetPlayerUnitTypeCount takes player p, integer unitid returns integer Code:
native GetUnitCountDone takes integer unitid returns integer Code:
native GetTownUnitCount takes integer id, integer tn, boolean dn returns integer How does the town system work? Could someone explain it, please? Code:
native GetUnitGoldCost takes integer unitid returns integer Code:
native GetUnitWoodCost takes integer unitid returns integer Code:
native GetMinesOwned takes nothing returns integer Code:
native GetGoldOwned takes nothing returns integer Code:
native TownWithMine takes nothing returns integer Code:
native TownHasMine takes integer townid returns boolean Code:
native TownHasHall takes integer townid returns boolean -Newtfeet |
| 01-31-2003, 10:11 AM | #6 |
GetUnitCount - counts units of that type owned by the player for whom the script is currently running (= aiplayer) (currently produced units included) GetPlayerUnitTypeCount - same as above but you can choose the player (ie Player(0) for Player 1) GetTownUnitCount - counts units of type owned by aiplayer in a specific town (Townsystem: 0 = Starting Base, 1 first expansion and so on, -1 is the base where all the important buildings (Barracks) are) , if boolean is true then only done units are counted GetMinesOwned - counts mines owned by the aiplayer (for peon assignment) GetGoldOwned - returns the amount of Gold the aiplayer ownes TownWithMine - returns a town of the aiplayer that has a mine all the others were correctly guessed :D |
| 02-01-2003, 02:27 AM | #7 |
Thanks guys! Ok, here is even more common.ai: Code:
native GetUpgradeLevel takes integer id returns integer Code:
native GetUpgradeGoldCost takes integer id returns integer Code:
native GetUpgradeWoodCost takes integer id returns integer Code:
native GetNextExpansion takes nothing returns integer Code:
native GetMegaTarget takes nothing returns unit Code:
native GetBuilding takes player p returns unit Code:
native GetEnemyPower takes nothing returns integer Code:
native SetAllianceTarget takes unit id returns nothing Code:
native GetAllianceTarget takes nothing returns unit Code:
native SetProduce takes integer qty, integer id, integer town returns boolean Code:
native Unsummon takes unit unitid returns nothing Code:
native SetExpansion takes unit peon, integer id returns boolean Code:
native SetUpgrade takes integer id returns boolean Code:
native SetHeroLevels takes code func returns nothing Code:
native SetNewHeroes takes boolean state returns nothing Code:
native PurchaseZeppelin takes nothing returns nothing Code:
native MergeUnits takes integer qty, integer a, integer b, integer make returns boolean Thanks! -Newtfeet |
| 02-01-2003, 08:28 AM | #8 |
GetMegaTarget - only returns a target unit if an enemy player's defense is down in order to make an all out attack, otherwise it returns null (WatchMegaTargets must be set to true in the main function) GetBuilding - returns a building of an enemy player which can be used as attack target GetEnemyPower - returns the amount of food used by enemies SetAllianceTarget - first you get an attack target with functions such as GetBuilding, then you set the alliance target to this, if there are more aiplayers in the same force the other one will receive this target with the command GetAllianceTarget() and be able to attack the same target SetProduce - boolean means that the building of the unit/building has succeeded (normally not used), nevertheless you can call it with 'call SetProduce(1,MORTAR,-1) SetExpansion - Sets up a new base (unit would be a peon/peasant/acolyte/... that is picked before with GetExpansionPeon(), the id would be TOWN_HALL for humans), returned boolean normally not used SetUpgrade - same again, boolean need not to be used MergeUnits - only used for hippo riders (would look like this: call MergeUnits(1,ARCHER,HIPPO,HIPPO_RIDER), same again with the boolean the others are quite obvious :D |
| 02-01-2003, 12:06 PM | #9 |
GetEnemyPower does not work, always returns 0. |
| 02-01-2003, 02:21 PM | #10 |
We're on a roll! Code:
native SetCampaignAI takes nothing returns nothing Code:
native SetMeleeAI takes nothing returns nothing Code:
native SetTargetHeroes takes boolean state returns nothing Code:
native SetPeonsRepair takes boolean state returns nothing Code:
native SetHeroesFlee takes boolean state returns nothing Code:
native SetWatchMegaTargets takes boolean state returns nothing Code:
native SetIgnoreInjured takes boolean state returns nothing Code:
native SetHeroesTakeItems takes boolean state returns nothing Code:
native SetUnitsFlee takes boolean state returns nothing Code:
native SetGroupsFlee takes boolean state returns nothing Code:
native SetSlowChopping takes boolean state returns nothing Code:
native SetCaptainChanges takes boolean allow returns nothing Code:
native SetSmartArtillery takes boolean state returns nothing Code:
native SetReplacementCount takes integer qty returns nothing Code:
native GroupTimedLife takes boolean allow returns nothing Code:
native RemoveInjuries takes nothing returns nothing Code:
native RemoveSiege takes nothing returns nothing *sigh* I have a lot of no ideas! -Newtfeet |
| 02-01-2003, 08:09 PM | #11 |
first of all these commands are all initials which means that they are only called once at the beginning of the script SetCampaignAI - defines the script as campaign AI (can be used when comp has larger starting base) SetMeleeAI - defines the script as melee AI (will often not work correctly if the comp doesn't start from the beginning) SetIgnoreInjured - if false the comp prefers targets that are already damaged Flee Commands: i guess a unit in a group will not flee when it's damaged as long as the group is still strong enough but the whole group will flee if enemy is stronger SetSlowChopping - has to do something with the speed the ai reacts on events (dunno exactly but is normally not used) ---------------------------------------------- CreateCaptains - initial command needed for using all the captain-commands (don't know what SetCaptainChanges means because it is never used), for example you could use them to check battle states ( if CaptainInCombat(true) == true it would mean that the ai units are involved in an offensive battle) use this to wait until battle is over and send group home with CaptainGoHome(). There are two captains (an offensive and an defensive) which can be used to determine the behaviour in battles. --------------------------------------------- SetSmartArtillery - helps the ai to attack targets in the right order SetReplacementCount - integers from 1 to 3 are used, higher values make the ai stronger but dunno exactly what they do I don't know about the last three ones but only RemoveInjuries() matters because it is normally used at the beginning of the script. |
| 02-01-2003, 10:41 PM | #12 |
SetGroupsFlee enables fleeing from combat. SetUnitsFlee activates the behaviour that a unit will flee a short way and then return. SetSlowChopping is used in campaign AIs to make the AI chop wood very slow, so the wood is not removed in a large way. Due to the reduced resource income by that it is required to provide the AI with wood by trigger. I think, RemoveInjuries causes highly damaged units to stay at home to heal. My guess for RemoveSiege is that it removes siege units from the attack group. As for the unexplained rest, try them out and tell us what they do. They might be useful. |
| 02-02-2003, 07:00 PM | #13 | |
Quote:
Code:
native InitAssault takes nothing returns nothing Code:
native AddAssault takes integer qty, integer id returns boolean Code:
native AddDefenders takes integer qty, integer id returns boolean Code:
native GetCreepCamp takes integer min, integer max, boolean flyers_ok returns unit -Newtfeet |
| 02-02-2003, 10:53 PM | #14 |
GetCreepCamp 's min and max refer to the sum of the levels of the creeps in the camp. The rest is right. |
