JASS 101 Classroom

Status
Not open for further replies.
I

IKilledKEnny

Guest
> hey, is there a JASS editor that works on a mac? Or do I have to install virtual PC...

I'm not sure, why don't you try to ask who wrote it?

> could work directly on WE, but he said that wasn't a good option

But it's optional, I do that somtimes, especially now when I know how to avoid crushes, just be careful.
 

Hero

─║╣ero─
Reaction score
250
I think Grimore works with WE it's like a new WE with a built in jasscraft kinda
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
You keep saying "crushes". Do you mean crashes, or is there something else I should know about?

Yup, it is crashes. There isn't something else to know about.

@IKilledKEnny: I fixed mine and sent it through a PM. :D [Non-Leaking Assignment [Locals used]]
 

ertaboy356b

Old School Gamer
Reaction score
86
Is it really neessary to remove the leaks, because if it is, then I'll rewrite my triggers...
 

chovynz

We are all noobs! in different states of Noobism!
Reaction score
130
lol guys...just do the assignments. Don't do more than you're asked to. You'll only confuse yourselves. :)
 
I

IKilledKEnny

Guest
No need to clear leaks, I guess PurgeandFire learned JASS before joining the class.

As for curshes / crashes, thanks for letting me know I will fix that as soon as possible, however "word" didn't correct me and I'm sure I have seen it written like that few times, maybe "crush" is American and "crash" is English?
 

ertaboy356b

Old School Gamer
Reaction score
86
I already learned Jass before I joined this class so it means that I could do things leakless if necessary..
 

elmstfreddie

The Finglonger
Reaction score
203
Yo IKilledKenny, crush is a word too, however crash is the one you want to use. Crush means... Hmm, hard to describe... Kinda like destroying something, to crush something is to squish it and break it a lot.
 

Knocksious

Sweet, I got 2 little green bars!
Reaction score
46
the only JASS I learned was how to clear leaks, other than that, I am a clean slate :)
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
the only JASS I learned was how to clear leaks, other than that, I am a clean slate :)

Code:
function Knocksious takes nothing returns nothing
    local member Knocksious
    set Knocksious = leakclearer
    //Actions//
    set Knocksious = null

I, uh... Can... call functions! lol

Code:
function elmstfreddie takes nothing returns nothing
    local member elmstfreddie
    set elmstfreddie = functioncaller
    //Actions//
    set elmstfreddie = null
Jk... :rolleyes:

Is the next assignment going to be next week? :)

P.S. I, uh, know basic JASS! :D
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
Oh you **cker! I'm null now
*disappears*

Edit > Wait, I'm safe as no one calls it...

Do you mean that it wasn't called? If so, I did call it:
Code:
 set pooh = null
Is basically like
Code:
 call pooh = null
^But that would give you a syntax^

So.... be gone spawn of darkness!! MUAHA! :D
 

Squll2

je'ne sais pas
Reaction score
76
i guess i should post something just to let u know that im tuned in ^^ :p

well theres the post...
 

chovynz

We are all noobs! in different states of Noobism!
Reaction score
130
elmstfreddie said:
Oh you **cker! I'm null now
*disappears*

Edit > Wait, I'm safe as no one calls it...

I Call you and raise you $25. </spam>
 
I

IKilledKEnny

Guest
JASS 101: Basic Jass Classrom
Lesson 2: JASS Commands

Greetings

Hello again to all the students, this is our second class! In the first one we learned what JASS is, why would we want to use it, and how we can work with it efficiently. The assignment was:

Create a trigger in GUI that will create for player red (1) a unit of type footman in the middle of the map when a footman owned by him dies. After that convert it to JASS and add at least 5 random comments around the trigger. Assignment Challenge: If you want a bit of a challenge, try to find out what each of the JASS trigger’s lines do (or at least few of them) and say so using comments. This will need time, logic, and self teaching, however if you are determined you should be able to do this.

Note about the challenge: You need to find out lines that have 4 spaces before them(“ “) only, no need to know what the rest of the lines do.

The best works were made by:

Chovynz
PurgeandFire

They both made 100/100 assignments.

