Slime
Active Member
- Joined
- Jan 25, 2014
- Messages
- 115
- Reaction score
- 33
I'm remaking def into sort of dodge system. I want it to work like this: if the damage dealt to the player is lower or equal to his defense rate there's 80% chance he will dodge it and 20% chance that he will get 100% damage (not including ARM reductions). I'm almost there
if(checkDefense && hasDefense)
{
int32_t maxDefense = getDefense(), minDefense = 0;
damage -= random_range(minDefense, maxDefense);
if(damage <= 0)
{
damage = 0;
blockType = BLOCK_DEFENSE;
checkArmor = false;
}
}
The only thing I need is to make "damage-" value being chosen randomly out of these 2 values, not between (20% chance for minDefense aka 0 and 80% chance for maxDefense).
@Edit
Now I think it's not all that has to be done. If random_range chooses maxDefense and damage is higher than maxDefense, the damage will be reduced which is the thing I don't want. When dodge fails there shouldn't be any damage reduction (except for arm). Can someone help me with reworking this?
if(checkDefense && hasDefense)
{
int32_t maxDefense = getDefense(), minDefense = 0;
damage -= random_range(minDefense, maxDefense);
if(damage <= 0)
{
damage = 0;
blockType = BLOCK_DEFENSE;
checkArmor = false;
}
}
The only thing I need is to make "damage-" value being chosen randomly out of these 2 values, not between (20% chance for minDefense aka 0 and 80% chance for maxDefense).
@Edit
Now I think it's not all that has to be done. If random_range chooses maxDefense and damage is higher than maxDefense, the damage will be reduced which is the thing I don't want. When dodge fails there shouldn't be any damage reduction (except for arm). Can someone help me with reworking this?
Last edited: