| 12-28-2003, 01:11 PM | #1 |
Hi folks! I wrote a small and simple AI for the purposes of ordering all of an AI player's units to attack a specific location. The script and instructions how to use it are found here: http://www.hut.fi/~tgustafs/wc3attackai.html The AI simply gathers all attack units and launches an attack at the target of your choosing. Should be pretty easy to use. I have tested it only on a single map, but I believe that it is rather bug-free. Comments and suggestions for improving the ai are welcome. 8)) Cheers, Tommi |
| 01-01-2004, 02:43 PM | #2 |
Ohhh I was looking for something like this. I have been working on a map for a while now (FoK Map 3) and I wanted to do a AI for it. I realized that it would take too long time for me to do one so I'll try to adapt this one for that map, I'll be sure to add you to the credits if this works out :) *EDIT* It seems like if the AI meets a enemy along the way to their destination it will attack and when the enemy is killed it will go home again, any way to prevent that or do I have to fix that with triggers? |
| 01-01-2004, 07:44 PM | #3 |
I'll look into it, if I can get the AI behave better. Before that try reissuing the attack order until the target is destroyed. However, if your attack group has only heros, it acts just like you said. Try adding some regular units to prevent hard coded "heroes flee if alone" behavior. EDIT: Yeah, it seems to do as you said. I'll try to update the script tomorrow. Cheers, Tommi |
| 01-02-2004, 10:19 AM | #4 |
Alright. I now updated the AI. The new file is named attacklocation2.ai. http://www.hut.fi/~tgustafs/wc3attackai.html - Now, the AI continues to attack the target as long as it has units. - To form a new group of units, send a new AI command targeting the same location - To quit attack behavior, send a (0, 0) command (a new special command). It ends the attack cycle and the AI returns to the target location. Make sure to send the coordinates of home location before using this command, if you want the AI to return home. It can also be used to quit units' restlessness when the target location has been conquered. - AI also now excludes hidden units from the attack group. EDIT: Made a small change to the AI. Sending (0,0) now commands the AI to retreat and ignore enemy units until at home. Also, I noted that AI commands go into a stack (rather than a queue), and thus you should not send AI commands faster than every 1 second, or they are processed in a wrong order. There wasn't GetFirstCommand() function to use. :bgrun: Cheers, Tommi |
| 01-02-2004, 12:16 PM | #5 |
There's now attacklocation3.ai. - The AI now processes commands in the order you send them to it. I.e. You can now queue commands. E.g. send (homeX, homeY) followed by (0, 0) causes the AI to flee home. Cheers, Tommi |
| 01-02-2004, 02:12 PM | #6 |
Wow nice, there's just one more thing i'd like to ask for; Being able to set defending units. I tried adding it in myself but i'm not sure it worked right because it acts a bit strange. Code:
function PrepareAssault takes nothing returns nothing
local group g = CreateGroup()
local unit u = null
local integer id
call ClearCount()
call GroupEnumUnitsOfPlayer(g, ai_player, null)
set u = FirstOfGroup(g)
loop
exitwhen u == null
set id = GetUnitTypeId(u)
//If the unit is not hidden, building, or worker, assign it to the attack group
if (not IsUnitType(u, UNIT_TYPE_STRUCTURE) and not IsUnitType(u, UNIT_TYPE_PEON) and not IsUnitHidden(u) and GetUnitUserData(u) != 1) then
call CountUnit(id)
endif
call GroupRemoveUnit(g, u)
set u = FirstOfGroup(g)
endloop
call DestroyGroup(g)
call AddCountedToAssault()
endfunctionYou can see that I added in the condition "GetUnitUserData(u) != 1" but I don't know if it works right, could you look it up? |
| 01-02-2004, 03:17 PM | #7 |
Yeah. I'll look into it. |
| 01-02-2004, 04:59 PM | #8 |
Alright. It now works. 8)) I uploaded attacklocation4.ai. To leave units out of the attack group, you must give a custom value to one or more units of a unit-type to leave a number of them home. See the page for details: http://www.hut.fi/~tgustafs/wc3attackai.html The AI does not make difference between what specific units it picks to the attack group (only the number and unit type matter), and thus there is no way to discriminate between units of the same unit type. EDIT: updated ai script comments. EDIT2: There may be quite a few unit states, in which they should be excluded from the attack group. One I added was "is alive", others which occured to me (but weren't added) were at least "devoured". Dunno how many of them there are in fact when you begin to really search for them. emote_sweat Cheers, Tommi |
| 01-02-2004, 07:35 PM | #9 |
Great! I'll test it ASAP. |
| 01-07-2004, 07:56 PM | #10 |
Hi Kerry, how's the AI working? |
| 01-09-2004, 02:30 PM | #11 |
I've tested it now and it works perfectly fine, you've done a great job on this :D |
| 01-12-2004, 04:50 PM | #12 |
That's great to hear. :gsmile: |
| 01-29-2004, 06:06 PM | #13 |
I finished improving the attack AI so that it uses both the defense group and the attack group. :ggani: See: http://www.hut.fi/~tgustafs/wc3attackai.html It is named attacklocation6.ai. I added commands to select the groups to which orders are issued (see Section 4.4). The defense group behaves a bit differently than the attack group, but it should be good enough for simple attack orders. Now you can effectively separate the attack into two groups, as long as the attack orders are pretty simple. Suggestions for improvements and other comments welcome. 8)) Cheers, Tommi |
| 01-31-2004, 09:40 AM | #14 |
A more advanced version of the AI that includes 12 special commands is now available. It is named attacklocation8.ai. |
| 01-31-2004, 12:31 PM | #15 |
Guard positions were rather buggy and I removed support for them. Now there is attacklocation9.ai, which is more stable. |
