HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

About Ability Jass Codes

02-24-2007, 01:44 AM#1
chobibo
I'm wondering if the skills that blizzard made have jass codes and if it does can someone tell me how to access them, also if anyone can explain briefly what a constant function is? Thanks.
02-24-2007, 01:51 AM#2
Pyrogasm
Every ability has a "JASS code", though that's not the real term for it. You can access them by pressing Control+D in the object editor. You'll see things like "Athb" and "Aloc", etc. Those are the ability rawcodes. If used in JASS, they must be between apostrophies (these: ' ), else your WE will crash when saving.

As for a constant function, it is a function that never changes throughout the course of the map. They may return a value, but don't generally take anything. They're mainly used for configuration sections of spells/systems. Example:
Collapse JASS:
constant function Unit_Id_Checker takes nothing returns integer
    return 'h000'
endfunction
The value that's returned is constant; it will always be 'h000' no matter what. No variables affect it, and the only thing that may change it is if a person were to change the value manually in the WE outside of a game.
02-24-2007, 01:59 AM#3
Av3n
crt+d in the object editor is the JASS name of the abiltiy and Pyro's way of how to do it is one of the best way

-Av3n
02-24-2007, 05:21 PM#4
chobibo
Thanks for answering guys but i think i used the wrong term in my first question, what i wanted to know was if blizzard use jass scripts to make, for example, the storm bolt spell. I am a bit aware that its rawcode is used to refer it in jass scripting. And about the constant functions, I still think i need to read more source codes to figure them out but thanks for the jumpstart! Thanks guys I'll add a rep point for you.
02-24-2007, 07:41 PM#5
The)TideHunter(
Quote:
Originally Posted by Pyrogasm
As for a constant function, it is a function that never changes throughout the course of the map. They may return a value, but don't generally take anything. They're mainly used for configuration sections of spells/systems. Example:
Collapse JASS:
constant function Unit_Id_Checker takes nothing returns integer
    return 'h000'
endfunction
The value that's returned is constant; it will always be 'h000' no matter what. No variables affect it, and the only thing that may change it is if a person were to change the value manually in the WE outside of a game.

Untrue.

Constant functions can return different values.

Example:

Collapse JASS:
constant function ReturnInt takes integer i returns integer
    return i*5
endfunction

function Test takes nothing returns nothing
    local integer 1 = ReturnInt(1)
    local integer 2 = ReturnInt(2)
endfunction

Although, constants don't really do much, i think i remember hearing it dosent increase speed or its not calculated at startup, its just the constant is a syntax keyword, with no actual meaning.

Oh, and about the Spells like stormbolt, i don't think they did use Jass, they might have used C or C++, because it is hardcoded into wc3, and wc3 is made of C or C++, so why use a artifical langauge that runs off C or C++, would just be like wrapper functions. But some spells require things that Jass doesnt have, (or has because of storage methods), and some hardcoded things that spells use that Jass dosent have, like stunning a unit (yes we use a dummy unit and all, i seriously doubt blizzard spells do).
02-25-2007, 05:23 AM#6
chobibo
Quote:
Untrue.

Constant functions can return different values.
So they act like normal functions do(?), Do they have unique uses?

And about the spells, thanks for telling me that I was really thinking hard how they did those spells in jass lol, you guys are the best + rep 4 The)TideHunter(. Again , Thanks.
02-25-2007, 06:52 AM#7
Chocobo
Quote:
Originally Posted by chobibo
So they act like normal functions do(?), Do they have unique uses?

And about the spells, thanks for telling me that I was really thinking hard how they did those spells in jass lol, you guys are the best + rep 4 The)TideHunter(. Again , Thanks.

Constant Functions are just easier to see for the eye, that's all.

http://www.thehelper.net/forums/show...light=constant

Quote:
Quote:
Originally Posted by substance;417851
DAMN YOU JAAASSS!

Well thanks for the offer chovynz, but I like knowing HOW my spells work and I cant really do that in JASS. If all else fails though, it may come down to using someone else's shit 8[

btw who is 'we'? I've been thinking about joining a project to get some more experience with veteran mappers.

You can use //<some text> to give information about something, like :

Collapse JASS:
function Chocobo takes nothing returns integer
    returns 'A001' //call Chocobo() returns 'A001' as integer unittype
endfunction

Very simple. Also, constant functions are for easier read, to be "Inlighned", if I get the good word :

Collapse JASS:
constant function Chocobo takes nothing returns integer
    returns 'A001' //call Chocobo() returns 'A001' as integer unittype
endfunction

function Chocobo2 takes nothing returns integer
    local array integer i //declares a local array of type integer called i
    local integer loop //declares a local integer called i
    loop //starts the loop from there
        exitwhen loop == 8191 //loops end when i equal to 8191
        set i[loop] = Chocobo() //sets i[loop] to Chocobo() return type
    endloop //unallows to loop after this
endfunction
02-25-2007, 07:00 AM#8
Pyrogasm
Quote:
Originally Posted by Chocobo
Constant Functions are just easier to see for the eye, that's all.
Really? So telling someone to optimize their code by using constant functions is, well, pointless?
02-25-2007, 10:45 AM#9
chobibo
@Chocobo: I don't want to be disrespectful, but in my opinion constant functions have another unique use aside from making it easier to view codes. Thanks for answering!
@pyro: DO constant functions get used on naming rawcodes? also certain functions for spells. I've seen this is done in Daelin's Hero(Scarlet Crusader) ablity jass scripts.

I think I need to stop asking now and try to learn more about jass for myself : )
Thanks for everyone that helped.
02-25-2007, 10:48 AM#10
Pyrogasm
Generally constant functions are used in configuration sections of spells and systems. If, for instance, you want the amount of damage an ability does per level configurable, you're likely to see this:
Collapse JASS:
constant function Spell_Damage takes nothing returns real
    return 300.00
