• 🏆 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] For some reason it isn't working as it should

Status
Not open for further replies.
It's a tome-based damage system and sadly it only loops once so I am confused now and would appreciate anyone's help if possible.

[trigger=]
Events
Time - Elapsed game time is 1.00 seconds
Conditions
Actions
Set itemamountmax = (itemamountmax + 1)
Set itembase[itemamountmax] = Zweihander
Set itembasedmg10s[itemamountmax] = 5
Set itembasedmg100s[itemamountmax] = 2


[/trigger]



[trigger=]
Events
Unit - A unit Acquires an item
Conditions
Actions
For each (Integer itemloop1) from 1 to itemamountmax, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Item-type of (Item being manipulated)) Equal to itembase[itemloop1]
Then - Actions
For each (Integer ZITEMLOOP[1]) from 1 to itembasedmg100s[itemloop1], do (Actions)
Loop - Actions
Hero - Create atk add 100 and give it to (Triggering unit)
For each (Integer ZITEMLOOP[2]) from 1 to itembasedmg10s[itemloop1], do (Actions)
Loop - Actions
Hero - Create atk add 10 and give it to (Triggering unit)
Else - Actions

[/trigger]
 
Last edited:
Level 12
Joined
Nov 3, 2013
Messages
989
Loops? It says elapsed not periodic

Edit: Nvm, it might be because of the inaccuracy of the waits? try with a longer experiation timer

Edit 2: If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Item-type of (Item being manipulated)) Equal to itembase[itemloop1]
Then - Actions
Else - Actions
Skip remaining actions
Nvm saw it wrong.

Edit: I don't even know what you're doing tbh, i think i'm just gonna get some sleep and leave this for a real pro :3
 
As usual everyone is fixated on them waits, I use them to reset the thread limit so I don't hit it. The waits aren't the issue and they're not evil/bad.

I did say it was a tome-based damage add system, I guess it is a little complex.

Oh forgot to remove that, the skip there was disabled so it isn't that.

What's wrong is that it only provides 1 of each tome/item when it should do like 0 for some or 5 for another as according to the item database. It doesn't loop within the main loop for some reason. I might switch to 0 though I don't know if that still resets it however that wasn't the problem. Hopefully this helps and every time I provide a test map people complain but the one time I didn't... lol =(

Thanks for trying Death Adder as well GreeN!X.
 
Level 12
Joined
Nov 3, 2013
Messages
989
Does the unit acquire items only through these two triggers? Because if so then It probably has to do with it only gets one item from the first trigger which sets the max index to 1 and then the 2nd trigger never run again because you never add another item with the first one.

I mean all that stuff after the wait won't do a thing for the 2nd trigger since it only runs when you add an item.

Again I don't even really understand what's supposed to be going on and I might be way off.
 
The hero acquires items normally through picking them up or well in my case buying them. What do you mean only gets one item from first trigger? The loop doesn't run more then once because of the event? The max index, which one do you mean?

It doesn't? Why would that be? The first trigger just sets up all the values and variables.

It is an add damage system... what don't you get or what am I doing wrong?
 
In your
  • For each (Integer ZITEMLOOP1) from 1 to itembasedmg100s[itemloop1], do (Actions)
You use the wrong loopIndex in the comparisson. And the result will always be the same here.

Also the other loops inside, for example:
  • For each (Integer ZITEMLOOP[1]) from 0 to itembasedmg100s[itemloop1], do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ZITEMLOOP[1] Less than or equal to itembasedmg100s[itemloop1]
          • ZITEMLOOP[1] Not equal to 0
        • Then - Actions
          • Game - Display to (All players) the text: (String(ZITEMLOOP[1]))
          • Hero - Create atk add 100 and give it to (Triggering unit)
          • Else - Actions
You loop from null to maxIndex. In the If/Then/Else you check if the loopIndex is not null and less or equal itembasedmg100s[itemloop1].

You can remove both conditions I think and just start the loop with 1 and not 0. It won't loop if the itembasedmg100s[itemloop1] is 0. (or else, pls explain if you need it)

To simplify you could remove all the "Set blah = 0" initializations. They are 0 anyway.

Also it might work in most cases but inside the loop I think it's better to use an ItemComparisson, not an ItemType comparisson.
 
Ignore the last four loops inside the loop, they weren't working anyways so I tried something else, yeah I know I can remove all the 0s, I just wasn't done setting stuff.

What do you mean by using item comparison instead of item type? Only item type will work from what I know with this, thanks though IcemanBo. Still the problem of the loops not working as they should, some items should give 2-3 atk add 100's but yet they only give one. Zweihander for example is the one I have been testing with and it is meant to give 2.

Edit: I will remove all the extra stuff so it is easier to identify the issue at hand.
 
Assuming the triggers in the first post is up to date.

Try instead of running the two loops within the main loop to run a second trigger with the two item creating loops.
  • Events
  • Unit - A unit Acquires an item
  • Conditions
  • Actions
  • For each (Integer itemloop1) from 1 to itemamountmax, do (Actions)
  • Loop - Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
  • (Item-type of (Item being manipulated)) Equal to itembase[itemloop1]
  • Then - Actions
  • Run Item Creation Trigger
  • Else - Actions
  • Item Creation Trigger
  • Actions
    • For each (Integer ZITEMLOOP[1]) from 1 to itembasedmg100s[itemloop1], do (Actions)
    • Loop - Actions
    • Hero - Create atk add 100 and give it to (Triggering unit)
    • For each (Integer ZITEMLOOP[2]) from 1 to itembasedmg10s[itemloop1], do (Actions)
    • Loop - Actions
    • Hero - Create atk add 10 and give it to (Triggering unit)
 
Level 2
Joined
Jan 14, 2014
Messages
5
What happens when you print the loop index each time inside the loops?

("itemloop1 = " + I2S(itemloop1))
("ZITEMLOOP[1] = " + I2S(ZITEMLOOP[1]))
("ZITEMLOOP[2] = " + I2S(ZITEMLOOP[2]))

Just to ensure the correct item index and as well the loops run properly. (I2S does mean Integer converted to String)
 
Why does this work and not the original one?

[trigger=]
Events
Unit - A unit Acquires an item
Conditions
Actions
For each (Integer itemloop1) from 1 to itemamountmax, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Item-type of (Item being manipulated)) Equal to itembase[itemloop1]
Then - Actions
For each (Integer ZITEMLOOP0) from 1 to (Integer((Current life of (Item being manipulated)))), do (Actions)
Loop - Actions
Hero - Create atk add 1 and give it to (Triggering unit)



[/trigger]
 
Status
Not open for further replies.
Top