• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[GUI] Item Set System 1.4.1

  • Like
Reactions: Vinz
Description:
With this system you can make item sets similar to the item sets from Worls of Warcraft, Torchlight 2, and any other game that uses item sets like these.
- The item sets are registered by items that give you one stack in that item set.
(Every item type can only be registered to one item set. They can however be switched between item sets or removed from one.)
- Every stack in an item set (even 1) can have an ability that will be added to the unit.
With spell books you can add more abilities per stack.
- Abilities can increase level by having more stacks.
- A buff can be displayed to show the item set and what bonusses you have or haven't.

How to install:
Copy all global variables from the test map into your map.
Copy all triggers from the category "Item Set System (ISS)" into your map.
Create some items and sets.
Register your item sets in the "ISS Initialization"; trigger.

Triggers:

  • ISS Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set ISS_Hashtable = (Last created hashtable)
      • Custom script: set udg_No_Ability = 0
      • -------- Register all item sets. --------
      • Set ISS_Param_Tooltip = Item Set Elite (Spellbook)
      • Set ISS_Param_Buff_Array[0] = Item Set Elite Level 1
      • Set ISS_Param_Buff_Array[1] = Item Set Elite Level 2
      • Set ISS_Param_Buff_Array[2] = Item Set Elite Level 3
      • Set ISS_Param_Ability_Array[0] = Attribute Bonus (Item Set 1)
      • Set ISS_Param_Ability_Array[1] = Damage Bonus (Item Set 1)
      • Set ISS_Param_Ability_Array[2] = Life Bonus (Item Set 1)
      • Set ISS_Param_Ability_Number = 2
      • Set ISS_Param_Item_Type_Array[0] = Assassin's Blade
      • Set ISS_Param_Item_Type_Array[1] = Elven Mantle
      • Set ISS_Param_Item_Type_Array[2] = Holy Shield
      • Set ISS_Param_Item_Type_Array[3] = Necronomicon
      • Set ISS_Param_Item_Type_Array[4] = Orb of Shadow
      • Set ISS_Param_Item_Type_Number = 4
      • Trigger - Run ISS_Trigger_Create_Set (ignoring conditions)
      • -------- Register all item sets. --------
      • Set ISS_Param_Tooltip = Item Set Full Hand (Spellbook)
      • Set ISS_Param_Buff_Array[0] = Item Set Full Hand Level 1
      • Set ISS_Param_Buff_Array[1] = Item Set Full Hand Level 2
      • Set ISS_Param_Buff_Array[2] = Item Set Full Hand Level 3
      • Set ISS_Param_Buff_Array[3] = Item Set Full Hand Level 4
      • Set ISS_Param_Ability_Array[0] = No_Ability
      • Set ISS_Param_Ability_Array[1] = Devotion Aura (Item Set 2) (Spellbook)
      • Set ISS_Param_Ability_Array[2] = Devotion Aura (Item Set 2) (Spellbook)
      • Set ISS_Param_Ability_Array[3] = Hardened Skin (Item Set 2) (Spellbook)
      • Set ISS_Param_Ability_Number = 3
      • Set ISS_Param_Item_Type_Array[0] = Ring of Poison
      • Set ISS_Param_Item_Type_Array[1] = Ring of Protection
      • Set ISS_Param_Item_Type_Array[2] = Ring of Regeneration
      • Set ISS_Param_Item_Type_Array[3] = Ring of Superiority
      • Set ISS_Param_Item_Type_Number = 3
      • Trigger - Run ISS_Trigger_Create_Set (ignoring conditions)
