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

detecting random integer

Status
Not open for further replies.
Level 2
Joined
Feb 1, 2014
Messages
19
Hello guys,

here are my triggers for random weather, my problem is that i want detect which weather it selected and make action with it.I mean when it selects snow it will slows all players etc.. I will glad if u post triggers but dont post them without description , i want to learn 'em, why and when to use which thingz etc. ty </3

  • pocasi init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Environment - Create at (Playable map area) the weather effect Ashenvale Rain (Light)
      • Set pocasi[0] = (Last created weather effect)
      • Environment - Turn (Last created weather effect) Off
      • Environment - Create at (Playable map area) the weather effect Dungeon White Fog (Heavy)
      • Set pocasi[1] = (Last created weather effect)
      • Environment - Turn (Last created weather effect) Off
      • Environment - Create at (Playable map area) the weather effect Ashenvale Rain (Heavy)
      • Set pocasi[2] = (Last created weather effect)
      • Environment - Turn (Last created weather effect) Off
      • Environment - Create at (Playable map area) the weather effect Northrend Snow (Heavy)
      • Set pocasi[3] = (Last created weather effect)
      • Environment - Turn (Last created weather effect) Off
  • pocasi zmena
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 0 to 3, do (Actions)
        • Loop - Actions
          • Environment - Turn pocasi[(Integer A)] Off
      • Environment - Turn pocasi[(Random integer number between 0 and 3)] On
 

Ardenian

A

Ardenian

To get what weather is currently up, you would save the chosen integer in an integer variable:

  • Set TempInteger = (Random integer number between 0 and 3)
  • Environment - Turn pocasi[TempInteger] On
 
Level 2
Joined
Feb 1, 2014
Messages
19
U mean something like this ?

  • pocasi zmena
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 0 to 3, do (Actions)
        • Loop - Actions
          • Environment - Turn pocasi[(Integer A)] Off
      • Set pocasi_integer = (Random integer number between 0 and 3)
      • Environment - Turn pocasi[(Random integer number between 0 and 3)] On
And that "weather effects" should be executed how?
Might it be something like this?

  • pocasi zmena
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 0 to 3, do (Actions)
        • Loop - Actions
          • Environment - Turn pocasi[(Integer A)] Off
      • Set pocasi_integer = (Random integer number between 0 and 3)
      • Environment - Turn pocasi[(Random integer number between 0 and 3)] On
      • If (pocasi_integer Equal to 1) then do turn on mlha else do If and do it 4 times.
Or is there better method?
 
Level 14
Joined
Nov 30, 2013
Messages
926
  • pocasi zmena
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 0 to 3, do (Actions)
        • Loop - Actions
          • Environment - Turn pocasi[(Integer A)] Off
      • Set pocasi_integer = (Random integer number between 0 and 3)
      • Environment - Turn pocasi[pocasi_integer] On
 
Level 2
Joined
Feb 1, 2014
Messages
19
  • pocasi zmena
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 0 to 3, do (Actions)
        • Loop - Actions
          • Environment - Turn pocasi[(Integer A)] Off
      • Set pocasi_integer = (Random integer number between 0 and 3)
      • Environment - Turn pocasi[pocasi_integer] On

Don't i just did used same trigger? I just ask'd how to apply spells & buffs into each random weather saved into variable.
 
Level 13
Joined
Oct 16, 2010
Messages
731
These buffs will effect all units in the map right? If so, I'd create a dummy with 3 different auras for each weather effect. You can set the aura to hit the whole map, make endurance aura effect everyone and have a negative effect for a global slow.

When you change the effects disable the other 2 auras leaving one active. Could work...
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
  • pocasi zmena
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • Environment - Turn pocasi[pocasi_integer] Off
      • Set pocasi_integer = (Random integer number between 0 and 3)
      • Environment - Turn pocasi[pocasi_integer] On
Also, when you do:
Set pocasi_integer = (Random integer number between 0 and 3)
Environment - Turn pocasi[(Random integer number between 0 and 3)] On
That means that the integer can be set to any value between 0 and 3 and that the environment is also changed depending on a random value between 0 and 3.
You have no way to make sure that both values are the same, so you have to save the returned value of the random generator and use that value over and over again instead of asking for a random number over and over again.

About the spells, you can turn off one aura and turn on another aura by adding/removing the ability from a unit.
You can place those abilities in an ability array variable and remove the one of the current integer value before you update the integer value and add the ability of the newly generated integer value (the same way how the changing of the environment works).

Sorry I cannot use MUI, it was a very long time since I used it.

Please, be a nice guy and call it GUI.
GUI = Graphical User Interface (often used as an abbreviation for the GUI Trigger Editor)
MUI = Multi Unit Instanceable (meaning that a specific thing can be used by multiple units at the same time)
 
Level 10
Joined
May 28, 2011
Messages
455
Please, be a nice guy and call it GUI.
GUI = Graphical User Interface (often used as an abbreviation for the GUI Trigger Editor)
MUI = Multi Unit Instanceable (meaning that a specific thing can be used by multiple units at the same time)

Okey. I might mixed some of my understanding between GUI and MUI. I thought MUI is usually relevant to GUI. So, to post trigger must include MUI at best (not for this case). I am just Jass person now. When I say MUI, people would know it is for GUI? I don't know. Implementing MUI is usually for GUI as no it is no really an issue for jass. Isn't GUI too straightforward to understand? Who couldn't understand GUI even left it for a decade? It is MUI that I left for a long time. Obviously...

