Chocobo
White-Flower
- Reaction score
- 409
This is the whole list of native types, constants, and APIs I done on some months after I'd wrote the whole list for Unit Group functions.
The whole clear Unit Group function list can be found there.
All Credits goes to :
- Blizzard for Warcraft 3
- JASS Shop Pro (most of functions found there)
- JASS Craft (most of functions found there)
I'm not sure about TFT/ROC Triggers, so if someone finds something, post it there.
JASS Starting Tutorial
JASS is a scripting language used for Warcraft 3 .j scripts and .ai scripts, only these are allowed to be ran with Warcraft 3.
.j scripts are JASS scripts, whereas .ai scripts are Artificial Intelligence (AI) scripts.
Whenever you save your map, the JASS Script is imported to your map with a name called war3map.j, from the Graphical User Interface (GUI) of the Trigger Editor. All GUI Scripts can be converted to JASS via "Convert to Custom Script" in "Edit" menu.
When you create a global variable in the Variable Editor (from Trigger Editor), the World Editor generates a new global declaration (you'll see after that) with a _udg prefix variable. Also, all spaces on a variable are replaced with an underscore ("_"). You can easily crash WE with that problem, like writing two variables like this :
Variable 1 : my var (udg_my_var)
Variable 2 : my_var (udg_my_var)
Respectivly the same. Maybe it won't crash, but you will simply get compile errors while saving, and maybe you'll see an error giving that the variable is already used.
All JASS Scripts consist on series of "global declarations" :
- Type Definitions (type type extends type)
- Global Variables (globals type name = expression)
- Native Functions (native funcname takes parameters returns returntype)
- User Defined Functions (function funcname takes parameters returns returntype)
Each Declaration begins on a new line, but in all cases, you can't refer to declarations written after the reference you want. In simple words,type declarations and global variables must be declared before all user-defined function declarations.
Type Definitions
There is a Type List Definition at the second post of this thread.
JASS has a system to help to the assignement and expressions. Example, you can't write unit = ability. There are also subtype variables for some types.
Native Integer Types
Each JASS integer takes 32 bits (4x8 bits). They are just like the C++ "int" (signed) type. In some other documentation of this kind you may see them named "long" (because their range are from -2147483647 to 2147483647).
There are also Short Integers that takes only 2 bytes. They are close to the C++ named "short" (signed) but their range is from -16384 to 16383. It means the 2 highest bit are free of use for a flag for example.
But both types are in "Little Endian Order", meaning that all bits are reversed. Here's an example :
integer 1234 = [D2 04 00 00]h instead of [00 00 04 D2]h
Integers can be :
- Decimal (No fractionary part), like -661, 385, but not [del]2.01[/del].
- Octal (Only if an integer starts with 0), like 07 = 7.
- Hexadecimal (Only if an integer starts with 0x, it'll be considered as a hex value), like : 0x0==0, 0xA == 10 , 0xF == 15 , 0xFF == 255. The whole hex table list can be found there.
- Character ASCII (Any integer between ' and '), like : 'A' = 65.
- 4 Character ASCII (4 numbers between ' and ', takes 4 bytes) like : '1234' = 825373492.
Real Native Types
Each Real are Floats (Floating Points). They all take 4 bytes and are in Little Endian Order.
Example : 7654.32 ~ [8F 32 EF 45]h ~ 7654.319824
The last number is the closest number to 7654.32
Real Variables are :
- Floating Points (or called simply Rational Numbers, or Fractional Numbers), like : 1.2586
Boolean Native Types
Boolean, or "Flags", take 4 bytes. In those 4 bytes, there are 32 bit, which can contains 32 flags. Each Flag can contain only the value 0 (False) or 1 (True).
Boolean Variables are :
- 0 or 1 post-predictions flags. Meaning, 0 returns false (C++), 1 returns true (C++). It is usually used on "if" statements.
String Native Types
String Variables are :
- String Carriage Characters, representing a string only between " ", like "my test", or "blabla".
- Localized Strings, using "TRIGSTR_XXX" or "TRIGSTR_XXXX". Using "TRIGSTR_XXX" is meaning that the game reads into the .wts file directly to find its equal value.
String Native Types are using Control Characters and a Special Format for Warcraft 3.
Control Characters :
- |n or |r = Carriage return.
- \" = Allow Quotes inside strings, control.
- \\ = Allow \ inside strings.
Format :
- |n = New line.
- |r = Resets the color back to the normal.
- |cAARRGGBB<msg> = Color change the text until |r. AA meaning Alpha between 0x00 (00) to 0xFF (FF), RR meaning Red, GG for Green, BB for Blue. Each Base16 (Hexadecimal) integer must contains 2 digits, like : |CFF4185C9, meaning for 255 Alpha (0% transparency), 65/255 Red, 133/255 Green, and 201/255 Blue (result color : dark blue).
Handle Native Types
Handles can be many things, here's the full list :
So it is :
Handle extends Event, Player, Widget, Unit, Destructable, Item, Ability, Buff, Force...... Version, Item-Type, and Text Tag. So there are 69 differant types of Handles.
Remember that a Widget (italic in the CODE section) can be only a unit, an item, and a destructable. And also, a Widget is a Handle, so handle should be be enough.
Global/Local Variable Declaration
There are 2 types of Variable Declaration :
- Global
- Local
Global is meaning that it can be used by any trigger, and its value can be overwrote over with an another trigger, whereas a local works only for a function.
A global is declared in that way :
Remember you can't do that in World Editor unless you use a preprocessor, World Editor will give you an error while saving (Only the Variable Editor is able to create a variable via the Trigger Editor if you are using the simple World Editor). Here some examples of global declaration :
- An array variable unit called UnitArray
- A unit variable called Unit
- A handle variable called Handle
- A trigger variable called Trigger
An array variable is a variable that is set differantly. It has 8192 possible indexes (setting the 8192st index will crash the game save) with index call whereas a non-array has only 1 index without index call.
Here some exemples of settings :
We can't fit a value for UnitArray unless we use an index call (a loop should do it). There, Unit variable is set to UnitArray[0] (UnitArray[index], meaning UnitArray's first index, index being equal to the index given - 1), Handle is set to Unit (a handle can be a unit), and Trigger creates a trigger for itself (that does nothing).
Declaring a local is a bit the same, it only looks like :
This is the old global declaration converted to our local declaration. Local Variables only work in a function, remember that.
Also, pre-defined variables (From Variable Editor) ever starts with the udg_ prefix, as said a lot before this.
Functions
A function is like that :
Local Declarations can be found before this.
Paramater Lists are what type of paramaters the function takes.
There, the function "Ex" takes a unit that will be called "u", and an integer called "i" in the function.
Return Type is what the function returns. As said in the funcname function, if the returntype is equal to none, it returns nothing, else it returns something in a return block :
There, "u" and "i" are parameters, and "u" is returned.
Statements are functions, sets, or something that order the function to do something.
Example :
There, if "u's Custom Unit Value (Integer - Get Unit Custom Value) equal to "i", it returns the unit, else it returns null.
There are also constants function, like :
With that, you are not allowed to call non-constant functions in it, whereas you are able to use the set statement, so it isn't really a constant.
Set Statements
A statement is what a function does, there is only one statement per line (exception : if + then + (else) - /line break endif).
The most known statements are the set something to something :
The Expression returntype must be equal to the Variable to work, so does for the array variable. Also, an array variable without an index is illegal.
The first one is legal, the second one is not legal.
So does if we try to use an Expression that do not match up the Variable type :
So that's simple to understand.
Call Statements
Call Statements are started with call, then a space, and after the name of the function (native or user-defined in map header). And then, you must put a "(", and after the arguments, each taken one by one seperated with a ",", and at end, closed with a ")".
Examples :
There, the function Test takes 2 paramaters, u and i, and calls the function Ex with the same paramaters because the function Ex takes a unit and an integer.
In small example, it looks like :
Remember, a function that takes nothing is called simply by :
Loop Statements
Loops are something to avoid you to copy and paste a million of times, it does simply for you : For Each (Integer) X to Y, do actions between loop - endloop :
There, the function Test loops 20 times from 0 to 19, both included.
-> set i=0
-> call Ex(u,0)
-> set i=i+1=1
-> call Ex(u,1)
-> set i=i+1=2
-> call Ex(u,2)
-> set i=i+1=3
-> call Ex(u,3)
-> set i=i+1=4
...
-> call Ex(u,18)
-> set i=i+1=19
-> call Ex(u,19)
-> set i=i+1=20
-> exitwhen prediction true.
A loop without exitwhen prediction is legal. But it is then an infinite loop, no wait in will crash any computer that runs the function.
If-Then-(Else)-Endif Statements
There are 3 types of If-Then-(Else)-Endif Statements :
If-Then-Endif :
If-Then-Else-Endif :
Else-If-Then :
Each "if" predictions must return a boolean value. If it isn't returning that, it gives you a compile error while saving.
More will come later.
The whole clear Unit Group function list can be found there.
All Credits goes to :
- Blizzard for Warcraft 3
- JASS Shop Pro (most of functions found there)
- JASS Craft (most of functions found there)
I'm not sure about TFT/ROC Triggers, so if someone finds something, post it there.
JASS Starting Tutorial
JASS is a scripting language used for Warcraft 3 .j scripts and .ai scripts, only these are allowed to be ran with Warcraft 3.
.j scripts are JASS scripts, whereas .ai scripts are Artificial Intelligence (AI) scripts.
Whenever you save your map, the JASS Script is imported to your map with a name called war3map.j, from the Graphical User Interface (GUI) of the Trigger Editor. All GUI Scripts can be converted to JASS via "Convert to Custom Script" in "Edit" menu.
When you create a global variable in the Variable Editor (from Trigger Editor), the World Editor generates a new global declaration (you'll see after that) with a _udg prefix variable. Also, all spaces on a variable are replaced with an underscore ("_"). You can easily crash WE with that problem, like writing two variables like this :
Variable 1 : my var (udg_my_var)
Variable 2 : my_var (udg_my_var)
Respectivly the same. Maybe it won't crash, but you will simply get compile errors while saving, and maybe you'll see an error giving that the variable is already used.
All JASS Scripts consist on series of "global declarations" :
- Type Definitions (type type extends type)
- Global Variables (globals type name = expression)
- Native Functions (native funcname takes parameters returns returntype)
- User Defined Functions (function funcname takes parameters returns returntype)
Each Declaration begins on a new line, but in all cases, you can't refer to declarations written after the reference you want. In simple words,type declarations and global variables must be declared before all user-defined function declarations.
Type Definitions
There is a Type List Definition at the second post of this thread.
JASS has a system to help to the assignement and expressions. Example, you can't write unit = ability. There are also subtype variables for some types.
Native Integer Types
Each JASS integer takes 32 bits (4x8 bits). They are just like the C++ "int" (signed) type. In some other documentation of this kind you may see them named "long" (because their range are from -2147483647 to 2147483647).
There are also Short Integers that takes only 2 bytes. They are close to the C++ named "short" (signed) but their range is from -16384 to 16383. It means the 2 highest bit are free of use for a flag for example.
But both types are in "Little Endian Order", meaning that all bits are reversed. Here's an example :
integer 1234 = [D2 04 00 00]h instead of [00 00 04 D2]h
Integers can be :
- Decimal (No fractionary part), like -661, 385, but not [del]2.01[/del].
- Octal (Only if an integer starts with 0), like 07 = 7.
- Hexadecimal (Only if an integer starts with 0x, it'll be considered as a hex value), like : 0x0==0, 0xA == 10 , 0xF == 15 , 0xFF == 255. The whole hex table list can be found there.
- Character ASCII (Any integer between ' and '), like : 'A' = 65.
- 4 Character ASCII (4 numbers between ' and ', takes 4 bytes) like : '1234' = 825373492.
Real Native Types
Each Real are Floats (Floating Points). They all take 4 bytes and are in Little Endian Order.
Example : 7654.32 ~ [8F 32 EF 45]h ~ 7654.319824
The last number is the closest number to 7654.32
Real Variables are :
- Floating Points (or called simply Rational Numbers, or Fractional Numbers), like : 1.2586
Boolean Native Types
Boolean, or "Flags", take 4 bytes. In those 4 bytes, there are 32 bit, which can contains 32 flags. Each Flag can contain only the value 0 (False) or 1 (True).
Boolean Variables are :
- 0 or 1 post-predictions flags. Meaning, 0 returns false (C++), 1 returns true (C++). It is usually used on "if" statements.
String Native Types
String Variables are :
- String Carriage Characters, representing a string only between " ", like "my test", or "blabla".
- Localized Strings, using "TRIGSTR_XXX" or "TRIGSTR_XXXX". Using "TRIGSTR_XXX" is meaning that the game reads into the .wts file directly to find its equal value.
String Native Types are using Control Characters and a Special Format for Warcraft 3.
Control Characters :
- |n or |r = Carriage return.
- \" = Allow Quotes inside strings, control.
- \\ = Allow \ inside strings.
Format :
- |n = New line.
- |r = Resets the color back to the normal.
- |cAARRGGBB<msg> = Color change the text until |r. AA meaning Alpha between 0x00 (00) to 0xFF (FF), RR meaning Red, GG for Green, BB for Blue. Each Base16 (Hexadecimal) integer must contains 2 digits, like : |CFF4185C9, meaning for 255 Alpha (0% transparency), 65/255 Red, 133/255 Green, and 201/255 Blue (result color : dark blue).
Handle Native Types
Handles can be many things, here's the full list :
Code:
type event extends handle
type player extends handle
type widget extends handle
[I]type unit extends widget
type destructable extends widget
type item extends widget[/I]
type ability extends handle
type buff extends ability
type force extends handle
type group extends handle
type trigger extends handle
type triggercondition extends handle
type triggeraction extends handle
type timer extends handle
type location extends handle
type region extends handle
type rect extends handle
type boolexpr extends handle
type sound extends handle
type unitpool extends handle
type itempool extends handle
type race extends handle
type alliancetype extends handle
type racepreference extends handle
type gamestate extends handle
type playerstate extends handle
type playergameresult extends handle
type unitstate extends handle
type aidifficulty extends handle
type eventid extends handle
type unittype extends handle
type gamespeed extends handle
type gamedifficulty extends handle
type gametype extends handle
type mapflag extends handle
type mapvisibility extends handle
type mapsetting extends handle
type mapdensity extends handle
type mapcontrol extends handle
type playerslotstate extends handle
type volumegroup extends handle
type camerafield extends handle
type camerasetup extends handle
type playercolor extends handle
type placement extends handle
type startlocprio extends handle
type raritycontrol extends handle
type blendmode extends handle
type texmapflags extends handle
type effect extends handle
type effecttype extends handle
type weathereffect extends handle
type terraindeformation extends handle
type fogstate extends handle
type fogmodifier extends handle
type dialog extends handle
type button extends handle
type quest extends handle
type questitem extends handle
type defeatcondition extends handle
type timerdialog extends handle
type leaderboard extends handle
type multiboard extends handle
type multiboarditem extends handle
type trackable extends handle
type gamecache extends handle
type version extends handle
type itemtype extends handle
type texttag extends handle
So it is :
Handle extends Event, Player, Widget, Unit, Destructable, Item, Ability, Buff, Force...... Version, Item-Type, and Text Tag. So there are 69 differant types of Handles.
Remember that a Widget (italic in the CODE section) can be only a unit, an item, and a destructable. And also, a Widget is a Handle, so handle should be be enough.
Global/Local Variable Declaration
There are 2 types of Variable Declaration :
- Global
- Local
Global is meaning that it can be used by any trigger, and its value can be overwrote over with an another trigger, whereas a local works only for a function.
A global is declared in that way :
Code:
globals
<type> <name>
endglobals
Remember you can't do that in World Editor unless you use a preprocessor, World Editor will give you an error while saving (Only the Variable Editor is able to create a variable via the Trigger Editor if you are using the simple World Editor). Here some examples of global declaration :
- An array variable unit called UnitArray
- A unit variable called Unit
- A handle variable called Handle
- A trigger variable called Trigger
Code:
globals
unit array UnitArray
unit Unit
handle Handle
trigger Trigger
endglobals
An array variable is a variable that is set differantly. It has 8192 possible indexes (setting the 8192st index will crash the game save) with index call whereas a non-array has only 1 index without index call.
Here some exemples of settings :
Code:
globals
unit array UnitArray
unit Unit = UnitArray[0]
handle Handle = Unit
trigger Trigger = CreateTrigger()
endglobals
We can't fit a value for UnitArray unless we use an index call (a loop should do it). There, Unit variable is set to UnitArray[0] (UnitArray[index], meaning UnitArray's first index, index being equal to the index given - 1), Handle is set to Unit (a handle can be a unit), and Trigger creates a trigger for itself (that does nothing).
Declaring a local is a bit the same, it only looks like :
Code:
local unit array UnitArray
local unit Unit = UnitArray[0]
local handle Handle = Unit
local trigger Trigger = CreateTrigger()
This is the old global declaration converted to our local declaration. Local Variables only work in a function, remember that.
Also, pre-defined variables (From Variable Editor) ever starts with the udg_ prefix, as said a lot before this.
Functions
A function is like that :
Code:
function funcname takes paramlist returns returntype
localdeclarations
statements
if not returntype = none then returns returnvalue
endfunction
Local Declarations can be found before this.
Paramater Lists are what type of paramaters the function takes.
Code:
function Ex takes unit u, integer i, returns nothing
endfunction
There, the function "Ex" takes a unit that will be called "u", and an integer called "i" in the function.
Return Type is what the function returns. As said in the funcname function, if the returntype is equal to none, it returns nothing, else it returns something in a return block :
Code:
function Ex takes unit u, integer i, returns unit
return u
endfunction
There, "u" and "i" are parameters, and "u" is returned.
Statements are functions, sets, or something that order the function to do something.
Example :
Code:
function Ex takes unit u, integer i, returns unit
if GetUnitUserData(u)==i
then return u
else return null
endif
endfunction
There, if "u's Custom Unit Value (Integer - Get Unit Custom Value) equal to "i", it returns the unit, else it returns null.
There are also constants function, like :
Code:
constant function funcname takes paramlist returns returntype
statements
if not returntype = none then returns returnvalue
endfunction
With that, you are not allowed to call non-constant functions in it, whereas you are able to use the set statement, so it isn't really a constant.
Set Statements
A statement is what a function does, there is only one statement per line (exception : if + then + (else) - /line break endif).
The most known statements are the set something to something :
Code:
set Variable = Expression
set Array_Variable[index] = Expression
The Expression returntype must be equal to the Variable to work, so does for the array variable. Also, an array variable without an index is illegal.
Code:
local <type> array Array_Variable[index] = Expression //legal
[COLOR="Red"] local <type> array Array_Variable = Expression //illegal[/COLOR]
The first one is legal, the second one is not legal.
So does if we try to use an Expression that do not match up the Variable type :
Code:
local unit array Array_Variable[0] = GetTriggerUnit() //legal
[COLOR="Red"] local integer array Array_Variable[0] = GetTriggerUnit() //illegal[/COLOR]
So that's simple to understand.
Call Statements
Call Statements are started with call, then a space, and after the name of the function (native or user-defined in map header). And then, you must put a "(", and after the arguments, each taken one by one seperated with a ",", and at end, closed with a ")".
Examples :
Code:
function Ex takes unit u, integer i, returns unit
if GetUnitUserData(u)==i
then return u
else return null
endif
endfunction
function Test takes unit u, integer i returns nothing
call Ex(u,i)
endfunction
There, the function Test takes 2 paramaters, u and i, and calls the function Ex with the same paramaters because the function Ex takes a unit and an integer.
In small example, it looks like :
Code:
function Test takes unit u, integer i returns nothing
call Ex(<unit>,<integer>)
endfunction
Remember, a function that takes nothing is called simply by :
Code:
call Func()
Loop Statements
Loops are something to avoid you to copy and paste a million of times, it does simply for you : For Each (Integer) X to Y, do actions between loop - endloop :
Code:
function Ex takes unit u, integer i, returns unit
if GetUnitUserData(u)==i
then return u
else return null
endif
endfunction
function Test takes unit u returns nothing
local integer i //=0
loop
exitwhen i==20
call Ex(u,i)
set i=i+1
endloop
endfunction
There, the function Test loops 20 times from 0 to 19, both included.
-> set i=0
-> call Ex(u,0)
-> set i=i+1=1
-> call Ex(u,1)
-> set i=i+1=2
-> call Ex(u,2)
-> set i=i+1=3
-> call Ex(u,3)
-> set i=i+1=4
...
-> call Ex(u,18)
-> set i=i+1=19
-> call Ex(u,19)
-> set i=i+1=20
-> exitwhen prediction true.
A loop without exitwhen prediction is legal. But it is then an infinite loop, no wait in will crash any computer that runs the function.
If-Then-(Else)-Endif Statements
There are 3 types of If-Then-(Else)-Endif Statements :
If-Then-Endif :
Code:
if <prediction> then <single statement>
<statements>
endif
If-Then-Else-Endif :
Code:
if <prediction> then <single statement>
<statements>
else
<statements>
endif
Else-If-Then :
Code:
else if <prediction> then <statement>
Each "if" predictions must return a boolean value. If it isn't returning that, it gives you a compile error while saving.
More will come later.


