Warcraft III resources & community, 2003–2006 · archived

Adding basic but effective AI to footman wars maps

26 posts
#1

Adding basic but effective AI to footman wars maps

Okay, adding AI to footman wars maps is one of the easiest things to do, and makes the world of difference in the map's playability, especially with large file footman wars maps that are likely to never have a full house on b-net. It also allowes the map to be played to its full potential even on solo, which is ideal for those who like playing wc3 alone. So without further ado, here is how to create a basic AI for footman wars maps using only triggers:

With the method I will explain, it will only work if there is computer players in the slots. Leaving the slots empty will make the AI-orered units ignore the missing player and attack only ones that are activly in-game, so you can adjust how many players will fight by simply making sure there is an AI present.

Step one: Create a region in the dead center of the map. All footman wars maps generally have the same style layout, with four corners with 2-3 player positions in each corner, with a central battleground in the dead center between them all.

Next, make this trigger:

Event:
Region- unit enters (center Region you just made).
Condition:
Player controller comparison- owner of (entering unit) is equal to computer
Action:
Note: the condition in the action is an "and" condition
Unit- Issue order targeting a point- Order (entering unit) to (Attack move to) (random player of ((all players matching condition- (((matching player is an enemy of (owner of entering unit))) Equal to true AND (((matching player) slot status is equal to (is playing ))) start location)

This means when a unit enters the center region, it will attack-move the the start location (resumably where you placed the main structure) of a player that is playing and is an enemy of the unit that entered the region.

Next is the spawn trigger. Whenever you have a unit spawn, such as:

Event- periodic event
Action- create 1 (footman) for (Player#) at (whatever location).

Simply add this action behind it:

Action:
Note: This will be an "if/then/else" action...
if (player#) controller is equal ot (computer) then do Unit- issue order targeting a point- (unit- order (last crated unit) to attack move to center of (center region you made) or else (do nothing)

This way, whenever a computer is in a slot, the spawned units will attack to the center on their own. When all slots are filled, that will be a lot of units attacking to the center of the map, leading to a quik, large fight. Not only that, units that do make it to the center, and any that follow behind them, will automatically start attacking enemy player positions next. WHen a player is defeated, the units entering the center region will no longer attack that player Simple, no?

Now, here is how to make you comp players upgrade for themselves, so they not only attack you, but also keep up with you in upgrades:

You will first need a variable. Type: Random intiger. just call it "random".

Event:
Time- periodic event
Condition:
Player controller comparison- (player#) controller is equal to (computer)
Action:
Variuable: set variable "random"= (random intiger bewtween 1 and (however many upgrade types you have))
if/then/else function do this for every upgrade type...
condition: (if)
Intiger comparison- if (random) is equal to 1
Action: (then)
unit- issue research order- order (player's structure that has all the upgrades in it) to (research one of the upgrades)
Note: repeat that same "if/then/else" function for every upgrade type, then repeat this whole trigger for every player. Every time you repeat that action, be sure to up the number in "(random) is equat to #) by 1 each time, so it properly randomizes which upgrade to research.

You will notice that sometimes when a unit no longer has any orders, it will travel back to their spawn location. To make this useful, add a periodic event trigger with an action that selects all units around the spawn point (or stucture thats within it) and order the units matching the computer-controlled condition and order them to the center of the map. Upon entering the region again, they will go back to attacking enemy players.

And there you go. You map is now fully AI compatable and with only a few extra triggers! Now lets not see any more "must have a full house/human players only to play" footy wars maps :evil: !

These exact triggers were made for and used in my Footman Wars: Ladies Night map found here:

http://www.wc3sear.ch/index.php?p=Maps&ID=1856&sid=759b5c48399fb2c6abab609bc641339b

So you can CnP them yourself or otherwise examine them for yourself if you are confused here. It is unprotected.
-VGsatomi
#2
nice... u just explained what took me almost 3 days to figure out... and your is so much simpler (and probably more effective) than what i had thought of :D

edit: just looked over it again...
Event:
Region- unit enters (center Region you just made).
Condition:
Player controller comparison- owner of (entering unit) is equal to computer
Action:
Note: the condition in the action is an "and" condition
Unit- Issue order targeting a point- Order (entering unit) to (Attack move to) (random player of ((all players matching condition- (((matching player is an enemy of (owner of entering unit))) Equal to true AND (((matching player) slot status is equal to (is playing ))) start location)

wouldnt that "Player controller comparison- owner of (entering unit) is equal to computer" referring to the unit entering cause nothing to happen unless it is a computer that enters the center? i can see where that would most likely work under the terms that the computer opponent was attacked and is then chasing the enemy back into the center. hmmm... :neutral:
#3
Thats so only computer players are effected by this trigger. It would be inconvenient if human-player owned units suddenly started doing their own thing when they enter that region, wouldnt it? If you follow the previous triggers, all units spawned by AI players will attack move to the center region, where they will then be given different order upon entering that regiuon. The point is that computer units are constently attacking something. If they are chasing something and enter that region, they'll simply be given different orders.
-VGsatomi
#4
oh WOW I'm sorry i missed this part:
Note: This will be an "if/then/else" action...
if (player#) controller is equal ot (computer) then do Unit- issue order targeting a point- (unit- order (last crated unit) to attack move to center of (center region you made) or else (do nothing)

my bad :D
great example... wow i feel like a moron suddenly hehehe

only problem there is is that theres not going to be units to defend the base (as far as i can tell) and there will be no unit massive since as soon as it spawns its sent out. but HEY this would work :D
(besides... who wants a computer to be able to eradicate them in a footy wars anyways)
#5
There is some ptential for massing. Once a unit finishes its orders, such as finishing attacking an enemy player position, it will move back to their spawn location, eventually leading to a lot of units massing there. Just make a periodic trigger that pick all computer owned units around their start postions and order them to attack-move to the center of the map. Later in the game you will get 50-100+ unit rushes. But yes, with this method, its not very defense freindly.
-VGsatomi
#6
heeeyyy....I'v got this in my Wood War'z map :P
Thats where you got the idea?
#7
In wood warz, they only attacked to the center. With this method they'll attack to all active player positions.
-VGsatomi
#8
Very helpful, VGsatomi. I for one thank you for putting this up.
#9
Thank you for posting this. ^^
#10
Very interesting thats exactly what i did with my footman, of course accept for a few things, thats the reason i made a footman i didnt think there were any with ai.
#11
good idea, how about battleships? give comp sailors a few mor weapons and have them move around killing things?
#12
If anybody should be interested, I've made a tutorial for making simple AIs for hero arena's, I know I should fix typos and grammatical errors in it, but I haven't done it yet.

http://www.wc3jass.com/viewtopic.php?t=2474
#13
I think I have an incomplete version of WE

cause I don't have the (random player of ((all players matching condition))
#14

Map AI

I don't think so because I am an AI-maker too and I know theres everywhere a way to create an AI for maps. So I added AI to my heroarena, too. I think you all think that AI-creating is to easy , buts very difficult to create an AI what could win against an human with fair play. I added a effective AI to my footman map ( VGsatomi has already seen it ) and I am angry of your replies for an good AI. I don't think that a only order unit to attack/move to x order is a good AI. I Think there are better ways to make an realistic AI.

If you want , I will send you some triggers for my AI.

If you want to play my map, go to the followring map:
http://www.wc3sear.ch/?p=Maps&ID=8277
#15
I never said this was the best AI, its just something easy that anyone can understand meant for people to put in so there are no more "Must have full house of human players for this map to be worth anything because there is no AI" maps that there are all too many of. Not the complicated stuff that many beginners would possibly not understand, like what you used.

So go ahead and get angry all you want. See if I care.
-VGsatomi