Code:
// This is the boolean part, it will return true or flase, depending if the lines in it a true or false.
function Trig_Assignment_Conditions takes nothing returns boolean
    if ( not ( GetUnitTypeId(GetTriggerUnit()) == 'hfoo' ) ) then // If the unit is a footman it will return true, else false.
        return false
    endif
    return true
endfunction

// This is action part, this will do the actions we commanded the trigger,
function Trig_Assignment_Actions takes nothing returns nothing
    call CreateNUnitsAtLoc( 1, 'hfoo', Player(0), GetRectCenter(GetPlayableMapRect()), bj_UNIT_FACING ) // This will create a footman for player red in the middle of the map.
endfunction

// This part will create the trigger and set it.
function InitTrig_Assignment takes nothing returns nothing
    set gg_trg_Assignment = CreateTrigger(  ) // Creates the trigger. Think of it as a global variable.
    call TriggerRegisterPlayerUnitEventSimple( gg_trg_Assignment, Player(0), EVENT_PLAYER_UNIT_DEATH ) // Adds the event which is a unit owned by red dies.
    call TriggerAddCondition( gg_trg_Assignment, Condition( function Trig_Assignment_Conditions ) ) // Set the condtion part as tje condition for this trigger.
    call TriggerAddAction( gg_trg_Assignment, function Trig_Assignment_Actions ) // Sets the action part as the action for this trigger.
endfunction

This was enough to get 100/100.

In this class we will learn about JASS commands, I will start by giving you some information about them, how to use them, and how to find out more about these.

Lesson 2: JASS Commands.
What are JASS commands?
How do we use them?
JASSCraft and commands
Conclusion
Assignment

This is roughly the lesson plan. The lesson is divided into chapters to ease the read; I suggest you don’t skip over parts because if you do, it might stop you from understanding stuff written later on. Also I suggest you understand the previous lesson fully before attempting to read this one. Enjoy your read.

Note: This chapter is much more challenging then the previous one, so don’t be frustrated if you don’t understand it, read it again and again until you do. Remember that you can always post questions!!

What are JASS Commands?

I will discuss in this chapter what JASS commands and give some general information about them.

This whole lesson is about JASS commands, but what are they? Well JASS commands are the actions, conditions and events of a trigger. Other name for JASS commands is native (or Blizzard JASS in some cases) functions; however I find “commands” a better word, especially when you don’t know a lot about JASS yet. When you do, there is a difference between Blizzard JASS (BJ) and natives. We will go over that.

When converting a GUI trigger into JASS (Check lesson 1 if you forgot already what does it mean when you import GUI to JASS!) the commands is everything that has 4 or more space before it (“ “), however there are few exceptions. For example here the commands are bolded.

Code:
function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
    [b]call CreateNUnitsAtLoc( 1, 'hfoo', Player(0), GetRectCenter(GetPlayableMapRect()), bj_UNIT_FACING )[b]
endfunction

//===========================================================================
function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
    [b]set gg_trg_Untitled_Trigger_001 = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( gg_trg_Untitled_Trigger_001, 5 )
    call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions )[/b]
endfunction

Other word to describe it is that commands are everything inside a function. To understand that we need to know what functions are, this topic will be discussed fully in lesson 5. Yet, I will go over it quickly.

A function declaration starts when we write “function” after that we define the function’s name, taking values and returning value. An example for that will be:

Code:
[b]function[/b] Trig_Untitled_Trigger_001_Actions takes nothing returns nothing

Once we had spotted the “function” (bolded) we know that a function has started. It will end when we fine the word “endfunction:. That being said, all lines between the function declaration line (presented above) and the “endfunction” line are commands.

Challenge 1: Find the commands in this function.

Code:
function Challenge_1 takes nothing returns nothing
    call PauseUnit(GetTriggerUnit(),true)
    call SetUnitMoveSpeed(GetTriggerUnit(),522)
endfunction



If you said that those lines:

Code:
 [b]   call PauseUnit(GetTriggerUnit(),true)
    call SetUnitMoveSpeed(GetTriggerUnit(),522) [/b]

Are the commands you are right indeed.

So we know 2 ways to spot commands, 1 every line that has 4 or more spaces before it (Use this ONLY when converting GUI to JASS), and a better way that always works is simply finding all the lines that are in functions the way using the way I just presented to you.

