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

[Trigger] Passively Adding Attributes (MUI)

Status
Not open for further replies.
Level 4
Joined
May 21, 2015
Messages
70
my 3rd trigger dont work, it will remove the added atrribute after seconds 5 but it didnt EDIT:Ive found the problem, but the new problem now is the stats doesnt go away after 5 seconds if RageC is repeatitively takes damage. >> heres the trigger again
  • Rage Start
    • Events
      • Unit - A unit Learns a skill
    • Conditions
    • Actions
      • Set RageC[RageS] = (Learning Hero)
      • Trigger - Add to Rage Cast <gen> the event (Unit - RageC[RageS] Takes damage)
  • Rage Cast
    • Events
    • Conditions
    • Actions
      • Set RageS = (RageS + 1)
      • Set RageCh[RageS] = (Random integer number between 1 and 2)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RageCh[RageS] Not equal to 1
        • Then - Actions
          • Set RageS = (RageS - 1)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • RageCh[RageS] Equal to 1
            • Then - Actions
              • Set RageC[RageS] = (Triggering unit)
              • Set RageT[RageS] = 0
              • Set RageTi = 1.00
              • Set RageTiR[RageS] = 1
            • Else - Actions
              • Trigger - Turn on Rage Trigger <gen>
  • Rage Trigger
    • Events
      • Game - RageTi becomes Equal to 1.00
    • Conditions
    • Actions
      • Trigger - Turn on Rage Add <gen>
  • Rage Add
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer RageIn) from 1 to RageS, do (Actions)
        • Loop - Actions
          • Set RageT[RageIn] = (RageT[RageIn] + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • RageTiR[RageIn] Equal to 1
            • Then - Actions
              • Hero - Modify Strength of RageC[RageIn]: Add (2 x (Hero level of RageC[RageIn]))
              • Set RageA[RageIn] = (RageA[RageIn] + (2 x (Hero level of RageC[RageIn])))
              • Set RageTiR[RageIn] = 0
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • RageT[RageIn] Equal to 5
                • Then - Actions
                  • Hero - Modify Strength of RageC[RageIn]: Subtract RageA[RageIn]
                  • Set RageA[RageIn] = 0
                • Else - Actions
                  • Set RageIn = (RageIn - 1)
                  • Set RageC[RageIn] = RageC[RageS]
                  • Set RageS = (RageS - 1)
                  • Set RageT[RageIn] = 0
 
Level 25
Joined
Sep 26, 2009
Messages
2,382
It may be for test purposes I guess, but I'll write it anyway: the first trigger lacks conditions, so even an archmage who learns Blizzard ability will "learn" and later fire this Rage ability.

The first trigger
The first trigger immediately bugs your spell, because you set the caster into unit array for no reason.
An example of this bug occurring is when you have a unit, who learned this spell (I'll call it "first unit") takes damage and after first unit took damage another unit learns this spell (I'll call it "second unit"). Now before second unit learns the spell, the first unit will be stored in RageC array under index 1.
When second unit learns this spell, you save the second unit in RageC array under same index (index 1). Now even though your first unit got the Strength bonus, after the effect expires the strength bonus will be removed from second unit, because that is the unit saved in RageC with index 1.
There is actually no need to save the unit inside the array in the first trigger. It just bug things.


The second trigger
Way too many actions that don't make sense logically. The best script is the script which does what you want with as least actions as possible.
I wrote a pseudocode on what you have and how you could improve it. Notice how many actions you have:

What you have:
Code:
Increase index
Set random number
Is that number not 1?
Yes: Decrease index
No: Do stuff

instead you could have this:
Code:
Set random number
Is that number 1?
Yes: Increase index, do stuff
That aside, other thing I don't understand is why you have two If/Then/Elses (ITEs) - One checking if number is not 1 and the other if number is 1.
If you call a random integer function on an interval [1,2], then the only numbers you can get are 1 or 2 (no numbers with decimal point since you picked random integer number).
If you check what number you got and the number you got is not number 1, then it obviously has to be number 2. There is no other option here. Hence having two ITEs, one checking if the number is 1 and the second if the number is NOT 1 makes no sense.

Same what doesn't make sense is the action in the inner ITE - the "Set RageTi = 1.00" action.
What this action does is that it only fires the third trigger and all this trigger does is that it turns on the fourth trigger. Why not simply remove the third trigger and put the "Turn on <trigger>" action into the second trigger? More on that, you should turn trigger only once - when index value is 1, as that means there were 0 units indexed before the trigger run. Same, you should turn off the loop trigger when index after deindexing reaches value 0, as that means there are no units left in the RageC array.

The next thing that doesn't make any sense in your second trigger is the "Else" block of the second (the inner) ITE.
Let's take again a look at the structure of your ITEs.
Code:
If (condition)
    number != 1
Then (action)
    decrease index
Else (action)
    <goes to second ITE>
    If (Condition)
        number == 1
    Then (action)
        Do stuff like firing the third trigger by setting the real value of variable to 1.00
    Else (action)
        Turn on third trigger
Now here's the funny part: The trigger will never execute the "Turn on third trigger" action. Why? Because if the random number is not 1, the "Then" block of the outer ITE will be executed and the "Else" block will be omitted. If the number is 1, the "Else" block of the outher ITE is executed which leads to executing the "Then" block of the inner ITE, because there the condition (number == 1) is true. There is no way for you to get to the "Else" block of the inner ITE.
tl;dr:
When number != 1, "Then" block of the outer ITE is executed.
When number == 1, "Then" block of the inner ITE is executed.



The fourth trigger
The fourth trigger is a mess. Again, your way of doing things is way too complicated. First of all, you use the RageTir array to just add the strength attribute inside the fourth trigger. I ask: "Why not add it immediately in second trigger?". You may say that you want it to be exactly 5 seconds, but I doubt the bonus will have greater impact on your game if the effect was on your unit longer by anywhere between 0.00 to 1 second. And if so, the ideal way would actually be to make the loop run like every .25 seconds.
Assuming your deindexing would work (which it does not but about that later) your "Then" block in the first ITE makes two times the same calculation for no reason whatsoever.
Basically you have: "Set attribute: Add (2 * X)", and then after it another action: "A = 2 * X". Why not make it: "A = 2 * X"; "Set attribute: Add A". Your way makes the computer compute the same operation two times.

The second ITE is where things start to bug. Basically you check the RageT array, which I assume represents time. If it equals to 5, you remove the attribute bonus, if it does not equal 5 (which is true for 2, 3 and 4), you actually execute some buggy pseudo deindexing. I won't go much into how that deindexing won't work, the important thing is that after 2 seconds that your unit took damage, he will be deindexed by the trigger. So when it is actually 5 seconds, you do remove the attribute bonus, but you remove it from (no unit) or some completely unrelated unit.
To understand deindexing, I advise going through the tutorial section and read some stuff about it.


Other things
You should rethink your variables naming convention. It was pretty confusing to understand what is for what. RageA, RageC, RageWhateverIsHere does not explain much by itself. Also, RageCh should be an integer variable, not an array.

Last thing: The same hero will be indexed by this spell multiple times - once for each attack that lands on him. I'm not sure if that is intended, but assuming there are some units with fast attack speed, you could end up with pretty high number of the index, not to mention if there were more of these fast units and units using the Rage ability.

The way I would do it would be to either:
a) just reset duration of the Rage effect
b) give additional attribute bonus and reset duration
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Your second trigger should look something like this

EDIT: Ignore this, Nichilus made a good post

  • Rage Cast
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Random number [1, 2] == 1
        • Then - Actions
          • Set RageS = (RageS + 1)
          • Set RageC[RageS] = (Triggering unit)
          • Set RageT[RageS] = 0
          • Set RageTi = 1.00
          • Set RageTi = 0.00 // This can't become 1 if it is not set to some other number inbetween
          • Set RageTiR[RageS] = 1
          • Trigger - Turn on Rage Trigger <gen>
        • Else - Actions
 
Level 4
Joined
May 21, 2015
Messages
70
ohh forgot to say the var RageCh is like a chance if RageCh is equal to 1 then do stuffs EDIT2: Nichilus i now understand, well at first im very confuse. . hehehehe ty +rep
 
Status
Not open for further replies.
Top