• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Trigger] Creating unit after acquiring multiple same items

Status
Not open for further replies.
Level 4
Joined
Dec 12, 2012
Messages
96
OK, so this is my first post on this site and kinda frustrated working on a trigger for a certain event.

I'm trying to create a hero for whoever completes or acquires 6 items of the same type. This hero will be created for the owner of the acquiring unit and at the position of that acquiring unit.

I had this new trigger based on some post I found somewhere on the net but it doesn't work for me.


  • Maltheo II
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Crown of Archimonde +10000
    • Actions
      • Set Item_ArchInt = 0
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item carried by Item_Arch_Hero in slot Item_ArchInt)) Equal to Crown of Archimonde +10000
            • Then - Actions
              • Set Item_ArchInt = (Item_ArchInt + 1)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Item_ArchInt Equal to 6
        • Then - Actions
          • Item - Remove (Item carried by (Triggering unit) of type Crown of Archimonde +10000)
          • Item - Remove (Item carried by (Triggering unit) of type Crown of Archimonde +10000)
          • Item - Remove (Item carried by (Triggering unit) of type Crown of Archimonde +10000)
          • Item - Remove (Item carried by (Triggering unit) of type Crown of Archimonde +10000)
          • Item - Remove (Item carried by (Triggering unit) of type Crown of Archimonde +10000)
          • Item - Remove (Item carried by (Triggering unit) of type Crown of Archimonde +10000)
          • Unit - Create 1 Maltheo for (Owner of Item_Arch_Hero) at (Position of Item_Arch_Hero) facing Default building facing degrees
        • Else - Actions

I had two triggers before that one and they work but not properly.
  • MaltheoA
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • ((Triggering unit) has an item of type Crown of Archimonde +10000) Equal to True
    • Actions
      • Set Item_Arch1 = (Item_Arch1 + 1)
      • Set Item_Arch_Hero = (Triggering unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Item_Arch1 Equal to 6
        • Then - Actions
          • Item - Remove (Item carried by Item_Arch_Hero in slot 1)
          • Item - Remove (Item carried by Item_Arch_Hero in slot 2)
          • Item - Remove (Item carried by Item_Arch_Hero in slot 3)
          • Item - Remove (Item carried by Item_Arch_Hero in slot 4)
          • Item - Remove (Item carried by Item_Arch_Hero in slot 5)
          • Item - Remove (Item carried by Item_Arch_Hero in slot 6)
          • Unit - Create 1 Maltheo for (Owner of Item_Arch_Hero) at (Position of Item_Arch_Hero) facing Default building facing degrees
        • Else - Actions

  • MaltheoB
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • (Item-type of (Item being manipulated)) Equal to Crown of Archimonde +10000
          • (Triggering unit) Equal to Item_Arch_Hero
    • Actions
      • Set Item_Arch1 = (Item_Arch1 - 1)
Item_ArchInt is an Integer variable
Item_Arch1 is also an integer variable
Item_Arch_Hero is a unit variable


MaltheoA - Acquiring the item, everytime the unit acquires the item, the int variable which is initially set on 0 are then added by 1 on loop.

MaltheoB - Losing/Dropping the item, the int variable is decreased by 1

The problem on these triggers (MaltheoA & MaltheoB) is that acquiring the item, REGARDLESS of whatever units acquire it, adds up to the int variable. So taking for example UnitA acquires 3 items of the same type and UnitB acquires the item with same number and type, the last one to acquire the 6th item gets the Price.

This is somehow similar to the Dota item Orchid Malevolence, but here the unit is created, not the item.

I hope I explained it carefully here, if not please tell me so. :) Hope somebody can help.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
In the first trigger, the problem might be the condition:
  • (Item-type of (Item carried by Item_Arch_Hero in slot Item_ArchInt)) Equal to Crown of Archimonde +10000
The variable "Item_ArchInt" (used as the slot) is 0 at the start, and will always be 0 the rest of the loop (the condition is never true).
You need to change that with "Integer A".
The variable "Item_ArchHero" is also not set up (and completely obsolete, use "Triggering Unit" instead).

