| 10-08-2002, 01:16 AM | #1 |
This thread will eventually Be locked and Untouchable except by another sticky below it so that All the Important stuff is kept in one easy to read place. It is currently Under construction as is the rest of the forum. But for now I want people to ask lots of AI and JASS questions, so that I can start on getting this FAQ useful. Thanks What is AI? Artifical intelligence. It is what causes the computer to act the way it does. Where is the AI in Warcraft III? If you are looking for the Muliplayer and Campaign AI that came with the retail. They are located in the .mpq under the Scripts folder. If it is Custom and added by the Map maker it is in the map where ever he placed it or in hte triggers. What are the files for the AI? Blizzard.j, common.j, common.ai human.ai, orc.ai, elf.ai, undead.ai I looked in the Script folder and there are way more than the ones you named? Yes, That folder holds all the scripting stuff blizzard used for Warcraft III. Not just AI stuff. Most of them are files for the campagins. There are some .j, .pld, and .ai files. I don't feel like extracting them can I download them from somewhere? I know have them hosted on a Quickie page I made. Goto the Files section and it will have those files. www.dkslayer.netfirms.com What is a .pld file? It is a file that preloads other files. What is a .j file? These two files, Blizzard.j and common.j, contain all the functions and globals that compose JASS. What is that JASS you mentioned? JASS is the scripting langauge that Blizzard uses. If you do any Custom Text Triggers or work on your own AI files that is what you will be doing. So the .ai files are where the AI is? Yes. The .ai files are basicly just a bunch of the JASS Functions put in a certain way with other Statements in it. How can I make computer AI? Their are about 3 ways. 1st and easiest. You can make triggers and cause the compuer to act in certain ways. I don't consider this scripting AI, but it is AI at it's simplest form. 2nd Making a Custom Text Trigger and script AI in it. This is still a form of the above method but you have more flexibilty and it's a step closer to real AI scripting. 3rd Make a real .ai file and script with in it to create the computer AI you want. This is the most difficult but you have Total Freedom and Power. How can I make a Custom Text Trigger? Make a new trigger in the Trigger Editor. Then select it, goto the edit menu, and Click Convert to Custom Text. Wammy. Now you can script using JASS. Any Special Tools needed to make AI No, just use notepad to make the .ai file. There are two tools in development to make that task easier. For beginners to Experts look at JonahDean's Upcoming AI Builder. Going to be awesome. Provides a great GUI, kind of like triggers but for AI.For Ok to Experts I have an advanced Editor in the works. Think of Notpad on steroids although that's don't do it justice. Both Programs are in beta, yet AI Builder should be done soon. |
| 12-05-2002, 05:32 PM | #2 |
Here I will talk about JASS functions and the Various parts and things you can do to them. Lets start out with a simple description of a function. What is a Function? To me I compare it to a part in a motor. The motor being the trigger or .ai file. Say the Air Filter on your car. It takes in dirty air, and returns clean air. Other parts don't take or return anything, like the lights on you car, they are turned on or in our case called and just do what they were made to do. So a fuction is like a chunk of your code, it's hard to explain so I will show you. Code:
function Displayer takes player Comp, string Msg returns nothing local integer Test = GetPlayerID(Comp) call DisplayTimedTextTo( Comp, 0, 0, 5, "Player's Id " + I2S(Test) + " the msg is: " + Msg ) endfunction function Main takes nothing returns nothing call Displayer(Player(3), "Night Elves RULE.") endfunction See all that is our code yet there are two functions. Of course I could put the Displayer code in the main instead of using a function, but What if I use that code 5 times it is less code to just call the function. Basics of a Function It's Really Simple a Function executes whatever code is inside when it is called. It can take and return stuff. All delcarations of variables must be done at the begining of the function or causes problems. Function taking and returning and Calling Ok Lets start with a main function. Usually your main function does not return anything nore take anything so it looks say like this. Code:
function Main takes nothing returns nothing endfunction So lets say you wanted a function that would take 50 away from and integer Multiply by 9 and divide by two. You would do this. Code:
function Math takes integer MyNumber returns integer set MyNumber = (((MyNumber - 50) * 9) / 2) return MyNumber endfunction So lets see these functions used together. Code:
function Math takes integer MyNumber returns integer set MyNumber = (((MyNumber - 50) * 9) / 2) return MyNumber endfunction function Main takes nothing returns nothing call Math(125) endfunction Code:
function Math takes integer MyNumber, boolean NO returns integer if (No == False) then set MyNumber = (((MyNumber - 50) * 9) / 2) else set MyNumber = (MyNumber + 2) endif return MyNumber endfunction function Main takes nothing returns nothing local integer Num set Num = call Math(125, true) endfunction Code:
set Num = Math(150) Code:
if (Math(150) = 25) then --CODE HERE-- endif There you go you got the basics of making/creating a function, issuing calls to them, and dealing with Arguments(takes & returns). Good Luck DKSlayer |
| 12-24-2002, 03:17 PM | #3 |
This section will explain variables. We will show you how to use them. What is a Variable? To explain this lets pretend a Variable is a Bag. Now the Bag holds an Item(for us Data) so we can put it aside and come back to the bag and it will still be there. So basically a Variable holds one thing of data for us. The Basics to using a Variable To use a Variable you must Declare it(Create it). When you create it you also say what kind of data or object it will hold. A couple examples of that is, strings, integers, timers, dialogs, etc.. After you declare it you can put stuff into it and use it for what you need. NOW Very important the Variables must be declared at the begining of the function if you are doing a trigger. If you are using doing this in a .ai file than locals declared at the begining of the function they are in, and globals at the begining of the file. Declaring a Variable When you declare a variable there are 5 things you can do state, if it will be a constant, if it will be local or global, if it will be an array or not, the name of the variable, and an initial value if you would like. Lets start with the constant. Constants These don't allow the value of the Variable to change. You set the Value when you declare it, and that's it. No, changing it later in the code. Now you are probably asking why the heck would I want to use a Constant than. Well If you have a value that you use a lot across a project and you want to change that value, instead of having to go through each time you want to change that one you could just use a const and change the value where it was declared. Code:
function ConstantExample takes nothing returns nothing local constant integer varTest = 5 call call DisplayTimedTextToPlayer(Player(0),0,0,varTest,"The Commander Help") call call DisplayTimedTextToPlayer(Player(0),0,0,varTest,"To attack") call call DisplayTimedTextToPlayer(Player(0),0,0,varTest,"To Tribute") call call DisplayTimedTextToPlayer(Player(0),0,0,varTest,"To Stop Current") endfunction You will use these very rarely if at all. To declare a variable that is not a constant, just leave constant out of the declare statement. Code:
local integer varTest There are two settings for variables, they can be local meaning they can only be used within that Function or global witch can be used all the way across the code. Globals can only be declared in .ai files. If you want to delcare a Global in a Trigger, you will have to do it in WE by going to the Variable Dialog and doing it there, when you refer to the variable then you add udg_ to the name you gave it in the dialog(you only have to do udg_ thing when you refer to one you made in WE.) Here are examples on how to declare both Code:
//Here is a Local
local string MyMsg
//Here is how to declare a global
globals
constant string Msg = "Error"
integer MyNum
endglobalsArrays will be talked about in next post. The Name This is just the name you will use to refer to it later. For easy of finding and knowing what it is it's nice to use naming conventions like, strMsg intNumber blnYea. You are able to tell that strMsg is a string, intNumber is a Integer, and blnYea is a boolean. You don't need to do this just makes t easier for you and those that may look at your code later. Intial Value You can set the Initial Value of your variable when declaring the variable or if not. Here is an example of both. Code:
//Variable has Initial Value local integer intNumber = 5 //Variable has no Initial Value local integer intNumber Setting a Variable |
| 12-30-2002, 07:55 AM | #4 |
Pretty good. I give it 4****s. Sorry for being corny. Gives great insight into ai. You gotta know something about it in the first place, but still nice. And for the dude with the dancing avatar, just make a few triggers, convert them to jass, then learn them a bit that way. Its pretty easy, give it a try. |
| 01-04-2003, 06:22 AM | #5 |
For you who are too lazy or just too stupid to use Winmpq or another program, i put the files into a .rar file. |
| 01-06-2003, 04:32 PM | #6 |
I have a site up with those files up as well. If I am right it has unlimited Bandwidth so if the site biffs it tell me. Also I have noticed the views on this thing are rising faster, I will try and get mroe stuff on this. Finish the Variable part and start the array stuff. Thanks All DKSlayer |
| 01-16-2003, 10:13 AM | #7 |
Guest | bravo...i wouldn't have the patience to write all that stuff :) altho I see jass for the first time(well, not first, i do custom trigers a lot) it looks much like java :) it's very similar....but i think u should first upload a basic programming tutorial before teaching AI making.... that's just my opinion :) |
| 01-16-2003, 03:49 PM | #8 |
Thank You, I still really need to work on the Setting a Variable and Array part. Yes it is a lot like JAVA. As a matter of fact, at Beta Time when I was learning JASS, I was also taking a class in JAVA which helped me tons. It worked out nicely. This part will teach you alot of JASS, then I hope to sit down and do an AI again step by step, while writing a tutorial as well. This might be a little bit since College has started but hope to get it soon. Thank You DKSlayer |
| 02-15-2003, 09:50 AM | #9 |
Guest | Pretty cool faq....... Has the language changed much since the old beta days where we were the pioneers and made the very first AI scripts?? Ive been away from war3 for a while but maybee i can still do something on the scripting scene. (Im sure i can learn JASS agai pretty quick) Gof (Yes it was me who made that human ai for the beta that kept coming in new versions (The aiscript not the beta )) |
| 02-17-2003, 04:46 PM | #10 |
I rememeber you GOF, I still have your Script on my computer Somewhere. JASS has not changed much at since beta, only a couple of functions changed, added, or removed. Nothing stelar. So it should be easy getting back into it for you. Welcome Totally and hope you enjoy the time here. Thanks DKSlayer |
| 04-26-2003, 03:32 PM | #11 |
I wonder if JASS is able to address details which are not included in the Trigger editor. I'm talking about Unit Stats like Basic Attack Damage or Attack Cooldown Time. Couldn't make it work, as shown here |
| 05-25-2003, 06:39 AM | #12 |
What should I do to get an AI script up and running? I have tried to stuff my ai script everywhere, in the map file, outside the map file, in a Scripts directory in an outside the map. I am trying to start the script with: function Trig_Melee_Initialization_Actions takes nothing returns nothing call StartMeleeAI( Player(1), "test.ai" ) endfunction //=========================================================================== function InitTrig_Melee_Initialization takes nothing returns nothing set gg_trg_Melee_Initialization = CreateTrigger( ) call TriggerRegisterTimerEventSingle( gg_trg_Melee_Initialization, 3.00 ) call TriggerAddAction( gg_trg_Melee_Initialization, function Trig_Melee_Initialization_Actions ) endfunction But it doesn't seem that my script run at all, this is the scripts code: function main takes nothing returns noting call DisplayTimedTextToForce( GetPlayersAll(), 30, "Hello World, I am ai" ) endfunction Please help. :( /Vidstige |
| 05-25-2003, 08:01 AM | #13 |
In your AI script you use DisplayTimedTextToForce and GetPlayersAll . These are in Blizzard.j and functions in that file cannot be accessed from AI. So what happens is that War3 finds that error and then just ignores the script. Best test your scripts with the script checker. What you can access from AI scripts is common.j and common.ai . So to display something to all players use call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 20, "Hello, world" ) The right place for scripts is the \Scripts subfolder in the map. |
| 05-25-2003, 09:20 AM | #14 |
It works! :ggani: Thanks Andy! |
| 05-31-2003, 10:10 AM | #15 |
Guest | is there is list of functions anywhere that i can get? |