this wont be real problem , i got problem in executing that trigger based on random integer choice

I suggest create weather after the random integer chose and save environment variable to the type of the created weather. I use this way in my map Revenants of Ruins.
 
Level 2
Joined
Feb 1, 2014
Messages
19
Okey. I might mixed some of my understanding between GUI and MUI. I thought MUI is usually relevant to GUI. So, to post trigger must include MUI at best (not for this case). I am just Jass person now. When I say MUI, people would know it is for GUI? I don't know. Implementing MUI is usually for GUI as no it is no really an issue for jass. Isn't GUI too straightforward to understand? Who couldn't understand GUI even left it for a decade? It is MUI that I left for a long time. Obviously...



I suggest create weather after the random integer chose and save environment variable to the type of the created weather. I use this way in my map Revenants of Ruins.

could u post that part of the trigger here , please?
 
Level 10
Joined
May 28, 2011
Messages
455
Mine is in Jass and struct. Wait. I just change your based on your code.

  • Events
    • Time - Every 10.00 seconds of game time
  • Conditions
  • Actions
    • Custom script: call BJDebugMsg("10 seconds passed")
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • Weather_Index Equal to 0
      • Then - Actions
        • Set Random_Index = (Random integer number between 1 and 2)
        • Custom script: call BJDebugMsg("Random number is " + I2S(udg_Random_Index))
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • Random_Index Equal to 1
          • Then - Actions
            • Environment - Create at (Playable map area) the weather effect Ashenvale Rain (Heavy)
            • Environment - Turn (Last created weather effect) On
            • Set Weather_Current = (Last created weather effect)
            • Set Weather_Index = Random_Index
            • -------- Further Actions for Ashenvale Rain Weather --------
          • Else - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • Random_Index Equal to 2
          • Then - Actions
            • Environment - Create at (Playable map area) the weather effect Dalaran Shield
            • Environment - Turn (Last created weather effect) On
            • Set Weather_Current = (Last created weather effect)
            • Set Weather_Index = Random_Index
            • -------- Further Actions for Dalaran Shield Weather --------
          • Else - Actions
      • Else - Actions
        • Custom script: call BJDebugMsg("Off weather")
        • Set Weather_Index = 0
        • Environment - Turn Weather_Current Off
        • Custom script: set udg_Weather_Current = null
 
Level 2
Joined
Feb 1, 2014
Messages
19
Mine is in Jass and struct. Wait. I just change your based on your code.

  • Events
    • Time - Every 10.00 seconds of game time
  • Conditions
  • Actions
    • Custom script: call BJDebugMsg("10 seconds passed")
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • Weather_Index Equal to 0
      • Then - Actions
        • Set Random_Index = (Random integer number between 1 and 2)
        • Custom script: call BJDebugMsg("Random number is " + I2S(udg_Random_Index))
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • Random_Index Equal to 1
          • Then - Actions
            • Environment - Create at (Playable map area) the weather effect Ashenvale Rain (Heavy)
            • Environment - Turn (Last created weather effect) On
            • Set Weather_Current = (Last created weather effect)
            • Set Weather_Index = Random_Index
            • -------- Further Actions for Ashenvale Rain Weather --------
          • Else - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • Random_Index Equal to 2
          • Then - Actions
            • Environment - Create at (Playable map area) the weather effect Dalaran Shield
            • Environment - Turn (Last created weather effect) On
            • Set Weather_Current = (Last created weather effect)
            • Set Weather_Index = Random_Index
            • -------- Further Actions for Dalaran Shield Weather --------
          • Else - Actions
      • Else - Actions
        • Custom script: call BJDebugMsg("Off weather")
        • Set Weather_Index = 0
        • Environment - Turn Weather_Current Off
        • Custom script: set udg_Weather_Current = null

thanks you lad , can u explain me Random_Index variable?
Or post a test map?
 
Last edited:
Level 3
Joined
Dec 31, 2003
Messages
42
I would use what wietlol suggested and then compare integer values. It leaks a lot less

  • pocasi init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Environment - Create at (Playable map area) the weather effect Ashenvale Rain (Light)
      • Set pocasi[0] = (Last created weather effect)
      • Environment - Turn (Last created weather effect) Off
      • Environment - Create at (Playable map area) the weather effect Dungeon White Fog (Heavy)
      • Set pocasi[1] = (Last created weather effect)
      • Environment - Turn (Last created weather effect) Off
      • Environment - Create at (Playable map area) the weather effect Ashenvale Rain (Heavy)
      • Set pocasi[2] = (Last created weather effect)
      • Environment - Turn (Last created weather effect) Off
      • Environment - Create at (Playable map area) the weather effect Northrend Snow (Heavy)
      • Set pocasi[3] = (Last created weather effect)
      • Environment - Turn (Last created weather effect) Off
  • pocasi zmena
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • Environment - Turn pocasi[pocasi_integer] Off
      • If - Conditions
        • pocasi_integer == 0
      • Then - Actions
        • -------- Undo the effects if the last effect was weather 0 --------
      • Else - Actions
        • If - Conditions
          • pocasi_integer == 1...
      • Set pocasi_integer = (Random integer number between 0 and 3)
      • If - Conditions
        • pocasi_integer == 0
      • Then - Actions
        • -------- Add your additional actions for weather 0 --------
      • Else - Actions
        • If - Conditions
          • pocasi_integer == 1...
      • Environment - Turn pocasi[pocasi_integer] On
 
Status
Not open for further replies.
Top