Jump to content

Recommended Posts

Posted

So You Want to Learn JASS?

 

A beginner’s helpful guide to the start of thinking about possibly wanting to learn JASS by emjlr3.

 

Requirements: Basic/ Advanced knowledge of the WE trigger editor, and some common sense.

A little Program called JASS Craft

 

Common Myths about JASS:

• GUI is better because it is easier

• JASS is better because it is more difficult

• GUI is easier than JASS: Probably if you want to make small stuff, but if you want to make big things (for example the main feature of your map) JASS is much easier cause it simplifies your code

• You can do everything in GUI: This might be true, but because you can make your own functions in JASS, it is generally much EASIER to make complex things in JASS than in GUI.

• You need to know GUI before learning JASS: It is actually easier to learn JASS without knowing GUI, generally to learn JASS you have to unlearn plenty of things you learned in GUI cause they pollute your mind. That's the reason people that got a lot of experience in GUI might find JASS to not be usable enough.

• You need to know programming to learn JASS: GUI is also a programming language. You can actually learn JASS at the same time you learn programming, and you can learn JASS alone, programming language will appear magically while you learn JASS.

• You need to know XXXX programming language to learn JASS: This is not true at all.

• A map is good because it wasn't made in JASS

• A map is good because it was made in JASS

• A map is good because it wasn't made in GUI

• A map is good because it was made in GUI

 

 

JASS Advantages:

If you use JASS directly instead of GUI you win:

• Functions: you can make your own functions and that will save you time

• Efficiency: Typing is faster than clicking with the mouse

• Ability to write more optimized code: GUI's automatization is not flexible enough to make well optimized code and it most of the times will generate really slow code.

• Local variables and multi instancibility : GUI is simply not good to make things multi player proof.