Challenge 2: Find the command in this function:

Code:
function Another_Challenge takes nothing returns nothing
if IsUnitDeadBJ(GetTriggerUnit())==true then
  call ReviveHero(GetTriggerUnit(),GetUnitLoc(GetTriggerUnit()),true)
  call SetHeroStr(GetTriggerUnit(),50,true)
endif
endfunction



This is a tougher challenge aye? Here I didn’t convert the trigger so there are only 0 or 2 spaces before each line. Yet, you don’t have to know anything but when does the function starts and ends, knowing that we can say that the commands are those:

Code:
[b]if IsUnitDeadBJ(GetTriggerUnit())==true then
  call ReviveHero(GetTriggerUnit(),GetUnitLoc(GetTriggerUnit()),true)
  call SetHeroStr(GetTriggerUnit(),50,true)
endif[/b]

Challenge 3: This is important so we need to go over it a lot of times, where are the commands here?

Code:
function Challenge_3_Func_1 takes nothing returns nothing
if IsUnitDeadBJ(GetTriggerUnit())==true then
  call ReviveHero(GetTriggerUnit(),GetUnitLoc(GetTriggerUnit()),true)
  call SetHeroStr(GetTriggerUnit(),50,true)
endif
endfunction

function Challenge_3_Func_2 takes nothing returns nothing
    call PauseUnit(GetTriggerUnit(),true)
    call SetUnitMoveSpeed(GetTriggerUnit(),522)
endfunction



Here we got to functions (the 2 already presented functions) how can we find out the commands when we got over one function? The exact same way!!

Code:
[b]if IsUnitDeadBJ(GetTriggerUnit())==true then
  call ReviveHero(GetTriggerUnit(),GetUnitLoc(GetTriggerUnit()),true)
  call SetHeroStr(GetTriggerUnit(),50,true)
endif
   call PauseUnit(GetTriggerUnit(),true)
    call SetUnitMoveSpeed(GetTriggerUnit(),522) [/b]

Those lines are the commands, even though we got 2 functions, we take all the lines that are in them, and those are the commands.

So you should understand this very clearly, if not, no reason to continue reading, re-read it if you need.

How do we use them?

I will explain in this chapter generally how you can work with commands, what are arguments and etc.

Ok, we got a clear definition of commands. Commands are the action / events / condition (and more) that can be found in GUI triggering. The best and easiest way to spot them would be simply checking if they are inside a function or not.

But the problem is how do we use them? Well then, let’s start. Each command takes something and returns something (something may be nothing). For example this action:

Code:
GetUnitUserData(GetTriggerUnit()) // GetUnitUserData is custom value of a unit and GetTriggerUnit() is triggering unit

Will take a unit and return an integer. This though:

