JASS 101 Classroom

Status
Not open for further replies.
I

IKilledKEnny

Guest
Class Delay

It seems like I'm not going to make it for tommorow, I might, but the chances are low. If I won't make it for Tuwsday I hope to get it by Friday.

As allways I will Private Massage students and then classs in submitted.
 
I

IKilledKEnny

Guest
It seems like I would have to delay the class again. The class is done (I finished it 2 fays ago already) but my main computer's internet is playing "hard to get".

Sorry, I hope to fix it soon.
 

elmstfreddie

The Finglonger
Reaction score
203
Try it at school, I've learned that my school doesn't block thehelper!
I'm surprised too, because it seems everything else is blocked.
So, try going on here at school.
... Then again you'd need to email it wouldn't you lol
 

Miz

Administrator
Reaction score
424
... Class delays It has finally got around to me along time ago but I didn't have time to deal with it but w/e so if your internet doesn't work and you can't fix it what would you like me to do? get a sub? or something

If so and you can't get to your computer in like a week we will have to postpone the class or something rather

Like we need any more Pending classes

PM if you need something

I understand my WC3 disk is playing "Hard to Get" so if you here me CD it you work or your gone bitch!

Contact me if you want to be a sub! (Not just for this class)
 
I

IKilledKEnny

Guest
Greetings

Here we are in the third lesson, 5 to go when you know basic JASS. In the last lesson we discussed about commands, in general especially on commands that are triggered by “call”, in this lesson we will talk about locals, which are triggered by “local” and “set”.

The assignment in the previous class was:

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.

The best works were made by:

ertaboy356b
DrinkSlurm
Andrewgosu
Purgeandfire
Slywolf15

They all got 100/100 grade.

JASS:
 function assignment_2 takes nothing returns nothing
call SetPlayerState(Player(2),PLAYER_STATE_RESOURCE_GOLD,500) // Sets the player's gold to 500
call SetPlayerState(Player(2),PLAYER_STATE_RESOURCE_LUMBER,500) // Sets the player's lumber to 500
call SetPlayerAbilityAvailable(Player(2),'AHbz',false) // Disabled Blizzard for the player
call DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"This is a function regarding player 3") // This is a BJ but in order to make it native you need locals, which you don't know how to use yet. It shows a massage to all players
endfunction


This was enough to get perfect grade.

Lesson 3: Basic Locals
What are locals?
What is the difference between globals and locals?
Conclusion
Assignment

This is roughly the lesson plan, the lesson is divided into chapters to ease the reading process. I suggest you read everything, skipping over stuff if a bad idea because it can stop you from learning things later on.

As always if you don’t understand something after reading the lesson, you are free to ask.

What are Locals?

In this chapter we will discuss mostly the basics of locals, how they are used, created etc.

Locals are like normal variables (which are called globals), you can store inside them information for later use. For example this action:

Set VariableA = 1

Will result that every time we use VariableA as an argument it would return 1. Locals, like globals, are divided into different types, there are units, players, forces, groups, integers, reals, strings, effects and so on and so on. You can only store inside a variable value which match type. For example if we have a variable of type unit, we could not store inside it anything but unit. This is legal:

Set UnitVariable=GetTriggerUnit()

This is not:

Set UnitVariable=Player(0)

Because player is not a unit. When using locals we can also apply to them an array, or index. Indexes are used so:

Set VariableB[1]=0

Set VariableB[2]=3

VariableB[1] is not equal to VariableB[2]. Think about the index as a part of the variable’s name which can be modified using integers.

So we know what locals are, what indexes are and what valid values can be store inside certain locals. However the question is, how can we declare a local?

Code:
 [b]local[/b] [i]VariableType Variable_Name[/i] = Expression

Bolded text is a must have text which can’t be modified. Italic text is a much have but can be modified, and finally text which is neither bolded nor italic is optional.

Here is an example:

Code:
local unit Variable_C

This will create a local variable of type unit which is named Variable_C. Other examples:

Code:
local player Editor
local integer NumOfTrees
local real distance
local effect crush
etc.

Now, say we want to set a local, how will we do that? Simply write:

Code:
[b]set[/b] [i]VariableName[/i][b]=[/b][i]Expression[/i]

example:

Code:
set Editor=Player(0)
set Variable_C=GetSpellTargetUnit()
set NumOfTress=50
set distance=750.00
etc.

Now, say when we declare the local we know already what we want it to be. For example we want to declare an integer which will be return 5. The simplest way to do would be:

Code:
local integer ThisWillReturnFive
set ThisWillReturnFive=5

However there is a simpler way to do it, we get right a way set a local to it’s expression.

Code:
local integer ImEfficent=5

exactly the same thing, simply the second example requires one line less.

VERY IMPORTANT:: All locals must be declared at the beginning of the function. You can’t put a command before finishing creating all locals which will be used in the trigger. Not doing so we’ll result in script errors and your trigger will be disabled until you fix this.

Now, say you want to use a local as an argument, how would you do that? Well, it’s really simple, what you need to do is simply type down the local’s name in the correct place and the function will get the local’s value.

What is the difference between globals and locals?
In this chapter I will tell you what is the difference between global variables and local variables.

Let’s talk a little about globals, you can read this part briefly if you have knowledge of global variables already (only this part, the rest of the lesson may be still relevant to you). Globals are created in the variable window which can be opened pressing ctrl + b. There you could create a global and define a name and type to it. Once done, the variable could be used.

