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

How to temporarily spawn weather effects on mui spells?

Level 7
Joined
Mar 16, 2014
Messages
152
There is no way to save weather effects beyond globals that I'm aware of. I want to create a weather effect and reference it later without using a global variable. If I could, for example, tie a weather effect to a unit, that would make me much happier with how I could manipulate it and just set an expiration timer on the unit for when the weather effect dies.

Ideally I would just like the model files for the weather, but those basically don't seem to exist.
 
Level 39
Joined
Feb 27, 2007
Messages
5,019
Weather effects are applied to rects (what GUI calls "regions") and have extremely limited functionality. You cannot attach one to a unit outside of building a struct to hold such data and maintain/act upon it accordingly. You could also use a similar but simpler struct to allow you to save a weathereffect in a hashtable by instead storing the integer value of the struct instance it's attached to.

Frankly I'm not even sure that moving or resizing a rect will change the weathereffect's bounds dynamically, so it may be a fruitless endeavor to begin with if you want that functionality. It might work but only if the effect is disabled and reenabled.

There are a variety of ways you can manipulate data locally in GUI by using some editor fuckery or sound logic. Generally there are issues with using the Wait action, but when you do not need to be extra precise it's the perfect tool for the job. Here are three examples:
  • Events
  • Conditions
  • Actions
    • -------- store the data in a jass local, and read that value into a global that GUI can interface with --------
    • -------- this requires you to convert back and forth properly at the right time(s), as well as null the local variable at the end of the trigger --------
    • Custom script: local weathereffect WE
    • Environment - Create at (Playable map area) the weather effect Ashenvale Rain (Heavy)
    • Set TempWE = (Last created weather effect)
    • Custom script: set WE = udg_TempWE
    • Wait - 20.00 seconds
    • Custom script: set udg_TempWE = WE
    • Environment - Remove TempWE
    • Custom script: set WE = null
  • Events
  • Conditions
  • Actions
    • -------- shadow the GUI global variable with a jass local that has the same name --------
    • -------- this requires you to respect things like ForGroup and basically all If/Then/Else blocks which under-the-hood execute in separate functions --------
    • -------- where the locally shadowed version of this variable will not exist, causing potential confusion since GUI will still allow you to interface with global version --------
    • Custom script: local weathereffect udg_LocalWE
    • Environment - Create at (Playable map area) the weather effect Ashenvale Rain (Heavy)
    • Set LocalWE = (Last created weather effect)
    • Wait - 20.00 seconds
    • Environment - Remove LocalWE
    • Custom script: set udg_LocalWE = null
  • [trigger]Events
  • Conditions
  • Actions
    • -------- use an array and an incrementing process that will always destroy them in the same order --------
    • -------- this method will only work for groups of weathereffects that all always have the same duration --------
    • -------- yes, this does work; think about it --------
    • Environment - Create at (Playable map area) the weather effect Ashenvale Rain (Heavy)
    • Set TempWE = (Last created weather effect)
    • Set WE_CounterA = (WE_CounterA + 1)
    • Set WEs[WE_CounterA] = TempWE
    • Wait - 20.00 seconds
    • Set WE_CounterB = (WE_CounterB + 1)
    • Set TempWE = WEs[WE_CounterB]
    • Environment - Remove TempWE
    • If (All conditions are true) then do (Then actions) else do (Else actions)
      • If - Conditions
        • WE_CounterA equal to WE_CounterB
      • Then - Actions
        • -------- if we get here it means there are no weather effects currently 'waiting' in the 20s wait period, so we can safely reset the counters to 0 --------
        • Set WE_CounterA = 0
        • Set WE_CounterB = 0
      • Else - Actions
 
Level 7
Joined
Mar 16, 2014
Messages
152
Creating timed effect weathers seems possible, but referencing them beyond giving them a set duration seems impossible. I ideally want the weathers to be destroyed on demand and be tied to a dummy unit existing.

Due to the extremely limited functionality of weather effects, things would be much simpler if we could just emulate the weathers with models - I found a model emulating the rain weather effect but no luck for the rest.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,555
Use a Unit Indexer, use a Weather array variable, and attach the newly created Weather to the desired unit.
  • Unit - Create 1 unit...
  • Environment - Create weather...
  • Set Variable Attached_Weather[(Custom value of (Last created unit))] = (Last created weather effect)
This is how you attach data to Units. Or you can use a Hashtable, they're practically the same thing.

If you have a reference to the Unit, you will also have a reference to it's Custom Value, and therefore a reference to any Arrays that are attached to it.

Or, if using a Hashtable, you will be able to Load the Weather by plugging in the Unit as a Key in your Hashtable.
 
Last edited:
Top