Do you also need help with the other 2 triggers if the first one works correctly? :p
I'm a bit lazy...

Edit: Oh, this is a shorter version by the way (but only works for 6 items, not less).
  • Melee Initialization
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Claws of Attack +15
    • Actions
      • For each (Integer tempInt) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item carried by (Triggering unit) in slot tempInt)) Equal to Claws of Attack +15
            • Then - Actions
            • Else - Actions
              • Skip remaining actions
      • For each (Integer tempInt) from 1 to 6, do (Actions)
        • Loop - Actions
          • Item - Remove (Item carried by (Triggering unit) in slot tempInt)
      • Hero - Create Crown of Kings +5 and give it to (Triggering unit)
And if you've got many recipes like this, do consider a recipe system :).
 
Last edited:
Level 4
Joined
Dec 12, 2012
Messages
96
The variable "Item_ArchHero" is also not set up (and completely obsolete, use "Triggering Unit" instead).

Oh yeah, I tried setting the variable Item_ArchHero = Unit but still didn't work.
Do you also need help with the other 2 triggers if the first one works correctly? :p
I'm a bit lazy...
It's alright, I just want any trigger for this to work ;)
Edit: Oh, this is a shorter version by the way (but only works for 6 items, not less).
  • Melee Initialization
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Claws of Attack +15
    • Actions
      • For each (Integer tempInt) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item carried by (Triggering unit) in slot tempInt)) Equal to Claws of Attack +15
            • Then - Actions
            • Else - Actions
              • Skip remaining actions
      • For each (Integer tempInt) from 1 to 6, do (Actions)
        • Loop - Actions
          • Item - Remove (Item carried by (Triggering unit) in slot tempInt)
      • Hero - Create Crown of Kings +5 and give it to (Triggering unit)

Okay, so I tried recreating this into two triggers, both of them worked but the first one only requires 5 of the same items while the 2nd one worked perfectly.

1st:
  • Maltheo II
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Crown of Archimonde +10000
    • Actions
      • Set Item_ArchInt = 1
      • For each (Integer Item_ArchInt) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item carried by (Triggering unit) in slot Item_ArchInt)) Equal to Crown of Archimonde +10000
            • Then - Actions
              • Set Item_ArchInt = (Item_ArchInt + 1)
            • Else - Actions
              • Skip remaining actions
      • Set Item_ArchInt = 1
      • For each (Integer Item_ArchInt) from 1 to 6, do (Actions)
        • Loop - Actions
          • Item - Remove (Item carried by (Triggering unit) in slot Item_ArchInt)
      • Unit - Create 1 Maltheo for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing Default building facing degrees
I used Item_ArchInt = 1 as integer variable for the First For Loop and setting it to 1 again for the Second For Loop

2nd:
  • Maltheo IIB
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Crown of Archimonde +10000
    • Actions
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item carried by (Triggering unit) in slot (Integer A))) Equal to Crown of Archimonde +10000
            • Then - Actions
            • Else - Actions
              • Skip remaining actions
      • For each (Integer B) from 1 to 6, do (Actions)
        • Loop - Actions
          • Item - Remove (Item carried by (Triggering unit) in slot (Integer B))
      • Unit - Create 1 Maltheo for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing Default building facing degrees
This one is ran by Integer A and Integer B only and worked perfectly. THANKS A LOT! This is exactly what I need. :p

And if you've got many recipes like this, do consider a recipe system :).
This is the only item recipe in my map that requires same items. :)
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
1st:
  • Maltheo II
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Crown of Archimonde +10000
    • Actions
      • Set Item_ArchInt = 1
      • For each (Integer Item_ArchInt) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item carried by (Triggering unit) in slot Item_ArchInt)) Equal to Crown of Archimonde +10000
            • Then - Actions
              • Set Item_ArchInt = (Item_ArchInt + 1)
            • Else - Actions
              • Skip remaining actions
      • Set Item_ArchInt = 1
      • For each (Integer Item_ArchInt) from 1 to 6, do (Actions)
        • Loop - Actions
          • Item - Remove (Item carried by (Triggering unit) in slot Item_ArchInt)
      • Unit - Create 1 Maltheo for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing Default building facing degrees
