- 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
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