JASS:
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//  Wietlol's Item Set System 1.4.1 11/07/2016
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//  Description:
//      This system is made to create item sets.
//      You must configure the item sets that you want them to be and the system will do the rest.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//  How to install:
//      1. Copy or create all variables that are used in this map into your map.
//      2. Copy all triggers from the Item Set System (ISS) category and paste it into your map.
//      3. Create and register some items and abilities.
//      4. Enjoy your Item Set System.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//  Feature list:
//      This system can make item sets... thats it :)
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//  Variable explaination:
//////////////////////////
//      Map Initialization:
//      - ISS_Trigger_Create_Set         - trigger
//          This is the function that saves item-types and abilities to an item set.
//        
//      - ISS_Hashtable                 - hashtable
//          This is the hashtable that is used to save the data of the item sets.
//        
//      - No_Ability                    - ability (integer in JASS)
//          This is a null-variable. It is used to set ability variables back to null/0
//    
//////////////////////////
//      Parameters:
//      - ISS_Param_Index               - integer
//          This is a unique code for each item set.
//          Under this integer, the data of the item set is saved.
//        
//      - ISS_Param_Ability_Array[]     - ability[] (integer array in JASS)
//          This is an array of the abilities that an item set gives to the unit.
//        
//      - ISS_Param_Ability_Number      - integer
//          This is the amount of abilities that an item set has.
//        
//      - ISS_Param_Buff_Array[]        - buff[] (integer array in JASS)
//          This is an array of the buffs for instant replacing of the buff.
//          It uses ISS_Param_Ability_Number as well for the amount.
//        
//      - ISS_Param_Item_Type_Array[]   - item-type[] (itemtype array in JASS)
//          This is an array of all the items that an item set has.
//        
//      - ISS_Param_Item_Type_Number    - integer
//          This is the amount of item-types that an item set has.
//        
//      - ISS_Param_Tooltip             - ability (integer in JASS)
//          This is the ability that makes the toolip buff for the unit.
//        
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//  Changelog:
//      1.4.1 - 11/07/2016 - Fixed bug.
//          Bug fixed where removing an item of a set would remove the wrong effect.
//        
//      1.4 - 01/04/2015 - Buff Configuration Version.
//          Fixed double-buff-bug by adding buff removal and buff configuration.
//          Now automatically creates index numbers.
//          Fixed a few leaks and optimized code a bit.
//          Added condition to triggers for people who want to use TriggerEvaluate() instead of TriggerExecute().
//        
//      1.3 - 03/02/2015 - Update on review of IcemanBo, Edo494 and Mythic.
//          Merged the Save_Set and Save_Ability triggers to one Create_Set trigger.
//          Function names are smaller.
//          Local variable leaks removed.
//        
//      1.2 - 28/01/2015 - Update of reworked system.
//          Now all code is inside one trigger.
//          Functions can be called using global variables.
//        
//      1.1 - First official release on the Hive.
//        
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//  Known bugs:
//      - None
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////





/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//  This code is handling item sets on units.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//This function adds a stack of an item set.
function ISS_Add_Stack takes nothing returns boolean
    local unit u
    local integer unitId
    local integer index = LoadInteger(udg_ISS_Hashtable, GetItemTypeId(GetManipulatedItem()), 0)
    local integer level
    local integer abilityId
    local integer buffId
    local integer tooltip
 
    //The item is not attached to an item set.
    if index == 0 then
        return false
    endif
 
    set u = GetManipulatingUnit()
    set unitId = GetHandleId(u)
    set level = LoadInteger(udg_ISS_Hashtable, unitId, index)
    set abilityId = LoadInteger(udg_ISS_Hashtable, index, level*2 + 1)
    set buffId = LoadInteger(udg_ISS_Hashtable, index, level*2)
    set tooltip = LoadInteger(udg_ISS_Hashtable, index, 0)
 
    call SaveInteger(udg_ISS_Hashtable, unitId, index, level + 1)
 
    call UnitRemoveAbility(u, buffId)
    //Increase the level of the tooltip
    if GetUnitAbilityLevel(u, tooltip) > 0 then
        call SetUnitAbilityLevel(u, tooltip, level + 1)
    else
        call UnitAddAbility(u, tooltip)
    endif
 
    //Increase the level of the effect.
    if abilityId != 0 then
        if GetUnitAbilityLevel(u, abilityId) > 0 then
            call IncUnitAbilityLevel(u, abilityId)
        else
            call UnitAddAbility(u, abilityId)
        endif
    endif
 
    set u = null
    return false