Loops automatically set the variable you're going to loop, so when Warcraft converts the code to something it can read, it will look something like this:
JASS:
set udg_Item_ArchInt = 1
set udg_Item_ArchInt = 1
// (Here comes the actual loop and all the rest)
It's also a bad idea to use the same variable you're looping (here: "Item_ArchInt") in the loop itself, unless you specifically want to change the loop.
I'm actually surprised this works at all, it should miserably fail when I look at it :p (at least if this is really for 5 items, not 6).
 
Level 4
Joined
Dec 12, 2012
Messages
96
Loops automatically set the variable you're going to loop, so when Warcraft converts the code to something it can read

Somehow, I'm still a little confused about this for loop and still haven't understood fully how that trigger works but as long as it works perfectly, I won't mind for the meantime.

It's also a bad idea to use the same variable you're looping (here: "Item_ArchInt") in the loop itself, unless you specifically want to change the loop.
I'm actually surprised this works at all, it should miserably fail when I look at it :p (at least if this is really for 5 items, not 6).

I'll keep this one in mind. I just didn't want to create more variables to lessen my confusion on my own map :grin: so i thought of using the same variable here. :)

Anyway, +repu for you. :thumbs_up:
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Somehow, I'm still a little confused about this for loop and still haven't understood fully how that trigger works but as long as it works perfectly, I won't mind for the meantime.
That's exactly the problem: it doesn't work :p.
I can try to explain this by using JASS (the actual language for Warcraft 3), but I don't know how understandable that will be.

This:
  • For each (Integer tempInt) from 1 to 6, do (Actions)
    • Loop - Actions
Converts to this:
JASS:
set udg_tempInt = 1
loop
    exitwhen udg_tempInt > 6
    set udg_tempInt = udg_tempInt + 1
endloop
For me this is a lot more clear, because you always know when the loop will end (when the exitwhen-condition is met).

Loops just repeat the code inside them until a certain condition is met.
In your trigger, that condition is "Item_ArchInt is greater than 6". If that is true, the loop will end.
But you change that variable while looping. That's a problem.
Your code will look like this:

JASS:
set udg_tempInt = 1
loop
    exitwhen udg_tempInt > 6
    set udg_tempInt = udg_tempInt + 1
    set udg_tempInt = udg_tempInt + 1
endloop
See that? You're actually increasing the variable by 2 every time, not 1.
So it goes 1 -> 3 -> 5. After that it becomes greater than 6, so the loop ends.
It only loops 3 times! Not 5.

So why does it look like it works?
As you can see from the order it checks in (1 -> 3 -> 5), the correct items need to be in those 3 slots.
If you just pick up 5 of those items, it will work (because slot 1, 3 and 5 will be filled with the correct item).
However, if you pick up any other item before that, or if you move the items to slot 3 and 5 and then pick up a new one (that goes to slot 1), it will also work.
Or it will fail if item 1, 3, or 5 contains a different item.


Long story short: it really doesn't work, you should use your initial trigger for that (after fixing what I said in my first post).
 
Level 4
Joined
Dec 12, 2012
Messages
96
You're absolutely right, It only needs to be at the slot 1, 3 & 5. But I really don't get it since this is the way I understand the order:

Code:
Item_ArchInt is equal to 1
FOR Item_ArchInt is 1, check condition (TRUE), Item_ArchInt = 1 + 1 hence 2
FOR Item_ArchInt is 2, check condition (TRUE), Item_ArchInt = 2 + 1 hence 3
FOR Item_ArchInt is 3, check condition (TRUE), Item_ArchInt = 3 + 1 hence 4
FOR Item_ArchInt is 4, check condition (TRUE), Item_ArchInt = 4 + 1 hence 5
FOR Item_ArchInt is 5, check condition (TRUE), Item_ArchInt = 5 + 1 hence 6
This is not exactly a code, this is just the way i see the order of the 1st Loop.

