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

[Trigger] [Reforfed] Increasing stacks that have indexarray not working [Possibly a bug]

Status
Not open for further replies.
Level 12
Joined
Feb 5, 2018
Messages
521
  • TEST
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Set VariableSet TEMP = (TEMP + 1)
      • Set VariableSet StackCount[TEMP] = (StackCount[TEMP] + 1)
      • Game - Display to (All players) the text: (String(StackCount[TEMP]))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • StackCount[TEMP] Equal to 10
        • Then - Actions
          • Game - Display to (All players) the text: ---END OF COUNT---
          • Set VariableSet StackCount[TEMP] = 0
          • Set VariableSet TEMP = 0
          • Trigger - Turn off (This trigger)
          • Trigger - Turn on (This trigger)
        • Else - Actions
This is related to my previous post. I am trying to make a statement here. I really think the code is broken in reforged editor at least for this part.

This is a completely clear map. It has nothing in it at all, except for one start location and that's it.

The StackCount[TEMP] remains at 1(one).

Anyone with classic editor could open this and check it out? All my old warcraft 3 clients, including the editor are gone after downloading the released version of reforged.

I included a test map so people can try this with their reforged editor and/or with classic editor.
 

Attachments

  • TESTMap.w3m
    16.5 KB · Views: 28
Level 25
Joined
Sep 26, 2009
Messages
2,378
This trigger is working as intended.

Let's go through what the trigger does:
First of all, all integer values are intialized with value 0
1st iteration:
  • Set variable TEMP = TEMP + 1 --> TEMP value is now 1
  • Set variable StackCount[TEMP] = StackCount[TEMP] + 1 --> Set variable StackCount[1] = StackCount[1] + 1 --> StackCount[1] value is now 1
  • Display value of StackCount[1]

2nd iteration:
  • Set variable TEMP = TEMP + 1 --> TEMP value is now 2
  • Set variable StackCount[TEMP] = StackCount[TEMP] + 1 --> Set variable StackCount[2] = StackCount[2] + 1 --> StackCount[2] value is now 1
  • Display value of StackCount[2]

3rd iteration does the same as above, but for StackCount[3], etc.

As you can see, the value in StackCount does not increase, because you only set it and access it once.


Edit:
Attached is your map with triggers added by me. When playing the map, type "a" into chat. Preferrably, do it two times to see how two instances are handled.
What the triggers do is simply create new instance, run the instance's counter until it hits value 8 and then end the instance.
 

Attachments

  • TESTMap.w3m
    17.7 KB · Views: 25
Last edited:
Level 1
Joined
Jan 30, 2020
Messages
3
  • TEST
    • Events
    • Conditions
    • Actions
      • Set VariableSet TEMP = (TEMP + 1)
      • Set VariableSet StackCount[TEMP] = (StackCount[TEMP] + 1)
The code is broken, but calm down - Reforged isn't the source of all evil. It works as written, it's just written wrong.

Basically, it seems like you are using the indexer incorrectly.

In this example you change StackCount[TEMP] *after* you increase TEMP (and same for previous post). So you will read from whatever integer was stored there every time, until you restart the index or run out of array, and only add single stack per pass.TEMP increases, while StackCount[TEMP] reading from unchanged array element will return 0.

