• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Help with learning triggers

Status
Not open for further replies.
Level 9
Joined
May 14, 2011
Messages
524
I've messed around with the triggers and understood the basics,can anyone teach me farther? I need to learn Hashtables,MUI and leaks,I have never coded in my life but I'll catch on really fast :aht:
 
Level 10
Joined
Jun 6, 2007
Messages
392
For leaks, you should check the thread "things that leak", it has useful tips to avoiding most common types of leak. For hashtables, there is at least one good tutorial on hive, I can't remember the name though. The spells are mui, if you don't wait between setting and using a global variable. If the spell requires waiting (like most do), you can make it mui by using a local variable instead of a global one, or by using an array of some sort (such as hashtables). You can consider a hashtable an array, in which you have rows (in most cases, a row represents the casting unit) and in one row, you have all variables that link to the corresponding unit. It's a little difficult to explain, check out that tutorial. Sorry if my reply is a little messy, I just wrote what came into my mind. Good luck with learning!
 
Since you're a beginner, here are some things you need to know:

1- GUI is inefficient (Way too inefficient)

2- To make up for its efficiency, we have to do 4 things:
......a- Never repeat things like (Triggering Unit) and (Last Created Unit) in a trigger. You should store them in "variables".
......b- Always remove leaks
......c- Never use "Do Nothing" (It does what it does ;p)
......d- Never use "wait" (Except in some cases like in cinematics and some triggers that ONLY use actions that use (Triggering Unit).

3- Never use (Integer A) or (Integer B). Use (Integer Variable) since (Integer A/B) can cause some really wierd bugs

4- When you're creating a spell that you want to upload, it's always good to
add a few comments in the code so that people would be able to understand
what's going on, and they might even learn a thing or two about triggering ^-^

5- For file size, never repeat actions that are VERY similar. Use (Integer Variable) loops
in that case.
 
Level 9
Joined
May 14, 2011
Messages
524
  • Overheat index
    • Events
    • Conditions
    • Actions
      • Set Color_Blue = 100.00
      • Set Color_Green = 100.00
      • Set Oh_Fin = (Oh_Fin + 1)
      • Set Oh = Oh_Fin
  • Overheat cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Overheat
    • Actions
      • Trigger - Run Overheat index <gen> (ignoring conditions)
      • Set Oh_Caster[Oh] = (Triggering unit)
      • Special Effect - Create a special effect attached to the head of Oh_Caster[Oh] using Abilities\Spells\Orc\Voodoo\VoodooAuraTarget.mdl
      • Set SFX = (Last created special effect)
      • Set Caster_Point[Oh] = (Position of Oh_Caster[Oh])
      • Set Too_Close[Oh] = (Units within 150.00 of (Position of Oh_Caster[Oh]) matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) is A structure) Equal to ((Matching unit) belongs to an enemy of (Owner of Oh_Caster[Oh])))))
      • Set Too_Close_Units[Oh] = (Picked unit)
      • Set Dummy = (Last created unit)
      • Set Oh_Angle[Oh] = (Angle from Caster_Point[Oh] to (Position of (Random unit from Too_Close[Oh])))
      • Set Max_Dist[Oh] = 250.00
      • Set KB_Speed[Oh] = 50.00
      • Set Dist[Oh] = 0.00
      • Trigger - Turn on Overheat Effect <gen>
  • Overheat Effect
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • Animation - Change Oh_Caster[Oh]'s vertex coloring to (100.00%, (Color_Green - 20.00)%, (Color_Blue - 20.00)%) with 0.00% transparency
      • For each (Integer Oh) from 1 to Oh_Fin, do (Actions)
        • Loop - Actions
          • Set Point_1 = (Position of Too_Close_Units[Oh])
          • Set Point_2 = ((Position of Too_Close_Units[Oh]) offset by KB_Speed[Oh] towards Oh_Angle[Oh] degrees)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • Dist[Oh] Greater than or equal to Max_Dist[Oh]
                  • (Terrain pathing at Point_2 of type Walkability is off) Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Oh_Fin Equal to 1
                • Then - Actions
                  • Special Effect - Create a special effect attached to the chest of Too_Close_Units[Oh] using Abilities\Spells\Other\Doom\DoomDeath.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • Unit - Create 1 DUMMY for (Owner of Oh_Caster[Oh]) at Caster_Point[Oh] facing Caster_Point[Oh]
                  • Unit - Add Stun Dummy to Dummy
                  • Unit - Set level of Stun Dummy for Dummy to (Level of Overheat for Oh_Caster[Oh])
                  • Unit - Order Dummy to Human Mountain King - Storm Bolt Too_Close_Units[Oh]
                  • Unit - Add a 1.00 second Generic expiration timer to Dummy
                  • Unit - Hide Dummy
                  • Animation - Change Oh_Caster[Oh]'s vertex coloring to (100.00%, 100.00%, 100.00%) with 0.00% transparency
                  • Special Effect - Destroy SFX
                  • Trigger - Turn off (This trigger)
                • Else - Actions
                  • Set Oh_Caster[Oh] = Oh_Caster[Oh_Fin]
                  • Set Caster_Point[Oh] = Caster_Point[Oh_Fin]
                  • Set Dist[Oh] = Dist[Oh_Fin]
                  • Set Oh_Angle[Oh] = Oh_Angle[Oh_Fin]
                  • Set KB_Speed[Oh] = KB_Speed[Oh_Fin]
                  • Set Max_Dist[Oh] = Max_Dist[Oh_Fin]
                  • Set Too_Close_Units[Oh] = Too_Close_Units[Oh_Fin]
                  • Set Oh = (Oh - 1)
              • Set Oh_Fin = (Oh_Fin - 1)
            • Else - Actions
              • Unit - Move Too_Close_Units[Oh] instantly to Point_2
              • Special Effect - Create a special effect at Point_2 using Abilities\Weapons\AncientProtectorMissile\AncientProtectorMissile.mdl
              • Special Effect - Destroy (Last created special effect)
              • Set Dist[Oh] = (KB_Speed[Oh] + Dist[Oh])
