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

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