This has long been a problem with SC2 neutral shops, that requirements don't work like you would think. There are tutorials for workarounds if you search. Basically what people do is make an invisible shop for each player, and when they click the neutral shop triggers redirect their selection to the invisible shop. Since the invisible shop belongs to them, requirements work correctly.
Secondly, you no longer need to check for behaviors to see if a unit is carrying an item. Patch 1.5 added a validator that checks for an item in the unit's inventory, and even before patch 1.5 it was possible to check for items using requirements by doing: CountUnit(Item,CompleteOnlyAtUnit).
Another option is to use triggers the whole way, but this is not preferable. In order to be certain that a purchase is cancelled when someone attempts it without proper requirements, a small creation time needs to be added to the item, so that it takes 1 second for the shop to produce it. During this 1 second triggers can cancel the purchase if requirements aren't met. But it's annoying. I'd go the invisible shop way if this is going to be a major part of your map.
If I remember correctly, when I did this I did have to change the weapons. So there's two versions of each unit's weapon, and a behavior is applied when they are loaded up that disables the default weapon and enables the weapon that attacks while moving. Despite this, targets are not always acquired while moving; often one has to order the transport to stop, then the attacking begins, and the transport can start moving again. It might be possible to fix this using a behavior that searches for targets, but I'm too lazy.
I would think it would be as simple as:
On Event: AnimationDone
Term: AnimationName Open (Corresponding to the name of the animation given by the trigger, not the actual name as in the model's animation data)
Message: ModelSwap OpenGate
Now keep in mind that if the animation iss played with AnimationBracketStart, then your event should be AnimationBracketState.*.AfterClosing.
Is this what you have? If not, give it a try. If it still doesn't work, try starting a timer with the trigger, like: TimerStart 5.0 TimerName the time should correspond to the length of time it takes to perform the animation. Then, add an event:
On Event: TimerExpired
Term: TimerName TimerName
Message: ModelSwap OpenGate
Thanks, tdhsst, but it's not as simple as that. If you do not start any AI, then the units will not have any tactical AI (which tells them when and how to use abilities, the best way to win engagements, etc.). The ideal goal is to use much of Blizzards' built-in AI code for handling the fundamentals, including handling an economy and preparing attack waves. To hand-code every single action of that an AI takes, including building each and every structure at a precise moment and a precise location, would be excessive, plus lacking in flexibility. Now you're right that the "Start Melee AI" action will not be used in a good custom AI, but that does not mean that the AI will not be started at all. Instead it is started through the "Start AI Personality" action, which supplant the melee AI start code but will do many of the same things, and refer to the same body of Blizzard AI functions.
After looking into it more I am much closer to utilizing patch 1.5's AI module and answering Captaintoottoot's questions. The constant variables representing unit types are stored in Core.SC2Mod\Base.SC2Data\TriggerLibs\RequirementsAI.galaxy . Build order (what Captaintootoot was looking for) should be in the difficulty-level-specific AI, such as Terran0.galaxy. I think the build orders should therefore be put into the AI Personality's custom script, but I need to test things out before I can give specific directions.
For those who are interested, here's my notes on the various AI libraries. I think making AI with the new module will basically involve copying parts of these files into the Custom Script of an AI Personality, and then modifying it to fit the map's needs. The "REPLACE" column shows which files will likely be copied and modified.
ARCHIVE: FILE: REPLACE: NOTES:
Core.SC2Mod\Base.SC2Data TriggerLibs\AI.galaxy No Defines a number of important flag constants, as well as AI function prototypes. Important reference file, especially because it contains useful comments.
TriggerLibs\BaseAI.galaxy Maybe Defines flags, difficulty levels, and startup routines for melee and campaign AIs. Also defines which units count as healers, oddly enough--this part may need replacement.
TriggerLibs\BuildAI.galaxy Yes Sets flags for the structures for each of the three races that tells the AI how to position and treat them. Vital for custom tech trees.
TriggerLibs\CampaignAI.galaxy No Blank, equivalent of MeleeAI.galaxy. Probably defined in particular maps?
TriggerLibs\Computer.galaxy No Includes the relevant trigger libraries for a computer-controlled player. Useful for determining load order of the scripts.
TriggerLibs\DebugAI.galaxy No Outputs trigger debug messages. Mainly for Blizzard's own use.
TriggerLibs\MeleeAI.galaxy Yes Defines state constants and functions for states and waves, and at the end includes other AI libraries.
TriggerLibs\MeleeHardAI.galaxy Yes Scouting, intelligence, and strategic functions, only used for Hard AIs.
TriggerLibs\MeleeNotHard.galaxy No Economic functions only used for non-Hard AIs.
TriggerLibs\RequirementsAI.galaxy Yes Defines constant variables for all of the pertinent game links that AI code refers to, including units, upgrades, abilities, etc. Vital data to change for custom races or tech trees.
TriggerLibs\SharedAI.galaxy No Four small functions used by all AIs, whether melee or campaign.
TriggerLibs\Tactical\TactCompAI.galaxy No "Intentionally empty. Will be overridden by campaign-specific file."
TriggerLibs\Tactical\TacticalAI.galaxy No Tactical AI data in the Galaxy Editor's Data module is apparently converted to triggers. This file is the equivalent of the default Tactical AI data. Whether or not it has anything more than what is found in the Editor, there's no point in using this file, because the Tactical AI editing capabilities of the Editor are good enough.
TriggerLibs\TactProt.galaxy No Tactical AI data for Protoss.
TriggerLibs\TactTerr.galaxy No Tactical AI data for Terran.
TriggerLibs\TactZerg.galaxy No Tactical AI data for Zerg.
Liberty.SC2Mod\Base.SC2Data TriggerLibs\Protoss\Protoss.galaxy Yes Basic AI data and functions for a Protoss AI, including which units are used to counter which.
TriggerLibs\Protoss\Protoss0.galaxy Yes For Very Easy AI, functions for carrying out the current AI state (Attack by land or air? Early or late game?).
TriggerLibs\Protoss\Protoss1.galaxy Yes For Easy AI, functions for carrying out the current AI state (Attack by land or air? Early or late game?).
TriggerLibs\Protoss\Protoss2.galaxy Yes For Normal AI, functions for carrying out the current AI state (Attack by land or air? Early or late game?).
TriggerLibs\Protoss\Protoss3.galaxy Yes For Hard AI, functions for carrying out the current AI state (Attack by land or air? Early or late game?).
TriggerLibs\Protoss\Protoss4.galaxy Yes For Very Hard AI, functions for carrying out the current AI state (Attack by land or air? Early or late game?).
TriggerLibs\Protoss\Protoss5.galaxy Yes For Insane AI, functions for carrying out the current AI state (Attack by land or air? Early or late game?).
TriggerLibs\Terran\Terran.galaxy Yes Basic AI data and functions for a Terran AI, including which units are used to counter which.
TriggerLibs\Terran\Terran0.galaxy Yes For Very Easy AI, functions for carrying out the current AI state (Attack by land or air? Early or late game?).
TriggerLibs\Terran\Terran1.galaxy Yes For Easy AI, functions for carrying out the current AI state (Attack by land or air? Early or late game?).
TriggerLibs\Terran\Terran2.galaxy Yes For Normal AI, functions for carrying out the current AI state (Attack by land or air? Early or late game?).
TriggerLibs\Terran\Terran3.galaxy Yes For Hard AI, functions for carrying out the current AI state (Attack by land or air? Early or late game?).
TriggerLibs\Terran\Terran4.galaxy Yes For Very Hard AI, functions for carrying out the current AI state (Attack by land or air? Early or late game?).
TriggerLibs\Terran\Terran5.galaxy Yes For Insane AI, functions for carrying out the current AI state (Attack by land or air? Early or late game?).
TriggerLibs\Zerg\Zerg.galaxy Yes Basic AI data and functions for a Zerg AI, including which units are used to counter which.
TriggerLibs\Zerg\Zerg0.galaxy Yes For Very Easy AI, functions for carrying out the current AI state (Attack by land or air? Early or late game?).
TriggerLibs\Zerg\Zerg1.galaxy Yes For Easy AI, functions for carrying out the current AI state (Attack by land or air? Early or late game?).
TriggerLibs\Zerg\Zerg2.galaxy Yes For Normal AI, functions for carrying out the current AI state (Attack by land or air? Early or late game?).
TriggerLibs\Zerg\Zerg3.galaxy Yes For Hard AI, functions for carrying out the current AI state (Attack by land or air? Early or late game?).
TriggerLibs\Zerg\Zerg4.galaxy Yes For Very Hard AI, functions for carrying out the current AI state (Attack by land or air? Early or late game?).
TriggerLibs\Zerg\Zerg5.galaxy Yes For Insane AI, functions for carrying out the current AI state (Attack by land or air? Early or late game?).
Just a possible clue to tell the AI without tricking it:
It looks like the required AI state is e_mainState_OpenAir0, which I believe is equivalent to the number 8. So try using the Set State action in triggers to change the AI's state to 8, after initializing it. Let me know if that helps.
I'm looking into AI right now and there's not much info out there, it seems. There's a forum here: http://darkblizz.org/Forum2/land-of-ai/ but it looks like no one posts in it anymore. Still there's a lot there that's useful, though I would save your queries for SC2Mapster.
When running "Test map" it doesn't use a specific AI, I believe, but in a melee map the AI is dependent upon the game difficulty, and in a triggered map you are supposed to tell it via triggers how difficult to make the AI (and the parameters of this differ between campaign and melee AIs).
I'm curious how you overrided the scripts, e.g. Zerg0.galaxy. My suspicion is that they are not actually overridable, and for that reason the changes that you made were ignored altogether. With the new AI Editor it looks like we do not need to override the AI, because we can create our own scripts. As far as I can tell, the "Custom Script" for an AI personality replaces the Zerg0.galaxy, etc., in addition to the main racial AI (Zerg.galaxy), and it is designed to be run when an AI personality is initialized for a player via triggers.
That being said, where I am stuck at the moment is figuring out how to supplant the constant variables representing different unit types (like c_PU_Zealot). I cannot find where the variables are declared, but I guess if they refer to simple Game Links then I can replace them by declaring variables of my own, or using a String to Game Link function.
I'm looking into the AI trigger libraries and there are differences between the difficulty levels that are more than mere APM or resource cheating. In an MPQ editor open the Liberty.SC2Mod archive and go to Base.SC2Data/TriggerLibs/Terran . The Terran0, Terran 1, etc. represent different difficulty levels.
This new Cutscene Editor is frustrating me because it doesn't want to preview every model. Often times right-clicking a unit, actor, or model and selecting Preview just opens the Cutscene Editor with a blank slate. You can load the model by file directly, but sometimes that doesn't do anything either; nothing shows up. For example, right now I'm trying to compare the Dark Stalker missile with the regular Stalker missile, and neither shows up. Any suggestions?
Good news! It's way simpler now with patch 1.5. In order to make a unit stay on top of water you can simply add SOpHigherOfTerrainOrWater to the Host Site Ops + array inside the unit's actor. No need to use triggers to determine the height of the terrain vs the height of the water. But other means are still necessary for making the unit unable to travel on land. (See tutorial.)
So patch 1.5 says: "Items can now display range indicators and AoE targeting cursors when in target mode in custom games."
I know that previously the method for making AOE cursors for items was to use Ability-type items. This seems to imply that regular, Target items can use range and AOE actors. However, I cannot figure out how. There is a new "Item" message in the actor events, but it has no sub-messages, so I have no idea what it does. Anyone figure this out yet?
Seems like it should work. Have you played with the flags? Try the "Placement" flag. Technically what it does is check the spot you want the unit to spawn to make sure that it can spawn there, and if not it moves it slightly until it can. But maybe the effect is ignoring the offsets because it expects some flag to be set?
I want to remove it too. There's a pawn instant command in the inventory ability. I'm going to try either checking "Hidden" or putting a Requirement that always returns 0.
On the item itself, the Cost should not be set to anything because the item is not used up by its own use. An item's cost refers to the item unit, rather than the carrying unit, so it is of no use to us.
In the Ability, the charge location should just be Ability, and the Count (Use) should be 1.
In the Modify Unit effect, select the Ability from the list. Select Caster under Player - Value. To add a charge, set Usage Charge Count to -1. To remove a charge, set it to 1. For some reason I also have Fraction - Charge set to 1, but I don't remember why...
Now that I have my editor open, I'll go through more detail about how it works in my map. The item involved is the WheatSeed, and the ability is PlantWheat.
The Item's Carry Behavior:
<!--The Item is not Caster, apparently, but the Target is also Caster, so that stack times per caster must be unlimited.--><CBehaviorBuffid="CarryingWheatSeed"><InfoFlagsindex="Hidden"value="1"/><InfoIconvalue="Assets\Textures\btn-tips-chrysalis.dds"/><EditorCategoriesvalue="Race:Terran,AbilityorEffectType:Units"/><MaxStackCountvalue="20"/><InitialEffectvalue="WheatSeedAddCharge"/><RefreshEffectvalue="WheatSeedAddCharge"/><FinalEffectvalue="WheatSeedUseCharge"/></CBehaviorBuff>
According to my note, you have to make sure that the buff can stack on the unit, so its MaxStackCount must be greater than 1, the default.
The ability calls a Create Persistent effect. The initial effect of this CP is WheatSeedDoubleCharge, and the expire effect is WheatSeedDestroySearch.
Effect WheatSeedDoubleCharge:
<!--Because there is no way to distinguish between dropping an item and using an item in removing charges, and because the ability does not allow 0 to be the price of cost without messing up charges altogether, it is necessary to ADD a charge upon using the ability, so that charge can then be taken away when the item is destroyed. Also used to give refund in case of cancellation.--><CEffectModifyUnitid="WheatSeedDoubleCharge"><EditorCategoriesvalue="Race:Terran"/><ImpactUnitValue="Caster"/><CostAbil="PlantWheat,Execute"ChargeCountUse="-1"><PlayerValue="Caster"/><FractionCharge="1"/></Cost></CEffectModifyUnit>
In short, the item's carry behavior adds a charge when the unit picks up the item, both in its initial effect and in its refresh effect. It removes a charge when the item is dropped or destroyed.
Clicking the item also calls an Issue Order effect that orders the unit to cast the ability on the target unit.
The Ability calls an effect that at first calls an effect to add another charge, and when it's done is searches for the item and destroys it.
I did not realize, actually, that items could be filters using Required:Hidden. Thanks, DrSuperEvil.
0
@Freddy2287: Go
This has long been a problem with SC2 neutral shops, that requirements don't work like you would think. There are tutorials for workarounds if you search. Basically what people do is make an invisible shop for each player, and when they click the neutral shop triggers redirect their selection to the invisible shop. Since the invisible shop belongs to them, requirements work correctly.
Secondly, you no longer need to check for behaviors to see if a unit is carrying an item. Patch 1.5 added a validator that checks for an item in the unit's inventory, and even before patch 1.5 it was possible to check for items using requirements by doing: CountUnit(Item,CompleteOnlyAtUnit).
Another option is to use triggers the whole way, but this is not preferable. In order to be certain that a purchase is cancelled when someone attempts it without proper requirements, a small creation time needs to be added to the item, so that it takes 1 second for the shop to produce it. During this 1 second triggers can cancel the purchase if requirements aren't met. But it's annoying. I'd go the invisible shop way if this is going to be a major part of your map.
0
@Vietman: Go
If I remember correctly, when I did this I did have to change the weapons. So there's two versions of each unit's weapon, and a behavior is applied when they are loaded up that disables the default weapon and enables the weapon that attacks while moving. Despite this, targets are not always acquired while moving; often one has to order the transport to stop, then the attacking begins, and the transport can start moving again. It might be possible to fix this using a behavior that searches for targets, but I'm too lazy.
0
I would think it would be as simple as: On Event: AnimationDone Term: AnimationName Open (Corresponding to the name of the animation given by the trigger, not the actual name as in the model's animation data) Message: ModelSwap OpenGate
Now keep in mind that if the animation iss played with AnimationBracketStart, then your event should be AnimationBracketState.*.AfterClosing.
Is this what you have? If not, give it a try. If it still doesn't work, try starting a timer with the trigger, like: TimerStart 5.0 TimerName
the time should correspond to the length of time it takes to perform the animation. Then, add an event:On Event: TimerExpired Term: TimerName TimerName Message: ModelSwap OpenGate
0
@tdhsst: Go
Thanks, tdhsst, but it's not as simple as that. If you do not start any AI, then the units will not have any tactical AI (which tells them when and how to use abilities, the best way to win engagements, etc.). The ideal goal is to use much of Blizzards' built-in AI code for handling the fundamentals, including handling an economy and preparing attack waves. To hand-code every single action of that an AI takes, including building each and every structure at a precise moment and a precise location, would be excessive, plus lacking in flexibility. Now you're right that the "Start Melee AI" action will not be used in a good custom AI, but that does not mean that the AI will not be started at all. Instead it is started through the "Start AI Personality" action, which supplant the melee AI start code but will do many of the same things, and refer to the same body of Blizzard AI functions.
After looking into it more I am much closer to utilizing patch 1.5's AI module and answering Captaintoottoot's questions. The constant variables representing unit types are stored in Core.SC2Mod\Base.SC2Data\TriggerLibs\RequirementsAI.galaxy . Build order (what Captaintootoot was looking for) should be in the difficulty-level-specific AI, such as Terran0.galaxy. I think the build orders should therefore be put into the AI Personality's custom script, but I need to test things out before I can give specific directions.
0
For those who are interested, here's my notes on the various AI libraries. I think making AI with the new module will basically involve copying parts of these files into the Custom Script of an AI Personality, and then modifying it to fit the map's needs. The "REPLACE" column shows which files will likely be copied and modified.
0
Just a possible clue to tell the AI without tricking it:
It looks like the required AI state is e_mainState_OpenAir0, which I believe is equivalent to the number 8. So try using the Set State action in triggers to change the AI's state to 8, after initializing it. Let me know if that helps.
0
I'm looking into AI right now and there's not much info out there, it seems. There's a forum here: http://darkblizz.org/Forum2/land-of-ai/ but it looks like no one posts in it anymore. Still there's a lot there that's useful, though I would save your queries for SC2Mapster.
When running "Test map" it doesn't use a specific AI, I believe, but in a melee map the AI is dependent upon the game difficulty, and in a triggered map you are supposed to tell it via triggers how difficult to make the AI (and the parameters of this differ between campaign and melee AIs).
I'm curious how you overrided the scripts, e.g. Zerg0.galaxy. My suspicion is that they are not actually overridable, and for that reason the changes that you made were ignored altogether. With the new AI Editor it looks like we do not need to override the AI, because we can create our own scripts. As far as I can tell, the "Custom Script" for an AI personality replaces the Zerg0.galaxy, etc., in addition to the main racial AI (Zerg.galaxy), and it is designed to be run when an AI personality is initialized for a player via triggers.
That being said, where I am stuck at the moment is figuring out how to supplant the constant variables representing different unit types (like c_PU_Zealot). I cannot find where the variables are declared, but I guess if they refer to simple Game Links then I can replace them by declaring variables of my own, or using a String to Game Link function.
0
I'm looking into the AI trigger libraries and there are differences between the difficulty levels that are more than mere APM or resource cheating. In an MPQ editor open the Liberty.SC2Mod archive and go to Base.SC2Data/TriggerLibs/Terran . The Terran0, Terran 1, etc. represent different difficulty levels.
0
This new Cutscene Editor is frustrating me because it doesn't want to preview every model. Often times right-clicking a unit, actor, or model and selecting Preview just opens the Cutscene Editor with a blank slate. You can load the model by file directly, but sometimes that doesn't do anything either; nothing shows up. For example, right now I'm trying to compare the Dark Stalker missile with the regular Stalker missile, and neither shows up. Any suggestions?
0
Anyone notice the new "Vital bonus on dense terrain" field in the unit data? Any ideas as to what dense terrain is?
0
@lemmy734: Go
Good news! It's way simpler now with patch 1.5. In order to make a unit stay on top of water you can simply add SOpHigherOfTerrainOrWater to the Host Site Ops + array inside the unit's actor. No need to use triggers to determine the height of the terrain vs the height of the water. But other means are still necessary for making the unit unable to travel on land. (See tutorial.)
0
So patch 1.5 says: "Items can now display range indicators and AoE targeting cursors when in target mode in custom games."
I know that previously the method for making AOE cursors for items was to use Ability-type items. This seems to imply that regular, Target items can use range and AOE actors. However, I cannot figure out how. There is a new "Item" message in the actor events, but it has no sub-messages, so I have no idea what it does. Anyone figure this out yet?
0
@playpong: Go
Seems like it should work. Have you played with the flags? Try the "Placement" flag. Technically what it does is check the spot you want the unit to spawn to make sure that it can spawn there, and if not it moves it slightly until it can. But maybe the effect is ignoring the offsets because it expects some flag to be set?
0
I want to remove it too. There's a pawn instant command in the inventory ability. I'm going to try either checking "Hidden" or putting a Requirement that always returns 0.
0
On the item itself, the Cost should not be set to anything because the item is not used up by its own use. An item's cost refers to the item unit, rather than the carrying unit, so it is of no use to us.
In the Ability, the charge location should just be Ability, and the Count (Use) should be 1.
In the Modify Unit effect, select the Ability from the list. Select Caster under Player - Value. To add a charge, set Usage Charge Count to -1. To remove a charge, set it to 1. For some reason I also have Fraction - Charge set to 1, but I don't remember why...
Now that I have my editor open, I'll go through more detail about how it works in my map. The item involved is the WheatSeed, and the ability is PlantWheat.
The Item's Carry Behavior:
According to my note, you have to make sure that the buff can stack on the unit, so its MaxStackCount must be greater than 1, the default.
Effect WheatSeedAddCharge:
Effect: WheatSeedUseCharge:
Ability PlantWheat:
The ability calls a Create Persistent effect. The initial effect of this CP is WheatSeedDoubleCharge, and the expire effect is WheatSeedDestroySearch.
Effect WheatSeedDoubleCharge:
Effect WheatSeedDestroySearch:
Effect WheatSeedDestroy:
In short, the item's carry behavior adds a charge when the unit picks up the item, both in its initial effect and in its refresh effect. It removes a charge when the item is dropped or destroyed.
Clicking the item also calls an Issue Order effect that orders the unit to cast the ability on the target unit.
The Ability calls an effect that at first calls an effect to add another charge, and when it's done is searches for the item and destroys it.
I did not realize, actually, that items could be filters using Required:Hidden. Thanks, DrSuperEvil.