Spell don't work :( I have not removed the leaks yet and don't know how to describe the spell.
 
Level 17
Joined
Jan 21, 2010
Messages
2,111
  • Overheat index
    • Events
    • Conditions
    • Actions
      • Set Color_Blue = 100.00
      • Set Color_Green = 100.00
      • Set Oh_Fin = (Oh_Fin 1)
      • Set Oh = Oh_Fin
  • Overheat cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Overheat
    • Actions
      • Trigger - Run Overheat index <gen> (ignoring conditions)
      • Set Oh_Caster[Oh] = (Triggering unit)
      • Special Effect - Create a special effect attached to the head of Oh_Caster[Oh] using Abilities\Spells\Orc\Voodoo\VoodooAuraTarget.mdl
      • Set SFX = (Last created special effect)
      • Set Caster_Point[Oh] = (Position of Oh_Caster[Oh])
      • Set Too_Close[Oh] = (Units within 150.00 of (Position of Oh_Caster[Oh]) matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) is A structure) Equal to ((Matching unit) belongs to an enemy of (Owner of Oh_Caster[Oh])))))
      • Set Too_Close_Units[Oh] = (Picked unit)
      • Set Dummy = (Last created unit)
      • Set Oh_Angle[Oh] = (Angle from Caster_Point[Oh] to (Position of (Random unit from Too_Close[Oh])))
      • Set Max_Dist[Oh] = 250.00
      • Set KB_Speed[Oh] = 50.00
      • Set Dist[Oh] = 0.00
      • Trigger - Turn on Overheat Effect <gen>
  • Overheat Effect
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • Animation - Change Oh_Caster[Oh]'s vertex coloring to (100.00%, (Color_Green - 20.00)%, (Color_Blue - 20.00)%) with 0.00% transparency
      • For each (Integer Oh) from 1 to Oh_Fin, do (Actions)
        • Loop - Actions
          • Set Point_1 = (Position of Too_Close_Units[Oh])
          • Set Point_2 = ((Position of Too_Close_Units[Oh]) offset by KB_Speed[Oh] towards Oh_Angle[Oh] degrees)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • Dist[Oh] Greater than or equal to Max_Dist[Oh]
                  • (Terrain pathing at Point_2 of type Walkability is off) Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Oh_Fin Equal to 1
                • Then - Actions
                  • Special Effect - Create a special effect attached to the chest of Too_Close_Units[Oh] using Abilities\Spells\Other\Doom\DoomDeath.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • Unit - Create 1 DUMMY for (Owner of Oh_Caster[Oh]) at Caster_Point[Oh] facing Caster_Point[Oh]
                  • Unit - Add Stun Dummy to Dummy
                  • Unit - Set level of Stun Dummy for Dummy to (Level of Overheat for Oh_Caster[Oh])
                  • Unit - Order Dummy to Human Mountain King - Storm Bolt Too_Close_Units[Oh]
                  • Unit - Add a 1.00 second Generic expiration timer to Dummy
                  • Unit - Hide Dummy
                  • Animation - Change Oh_Caster[Oh]'s vertex coloring to (100.00%, 100.00%, 100.00%) with 0.00% transparency
                  • Special Effect - Destroy SFX
                  • Trigger - Turn off (This trigger)
                • Else - Actions
                  • Set Oh_Caster[Oh] = Oh_Caster[Oh_Fin]
                  • Set Caster_Point[Oh] = Caster_Point[Oh_Fin]
                  • Set Dist[Oh] = Dist[Oh_Fin]
                  • Set Oh_Angle[Oh] = Oh_Angle[Oh_Fin]
                  • Set KB_Speed[Oh] = KB_Speed[Oh_Fin]
                  • Set Max_Dist[Oh] = Max_Dist[Oh_Fin]
                  • Set Too_Close_Units[Oh] = Too_Close_Units[Oh_Fin]
                  • Set Oh = (Oh - 1)
              • Set Oh_Fin = (Oh_Fin - 1)
            • Else - Actions
              • Unit - Move Too_Close_Units[Oh] instantly to Point_2
              • Special Effect - Create a special effect at Point_2 using Abilities\Weapons\AncientProtectorMissile\AncientProtectorMissile.mdl
              • Special Effect - Destroy (Last created special effect)
              • Set Dist[Oh] = (KB_Speed[Oh] Dist[Oh])
