# Chance by Hero Level

Status
Not open for further replies.

#### Assassins-Creed

Level 11
I want to make it so if a unit kills another unit then it has a chance to gain a stat based on levels. I'm not quite sure how to implement the chance part after doing this:

• Set StatGainChance = ((Level of (Dying unit)) / (Hero level of (Killing unit)))
Any ideas?

#### defskull

Level 33
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 --------

#### Assassins-Creed

Level 11
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

#### defskull

Level 33
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.

#### Assassins-Creed

Level 11
I changed it to 1,thanks! I would +Rep you but I just did on my other thing aswell :I

Status
Not open for further replies.

Replies
2
Views
719
Replies
5
Views
872
Replies
3
Views
526
Replies
1
Views
641
Replies
6
Views
455