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

[Trigger] adding stats with percentage chance

Status
Not open for further replies.
Level 6
Joined
Sep 24, 2015
Messages
174
hey, why is the trigger not working, i used the damage engine trigger and it's still not giving any stats ...

  • stats
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
      • IsDamageSpell Equal to FALSE
      • (DamageEventTarget is A building) Equal to TRUE
      • (DamageEventSource has an item of type Elemental Essence - |c000000ffWater|r) Equal to TRUE
      • (Mana of DamageEventSource) Greater or Equal to 1045.00
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 3) Equal 3
        • Alors - Actions
          • Heros - Modify Strenght of DamageEventSource: Add 2
          • Heros - Modify Agility of DamageEventSource: Add 2
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Random integer number between 1 and 3) Equal to 1
            • Then - Actions
              • Heros - Modify Intelligence of DamageEventSource: Add 2
            • Else - Actions
      • Unit - Set mana of DamageEventSource to ((Mana of DamageEventSource) - 45.00)
 
Level 6
Joined
Sep 24, 2015
Messages
174
well, i don't understand why it is not working...i even followed the steps (requirements) for damage engine and it's still not working...

  • stats
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
      • IsDamageSpell Equal to TRUE
      • ((Owner of DamageEventSource) is an ally of (Owner of DamageEventTarget)) Equal to FALSE
      • (DamageEventSource has an item of type Elemental Essence - |c000000ffWater|r) Equal to TRUE
      • (Mana of DamageEventSource) Greater or Equal to 1045.00
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 3) Equal to 1
        • Then - Actions
          • Heros - Modify Intelligence of DamageEventSource: Add 1
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Random integer number between 1 and 3) Equal to 3
            • Then - Actions
              • Heros- Modify Agility of DamageEventSource: Add 2
              • Heros - Modify Strength of DamageEventSource: Add 2
            • Else - Actions
      • Unit - Set mana of DamageEventSource to ((Mana of DamageEventSource) - 45.00)
Please help. i really don't know why it is not working.
 
Level 6
Joined
Sep 24, 2015
Messages
174
it's okay i found the solution

and thx for the tips

@millzy nope it has to be False because it's not spell dmgs but physical
 
Last edited:
Level 6
Joined
Sep 24, 2015
Messages
174
well y, sorry mate my bad :/

here's the solution :

  • stats
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
      • ((Item carried by DamageEventSource of type Elemental Essence - |c000000ffWater|r) is owned) Equal to TRUE
      • (Mana of DamageEventSource) Greater or Equal to 1045.00
      • (DamageEventTarget is A Building) Equal to TRUE
      • IsDamageSpell Equal to FALSE
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 3) Equal to 1
        • Then - Actions
          • Heros - Modify Intelligence of DamageEventSource: Add 1
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Random integer number between 1 and 3) Equal to 3
            • Then - Actions
              • Heros - Modify Agility of DamageEventSource: Add 2
              • Heros - Modify Strenght of DamageEventSource: Add 2
            • Else - Actions
      • Unit - Set mana of DamageEventSource to ((Mana of DamageEventSource) - 45.00)
it has a 33% chance to add 1 int stat or 66% chance to add 2 str and 2 agi everytime you hit a non allied building.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
it has a 33% chance to add 1 int stat or 66% chance to add 2 str and 2 agi everytime you hit a non allied building.
As far as outcomes go it is actually 33.3...% of the time it will add 1 int stat, 22.2...% add 2 str and 2 agi and 44.4...% of the time add absolutely nothing at all (total is 100% so all cases covered). Maybe this is not what you intend?
 
Level 6
Joined
Sep 24, 2015
Messages
174
44% of giving nothing? why that? random integer between 1 and 3 isn't it 33% x 3?

i guess i'll let it like that it's to hard for me all these maths ahha i'm not a uni student bro^^
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
First you pick a random number between 1 and 3 and if equal to 1 then X otherwise Y.

X -> 33.3...% chance : add 1 int
Y -> 66.6...% chance : run else actions

In else actions you then pick another random number between 1 and 3 and if equal to 3 then do Z otherwise nothing.
Z -> 33.3...% chance : 2 str and 2 agi
Nothing -> 66.6...% chance

Y branch can be expanded with the results from the else actions as long as it is scaled appropriately.
X -> 33.3...% chance : add 1 int
Z -> 33.3...% * 66.6...% = 22.2...% chance : 2 str and 2 agi
Nothing -> 66.6...% * 66.6...% = 44.4...% chance
33.3...% + 22.2...% + 44.4...% = 100%

Maybe explain what you want to happen and others can help you to achieve the desired probability?
everytime you hit a non allied building.
I do not see any test for if the building was not an ally.
 
Level 6
Joined
Sep 24, 2015
Messages
174
hmm i could do till y branch but rest is to hardcore for me haha

you think if i don't set a condition for non allied building the trigger could run even if i disabled friendly fire?

i just want add chances on an item.

with every hit you have 33% chance to gain 1 int stat or 67% chance to get 2 str and 2 agi...

with a result of 100% chances in total.

not 66% with 0 chances...i don't know if I was clear :/

like dr said but remove the 44% chances of doing nothing
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
you think if i don't set a condition for non allied building the trigger could run even if i disabled friendly fire?
It could not run on allies if friendly fire is disabled. In which case mentioning the ally part is kind of pointless and confusing.
with every hit you have 33% chance to gain 1 int stat or 67% chance to get 2 str and 2 agi...
This should work.
  • stats
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
      • ((Item carried by DamageEventSource of type Elemental Essence - |c000000ffWater|r) is owned) Equal to TRUE
      • (Mana of DamageEventSource) Greater or Equal to 1045.00
      • (DamageEventTarget is A Building) Equal to TRUE
      • IsDamageSpell Equal to FALSE
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 3) Equal to 1
        • Then - Actions
          • Heros - Modify Intelligence of DamageEventSource: Add 1
        • Else - Actions
          • Heros - Modify Agility of DamageEventSource: Add 2
          • Heros - Modify Strenght of DamageEventSource: Add 2
      • Unit - Set mana of DamageEventSource to ((Mana of DamageEventSource) - 45.00)
 
Level 6
Joined
Sep 24, 2015
Messages
174
ah i see if you add more random integer it gives you other probabilies? or am i wrong...i really try to understand these things xd

and thank you very much for your help.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
ah i see if you add more random integer it gives you other probabilies? or am i wrong...i really try to understand these things xd
I suggest paying more attention to mathematics at high school. What you were after doing is no different than rolling a dice where numbers 1 and 2 do X and numbers 3, 4, 5 and 6 do Y, a typical high school mathematics problem.

If you want more than 2 outcomes then save the random number (dice roll) to a variable and then test that variable for the appropriate causes using nested if then else actions. Since there are only 2 outcomes in the above case there is no need for any nesting as one does not need to test the second condition by the assumption that it is always the second condition if not the first as the total must add up to 100%.
 
Status
Not open for further replies.
Top