Spell don't work :( I have not removed the leaks yet and don't know how to describe the spell.
You decleare the dummy when the unit 'haven't created', all 'last created unit refer to this action:
Unit - create unit for player facing angle
Or
Unit - create unit for player facing point
 
NOT

my first resource was in vJASS... but I was using GUI for years before I even came across The Hive, when I came here, I realized how awful my triggering was (I was using WEU back then)... and it took me a while to learn vJASS (well still learning)... especially since I have no background on coding (It was really hard when I started, then my first resource was in vJASS and uses hashtables, then TRD forced me to learn structs which took me a while)...



so you can do it too!
 
Level 17
Joined
Jan 21, 2010
Messages
2,111
Ah...
I have spent almost 1 year learning jass, and still dont get it...
Nestahrus suggest me to learn jass, but, simply, i can under stand a thing from jass it self...
I was searching for a good teacher that can answer me, whenever i need a help...
 
Practice is the key... I think the tutorials by Nestharus is good to read (his knowledge is really high)...

I found jass to be really hard at first, but once I got my mind into it, it started to become easier... and once you get the hang of it, you'll like it... ^_^

and a lot of people nowadays, seem to be learning faster...
 
well, I'm posting things that will still help the creator of the thread (as mckill already suggested he learn JASS)

a very simple spell which deals 100 damage per level of spell...