As for your Might code; it works wrong because it doesn't really use indexer - it just uncaringly reads whatever Stacks for next array element was stored and increases it, overwriting old Source, Target and Max. You got infinite stacks because every time the trigger runs it stores it into separate stacks;

  • Might
    • Events
      • Game - PDD_damageEventTrigger becomes Equal to 1.00
    • Conditions
      • (Level of Might for PDD_target) Not equal to 0
      • (PDD_target belongs to an enemy of (Owner of PDD_source).) Equal to True
      • (Random integer number between 1 and 100) Less than or equal to 33
    • Actions
      • Set VariableSet MighTemp = (MighTemp + 1)
      • Set VariableSet MightStacks[MighTemp] = (MightStacks[MighTemp] + 1)
      • Set VariableSet MightSource[MighTemp] = PDD_source
      • Set VariableSet MightTarget[MighTemp] = PDD_target
      • Set VariableSet MightMax[MighTemp] = ((Level of Might for MightTarget[MighTemp]) x 5)
      • Game - Display to (All players) the text: (String(MightStacks[MighTemp]))
      • Set VariableSet MightTime[MighTemp] = 15.00
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • MightStacks[MighTemp] Less than MightMax[MighTemp]
        • Then - Actions
          • Hero - Modify Strength of MightTarget[MighTemp]: Add 4.
          • Special Effect - Create a special effect attached to the origin of MightTarget[MighTemp] using Abilities\Spells\Items\AIsm\AIsmTarget.mdl
            • Set VariableSet MightFX = (Last created special effect)
            • Special Effect - Destroy MightFX
        • Else - Actions
      • Wait MightTime[MighTemp] seconds
      • Hero - Modify Strength of MightTarget[MighTemp]: Subtract 4.
      • Set VariableSet MightStacks[MighTemp] = (MightStacks[MighTemp] - 1)
      • Game - Display to (All players) the text: (String(MightStacks[MighTemp]))
      • Set VariableSet MighTemp = (MighTemp - 1)

To actually use indexer, you need to find if you already have PDD_target as a MightTarget stored somewhere in the index, and save data into new index only if it is not.

also, using wait and trying to do anything after wait is asking for a trigger collision. You expect the global variable to remain unchanged? That's not how it works. You need either a local or local shadowing to do anything post-wait, or better yet not use waits at all and run timers instead. Though I don't recall how one works with timer arrays.

Let me check if I get it right: the ability should add stack on enemy damage with 33%, adds 4 strength and fx per stack, has LVx5 maximal stack and each stack lasts 15 seconds? Also I don't know why would you want to save source since it doesn't seem to be use d anywhere beyond initial condition, is something intended to work for multiple damage sources separately?

Anyway, hope it helps make it work.
Edit: whoops, I was late
 
Level 12
Joined
Feb 5, 2018
Messages
521
Ah well I guess I was trying to cut corners and somehow totally missed this, but for what it's worth I actually use similar index loops.

There are still some weird stuff going on. You are right it's not the root of all evil, but sometimes I get confused whether the issue lies within the actual trigger or within the code.

Like in my previous post where I stated that one of my abilities doesn't add the secondary damage to get to deal the actual total damage, even tho it is made with dynamic indexing, so it should be able to count the damage.
That is probably one of the reasons why I got so lost with this.

Both of you are correct. I have no idea why I saved the source in the initial trigger.

Yeah I will probably get it from here. :) thanks to both of you.
 
Level 12
Joined
Feb 5, 2018
Messages
521
Okay I have almost got it to work. One slight change, if you could help me with and it's done. The subtract works fine, can run on multiple units at once. :)

But the infinite stack problem remains, i'm sorry I didn't quite understand, how to run it. Since I want to increase the stacks when the target takes damage and not increase the stacks every 1 second on the loop trigger.

INI

  • Might
    • Events
      • Game - PDD_damageEventTrigger becomes Equal to 1.00
    • Conditions
      • (Level of Might for PDD_target) Not equal to 0
      • (PDD_target belongs to an enemy of (Owner of PDD_source).) Equal to True
      • (Random integer number between 1 and 100) Less than or equal to 33
    • Actions
      • Set VariableSet MightStacks[MighTemp] = (MightStacks[MighTemp] + 1)
      • Set VariableSet MighTemp = (MighTemp + 1)
      • Set VariableSet MightTarget[MighTemp] = PDD_target
      • Set VariableSet MightMax[MighTemp] = ((Level of Might for MightTarget[MighTemp]) x 5)
      • Set VariableSet MightTime[MighTemp] = 15.00
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • MightStacks[MighTemp] Less than MightMax[MighTemp]
        • Then - Actions
          • Hero - Modify Strength of MightTarget[MighTemp]: Add 4.
        • Else - Actions
      • Trigger - Turn on MightStackLoop <gen>