Now, what is the most common problem with globals (despite the fact that they are messy, hard to read, and take unneeded memory place) is that they overwrite themselves.

For example if you do this in one trigger:

Set GlobalInteger = 5

And then a second later in another trigger you do this:

Set GlobalInteger=7

GlobalInteger will be 7. In this case, you could simply use 2 different variables, however when trying to work with a trigger with waits and globals in it, it is not possible to do so, what will result that a trigger may be destroyed because of that.

That is why we can use locals, locals are created once a function runs, and they are made only for him, thus they do not interfere with each other. This means that not only locals are less messy and take less memory space, but they are also great tools for making long triggers, especially spells that involve waits.


However, we do face a problem when working with locals. As I said, locals are created for one function only and can't be referred to it through other ones. At the moment it isn't a huge problem to you because you are not doing things that are very advanced, however later on it may prove to be something that is very hard to deal with.

The most common solution to this matter are using either Vexorian's handle system or KaTTaNa's local handle system, both are systems that can store locals and transfer them to other functions.
I will not discuss those systems because they require advanced knowledge of JASS.

Last note before we move on. When you want to refer to a global variable in JASS script you must put:

udg_Variable_Name

Thus, the string "udg_" must come before a global's name. udg stands for user designed global.

Conclusion

So, in conclusion, locals are just like globals, simply they are created for one function and only that function can effect them. This is good because it helps us solve certain limits with regular variables, however it is bad because it makes the local transferring from function to function much harder although there are ways to solve it.

Assignment

Well, this is the end of this lesson (which was surprisingly short), for your "home work" you must create a function that gets inside local variables the triggering unit, the target unit of the spell and it's location as well the owners of both units. After that increase the gold value of the owner of the casting unit by 200, and reduce the owner of the target's gold by 200. Lastly move the caster to the target's location.
 

Attachments

  • JASS 101 Lesson 3.doc
    38 KB · Views: 289

Doom-Angel

Jass User (Just started using NewGen)
Reaction score
167
JASS:
 function assignment_2 takes nothing retursn nothing
call SetPlayerState(Player(2),PLAYER_STATE_RESOURCE_GOLD,500) // Sets the player\'s gold to 500
call SetPlayerState(Player(2),PLAYER_STATE_RESOURCE_LUMBER,500) // Sets the player\'s lumber to 500
call SetPlayerAbilityAvailable(Player(2),'AHbz',false) // Disabled Blizzard for the player
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,"This is a function regarding player 3") // This is a BJ but in order to make it native you need locals, which you don\'t know how to use yet. It shows a massage to all players
endfunction

u forgot a 'call'
 
I

IKilledKEnny

Guest
Nice Spotting, I'm soon going to updating this lesson to fix few other errors I missed.
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
JASS:
 function assignment_2 takes nothing <b>retursn</b> nothing
call SetPlayerState(Player(2),PLAYER_STATE_RESOURCE_GOLD,500) // Sets the player\&#039;s gold to 500
call SetPlayerState(Player(2),PLAYER_STATE_RESOURCE_LUMBER,500) // Sets the player\&#039;s lumber to 500
call SetPlayerAbilityAvailable(Player(2),&#039;AHbz&#039;,false) // Disabled Blizzard for the player
DisplayTextToForce(bj_FORCE_ALL_PLAYERS,&quot;This is a function regarding player 3&quot;) // This is a BJ but in order to make it native you need locals, which you don\&#039;t know how to use yet. It shows a massage to all players
endfunction

u forgot a 'call'

You also had a typo with "returns"... lol

Anyways, I might turn my work in real soon. Thank you for the reputation. ;)
 
R

robizeratul

Guest
Help PLs

hi...sry if this is not the good place to write this...but i don;tno where to do it:Can someone pls tell me where can i download the warctaft 3 frozen trone map editor?i would like to make a map,a readed alll the stuff from the site,but i don;t know where to get it,it was on the W3 CD but i lost it:banghead: :((

Thank For Your Help


Your Answer May Save Lives sooo:shades:
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
I don't think it can be downloaded... If you lost the CD, then it most likely won't work anyways. It comes with the Warcraft game, so as sad as it is, you must buy a new Warcraft.. :(

Unless you do something illegal. :rolleyes:
 
R

robizeratul

Guest
Thank YOu for you help,what illegel should i do?:shades: :shades: :shades: :shades: :shades: :shades:




jsut joking :))
but,can you help me with other W3 editors..if there exist pls?

Thank You
 

elmstfreddie

The Finglonger
Reaction score
203
Technically nothing you do to get it is illegal, since you bought and still own a copy of warcraft III TFT (even if you don't know where it is).
So, go ahead, download it from anywhere. Use utorrent, that's the best.
But, why did you post this in a random thread? Why not make a new thread o_O

But until you get it, take a looksie around thehelper and read up on tutorials n stuff :)
 

ertaboy356b

Old School Gamer
Reaction score
86
I thought GetSpellTargetUnit() was supposed to be 'Target Unit of Ability Being Cast'....... I was asking for the Casting Unit...

Is Casting Unit = GetSpellAbilityUnit() ???
 

elmstfreddie

The Finglonger
Reaction score
203
Just some confusion in my brain.
We went over that.
Caster is GetTriggerUnit() and target is
GetSpellTargetUnit()
I thought he wanted the target, not the caster at first :eek:
 
Status
Not open for further replies.
General chit-chat
Help Users
  • No one is chatting at the moment.
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • 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 Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top