endfunction

//This function removes a stack of an item set.
function ISS_Remove_Stack takes nothing returns boolean
    local unit u
    local integer unitId
    local integer index = LoadInteger(udg_ISS_Hashtable, GetItemTypeId(GetManipulatedItem()), 0)
    local integer level
    local integer abilityId
    local integer buffId
    local integer tooltip
 
    //The item is not attached to an item set.
    if index == 0 then
        return false
    endif
 
    set u = GetManipulatingUnit()
    set unitId = GetHandleId(u)
    set level = LoadInteger(udg_ISS_Hashtable, unitId, index) -1
    set abilityId = LoadInteger(udg_ISS_Hashtable, index, level*2 + 1)
    set buffId = LoadInteger(udg_ISS_Hashtable, index, level*2 +2)
    set tooltip = LoadInteger(udg_ISS_Hashtable, index, 0)
 
    call SaveInteger(udg_ISS_Hashtable, unitId, index, level)
 
    call UnitRemoveAbility(u, buffId)
    //Decrease the level of the tooltip.
    if GetUnitAbilityLevel(u, tooltip) > 1 then
        call SetUnitAbilityLevel(u, tooltip, level)
    else
        call UnitRemoveAbility(u, tooltip)
    endif
 
    //Decrease the level of the effect.
    if abilityId != 0 then
        if GetUnitAbilityLevel(u, abilityId) > 1 then
            call DecUnitAbilityLevel(u, abilityId)
        else
            call UnitRemoveAbility(u, abilityId)
        endif
    endif
 
    set u = null
    return false
endfunction

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//  This code is the function that this system has.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//This function saves the item-types and abilities on an item set.
function ISS_Create_Set takes nothing returns boolean
    //Requires:
    //  - ISS_Item_Type[]
    //  - ISS_Item_Type_Number
    //  - ISS_Ability[]
    //  - ISS_Ability_Number
    //  - ISS_Tooltip[]
 
    local integer i = 0
    local integer index = 0
 
    set udg_ISS_Param_Index = udg_ISS_Param_Index + 1
    call SaveInteger(udg_ISS_Hashtable, udg_ISS_Param_Index, 0, udg_ISS_Param_Tooltip)
 
    loop
        exitwhen i > udg_ISS_Param_Item_Type_Number
        call SaveInteger(udg_ISS_Hashtable, udg_ISS_Param_Item_Type_Array[i], 0, udg_ISS_Param_Index)
        set i = i + 1
    endloop
 
    set i = 0
    loop
        exitwhen i > udg_ISS_Param_Ability_Number*2
        call SaveInteger(udg_ISS_Hashtable, udg_ISS_Param_Index, i + 1, udg_ISS_Param_Ability_Array[index])
        call SaveInteger(udg_ISS_Hashtable, udg_ISS_Param_Index, i + 2, udg_ISS_Param_Buff_Array[index])
        set i = i + 2
        set index = index + 1
    endloop
 
    return false
endfunction

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//  This code is the initialization of the system and it's functions.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//This is the initial function.
function InitTrig_ISS_System takes nothing returns nothing
    local trigger t1 = CreateTrigger()
    local trigger t2 = CreateTrigger()
    local integer index = 0
    local player p
 
    set udg_ISS_Param_Index = 0
 
    call TriggerAddCondition(t1, Filter(function ISS_Add_Stack))
    call TriggerAddCondition(t2, Filter(function ISS_Remove_Stack))
 
    loop
        exitwhen index == bj_MAX_PLAYER_SLOTS
        set p = Player(index)
        call TriggerRegisterPlayerUnitEvent(t1, p, EVENT_PLAYER_UNIT_PICKUP_ITEM, null)
        call TriggerRegisterPlayerUnitEvent(t2, p, EVENT_PLAYER_UNIT_DROP_ITEM, null)

        set index = index + 1
    endloop
 
    set udg_ISS_Trigger_Create_Set = CreateTrigger()
    call TriggerAddCondition(udg_ISS_Trigger_Create_Set, Filter(function ISS_Create_Set))
    call TriggerAddAction(udg_ISS_Trigger_Create_Set, function ISS_Create_Set)