Code:
call SetUnitPositionLoc(GetTriggerUnit,GetRectCenter(GetWorldBounds()) // SetUnitPostionLoc is “move unit (instantly)”, GetRectCenter(GetWorldBound()) is center of the map.

Will take unit and location but will return nothing. For more information about commands that take and return look at the chapter “JASSCraft and Commands”.

So commands take and return something (like functions, like it was briefly explained above), and indeed commands are functions, simply blizzard made ones.

However the question is how do we start a command? Well there are 3 types of commands.

Local (will not be discussed in this lesson)
Set (will not be discussed in this lesson)
Call (The lesson is about this kind of commands.)

Before each command line we put local, set or call (with few little exceptions). Let’s discuss “call”. “local” and “set” will be explained in the next lesson.

Before each command we need to put “call”, call means we are taking command as an event / condition / event. Once we put a “call” we will write down the command’s name (Critical side note: JASS is case sensitive, many codes can be ruined because of that, be careful when typing with JASS). After we typed the command name, we open brackets (type arguments here and then close them).

So it would look like so:

Code:
call CommandNameHere(The arguments)

This is very hard; we did a big jump from the last chapter so let’s summarize it: At the moment we are talking only about commands that are triggered by putting a call before them. Once you typed “call” you type the command name and arguments in brackets.

Now let’s try to understand what arguments are. Arguments are what our command needs to take. For example if we want to move a unit as shown in the above example, we need to give the function the unit and the location. (Again, to find out what arguments need to be passed and in what order check “JASSCraft and commands”) After they are given the command will be executed and will take the unit we passed to it, and will move it to the location. Now if you noticed I separated between the location and the unit with a comma.

Code:
 call SetUnitPositionLoc(GetTriggerUnit [b],[/b] GetRectCenter(GetWorldBounds())

When we pass several arguments to a command we separate them with a comma.

Now I want to go over quickly on “GetRectCenter(GetWorldBounds())” GetRectCenter is a command which gives the middle of a region (just like GUI), now, you agree with me that we need to give the GetRectCenter a region as an argument, so it would know what the center should be? Well then if you watch closely we do give it an argument, which is GetWorldBounds(), GetWorldBounds is the whole map, so what it would do it take the whole map give you the center of it. In other words:

SetUnitPositiocLoc takes unit and a location. The unit is triggering unit and the location Is GetRectCenter(GetWorldBounds()), GetRectCenter needs to take something as well so it takes GetWorldBounds(). Do you understand that? It’s important that you do.

So we understand that SetUnitPostionLoc needs to take a unit and a location, and the location we gave it also takes something, that an argument inside an argument. In theory you can pass do argument inside an argument inside an argument and so on with no limits.

Let’s Check GetTriggerUnit and GetWorldBounds, do you see that they have an empty () after them? Well the reason is simple, neither GetTriggerUnit nor GetWorldBounds need to take something, so leave the argument brackets empty. This is important, while we can give argument inside an argument inside an argument and etc., we must end up with an argument that takes nothing so we could end the chain.

So we understand what taking is, the command / argument takes something in order for it to run. We also understand what returning is, the return value is what the command returns, arguments must return somthing.

Challenge 4: With that information answer the following question: May I have inside a command an argument (any argument) which returns nothing?



The correct answer is no, argument must return something so the command could take them, it doesn’t make sense that in SetUnitPositionLoc you would give an argument that doesn’t returns location because then the SetUnitPositionLoc would not know where it should move the unit to. Same goes to the unit, you can’t give a unit argument which returns nothing because then SetUnitPositionLoc will not know what unit it should move.

So to sum it up: Commands called by “call” may take something (and may not). Argument can take something (and may not) but they have to return something so the command could read the returned value.

This is a very important chapter as well, you must understand it. Here are few challenges you should be able to answer them, or at least understand the answer.

Challenge 5: What does this argument takes and returns (what type)

GetRandomLocInRect(GetWorldBounds())

This argument takes a region (GetWorldBounds in this case, GetWorldBounds as I said doesn’t take anything but returns a region, so GetRandomLocInRect can read it) and returns a location.

Challenge 6: I want you to order the triggering unit to move (NOT instantly) to the center of the map. IssuePointOrderLoc takes unit, order string (type “move”) and then a location.

If you did this:

Code:
IssuePointOrderLoc(GetTriggerUnit(),”move”,GetRectCenter(GetWorldBounds())

You get 100 points, that exactly what you needed to do.

Well, assuming you understood this properly; let’s move on to the next chapter!

JASSCraft and Commands

I will explain how you can use JASSCraft (which is similar to JASS Shop Pro) efficiently so you could get information as much as possible about commands from it.

So we have came to the last chapter in this lesson, soon this one will be over too. Before we begin with it, I need to explain briefly was are BJs and natives, 2 out of 3 function types (the third one is user-defined functions).

Native functions are basic function of JASS, thus they are uneditable (unless you are editing WC3’s engine, which I doubt that you do) and the most basic triggering we can get to, everything in JASS works from those. 99% of the times you want to use a native if possible.

Now we are coming to the second type of functions which are BJs (Blizzard JASS), BJs are usually useless and do nothing but slowing triggers. BJs calls native, thus BJs are functions that call other function which are created into them. Why is that? Because Blizzard likes to make our life hard. Sometimes BJs do help, for example opening gate function is very long, and with BJ you can get it with only one line, however sometimes BJs do nothing but change order of arguments.

So to sum it up, native are the basic JASS triggers and you build JASS using them. BJs call a function which is made of natives (or other BJs in rare cases) and usually do nothing but slowing the trigger, however in rare cases they shorten the trigger and make it more readable. Natives > BJs, this is the ground rule.

So, say you want to find how new command would look like, why do you do? There are 2 options. The first is going to GUI, writing it and then converting, however this is a bad way to do it because usually you would receive a BJ function, which as I said, they are bad. The second better option is going to JASSCraft and in the searching tool typing a word that has something to do with what you want to do. Say you want to set Unit’s ability level? So you could search “set”, ”unit”, ”ability” or “level” and after few second you should find it. Also JASS has a certain “grammar” which you can pickup pretty quickly, soon you could more or less know what a command’s name will be if you know what you want it to do.

So say you found the command (which was “SetUnitAbilityLevel”, and it’s BJ “SetUnitAbilityLevelSwapped” does nothing but switching the unit and the ability argument location.) you want to know how to use it, right? Well click on it and the look down, there should be a box. You should see down there:

Code:
native SetUnitAbilityLevel takes unit whichUnit, integer abilcode, integer level returns integer

First of all notice it says “native” what means the function is good, it doesn’t call other functions but it’s the most basic way to do this action, so this is the fastest easiest way to do this. Now we want to know what it takes, right? Well just look, it written it takes unit, integer and another integer (in that order) and it even tells you what each take will be. The first take, unit, will define what unit the function will work on, the next take, integer abilcode needs to take the raw code of the ability, and lastly integer level needs to take the integer that it will set the ability level to.

So simple, right? With one simple click you can know about a command if it’s native or BJ, what it takes, in what order and what it returns. Isn’t that useful?

Now click on “SetUnitAbilityLevelSwapped”, you should see:

Code:
 function SetUnitAbilityLevelSwapped takes integer abilcode, unit whichUnit, integer level returns integer
    return SetUnitAbilityLevel(whichUnit, abilcode, level)
endfunction

No native! What does this mean? An BJ stacked his ugly head into this function. Look what it does, it’s so useless, what it does is instead of taking unit, integer, integer it takes integer, unit, integer. Why would we need that? We don’t!

So understanding that SetUnitAbilityLevel > SetUnitAbilityLevelSwapped. That’s generally how you can work with JASSCraft. It also got color coded text (depends what the text represent it will color it) and a double click will out in a picked command.

So let's go over a quick example on how we can get a working command from JASSCraft. Let's take "move unit (instantly)" command Look it up in JASSCraft what do you get?

Code:
native SetUnitPositionLoc  takes unit whichUnit, location whichLocation returns nothing

So let's go over it. native means only that is native, ignore that when typing the command. SetUnitPositionLoc is the name of the command. From now on it's arguments so, so far it should look like this:

Code:
call SetUnitPositionLoc

The call is to run the command, and "SetUnitPositionLoc" is the name, now the arguments. It takes a unit and a location, right? So:

Code:
call SetUnitPositionLoc(someunit,somelocation)

An example would be then:

Code:
 call SetUnitPositionLoc(GetTriggerUnit,GetRectCenter(GetWorldBounds())

Challenge 7: Give an example of this command which was found in JASSCraft.

Code:
 native AddHeroXP takes unit whichHero, integer xpToAdd,   boolean showEyeCandy returns nothing




Here is an example:

Code:
 call AddHeroXP(GetTriggerUnit(),500,false)

You can change GetTriggerUnit() to any other unit, 500 to any other integer and false to true.
Conclusion

So we learned commands are events / conditions / actions, we learned how you call them and use them, and lastly how does JASSCraft supports them

Assignments

This time the assignments are going to be a little tougher. I want you to make a trigger (100% in JASS) which will take play 3 (teal) disable the spell “Blizzard” for him, and set his gold and lumber to 500. After that is done display to all players the massage “this is a function regarding player 3” and add comments saying what each command does.

Good luck with it, you’ll need to think a little more on this one!!
 

Attachments

  • JASS 101 Lesson 2.doc
    57.5 KB · Views: 382

Omni

Ultra Cool Member
Reaction score
37
*reading lesson 2*
btw ikilledkenny jou might wanna change the link to the second lesson
when i clicked it on the first page i got the first lesson again :(
*back reading lesson 2*
 
Status
Not open for further replies.
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top