• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Remaking DEF into Dodge/Flee Rate - a simple C++ question

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?
 
Last edited:
bump
@edit
The way it's now:

if(checkDefense && hasDefense)
{
int32_t maxDefense = getDefense();
int32_t fleefail = random_range(0, 100);
if (damage <= maxDefense)
{
if (fleefail<=80)
damage = 0;
blockType = BLOCK_DEFENSE;
checkArmor = false;
}
}

But it doesn't work for some reason, still if damage>maxdefense player gets always hit and when damage<=maxdefense he always dodges.
 
Last edited:
Back
Top