• 🏆 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!

stored item gets removed?

Status
Not open for further replies.
Level 12
Joined
Jan 13, 2008
Messages
559
  • use anvil
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Use Anvil
      • ((Triggering unit) has an item of type Battle Axe) Equal to True
    • Actions
      • Set strenghted_itemcount = (strenghted_itemcount + 1)
      • Set strenghted_items[strenghted_itemcount] = (Item carried by (Triggering unit) in slot 1)
      • Game - Display to (All players) the text: (strenghted_items + ((String(strenghted_itemcount)) + (] = + (Name of (Item carried by (Triggering unit) in slot 1)))))
      • Hero - Drop the item from slot 1 of (Triggering unit)
The debug msg shows : strengthted_items[1] = Battle Axe
So far so good.

Now when I equip said item, i should receive a dmg bonus but for some reason the item is not stored anymore?

  • equip strenghted weapon
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to Battle Axe
        • Then - Actions
          • For each (Integer strenghtedInt) from 1 to strenghted_itemcount, do (Actions)
            • Loop - Actions
              • Game - Display to (All players) the text: (strenghted_items[ + ((String(strenghtedInt)) + (] = + (Name of strenghted_items[strenghtedInt]))))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Item carried by (Triggering unit) of type Battle Axe) Equal to strenghted_items[strenghtedInt]
                • Then - Actions
                  • Game - Display to (All players) the text: works
                  • Unit - Create 1 strenghten sword (dummy) for Neutral Passive at (Position of (Triggering unit)) facing Default building facing degrees
                  • Unit - Order (Last created unit) to Human Priest - Inner Fire (Triggering unit)
                  • Unit - Add a 1.50 second Generic expiration timer to (Last created unit)
                  • Skip remaining actions
                • Else - Actions
        • Else - Actions
dbg message shows: strengthted_items[1] =
so it's basicaly just empty. Any idea why?
 
Level 12
Joined
Jan 13, 2008
Messages
559
In both cases the strenghted_itemcount and strenghtedInt are 1. The first trigger fires before the second obviously :p

What the trigger is doing/is supposed to do:
  1. Put an item into the anvil and strenghten it (use the "use anvil" ability)
  2. The item gets stored in an array with "itemcount"-index which I increment by 1 after a use. So the first strenghted item will be stored in strenghtedItems[1], the second in strenghtedItems[2] etc.
  3. When the hero uses the item, he will be replaced with a certain unit (which is what you see in the second trigger). If a hero uses the Battleaxe item, the hero will be replaced with a Battleaxe hero (aka "Battleaxe enters playable map area, which triggers the event of the second trigger)
  4. I then check if the hero carries a strenghted item by comparing all stored items with every item the hero is currently carrying.
  5. If the above condition is true then I give the hero a bonus dmg effect.
The problem is that when the second trigger fires, the array seems to be empty??!
 
Last edited:
Level 21
Joined
Dec 4, 2007
Messages
1,487
like streetpunk mentioned before, strenghtedInt is nowhere correlated with strenghted_items?!

you only did so with Set strenghted_itemcount = (strenghted_itemcount + 1) in trigger 1

so where is strenghtedInt setup?
 
Level 8
Joined
Jan 28, 2016
Messages
486
@A]mun @streetpunk The issue isn't with the integer variable in the loop. Check the spoiler for more info.

  • For Loop
    • Events
      • Time - Elapsed game time is 5.00 seconds
    • Conditions
    • Actions
      • For each (Integer TempInteger) from 1 to 10, do (Actions)
        • Loop - Actions
          • Game - Display to (All players) the text: (Temp Integer = + (String(TempInteger)))
The above trigger will print out the numbers from 1 to 10, as intended. The GUI For Loop sets the variable to the minimum (in this case 1) before running the loop actions. Here's the Jass version, which should make it easier to see what's going on.

JASS:
function Trig_For_Loop_Actions takes nothing returns nothing
    set udg_TempInteger = 1 //Sets the variable to the min value
    loop
        exitwhen udg_TempInteger > 10 //Loop will end once the variable is greater than the max
        call DisplayTextToForce( GetPlayersAll(), ( "Temp Integer = " + I2S(udg_TempInteger) ) )
        set udg_TempInteger = udg_TempInteger + 1 //Adds one to the variable and restarts the loop
    endloop
endfunction

//===========================================================================
function InitTrig_For_Loop takes nothing returns nothing
    set gg_trg_For_Loop = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( gg_trg_For_Loop, 5 )
    call TriggerAddAction( gg_trg_For_Loop, function Trig_For_Loop_Actions )
endfunction

@Nordmar When you say that you're replacing the unit, are you using the GUI "Replace" action? If so, that might be the cause of why your array is losing reference of the stored item.
 
Level 12
Joined
Jan 13, 2008
Messages
559
@A]mun @streetpunk The issue isn't with the integer variable in the loop. Check the spoiler for more info.


@Nordmar When you say that you're replacing the unit, are you using the GUI "Replace" action? If so, that might be the cause of why your array is losing reference of the stored item.

Hm, maybe but the trigger works fine with other items tho which confuses me the most.
 
Level 8
Joined
Jan 28, 2016
Messages
486
Are there any other triggers involving the array? I created these triggers yesterday to test out my theory and they worked, so yours should too.

  • Replace
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Replace
    • Actions
      • For each (Integer TempInteger) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item carried by (Triggering unit) in slot TempInteger) Not equal to No item
            • Then - Actions
              • Set Inventory[TempInteger] = (Item carried by (Triggering unit) in slot TempInteger)
              • Game - Display to (All players) the text: (Name of Inventory[TempInteger])
              • Hero - Drop the item from slot TempInteger of (Triggering unit)
            • Else - Actions
              • Set Inventory[TempInteger] = No item
              • Game - Display to (All players) the text: (Name of Inventory[TempInteger])
      • Unit - Replace (Triggering unit) with a Ancient Wendigo using The old unit's relative life and mana
  • Item Check
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Ancient Wendigo
    • Actions
      • For each (Integer TempInteger) from 1 to 6, do (Actions)
        • Loop - Actions
          • Game - Display to (All players) the text: (Name of Inventory[TempInteger])
 
Level 12
Joined
Jan 13, 2008
Messages
559
Are there any other triggers involving the array? I created these triggers yesterday to test out my theory and they worked, so yours should too.

  • Replace
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Replace
    • Actions
      • For each (Integer TempInteger) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item carried by (Triggering unit) in slot TempInteger) Not equal to No item
            • Then - Actions
              • Set Inventory[TempInteger] = (Item carried by (Triggering unit) in slot TempInteger)
              • Game - Display to (All players) the text: (Name of Inventory[TempInteger])
              • Hero - Drop the item from slot TempInteger of (Triggering unit)
            • Else - Actions
              • Set Inventory[TempInteger] = No item
              • Game - Display to (All players) the text: (Name of Inventory[TempInteger])
      • Unit - Replace (Triggering unit) with a Ancient Wendigo using The old unit's relative life and mana
  • Item Check
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Ancient Wendigo
    • Actions
      • For each (Integer TempInteger) from 1 to 6, do (Actions)
        • Loop - Actions
          • Game - Display to (All players) the text: (Name of Inventory[TempInteger])

hm, there is a item stack system..this might be the problem but i made it work differentely so its all good now. Thanks
 
Status
Not open for further replies.
Top