| 01-24-2010, 09:10 AM | #1 |
In melee AI script, there is a native CreateCaptains which create captains (an invisible unit) that coordinate the movement of the AI units. I'm having problem with these captains giving orders that conflict with mine. Here's the question: 1. What is the correct sequence or way to order units to perform my actions rather than following the captain's order. 2. What is the way to correctly manipulate captains so it will not made conflicting orders to the units? 3. Is there a way to shut them off without later crash them while expanding? (there maybe more than just expanding that causes the crash which has not been found yet) If anyone understand them or have some idea about these captains, you're welcome to leave your comment as well as it might help. |
| 01-24-2010, 01:32 PM | #2 |
1. Have you tried the order "AImove"? This one is used by AI to move group units in a formation way. 2. How captains can conflict orders? example please. 3. AI can crash the game when it orders them to reach a point/target out of map limits / unreachable |
| 01-24-2010, 02:57 PM | #3 |
1. I've seen this order but not yet test it. Thanks for the info. 2. From the trigger that i've created, it seems like the AI wrote by me did not trigger the 2nd captain out (attack captain). Whenever the AI order the group to attack somewhere and when the group of unit tries to leave the base to head to the destination, the defending captain will redirect them back to the base automatically. I'm sure it is done by the defending captain as the ping (a ping to track location of captains) on the gold mine teleported to my unit group and moved back into the base (sucking the unit group as well like magnet). native CaptainIsEmpty() response that it is true which means empty at that time. When there is a second captain occur (attack captain) then the native will return true. 3. When i try to turn off CreateCaptains(), the game will crash whenever i use native GetNextExpansion(). Still haven't found out what other crash it might cause after turning off CreateCaptains(). At the moment i'm relying on their base expansion code to made the AI expand. |
| 01-24-2010, 04:19 PM | #4 |
Captains are not invisible units. I can't imagine where you would get that idea. I think the highest level unit/hero in an assault group is designated as a Captain, and it is certainly a unit among the quantity controlled by an AI player. Just look at the common.ai natives which refer to Captains. AIs will override orders to their units. If you don't want this to happen, give the units you want ordered to another computer player without an AI that looks identical to the original. Have you searched through every function in your script to find references to the Captain? Remember that common.ai has both natives and non-native functions, and if any one of those functions you use refers to Captains, it may cause your crash. On the other hand, I can think of no good reason to remove the Captains, since they're not issuing orders or doing much of anything except perhaps determining which unit to protect, follow and when to retreat. Lastly, you can't fight against what AIs were intended to do. If you want your units to respond to your orders and such in a specific way, don't use an AI; AIs are for automating large-scale unit behavior, aka macromanagement. If that's not what you're looking for, then trigger it with in-map script. |
| 01-24-2010, 05:02 PM | #5 | ||
This is where i get those idea. I've used a trigger to get the reference of such widgets mention in that thread and the ping did change location when I set the captain home on the unit's destination. It ping on the map without any unit (AI or creep) there. The ping shows that the widget is moving and there's 2 ping per controller. One will move around with the unit group and one will be at the gold mine most of the time. Quote:
I'm sure that the GetNextExpansion() native is the one that crashes the game as the code works till that line. Quote:
|
| 01-24-2010, 08:03 PM | #6 |
Wow. That's actually pretty cool. I'd never read that. Can you post your code that monitors captain widget positions? I'd wager that GetNextExpansion requires a Captain. No way around that, unless you think you can avoid using it or trigger it within the map-script. If you want to manipulate the captain widget without the AI interfering, have you considered TeleportCaptain? Or is this precisely what the AI overrides? In which case, you'd need to periodically reinforce your desired order with a thread loop on the AI side (and a timer on the map-script side to periodically CommandAI). |
| 01-24-2010, 11:49 PM | #7 |
This is the closest i can get. JASS:function Trig_Untitled_Trigger_002_Actions takes nothing returns nothing local widget w = GetOrderTarget() local real Life = 0 local integer ID = GetHandleId(GetOrderTarget()) set Life = GetWidgetLife(w) //call DisplayTextToPlayer(GetLocalPlayer(), 0, 0,R2S(Life)) if Life == 0 then call DisplayTextToPlayer(GetLocalPlayer(), 0, 0,I2S(ID)) call DisplayTextToPlayer(GetLocalPlayer(), 0, 0,GetObjectName(ID)) loop call PingMinimapForForce(GetPlayersAll(), GetWidgetX(w), GetWidgetY(w), 1) call TriggerSleepAction(1) endloop endif endfunction //=========================================================================== function InitTrig_Untitled_Trigger_002 takes nothing returns nothing set gg_trg_Untitled_Trigger_002 = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Untitled_Trigger_002, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER ) call TriggerAddAction( gg_trg_Untitled_Trigger_002, function Trig_Untitled_Trigger_002_Actions ) endfunction I haven't try on other way to expand yet as i my priority are on the attack sequence. Not sure if i state the expansion value manually will help. but I do know that each mine has a value itself. TeleportCaptain doesn't help at all. It seems like it will only teleport the attack captain to the destination whereby my AI fail to trigger the attack captain. By using CaptainIsEmpty() it will return if the attack captain is available but it seems that my AI did not trigger it out. I'm using a loop to periodically send Group-orders but it will eventually been overwrite by the new order unless i make it loop every sec or 0.5sec. However, by having 2 "leader" the group will move back and forth. |
| 01-24-2010, 11:58 PM | #8 |
Fascinating. I've never experimented with AI Captains; it never occurred to me they were distinct entities. I will certainly pursue that avenue in the near future. Triggers (and a number of other game objects) cannot be utilized from within AI scripts. I've done extensive experiments on this subject during my work on PoC, even going so far as to attempt exporting trigger pointers made inside an AI script to the map script through gamecache, to no avail. Gamecache was able to send data back to a map script, which enabled a limited form of two-way communication, but since the return bug has been fixed, even this is called into question (I haven't experimented with it since the fix). Have you tried using a thread loop (since AI scripts don't abide timer objects IIRC) to TeleportCaptain to a desired location every, say, 0.1 second? |
| 01-25-2010, 12:13 AM | #9 |
I've tried using a thread loop but with no success. The problem is I can't trigger the attack captain to come out. It does however came out when the AI uses Keeper of the Grove and only when it summons the Treants. Edit: However it did teleport the defend captain to that specific location. Then there'll be no captain to use for TownThreatened() function i guess. Got to try it out. |
| 01-25-2010, 12:21 AM | #10 |
By "come out" do you mean it's only created or appears on the map under those conditions and is otherwise inaccessible? That would help make sense as to why you can't teleport the captain to a target point, in that it only exists under a set of conditions. If not for that, it should be easy to force the captain to a location. Is AttackMoveXY not helpful for guiding the forces? Or does the typically over-active melee AI override it somehow? |
| 01-25-2010, 12:53 AM | #11 |
Well you see that there is 2 ping right from the trigger? the moving ping is the attack captain where in my AI it doesn't have that and on my checking the captain is empty. I do not know what condition is to force it out. AttackMoveXY is called but the unit will not move unless i call my own group attack order. Some how i did not use SetMeleeGroup() from common.ai but creating my own group of unit through EnumUnits...functions. |
| 01-25-2010, 01:20 AM | #12 |
There's not much I say to assist you, except that you could keep up with the progress of my own investigations into how captains function. Hopefully it's not an integral aspect of your project and is something that can be addressed later, since I have other projects to work on before I can start tinkering with it. |
| 01-25-2010, 05:59 AM | #13 | |
Quote:
Or maybe that you can give some example of code on how to can direct the captain and i'll experiment with it and hopefully can extract something out of it. I guess a melee AI is no longer as fun to play with when they can't perform in battles. I can use blizzard's attack sequence but they seem to cheat the way to victory and with less reasoning done. Unfortunately this part is important as how a battle is fought is as important as how we should manage our economy. |
