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

[Solved] Chilled Units

Status
Not open for further replies.
Level 5
Joined
Aug 14, 2020
Messages
118
Hello guys, I haven't been here for a while. good to be back!

well, I'm creating an ability for a FrostMage called Chill, any kind of damage from her will chill enemies for 5 seconds, additionally she can active ability to freeze all chilled units.

Here is trigger:
  • Chilled
    • Events
    • Conditions
      • (Damage taken) Greater than 0.00
    • Actions
      • Set TempUnit[0] = (Attacked unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (TempUnit[0] belongs to an enemy of (Owner of Mira)) Equal to True
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (TempUnit[0] is in Chilled) Equal to False
            • Then - Actions
              • Unit Group - Add TempUnit[0] to Chilled
              • Unit - Add Chilled (Buff) to TempUnit[0]
              • Set Chilled_Int[(Custom value of TempUnit[0])] = 5
            • Else - Actions
              • Set Chilled_Int[(Custom value of TempUnit[0])] = 5
        • Else - Actions
          • -------- EMPTY --------
about (Chilled_Int)! that is integer that I use instead of wait function
here is second trigger
  • Chilled Loop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
      • (Number of units in Chilled) Greater than 0
    • Actions
      • Unit Group - Pick every unit in Chilled and do (Actions)
        • Loop - Actions
          • Set Chilled_Int[(Custom value of (Picked unit))] = (Chilled_Int[(Custom value of (Picked unit))] - 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Chilled_Int[(Custom value of (Picked unit))] Equal to 0
            • Then - Actions
              • Unit Group - Remove (Picked unit) from Chilled
              • Unit - Remove Chilled (Buff) from (Picked unit)
            • Else - Actions
here is a thing! I got a bit self confused, kinda!
how should I set Array's Size? since we have a lot of units in campaign I don't know if I should set it to 999999 or only 1 xd
I don't know how it works exactly, also if I did anything wrong in triggers I'll be thankful if u tell me where is my mistake.
 
Level 25
Joined
Sep 26, 2009
Messages
2,378
Maximum array size is 8192, but you should leave it initialized to size 1 - that's optimal.
Also, I am not sure how your "Chilled" trigger's event is set up, but if it is the "Unit - <specific> unit takes damage" event, then this action is incorrect:
  • Set TempUnit[0] = (Attacked unit)
Instead of (Attacked unit) I think you need to use (Damage Target)
 
Level 25
Joined
Sep 26, 2009
Messages
2,378
(Damage target) has been in the editor for years (years even before reforged came out).

Here is an example trigger:
  • Untitled Trigger 001
    • Events
    • Conditions
    • Actions
      • Set VariableSet u = (Damage Target)
and a screenshot from map editor:

wc3_pic.png


I checked the (Attacked unit) and to my surprise it does work. Not sure if it is some recent change or not.
Going by blizzard's own comments, the (Attacked unit) and (Attacking unit) are responses to "Unit is attacked" event. The "Unit is attacked" event can happen way earlier than the "Unit takes damage". For example the "Unit is attacked" event is fired when night elf archer begins preparing to shoot an arrow - so depending on range from her target, that can be even a full second before the "Unit takes damage" event is fired.

Basically, when you use (Attacked unit) to a "Unit takes damage" event, you cannot be certain who the (Attacked unit) actually is, while if you use (Damage Target), you definitely know it is the target of the "Unit takes damage" event.

Perhaps someone else could clarify why (Attacked unit) works in this case.


As for the array initialization, yes, I am sure size 1 is fine. Size 1 does not set size of the array itself, but it sets how many items in the array should be initialized to the default value.
This could be useful in some edge cases (i.e. if you wanted to have unit-group array with pre-created unit groups), but for great majority of cases size 1 is fine.
 
Status
Not open for further replies.
Top