endfunction
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//  End of the gg_trg_ISS_System trigger.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

qtFHmt1.png

hvX0bxc.png


Changelog:
- 1.4 - 01/04/2015 - Optimization Update.
- 1.3 - 03/02/2015 - Update on review of IcemanBo, Edo494 and Mythic.
Merged the Save_Set and Save_Ability triggers to one Create_Set trigger.
Function names are smaller.
Local variable leaks removed
- 1.2 - Reworked the system.
Now all code is inside one trigger. Functions can be called using global variables.
- 1.1 - Uploaded this system to the Hive.

Feel free to post any feedback or suggestions.

Keywords:
Item Set, System, Item Group.
Contents

Just another Warcraft III map (Map)

Reviews
14:37, 17th Feb 2015 IcemanBo: Works as intended. http://www.hiveworkshop.com/forums/spells-569/item-set-system-gui-1-3-a-261702/index2.html#post2654436 00:5, 03th Feb 2015 IcemanBo...
Level 10
Joined
Aug 21, 2010
Messages
316
Very good. 4/5

One small suggestion:

All this can be only one function

JASS:
function Trig_ISS_Set_Abilities_Actions takes nothing returns nothing
    //Requires:
    //    - ISS_Index
    //    - ISS_Ability[]
    //    - ISS_Ability_Number
    //    - ISS_Tooltip[]
    
    local integer i = 0
    call SaveInteger(udg_ISS_Hashtable, udg_ISS_Index, 0, udg_ISS_Tooltip)
    loop
        exitwhen i > udg_ISS_Ability_Number
        call SaveInteger(udg_ISS_Hashtable, udg_ISS_Index, i + 1, udg_ISS_Ability_Array[i])
        set i = i + 1
    endloop
endfunction

//===========================================================================
function InitTrig_ISS_Set_Abilities takes nothing returns nothing
    set gg_trg_ISS_Set_Abilities = CreateTrigger()
    call TriggerAddAction(gg_trg_ISS_Set_Abilities, function Trig_ISS_Set_Abilities_Actions)
endfunction

function Trig_ISS_Set_Items_Actions takes nothing returns nothing
    //Requires:
    //    - ISS_Index
    //    - ISS_Item_Type[]
    //    - ISS_Item_Type_Number
    
    local integer i = 0
    loop
        exitwhen i > udg_ISS_Item_Type_Number
        call SaveInteger(udg_ISS_Hashtable, udg_ISS_Item_Type_Array[i], 0, udg_ISS_Index)
        set i = i + 1
    endloop
endfunction

//===========================================================================
function InitTrig_ISS_Set_Items takes nothing returns nothing
    set gg_trg_ISS_Set_Items = CreateTrigger()
    call TriggerAddAction(gg_trg_ISS_Set_Items, function Trig_ISS_Set_Items_Actions)
endfunction


also this