JASS:
scope SimpleDamageSpell initializer init

    
    private function SimpleDamage takes nothing returns boolean
        //here we check if the casted spell corresponds to the spell that we want
        //this code to work for
        //I didn't use a local for the unit since I think two calls is tolerable
        if GetSpellAbilityId() == YOUR_SPELL_RAWCODE_HERE then
            //here we deal damage to the target
            call UnitDamageTarget(GetTriggerUnit(), GetSpellTargetUnit(), 100.0*(GetUnitAbilityLevel(GetTriggerUnit(), YOUR_SPELL_RAWCODE_HERE)), false, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_DIVINE, null)
        endif
        //we need this line since the function should return a boolean
        return false
    endfunction
    
    //This is the function run at map init
    private function init takes nothing returns nothing
        //here we create a trigger
        local trigger t = CreateTrigger()
        local integer i = 0
        loop
            exitwhen i > 15
            //We register the event Unit - A unit starts the effect of an ability
            //for all player units
            call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
            set i = i + 1
        endloop
        //we merge the actions into the condition because its faster than actions
        call TriggerAddCondition(t, Condition(function SimpleDamage))
        set t = null
    endfunction


endscope
 
Level 17
Joined
Jan 21, 2010
Messages
2,111
you forgot to put then?

or did you copy the whole code? your editor might not support vJASS (since I used scopes and privates, which are vJASS things, you need to use NewGenWE)...
Did usmwe support vjass?
i use it
But the problem is solved when i use
JASS:
If (not ( GetSpellAbilityId() == 'A000')) then
But when i used it, the spell does no damage
 
Did usmwe support vjass?
i use it
But the problem is solved when i use
JASS:
If (not ( GetSpellAbilityId() == 'A000')) then
But when i used it, the spell does no damage

UMSWE don't have JH so it will not probably support VJASS, but its weird that that change made it to work... but of course that won't work, since you used not, meaning it will only do the actions if the ability is not 'A000'...
 
read this thread >>> http://www.hiveworkshop.com/forums/triggers-scripts-269/natives-local-variables-190476/ and http://www.hiveworkshop.com/forums/world-editor-help-zone-98/gui-jass-190289/, I asked too many questions there, maybe you'll be interested...by now I can make JASS spells (not perfect though), but things are more clear to me now even vJASS...you cant learn it in 1 day nor 1 month depending on how busy you are in real life but if you focus and WANT TO LEARN, then you'll be a good JASSER like Adiktuz, one of my teachers :)...
 
If (not ( GetSpellAbilityId() == 'A000')) then

You capitalized the "if"

EDIT:

I really advise you to skip GUI
As soon as you learn JASS and vJASS or Zinc, (Which is the same thing, except for the syntax)
you're going to see how bad and inefficient GUI can be :)

I used to be a GUIer for 4 years ... 3 months ago, I came back to my hive account,
uploaded a GUI spell that used waits, and got flamed :p

Don't you remember Adiktuz? The Atomic Bomb spell ^^
I used to be "Mabster" back then :p

A month ago, I mastered the "simple" aspects of vJASS, and now, I'm learning about modules,
delegates, interfaces, and the "struct blekh extends array" thing that generates almost no code
in the background for functionality.


I put the "HIV" in hive man! :ogre_datass:


If you ever have a question about vJASS or JASS, just ask me. If I can't help you, then
ask Nestharus (The most badass vJASSer we have here ^^)
 
Are you sure? Here's my solution:

JASS:
function JOIN_US takes unit GUIer returns nothing
    call IssueImmediateOrder(GUIer,"smart")
    call TriggerSleepAction (ENOUGH_TIME_FOR_A_GUIER_TO_UNDERSTAND_HOW_GUI_IS_INEFFICIENT)
    call BJDebugMsg("A GUIer has went to the JASS side ^^")
    call set NUMBER_OF_JASSERS = NUMBER_OF_JASSERS + 1
endfunction

Don't those pretty colors tempt you to join us? ^^
 
Status
Not open for further replies.
Top