Wait, I just noticed at the 2nd loop, I didn't put Item_ArchInt = Item_ArchInt + 1 on the Action but it still looped. Does that mean that in the 1st Loop, I actually added TWO Item_ArchInt = Item_ArchInt + 1? Hence making it +2?

I didn't really get that JASS you made 'cause I don't have any background in it but I do somehow get the concept of the For Loop.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Wait, I just noticed at the 2nd loop, I didn't put Item_ArchInt = Item_ArchInt + 1 on the Action but it still looped. Does that mean that in the 1st Loop, I actually added TWO Item_ArchInt = Item_ArchInt + 1? Hence making it +2?

[JASS script]
See that? You're actually increasing the variable by 2 every time, not 1.
So you're completely right :). Because it increases by 2 (not 1), the trigger skips slot 2, 4 and 6.
I already thought you might not understand the JASS-scripts. I find it easier because you can actually see when exactly the loop ends (which isn't the case in GUI), but if you're not familiar with JASS (or another programming language), then it's pretty vague indeed.

So can you modify the first trigger in your first post to make it work for the recipe with 5 items?
(I explained it in my first post, but there might be something else).
 
May I suggest a little different approach, you see, your system has some bad things like:
- Max 6 items
- You take whole inventory

I suggest next:
Make item active, something like Potion items.
When you use item (or some different type of it), just increase number [ or if type array ] like this:
set Counter [ ItemType ] = Counter [ ItemType ] + 1

then with simple if the else you detect for that Counter [ ItemType ] how many items you need to consume to create unit or do anything you want, then you simply set it again back to 0.
set Counter [ ItemType ] = 0

You see this way you have far more possibilities and you can even split this for single unit as well using hashtables, where you do next:

SaveInteger ( hash, unitHandleId, itemTypeId, value)

If you need more explanation, and found this idea more attractive and useful, I can provide test map, GUI, jass or any thing you need.
 
Level 4
Joined
Dec 12, 2012
Messages
96
So you're completely right :). Because it increases by 2 (not 1), the trigger skips slot 2, 4 and 6.
I already thought you might not understand the JASS-scripts. I find it easier because you can actually see when exactly the loop ends (which isn't the case in GUI), but if you're not familiar with JASS (or another programming language), then it's pretty vague indeed.

I'm familiar with C and C++ that's why i got confused with the For Loop, but just now i realized that so far i've been treating these For Loop Triggers as While and Do-While functions and that's why i keep putting in increments inside the for loop. I forgot that For Loops already contains Assignment, How many times it'll repeat and Increment; and that thing you posted made my understanding with For Loop clearer. Now I think I know how to use this for loop trigger right. Thanks :)

So can you modify the first trigger in your first post to make it work for the recipe with 5 items?
(I explained it in my first post, but there might be something else).
If you meant keeping the same variable in a trigger, I did. I just removed the
Action in the first loop which is Item_ArchInt = Item_ArchInt + 1 and it worked perfectly fine.

  • Maltheo II
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Crown of Archimonde +10000
    • Actions
      • Set Item_ArchInt = 1
      • For each (Integer Item_ArchInt) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item carried by (Triggering unit) in slot Item_ArchInt)) Equal to Crown of Archimonde +10000
            • Then - Actions
            • Else - Actions
              • Skip remaining actions
      • Set Item_ArchInt = 1
      • For each (Integer Item_ArchInt) from 1 to 6, do (Actions)
        • Loop - Actions
          • Item - Remove (Item carried by (Triggering unit) in slot Item_ArchInt)
      • Unit - Create 1 Maltheo for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing Default building facing degrees
May I suggest a little different approach, you see, your system has some bad things like:
- Max 6 items
- You take whole inventory

I suggest next:
Make item active, something like Potion items.
When you use item (or some different type of it), just increase number [ or if type array ] like this:
set Counter [ ItemType ] = Counter [ ItemType ] + 1

