1. The long-awaited results for Concept Art Contest #11 have finally been released!
    Dismiss Notice
  2. Join Texturing Contest #30 now in a legendary battle of mythological creatures!
    Dismiss Notice
  3. The 20th iteration of the Terraining Contest is upon us! Join and create exquisite Water Structures for it.
    Dismiss Notice
  4. Hivers united and created a bunch of 2v2 melee maps. Vote for the best in our Melee Mapping Contest #4 - Poll!
    Dismiss Notice
  5. Check out the Staff job openings thread.
    Dismiss Notice

Beginning JASS Tutorial Series

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

  1. NRJ

    NRJ

    Joined:
    Feb 26, 2008
    Messages:
    5
    Resources:
    0
    Resources:
    0
    You must have event in your trigger
     
  2. Mzorgou

    Mzorgou

    Joined:
    Jun 8, 2008
    Messages:
    2
    Resources:
    0
    Resources:
    0
    I didn't understand this tutorial at all, which sucks cuz i always wanted to learn JASS and though this would help me a lot.:cry:
     
  3. Vercas

    Vercas

    Joined:
    Dec 9, 2007
    Messages:
    2,604
    Resources:
    1
    Spells:
    1
    Resources:
    1
    Wohoo... Same as Mzorgou... I wanted a lot to learn about JASS...
    I just... I Can't understand this tutorial!!! Just something about creating functions, creating actions, creating and seting local and global variables...
    wyrmlord... Can you make a spell for me?
    If yes, ask me!
     
  4. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,419
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    Maybe you could try learning about WE and the trigger editor BEFORE reading this. I mean, people say that you should learn JASS from the start but that just isn't the path for some people, some don't know what an "event" or "condition" is and that is usually not really explained in JASS tutorials.
     
  5. Shizune

    Shizune

    Joined:
    Mar 29, 2008
    Messages:
    15
    Resources:
    0
    Resources:
    0
    I would like to learn JASS to make triggers easier for me but,
    i got stuck when you did "Edit Away!" in the introduction,
    Can you give some examples of what to do?
    would be greatly appreciated
     
  6. Shizune

    Shizune

    Joined:
    Mar 29, 2008
    Messages:
    15
    Resources:
    0
    Resources:
    0
    Its been over a month and a week now,Still no responses.
    I guess people dont want me to learn
     
  7. Herman

    Herman

    Joined:
    Aug 20, 2007
    Messages:
    877
    Resources:
    0
    Resources:
    0
    Its been almost 2 weeks....
     
  8. DrazharLn

    DrazharLn

    Joined:
    Nov 29, 2007
    Messages:
    368
    Resources:
    0
    Resources:
    0
    Try the tutorials on JASS vault and wc3campaigns.
    Convert GUI to custom text, learn how it works and then clean it up.

    Lots of ways to learn
     
  9. Dreadnought[dA]

    Dreadnought[dA]

    Joined:
    Feb 23, 2007
    Messages:
    810
    Resources:
    0
    Resources:
    0
    I found optimizing code to be the best way to learn... I just self taught myself pretty much everything (except structs... had to look at a few triggers to see how they work) after I read up on ways to optimize.
     
  10. Jay-D

    Jay-D

    Joined:
    Jun 29, 2008
    Messages:
    50
    Resources:
    0
    Resources:
    0
    Where can i get the newest JassNewGen??

    i need JassNewGen.... pls tell me where i can dl it :fp:
     
  11. DrazharLn

    DrazharLn

    Joined:
    Nov 29, 2007
    Messages:
    368
    Resources:
    0
    Resources:
    0
    Try google.
    Google search, for your convenience.
    You want the third in the list, the wc3campaigns v5a release.
     
  12. Pisco1412

    Pisco1412

    Joined:
    Jul 4, 2008
    Messages:
    9
    Resources:
    0
    Resources:
    0
    this tutorial is nearly impossible for people without some good knowledge on Computer Science. I hated that class, it was so freakin' hard, I ain't about to tire myself out making a map using JASS. My Computer Science class was torture, and learning this will be equally annoying. Play the game to enjoy, not to learn. Learning's for school, AND SCHOOL'S OUT FOR SUMMER!!!
     
  13. DrazharLn

    DrazharLn

    Joined:
    Nov 29, 2007
    Messages:
    368
    Resources:
    0
    Resources:
    0
    I'm taking computer science next year [urk >.>], I found the tutorial by vexorian [on wc3campaigns and the JASS vault to be easier myself, but this one is useful for some things.
     
  14. Herman

    Herman

    Joined:
    Aug 20, 2007
    Messages:
    877
    Resources:
    0
    Resources:
    0
    Bah, I hate these tutorials, the guys who write are laazzy, I mean some of are great but for the most part I only learned the stuff I know now through sheer determination

    Just keep re-reading these things and after awhile it'll all come together
     
  15. Djamp

    Djamp

    Joined:
    Jun 11, 2008
    Messages:
    17
    Resources:
    0
    Resources:
    0
    thanks this page is a real help..thanks so much for making this
     
  16. Lestat(br)

    Lestat(br)

    Joined:
    Oct 2, 2005
    Messages:
    406
    Resources:
    7
    Models:
    7
    Resources:
    7
    Code (Text):
    function Trig_Frost_Nova_Conditions takes nothing returns boolean
        if ( not ( GetSpellAbilityId() == 'ACfn' ) ) then
            return false
        endif
        return true
    endfunction

    function Trig_Frost_Nova_Actions takes nothing returns nothing
        local unit caster = GetSpellAbilityUnit()
        local unit temptarget = GetSpellTargetUnit()
        local real range = (300.00+(GetUnitAbilityLevel(caster, 'ACfn')*100.00))
        local location temploc = GetUnitLoc(caster)
        local group enemies = CreateGroup()
        local integer unitlimit = (4+(GetUnitAbilityLevel(caster, 'ACfn')*2))
        local real actdmg = 50.00
        call GroupEnumUnitsInRangeOfLoc(enemies, temploc, range, null)
        loop
            set unitlimit = unitlimit - 1
            exitwhen unitlimit == 0 or temptarget == null
            loop
                exitwhen IsUnitEnemy(FirstOfGroup(enemies), GetOwningPlayer(caster)) == true
                if IsUnitAlly(FirstOfGroup(enemies), GetOwningPlayer(caster)) == true then
                    call GroupRemoveUnit(enemies, FirstOfGroup(enemies))
                    set temptarget = FirstOfGroup(enemies)
                endif
            endloop
            set temploc = GetUnitLoc(temptarget)
            call SetUnitPositionLoc(caster, temploc)
            call UnitDamageTarget(caster, temptarget, actdmg, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_MAGIC, null)      
            call GroupRemoveUnit(enemies,temptarget)
            call TriggerSleepAction(0.2)
            if unitlimit > 0 then
                set temptarget = FirstOfGroup(enemies)
            else
                set caster = null
                set temptarget = null
                set temploc = null
                set enemies = null
            endif        
        endloop
    endfunction

    //===========================================================================
    function InitTrig_Frost_Nova takes nothing returns nothing
        set gg_trg_Frost_Nova = CreateTrigger(  )
        call TriggerRegisterAnyUnitEventBJ( gg_trg_Frost_Nova, EVENT_PLAYER_UNIT_SPELL_EFFECT )
        call TriggerAddCondition( gg_trg_Frost_Nova, Condition( function Trig_Frost_Nova_Conditions ) )
        call TriggerAddAction( gg_trg_Frost_Nova, function Trig_Frost_Nova_Actions )
    endfunction
    This didn't work. Please tell me what's wrong...
    Thank you.
     
  17. Herman

    Herman

    Joined:
    Aug 20, 2007
    Messages:
    877
    Resources:
    0
    Resources:
    0
    Chances are you have the wrong object data

    You need to be more descriptive when you ask for help, like, it doesn't compile, it doesn't cast, it doesn't damage the correct damage

    Saying "it doesn't work, tell me why" is like saying "God, I need your help, I am retarded"

    I really didn't look into it, but if it still doesn't work, post your map and I'll take a better look

    EDIT - Looked at it again, there are a few things that might cause problems

    Starting from the top, you probably don't know what boolexprs are, you should use them when you enumerate groups, I will not explain it to you, you need to look further into it

    You created a location at the casters position, and never removed it
    That will cause a leak

    If there are any effects to be used with your newly enumerated group, the group was enum'ed by your caster, not the target of the spell, so loop through the group will only affect nearby units

    I see you nested a loop to remove all allied units, this is normally used with boolexprs, but since you do not know what they are, you should instead put the enemies in a new group, and remove the old group

    Then working with the new group, damage all of the enemies

    I highly suggest not using nested loops when looping through groups, because it gets very very complicated

    Here is how I would go about it...

    Code (vJASS):

    function NoLeak takes nothing returns boolean
        return true
    endfunction
    //Don't worry about this function, it is a little bug with using 'null' for a
    //boolexpr parameter

    constant function Nova_RawCode takes nothing returns integer
        return 'ACfn'
    endfunction

    function Trig_Frost_Nova_Actions takes nothing returns nothing
        local unit caster = GetSpellAbilityUnit()
        local unit temptarget = GetSpellTargetUnit()
        local unit u //An empty variable for looping
        local player own = GetOwningPlayer(caster)
        //It would be very inefficient to constantly get the owning player
        //every time you looped
        local integer level = GetUnitAbilityLeve(caster, Nova_RawCode())
        local real range = 300.00 + level *100.00 //PEMDAS
        local location temploc = GetUnitLoc(temptarget)
        local group g = CreateGroup()
        local group g2 = CreateGroup()
        local integer unitlimit = 4 + level * 2
        local real dmg = 50.00 //Unnecessary, but we will keep it
        call GroupEnumUnitsInRangeOfLoc(g, temploc, range, Condition(function NoLeak))
        loop
          set u = FirstOfGroup(g)
          exitwhen u == null
          call GroupRemoveUnit(g, u)
          if IsUnitEnemy(u, own) then
            call GroupAddUnit(g2, u)
          endif
        endloop
        call DestroyGroup(g)
        set g = null
        //Enums the second group with only enemies
        loop
          set u = FirstOfGroup(g2)
          exitwhen unitlimit == 0 or u == null
          call GroupRemoveUnit(g2,u)
          call UnitDamageTarget(caster, u, dmg, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_WHOKNOWS)
          set unitlimit = unitlimit - 1
        endloop
        //Damages 'unitlimit' # of units in 2nd group
        call GroupClear(g2)
        call DestroyGroup(g2)
        set g2 = null
        call RemoveLocation(temploc)
        set temploc = null
        set caster = null
        set temptarget = null
        set u = null
    endfunction


    I really have no idea what you were trying to do, but here is a fix on what you had that should damage only enemy units in range of the target approx. 50 damage (units have armor, generally)

    The WEAPON_TYPE_WHOKNOWS is a constant, I'm not sure what it does, but I believe it has some effect sound, it may be an incorrect name (WEAPON_TYPE_WHO_KNOWS may be the correct one) I don't remember exactly, but you can change it back to null if you need to

    If the code looks really confusing to you, just go through it line-by-line, and it should make sense
     
    Last edited: Jul 18, 2008
  18. Dragon_Lancer

    Dragon_Lancer

    Joined:
    Jul 16, 2008
    Messages:
    68
    Resources:
    0
    Resources:
    0
    My wc3 editor keeps breaking down when i don't get a jass thing right:cry:
     
  19. Herman

    Herman

    Joined:
    Aug 20, 2007
    Messages:
    877
    Resources:
    0
    Resources:
    0
    Search jassnewgenpack on google, download it, install it, and then turn off the WE syntax checker

    The jasshelper is a better version that will not cause it to crash when you make an error

    I would suggest some vJASS learning too, but it gets to be rather complicated if you don't even know regular JASS
     
  20. Dragon_Lancer

    Dragon_Lancer

    Joined:
    Jul 16, 2008
    Messages:
    68
    Resources:
    0
    Resources:
    0
    I need help what ability should i use and i need help with the never used the units start location thing