endfunction
02-25-2007, 10:57 AM#11
chobibo
I think I'm getting it somehow lol, how about this script
Collapse JASS:
constant function Unit_Id_Checker takes nothing returns integer
    return 'h000'
endfunction
Is this like making a rawcode for a custom spell?
Thanks again pyro you've been a great help!
02-25-2007, 11:02 AM#12
Rising_Dusk
Constant functions are indeed faster than normal functions.
The only requirement for them is that you cannot call any other natives or functions inside of them.
You can still do most of the basic math calculations.

The reason for telling someone to use them is not because of speed, however.
It's because in configuring a spell submitted at a site (Like you know, here) to be used in a new map, you want it to be as easy a process as possible.

It's much more convenient to look at the top of the code, change a few constants, and import into your map than it is to have to weed out all of the instances of X and replace them manually in the code itself.
Sure, that's what we have find and replace for in the coding programs, but we as the makers of the spell can't require the user use more than they need to.
It's more convenience than anything else.

It's also great for stuff you don't like having to memorize.
Like in my maps, I always use constants for generic dummy units.
02-25-2007, 11:02 AM#13
Chocobo
Quote:
Originally Posted by Pyrogasm
Really? So telling someone to optimize their code by using constant functions is, well, pointless?

If they are at the top xD

Because they "almost" return something that can be modified, to be easier to be seen (easier to view because it's at the top), like inlightned functions.
02-25-2007, 11:05 AM#14
Captain Griffen
Constant functions have the same byte code as normal functions, according to PipeDream, so work in exactly the same way. However, they won't compile if they use non-constant functions.

The main use is inlining with Vex's optimiser, which can make it much faster by saving a function call (doesn't always, as if the parameters aren't assigned to variables, it may create more function calls).
02-25-2007, 11:13 AM#15
Pyrogasm
Quote:
Originally Posted by chobibo
I think I'm getting it somehow lol, how about this script
Collapse JASS:
constant function Unit_Id_Checker takes nothing returns integer
    return 'h000'
endfunction
Is this like making a rawcode for a custom spell?
You're not making a rawcode for anything. What you're doing is creating a function that, when called, returns 'h000'. That's it. In application, the above function would be used in something like this:
Collapse JASS:
constant function Unit_Id_Checker takes nothing returns integer
    return 'h000'
endfunction

function Some_Function takes nothing returns nothing
    local group G = GetUnitsInRectMatching(GetPlayableMapRect(), Condition(GetUnitTypeId(GetFilterUnit()) == Unit_Id_Checker()))
    //Do something with G
    call DestroyGroup(G)
    set G = null
endfunction

function Some_Other_Function takes nothing returns nothing
    local unit U
    if GetUnitTypeId(U) != Unit_Id_Checker() then
        call KillUnit(U)
    endif
    set U = null
endfunction
Where something has to be referenced multiple times, and you make a constant function for sake of convenience.