| 09-23-2002, 08:34 PM | #1 |
I want to modify AI script, but I do not know how to. I read this forum carefully, but I don't understand how.. -_-? so.. can someone make any tutorial or give me some examples.. |
| 09-23-2002, 09:11 PM | #2 |
First thing you need to get is a mpq extractor, I recommend winmpq for this, then you also need a program to add files to your map, for this I use MPQ2K. After you have these two programs (or one that does the equivalent), open up the main war3 mpq, extract all the ai files to a directory, then open notepad (or any other text editor), and look at the files. The easier ones are the campaign ais so I suggest you start with those, and then look at the true ais. Most of the functions work like this function ( easy,medium,hard, argument) I can give you some basic idea of how the ais work. call InitAssaultGroup() call CampaignAttackerEx( 1,2,3, GRUNT ) call CampaignAttackerEx( 1,2,3, HEAD_HUNTER ) call SuicideOnPlayer(M2,user) Here is a snip bit of code. This is telling the computer to create an attack group consisting of 1 grunt and 1 headhunter on easy setting, to create 2 grunts, 2 head hunters on medium and 3 grunts and 3 headhunters of difficult setting. Then its telling them to wait two minutes to attack. Note user is defined in globals area. M# stands for minutes. M2 is two minutes, M3 is three minutes... M12 is twelve minutes. I suggest start by looking at h02_red.ai it is quite a simple ai script, from which the ai was taken from. After you have completed your ai, you will open your warcraft3 map in the Warcraft3 editor, and call your script, then have a trigger call your ai function; I usually put my ai functions in directory Scripts/ainame.ai. Then save and close your map, now open up ms-dos, go to the directory where mpq is. Then type the command, for example mpq2k a test.w3m Scripts\new.ai. If you want to add your custom unit to a map, get the 4 digit code, then in globals put something like this constant integer name = 'code'. For example constant integer WAVE_DOOMS = 'nC00', is used in the nightelf 06_tich.ai call WaitForSignal(), this requires you to send the ai a chunk of code before it continues on. loop as you would expect, will continuously go through a chunk of code forever. loop //*** WAVE 2 *** call InitAssaultGroup() call CampaignAttackerEx( 1,1,4, GRUNT ) call SuicideOnPlayerEx(M5,M5,M4,user) //*** WAVE 3 *** call InitAssaultGroup() call CampaignAttackerEx( 1,1,4, GRUNT ) call SuicideOnPlayerEx(M5,M5,M4,user) endloop this would cycle through attack groups 2,3 |
| 09-23-2002, 09:19 PM | #3 |
Oh... I see. thank you |
| 09-23-2002, 09:27 PM | #4 |
Also I have a modfied ai script from di of the former site Campaigncreations.com, it is a modified orc.ai script not a campaign ai script, I could send it to you if you want, but is quite complex. If you are looking for a variable or want to reference a function it is a good idea to extract Blizzard.j, Common.ai, Common.j, and cheats.j |
| 09-24-2002, 03:55 PM | #5 |
can I make the computer to produce bandits from barracks? I tried, but the computer doesn't do anything. I am making a map against bandits. I edited unit properties, so barracks can produce bandits, enforcers, rugues, etc. |
| 09-24-2002, 04:18 PM | #6 |
An easy way out is to use triggers in world editor if you just want to do some simple things. (In fact, it can also be made to do very complicated things too.) e.g. E: every 100s C: player1's gold > 100 A: create 1 bandit for player1 at bandit camp player1's gold = player1's gold - 100 Simple enough! Of course, there are other advantages using .ai script. So it depends on you to choose which methods. |
| 09-24-2002, 05:23 PM | #7 |
I want to learn how to use AI scripts for further steps.. Also I tried to use triggers, but they are so complicated and make fatal errors sometime. -_-.. |
| 09-24-2002, 11:35 PM | #8 |
I made a quick map using a pre-existing human campaign ai, and added it to use the bandit, as well as a custom hero. http://aiursrage2k.virtualave.net/maps/bandit.w3m You can look at the map and see how it's done, and edit it if you want. |
| 09-25-2002, 03:07 AM | #9 |
.... can you tell me what i did wrong? here is the script.. I extracted bandit.ai script from your map, and I edited it.. //============================================================================ // Bandit.ai, builds bandits, human ai, and bandito. //============================================================================ globals player user = Player(0) constant integer BANDIT = 'nban' constant integer BRIGAND = 'nbav' constant integer ASSASSIN = 'nbae' constant integer ENFORCER = 'nbab' constant integer ROGUE = 'nbax' constant integer BANDIT_LORD = 'nbad' endglobals //============================================================================ // main //============================================================================ function main takes nothing returns nothing call CampaignAI(HOUSE,null) call SetReplacements(2,2,4) set do_campaign_farms = false call SetBuildUnitEx( 0,0,1, TOWN_HALL ) call SetBuildUnitEx( 3,3,3, PEASANT ) call SetBuildUnitEx( 0,0,2, BARRACKS ) call SetBuildUnitEx( 0,0,1, LUMBER_MILL ) call SetBuildUnitEx( 3,3,3, PEASANT ) call SetBuildUnitEx( 0,0,1, BLACKSMITH ) call SetBuildUnitEx( 4,4,4, PEASANT ) call SetBuildUnitEx( 0,0,1, KEEP ) call CampaignDefenderEx( 2,2,2, ENFORCER ) call CampaignDefenderEx( 1,1,1, BANDIT_LORD ) call CampaignDefenderEx( 3,3,3 ASSASIN ) call WaitForSignal() //*** WAVE 1 *** call InitAssaultGroup() call CampaignAttackerEx( 5,5,7, BANDIT ) call CampaignAttackerEx( 2,2,3, BRIGAND ) call CampaignAttackerEx( 2,2,2, ENFORCER) call CampaignAttackerEx( 1,1,1, BANDIT_LORD ) call SuicideOnPlayerEx(M1,M1,M1,user) call SetBuildUpgrEx( 0,0,1, UPG_MELEE ) //*** WAVE 2 *** call InitAssaultGroup() call CampaignAttackerEx( 2,2,4, ENFORCER) call CampaignAttackerEx( 1,1,2, ASSASIN ) call CampaignAttackerEx( 2,2,2, BANDIT_LORD ) call SuicideOnPlayerEx(M4,M4,M3,user) call SetBuildUpgrEx( 0,0,1, UPG_LEATHER ) call SetBuildUpgrEx( 0,0,1, UPG_ARMOR ) //*** WAVE 3 *** call InitAssaultGroup() call CampaignAttackerEx( 5,5,7, BANDIT ) call CampaignAttackerEx( 2,2,3, ASSASSIN ) call CampaignAttackerEx( 1,1,1, BANDIT_LORD ) call SuicideOnPlayerEx(M3,M3,M2,user) call SetBuildUpgrEx( 1,1,2, UPG_MELEE ) call SetBuildUpgrEx( 1,1,2, UPG_RANGED ) //*** WAVE 4 *** call InitAssaultGroup() call CampaignAttackerEx( 3,3,5, ENFORCER ) call CampaignAttackerEx( 2,2,2, ASSASSIN ) call CampaignAttackerEx( 1,1,2, BANDIT_LORD ) call SuicideOnPlayerEx(M3,M3,M2,user) call SetBuildUpgrEx( 1,1,2, UPG_LEATHER ) call SetBuildUpgrEx( 1,1,2, UPG_ARMOR ) loop //*** WAVE 5+ *** call InitAssaultGroup() call CampaignAttackerEx( 4,4,5, ENFORCER ) call CampaignAttackerEx( 2,2,3, ASSASSIN ) call CampaignAttackerEx( 2,2,2, BANDIT_LORD ) call SuicideOnPlayerEx(M3,M3,M2,user) //*** WAVE 6+ *** call InitAssaultGroup() call CampaignAttackerEx( 6,6,8, ROGUE ) call CampaignAttackerEx( 2,2,3, ASSASSIN ) call CampaignAttackerEx( 2,2,3, ENFORCER ) call CampaignAttackerEx( 1,1,1, BANDIT_LORD ) call SuicideOnPlayerEx(M3,M3,M2,user) endloop endfunction this script did not work at all.. I tried to figure out what the hell is wrong with this thing, but I have no idea. |
| 09-25-2002, 08:55 PM | #10 |
the four letter codes cannot be made up by you, they must be found using the map (creating a trigger with the unit, converting to jass, and taking the four letter code). I did this, and the globals should be changed to: constant integer BANDIT = 'nban' constant integer BRIGAND = 'nbrg' constant integer ASSASSIN = 'nass' constant integer ENFORCER = 'nenf' constant integer ROGUE = 'nrog' constant integer BANDIT_LORD = 'nbld' That might be the problem, providing you didnt make these unit(s) custom. Another problem might be that you didnt set these units to buildable from the building. If that does not work post your map up so that I may look at it. |
| 09-26-2002, 03:22 PM | #11 |
God!! it works now.. thank you so much. |
