• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Could someone draft me an example on Triggers to make a weather system that changes per timed event?

Level 5
Joined
Nov 17, 2022
Messages
84
Salutations once again 👋 I am in need of help. I've been fiddling around with triggers for my map in regards to weather creation and a system where weather is dynamic, as in, it changes randomly or on a set schedule depending on time passing. But no matter what I've tried nothing has worked.

Additionally, I'd like to add buffs the weather causes like for example a blizzard causing units to move and attack slower or perhaps lose mana/hp faster etc but I can't figure that out either. If anyone could draft me up a visual example with the triggers menu, it'd assist me a lot with my map.

Thank you 🙏
 
Level 30
Joined
Aug 29, 2012
Messages
1,382
Never really fiddled with weather but it should go like this

  • Rain
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Environment - Create at (Playable map area) the weather effect Ashenvale Rain (Heavy)
      • Set VariableSet WeatherEffect = (Last created weather effect)
      • Environment - Turn WeatherEffect On
Here you've created and enabled your weather. Then it's up to you to decide if you want to use waits or timers in order to make it stop and create the next one
  • Environment - Turn WeatherEffect Off
  • Environment - Create at (Playable map area) the weather effect Northrend Snow (Heavy)
  • Set VariableSet WeatherEffect = (Last created weather effect)
  • Environment - Turn WeatherEffect On
Etc. About the buffs, you can create a dummy caster for the neutral hostile player and give it e.g. a negative endurance aura with a radius of 99999, then remove it when the snow weather is changed
 
Level 29
Joined
Sep 26, 2009
Messages
2,595
give it e.g. a negative endurance aura with a radius of 99999, then remove it when the snow weather is changed
I would advise using "Slow Aura (Tornado)" instead of endurance aura. Functionally it is the same thing (both auras affect atk and mov speed), but the slow aura is offensive aura by default :)

----
@WolfChalk for applying effects you will need to do basically what Chaosium wrote - try to leverage aura skill effects with large 'area of effect' range so that a single aura affects entire map. Then just use an invisible/invulnerable dummy unit owned by Neutral Passive that will have this aura so that it is applied to everyone on the map.
For effects that cannot be applied via auras, you will need to get a bit creative. E.g.:
1) Adding and removing item abilities from all units on map and using a custom aura that does nothing just to see a buff
2) Create a active spell that applies (de)buffs and have a dummy unit cast it on everyone on the map. This second approach has an important disadvantage: such effects can be dispelled by skills like Abolish Magic, Dispel Magic, etc.

For a generic weather system, I would try something like below (note that I have not tested the triggers, so I may have some bugs there).
How it works:
  • Have a bunch of triggers, each for different weather. Each such trigger has two parts: For enabling and for disabling that weather
  • On map initialization, populate array variables: assign to array each weather trigger and that weather's weight. Weight impacts the chance that the given weather will be selected.
  • Have an initial trigger that starts a countdown timer.
  • Finally, have a trigger that fires when the countdown timer expires. It will first disable currently active weather (if any is active) and then select new weather and enables it.

