1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. Travel to distant realms and encounter scenes unknown to the common folk. The Greatest of Adventures is upon us with the 8th Cinematic Contest. Join in on a fun ride.
    Dismiss Notice
  4. The 18th Icon Contest is ON! Choose any ingame unit and give him/her Hero abilities. Good luck to all.
    Dismiss Notice
  5. The Secrets of Warcraft 3 have revealed interesting works. The RESULTS for Abelhawk's Mini-Mapping Contest #15 have come out!
    Dismiss Notice
  6. Contestants are to create a scene set in the Stone Age. Come and see what you can come up with. We wish you the best of luck!
    Dismiss Notice
  7. Colour outside the lines! Techtree Contest #13 is a go. The contest is optionally paired.
    Dismiss Notice
  8. Night Rider gained several songs for his journey. The poll for the 12th Music Contest has started. Check it out!
    Dismiss Notice
  9. Greetings cerebrates, our Swarm needs new spawners that will have numerous children. Join the HIVE's 31st Modeling Contest - Spawners and Spawned! The contest is optionally paired.
    Dismiss Notice
  10. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Beginning JASS Tutorial Series

Discussion in 'JASS/AI Scripts Tutorials' started by wyrmlord, Feb 16, 2007.

  1. Sonya

    Sonya

    Joined:
    Aug 23, 2007
    Messages:
    1
    Resources:
    0
    Resources:
    0
    ........omg:confused:, i swear I'm mentally f'in handy caped when it comes to this shit. It took me forever on my own to learn Gui and i still haven't completely mastered it, hell some might still consider me noob. Anyway i think this is an amazing tutorial just wish i could understand it..:cry: I need like Jass for dummies or sumthin.:xxd: Iv found that jass probably isn't so hard if ur a fluent typer... or in my case it wold be easy if i could spell worth a shit...:hohum: but 5/5 i can tell u know what ur talking about!! kudos:thumbs_up:
     
  2. Herman

    Herman

    Joined:
    Aug 20, 2007
    Messages:
    877
    Resources:
    0
    Resources:
    0
    Don't worry too much, thats how it is for all beginnings, as long as you are interested in it, it will come

    *Please Mods don't remove my head* - There is a clan-type of site that is really a small one, but it was made by new(b) people, and ment for new(b) people, you can check it out for recent tutorials that are pretty much ground-level (search on google, [zetaboards synthetic corporations] )
     
  3. shift4101

    shift4101

    Joined:
    Aug 8, 2008
    Messages:
    17
    Resources:
    0
    Resources:
    0
    This is probabally the most noobish question ever, but what are the spaces between "call" and the start of the line? Everytime i try to re-enable the trigger it says it requires a name..:cry:
     
  4. Dark Hunter1357

    Dark Hunter1357

    Joined:
    Feb 20, 2007
    Messages:
    777
    Resources:
    29
    Models:
    20
    Icons:
    6
    Maps:
    2
    Tutorials:
    1
    Resources:
    29
    after "call" there is one space (one press of the spacebar button on your keyboard-" ")
    Post your trigger.
     
  5. Kwah

    Kwah

    Joined:
    May 9, 2007
    Messages:
    3,391
    Resources:
    8
    Icons:
    5
    Maps:
    1
    Tutorials:
    2
    Resources:
    8
    Well, I'm finally really starting to learn JASS, I have toyed with the idea for a while, but never got around to it.

    So, here I am. I was wondering about the reccomended tools. SO, far JNG and JassCraft are what I have, and wondering if I should get more.

    Well, here goes.
     
  6. Herman

    Herman

    Joined:
    Aug 20, 2007
    Messages:
    877
    Resources:
    0
    Resources:
    0
    Yeah, the JNGP is an awesome tool for when you really get started

    For begginning, I recommend JassCraft, it helps you get a deep understanding of handles, leaks, functions, etc.

    I don't highly recommend JNGP until you get pretty decent at regular JASS, JNGP in my eyes is just a ridiculously great tool for writing code very fast

    EDIT - And vJASS isn't hard to learn, only regular JASS is, if you don't understand things in regular JASS, obviously they won't be clear in vJASS.

    Aside from that, I feel those are the only two tools your ever gonna need.

    Btw, if you have any questions I could probably help answer them
     
  7. Sam Panda

    Sam Panda

    Joined:
    Jan 6, 2008
    Messages:
    25
    Resources:
    0
    Resources:
    0
    Please help! I'm having some very aggravating problems when trying to add special effects to the spell.

    First, heres my trigger code without the effects:

    Code (vJASS):
    function Slash_Condition takes nothing returns boolean
     return GetSpellAbilityId() == 'A000'
    endfunction

    function Slash_Actions takes nothing returns nothing
     local unit caster = GetSpellAbilityUnit()
     local location start_position = GetUnitLoc(caster)
     local group enemies = CreateGroup()
     local unit temp
     local integer count = 5
     local location temp_loc
      call GroupEnumUnitsInRangeOfLoc(enemies, start_position, 500.0, null)
      loop
       set temp = FirstOfGroup(enemies)
       exitwhen temp == null or count == 0
       if IsUnitEnemy(temp, GetOwningPlayer(caster)) and IsUnitAliveBJ(temp) then
        set temp_loc = GetUnitLoc(temp)
        call SetUnitPositionLoc(caster, temp_loc)
        call UnitDamageTarget(caster, temp, 50, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, ConvertWeaponType(8))
        set count = count - 1
        call TriggerSleepAction (0.1)
       endif
       call GroupRemoveUnit(enemies,temp)
      endloop
      call SetUnitPositionLoc(caster, start_position)
      call RemoveLocation(start_position)
      call RemoveLocation(temp_loc)
      call DestroyGroup(enemies)
     set temp = null
     set caster = null
     set enemies = null
     set start_position = null
     set temp_loc = null
    endfunction


    function InitTrig_Slash takes nothing returns nothing
     set gg_trg_Slash = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(gg_trg_Slash, EVENT_PLAYER_UNIT_SPELL_EFFECT)
        call TriggerAddCondition(gg_trg_Slash, Condition(function Slash_Condition))
        call TriggerAddAction(gg_trg_Slash, function Slash_Actions)
    endfunction


    It works totally fine and everything this way.



    I made several attempts to get special effects working, all of which had some kind of error or crashed when I saved. Here is one attempt.

    Code (vJASS):

    function Slash_Actions takes nothing returns nothing
     local unit caster = GetSpellAbilityUnit()
     local location start_position = GetUnitLoc(caster)
     local group enemies = CreateGroup()
     local unit temp
     local integer count = 5
     local location temp_loc
     local effect specialEffect
      call GroupEnumUnitsInRangeOfLoc(enemies, start_position, 500.0, null)
      set specialEffect = AddSpecialEffectLoc("Abilities\\Spells\\NightElf\Blink\\BlinkTarget.mdl", start_position)


    That one causes a compile error on the line that has
    set specialEffect = AddSpecialEffectLoc("Abilities\\Spells\\NightElf\Blink\\BlinkTarget.mdl", start_position)

    The compile error is that it Expected a valid arguement list.



    Preferably what I'd like it to do is play a special effect on the Hero when he casts it, and on the temp unit when he smacks it, could someone please tell me how to get these working? >.<
     
  8. Cheezeman

    Cheezeman

    Joined:
    Aug 19, 2008
    Messages:
    437
    Resources:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    2
    WTF Dude?

    WTF Dude? :eekani:
    I thought this would be an upload of a nice tutorial for JASS Editing, but I can't get anything to work!
    Let me quote you:

    Now, I've gone over with you a very basic example of JASS, if you wish to test this function in the World Editor, simply:
    -Create a new map
    -Go to the trigger editor
    -Click on the map icon at the top of the list of triggers
    -Paste the code in the custom script section.


    So I did: I pressed the "Untitled" map icon on the trigger editor, and pasted the text
    Code (vJASS):
    function HelloWorld takes nothing returns nothing
        call BJDebugMsg("Hi, my name is Bob.")
        call BJDebugMsg("I am 2 years old!")
        //And so on, by the way you can add comments to your code like this
        //Basically if you have '//' somewhere on a line, the rest of the line (after the '//') counts as a comment
    endfunction

    on the "Custom Script Code:" section. When I start the game, NOTHING HAPPENS.

    If I am to move on I have to know how to make a simple trigger.
    What am I doing wrong?
     
  9. Vercas

    Vercas

    Joined:
    Dec 9, 2007
    Messages:
    2,604
    Resources:
    1
    Spells:
    1
    Resources:
    1
    There is a mispell in the text, check it!
     
  10. Herman

    Herman

    Joined:
    Aug 20, 2007
    Messages:
    877
    Resources:
    0
    Resources:
    0
    Oh dear, ok, cheezeman read through the rest of the tutorial

    Sam Panda, you need to have your code totally finished before you save it

    The compiler doesn't always check the correct problem, what your missing is an endfunction after your original function declaration.

    One common reason the WE crashes, is because a string has not been closed, like this...

    Code (vJASS):
    local string s = "I'm an unclosed string


    I'm not sure exactly why the WE crashes, I think its due to a massive clog of data as the compiler tries to put all of the map code and source code into a single string

    I really don't know that though

    If you'll notice, all of the text after that point of not adding in that closing " has turned blue


    Thats kind of what happens in your WE compiler
     
  11. Cheezeman

    Cheezeman

    Joined:
    Aug 19, 2008
    Messages:
    437
    Resources:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    2
    This tutorial sucks...

    This tutorial really sucks...
    I can't even make the "simple trigger" to work.
    I'm supposed to put the following text inside the map icon (called Untitled) on the "Custom Script Code:"
    Code (vJASS):
    function HelloWorld takes nothing returns nothing
        call BJDebugMsg("Hello World")
    endfunction


    So I did...
    Then I was suposed to create a trigger which went of by pressing Left Key and name it whatever I want. I was going to put the following text there, just as asked:
    Code (vJASS):
    call HelloWorld()


    BUT: There was already a text there:
    Code (vJASS):
    function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
    endfunction

    //===========================================================================
    function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
        set gg_trg_Untitled_Trigger_001 = CreateTrigger(  )
        call TriggerRegisterPlayerKeyEventBJ( gg_trg_Untitled_Trigger_001, Player(0), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_LEFT )
        call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions )
    endfunction


    And wherever I put it, it said that the trigger was wrong.
    If I replaced it the Editor asked for a initzialation text...
    If I placed it after the text, it said that it was wrong and would be disabled.



    So my finnaly question/sugestion:

    Could you post a picture or JASStag which shows
    1: You selecting "Untitled" map icon?
    2: You selecting the "Untitled Trigger 001" icon?

    Oh yes and by the way Herman: I've read the rest and didn't understand a single thing about it, probobly due to that I didn't even make the 1th tutorial to work. Why move on to the next stage, if you are not finished with the first?

    BTW I re-uploaded this "complination text" (wrong word, I know) beacuse I didn't find it on the Replies section.
     
  12. Herman

    Herman

    Joined:
    Aug 20, 2007
    Messages:
    877
    Resources:
    0
    Resources:
    0
    Unless your dyslexic, please don't spell words wrong, or use incorrect words. I cannot tell what 'complination' is supposed to mean. My strongest guess is 'compilation', 2nd guess would be 'complaint'.

    I meant read through the rest of it, because your supposed to stick it in a trigger and use it. Simply making the function will not do anything, as you had described.

    When he says make a trigger, he is assuming your moving from GUI to JASS. You should not convert the trigger to custom text, in your events put a normal GUI event for 'Left Key', and put for 'Actions', find the 'Custom Script' and type in 'call HelloWorld()'

    It should look somewhat like this...

    • Events
      • 'Left Key Press'
    • Conditions
    • Actions
      • Custom Script: call HelloWorld()


    And as for this tutorial sucks, don't blame the tutorial, there is such a thing as being stupid

    I don't think your stupid though, I had the same problems with these tutorials, and really got quite pissed when I started. You just need to keep at it, try every possibility, and above all else being a lazy schmuck cannot help.
     
  13. Kwah

    Kwah

    Joined:
    May 9, 2007
    Messages:
    3,391
    Resources:
    8
    Icons:
    5
    Maps:
    1
    Tutorials:
    2
    Resources:
    8
    Quite framkly I think that it is a quality tutorial.

    The answer, wuite simply is:

    JASS is crap.


    Sorry, to all you dedicated JASS'ers out there, but as a language it is quite frankly lame. Compared to something like Pytohn, or C it does not compare.

    Still, I'm going to learn it, and it can do powerful things in Warcraft.
     
  14. Vercas

    Vercas

    Joined:
    Dec 9, 2007
    Messages:
    2,604
    Resources:
    1
    Spells:
    1
    Resources:
    1
    I know what my cat says better than a JASS trigger...
     
  15. Sam Panda

    Sam Panda

    Joined:
    Jan 6, 2008
    Messages:
    25
    Resources:
    0
    Resources:
    0
    Thanks for the reply, herman, but the reason it's missing an endfunction in the shown code is because I only showed the relevant part to what I was talking about.

    It still has an endfunction and everything, the only addition is one line that is correctly written and everything and I dunno why the lack of savability happens ;(
     
  16. Cheezeman

    Cheezeman

    Joined:
    Aug 19, 2008
    Messages:
    437
    Resources:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    2
    I'm so sorry for my bad English. When I wrote it I was starving and couldn't think straight.
    Well, first of all I don't have dyslexic (I can tell beacuse my neighbour have it), and second of all the word I was trying to describe would be something like "my complaining text" which would be more acurate.

    Now I see that I should have used a GUI Trigger, NOT a JASS Trigger and for that you have my thanks.
    And now I have a new question: do I need to convert the trigger to Custom Text?

    I hope you find this Quote's spelling better then my last one (really, really sorry for my awfull English)
    And this tutorial doesn't suck (like I wrote) beacuse people obviously find it helpful so there must be something I'm missunderstanding.
     
  17. Herman

    Herman

    Joined:
    Aug 20, 2007
    Messages:
    877
    Resources:
    0
    Resources:
    0
    Converting GUI to JASS comes later once one has learned all they need to know about functions {declarations, parameters, calling, returning}

    When you reach this point...

    GUI is actually a bad version of JASS (literally, the war3 processor converts GUI into a horribly odd-looking JASS script)

    When you use the 'Convert to Custom Text' button, you get a glimpse of what it looks like

    You'll notice something along these lines...

    Code (vJASS):
    function <triggername>_Actions takes nothing returns nothing
        //Your actions
    endfunction

    function <triggername>_Conditions takes nothing returns boolean
        //Your conditions
    endfunction

    function InitTrig_<triggername> takes nothing returns nothing
        set gg_trg_<triggername> = CreateTrigger()
        call <Function name for your GUI event>(<parameters for the GUI event>)
        call TriggerAddAction(gg_trg_<triggername>, function <triggername>_Actions)
        call TriggerAddCondition(gg_trg_<triggername>, function <triggername>_Conditions)
    endfunction


    Now this probably looks extremely confusing, but I want you to focus on the 'CreateTrigger()' portion. This creates what JASSers call a 'handle'. A handle is basically a big piece of information that has special syntax and can do certain things. Here, our handle is a trigger, and what trigger handles do, is pretty much exactly what a normal GUI trigger can do. The important part right now, is registering events.

    You can register an event to a trigger, and it will run like this...

    When the specific event occurs...

    Code (vJASS):
    if <TriggersAddedConditions> then
        <TriggersAddedActions
    endif


    An if-then similar to this will run and check to see whether or not the trigger will fire.

    Your probably thinking to yourself, great, but how does the 'CreateTrigger()' function get called???

    Well, the war3 processor has a 'main' function that runs all the various commands you told your WE to do in the different WE interfaces{such as creating units}. This 'main' function also calls each of your 'InitTrig_' functions

    In order to have your function called in the 'main', you must fulfill 3 conditions.

    1. You must create a regular GUI trigger and convert it to custom text, this doesn't sound like a big deal, but when you use the 'Custom Script' at the top of the trigger editor, you start to wish you didn't need to do this.

    2.The next condition, is that the function must start with 'InitTrig_'

    3.Lastly, after the 'InitTrig_' you must have the name of your trigger, this is because the war3 processor must need to know which functions are just functions and which one will be called in the main.
     
  18. ShrEad-ER

    ShrEad-ER

    Joined:
    Aug 29, 2008
    Messages:
    121
    Resources:
    1
    Maps:
    1
    Resources:
    1
    ok... first of all... good tut!
    the second... i think the tut was a little long and not descriping enough of the things that is possible... I THINK...
    the third... i use to many of '...' dont you think? XD
     
  19. TheBlooddancer

    TheBlooddancer

    Joined:
    Jun 24, 2008
    Messages:
    2,911
    Resources:
    0
    Resources:
    0
    Ehrm.. You guys lost me after "HelloWorld" :D

    Code (vJASS):
    function UnitCreation takes nothing returns nothing
      local unit u = CreateUnit(XXX)
    endfunction
     


    What should be in the XXX? The Rawcode (h001)? Or the Name? (Ninja) or What?

    And my W/E Keeps bugging with the GUI triggers also, after i made a mistake in JASS:
    Please? Can anyone help?
     
  20. Herman

    Herman

    Joined:
    Aug 20, 2007
    Messages:
    877
    Resources:
    0
    Resources:
    0
    Turn off or remove all of your JASS code until you find what is bugged and whats not.

    The JASS Vault

    Search around here for any questions you have about JASS functions, they will be in the common.j section

    player id --> the variable type is 'player', and the name is 'id'

    The name gives a hint to what the parameter is logically, here meaning the identity of the unit, or its owner

    integer unitid --> An integer variable, the name is 'unitid', through experience I've learned this is the place for a units rawcode

    real x --> simple enough, the exact x coordinate of where the unit will be placed

    real y --> exact y coordinate

    real face --> The degrees the unit will face, please note that this is in degrees, not radians

    And that 'returns' bit means that you can set this function to a variable, as you have done already.

    Your function could possibly look like this...

    Code (vJASS):
    function UnitCreation takes nothing returns nothing
        local real x = GetRandomReal(0,10000)
        local real y = GetRandomReal(0,10000)
        local real face = GetRandomReal(0,360)
        local player owner = Player(GetRandomInt(0,10))
        local unit u = CreateUnit(owner, 'A001', x, y, face)
    endfunction