• Access to 'hidden' native functions : For some reasons GUI does not allow you to use a lot of functions like those related to memory leaks (you won't be able to fix a big quantity of memory leaks in GUI)

{Taken from Vexorians JASS info., http://www.wc3c.net/showthread.php?t=78946&highlight=JASS+GUI}

 

 

This problem seems to come up far too often recently, and me being the good big green samaritan that I am, decided to try and help all those in need of such a service, thus spawned the "So You Want to Learn JASS" tutorial.

 

This will not cover how to write effective JASS code, how to clean leaks, moving locals around, or any of that humbug, this is for those of you who think you want to start down the path of the dark side, and succumb to the evil that is JASS.

 

Let me start by saying this road is long and arduous, unless however you previously know a coding language, then it will be very easy, but for the rest of us, be prepared to be stumped, pissed, spat on, blinded….etc…

 

Anywho, many people do not know precisely where to begin in this sort of ordeal. So some begin by inserting some custom script into their GUI triggers, mainly for the use of locals. This, I feel, gives a false sense of some basic JASS knowledge. You are not really doing anything, and all you can really do by this, other then the obvious efficiency helper(which if this is your reason for doing so, why use GUI at all…just makes no sense), is to make non-MUI triggers MUI by using locals instead of globals. Yea this can be good and all, but barely even scratches the surface of why JASS is far superior to GUI triggering and severely limits the effectiveness of what you are doing.

 

So when you get past that phase, or when you hopefully read this first and never get started, let me begin by saying…good choice, alrighty now let us begin.

 

I must say the easiest way to learn JASS, I felt, was to create your trigger in GUI, and convert it to JASS, while keeping the original GUI trigger, you can compare the two. The lines are going to be in the same order(aside from your Booleans functions), so you can see what your GUI command translates to when converted. Let me show you an example:

 

Test One
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Animate Dead
    Actions
        Special Effect - Create a special effect at (Position of (Triggering unit)) using Abilities\Spells\Human\ThunderClap\ThunderClapCaster.mdl
        Unit - Explode (Triggering unit)
        Unit - Cause (Triggering unit) to damage circular area after 0.00 seconds of radius 500.00 at (Position of (Triggering unit)), dealing 100.00 damage of attack type Spells and damage type Normal

 

That is the GUI code for a spell, now here it is converted to custom script:

 

function Trig_Test_One_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'AUan' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Test_One_Actions takes nothing returns nothing
    call AddSpecialEffectLocBJ( GetUnitLoc(GetTriggerUnit()), "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl" )
    call ExplodeUnitBJ( GetTriggerUnit() )
    call UnitDamagePointLoc( GetTriggerUnit(), 0, 500, GetUnitLoc(GetTriggerUnit()), 100, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
endfunction

//===========================================================================
function InitTrig_Test_One takes nothing returns nothing
    set gg_trg_Test_One = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Test_One, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Test_One, Condition( function Trig_Test_One_Conditions ) )
    call TriggerAddAction( gg_trg_Test_One, function Trig_Test_One_Actions )
endfunction

 

Of course this looks like a bunch of gibberish to you, and rightfully so, it did to me at first as well, but the first step to success is to not get overwhelmed. How you ask? Well this is how, open our handy dandy program JASS Craft, and it basically does the work for us. Copy that code into JASS Craft, and viola, now it looks all pretty and is more legible.

 

Now let me explain just a little bit about how triggers works in JASS, so you can get a better understanding of the basic things you will see in most all JASS triggers. First off there are these things called functions. These hold the key to everything. Functions basically do things for you. The function at the bottom InitTrig_Test_One, this is called during the maps init( as are all of these in every trigger you create in the WE), and it does what is inside of the function. For each trigger in the trigger editor your map creates a global trigger variable for it. So what this is doing is creating a trigger with CreateTrigger() and setting your global trigger equal to it.

 

Every line there after, as like in all functions, are run in order. Now take a look and actually read all your calls, most people just look, shat themselves, and go run and hide in a corner, but not you, your reading my tut. and will fight this monster like the pussy cat it is. From here the rest is self explanatory. To the trigger you just created, you are adding an event, a condition function, and an action function. So when the event happens, the condition function is ran, if it returns true, then the action function is ran. Simple enough.

 

Now take a look at the condition function, it takes nothing and returns a Boolean. As you should know, a Boolean is either true or false. If it returns true, the actions are ran, so if GetSpellAbilityId() == 'AUan' then it will return true, else it will return false and nothing will happen. How do you know this, well it is quite simple. The event is a unit casting an ability, GetSpellAbilityId(), as you can look up in JASS Craft returns an integer, the id of the ability cast from the event that happened. You compare it to the ability id you want your actions to happen with, and viola. Something to remember, integers like this always need ‘ ‘ around them, and strings always need “ “ around them.

 

So if our ability is cast, then our condition function returns true, and our action function is ran, so let’s take a look at it. Again, just take a look at the calls, they are usually self explanatory. We are first creating an effect:

 

call AddSpecialEffectLocBJ( GetUnitLoc(GetTriggerUnit()), "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl" )

 

What are all those damn parenthesis and what not you ask? Well they are just this, AddSpecialEffectLocBJ, just like your action function, is another function that you are “calling” to do something for you, a quick search in JASS Craft tells us that.

 

function AddSpecialEffectLocBJ takes location where, string modelName returns effect
    set bj_lastCreatedEffect = AddSpecialEffectLoc(modelName, where)
    return bj_lastCreatedEffect
endfunction

 

It takes a location and a string, and returns an effect. Functions can take things and return things, just like our condition function returns a Boolean. This takes the location where, and the string modelname, and returns the effect that is created. If we take a look back at our GUI trigger, you can see this in it as well:

 

Special Effect - Create a special effect at (Position of (Triggering unit)) using Abilities\Spells\Human\ThunderClap\ThunderClapCaster.mdl

 

Create a special effect at a location, using the model thunderclap, wow that looks very similar to our custom script call now doesn’t it?

 

 

Take a look at the rest of our actions functions the same way. Look at what it actually says, and that can give you an idea of what it is doing. Then compare it to the GUI trigger, and you can see that things are not so different.

 

Now our JASS trigger is MUI without locals, but how would we use locals for it?? Well lets see:

 

function Trig_Test_One_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'AUan' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Test_One_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local location l = GetUnitLoc(u)
    call AddSpecialEffectLocBJ( l "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl" )
    call ExplodeUnitBJ( u )
    call UnitDamagePointLoc( u 0, 500, l, 100, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
endfunction

//===========================================================================
function InitTrig_Test_One takes nothing returns nothing
    set gg_trg_Test_One = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Test_One, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Test_One, Condition( function Trig_Test_One_Conditions ) )
    call TriggerAddAction( gg_trg_Test_One, function Trig_Test_One_Actions )
endfunction

 

Locals must be at least established at the beginning of the function they are used in, and can only be used in the function that they are created, but can be set whenever. As you can see, I create a local unit with “local unit u” and set it equal to the GetTriggerUnit(), or the caster of the ability, I also get his position and set that to a local variable l. I use those in place of what they refer to.

 

This is the very basics of understanding JASS and beginning to learn it. Actually, I am not so sure I would call it learning it, if you know GUI, you know JASS, you just do not have the custom script memorized that the GUI call refers to. No one does, not me that is for sure, which is where JASS Craft comes in. It knows all of them, so you do not have to. It also tells you what the take and what they return. I never code in the WE and I suggest you do not either.

 

Now that you can begin learning JASS, I suggest you start by taking simple GUI triggers, like the one I had above, converting them to custom script, and just delving into them, making sure you understand it, and making yourself familiar with not only the structure, but also the functions. Like I said above, you don’t need to know all the functions, but knowing as many as you can helps you code faster, I mean, looking up everything you need to know can become quite lengthy.

 

Once you have done this, try using locals instead of globals in your triggers, and go from there. I highly suggest you try reading some if not all of the JASS tutorials around the site you can find, more then once even if you are a little unsure of yourself, for they will help you become a lot more familiar with all the in and outs.

 

Another suggestion I can make is if you are not sure of something in JASS to search for it in JASS Craft, or find it faster do get certain things from GUI, just write it and convert it.

 

From here on out it is just time on your side that can help. The more your practice, the more you will know, and the better you will get. In anycase, good luck, and happy JASSing.

V 1.00

 

Thanks to emjlr3 for this guide/tutorial!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Posts

    • Hi everyone,   I'm looking for someone to create a website for me with a pale, whitish design, inspired by Talking Island. I also need an auto-updater and a Discord logo included.   I already have the domain and hosting set up on OVH, with PHP ready to go. However, I'm new to website development, so you may need to guide me through the installation process.   Please do not contact me if you're charging unreasonable prices like $800 for "VIP" packages — I'm looking for fair and realistic offers. Payment will be made once the job is completed.   If you have previous work to show, that's definitely a plus. The website, auto-updater, and Discord elements should all be in English.   Thanks!
    • Make your own topic. Don’t be so rude and post in mine just to sell your stuff 😉   @Celestine
    • Server Client: Server is running on custom Classic Interlude Client. Enjoy the innovations that classic offers to players while maintaining the stability of Interlude features that we all loved.   Birth of a new character A new character spawns in the basement of Ivory Tower. There, you can buff yourself  via AIO buffer and then teleport to a low level zone for xp. A new character starts  with full no grade gear and a newbie supply box. AIO npc Buffer There are AIO npc Buffers spawned in every town. The buffs’ duration is 1hour and  are free of charge. The only buffs that are not included in the list are summoner’s  buffs, third class dances, third class songs, and resists.    Class transfer When you hit level  20, 40 and 76, you can seek for the Class Changer Carola in Aden  or Castle Town  in order to perform your 1st , 2nd  and 3rd class change or simply use the .menu feature located in your character skills list. There are no further quests required. Boosted Buffers and Summoners In order to boost Prophets, Bladedancers and Swordsingers for PvP action and  Olympiad games, they have been given special self-buffs. All of these classes are  gifted with higher level buffs which they can be casted on themselves only. Also,  summoner classes are boosted since they can buff their pets with more than usual  servitor’s buffs  There are 4 main custom shops in the server where you can buy the following items: 1) Harvana (Misc Shop): Consumables 2) Albert (Weapon Shop): D, C, B and A grade weapons 3) Meredion (Armor Shop): D, C and B grade armor and jewels 4) Wilbrand (Mantra Manager): A/S armor, S grade weapons and more  Event Shop Event Shop Dianne can either be found in Aden Castle Town or Giran. You  can buy several useful items in exchange for Vote Coins or Event Medals.  Via  Event Shop Dianne you can have access to the following items: 1) Blessed Enchants 2) Books of Giants 3) Common and Custom Accessories 4)Raidbombs  and many more  Weapons’ Special Abilities The Special Abilities (SA) for every C, B and A grade weapons can be bestowed by  Mantra Manager Wilbrand in exchange for some animal bones, water mantras or wind  mantras respectively.    Rebirth System When you reach level 76, you can perform your first rebirth via Rebirth Manager.  Once you perform a rebirth, your character will be deleveled to level 40 and you will  obtain a book of rebirth. You can exchange the book of rebirth for a unique accesories  via Rebirth Manager. A character can have 3 rebirths maximum. Remember once  you have chosen your  rebirth skills, you can anytime change your mind and choose  your rebirths once again.  Noblesse system Once you have performed 3 rebirths, you need to collect a set of four crowns from the  following Raid Bosses: 1) Death Lord Hallate (Black Crown) 2) Kernon (Gold Crown) 3) Longhorn Golkonda (Red Crown) 4) Shilen’s Messenger Cabrio (Silver Crown)  Once you’ve collected all the crowns and your character is at level 76, you can talk to  the Noblesse Manager Eddy Wally, located in Aden Castle Town and become a Noblesse. Crown Raids Bosses’ respawn time is every 12 (±2) hours and have 1 spot Spawn spot: Giants Cave Unique L2Halcyon weapons and shields L2Halcyon weapons are S grade weapons with a unique SA. There are also three unique  L2Halcyon shields. Both of them can be dropped only by Raid Bosses. Remember you  can check the possible drops of any Raid Boss by pressing Shift+left click. Find  bellow more details regarding L2Halcyon items. Duals Crokian blade*Crokian blade: Increases Critical Attack by 95 and Accuracy by 6 Doll knife*Doll knife <-Daggers: Increases Atk. speed by 7% and Accuracy by 6 Swords Crokian Blade: Increases Atk. speed by 7% and Accuracy by 6 Sword of Apostle: Increases Accuracy by 6 and maximum HP by 25% Mage weapons Lady’s Fan: Increases Casting Spd. by 17.5% Dusk Staff: Increases Casting Spd. by 17.5% Dusk Sword: Increases M. Atk. by 15% Polearms Dreadbane: 360° hit rate, increases hit number from 4 to 8 and Accuracy by 6 Axe of Ketra: Increases Accuracy by 6 and P. Atk. by 265 during a critical attack Daggers Doll Knife: Increases Critical Attack by 95 and P. Atk. by 265 during a critical attack Giant Trident: Increases Evasion by 3 and P. Atk. by 265 during a critical attack 2-Handed Sword Sword of Vampire: Increases Critical Attack by 95 and maximum HP by 25% Blunt Cudgel: Increases Critical Attack by 95 and Atk. speed by 7% Bow Bow of Halisha: Increases Critical Attack by 95 and Accuracy by 6 Shields Shield of Reflect: Reflect magic debuffs and shield damage reflect Shield of Evasion: No evasion penalty and Speed +7 Dusk Shield: Bow resistance  Ancient L2Halcyon weapons Ancient L2Halcyon weapons can be obtained through refining the normal ones.  Unique L2Halcyon Jewels L2Halcyon Jewels are S grade Jewels which provide unique bonuses. They can be  dropped by specific Raid Bosses. Remember you can check the possible drops of any  Raid Boss by pressing Shift+left click. Find bellow the bonuses of L2Halcyon Jewels: -Earring of Garacsia: MP +31, +10% bow resistance and +7 speed -Earring of Ipos: MP +31, +10% dagger resistance and +7 speed -Earring of Kandra: MP +31, +20% wind resistance and +7 speed -Earring of Von Helman: MP +31, +20% dark resistance and +7 speed -Earring of Vermilion: MP +31, +20% fire resistance and +7 speed -Earring of Falston: MP +31, +20% water resistance and +7 speed -Ring of Horuth: MP +21 and +10% P.Def. -Ring of Mos: MP +21 and +10% M.Def. -Ring of Shadith: MP +21 and 500% HP regen -Ring of Tayr: MP +21 and +100 Bow Range -Necklace of Hekaton: MP +42 and +15% max CP -Necklace of Brakki: MP +42 and +60% resistance to most of the debuffs -Necklace of Naga: MP +42 and +15% max HP   Refining S grade armors/jewels Any S grade armor can be refined via Mantra Manager Wilbrand. S grade armors and  Tateossian jewels start at 55% and they can both be upgraded all the way up to 100%  in order to gain extra P.def or M.def. Once your armor reach 100%, you can transform  it into Apella and gain extra stats (Jewels cannot be further refined). In addition,  Apella armors start at 55% and can be upgraded up to 100% too. Then, you can  transform your Apella into Dynasty Armor or Ancient Apella depends on your preference (which can also be refined up to 100%).  Refining Epic Jewels (Core and Orfen) There is an option to refine Ring of Core and Earring of Orfen via Mantra Manager Wilbert. If you have two  Rings of Core, you can combine them and receive an  Enchanted Ring of Core. Then, you can combine two  Enchanted Rings of Core in order to create a Refined  Ring of Core (4 Rings of Core in total). The same  procedure can be applied to Earring of Orfen, in order  to create Enchanted Earring of Orfen or Refined  Earring of Orfen. In this case, the enchantment of the ring/earring will be reset, so do not enchant those epic jewels before refining.    Events: Korean TvT Squash Event Watermelon Event Raidboss Event Highrate    Features List is not the final and changes/additions can be made! Join us and say your ideas! WEBSITE: L2Halcyon Join our discord server for more information about the server development and also join access early to test features, and get a glimpse on what we are working on. Discord Server 
    • https://l2halcyon.com join discord server , you can actually get access to test. Classic Interlude.
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock