Tutorial : How to play against ai

Started by redspike474, February 27, 2010, 02:26:50 AM

Previous topic - Next topic

DKSlayer

Just grabbed the cache off of some site and started looking at at the files. Obiously we have the triggers file. Which looks like this.
<?xml version="1.0" encoding="utf-8"?>
<TriggerData>
    <root>
        <item type="Trigger" id="DA585CDF"/>
    </root>
    <element type="Trigger" id="DA585CDF">
        <event type="FunctionCall" id="9FD28024"/>
        <action type="FunctionCall" id="D8249E80"/>
        <action type="FunctionCall" id="879D3981"/>
        <action type="FunctionCall" id="BB0E3A48"/>
        <action type="FunctionCall" id="C749188F"/>
    </element>
    <element type="FunctionCall" id="879D3981">
        <function type="FunctionDef" library="Ntve" id="00000145"/>
    </element>
    <element type="FunctionCall" id="9FD28024">
        <function type="FunctionDef" library="Ntve" id="00000120"/>
    </element>
    <element type="FunctionCall" id="BB0E3A48">
        <function type="FunctionDef" library="Ntve" id="00000150"/>
    </element>
    <element type="FunctionCall" id="C749188F">
        <function type="FunctionDef" library="Ntve" id="00000148"/>
    </element>
    <element type="FunctionCall" id="D8249E80">
        <function type="FunctionDef" library="Ntve" id="00000143"/>
    </element>
</TriggerData>


we can see that the lower functions are being pulled from the native Triggers file. Which I have been unable to find. My thought it this is probably coded in. Anyways the functions are called by a Code number and given an Id. In the enUS.SC2DAta\LocalizedData\TriggerStrings.txt you find this:

Trigger/Name/DA585CDF=Melee Initialization

in another map thought you get

Trigger/Name/6B580A10=Melee Initialization


and in the triggers file for the second map you see

<?xml version="1.0" encoding="us-ascii"?>
<TriggerData>
    <root>
        <item type="Trigger" id="6B580A10"/>
    </root>
    <element type="Trigger" id="6B580A10">
        <event type="FunctionCall" id="55F0159A"/>
        <action type="FunctionCall" id="32730DBD"/>
        <action type="FunctionCall" id="8C8C05D9"/>
        <action type="FunctionCall" id="414B4FFA"/>
        <action type="FunctionCall" id="4E1DE037"/>
    </element>
    <element type="FunctionCall" id="32730DBD">
        <function type="FunctionDef" library="Ntve" id="00000143"/>
    </element>
    <element type="FunctionCall" id="414B4FFA">
        <function type="FunctionDef" library="Ntve" id="00000150"/>
    </element>
    <element type="FunctionCall" id="4E1DE037">
        <function type="FunctionDef" library="Ntve" id="00000148"/>
    </element>
    <element type="FunctionCall" id="55F0159A">
        <function type="FunctionDef" library="Ntve" id="00000120"/>
    </element>
    <element type="FunctionCall" id="8C8C05D9">
        <function type="FunctionDef" library="Ntve" id="00000145"/>
    </element>
</TriggerData>

As you can see the ids in the Function Call portion are random. I am guessing the map editor just creates a random unique id for each one even though the native. But the actualy Native functions are the same. So one side defines the triggers and the other side calls them.
Anyways the link someone showed above showed that in one of the maps someone actually was able to pull a more full AI like file. Anyways looking through the maps here to see what they are.

dodongbadong

hahaha.. very interesting map.. sad coz i wipe them all out but no conclusion wither victory or defeat but non the less its better than playing against yourself. more map please..

hmm id like to make my own map.. where do i start? hehe

i use to make starcraft broodwar map before though just simple editing using map editor or star forge but i guess sc2 is way different. T_T

more map please.. btw if you find some interesting script or inputs dealing with ai please post it here i beg you.. so that we can interact on what to do.
thx
You make your best AI script "cheating or not"
and ill test it for you
- FREE-

