• 🏆 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!
  • ✅ Time to vote for the top 3 models! The POLL for Hive's 6th HD Modeling Contest: Mechanical is now open! 📅 Poll close on July 16, 2024! 🔗 Cast your vote now!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

Chance to deal various spell effects

Status
Not open for further replies.
Level 3
Joined
Feb 27, 2011
Messages
39
If you mean 10% chance to give an item and 10% chance to give an ability then you could try this:
  • Untitled Trigger 001
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Random integer number between 1 and 100) Less than or equal to 35
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 35) Less than or equal to 10
        • Then - Actions
          • Item - Create item at (Position of (Triggering unit))
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Random integer number between 1 and 35) Less than or equal to 10
            • Then - Actions
              • Unit - Add ability to (Triggering unit)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Random integer number between 1 and 35) Less than or equal to 5
                • Then - Actions
                  • Item - Create greater item at (Position of (Triggering unit))
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Random integer number between 1 and 35) Less than or equal to 5
                    • Then - Actions
                      • Unit - Add greater ability (Triggering unit)
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Random integer number between 1 and 70) Less than or equal to 5
                        • Then - Actions
                          • Item - Create insane item at (Position of (Triggering unit))
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (Random integer number between 1 and 70) Less than or equal to 5
                            • Then - Actions
                              • Unit - Add insane ability to (Triggering unit)
                            • Else - Actions
I dont guarantee its correct though
 

Attachments

  • chance trigger testmap.w3x
    12.8 KB · Views: 52

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,233
1. roll a random number. Usually it is an integer in range of 1 - 100 but it can be any range really if you want lower chances.
2. Test the random number for certain number ranges. If you tested if it was equal to 1 for example it would have a 1 in 100 chance of running the code in an if statement.
3. Do your actions, whatever actions you want, do them.

If it does not work, make sure that the code is reachable and make sure the events fire and conditions actually do evaluate. If items spawn in the middle of the map, then they must be getting a null location or the position of null.
 
Level 6
Joined
Dec 9, 2010
Messages
121
DevBoyz, are you using the Test Map option inside the World Editor? Because if that's the case, you may be generating the same random seed each time you run the trigger (because of a preference in the World Editor). If this is the case, your trigger could be working, but you are just not seeing it, because the random seed is not within the range of integers you are checking for. See this thread: http://www.hiveworkshop.com/forums/world-editor-help-zone-98/random-190919/
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
In Warnem55's trigger the propabilities are a bit off.

Here's how you could do it:
  • Untitled Trigger 011
    • Events
    • Conditions
    • Actions
      • Set i = (Random integer number between 1 and 100)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • i Less than or equal to 20
        • Then - Actions
          • -------- 20% chance to go here. Do what you want. --------
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • i Less than or equal to 30
            • Then - Actions
              • -------- 10% chance to go here. Do what you want. --------
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • i Less than or equal to 35
                • Then - Actions
                  • -------- 5% chance to go here. Do what you want. --------
                • Else - Actions
                  • -------- 65% chance to go here --------
 
Status
Not open for further replies.
Top