JASS:
function Trig_ISS_Add_Stack_Actions takes nothing returns nothing
    //Requires:
    //    - ISS_Unit
    //    - ISS_Item_Type
    
    local integer unitid = GetHandleId(udg_ISS_Unit)
    local integer index = LoadInteger(udg_ISS_Hashtable, udg_ISS_Item_Type, 0)
    local integer level = LoadInteger(udg_ISS_Hashtable, unitid, index)
    local integer abilityid = LoadInteger(udg_ISS_Hashtable, index, level + 1)
    local integer tooltip = LoadInteger(udg_ISS_Hashtable, index, 0)
    
    if index == 0 then
        return
    endif
    
    call SaveInteger(udg_ISS_Hashtable, unitid, index, level + 1)
    
    if GetUnitAbilityLevel(udg_ISS_Unit, tooltip) > 0 then
        call SetUnitAbilityLevel(udg_ISS_Unit, tooltip, level + 1)
    else
        call UnitAddAbility(udg_ISS_Unit, tooltip)
    endif
    
    if abilityid != 0 then
        if GetUnitAbilityLevel(udg_ISS_Unit, abilityid) > 0 then
            call IncUnitAbilityLevel(udg_ISS_Unit, abilityid)
        else
            call UnitAddAbility(udg_ISS_Unit, abilityid)
        endif
    endif
endfunction

//===========================================================================
function InitTrig_ISS_Add_Stack takes nothing returns nothing
    set gg_trg_ISS_Add_Stack = CreateTrigger()
    call TriggerAddAction(gg_trg_ISS_Add_Stack, function Trig_ISS_Add_Stack_Actions)
endfunction

function Trig_ISS_Remove_Stack_Actions takes nothing returns nothing
    //Requires:
    //    - ISS_Unit
    //    - ISS_Item_Type
    
    local integer unitid = GetHandleId(udg_ISS_Unit)
    local integer index = LoadInteger(udg_ISS_Hashtable, udg_ISS_Item_Type, 0)
    local integer level = LoadInteger(udg_ISS_Hashtable, unitid, index)
    local integer abilityid = LoadInteger(udg_ISS_Hashtable, index, level)
    local integer tooltip = LoadInteger(udg_ISS_Hashtable, index, 0)
    
    if index == 0 then
        return
    endif
    
    call SaveInteger(udg_ISS_Hashtable, unitid, index, level - 1)
    
    if GetUnitAbilityLevel(udg_ISS_Unit, tooltip) > 1 then
        call SetUnitAbilityLevel(udg_ISS_Unit, tooltip, level - 1)
    else
        call UnitRemoveAbility(udg_ISS_Unit, tooltip)
    endif
    
    if abilityid != 0 then
        if GetUnitAbilityLevel(udg_ISS_Unit, abilityid) > 1 then
            call DecUnitAbilityLevel(udg_ISS_Unit, abilityid)
        else
            call UnitRemoveAbility(udg_ISS_Unit, abilityid)
        endif
    endif
endfunction

//===========================================================================
function InitTrig_ISS_Remove_Stack takes nothing returns nothing
    set gg_trg_ISS_Remove_Stack = CreateTrigger()
    call TriggerAddAction(gg_trg_ISS_Remove_Stack, function Trig_ISS_Remove_Stack_Actions)
endfunction

Not necessarily, but as for me it would be much more efficient
As I've already said it is only a suggestion

And just one more thing
Also could be avoided constantly calling the same function

  • Trigger - Run ISS Set Abilities <gen> (ignoring conditions)
  • Trigger - Run ISS Set Items <gen> (ignoring conditions)
I have a similar system that works exactly as I suggested.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
@Mythic
"I actually have no idea what the hell you are talking about.
I also dont understand what nulling triggers has to do with the fact that I should know what events, conditions and actions are. Wrong link?"

Never mind that. I just read a little bit further and saw what you meant.
I will do that in the next update.
If I want to call those triggers, I cannot apply this am I right?

@zv27
- First one yes, I could have done that.
It was made like this because of the way how I started making this stuff.
- Second one... I don't understand what you meant.
Add or remove stacks are never done at the same time.
- Because I use arrays to set the data, I have to call that for every single item set. I could indeed as you said put the save items and save abilities in one trigger so every item set would only have one "Run (Trigger)" action instead of 2.
- BTW: Nice that you also have a system that works exacly as you suggested but then uploaded it in the spell section of the hive on your account... I cannot find it.