Gamewiz

2g4u thank you for the map! I'm gonna try it out now! :D

Thank you guys for working on this. Looks like you are making really good progress! Sorry I can't contribute, I'm not good at this kind of stuff. :(

p-On:E

uhm guys, a question...

we have the triggers, and were able to edit them, right?
were able to spawn units, theoretically set up a base for the "braindead-AI" and have some fun.

so if were able to make some trigger stuff etc, arent were able to create locations and let some triggers do the action, like "attackmove -> all units on location A -> to Location B"?

that with some timeed triggers would make it possible to script the own AI.. kinda..

is this possible?

and is there any way to find out the coordinates for the grid to place units and buildings properly?

lovetoby

oki so far placing units doesnt depend on their id, you can use players startlocation coordinates to make funny things, also we can have 4 players, i ll release a map being able to fight against 3 opponents btw they fight each other too...
still much to do... triggering a wave lik walk behaiour and placing building... maybe the id are for the trigger action codes... so be carefull! but actually the ids doesnt matter what kind of unity u place! also u can play terrain and spawn zerg unit... so have fun cu later

2g4u

Taken from wc3campaigns.net

Here is the full list of types.
DebugString
DebugUnit
DebugInt
DebugFixed
DebugPoint
DebugDump
AISetDifficulty
AIGetDifficulty
AIStart
AIGivingUp
AIGoodGame
AIIsCampaign
AISetAPM
AIGrabUnit
AIState
AISetSpecificState
AISetAllStates
AISetFlag
AIGetFlag
AITechFlag
AIResetUserData
AISetUserString
AIGetUserString
AISetUserInt
AIGetUserInt
AIAddStringInt
AIGetTime
AIGetTotalStartLocs
AIGetGroundStartLocs
AIGetAirStartLocs
AIGetTotalTownLocs
AIGetGroundTownLocs
AIGetAirTownLocs
AIRandomVal
AINewChooseSubState
AISetSubStateChance
AIChooseSubState
AIWantsMultipleTransport
AISetWantsMultipleTransport
AIGetNumMobileTransports
AIGetBestCreepSpot
AIAddDetectionDanger
AIDefaultSuspectDetectionDanger
AIAnyWorkersFleeingNearby
AIGetNumEnemies
AIGetNumAllies
AIPlacementNearbyFindTest
AIAddToExtraScoutGroup
AIOfferNewScout
AIAnyAllyAttacking
AIBestAllyAttackPoint
AIAnyAllyNeedsDefending
AIBestAllyDefendPoint
AIGlobalSuicide
AIUnitGetWave
AIWaveGetUnits
AIGetAllEscorts
AIGetAllEscortsGroup
AIRemoveUnitFromAnyWaves
AIRemoveGroupFromAnyWaves
AIGetUnitsInWavesWithTarget
AIIsScriptControlled
AISetUnitScriptControlled
AISetGroupScriptControlled
AIIsSuicideUnit
AISetUnitSuicide
AISetGroupSuicide
AIIsNotUsableInWaves
AISetUnitNotUsableInWaves
AISetGroupNotUsableInWaves
AISetWantsToUpgrade
AIInitCampaignTowns
AIInitCampaignHarvest
AIDeclareTown
AIGetMainTown
AISetMainTown
AIUpdateMainTown
AIGetTownState
AIGetTownEstablishedTime
AIGetTownLocation
AIGetClosestTown
AIGetNextUnusedTownSlot
AIGetBuildingCountInTown
AIIsTownHarvestRunning
AIHarvest
AIHarvestRate
AIHarvestBonus
AISetGasPeonCountOverride
AIGetCurPeonCount
AIGetMinPeonCount
AIGetMaxPeonCount
AIGetMineralAmountLeft
AIGetGasAmountLeft
AIGetMineralNumSpots
AIGetRawGasNumSpots
AIGetGatherLocation
AIGetGatherDefLocation
AIExpand
AIGetTownThreats
AIGetObstruction
AIHasNearbyOpenExpansion
AIScout
AISetNumScouts
AISetScoutTimes
AIGetNextScoutLoc
AIClearCampaignScout
AIBuild
AITrain
AIResearch
AIMakeAlways
AIMakeOnce
AIClearBuildQueue
AIClearTrainQueue
AIClearResearchQueue
AIHasRes
AITechCount
AITechCountFixupSingle
AITechCountFixupEither
AITechCountFixupInOrder
AIKnownUnitCount
AIResetCounterUnits
AICounterUnit
AICounterUnits
AIGetRallyPoint
AISetPowerBuilding
AISetCreepBuilding
AIClearStock
AIEnableStock
AISetStockEx
AISetStock
AISetStockOpt
AISetStockUnitNext
AISetStockTown
AISetStockExpand
AISetStockExtra
AISetStockFarms
AISetStockPeons
AINewTechStock
AITechStockAdd
AISetStockTechNext
AIDefaultEconomy,'-4ssss4?',0AIDefaultExpansion
AIClearLimitTech
AILimitTech,'-4444444',0AIImportantTech
AILimitStockLarva
AIHasStock
AIHasStockFromTown
AIRemoveStockFromTown
AIDefaultGetObjectType
AIDefaultGetMaker
AIDefaultGetFirstMissingReq
AIDefaultGetFirstUnfinishedReq
AIDefaultGetFullMakeTime
AIGetBaseName
AIGetBuildAtName
AIReqCountAsBuiltObject
AIReqAddSpecialMaker
AISetNukeNukeCastTime
AISetNukeCloakCost
AISetNukeCloakRegenRate
AISetNukeGhost
AISetNukeNukeEffect
AISetNukeCloak
AISetNukeNukeAbilLink
AISetNukeCloakAbilLink
AISetNukeDamage
AISetNukeRadiusClose
AISetNukeRadiusMedium
AISetNukeRadiusFar
AIBaseThink
AIEvalTacticalData
AICast
AICastFlee
AINearbyUnits
AIFindUnits
AISameCommand
AILastAttacker
AILastAttack
AIControlWantsToMove
AIControlForceToMove
AIControlWantsToUnburrow
AIControlWantsToBurrow
AIControlForceUnburrow
AIUnitIsInCombat
AIIsIgnoredByWave
AISetIgnoredByWave
AIGetHomePosition
AIGetCloakedAttacker
AIClearCloakedAttacker
AISawCloakedUnit
AIRandomSpawnPoint
AIBestTargetPoint,'pu4433p34',0AIDefaultCombatPriority
AIFilter
AISetFilterAlliance
AISetFilterMarker
AISetFilterSelf
AISetFilterBits
AISetFilterRange
AISetFilterLife
AISetFilterLifeLost
AISetFilterLifePercent
AISetFilterLifeSortReference
AISetFilterLifeMod
AISetFilterLifePerMarker
AISetFilterShields
AISetFilterEnergy
AISetFilterPlane
AISetFilterCanAttackEnemy
AISetFilterCanAttackAlly
AISetFilterBehaviorCount
AIGetFilterGroup
AIFilterGathering
AIFilterPathable
AIFilterCasters
AICloakEvaluate
AISetTacticalAttackTargetPoint
AISetTacticalAttackTargetUnit
AIUnitGroupGetValidOrder
AIIsFollowingUnit
AIGetPlayerGroup
AINearbyPlaneTest
AIUnitGroupStrength
AIAllyEnemyRatio
AICombatTargetProduction
AICombatTargetDropOffs
AICombatTargetFood
AICombatTargetActiveProduction
AICombatTargetWorkers
AICombatTargetAllyThreats
AICombatTargetSelfThreats
AICombatTargetCurrent
AICombatTargetAir
AICombatTargetMovers
AICombatTargetInjuries
AICombatTargetInAttackRange
AICombatTargetThreats
AICombatTargetHealers
AICombatTargetSiege
AICombatTargetAttackers
AICombatTargetSpecial
AICombatAvoidTimedUnits
AICombatAvoidNonThreats
AICombatAvoidWeakUnits
AICombatAvoidDisabledUnits
AITransportIgnore
AITransportSetPanic
AITransportSetReturn
AIWaveInfoCreate
AIWaveInfo
AIWaveInfoAdd
AIWaveInfoAttack
AIWaveInfoSuicide
AIWaveInfoScout
AIWaveToString
AIWaveToText
AIWaveCreate
AIWaveAddUnit
AIWaveAddUnitPriority
AIWaveRemoveUnit
AIWaveUnitCount
AIWaveDetectorCount
AIWaveSetType
AIWaveState
AIWaveDelete
AIWaveTargetUnit
AIWaveTargetUnitGroup
AIWaveTargetUnitPoint
AIWaveTargetPoint
AIWaveTargetPlayer
AIWaveTargetMelee
AIWaveTargetMeleeHarass
AIWaveTargetMeleeDrop
AIWaveTargetMeleeDefend
AIWaveTargetMerge
AIWaveTargetPatrol
AIWaveTargetEscort
AIWaveTargetEscortNL
AIWaveTargetGatherO
AIWaveTargetGatherD
AIWaveTargetRegion
AIWaveTargetGatherOPoint
AIWaveTargetGatherDPoint
AIWaveTargetGetUnit
AIWaveTargetGetUnitGroup
AIWaveHarassRetreat
AIWaveGetTarget
AIWaveIsInCombat
AIWaveGetTimeInCombat
AIWaveGetTimeSinceCombat
AIWaveGetTimeSinceOrdered
AIWaveGetTimeSinceRetreat
AIDefenseThreat
AIDefenseThreatEval
AIWaveEval
AIWaveEvalRatio
AIUnitAreaEvalRatio
AIEvalRatio
AIEvalSetCustomIndex
AIEvalAllAllied
AIEvalLargestEnemy
AILastWaveEvalStaticRatio
AIWaveTargetAddWaypoint
AIWaveTargetClearWaypoints
AIWaveGet
AIWaveSet
AIWaveType
AIWaveSetUserData
AIWaveGetUserData
AIWaveMerge
AIWaveMergeMelee
WaveLastCreated
AIGetBestTarget
AIFindDropAttackTarget
AILastDropLocation
AILastDropGoal
AIGetNextDropTimeCheck
AISetNextDropTimeCheck
AILastAttackRatio
AILastAttackStartEval
AIAttackWaveAddUnits
AIAttackWaveSend
AIAttackWaveCancel
AIAttackWaveSetGatherPoint
AIAttackWaveUseUnit
AIAttackWaveUseGroup
AIAttackWaveAddEscortUnit
AIAttackWaveAddEscortType
AIAttackWaveSetTargetUnit
AIAttackWaveSetTargetUnitGroup
AIAttackWaveSetTargetUnitPoint
AIAttackWaveSetTargetPoint
AIAttackWaveSetTargetPlayer
AIAttackWaveSetTargetMelee
AIAttackWaveSetTargetMeleeHarass
AIAttackWaveSetTargetMeleeDrop
AIAttackWaveSetTargetMeleeDefend
AIAttackWaveSetTargetMerge
AIAttackWaveSetTargetPatrol
AIAttackWaveSetTargetEscort
AIAttackWaveSetTargetEscortNL
AIAttackWaveSetTargetGatherO
AIAttackWaveSetTargetGatherD
AIAttackWaveSetTargetRegion
AIAttackWaveSetGatherEarlyNoReplace
AIAttackWaveSetKeepAlive
AIAttackWaveAddWaypoint
AIAttackWaveClearWaypoints
AISetMinimumBullyCount
AISetGeneralRebuildCount
AISetSpecificRebuildCount
AISetBullyAttackWavePercent
AINearestTownLimitWaveGather
AINearestTownBullyRebuild
AIToggleBulliesInRegion
AIResetBullyRebuildCountsInRegion
AIClearAllBullies
AIAddBully
AIGetBullyType
CameraGetTarget
CatalogFieldValueGet
IntToFixed
IntToString
FixedToInt
StringToInt
StringToFixed
StringWord
CliffLevel
TriggerAddEventMapInit
TriggerAddEventChatMessage
EventChatMessage
MaxF
AbsI
RandomInt
MarkerCastingUnit
MarkerSetMatchFlag
MarkerSetMismatchFlag
MeleeInitResources
MeleeInitUnits
MeleeInitAI
MeleeInitOptions
AbilityCommand
AbilityCommandGetAbility
Order
OrderGetAbilityCommand
OrderSetPlayer
OrderGetPlayer
OrderGetTargetType
OrderSetTargetPlacement
OrderSetTargetPoint
OrderGetTargetPoint
OrderGetTargetPosition
OrderSetTargetUnit
OrderGetTargetUnit
OrderSetTargetPassenger
PlayerGetPropertyInt
PlayerRace
PlayerDifficulty
PlayerStartLocation
PlayerGetColorIndex
PlayerColorName
PlayerGetAlliance
DifficultyAPM
PlayerGroupAll
Point
PointWithOffset
PointWithOffsetPolar
PointsInRange
AngleBetweenPoints
DistanceBetweenPoints
RegionCircle
RegionRandomPoint
StringEqual
StringToText
TechTreeBehaviorCount
TechTreeUnitCount
TriggerCreate
TriggerDebugOutput
UnitIsAlive
UnitGetType
UnitGetOwner
UnitGetPosition
UnitGetFacing
UnitTestState
UnitGetPropertyInt
UnitGetPropertyFixed
UnitCargoGroup
UnitCargoValue
UnitTestPlane
UnitBehaviorCount
UnitMarkerCount
UnitOrder
UnitOrderCount
UnitOrderHasAbil
UnitOrderIsValid
UnitIsHarvesting
UnitRallyPointTargetCount
UnitRallyPointTargetPoint
UnitWeaponsPlaneTest
UnitTypeTestFlag
UnitTypeTestAttribute
UnitFilter
UnitFilterStr
UnitFilterSetState
UnitGroupCopy
UnitGroupAlliance
UnitGroup
UnitGroupFilter
UnitGroupFilterAlliance
UnitGroupFilterPlane
UnitGroupFilterRegion
UnitGroupFilterThreat
UnitGroupAdd
UnitGroupCount
UnitGroupUnit
UnitGroupTestPlane
UnitGroupNearestUnit
UIDisplayMessage
Wait

And a code sample featuring Point. Both curtesy of MindWorX.
int __stdcall Point(int x, int y)
{
    galaxyPoint *p;
    p = sub_B35410(32);
    if (p)
    {
        sub_AA3160(p, 11, 0); //This is a __thiscall, so it would prolly look like this in normal code: "p->sub_AA3160(11, 0);"
        p->field_0 = &off_137892C;
        p->field_C = 0;
        p->field_10 = 0;
        p->field_14 = 0;
        p->field_18 = 0;
        p->field_1C = 0;
    }
    else
    {
        p = 0;
    }
    p->field_10 = x;
    p->field_14 = y;
    return p->field_8;
}
"Only two things are infinite, the universe and human stupidity, and I'm not sure about the former!" Albert Einstein

Darkmapper

It doesnt work for me. Im using winMPQ and when i save the object.file, it creates a second one. So it doesnt replace it but it has just two object.files. Im opening the file with Scite and also tried it with the windows Editor. Is it bcause of winMPQ? MPQEditor doesnt work for me, and i used it in starcraft 2 already.

tomsons26

my theory about AI
in MapScript.galaxy there is only include "TriggerLibs/NativeLib" that shoud be be the AI that when an AI unit is attacked then he attacks you (kinda like natural hostile in war3)
can someone that maked an map with AI test adding these tags

//==================================================================================================
include "TriggerLibs/NativeLib"
include "TriggerLibs/RequirementsAI"
include "TriggerLibs/BuildAI"
include "TriggerLibs/MeleeAI"
include "TriggerLibs/Terran"
include "TriggerLibs/Protoss"
include "TriggerLibs/Zerg"

//--------------------------------------------------------------------------------------------------

RaTcHeT302


tomsons26


// Name:   Holy Land
// Author: Blizzard Entertainment

Valkirie

Quote from: tomsons26 on February 27, 2010, 12:33:29 PM
my theory about AI
in MapScript.galaxy there is only include "TriggerLibs/NativeLib" that shoud be be the AI that when an AI unit is attacked then he attacks you (kinda like natural hostile in war3)
can someone that maked an map with AI test adding these tags

//==================================================================================================
include "TriggerLibs/NativeLib"
include "TriggerLibs/RequirementsAI"
include "TriggerLibs/BuildAI"
include "TriggerLibs/MeleeAI"
include "TriggerLibs/Terran"
include "TriggerLibs/Protoss"
include "TriggerLibs/Zerg"

//--------------------------------------------------------------------------------------------------


http://www.mediafire.com/?gjnnzwjjdxk
Also added a Hatchery at Starting point loc 002. Looks like nothing is moving.

redspike474

Quote from: Valkirie on February 27, 2010, 12:49:03 PM
Quote from: tomsons26 on February 27, 2010, 12:33:29 PM
my theory about AI
in MapScript.galaxy there is only include "TriggerLibs/NativeLib" that shoud be be the AI that when an AI unit is attacked then he attacks you (kinda like natural hostile in war3)
can someone that maked an map with AI test adding these tags

//==================================================================================================
include "TriggerLibs/NativeLib"
include "TriggerLibs/RequirementsAI"
include "TriggerLibs/BuildAI"
include "TriggerLibs/MeleeAI"
include "TriggerLibs/Terran"
include "TriggerLibs/Protoss"
include "TriggerLibs/Zerg"

//--------------------------------------------------------------------------------------------------


http://www.mediafire.com/?gjnnzwjjdxk
Also added a Hatchery at Starting point loc 002. Looks like nothing is moving.

i dont think this method would work at all, if it is moving you wont get victory when u start the map. u get Victory because u have no oponant.


currently i belive that its the lazy town sandbox that needs to change its way of loading into the map, it isnt anything to do with the galaxy scripting.
because the scripts are working u can mess with them youselfs.

any triggers ect are no longer valid anyways after u have won the game, eg after vicotory is displayed its end game, i think... im not sure.

lazytown needs to load the map and emulate or tell the computer slot to be full , or somthing like that. there is no ai because all the player slots are empty, one needs to be set to computer.  well as far as i can figure out, 

tomsons26

there is an ai opponent needed to be added in MapScript.galaxy
because in wc3 there was one and this script is an wc3 script mod

redspike474

actually i belive its more like starcraft 1.

seeing as there are no units or buildings placed for the race you play as.
each time u play a map it randomly choses your starting location from those defined in the objects file, and then randomly chooses your race.  and gives you a command center ect.
i see no reason why it would not do the same for player 2 , or a computer player.
there simply is no computer  player present when the map starts. the slot is empty or closed.
yes it might be possible to create a map using triggers simaler to Ums in sc1, more like a single player mission, however i dont think this is possible at the moment with the current lazytown program ,
if you think about it what settings for custom map are there?
ums?
mele?
Player vs player>
think how many there was in sc1 And how each was a diffrent game mode, only ums used map settings and used triggers ect,

cryystyy

hmm :-? if this MeleeInitResources(); gives you 50 minerals at start how can we edit it to give 100 or 9999 :-?.