then with simple if the else you detect for that Counter [ ItemType ] how many items you need to consume to create unit or do anything you want, then you simply set it again back to 0.
set Counter [ ItemType ] = 0

You see this way you have far more possibilities and you can even split this for single unit as well using hashtables, where you do next:

SaveInteger ( hash, unitHandleId, itemTypeId, value)

If you need more explanation, and found this idea more attractive and useful, I can provide test map, GUI, jass or any thing you need.

If I understand it right, making that item perishable might possibly result to something unlikely during the game like accidentally clicking on it without intending to and just thinking how valuable that item was and how it was acquired will be quite disappointing for the gamer. But this very idea you suggested is interesting and I already thought of events where I might apply this thing. I've never used hashtable before but I want to learn how this would work. And yes if it's alright, please provide me a test map, that way I can study it. Thanks :)
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
@Kobas: I don't agree with that. You would be right for a larger amount of combinations, but that doesn't seem to be the case here. Also, having to manually activate these items makes it less dynamic.
Of course, that is just my opinion and I can only represent myself.
Great to see you're still helping people though :D.


@Maltheo: Hashtables are extremely useful and powerful, so it would be a good thing for you to pick up on those :).
Of course, there are some things that you shouldn't really do (with great power ... ), but you'll learn that as you go.
 
The most simple system:
JASS:
library ItemLib initializer Init uses RegisterPlayerUnitEvent

    globals
        /* Hashtable initializer */
        private hashtable HASH = InitHashtable()
        /* Number of green items needed for summon */
        private integer MAX_GREEN = 7
        /* Number of blue items needed for summon */
        private integer MAX_BLUE  = 3
        /* Green Drake Raw Code */
        private integer SUMMON_GREEN = 'ngdk'
        /* Blue Dragon Raw Code */
        private integer SUMMON_BLUE  = 'nadr'
        /* Green Item Raw Code */
        private integer ITEM_GREEN = 'I000'
        /* Blue Item Raw Code */
        private integer ITEM_BLUE  = 'I001'
    endglobals
    
    private function Run takes nothing returns nothing
        local unit    caster  = GetTriggerUnit()
        local item    it      = GetManipulatedItem()
        local integer id      = GetItemTypeId(it)
        local integer counter = LoadInteger(HASH, GetHandleId(caster), id)
        
        if id == ITEM_GREEN then
            set counter = counter + 1
            
                call BJDebugMsg(GetUnitName(caster) + " with ID: " + I2S(GetHandleId(caster)) + " has picked green item: " + I2S(counter) + " times"  )
            
            if counter == MAX_GREEN then
                set counter = 0
                call CreateUnit(GetOwningPlayer(caster), SUMMON_GREEN, GetUnitX(caster), GetUnitY(caster), 0.00)
            endif
        elseif id == ITEM_BLUE then
            set counter = counter + 1
            
                call BJDebugMsg(GetUnitName(caster) + " with ID: " + I2S(GetHandleId(caster)) + " has picked blue item: " + I2S(counter) + " times"  )
            
            if counter == MAX_BLUE then
                set counter = 0
                call CreateUnit(GetOwningPlayer(caster), SUMMON_BLUE, GetUnitX(caster), GetUnitY(caster), 0.00)
            endif
        endif
        
        call SaveInteger(HASH, GetHandleId(caster), id, counter)
        set caster = null
        set it = null
    endfunction
    
    private function Init takes nothing returns nothing
        call RegisterPlayerUnitEvent(EVENT_PLAYER_UNIT_USE_ITEM, function Run)
    endfunction
endlibrary
For more item types, you should use same hash first to register items, max charges and so on in it , then load this as well.
You can make this possible for only some unit type, or unit handle itself.

Can show you this as well.
 

Attachments

  • test.w3x
    22 KB · Views: 74
