• 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.
  • Create a faction for Warcraft 3 and enter Hive's 19th Techtree Contest: Co-Op Commanders! Click here to enter!
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 21st Texturing Contest: Upgrade is now concluded, time to vote for your favourite set of icons! Click here to vote!

Chance by Hero Level

Status
Not open for further replies.
Level 33
Joined
Mar 27, 2008
Messages
8,035
What happens if the level of the killed unit is greater than the level of the killer unit ?
It will return as < 0 (which returns Real, not Integer).

  • Actions
    • Set StatGainChance = ((Level of (Triggering unit)) / (Hero level of (Killing unit)))
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Random integer number between 1 and 100) Less than or equal to StatGainChance
      • Then - Actions
        • -------- THIS BLOCK IS SUCCESS BLOCK --------
      • Else - Actions
        • -------- THIS BLOCK IS FAIL BLOCK --------
 
Level 11
Joined
Aug 6, 2009
Messages
697
Thanks. I ended up doing this:

  • Stat Gain
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Killing unit) is A Hero) Equal to True
    • Actions
      • Set StatGainChance = (Real((Random integer number between 0 and (Hero level of (Killing unit)))))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • StatGainChance Less than or equal to (Real((Level of (Dying unit))))
        • Then - Actions
          • Hero - Modify Strength of (Killing unit): Add 5
          • Hero - Modify Agility of (Killing unit): Add 5
          • Hero - Modify Intelligence of (Killing unit): Add 5
        • Else - Actions
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
You should make the random starts from 1 to n because you will have a zero error calculation.

Let's say you want to random a 10% chance, you would do this;
  • (Random integer number between 1 and 10) Less than or equal to 1
The detail is like this:
1, 2, 3, 4, 5, 6, 7, 8, 9, 10.

The total number would be ? Yes, 10% chance.

But let's say you do this;
  • (Random integer number between 0 and 10) Less than or equal to 1
The detail is like this:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10.

The total number would be ? Yes, this is 20% (18% to be exact) chance, and this is zero error I mentioned earlier, it would defect your calculations.
 
Status
Not open for further replies.
Top