One last thing:
I just read some stuff about using conditions instead of actions in JASS and it sounds logic:
-----------------------------------
Event: Trigger is called.
If (All conditions are true) then
Run all actions.
-----------------------------------
Event: Trigger is called.
Run all conditions.
-----------------------------------
Logic enough for me.
But there is one thing that bothers me. One guy said that conditions handle wait timers different than actions.
Is that true and what difference is that then?

EDIT: Now I am confused:
If I use TriggerExecute() and "Run Ignoring conditions" (the same) is there any way actions can be slower than conditions when using TriggerEvaluate() and "Run Checking conditions"?
I know that regular events are still slower but how about that?

Also is it necessary to set hashtable values to null/0/false?
 
Last edited:
Level 33
Joined
Apr 24, 2012
Messages
5,113
You can even combine all of those Jass scripts in a single trigger. Trigger execution is done not in a whole code but it is done with only the handle.

Also, It is much faster to evaluate than to execute, Triggers executed are first evaluated then...executed obviously.


And it is not actually necessary to set hashtable values to null :)

You should also turn this:
  • Hashtable - Create a hashtable
    • Set ISS_Hashtable = (Last created hashtable)
to this:
  • Custom script : set udg_ISS_Hashtable = InitHashtable()
this way, it will be much faster.



You should also seperate the demo trigger from the initialization/configuration trigger.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Also, It is much faster to evaluate than to execute, Triggers executed are first evaluated then...executed obviously.

That is not true:
JASS:
function ConditionalTriggerExecute takes trigger trig returns nothing
    if TriggerEvaluate(trig) then
        call TriggerExecute(trig)
    endif
endfunction
TriggerExecute() is called without TriggerEvaluate().
ConditionalTriggerExecute is faster if you use conditions instead of actions and that action is called when an event fires.
So with events, it is faster. With custom call it is not or negligible.

In fact conditions might be slower because you have to filter them before it runs.
 
Level 33
Joined
Apr 24, 2012
Messages
5,113
That is not true:
JASS:
function ConditionalTriggerExecute takes trigger trig returns nothing
    if TriggerEvaluate(trig) then
        call TriggerExecute(trig)
    endif
endfunction
TriggerExecute() is called without TriggerEvaluate().
ConditionalTriggerExecute is faster if you use conditions instead of actions and that action is called when an event fires.
So with events, it is faster. With custom call it is not or negligible.

In fact conditions might be slower because you have to filter them before it runs.

TriggerEvaluate reads the condition afaik, so it is faster. So if you have a block of code in the condition function, it will be executed before it runs the Actions.
 
Code seems to be okay all in all. Still:

  • Local agents need to be nulled. unit in your case. Fix it.
  • TriggerCondtion could be used over TriggerAction in your case.
  • In JASS you write your own functions. One positive point with it is,
    you can change the name to your needs.
    function Trig_ISS_System_Add_Stack_Actions
    ... it works just fine, but such names are unnecessarily long. ->
    function AddStack ... would do just fine. I would change it.
  • You do not have to null triggers, that are never destroyed.
    Though it is not a bad habit to do so, but it's useless.
  • Currently you split item and ability registration and have to run two triggers.
    It would also make sense for me just to make all settings (abilities + items),
    and then call like a "RegisterItemSet" trigger that will handle both: ability + item registration.
    Though it would cut one not needed trigger. Think about it.
  • The ISS Init trigger should be moved in the system folder, as it obvisouly belongs to the system.

Usage of the system seems fair and useful. It is nice that you care much of documentation of your code.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
TriggerCondtion could be used over TriggerAction in your case.

You should explain that to me.
I understand that
JASS:
function ConditionalTriggerExecute takes trigger trig returns nothing
    if TriggerEvaluate(trig) then
        call TriggerExecute(trig)
    endif
endfunction
Is slower than
native TriggerEvaluate takes trigger whichTrigger returns boolean