LOOP

  • MightStackLoop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer MightLoop) from 1 to MighTemp, do (Actions)
        • Loop - Actions
          • Set VariableSet MightTime[MightLoop] = (MightTime[MightLoop] - 1.00)
          • Set VariableSet MightTarget[MightLoop] = MightTarget[MightLoop]
          • Set VariableSet MightMax[MightLoop] = ((Level of Might for MightTarget[MightLoop]) x 5)
          • Set VariableSet MightStacks[MightLoop] = MightStacks[MightLoop]
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • MightTime[MightLoop] Equal to 0.00
            • Then - Actions
              • Set VariableSet MightStacks[MightLoop] = (MightStacks[MightLoop] - 1)
              • Hero - Modify Strength of MightTarget[MightLoop]: Subtract 4.
              • Set VariableSet MightTarget[MightLoop] = MightTarget[MighTemp]
              • Set VariableSet MightMax[MightLoop] = ((Level of Might for MightTarget[MighTemp]) x 5)
              • Set VariableSet MightStacks[MightLoop] = MightStacks[MighTemp]
              • Set VariableSet MightTime[MightLoop] = MightTime[MighTemp]
              • Set VariableSet MighTemp = (MighTemp - 1)
              • Set VariableSet MightLoop = (MightLoop - 1)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • MighTemp Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
 
Your whole concept wont work because you should be retrieving the instance that you stored before for the hero. But you just create a new one for every damage event. Please read your triggers again and understand that it wont ever work this way.

Basically: Find a way to modify an already active instance instead of creating new ones.

Also few of your variable declarations are useless. You just set the value to what it was before.

Your turn off should not be the in the else branch either. Put it below.
 
Level 12
Joined
Feb 5, 2018
Messages
521
I understand it won't work like this. :(

I've just never done MUI with stack trigger included.

I am really trying, I have read the visualized dynamic indexing tutorial multiple times.

Learning is the key, I get it. It's just bit complex for me, but never the less I want to improve. I want to be good and understand everything.

The problem is within the Initial trigger, that much I have found out, because the stack count goes above the max count.
The Loop trigger is running fine. It's subtracts the strength as should and it runs on multiple units at the same time.
It never reduces the strength below the original strength of the unit.

Can you please the address the issue about what of the variables are useless?
 
  • empty.gif
    empty.gif
    empty.gif
    join.gif
    set.gif
    Set Variable Set MightTarget[MightLoop] = MightTarget[MightLoop]
  • empty.gif
    empty.gif
    empty.gif
    join.gif
    set.gif
    Set Variable Set MightStacks[MightLoop] = MightStacks[MightLoop]
Both of these commands are doing nothing.

For the things you are trying you should use a hashtable and save the instance index to the HandleID of the unit/hero. Then on every damage event, try to load the HandleID from the hashtable and if found, use that index and increase the stacks. Else create a new index and use that one.
 
Level 12
Joined
Feb 5, 2018
Messages
521
  • Might
    • Events
      • Game - PDD_damageEventTrigger becomes Equal to 1.00
    • Conditions
      • (Level of Might for PDD_target) Not equal to 0
      • (PDD_target belongs to an enemy of (Owner of PDD_source).) Equal to True
      • (Random integer number between 1 and 100) Less than or equal to 33
    • Actions
      • Set VariableSet MightStacksMax = ((Level of Might for PDD_target) x 5)
      • Hashtable - Create a hashtable
      • Set VariableSet MightHash = (Last created hashtable)
      • Hashtable - Save Handle OfPDD_target as 4 of (Key (Triggering unit).) in MightHash.
      • Hashtable - Save 15.00 as 1 of (Key (Triggering unit).) in MightHash.
      • Hashtable - Save MightStacksMax as 2 of (Key (Triggering unit).) in MightHash.
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • MightStacks Less than (Load 2 of (Key (Triggering unit).) from MightHash.)
        • Then - Actions
          • Set VariableSet MightStacks = (MightStacks + 1)
          • Hashtable - Save MightStacks as 0 of (Key (Triggering unit).) in MightHash.
          • Hero - Modify Strength of (Load 4 of (Key (Triggering unit).) in MightHash.): Add 4.
        • Else - Actions
Here is what I did. I'm surprised I actually even got this far, but this works for 1 unit only. At least the stacks won't run over the max amount. :D
 
Because you create a new hashtable all the time. Create it once on map init.
Then you need to figure out how to load an Index, right now you are just saving over the hashtable whatever was stored inside there before.
Because you will want to create a trigger that iterates over all indexes so that you can lower the value later on.
Still a long way to go.
 
Status
Not open for further replies.
Top