1721682059848.png
  • Weather Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set VariableSet WeatherEffectDummy = Weather Effect Dummy 0002 <gen>
      • -------- ------------------------------------------ --------
      • Set VariableSet WeatherOptions[1] = Weather Clear <gen>
      • Set VariableSet WeatherWeights[1] = 30
      • -------- ------------------------------------------ --------
      • Set VariableSet WeatherOptions[2] = Weather Rain <gen>
      • Set VariableSet WeatherWeights[2] = 15
      • -------- ------------------------------------------ --------
      • Set VariableSet WeatherOptions[3] = Weather Snow <gen>
      • Set VariableSet WeatherWeights[3] = 15
      • -------- ------------------------------------------ --------
      • Set VariableSet WeatherOptions[4] = Weather Storm <gen>
      • Set VariableSet WeatherWeights[4] = 10
      • -------- ------------------------------------------ --------
      • Set VariableSet WeatherOptions[5] = Weather Sunny <gen>
      • Set VariableSet WeatherWeights[5] = 18
      • -------- ------------------------------------------ --------
      • Set VariableSet WeatherOptions[6] = Weather Windy <gen>
      • Set VariableSet WeatherWeights[6] = 12
      • -------- ------------------------------------------ --------
      • -------- MaxIndex = how many weather options we have --------
      • Set VariableSet WeatherMaxIndex = 6
  • Weather Start
    • Events
      • Time - Elapsed game time is 5.00 seconds
    • Conditions
    • Actions
      • Countdown Timer - Start WeatherTimer as a One-shot timer that will expire in 10.00 seconds
  • Weather Change
    • Events
      • Time - WeatherTimer expires
    • Conditions
    • Actions
      • -------- ------------------------------------------------------------------------------------ --------
      • -------- Disable previous weather, if any --------
      • Set VariableSet WeatherEnable = False
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • WeatherPickedIndex Greater than 0
        • Then - Actions
          • Trigger - Run WeatherOptions[WeatherPickedIndex] (checking conditions)
        • Else - Actions
      • -------- ------------------------------------------------------------------------------------ --------
      • -------- Get total weight of all weathers --------
      • Set VariableSet WeatherWeightTotal = 0
      • For each (Integer loopInt) from 1 to WeatherMaxIndex, do (Actions)
        • Loop - Actions
          • Set VariableSet WeatherWeightTotal = (WeatherWeightTotal + WeatherWeights[loopInt])
      • -------- ------------------------------------------------------------------------------------ --------
      • -------- Pick random weather, get its index assigned to WeatherPickedIndex --------
      • Set VariableSet lowerBoundary = 0
      • Set VariableSet randomNumber = (Random integer number between 0 and WeatherWeightTotal)
      • For each (Integer loopInt) from 1 to WeatherMaxIndex, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • randomNumber Greater than lowerBoundary
              • randomNumber Less than or equal to (lowerBoundary + WeatherWeights[loopInt])
            • Then - Actions
              • Set VariableSet WeatherPickedIndex = loopInt
              • Set VariableSet loopInt = WeatherMaxIndex
            • Else - Actions
              • Set VariableSet lowerBoundary = (lowerBoundary + WeatherWeights[loopInt])
      • -------- ------------------------------------------------------------------------------------ --------
      • -------- Enable picked weather --------
      • Set VariableSet WeatherEnable = True
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • WeatherPickedIndex Greater than 0
        • Then - Actions
          • Trigger - Run WeatherOptions[WeatherPickedIndex] (checking conditions)
        • Else - Actions
  • Weather Rain
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • WeatherEnable Equal to True
        • Then - Actions
          • Environment - Create at (Playable map area) the weather effect Ashenvale Rain (Heavy)
          • Set VariableSet CurrentWeather = (Last created weather effect)
          • Environment - Turn CurrentWeather On
          • Unit - Add Rain Weather Slow Effect to WeatherEffectDummy
          • Countdown Timer - Start WeatherTimer as a One-shot timer that will expire in (((Real((Random integer number between 6 and 10))) x 2.00) + 15.00) seconds
        • Else - Actions
          • Environment - Turn CurrentWeather Off
          • Environment - Remove CurrentWeather
          • Unit - Remove Rain Weather Slow Effect (Tornado) from WeatherEffectDummy
The "WeatherEffectDummy" is a pre-placed dummy unit.
The "Weather Slow Effect" ability is an aura-like ability based off "Slow Aura (Tornado)"


How this would work during gameplay would be:
  • After 5 second since map start, the 'Start' trigger fires and starts the countdown timer with 10.0 seconds left.
  • After 10 seconds the timer expires and fires the 'Change' trigger.
  • Change trigger skips disabling current weather - there is none
  • Next, it uses weights and random number to determine 'WeatherPickedIndex', which is the index of picked weather (matching indices 1-6 as set up in Map Initialization trigger)
  • Let's say WeatherPickedIndex is 2, that matches the index of 'Weather Rain' trigger.
  • WeatherEnabled boolean var is configured to 'True', meaning we want to enable weather
  • The Change trigger finally fires trigger assigned to WeatherOptions[2], which is the 'Weather Rain <gen>' trigger.
  • Weather Rain trigger checks boolean value of 'WeatherEnabled' variable. It is set to 'True', so it will create the rain weather effect, add a slowing aura to dummy unit so that the 'Rain Slow' effect is applied globally to all units, and finally it starts again the WeatherTimer countdown timer again to expire between 27-35 seconds.
  • After time expires, it will trigger 'Change' trigger again, which will first set 'WeatherEnabled' bool to 'FALSE' and run 'Weather Rain' trigger again.
  • In 'Weather Rain' trigger the boolean is False this time, so the rain weather is disabled and the slowing aura is also removed.
  • After this, the 'Change' trigger resumes, once again determining random weather, which it would enable.

This approach is a bit complicated, but it has the following advantanges:
  • You can affect probability of a weather by just adjusting its weights
  • You can easily add new weather: Create a trigger like 'Weather Rain' and in Map Initialization trigger add that trigger to the WeatherOptions array, assign it a weight and increase the WeatherMaxIndex.
  • You can also do some additional stuff easily - for example "Weather Rain" trigger may start another periodic trigger that will also create lightning storm effects on the map, etc.
 
Top