but how can you ever know that
native TriggerEvaluate takes trigger whichTrigger returns boolean
is faster than
native TriggerExecute takes trigger whichTrigger returns nothing
???

When you create a trigger with an event, you should use conditions, ok.
When you create a trigger without an event and is only called via triggers, I actually believe that actions could be faster. At least you got the possibility to add another action to it.

Take a look at this:
1ZEsfqs.png

This is how I would make the triggerEvaluate and triggerExecute. (I would make new threads ofcourse for catching exceptions but that would not make a difference between the two functions.
If Blizzard wrote those natives properly, the TriggerExecute will always be faster than TriggerEvaluate (and safer)

So either I am wrong (and Blizzard can go back to school) or TriggerExecute is faster than TriggerEvaluate.
Which one is true?

(If they are equal as fast than TriggerExecute has one less character and thus saves one character in code length... Now I am being too precise :D)

You do not have to null triggers, that are never destroyed.
Though it is not a bad habit to do so, but it's useless.
I only null a local variable... which must be nulled right?

In JASS you write your own functions. One positive point with it is,
you can change the name to your needs.
function Trig_ISS_System_Add_Stack_Actions
... it works just fine, but such names are unnecessarily long. ->
function AddStack ... would do just fine. I would change it.
So... Here is the deal:
Someone wants to have item sets in his game and uses my system... ok.
Then he also wants to have a system where units have stackable abilities (or whatever).
The system he uses for the stacking abilities also has a function called AddStack()... Now you got 2 AddStack() functions... which JASS cannot handle.
I have been tought to make unique names for my functions so I use the regular Blizzard idea of placing "Trig_Trigger_Name_" before the function name...
I could remove the "_Actions" part but wont remove more than that... sorry.


  • Local agents need to be nulled. unit in your case. Fix it.
  • Currently you split item and ability registration and have to run two triggers.
    It would also make sense for me just to make all settings (abilities + items),
    and then call like a "RegisterItemSet" trigger that will handle both: ability + item registration.
    Though it would cut one not needed trigger. Think about it.
  • The ISS Init trigger should be moved in the system folder, as it obvisouly belongs to the system.
Will do.
 
I did not mention it was a trigger execute call. You can just stay to it, it's fine.

"ISS_AddStack" would still improve it. You do not really need the "trig" + " actions" in the name.
Though you can stay to it if you want, it is just a suggestion.

Nulling triggers is a exception. Well, at least statics.
You will never destroy them, and things that are never removed/destroyed don't need to be nulled.
That is also the reason why players don't need to be nulled.
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
they work a lot differently than you think.

The Virtual machine that runs Jass is not just as easy as that, triggeractions need to support wait, while triggerconditions doesnt, so that means there is some subtle difference between these.

Also, your code for conditions is wrong, since even if my condition returns false, it will evaluate all of them before deciding if it should run actions.

Disambiguate your function names, since Jass only has one scope, you can not declare things as private to certain scope, therefore you must make unique names for functions, and global variables for your system. Thats why everyone preplaces their system's things with shortcut of the system, e.g. DDS_stuff, CSS_stuff etc.

And no it may not be from system, but AddStack is very general, and the one that wants to use your system may already have function like this in his own code, and what is he going to do if he sees this? He will either change your function's name, which you should've done, or he will throw the system away.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Update 1.4

I just released version 1.4

Here are the changes:
  • Fixed double-buff-bug by adding buff removal and buff configuration.
  • Now automatically creates index numbers.
  • Fixed a few leaks and optimized code a bit.
  • Added condition to triggers for people who want to use TriggerEvaluate() instead of TriggerExecute().
 
Level 7
Joined
Aug 11, 2010
Messages
269
Hey, I love your systems however I'm having trouble with this. I tried out the demo map and the elite set consistently bugs if you pick up all the pieces and then drop them to pick them up again.

Not sure why it does this but... It's unfortunate.
 
Top