| 02-24-2007, 01:44 AM | #1 |
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 |
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: JASS:constant function Unit_Id_Checker takes nothing returns integer return 'h000' endfunction |
| 02-24-2007, 01:59 AM | #3 |
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 |
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 | |
Quote:
Untrue. Constant functions can return different values. Example: 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 | |
Quote:
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 | |||
Quote:
Constant Functions are just easier to see for the eye, that's all. http://www.thehelper.net/forums/show...light=constant Quote:
|
| 02-25-2007, 07:00 AM | #8 | |
Quote:
|
| 02-25-2007, 10:45 AM | #9 |
@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 |
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: JASS:constant function Spell_Damage takes nothing returns real return 300.00 endfunction |
| 02-25-2007, 10:57 AM | #11 |
I think I'm getting it somehow lol, how about this script JASS:constant function Unit_Id_Checker takes nothing returns integer return 'h000' endfunction Thanks again pyro you've been a great help! ![]() |
| 02-25-2007, 11:02 AM | #12 |
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 | |
Quote:
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 |
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 | |
Quote:
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 |