If you meant keeping the same variable in a trigger, I did. I just removed the
Action in the first loop which is Item_ArchInt = Item_ArchInt + 1 and it worked perfectly fine.

  • Maltheo II
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Crown of Archimonde +10000
    • Actions
      • Set Item_ArchInt = 1
      • For each (Integer Item_ArchInt) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item carried by (Triggering unit) in slot Item_ArchInt)) Equal to Crown of Archimonde +10000
            • Then - Actions
            • Else - Actions
              • Skip remaining actions
      • Set Item_ArchInt = 1
      • For each (Integer Item_ArchInt) from 1 to 6, do (Actions)
        • Loop - Actions
          • Item - Remove (Item carried by (Triggering unit) in slot Item_ArchInt)
      • Unit - Create 1 Maltheo for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing Default building facing degrees
You've also made another mistake if you don't mind pointing out. Although with loops when you are using GUI the loop always resets itself, meaning that the variable that the loop is using gets set to the from what you have already assigned it to. You don't need to to reset the variable to where you need to be if you are using the loop with that variable strait after.
Also replace Owner of(Triggering Unit) with Triggering Player, it's more efficient.

Long Story short your trigger should look more like this.
  • Maltheo II
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Crown of Archimonde +10000
    • Actions
      • For each (Integer Item_ArchInt) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item carried by (Triggering unit) in slot Item_ArchInt)) Equal to Crown of Archimonde +10000
            • Then - Actions
            • Else - Actions
              • Skip remaining actions
      • For each (Integer Item_ArchInt) from 1 to 6, do (Actions)
        • Loop - Actions
          • Item - Remove (Item carried by (Triggering unit) in slot Item_ArchInt)
      • Unit - Create 1 Maltheo for (Triggering Player)) at (Position of (Triggering unit)) facing Default building facing degrees
 
Also replace Owner of(Triggering Unit) with Triggering Player, it's more efficient.
Those 2 aren't same, triggering player refers to player (with/without unit) events while unit to unit events, sometimes those 2 match, but that's not always the case.

I know I had problem with this few years ago, dunno maybe latest JNPG calculate this nicely or whatever.
But if there is no need I would recommend using them separably.
 
Level 4
Joined
Dec 12, 2012
Messages
96
For more item types, you should use same hash first to register items, max charges and so on in it , then load this as well.
You can make this possible for only some unit type, or unit handle itself.

Sounds easy but seems sophisticated on JASS. Well, guess i'll take a leap on learning JASS now. :) Thanks for this whole thing, +repu for you. ;)

You've also made another mistake if you don't mind pointing out. Although with loops when you are using GUI the loop always resets itself, meaning that the variable that the loop is using gets set to the from what you have already assigned it to. You don't need to to reset the variable to where you need to be if you are using the loop with that variable strait after.
Also replace Owner of(Triggering Unit) with Triggering Player, it's more efficient.

So by default, you mean the initial number declared in the For Loop (in this case is the integer 1) is automatically set as the value of Item_ArchInt? That's another helpful info.

Event Response - Triggering Player? I didn't notice it on Trigger until now. I think I have a quick grasp on the difference between Triggering Player and Triggering Unit but I believe it can get broader than that.

it may be better to just do it with GUI and not use anything that requires JNGP.
Also, I don't like private hashtables :D.

JASS is that thing when you convert the trigger into custom text right? And it reminds me of Visual Basic. :)
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
So by default, you mean the initial number declared in the For Loop (in this case is the integer 1) is automatically set as the value of Item_ArchInt? That's another helpful info.
Loops automatically set the variable you're going to loop [...]
Yep!

JASS is that thing when you convert the trigger into custom text right?
Indeed, it is :).
And yeah, it does have some similarities with Visual Basic. Didn't really notice that before :p.
 
Event Response - Triggering Player? I didn't notice it on Trigger until now. I think I have a quick grasp on the difference between Triggering Player and Triggering Unit but I believe it can get broader than that.
Yeh in this situation Triggering Player and Owner Of(Triggering Unit) are the same although anything other than Owner Of(Triggering Unit) doesn't compile with Triggering Player. This is just an easier, whilst more efficient way.
Just remember if the even that you want your unit to respond from isn't found to be a triggering unit Get Triggering Player wont work.
__

You might also want to consider learning about leaks.
 
Status
Not open for further replies.
Top