• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Adding basic but effective AI to footman wars maps

Status
Not open for further replies.
Level 22
Joined
May 11, 2004
Messages
2,863
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
 
Level 4
Joined
Jan 9, 2005
Messages
106
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:
 
Level 22
Joined
May 11, 2004
Messages
2,863
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
 
Level 4
Joined
Jan 9, 2005
Messages
106
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)
 
Level 22
Joined
May 11, 2004
Messages
2,863
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
 
Level 1
Joined
Nov 11, 2005
Messages
1
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.
 
Level 8
Joined
Nov 20, 2005
Messages
372
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
 
Level 22
Joined
May 11, 2004
Messages
2,863
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
 
Level 22
Joined
May 11, 2004
Messages
2,863
But that is noob programming and every programmer know that ...

Well, appearently NOT considering how many foorman wars maps dont have AI in them. All you've done since you came to this topic is insult my work without providing anything better. That defines noob.

Now get down off your high horse and a write a better tutorial that everyone can understand.

*taps foot*
-VGsatomi
 
Level 25
Joined
Mar 31, 2004
Messages
4,468
Re: Okay I will do that!!

dhk_undead_lord said:
Okay if you want I write a toturial about giving a
footman map a good AI.

But I don'T know if ANDYBODY would understand it....

Hmmm, looks like I'll need to quote VG on this one

VG said:
Get down off your high horse

You won't know if anyone can't understand it unless you write it. So get around to it

What do you think this is, a community where everyone keeps their own things for themselves? Someone's never heard of learning from others
 
Level 22
Joined
May 11, 2004
Messages
2,863
But I don'T know if ANDYBODY would understand it....

Exactly.

Hence why I made this. Its easy for anyone who is only familiar with GUI. Although its nowhrre near as sophisticated, its the bare essentiuals needed to eliminate the whole "must have full house of human players only" nonesense, and does not require someone to learn a whole new programing language (jass), which most mappers do not know. So again, I invite you to write a tutorial for a better AI as long as anyone can understand it. If it starts off with "Step 1: learn jass", then I'm just going to ingnore it.
-VGsatomi
 
Level 24
Joined
Jun 26, 2006
Messages
3,406
dhk, it's "noob programming" because it's meant for noob programmers >_> VG said it's the easiest thing to do because s/he didn't specify how in-depth it had to be. first, if it doesn't have to be top-notch-overly-complex-unreadable-to-the-average-joe then it's probably going to be VERY simple to pros. second, I don't understand jass and doubt that 2 "C"s in high-school level java programming would help much, whether I know I catch on fast or not. third, the large majority map makers are NOT programmers, good map makers included, although they may learn how to do a few things here or there with very simple jass. this "noob programming" is so that anybody wanting to add AI to a footies game or create/modify their own with AI can do it easily and simply without requiring a large human in-game presence.

i would ask other people to form a fight ring around dhk and vg but that would probably be impossible >_> and i think one of them would find a way to virtually slap my account on wc3sear.ch >_>
 
Level 8
Joined
Nov 20, 2005
Messages
372
Yeah okay....

But the AI could be a little better.

Perhaps you create an +go back trigger+

Every 1 second
/
Pick every unit in playable map area and do then do ( multiplicate actions )

if owner of picked unit player controller equal to computer
Live of picked unit smaller than maximum of live of picked unit / 4
then order unit go to move to fourtain of live

or something like this :wink:
 
Level 8
Joined
Nov 20, 2005
Messages
372
NO problem...

Thats a part of a trigger of my map.

But PLEASE read this:

You have to decrase lagging with a custom script and you have to make another trigger.

Trigger 1.

Every 1 second
/
Pick every units in playable map area and do
if owner of picked unit controller equal to computer
Picked units live smaller or equal to maxímum of lives of picked unit / 4
then do:
Order picked unit to move to fourtain of live

Trigger 1.
Pick every unit in Range of Fourtain of live and do
if owner of picked unit controller equal to computer
Picked units live smaller or equal to maxímum of lives of picked unit / 4
then do:
Order picked unit to move to position of random units in playable map area matching owner of matching unit is an enemy of owner of picked unit an matching unit is a building equal to true

That was JUST the BEGINNING of my AI..^^ :wink:
 
Status
Not open for further replies.
Top